STANFORD CS109 · PROBABILITY CHALLENGE · THE LAB

Inside ChrisGPT

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.

made by Justin Yu · justinyu@stanford.edu
01

The model

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.

L19 · MLE

Count and divide

P(w|h)= c(h,w)c(h)

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.

L14 · BETA → DIRICHLET

Add a prior

P(w|h)= c(h,w)+α·P(w|h′) c(h)+α

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.

L14 · SMARTER PRIOR

Witten-Bell strength

α(h)=β·T(h)

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.

L18 · INFORMATION

Grade it in bits

H=−1N∑i=1N log2P(wi|hi) perplexity=2H

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.

02

Which model wins?

Five models, trained on the same lectures and graded on lectures none of them saw.

BITS PER WORD ON HELD-OUT LECTURES · LOWER IS BETTER · BARS = 95% BOOTSTRAP CI
03

A scaling law for one professor

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.

HELD-OUT BITS PER WORD vs TRAINING WORDS (LOG SCALE)
04

Chris gets surprising when he teaches something new

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).

EXTRA SURPRISE IN THE 20 s AFTER A KEY TERM'S FIRST MENTION (BITS/WORD vs LECTURE AVERAGE)
p < 0.05 p ≥ 0.05Each dot is one lecture
05

Where to rewind before the final

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.

★ = the concept effect is statistically significant in that lecture (p < 0.05)
—
06

How every claim was tested

  • Never graded on what it memorized. Model comparisons use whole held-out lectures; the game's rounds use 10-fold cross-validation, so each clip is guessed by a copy of ChrisGPT that never saw that part of the lecture.
  • Uncertainty, not just point estimates. Model comparisons and the scaling-law fit come with 95% bootstrap confidence intervals (L16); the concept effect uses permutation tests per lecture and a sign test across all 23.
  • No ML libraries in the model. ChrisGPT is plain Python: counting, MLE, a Dirichlet prior and Witten-Bell smoothing, written from scratch.
  • One pretrained tool, disclosed. OpenAI's Whisper turns lecture audio into text with word timestamps (like a very good microphone). It never predicts anything in the game or analysis.
  • Human vs ChrisGPT study, in progress. Every round played is logged anonymously, so we can measure how many bits CS109 students know about Chris (Shannon's 1951 guessing game, on a professor) and compare to the model.
▶ PLAY TODAY'S CHALLENGE
made by Justin Yu · justinyu@stanford.edu · Stanford CS109, Autumn 2026