liveBook · Manning

Extrapolation

As explained in How Large Language Models Work

The process of extending a pattern or method beyond the examples or cases from which it was learned.

Extrapolation extends a learned pattern beyond the examples that support it. For language models, familiar or structurally similar tasks often produce useful results, but reliability decreases as a task becomes more unique. section 4.3

From Python to Modula-3

A model correctly writes Python code to calculate pi because many similar examples exist online. Translating that function to obscure Modula-3 requires a larger leap, so the result contains three errors. The model confidently imports conventions from other languages, including an exponentiation operator that Modula-3 may not support. section 4.3

Listing 4.2 ChatGPT calculates pi in Modula-3
MODULE CalculatePi;  #1

IMPORT IO, Real;

PROCEDURE CalculatePi(terms: INTEGER): REAL;
VAR
  pi: REAL := 0.0;
  i: INTEGER;
BEGIN
  FOR i := 0 TO terms - 1 DO
       pi := pi + ((-1.0) ** FLOAT(i)) / (2.0 * FLOAT(i) + 1.0);  #2
  END;
  RETURN 4.0 * pi;
END CalculatePi;

BEGIN
  IO.PutReal(CalculatePi(1000000), 0, 15);  #3
END CalculatePi.

Inspect the Modula-3 translation to see how familiar coding patterns can look plausible while producing nonworking code. section 4.3

Treat extrapolated output as a plausible starting point, not automatic evidence of correctness:

  • Expect stronger results for common tasks with abundant examples. section 4.3
  • Increase scrutiny when the language, problem, or combination is unusual. section 4.3
  • Watch for confident assumptions borrowed from related languages or patterns. section 4.3

How How Large Language Models Work covers it

How deep it goes
Demonstrates the mechanism through code comparisons and failure analysis, stopping short of formal mathematical treatment.
Examples
Compares Python and Modula-3 programs that calculate pi, including an invented-looking exponentiation operation.
What it assumes
Assumes only familiarity with programming examples and explains reliability through similarity and novelty.
What you can do after
Evaluate generated code skeptically when a task is novel, obscure, or poorly represented in available examples.
How it connects
Connects extrapolation with training data, language models, programming languages, and code generation.

Also explained in

Compare how 3 books explain extrapolation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of How Large Language Models Work. The section links point to the parts of the book it draws on.