What a language model is, in econometric terms
March 17, 2027
Draws on talks by Scott Cunningham
Course Home Page
The first half of this course was done without AI.
The second half is about AI methods for research.
Today: why the first half came first, and what a language model actually is.
William Shockley studied why a few researchers produce far more than everyone else.
His answer was not intelligence. He broke productivity into several abilities and multiplied them.
Add the inputs
\[P = F_1 + F_2 + F_3\]
\[0.5 + 0.5 + 0.5 = 1.5\]
Multiply the inputs
\[P = F_1 \times F_2 \times F_3\]
\[0.5 \times 0.5 \times 0.5 = 0.125\]
Add the inputs
\[0 + 0.5 + 0.5 = 1.0\]
Inputs are perfect substitutes. Having none of one is no problem.
Multiply the inputs
\[0 \times 0.5 \times 0.5 = \color{red}{0}\]
You need at least some of every input to make anything at all.
A zero in any one input sinks the output.
\[P = F_1 \times F_2 \times F_3 \times F_4 \times F_5 \times F_6 \times F_7 \times F_8\]
Shockley (1957), “On the Statistics of Individual Variations of Productivity in Research Laboratories,” Proceedings of the IRE. He called it “a partial listing.”
If AI raises \(F_2\) while your \(F_3\) falls toward zero, your output falls.
Before AI
The three came as one bundle.
With agents
Checking and understanding now have to be done on purpose.
Adapted from Scott Cunningham’s deskilling diagrams. Illustrative curves, not data.
The first half was done by hand so that your skills exist before an agent can let you skip building them.
| Date | Topic |
|---|---|
| 3/17 | How LLMs work (today) |
| 3/22 | LLMs as a research tool: APIs from R, text classification |
| 3/24 | From chatbots to agents |
| 4/5 | Directing agents: AGENTS.md, skills, hooks |
| 4/7 | Reviewing agent work: pull requests |
| 4/14 | Quarto: every number comes from code |
| 4/19 | Checking results |
| 4/21 | Research design with agents |
Chatbots and agents sit on top of this one machine.
“The minimum wage reduces ______”
| Next token | Probability |
|---|---|
| employment | 0.41 |
| poverty | 0.22 |
| hours | 0.11 |
| inequality | 0.09 |
| every other token | 0.17 |
That is the only thing the model does: map the text so far to a distribution over what comes next.
The minimum wage reduces
The minimum wage reduces employment
The minimum wage reduces employment among
The minimum wage reduces employment among teenagers
...
An essay, a proof, an R script: each is thousands of these draws in a row.
Prompt: “The minimum wage reduced teen ______”
| Next token | Probability |
|---|---|
employment |
0.62 |
hours |
0.18 |
turnover |
0.09 |
wages |
0.04 |
| all others | 0.07 |
The draw can be made more or less random. With scores \(z_k\) for each token \(k\):
\[\Pr(k) = \frac{\exp(z_k / T)}{\sum_j \exp(z_j / T)}\]
Lowering the temperature reduces the randomness. It does not make the most likely answer correct.
You would not report a regression from one bootstrap draw. Do not treat one LLM answer as the answer.
“Difference-in-differences estimates the treatment effect.”
Difference72917 -in4200 -d2469 if366 ferences10131 ␣estimates30233 ␣the290 ␣treatment7448 ␣effect3159 .13
␣ marks a leading space.The model never sees letters or words. It sees ten integers.
Real output from OpenAI’s o200k_base tokenizer, the one GPT-4o uses. Example from Scott Cunningham.
Picture 200,019 flashcards in a fixed order, with one piece of text on each.
| Card | 13 | 290 | 6922 | 72917 | … |
|---|---|---|---|---|---|
| Text | . |
␣the |
␣bank |
Difference |
… |
A token ID is a categorical variable, like a FIPS code.
Nobody wrote 200,019 cards by hand. An algorithm did:
Sennrich, Haddow, and Birch (2016) brought byte-pair encoding to language models.
Text: low lower lowest
| Step | Most common pair | Pieces after the merge |
|---|---|---|
| 0 | l o w l o w e r l o w e s t |
|
| 1 | l + o |
lo w lo w e r lo w e s t |
| 2 | lo + w |
low low e r low e s t |
| 3 | low + e |
low lowe r lowe s t |
“low” became one card because it was common in the text that was counted.
That is why “the” is one token and “differences” is three.
| What it counts | GPT-3 (2020) | GPT-4o (2024) | |
|---|---|---|---|
| Vocabulary | tokens it can choose from | 50,257 | 200,019 |
| Context window | tokens it can hold at once | 2,048 | 128,000 |
| Parameters | weights estimated in training | 175 billion | not disclosed |
| Training text | tokens read in training | about 300 billion | not disclosed |
The choice set is small. What is enormous is the text it learned from and the number of weights it takes to choose well.
Sources: Brown et al. (2020) for GPT-3; OpenAI’s o200k_base tokenizer and model documentation for GPT-4o.
OpenAI’s tiktoken package does what the last few slides described.
[72917, 4200, 2469, 366, 10131, 30233, 290, 7448, 3159, 13]
['Difference', '-in', '-d', 'if', 'ferences', ' estimates', ' the', ' treatment', ' effect', '.']
200019
Use OpenAI’s web tokenizer (platform.openai.com/tokenizer), or run pip install tiktoken in your own Python environment and use the code on the last slide.
Try each of these and count the tokens:
heteroskedasticity, instrumental variables, Cobb-Douglas2027, 3.14159, 1,234,567df |> filter(year >= 2020) |> summarize(n = n())Why it matters:
The numbers in the vector are illustrative.
You know this from fixest:
county is a categorical variable. Each county gets its own estimated number.The list of tokens is chosen. What each token means is learned.
␣wage ends up close to ␣salary and ␣earnings.But one row per token is a problem: “bank” gets the same row in every sentence.
“She deposited the check at the bank.”
“We sat on the river bank.”
Attention lets each token look back at the tokens before it and update its vector.
Updating “bank” in sentence one
| Token | Share |
|---|---|
| She | 0.04 |
| deposited | 0.38 |
| the | 0.03 |
| check | 0.33 |
| at | 0.05 |
| the | 0.03 |
| bank | 0.14 |
Updating “bank” in sentence two
| Token | Share |
|---|---|
| We | 0.05 |
| sat | 0.12 |
| on | 0.08 |
| the | 0.04 |
| river | 0.55 |
| bank | 0.16 |
Each column sums to one. Illustrative shares, not model output.
The new vector for “bank” is a weighted average of the vectors before it, using those shares.
In our language: a kernel-weighted average, where the kernel is learned from data.
For token \(i\) looking at an earlier token \(j\), with current vectors \(x_i\) and \(x_j\):
\[\text{score}_{ij} = (W_Q\, x_i)'(W_K\, x_j) \qquad a_{ij} = \frac{\exp(\text{score}_{ij})}{\sum_{k \le i}\exp(\text{score}_{ik})}\]
\[x_i^{\text{new}} = \sum_{j \le i} a_{ij}\, W_V\, x_j\]
Same logit formula, two different jobs:
| Question | Answer |
|---|---|
| Can it be negative? | No. It is a ratio of exponentials. |
| Can it exceed one? | No. The shares are positive and sum to one. |
| Can it be zero? | Only for later tokens, which are masked out. |
| Is it a probability? | Same shape, but nothing is ever drawn from it. |
| Is it causal? | No. A large share does not mean that token caused the output. |
Reading attention shares as “what the model based its answer on” is a common mistake.
On causality: Jain and Wallace (2019), “Attention is not Explanation.”
After all the layers, the context is summarized in one vector, \(h(\text{context})\).
\[\Pr(\text{next token} = k \mid \text{context}) = \frac{\exp\big(h(\text{context})' w_k\big)}{\sum_{j=1}^{V}\exp\big(h(\text{context})' w_j\big)}\]
Familiar
New
The weights are all the parameters \(\theta\): embeddings, attention matrices, the \(w_k\), and the rest.
\[\hat{\theta} = \arg\max_{\theta} \sum_{t} \log \Pr_{\theta}\big(\text{token}_t \mid \text{tokens before } t\big)\]
The “labels” come free with the text: the next token is always right there.
There is no closed form like OLS, so the maximum is found step by step:
Fixed weights plus random draws: the same model, with the same prompt, gives different answers.
The objective rewards one thing: putting high probability on the text that actually came next.
It is a prediction model. Good predictions are often true, but truth is not what was estimated.
| Text → token IDs | Embedding table | Attention layers | Output logit | |
|---|---|---|---|---|
| Estimated (fixed after training) | (chosen before training) | rows of the table | \(W_Q, W_K, W_V\) | \(w_k\) |
| Computed (fresh for your text) | token IDs | one vector per token | attention shares, \(h(\text{context})\) | next-token probabilities |
| Weights | Attention shares | Next-token probabilities | |
|---|---|---|---|
| Where they come from | maximizing the likelihood | a logit formula inside \(h(\cdot)\) | the logit formula at the end |
| What goes in | the training text | \(W_Q\), \(W_K\), and your text | \(h(\text{context})\) and \(w_k\) |
| When | once, before you use it | every layer, every token | once per token it writes |
| Fixed afterward? | yes | no | no |
| Can be negative? | yes | no | no |
| Sum to one? | no | yes, for each token | yes, over the vocabulary |
| In the logit | the coefficients | part of the regressors | the fitted probabilities |
When someone says a model has 175 billion weights, they mean the first column. The other two are computed fresh each time.
A model trained only on next-token prediction continues text. It does not answer questions. A second stage, post-training, changes that:
The objective moves from “likely on the internet” to “preferred by raters.”
Still not “true.” Raters reward answers that look helpful and confident.
Ouyang et al. (2022), “Training language models to follow instructions with human feedback.”
Mary Gray and Siddharth Suri call it ghost work:
In 2023, TIME reported that Kenyan workers labeling abusive text for OpenAI’s filter took home less than $2 an hour.
Sources: Gray and Suri, Ghost Work (2019); Billy Perrigo, TIME, January 18, 2023.
What the arithmetic is
Why a GPU
One NVIDIA H100: about 17,000 arithmetic cores, 80 GB of memory, up to 700 watts, and $25,000 to $40,000 to buy.
Sources: NVIDIA product pages; Epoch AI hardware data; Jensen Huang, CNBC, March 2024.
The cost of the largest run has grown about 2.4 times a year. Most labs do not disclose theirs.
Ranges: hardware used up (low) to cloud rental rates (high). Sources: Patterson et al. (2021); Meta; xAI; OpenAI briefing, September 2026; Epoch AI; Stanford AI Index; Cottier et al. (2024). Data compiled by Scott Cunningham.
Sources: Lawrence Berkeley National Laboratory (2024); FactSet, July 2026; Epoch AI.
Closed models
Claude, GPT, Gemini
Open-weight models
Llama, Qwen, DeepSeek, Gemma, Mistral, gpt-oss
In September 2026, the best open-weight model scored 44 and the best closed model 53 on the same public index.
Source: Artificial Analysis Intelligence Index, September 7, 2026.
Before its answer, a model can write itself a scratchpad of reasoning tokens.
| Claude | OpenAI | |
|---|---|---|
| Name of the setting | effort |
reasoning_effort |
| Levels | low, medium, high, xhigh, max | minimal, low, medium, high, xhigh |
By the token (the API)
| Dollars per million tokens | In | Out |
|---|---|---|
| Claude Fable 5.1 | 10 | 50 |
| Claude Opus 5.5 | 4 | 20 |
| Claude Haiku 4.5 | 1 | 5 |
| GPT-6 Astra | 10 | 50 |
| GPT-6.1 Sol | 2 | 10 |
| GPT-6 Luna | 0.10 | 0.50 |
By the month (a subscription)
A million tokens is about 750,000 English words.
A subscription suits daily interactive work. The API suits a script that labels 300,000 documents overnight, which is where we start on 3/22.
Sources: Anthropic and OpenAI pricing pages, October 1, 2026.
If you cannot reproduce how a number was made, it is not evidence.
This is the “checking” leg. It does not come for free anymore.
ellmer, classify text, and check the labels against labels done by hand.Everything an agent does starts from next-token prediction.