Lesson 3 used Bayes' theorem to update the probability of one event. The same move works on a number you can never observe directly, like a model's true accuracy.
In Lesson 3 the hypothesis was a yes/no event: "this response is a hallucination." You had a base rate, a detector's flag, and one update. This lesson changes the hypothesis. It becomes a parameter: the true accuracy θ of a model, the true win rate of a prompt, the weight of a network. A parameter can take any value in a range, so your belief about it is a whole distribution, not a single probability. Lesson 13 introduced the Beta distribution for exactly this kind of quantity, a number between 0 and 1. Here you put it to work.
The theorem has not changed. Only the thing on the left has:
∝ means "proportional to." The denominator from Lesson 3, P(evidence), only rescales the curve to total 1, so you can drop it while finding the shape.
| Piece | Lesson 3 (an event) | This lesson (a parameter) |
|---|---|---|
| Prior | 2% of responses hallucinate | A distribution over θ before the eval: "accuracy is probably around 0.8" |
| Likelihood | Detector flags 90% of real hallucinations | How probable "6 correct out of 10" is for each possible θ |
| Posterior | 27% that a flagged response is real | A new distribution over θ after the eval |
Lesson 5 returned one number (the maximum likelihood estimate, the observed proportion) plus a confidence interval. The Bayesian answer is a full curve of how plausible each θ is, given the prior and the data.
A team is evaluating a new model version on a yes/no task: each prompt is answered correctly or not. Call the unknown true probability of a correct answer θ. Before running anything, the team has a view. The previous version scored around 80%, and they expect the new one to be similar. They encode that as a Beta(8, 2) prior (Lesson 13: the mean of Beta(α, β) is α/(α+β)).
The useful way to read α and β is as pseudo-counts: Beta(8, 2) behaves as if the team had already seen 8 correct and 2 wrong answers, 10 imagined prompts in total. That is a real opinion, but still wide: the prior alone allows anything from about 52% to 97%.
A prior is a modelling choice, not a fact: state where it came from, and check how far the answer moves if you change it.
The team runs a small eval: n = 10 prompts, k = 6 answered correctly. Given a value θ, the probability of that result is proportional to θk(1−θ)n−k. Multiply by the prior, which has the same form with exponents α−1 and β−1, and exponents on the same base add:
The posterior is another Beta. A prior that stays in its own family after the update is called conjugate. The update is just addition: add the correct answers to α and the wrong answers to β.
The posterior mean 0.70 sits exactly halfway between the prior mean 0.80 and the observed 0.60. The next section shows why.
Rewrite the posterior mean as a weighted average of the prior mean and the observed proportion. With a prior worth α+β = 10 pseudo-prompts and n real ones:
Now run a much larger eval with the same 60% hit rate: n = 1000, k = 600. The posterior is Beta(8 + 600, 2 + 400) = Beta(608, 402).
| Eval | Posterior | Mean | 95% credible interval | P(θ > 0.8) |
|---|---|---|---|---|
| No data (prior) | Beta(8, 2) | 0.800 | 0.518 to 0.972 | 0.564 |
| 6 of 10 | Beta(14, 6) | 0.700 | 0.488 to 0.874 | 0.163 |
| 600 of 1000 | Beta(608, 402) | 0.602 | 0.572 to 0.632 | about 0 |
The last column is something a Bayesian posterior hands you for free: a direct probability for a claim. After 10 prompts, there is still a 16% chance the new model is above 80%, because the prior keeps that door open. After 1000 prompts, the claim is dead. (The interval width falls from 0.386 to 0.060, the square-root tax from Lesson 5.)
Dashed purple is the Beta(8,2) prior. Left: 10 prompts drag it only part of the way toward 0.60, and it stays wide. Right: 1000 prompts leave a narrow spike on 0.60 (vertical scale about six times taller).
The prior is worth α+β imagined observations and the eval is worth n real ones; whichever is bigger wins. Ten prompts really do carry little information, so the posterior stays cautious.
Evals rarely arrive in one batch. Because the update is addition, you can do it in pieces. Start with the Beta(14, 6) posterior from the first 10 prompts and treat it as the prior for the next batch: 40 new prompts, 30 correct.
Batch by batch or all at once, the result is identical, so you never need to keep raw data around to keep a running belief: two numbers, α and β, summarise everything seen so far.
Lesson 5's maximum likelihood estimate picks the θ that makes the data most probable. The Bayesian counterpart picks the θ at the peak of the posterior, called the maximum a posteriori estimate, or MAP.
The MAP is the MLE pulled toward the prior. Two limits are worth noticing. With a flat prior, Beta(1, 1), the MAP formula gives k/n, so MAP equals MLE. With lots of data, the prior's pull vanishes, as in the table above. MAP keeps only the peak, not the curve's width, so it says nothing about how sure to be.
Lesson 8 introduced weight penalties (L2) as a way to hold a model back from overfitting. They are exactly a Gaussian prior on the weights. Take logs of the posterior, then negate to get a loss you minimise:
The first term is the data's negative log-likelihood, summed over examples: the cross-entropy loss from Lesson 7, or, for regression with Gaussian noise of variance σ², the squared-error loss from Lesson 6 divided by 2σ². The second is the L2 penalty. The formula λ = 1/(2τ²) holds against that summed negative log-likelihood; against plain squared error it becomes σ²/τ², and if the loss is averaged over n examples, divide λ by n.The prior's width sets its strength: τ = 1 gives λ = 0.5, and a tighter prior, τ = 0.5, gives λ = 1/(2 × 0.25) = 2. "Weights should be small" is the belief "weights are probably near zero," and regularization strength is how firmly you hold it. So regularized training is MAP estimation; a fully Bayesian treatment keeps the whole posterior over the weights.
Compare the Lesson 5 rule of thumb (observed ± 2 standard errors) with the Beta credible interval on the same evals.
At n = 1000 they agree to within a few thousandths. At n = 10 the credible interval is far narrower, and the reason is the prior: it contributed the equivalent of 10 more prompts. That narrowing is earned only if the prior was reasonable. A wrong confident prior gives a tight interval around the wrong place.
| Frequentist (Lesson 5) | Bayesian (this lesson) | |
|---|---|---|
| What θ is | A fixed unknown constant | Uncertain, so described by a distribution |
| What is random | The data, across repeated evals | Your belief; the observed data is fixed |
| Point estimate | MLE: 0.600 | Posterior mean 0.700 or MAP 0.722 |
| Interval | Confidence: 0.29 to 0.91, a statement about the procedure | Credible: 0.488 to 0.874, a statement about θ |
| Prior knowledge | Not part of the formal method | Required, and stated openly |
| Behaviour with lots of data | Both converge to nearly the same answer | |
What you often need is not θ itself but a forecast: will the next prompt be answered correctly? Without uncertainty you would plug in a single estimate. A Bayesian averages the prediction over every θ, weighted by the posterior. That is the posterior predictive.
For one yes/no outcome, "correct" has probability θ, so averaging θ over the posterior is just the posterior mean:
The two forecasts differ because the Bayesian one admits the 10-prompt eval is thin and leans toward the prior. The difference grows for events involving more than one prompt. Take the probability that the next two prompts are both correct. The Beta gives a closed form, α(α+1) / ((α+β)(α+β+1)):
An independent numerical integration of θ² against the Beta(14, 6) density also gives 0.500. The leftover 0.010 is the posterior variance: two answers are positively linked through the shared unknown θ even though they are independent once θ is known.
Test a new prompt on 10 cases and a Beta posterior lets you say "there is a 16% chance this is above 80%" instead of quoting a bare score. Per-prompt or per-route success rates in production work the same way: add one to α or β per call, and the estimate starts at the prior and sharpens as traffic arrives. Bandit-style routing between models keeps one Beta per option.
Weight penalties are priors, so tuning weight decay means choosing how firmly to believe weights are small.
Every posterior here, like every p-value in Lesson 15, assumes the eval data was a fair sample. If the prompts were cherry-picked, the groups were assigned by something related to the outcome, or test items leaked into training, no prior and no test can fix the number. Lesson 17 covers study design: random sampling, randomized comparisons, confounding, and data leakage.
1. A team's prior on a model's accuracy is Beta(8, 2). They run 5 prompts and 3 are answered correctly. What is the posterior?
2. With a Beta(8, 2) prior, why does a 10-prompt eval leave the posterior near the prior, while a 1000-prompt eval does not?
3. Adding an L2 weight penalty to a training loss is equivalent to which Bayesian choice?
4. A report gives a 95% credible interval of 0.49 to 0.87 for accuracy. What does it say?
5. A team updates a Beta posterior after batch 1, then uses it as the prior for batch 2. Compared with pooling both batches into one update from the original prior, the result is: