Brown University crest
CPSY 1291 Computational Methods for Mind, Brain & Behavior
Lecture 17 · Theme 3: Dynamics, sequences & world models

Large language models and the brain

Tuesday, November 17 · Fall 2026

Reader-friendly version — lecture content with figure descriptions

Finish the sentence

He spread the warm bread with ___

Finish the sentence

He spread the warm bread with ___
  • Most of you thought butter: you predicted the next word, as our language models do
  • socks (from the attention lecture) → larger EEG response ~400 ms after the word: the N400
  • A language model assigns every word a surprisal (how unexpected it is). Does surprisal predict reading times and N400 size?

Kutas and Hillyard 1980, Fig. 1A: the average EEG at the back of the scalp while people read three seven-word sentences one word per second, plotted with negative up. The traces are similar until the last word. It was his first day at work, solid, ends flat; He spread the warm bread with socks, dashed, gives a large negative peak about 400 ms after socks, labeled N400; She put on her high heeled SHOES, with the last word in large type, dotted, gives a positive peak labeled P560

Scaling up the language model

The same transformer, trained on more text than anyone could read

Where we left off

  • Next-token transformers are generative models: sample a token, append it, repeat → text. Same principle behind image and video generators, and world models (later in the course)
  • Transformer + self-supervised training (as in vision) → here the target is the next token, so any text is training data (pretraining)
  • Today: (1) scaling up: scaling laws, tokens, data, in-context learning, assistants (instruction tuning, RLHF, tools); (2) large language models (LLMs) as models of readers and brains: surprisal, reading times, the N400, encoding models; (3) predictive coding

Scaling laws: the loss falls smoothly with size

Figure 1 of Kaplan et al.: three log-log panels of test loss against compute, dataset size and parameters, each a straight line, a power law, over several orders of magnitude; the fitted exponents are minus 0.050, minus 0.095 and minus 0.076

  • A striking finding of modern AI: test loss (cross-entropy, held-out text) falls predictably with scale, a power law (line on log–log axes) in compute (PF-days), data, parameters. Left: one curve per model size; black = best loss
  • Why a law? A frontier run takes months → fit small runs first and predict the large run's loss before committing

From characters to word pieces

  • Scale is counted in tokens and parameters. Token = the unit the transformer reads: characters in our assignment model, word pieces in GPT-2. How is the vocabulary chosen?
  • Byte-pair encoding (BPE):
    1. Start with all 256 possible byte values (letters, digits, punctuation, and pieces of other characters)
    2. Count every pair of neighboring tokens in a large text; merge the most frequent pair into one new token (t + h → th)
    3. Repeat: merged tokens can merge again (th + e → the); old tokens stay
    4. Stop at the chosen vocabulary size

Word pieces in GPT-2

  • Frequent words → one token; rare strings stay in pieces: brain, neuroscience → one token each · tokenization → token + ization · surprisal → surpr + isal · the made-up Zorblat → Z + or + bl + at
  • GPT-2: 256 bytes + 50,000 merges + 1 end-of-text token = 50,257 tokens
  • Vocabulary sizes range ~8×, in tokens: Llama 2 32 K · GPT-2 50 K · GPT-4 ~100 K · Llama 3 128 K · Qwen2.5 ~152 K · GPT-4o ~200 K · Gemma 256 K
  • Larger vocabulary → fewer tokens per text, better coverage of other languages
  • Rule of thumb for English: 1 token ≈ 0.75 words (100 tokens ≈ 75 words)

How much text do modern LLMs use?

Data, the first ingredient of scale, counted in tokens: how much do models read?

  • Llama 3 (Meta, 2024): ~15 T tokens ≈ 130 M books, about every book ever published
  • Newer open models:
    • Qwen3 (Alibaba, 2025): ~36 T tokens
    • Llama 4 (Meta, 2025): > 30 T tokens of text, images and video
    • DeepSeek-V3 (2024): 14.8 T tokens; later V3 versions continue from it
  • The web: ~510 T tokens indexed by search engines, ~3,100 T in all; ~300 T of usable public text → used up between 2026 and 2032 at the current pace
  • A child hears ~130 M tokens by age 13 → Llama 3 reads ~100,000× more

T = trillion · B = billion · M = million · web figures are estimates

Model size: the largest are undisclosed

Model Year Built by Training tokens Parameters
GPT-2 2019 OpenAI ~0.01 T 0.1 – 1.5 B
GPT-3 2020 OpenAI 0.3 T 175 B
Chinchilla 2022 DeepMind (Google) 1.4 T 70 B
Llama 3 2024 Meta 15 T 8 – 405 B
Frontier models 2023 on OpenAI, Google, … ? ?
  • Frontier models: the most capable ones (GPT, Claude, Gemini), closed, size and data undisclosed
  • A growing gap: academic labs, including brain research, use open models (GPT-2, Pythia, Llama, OLMo), far below the frontier in scale and ability

Compute: the third ingredient

Scatter plot from Epoch AI's dataset of notable AI models: training compute in floating-point operations, log scale from 10 to the 16 to 10 to the 28, against publication year, 2017 to 2026, for 286 language models. A fitted line rises about 6.2 times per year. Labeled: GPT-2 in 2019 at about 2 times 10 to the 21; GPT-3 in 2020 at about 3 times 10 to the 23; Chinchilla in 2022 at about 6 times 10 to the 23; GPT-4 in 2023 at about 2 times 10 to the 25; Gemini 1.0 Ultra in late 2023 at about 5 times 10 to the 25; Llama 3.1-405B in 2024 at about 4 times 10 to the 25; and GPT-6 Astra in 2026, the largest, at about 9 times 10 to the 26

  • Training compute of language models: ~6× more every year (fit to 276 models, 2018–2026) → GPT-2 to today's largest: ~500,000× in seven years

Scaling laws in practice

Data, parameters, compute: how should a fixed compute budget be split between model size and data?

  • Chinchilla (2022): a fixed compute budget buys a bigger model or more training text (cost ∝ parameters × tokens)
    • Gopher: big model, 280 B parameters, trained on 300 B tokens
    • Chinchilla, same cost: 4× smaller (70 B), so it can read ~5× more new text (1.4 T tokens) → lower loss
    • Gopher was too big for its data. Rule: ~20 training tokens per parameter (1.4 T ÷ 70 B)
  • Yet small models are trained far past this (Llama 3 8B: 15 T tokens ≈ 1,900 per parameter): a bigger model would be better for the same training cost, but a small one is cheaper to run each time it answers, over billions of questions
  • Lower loss ≠ ability, yet abilities thought to need special architectures came with scale → the bitter lesson: general methods that use more compute win (Sutton 2019)

Do large models converge?

As models scale, do they also become alike?

  • Take images with their captions. A vision model (images only) and a language model (captions only) each group similar items: dog near wolf, far from car. The bigger the two models, the more their groupings agree
  • Platonic representation hypothesis: scale drives models toward one shared statistical model of reality, the process that generated the data
  • Debated: the evidence rests on a few alignment measures, and counterexamples exist
  • If true → a brain, shaped by the same world, might converge on the same representation. Later today: language models compared with brains

In-context learning: what a prompt looks like

  • Before GPT-3: new task → fine-tuning: keep training the pretrained weights on labeled examples of that task (like readouts on vision networks). A pretrained model reused this way is a foundation model
  • In-context learning: give the task in the prompt, weights fixed → one model, many tasks (as people learn a task from a few examples)
  • Example task, never trained for: remove the random symbols from a word
    • Zero-shot: the instruction, no examples → relies on pretraining (instructions followed by answers are common in web text)

      Remove the symbols from the word. b!r.a/i n =

    • Few-shot: a few solved examples, then a new word (one example: one‑shot)

      s.u!c/c!e.s s i/o/n = succession · p,l.a!n e/t = planet · b!r.a/i n =

    • The model continues the text with brain: only the examples tell it the rule

In-context learning

Accuracy against the number of examples in the prompt, from zero-shot through one-shot to few-shot, for three GPT-3 sizes. The 175-billion-parameter model climbs from under to about 67%; the 13-billion model reaches about and the 1.3-billion model stays below 5%. Solid lines add a natural-language description of the task, dashed lines do not

In the figure: solid = prompt opens with a one-sentence instruction ("Please unscramble the letters…"); dashed "No Prompt" = examples only, no instruction

  • Published result, GPT-3 on the task of the previous slide: accuracy grows with the number of examples and with model size. No weight changes. Next: our replication with GPT-2

Our replication: in-context learning in GPT-2

Antonyms correct in percent against the number of solved examples in the prompt, 0, 1, 2, 4 and 8, for GPT-2 small, medium and large. Small stays below 10 percent at every count. Medium rises from 0 to 22, 64, 88 and 94 percent; large from 4 to 25, 81, 92 and 96 percent

Computed for this course: GPT-2 small, medium and large, weights as trained · antonym task · 32 pairs, 24 test words × 3 random orders per point

  • Prompt: hot -> cold, big -> small, … wet ->. 8 examples: medium and large 94–96%, small < 10%; 0 examples: all ≈ 0 → the examples define the task; only the larger models use them

In-context learning: surprising results

Beyond accuracy curves: what does the model take from the examples?

  • A new language from one book: Kalamang (< 200 speakers, almost no web text). With a grammar book in its prompt, Gemini 1.5 translates English → Kalamang about as well as a person who learned from the same book
  • Wrong labels in the examples (task: is a movie review positive or negative?):
    • Random labels on the examples: accuracy barely drops → the examples mostly show the format and the possible answers
    • Flipped labels (positive reviews labeled "negative" and vice versa): large models flip their answers too, following the prompt over what they learned in pretraining; small models keep answering correctly
  • More examples keep helping: with long contexts, hundreds to thousands of examples (many-shot) → further gains

Where in-context learning comes from

Nobody trained for this ability: where does it come from?

Figure 1.1 of Brown et al.: an outer loop, learning by stochastic gradient descent during pretraining, runs across many text sequences; within each sequence an inner loop of in-context learning runs down a list of examples of one task: additions such as 5 + 8 = 13, unscrambled words such as gaot => goat, and English to French translations such as thanks => merci

  • GPT-3's account: pretraining contains two nested loops (figure), one that changes the weights and one that does not → next slide

Two loops during pretraining

Ordinary next-token training, described as two loops:

  • Outer loop: gradient descent across millions of documents; the weights change
  • Inner loop: within one document, e.g. hot → cold · big → small · wet →. From wet → alone, dry is a guess; using the two examples before it, it is easy. No weight changes, only the context grows
  • The loss scores every token, dry included, and documents like this are everywhere on the web → gradient descent favors weights that use the examples: meta-learning
  • Your prompt is a new document: at use time, only the inner loop runs

Mechanism 1 (last lecture): induction heads copy

Two bands of word boxes for The black cat sat on the mat. The black, the last black marked as the current position. Top band, block 1, a previous-token head: an arrow from each word to the next, and the first cat receives a tag reading previous: black. Bottom band, block 2, an induction head: the query of the last black, find previous = black, matches the key of the first cat, previous: black, along a curved gold arrow; the value of cat, cat, flows to a box reading predict: cat. A faint dashed arrow from the last black back to the first black is labelled one head alone: finds black, reads back black

  • Previous-token head tags each token with the one before; at the second black, the induction head finds the token tagged "previous: black" → copies cat. Forms abruptly in training, when in-context learning jumps (Olsson et al.)

Mechanism 2: heads that encode the task

Figure 1a of Yin and Steinhardt: few-shot in-context-learning accuracy of Pythia 6.9B as a growing percentage of its attention heads is ablated. Clean and random-ablation lines stay flat near 0.56; ablating induction heads lowers accuracy slowly to 0.44 at 20 percent; ablating function-vector heads drops it to about 0.32 at 3 percent, 0.20 at 9 percent and 0.18 at 15 percent

In the figure: ICL = in-context learning · FV = function-vector heads · ablation = knockout

  • Function-vector heads: a few heads, the same for every task, whose output vector encodes which task the examples show (antonym, capital of, …)
  • Knock out FV heads → few-shot accuracy falls to about a third; knock out induction heads → it drops only a little. Copying ≠ learning a task from examples (12 models, up to 6.9 B parameters)

Mechanism 3: learning without backprop

Third account: can a forward pass itself carry out a learning algorithm?

  • In-context learning is learning without backprop: the forward pass itself does the fitting
  • Test case: put pairs (x, y) from a line in the prompt, then a new x → the transformer predicts y as least squares or ridge regression would
  • How: one attention layer (without softmax) can carry out one gradient-descent step on the examples in its prompt; the weights never change

The same recipe in real systems

What a 2026 model is, and what every prompt does

From GPT-2 to today's assistants

Same recipe, GPT-2 to today: what changed?

  • 2019, GPT-2: writes fluent paragraphs from a prompt
  • 2020, GPT-3: learns new tasks from a few examples in its prompt
  • 2022, ChatGPT: GPT-3.5 trained further to follow instructions and hold a conversation (next slides)
  • 2023 on, frontier assistants: OpenAI GPT-4 and GPT-5, Anthropic Claude, Google Gemini (closed); Meta Llama, DeepSeek, Alibaba Qwen (open weights)
  • 2024–25, reasoning models (OpenAI o1, DeepSeek-R1): write out steps before answering (see Reasoning, below)
  • The core has not changed since GPT-2: a transformer pretrained to predict the next token; what changed is the scale and the training that comes after

From autocomplete to assistant

Figure 2 of Ouyang et al.: three steps. Step 1, a labeler writes a good answer to a prompt such as Explain the moon landing to a 6 year old, and GPT-3 is fine-tuned on these demonstrations. Step 2, the model writes several answers to a prompt, a labeler ranks them from best to worst, and the rankings train a reward model. Step 3, for a new prompt such as Write a story about frogs, the model writes an answer, the reward model scores it, and the score updates the model by reinforcement learning

  • RLHF (reinforcement learning from human feedback), InstructGPT's recipe: SFT (supervised fine-tuning) on demonstrations → reward model fit to human rankings → PPO against it

After InstructGPT: simpler and checkable rewards

RLHF is costly: later post-training drops the reward model, then the human labels.

  • DPO (direct preference optimization): learns from the same human choices between two answers, with no reward model and no reinforcement-learning loop
  • Reinforcement learning from verifiable rewards: reward answers a program can check (a math result, code that passes its tests) → no human labels needed → reasoning models (next slides)
  • All these stages keep training the same pretrained network: post-training

Writing an answer is choosing a path

Why would writing out steps help a model answer?

Illustrative tree of token choices for the prompt 17 times 24 equals. The top path takes the most likely next token at every step, 3, 9, 8, and ends in 398, marked wrong. Three other paths write intermediate steps: 17 times 20 is 340, 17 times 4 is 68, 340 plus 68 is 408; 24 times 17, 24 times 10 is 240, 24 times 7 is 168, 240 plus 168 is 408; and 17 times 25 is 425, 425 minus 17 is 408. All three end in 408, marked correct. Faint grey stubs branch off the nodes, showing other possible continuations

  • An answer is a path through a huge tree of continuations: the most likely token at every step (greedy) can dead-end; many paths reach the goal
  • Intermediate steps make the next ones easy → writing them out helps (next slide)

Reasoning: thinking in tokens

Two ways to get intermediate steps: prompt for them, or train for them.

  • Chain of thought: worked solutions with intermediate steps in the prompt → large models write steps too and solve far more math word problems (8 examples: state of the art for a 540 B model)
  • No examples needed: add "Let's think step by step" → large gains on arithmetic and logic tasks
  • Reasoning models (OpenAI o1, DeepSeek-R1): reinforcement learning on answers a program can check, no human-written reasoning → step-by-step answers, self-checking and backtracking emerge
  • More tokens = more computation per answer (test-time compute) → thinking longer helps on hard problems

Inside a 2026 model

Same pretrained core, seen from inside: how do models grow without cost growing with them?

  • Mixture of experts: each block's MLP is split into many smaller MLPs, the "experts"; for each token, a learned router picks a few experts and only those run → DeepSeek-V3: 671 B parameters in total, 37 B used per token
  • Multimodal: image patches as tokens → one transformer for text and images
  • Long context, growing fast: GPT-3 (2020) 2 K tokens → GPT-4 Turbo (2023) 128 K → Gemini 1.5 (2024) 1 M → Llama 4 Scout (2025) 10 M, dozens of novels
  • Hybrids: many long-context models replace most attention layers with recurrent ones, which are cheaper on long inputs (next lecture)

Every prompt is in-context learning

Back to the prompt: what does an assistant read before it answers?

  • One long context: the provider's instructions, your earlier messages, any examples you give, and text the system adds for you, such as web pages, files and tool results. Adding retrieved text this way is retrieval-augmented generation
  • The model draws on two sources. The weights hold what it learned in pretraining; the context holds what you and the system have written so far. Only the context changes during a conversation
  • The weights do not learn from your conversation: when the context is gone, so is everything in it. Saved "memories" are text put back into a later context
  • Long contexts are expensive: the KV cache (keys and values of every token, last lecture) must be stored → a 1 M-token window needs a lot of memory

Tools and agents

The context can also hold tool results: the model's text triggers actions.

  • Two actors: the model only writes text; the system, an ordinary program around it, runs tools and pastes their results into the model's context
  • Tool call: the model writes search("Natural Stories reading times") → the system runs the search → the results go into the context
  • Agent = model + system in a loop: the model writes code → the system runs it → the model reads the error and writes a fix → … until the task is done
  • Everything the agent knows about your task sits in its growing context → it can lose track of a long task

A model of the reader, and of the brain?

Two tests of the same model: word probabilities → reading times and N400; internal activations → brain responses

Surprisal: how unexpected a word is

First test: do a model's word probabilities predict readers and the N400?

surprisal(wi)=−log⁡2p(wi∣w1,…,wi−1) bits\mathrm{surprisal}(w_i)=-\log_2 p\big(w_i\mid w_1,\dots,w_{i-1}\big)\ \text{bits}

  • Surprisal: how unexpected a word is given the words before it. 0 bits = certain; 10 bits ≈ a probability of 1/1,000. Same as the per-word training loss, in bits instead of nats
  • Surprisal theory (psycholinguistics, before LLMs): reading time (how long readers spend on a word) grows ~linearly with surprisal
  • N400 (opening sentence): larger for unexpected words → LLM surprisal predicts its size word by word
  • An LLM gives the surprisal of every word in any text → both predictions can be tested at scale

Surprisal from a real model, token by token

What does surprisal look like from a real model?

Bar chart of surprisal in bits for each token of the sentence My grandmother's recipe calls for two cups of flour and a pinch of salt, three bars per token for GPT-2 small, medium and large. Grandmother is the most surprising token, 14.5 bits for the small model and about 8.5 for the larger two; recipe about 8 to 10 bits; for and the second of are near zero for every model; salt is near zero. Means 4.0, 3.5 and 3.3 bits

Real computation: GPT-2 small, medium and large, weights as trained · a dot marks a token that begins with a space

  • Each bar is −log⁡2-\log_2 of the probability the model gave the token that actually came next. Function words (small grammar words: for, of, a) cost almost nothing; the first content word (noun, verb, adjective), grandmother, costs 14.5 bits. Bigger model, fewer bits: 4.0 → 3.5 → 3.3 on average

What it means to predict reading times

From per-word surprisal to a test against readers' behavior.

Two aligned bar charts for the sentence Seeds from a tulip will form a flowering bulb after seven-twelve years: mean reading time per word on top, from 314 to 873 ms, and GPT-2 small surprisal per word below. The word seven-twelve has the largest surprisal, 24.8 bits, and a slow reading time of 585 ms; the next word, years, is read slowest, 873 ms, at only 8.4 bits

Real computation: Natural Stories self-paced reading times · GPT-2 small surprisal, whole story as context

  • Self-paced reading: readers press a key to reveal each word. The unexpected seven-twelve (24.8 bits) slows them down, and the slowdown spills onto the next word. Next: the whole story

Reading time against surprisal, the whole story

Scatter plot of mean reading time in milliseconds against GPT-2 small surprisal in bits for the 1,038 words of one Natural Stories story. Most words have surprisal under 15 bits and reading times between 300 and 450 ms. A line of binned means rises slowly from about 340 ms to about 370 ms up to 17 bits, then to about 570 ms near 28 bits. Two words are highlighted: seven-twelve at 24.8 bits and 585 ms, and years at 8.4 bits and 873 ms. Text in the corner: r = 0.30, n = 1038 words

Real computation: Natural Stories, one story · GPT-2 small, whole story as context · dot = one word · line = mean per bin

  • More surprising words are read more slowly, r = 0.30, with a lot of scatter: surprisal explains ~9% of the variance. Next: what surprisal adds beyond word length and frequency

Against human readers: bigger is not better

Scatter plot of regression log-likelihood gain against perplexity on Natural Stories self-paced reading, for GPT-2 small to XL, five GPT-Neo and eight OPT models with dashed least-squares lines per family. Every family slopes the same way: the smallest models, with the highest perplexity, give the largest gain near 600 to 640, and the largest models, 20 to 66 billion parameters, the smallest, near 380 to 400

Each dot = one model (label = size) · left = lower perplexity, better text prediction · up = better fit to reading times · in every family, bigger models sit lower

  • ΔLL: gain in fit to reading times when surprisal is added to word length and frequency. Better text prediction → worse fit to readers, as better ImageNet models became worse models of IT

Try it: what did the model expect?

  • For you to try at home: a real 8 B model's surprisal for each word, and what it expected instead

Better language model, better brain model?

Reading times disagree with scale: what about brain responses?

  • Brain responses: yes, so far. Models that predict the next word better also predict brain responses to language better. This holds in fMRI (blood oxygenation, whole brain, a few seconds' resolution) and ECoG (electrodes on the surface of the cortex, milliseconds), and the fit grows logarithmically with size up to 30-billion-parameter models
  • Measured with an encoding model: a ridge readout from the model's activations to each voxel or electrode, as for IT
  • Reading times: no, past a point. Surprisal from larger models fits readers worse (previous slide)
  • Open: brain data and reading times disagree about the best model. Possible reason: a large model has read far more text than any person, so it finds words predictable that a reader does not

Using the model to control the brain

Figure 2 of Tuckute et al.: A, the left-hemisphere language network on an inflated brain; B and C, bar charts of the language network's fMRI response to drive, suppress and baseline sentences, in an event-related design with three participants and a blocked design with four. Drive sentences give the highest response and suppress sentences the lowest in both; D, example sentences: drive sentences are odd or ungrammatical, such as Jiffy Lube of, of therapies, yes; suppress sentences are plain, such as We were sitting on the couch

  • Encoding model: GPT-2 XL → fMRI of the language network (areas more active for sentences than nonwords). It then picks new sentences to raise or lower the network's response → confirmed in new participants

The brain as a prediction machine

  • Predictive coding: the brain runs an internal generative model, predicts its input, and passes up only the prediction error, the part the prediction did not explain
  • In language: surprisal tracks N400 size and reading time → consistent with prediction
  • With GPT-2: adding the model's activations for the next ~8 words improves the fMRI fit → brain activity carries information about upcoming words
  • Still a hypothesis: recordings across cortical layers show feedback that enhances predicted activity rather than cancelling it. Details in Going further

Open questions

  • Brain or behavior? Which should a cognitive model answer to? Would a model trained on about as much text as a person reads fit both?
  • Does the brain predict, or only carry information about what comes next? Brain activity that fits better when GPT-2 sees upcoming words shows that the brain holds information about the future. It does not show that the brain sends prediction errors up, as predictive coding says
  • In-context learning in a brain? A model learns a task from its prompt with frozen weights, in its activations. Is some fast human learning also held in activity rather than in changed synapses? → Next lecture: recurrent networks, which also hold context in activity

Recap

  • An LLM is a decoder transformer trained to predict the next token (word pieces from byte-pair encoding) on a very large amount of text
  • In-context learning emerges from next-token training (no separate objective): GPT-2 medium and large show it, every prompt uses it, weights stay fixed
  • Surprisal in bits, −log⁡2p-\log_2 p, from LLMs tracks brain responses, the N400 and reading times, but larger models fit readers worse while fitting the brain better, and a brain fit needs its controls
  • Predictive coding: the brain may predict its input and send errors up; the evidence runs both ways

The assistant you may use on the project

  • The AI assistants you may use on the project are the models from today
  • They are trained to produce likely text, which is not always true text. So they hallucinate: they invent citations and results that look plausible. They are also prompt-sensitive: rephrase a question and the answer can change
  • Contamination: public test questions end up in the training text → a model can answer them from memory, so a high benchmark score can overstate its ability. Testing an LLM in your project? Use items it cannot have seen
  • So check every claim and citation an assistant gives you against its source; the writer–critic workflow from recitation does this systematically

For your final project

  • Dates: teams registered on Canvas Thu 11/19 · proposal, one page per team, Sun 12/6 at 11:59 PM (moved from Wed 12/2) · poster session and report Mon 12/21 at 9:00 AM
  • Data and models: anything from the lectures and assignments, or anything else you can get your hands on; GPT-2 or Pythia for surprisal run on the course Colab
  • AI tools: allowed on the project, with disclosure; at the poster, either of you may be asked about any line of your code
  • The brief, with dates and the proposal checklist: serre-lab.github.io/CPSY1291-2026/final-project
  • Questions from today: which model size fits readers best, and does the answer change with the reading-time corpus?
  • Exam 2: in class, Tue 12/1, Lectures 9–19; one sheet of notes, both sides

Further reading

Papers from today worth reading, for your project or out of interest.

Minute paper

Submit on Canvas → Minute papers → Minute Paper 18 (access code read out in class).

Write three brief points in your own words:

  1. A model answers a new task correctly after reading three solved examples in its prompt. What changed inside the model, and what did not? How is this different from fine-tuning?
  2. Something you do not yet understand, or a question still open
  3. Another idea you found interesting, and why it matters for brains, behavior or AI

Credit for a thoughtful attempt, not for being correct.

Going further

Predictive coding in detail

Language models and the brain: current readings

More encoding-model results, from conversation to single neurons, with a caution.

  • Hours of real conversation: one speech-to-text model's sound, speech and word embeddings each predict ECoG activity across 100 h of everyday conversation, and the model's levels line up with the cortical hierarchy (Goldstein et al. 2025)
  • Single neurons: the same readout, neuron by neuron, separates cells that track a word's part of speech and syntactic dependencies from cells that track phrase and sentence structure (Cai et al. 2026)
  • What the fit tracks: across 34 saved stages of one training run, it follows a model's grammatical knowledge, not its world knowledge or reasoning (AlKhamissi et al. 2025)
  • A caution from 2026: an untrained network, which has learned no language, can reach a good brain fit through shuffled train–test splits and confounds such as word rate (words per second). Some influential results were inflated this way (Hadidi et al. 2026)

Testing it with a language model

Figure 2 of Caucheteux et al.: a, the brain score of GPT-2 activations on fMRI from 304 listeners, highest along the superior temporal sulcus; b and d, adding the model's representation of words d positions ahead improves the brain score, with a peak at about 8 words ahead; c, the regions where this forecast gain is significant, temporal, parietal and frontal; e to g, the best forecast distance grows from temporal regions (about 8 words) to frontal and parietal regions (about 9 to 10 words)

  • 304 people heard stories in fMRI. Adding GPT-2's activations for the next 8 words improved the fit: brain activity carries information about upcoming words (prediction, or context? see Open questions)

Predictive coding and autoencoders

If the brain minimizes prediction error, how does that compare with an autoencoder?

  • Autoencoder: minimizes the reconstruction residual e=x−x^\mathbf{e} = \mathbf{x} - \hat{\mathbf{x}} by backprop (one forward, one backward sweep)
  • Predictive coding minimizes the same residual by iterative settling (update r\mathbf{r} until the error is small): a higher level's estimate r\mathbf{r} of the causes relaxes until its prediction explains the input (Rao & Ballard 1999); the weights follow a local rule (each weight changes using only the activity of the two units it connects)
  • Same residual, different algorithm: predictive coding needs only local error circuits, which may be how cortex does it

Rao & Ballard (1999)

  • Each level predicts the level below through top-down connections; the residual, the prediction error, is sent bottom-up
  • A higher level holds an estimate r\mathbf{r} of the causes, predicts lower activity x^=Wr\hat{\mathbf{x}} = \textcolor{#B5396B}{\mathbf{W}}\mathbf{r}, and the error e=x−x^\mathbf{e} = \mathbf{x} - \hat{\mathbf{x}} drives the update
  • Trained on natural-image patches, it develops oriented, Gabor-like receptive fields, as sparse coding did, and predicts surround suppression (weaker response when the surround continues the pattern in the receptive field)

The predictive-coding equations

At one level: prediction of the level below x^=Wr\hat{\mathbf{x}} = \textcolor{#B5396B}{\mathbf{W}}\mathbf{r}, error e=x−x^\mathbf{e} = \mathbf{x} - \hat{\mathbf{x}}.

Inference (fast, within one stimulus: settle r\mathbf{r} to reduce the error):

r←r+ηr W⊤e\mathbf{r} \leftarrow \mathbf{r} + \eta_r\,\textcolor{#B5396B}{\mathbf{W}}^\top\mathbf{e}

Learning (slow, across stimuli: a local, Hebbian-like rule):

W←W+ηW e r⊤\textcolor{#B5396B}{\mathbf{W}} \leftarrow \textcolor{#B5396B}{\mathbf{W}} + \eta_W\,\mathbf{e}\,\mathbf{r}^\top

  • Wr\textcolor{#B5396B}{\mathbf{W}}\mathbf{r} is the top-down prediction; W⊤e\textcolor{#B5396B}{\mathbf{W}}^\top\mathbf{e} carries the error bottom-up
  • Each update uses only quantities available at that connection, the error and the activity, so there is no global backward pass

Predictive coding as a deep net: PredNet

  • Lotter, Kreiman & Cox stacked Rao–Ballard-style modules: each layer predicts the layer below and passes the prediction error up, trained on video to predict the next frame
  • The trained network reproduces perceptual effects nobody built in, such as the flash-lag illusion
  • From brain to AI: a 1999 theory becomes a trainable architecture

The PredNet module: representation units emit a prediction of the layer below, the mismatch becomes an error signal, and errors propagate up the hierarchy

Is backprop biologically plausible?

  • Backprop's problems for biology: a separate backward pathway; weight transport (backward weights must equal the forward ones); a global two-phase schedule; non-local error signals
  • Predictive coding offers local learning: errors computed in place by error units; updates use only the activity of the connected units
  • Under some conditions predictive coding approximates the backprop gradient
  • Still a hypothesis: direct evidence for cortical error units is debated

- Kutas and Hillyard (1980) used sentences like this one in one of the first EEG studies of reading. The next slide shows what they measured.

- Kutas and Hillyard (1980) compared sentences that ended as expected ("butter") with sentences that ended in a word that did not fit ("socks"). The EEG, averaged over many sentences, went more negative about 400 ms after the unexpected word. This response is called the N400 - Reading the figure: the voltage is plotted with negative up, as was the custom in EEG papers, so the N400 is the dashed peak above the line after SOCKS. The dotted sentence ends in a word printed in large type (SHOES): a surprise in how the word looks, not in its meaning, gives a positive response instead (P560). The N400 tracks meaning - We come back to this later. A language model gives every word a number called surprisal, which measures how unexpected the word was given the words before it. That number predicts how long people take to read the word and how large the N400 is

- The transformer block has multi-head self-attention, then a small MLP applied at each position. Each of the two has a residual connection and layer normalization. Because of the causal mask, one forward pass over T tokens gives T next-word predictions to train on - Feeding the true text as input during training, rather than the model's own guesses, is teacher forcing; it is unchanged at scale - The chain rule of probability: $p(w_1,\dots,w_T)=\prod_{i=1}^{T} p(w_i\mid w_1,\dots,w_{i-1})$, where $w_i$ is the token at position $i$ and $T$ the number of tokens in the window. The loss is the average cross-entropy of these T predictions; the vocabulary is now word pieces (see "From characters to word pieces") rather than characters - Scaling laws (Kaplan et al. 2020; Hoffmann et al. 2022, "Chinchilla") get their own slide shortly. Chinchilla's rule is about 20 training tokens per parameter for a fixed compute budget, with loss L(N, D) = E + A/N^α + B/D^β for N parameters and D tokens. Small models are now trained far beyond that ratio (Llama 3 8B saw about 15T tokens), because a small model is cheaper every time it answers a question

- PF-day: 10^15 floating-point operations per second for a day, about 8.6 × 10^19 operations - Non-embedding parameters: all the weights except the embedding table, the lookup that turns each token into a vector (and the matching output layer); Kaplan et al. leave those out because they barely affect the loss - Figure 1 of Kaplan et al. (2020): the loss of transformer language models on held-out web text against compute (left, every training run in light blue and their lower envelope in black), dataset size (middle) and non-embedding parameters (right), each a straight line on log-log axes, so a power law. N is the number of non-embedding parameters - With the number of parameters fixed, making the network deeper or wider barely changes the loss. The fitted law for parameters is L(N) = (N / 8.8 × 10^13)^-0.076. The exponent is small: multiplying the parameters by 10 multiplies the loss by 10^-0.076 ≈ 0.84. The loss keeps falling at a predictable rate, but each step costs ten times more parameters - Hoffmann et al. (2022) redid the fit with the learning-rate schedule matched to the length of each training run. They found that Kaplan's recipe undertrains the models: parameters and tokens should grow in equal proportion. Their 70-billion-parameter model trained on 1.4 trillion tokens (Chinchilla) beat Gopher, a 280-billion-parameter model trained on 300 billion tokens, with the same compute - The law predicts the loss, not what the model can do. Schaeffer et al. (2023) argue that many reported "emergent abilities", skills that seem to appear suddenly at some model size, come from all-or-nothing metrics such as exact-match accuracy. Scored with a continuous metric, the same models improve smoothly. The loss is smooth, but a task scored right or wrong can still show a jump

- BPE (byte-pair encoding) starts from the 256 possible bytes rather than from characters, so text in any language or script can be encoded; for English letters, one byte is one character. The space before a word is part of its piece. "brain" with no space and " brain" after a space are therefore different tokens, and can be split differently: "unbelievable" without a space is four pieces, " unbelievable" with a space is one - Each piece gets one row of the embedding table, as each character did in the model you build in the assignment. The examples on the slide come from GPT-2's own tokenizer - The tokenizer is fixed before the model is trained, and its merges are chosen from the tokenizer's own training text. The model only sees piece numbers and never the letters inside a piece, which is one reason large models often miscount the letters in a word - BPE began as a compression method; Sennrich et al. (2016) brought it to neural translation. A tokenizer may not be necessary: Pagnoni et al. (ACL 2025, "Byte latent transformer", doi:10.18653/v1/2025.acl-long.453) train on raw bytes, grouped into patches according to how predictable the next byte is, and match token-based models at scale

- Books: Google Books estimated about 130 million distinct books in 2010; at 70,000 to 100,000 words a book, that is roughly 9 to 13 trillion words - Public text: Villalobos et al. (ICML 2024) estimate the stock of good-quality public human text at about 300 trillion tokens, and project that models will have used it up between 2026 and 2032. Labs no longer publish their training-set sizes, so for frontier models these are estimates - A child's input: the BabyLM challenge (Warstadt et al., CoNLL 2023) caps training at 100 million words, roughly what a child has heard by age 13. 11 trillion / 100 million ≈ 110,000 - The next slide lists the models used in this lecture, with their sizes and training tokens

- B = billion, T = trillion. GPT-2: Radford et al. (2019); GPT-3: Brown et al. (2020). GPT-2 was trained on WebText, about 40 GB of text from web pages linked on Reddit; the token count is an estimate, since the paper gives only the size in bytes - DeepMind built Gopher and Chinchilla to study scaling. Chinchilla used the same compute as Gopher with a quarter of the parameters (70 billion against 280 billion) and more than four times the data, and it did better (next slide) - Pythia is a suite of eight model sizes trained on the same data in the same order, with saved checkpoints along the way, so researchers can study how models learn. The assignment and the reading-time analysis use GPT-2

- Data: Epoch AI, "Notable AI models" (CC-BY 4.0), downloaded 2026-11-17; language models with a training-compute value. Frontier values (GPT-4, Gemini, GPT-6 Astra) are Epoch's estimates, since these labs do not publish them - The line is a least-squares fit of log compute on date for all 276 language models from 2018 on (6.2× per year, doubling every ~4.6 months). Fits restricted to the frontier models give a somewhat slower rate (Epoch reports roughly 4–5× per year for frontier training runs) - GPT-2: 1.9 × 10^21 FLOP (2019). The largest in the data: 9.4 × 10^26 FLOP (2026), about 500,000 times more - Script: 2026/figures/make_L17_epoch_compute.py

- Some abilities seem to appear abruptly with scale; Schaeffer et al. (2023) show this is often an artifact of all-or-nothing scoring - Chinchilla's rule: about 20 training tokens per parameter for a fixed compute budget, with loss L(N, D) = E + A/N^α + B/D^β for N parameters and D tokens - Schaeffer et al. (2023): abilities that look abrupt when scored right or wrong often rise smoothly when scored by the probability of the correct answer

- Huh et al. (2024) survey many reports of convergence and show it across modalities: the nearest neighbours of an image in a vision model's space and of its caption in a language model's space overlap more as both models get larger and better - "Platonic", after Plato's allegory of the cave: the data are shadows, and different models trained on different shadows recover the same underlying reality - The paper itself discusses limits: alignment is measured with a few kernel-similarity metrics, absolute alignment values stay modest, and some information is specific to one modality - Representational geometry and its comparison across systems come from the lectures on mental spaces and on comparing networks with the brain

- This is the "random insertion in word" task of Brown et al. (2020): random punctuation or spaces are inserted between the letters of a word, and the model must output the original word. The prompt on the slide is written in that format as an illustration; it is not a transcript from the paper - Zero-shot: the prompt gives only a description of the task. One-shot: it also contains one solved example. Few-shot: it contains a handful; the prompt here has two, and Brown et al. used 10 to 100

- Solid versus dashed lines: the same prompts with and without a one-sentence natural-language instruction before the examples. The instruction helps most with zero or one example (175B one-shot: ~46% with it, ~26% without); from about 10 examples on, the curves merge: the examples alone convey the task - Zero-shot, one-shot and few-shot as on the previous slide: the x axis counts the solved examples in the prompt - The figure is Fig. 1.2 of Brown et al. (2020), on a simple task: removing random symbols from a word. The larger the model, the more accuracy it gains from the examples in the prompt - No weight changes. The examples are read in a single forward pass, and whatever the model picks up from them lives only in the activations of that pass

- This repeats the GPT-3 experiment of the previous slide at a scale that runs on a laptop. The three GPT-2 models (124 M, 355 M and 774 M parameters) are loaded with the Hugging Face transformers library, the same models the assignment uses. Each prompt holds k solved pairs, one per line, then a new word and an arrow. The model writes its most likely continuation at each step (greedy decoding), and the answer counts as correct when that continuation starts with the antonym - Accuracy for 0, 1, 2, 4 and 8 examples in the prompt: small 0, 10, 8, 6, 4%; medium 0, 22, 64, 88, 94%; large 4, 25, 81, 92, 96%. The 32 antonym pairs used for testing were chosen before any model was run - The examples in the prompt do two things. They tell the model what the task is (GPT-2 small cannot use this) and they show the answer format. With zero examples nothing tells the model what "->" means, so all three models score near zero - The caution about metrics from the scaling-laws slide applies here. Scored right or wrong, the step from GPT-2 small to medium looks like a jump. The probability the model assigns to the correct antonym would probably rise more smoothly (Schaeffer et al. 2023); we did not plot it - For the brain, the relevance is that a new task is picked up from a few examples within a single pass, with no change to any weight (the analogue of a synapse). The next two slides ask where this ability comes from and what mechanism inside the forward pass produces it

- Kalamang: MTOB benchmark (Machine Translation from One Book, Tanzer et al. 2024), several hundred pages of field-linguistics material for a language spoken by fewer than 200 people, so it is essentially absent from training data. The Gemini 1.5 report (2024) puts the whole book in the context and reports translation at a level similar to a person who learned from the same material - Min et al. (2022): replacing the labels of the demonstrations with random labels barely hurts classification and multiple-choice accuracy across 12 models, including GPT-3; what matters is the label space, the distribution of inputs and the format - Wei et al. (2023): with flipped labels, small models keep using their prior (they answer as if the labels were correct); the ability to override priors and follow the examples appears with scale - Agarwal et al. (2024): going from a few to hundreds or thousands of examples in the prompt improves many tasks and can override biases from pretraining

- Nobody trained these models to learn from examples. Web text happens to contain many word lists with translations, question-and-answer pages and worked problems, and each of these is a small task shown by example - Figure 1.1 of Brown et al. (2020). The outer loop is pretraining: gradient descent on next-token prediction over millions of documents. The inner loop is what happens within one document. By the third or fourth example line the model has picked up the task, and the next lines become easier to predict - Chan et al. (2022) trained transformers on sequences of images and found that in-context learning appeared only when the training data were "bursty", meaning the same rare items recur within one sequence, as words and topics recur within a document

- Brown et al. (2020) call this view meta-learning: the outer loop (pretraining by gradient descent) builds a model whose forward pass carries out an inner loop (learning a task from the examples in its context) - Chan et al. (2022): in-context learning emerges when training data are "bursty", with items that recur in clusters within a document, as tasks shown by example do

- Same figure as in the lecture on building a language model. The sentence is "The black cat sat on the mat. The black", and the model should predict "cat" - An induction head copies: [A][B] … [A] → predict [B]. That explains repeating a pattern seen earlier in the context, and part of the gain from long contexts - The attention-head explorer from the lecture on building a language model shows this pattern in GPT-2. A previous-token head (layer 4, head 11) copies each word's identity to the next position, and an induction head in the next layer (layer 5, head 5) looks back for the earlier occurrence of the current word and predicts the word that followed it - Olsson et al. (2022): in small and large models, induction heads appear at one point in training, the same point where the loss on late tokens in a context drops sharply (a measure of in-context learning). They propose induction heads as a candidate mechanism for most in-context learning; this is evidence, not a proof

- Function vectors (Todd et al. 2024): averaging the outputs of a few attention heads over prompts for one task gives a vector that, added to a new prompt, makes the model perform that task. The heads that write it are function-vector heads - Yin & Steinhardt (2025), Fig. 1a, Pythia 6.9B: accuracy on few-shot tasks as a growing fraction of heads is ablated. Random heads: flat near 0.56. Induction heads: slowly down to 0.44 at 20%. FV heads: down to about a third of the intact accuracy - Shown in the "Going further" part of the lecture on building a language model

- Akyürek et al. (2023) and von Oswald et al. (2023) trained transformers on sequences of (x, y) pairs generated by a linear function, where the task is to predict the next y. They show by construction that one linear self-attention layer can carry out one step of gradient descent on the squared error over the pairs in the context. They also show that trained transformers behave like gradient descent or ridge regression. Antonyms are not a linear function, so this does not explain the antonym task directly. It shows that learning from the prompt can come from computations already present in the pretrained weights

- Model names change every few months, but the recipe has stayed the same since 2020. A decoder-only transformer is pretrained on next-token prediction at scale, and then trained further (the alignment slides that follow) - Guo et al. (2025) is the peer-reviewed paper for DeepSeek-R1. OpenAI has not published a paper describing how o1 was trained

- Figure 2 of Ouyang et al. (2022), the InstructGPT paper. Step 1, SFT (supervised fine-tuning): the model is trained on answers written by people. Step 2, RM: a reward model is trained to score answers according to which ones labelers prefer. Step 3, PPO (proximal policy optimization): a reinforcement-learning algorithm updates the model to produce answers the reward model scores highly. The "policy" is the language model itself, treated as an agent that chooses which token to write next - Labelers preferred the answers of the 1.3-billion-parameter InstructGPT model to those of the 175-billion-parameter GPT-3, even though InstructGPT is more than 100 times smaller

- RLHF is reinforcement learning from human feedback (Ouyang et al. 2022, the InstructGPT paper behind ChatGPT). DPO is direct preference optimization (Rafailov et al. 2023), which learns from the same preference data without training a separate reward model - Writing out steps before the answer started as a prompting trick. Wei et al. (2022) put worked solutions in the prompt ("chain-of-thought"), and large models improved a lot on grade-school math word problems. Kojima et al. (NeurIPS 2022) found that adding "Let's think step by step" with no worked example already gives part of the gain. DeepSeek-R1 (Guo et al. 2025) is trained in step 3 to produce such chains on its own - Writing out steps helps people too, because intermediate results go onto the page instead of being held in working memory, which is limited to a few items - Each of the three stages continues training the same network. The weights change at every stage, but the architecture stays the same

- Schematic, own figure: the probabilities are not from a real model. It illustrates that generation is sequential choice, and that locally best choices need not give a globally good answer - Search over paths is what beam search, sampling several answers and picking the most common one (self-consistency, Wang et al. 2023), and reasoning models do in different ways

- Chain-of-thought prompting (Wei et al. 2022): eight worked examples with intermediate steps in the prompt; PaLM 540B reached state-of-the-art accuracy on GSM8K, grade-school math word problems, above a fine-tuned GPT-3 with a verifier. The gain appears only in sufficiently large models - Zero-shot chain of thought (Kojima et al. 2022): the single phrase "Let's think step by step" before the answer, no examples - DeepSeek-R1 (DeepSeek-AI, Nature 2025): pure reinforcement learning with rewards that a program can check (is the math answer right, does the code pass its tests). Self-reflection, verification and changes of strategy appear in the outputs without being taught - Each written token costs one forward pass, so a longer chain of thought is more computation spent on one answer. The weights are the same; only the amount of computation at answer time changes - A cognitive parallel often drawn: fast intuitive answers versus slow, deliberate, step-by-step reasoning ("System 1" and "System 2")

- In a mixture-of-experts layer, each expert is a separate MLP, and a small router network chooses which ones process each token. The compute per token stays small while the total number of weights grows. DeepSeek-V3 (DeepSeek-AI 2024) sends each token to 8 of 256 experts in each layer - Patches as tokens is the vision transformer (Dosovitskiy et al. 2021); multimodal assistants put image patches and word pieces in one sequence - Reid et al. (2024) is the Gemini 1.5 report; Gemini 1.5 was the first widely used model with a context window of about a million tokens. Blakeman et al. (2025) describe Nemotron-H, one of the hybrid families (attention layers mixed with another kind of sequence layer)

- Retrieval-augmented generation (Lewis et al. 2020) works in three steps. The system searches a document collection with the question, puts the best passages into the prompt, and the model writes its answer from those passages. When an assistant quotes a fact with a source, it usually read the fact this way, in the context, as it read the antonym examples. The fact was not stored in the weights - Providers may fine-tune later versions of a model on collected conversations, but that is a separate training run done afterwards. The model does not learn from your chat while you are talking to it - The stored keys and values are the "KV cache" from the lecture on building a language model: a key vector and a value vector for each earlier token, in every layer and head. Reid et al. (2024) report the first million-token context in a deployed model. As that lecture showed (Liu et al. 2024), models still answer best from information at the start and the end of a long context

- Toolformer (Schick et al. 2023) trained a model to insert calls to a calculator, a search engine and other tools into its own text. ReAct (Yao et al. 2023) alternates between writing a reasoning step and taking an action such as a search, and the model reads the result of each action before writing the next step - Coding assistants are agents of this kind. They read files, run commands and tests, and edit code in a loop. The model inside is still a next-token predictor, and the loop around it is ordinary software that runs the tools and feeds the results back into the prompt

- Surprisal in bits uses a logarithm with base 2, while the training loss used nats (natural logarithm); 1 nat is about 1.44 bits. A surprisal of 10 bits means the model gave the word a probability of about 1/1,000 given the words before it. A surprisal of 0 bits means the model was certain - Shain et al. (2024) tested how reading time depends on a word's probability, using six reading-time data sets. The effect is logarithmic, as surprisal theory says: each halving of the probability adds the same amount of reading time - The N400 is an event-related potential (ERP): EEG averaged over many trials and aligned in time to the onset of each word. Michaelov et al. (2023) show that the surprisal GPT-3 assigns to words accounts for several classic N400 effects - Surprisal began as a theory of reading in psycholinguistics (Hale 2001; Levy 2008). Language models could not estimate it well until recently, so the idea only became easy to test once they could

- The three models are the GPT-2 releases of Radford et al. (2019), with 124 M, 355 M and 774 M parameters. They load through the Hugging Face transformers library in two lines of code, and the assignment uses the same three. A word split into several pieces gets the sum of the surprisals of its pieces. The first token has no preceding words to condition on, so it has no surprisal - The mean surprisal in nats over a text is the cross-entropy loss on that text. Perplexity is the exponential of this loss, so a lower loss and fewer bits per token describe the same improvement - The larger model is not always more confident on a single word. For example, "calls" has a surprisal of 7.2 bits under GPT-2 medium and 5.2 bits under small. The scaling law is about average loss over a text, and says nothing about any one word

- Natural Stories (Futrell et al. 2021): ten stories of about 1,000 words, read one word at a time by 181 people; a word's reading time is how long a reader waited before pressing the key for the next word. Shown: the mean over readers who answered the comprehension questions well, keeping times between 100 and 3,000 ms, as in the assignment - Surprisal from GPT-2 small, with all earlier words of the story as context; a word split into several tokens gets the sum of their surprisals - The slowest word, "years.", ends the sentence: readers slow down at the end of a sentence, and some of the cost of "seven-twelve" lands on the word after it (spillover). This is why reading-time models also include the previous word's surprisal - Over all ten stories the correlation is 0.26. The next slide asks how much surprisal adds once word length and frequency are already in the model

- Same data, readers and filtering as the previous slide; one point per word of the story (n = 1,038). Pearson r = 0.30; r² ≈ 0.09 - years. (873 ms) sits far above the line for its surprisal: the slowdown from seven-twelve spills over onto the next word, which surprisal at that word does not capture - Script: 2026/figures/make_L17_reading_times_scatter.py

- The data are Natural Stories (Futrell et al. 2021): 181 readers each read ten stories. Each word's reading time is first predicted from the word's length and its frequency; then surprisal is added as an extra predictor - Least squares chooses the regression weights that make the squared differences between observed and fitted reading times as small as possible. The log-likelihood measures how probable the observed times are under the fitted model, and ΔLL on the axis is the increase in log-likelihood when surprisal is added to the predictors. Adding a predictor can never make the fit to the same data worse, so the comparison uses held-out stories: fit on nine stories, score on the tenth, and repeat with each story left out in turn - Perplexity is 2 raised to the mean surprisal in bits, and a lower perplexity means the model predicts the text better. Oh and Schuler (2023) found that, once models are large enough, lower perplexity goes with a worse fit to reading times, both on Natural Stories and on the Dundee eye-tracking corpus. The larger models have been trained on far more text than any person reads - Oh and Linzen (2026) argue that current language models predict words better than a person can ("superhuman"), because they have seen more text and keep more context in memory than a reader does. They propose that models of human prediction should be made less powerful, for example smaller, or trained on about as much text as a person reads - The Natural Stories texts were written to contain rare grammatical constructions while still reading naturally. Reading is self-paced: readers press a key to reveal each word, and the time between key presses is the reading time

- Recorded on a laptop with Ollama, 2026-11-17: qwen3:8b, raw text (no chat template), 20 top next-token candidates at each word. Script: 2026/figures/run_L17_expectations.py - 1. Compare butter and socks: after "He spread the warm bread with", the model puts 36% on butter (5.8 bits); socks is not in its top 20 (at least 8.75 bits) - 2. Click "with": the model expected "butter", "a", "the", "some" - 3. Antonyms: after two or three pairs, the answers cost almost 0 bits: in-context learning, word by word - 4. Garden path, "The old man the boat": "the" after "man" and "sleep" at the end are the surprising words - 5. Raise the temperature: the distribution flattens and unlikely words become more likely to be sampled

- ECoG (electrocorticography) records the electrical signal from electrodes placed directly on the surface of the brain, in patients who are being monitored before epilepsy surgery - On the brain side we use encoding models, as in the lecture on comparing networks with the brain: a linear readout is fitted from the model's activations to each voxel or electrode, and scored on held-out text. Antonello et al. (2023) found that fMRI encoding performance grew logarithmically with model size, from 125 M to 30 B parameters, by about 15% in total. Hong et al. (2026) found the same with ECoG in model families trained on a fixed data set, so what changes is the size of the model and not the amount of data - The reading-time result and the brain result seem to disagree, and one possible reason is the difference in what is measured. A reading time is one number per word that reflects the reader's prediction. An encoding model uses hundreds of dimensions of the model's representation and can pick up any feature that correlates with brain activity. AlKhamissi et al. (EMNLP 2025, on the further-reading slide) find that the fit to the brain follows how much grammar a model knows, and not how much it knows about the world - Model–brain scores have pitfalls of their own. Two slides ahead, Hadidi et al. (2026) show how confounds (other variables that also predict the signal) can inflate them

- The language network is the set of left frontal and temporal regions that respond more strongly to sentences than to lists of nonwords. It is located in each participant with a short localizer scan (panel A) - Tuckute et al. (2024) used the encoding model to search about 1.8 million sentences for those it predicted would give the largest responses ("drive") and the smallest ("suppress"), and showed them to new people who had not been in the data used to fit the model. In the event-related design the drive sentences raised the response by about 86% and the suppress sentences lowered it by about 98%, relative to baseline sentences. Surprisal and well-formedness explained much of the effect. The network responds most to sentences that are hard to predict but still read like language - This uses the encoding model from the lecture on comparing networks with the brain in the opposite direction. Before, we asked how well the model fits the brain. Here we ask which sentences the model predicts will change the brain response most, and then test that prediction on new people. We saw the same closed-loop idea earlier in the course, in the vision work with synthesized images

- Lineage: Helmholtz (unconscious inference) → Rao & Ballard (1999) → Friston (free energy) - This is the same idea as self-supervised learning, but from neuroscience. In self-supervised learning a machine predicts its input in order to learn good features. In predictive coding the brain is proposed to predict its input in order to perceive it - Helmholtz (1867) described perception as unconscious inference from sensations to their causes - Westerberg and Roelfsema (2026) review recordings across cortical layers during perception and attention. The usual finding is that feedback from higher areas increases the activity of neurons that represent the attended or predicted stimulus. Predictive coding expects the opposite, suppression of what is predicted. The authors group the accounts that fit better under the name BELIEF. Predictive coding is a hypothesis with evidence on both sides, so it can be tested - The brain score (panel a) is the correlation, on held-out data, between a voxel's fMRI response and the response predicted by an encoding model fitted to GPT-2's activations - The forecast score (panels b to d) is the gain in brain score when the model's activations for the current word are joined by its activations for the words that come after it, up to a distance d. The gain peaks at about 8 words, which is roughly three seconds of speech - Panels e to g: the distance that helps most is about 8 words in the superior temporal sulcus and about 9 to 10 words in the inferior frontal gyrus and the supramarginal and angular gyri. Higher areas predict further ahead, as hierarchical predictive coding expects - A language model is trained to predict only the next word. This result suggests that the brain predicts further ahead and at several timescales at the same time - The same group's earlier study (Caucheteux & King 2022) recorded 102 people with fMRI and MEG as they read 400 sentences, and compared many language models. A model's fit to the brain depended mainly on how well it predicts words from their context - A caution: the fMRI signal is slow. "8 words ahead" therefore tells us how far ahead the future words that improve the fit lie. It does not show the brain making a prediction

- The first question is whether models of human prediction should be made less powerful, as Oh and Linzen (2026) argue (further-reading slide). The BabyLM challenge (Warstadt et al., CoNLL 2023) trains language models on about 100 million words or fewer, roughly what a child has heard by age 13 - The second is how to connect two results. Caucheteux and King find that future words improve the model's fit to the brain, and Westerberg and Roelfsema find mostly enhancement rather than suppression in cortical circuits. A forecast in the representation has not yet been shown to be an error signal in the circuit - The third question leads into the next lecture. A recurrent network also keeps what it has read in its activity, a state that is carried from one step to the next, and does not store it in its weights

- The slides after this one go beyond the lecture and are for those who want to read more - Terms you should be able to define for the exam: token and word piece, surprisal (in bits or nats), in-context learning, encoding model, predictor and held-out fit, predictive coding and its error units - The next lecture covers recurrence, another way for a network to carry context, from loops in the visual cortex to the recurrent layers inside current language models. The last lecture before the exam is on world models

- Whether an LLM is also a good model of how people think is still argued - Binz & Schulz (2023) gave GPT-3 classic cognitive-psychology tasks. Binz et al. (2025) fine-tuned a language model on human choices from 160 experiments, so that it predicts and imitates how people behave - AI assistants are not allowed on the assignments. For the final project the rule is in the syllabus

- Natural Stories and similar corpora give the reading time of every word, which is what a project on surprisal needs - Contamination: benchmark questions posted online end up in the web text models are trained on. A model can then answer them from memory, and its score overstates what it can do on new items. A model's training cutoff date tells you which items it cannot have seen

- Oh & Linzen (2026) and Hadidi et al. (2026) follow from the reading-time and brain slides; Cai et al. (2026), Goldstein et al. (2025) and AlKhamissi et al. (2025) from the current-readings slide; Westerberg & Roelfsema (2026) from the predictive-coding slides - More that qualify: Hong et al. (eLife 2026, doi:10.7554/eLife.101204), larger models align better with ECoG when training data are held fixed; Shain et al. (PNAS 2024, doi:10.1073/pnas.2307876121), the logarithmic effect of word probability on reading time across six corpora; Nastase et al. (Neuron 2026, doi:10.1016/j.neuron.2026.07.024), a perspective on LLM embeddings as a model of the neural population code for language; Mahowald et al. (TICS 2024, doi:10.1016/j.tics.2024.01.011), language ability versus thought in LLMs; McCoy et al. (PNAS 2024, doi:10.1073/pnas.2322420121), what next-token training predicts LLMs will get wrong; Lotter, Kreiman & Cox (Nat Mach Intell 2020, doi:10.1038/s42256-020-0170-9), a predictive network that mimics neurons and illusions; Lian & Burkitt (PLoS Comput Biol 2025, doi:10.1371/journal.pcbi.1013059), sparse and predictive coding as divisive normalization

- Submit it on Canvas under Minute papers, Minute Paper 18. You get credit for a thoughtful attempt

- Goldstein et al. (2025) used Whisper, a model trained to transcribe speech. They fitted its acoustic, speech and language embeddings to ECoG recordings with linear encoding models, for both speaking and listening, and tested them on hours of conversation not used in fitting. Sensory and motor regions were best explained by the speech embeddings, and higher language areas by the word embeddings - Cai et al. (2026) recorded single neurons with microelectrode arrays while participants spoke. For every word, a language model supplied a vector of numbers describing the word, and the authors tested which neurons' firing is predicted by those numbers. The encoding was stronger in the left hemisphere and differed between regions - AlKhamissi et al. (2025) followed 34 training checkpoints across 8 model sizes. Brain alignment rises with formal linguistic competence (knowledge of grammar). Once models pass human-level proficiency, better next-word prediction no longer goes with better brain alignment, which agrees with the reading-time result - Hadidi et al. (2026) re-analysed three neural data sets. When the training and test sets are made by shuffling words, the context leaks between them. Position in the text and word rate alone predict about as well as an untrained model does. Many studies avoid these pitfalls. In your own project too, report a brain-fit number only together with the control analyses

- The brain score (panel a) is the correlation, on held-out data, between a voxel's fMRI response and the response predicted by an encoding model fitted to GPT-2's activations - The forecast score (panels b to d) is the gain in brain score when the model's activations for the current word are joined by its activations for the words that come after it, up to a distance d. The gain peaks at about 8 words, which is roughly three seconds of speech - Panels e to g: the distance that helps most is about 8 words in the superior temporal sulcus and about 9 to 10 words in the inferior frontal gyrus and the supramarginal and angular gyri. Higher areas predict further ahead, as hierarchical predictive coding expects - A language model is trained to predict only the next word. This result suggests that the brain predicts further ahead and at several timescales at the same time - The same group's earlier study (Caucheteux & King 2022) recorded 102 people with fMRI and MEG as they read 400 sentences, and compared many language models. A model's fit to the brain depended mainly on how well it predicts words from their context - A caution: the fMRI signal is slow. "8 words ahead" therefore tells us how far ahead the future words that improve the fit lie. It does not show the brain making a prediction

- The learning rule is local, meaning that each weight changes using only the activity of the two units it connects, as in Hebbian learning - Whether the cortex has dedicated neurons that report the prediction error is still debated

- Surround suppression: a neuron in visual cortex responds less when the pattern in the area around its receptive field continues the pattern inside it. Rao and Ballard explain this by saying that the higher level already predicts the continuation, so the error signal is small - Sparse coding, from the lecture on learning without labels, learned the same kind of Gabor-like filters from image patches of natural scenes - The equations for the updates are on the next slide

- $\mathbf{W}$ holds the generative weights, which map the higher level's estimate $\mathbf{r}$ to a prediction of the input $\mathbf{x}$. The prediction error is $\mathbf{e} = \mathbf{x} - \mathbf{W}\mathbf{r}$ - Both updates are gradient descent on the squared error ½‖x − Wr‖²: one changes r (fast, for the current input) and the other changes W (slowly, across many inputs)

- The figure shows one PredNet module. Representation units predict the layer below, the difference between that prediction and the actual input is computed as an error signal, and the errors are passed to the layer above - The architecture is from the 2017 paper (Lotter, Kreiman & Cox). The 2020 paper (Lotter, Kreiman & Cox, Nat Mach Intell) shows that the trained network reproduces perceptual effects such as the flash-lag effect and illusory motion, and has neuron-like responses - A network that predicts the next video frame is a simple example of a world model, the topic of the last lecture before the exam

- The weight transport problem: in backpropagation, the error sent back through a connection is multiplied by the weight that the same connection has in the forward direction. A real synapse has no way to read its own weight in the backward direction - Whittington & Bogacz (2017) showed that a predictive-coding network trained with local rules approximates backpropagation, for supervised learning. Millidge et al. (2022) extended this to arbitrary computation graphs, which cover any network that can be trained by backpropagation