Count and divide
The maximum-likelihood estimate: of the c(h) times Chris said the phrase h, how often was w next? Perfect on phrases he's said a lot, useless (probability 0) on new ones.
Every chatbot is a next-word predictor. ChrisGPT is one you can see inside: built from scratch with CS109 probability on 277,418 words of Chris Gregg's lectures. No neural nets, no internet, just counting, maximum likelihood and Bayes.
Given what Chris just said (the history h), ChrisGPT puts a probability on every word w he could say next. Four ideas from CS109 build it, one on top of the other.
The maximum-likelihood estimate: of the c(h) times Chris said the phrase h, how often was w next? Perfect on phrases he's said a lot, useless (probability 0) on new ones.
Put a Dirichlet prior (the Beta, generalized to many outcomes) centred on the prediction from the shorter phrase h′. The posterior predictive is the Beta's "add pseudo-counts" rule: α imaginary observations drawn from the shorter context.
T(h) is how many different words have followed h. A phrase followed by many different words is unpredictable, so it should lean harder on the shorter context. β = 4, fit by maximum likelihood.
Average surprise per word on lectures the model never saw. Perplexity 2H means "as unsure as picking uniformly among that many words." Lower is better; it's how real language models are graded.
Five models, trained on the same lectures and graded on lectures none of them saw.
Train ChrisGPT on 1, 2, 4, … 20 lectures and test on lectures it never heard. The more Chris it hears, the less he surprises it, and the curve has the same power-law shape researchers report for giant language models.
Each lecture's key terms are the words that most separate it from the rest of the course (their contribution to the KL divergence, L18). If surprise marks new ideas, ChrisGPT should be more surprised right after a key term first appears. We tested it with a permutation test in every lecture (L16).
The moments ChrisGPT found hardest to predict, minute by minute, for every lecture. Peaks are where Chris stopped being predictable, usually because he was introducing something new. Ticks mark where each key term first shows up.