Private notes
0/8000

Notes stay private to your browser until account sync is configured.

Part 5
16 min read6 headingsSplit lesson page

Lesson overview | Previous part | Next part

Calibration and Uncertainty: Part 5: Post-Hoc Calibration

5. Post-Hoc Calibration

Post-Hoc Calibration is the part of calibration and uncertainty that turns the approved TOC into a concrete learning path. The subsections below keep the focus on Chapter 17's canonical job: measurement, reliability, uncertainty, and decision support for AI systems.

5.1 Temperature scaling

Temperature scaling is part of the canonical scope of calibration and uncertainty. In this chapter, the object under study is not merely a dataset or a model, but the full probabilistic forecast: the items, prompts, outputs, graders, uncertainty statements, and decision rules that turn model behavior into evidence.

The basic mathematical pattern is an empirical estimator. For a model or system mm evaluated on items z1,,znz_1,\ldots,z_n, the local estimate is written

ECE=1ni=1nNLL.\operatorname{ECE} = \frac{1}{n}\sum_{i=1}^n \ell_{\mathrm{NLL}}.

The formula is intentionally simple. The difficulty lies in deciding what counts as an item, which loss or score is meaningful, whether the items are independent, and whether the estimate answers the real product or research question. For temperature scaling, those choices determine whether the reported number is evidence or decoration.

A useful invariant is that every evaluation claim should be reproducible as a tuple (m,T,π,g,ρ)(m,\mathcal{T},\pi,g,\rho), where mm is the system, T\mathcal{T} is the task sample, π\pi is the prompt or intervention policy, gg is the grader, and ρ\rho is the aggregation rule. If any part of this tuple is missing, the number cannot be audited.

ComponentWhat to recordWhy it matters
Item definitionIDs, source, split, and allowed transformationsPrevents accidental drift in temperature scaling
Scoring ruleExact formula for \ell_{\mathrm{NLL}}Makes comparisons repeatable
AggregationMean, weighted mean, worst group, or pairwise modelDetermines the scientific claim
UncertaintyStandard error, interval, or posterior summarySeparates signal from sampling noise
Audit trailCode version and random seedsMakes failures debuggable

Examples of correct use:

  • Report temperature scaling with item count, prompt protocol, grader version, and a confidence interval.
  • Use paired comparisons when two models answer the same evaluation items.
  • Inspect at least one meaningful slice before concluding that the aggregate result is reliable.
  • Store raw outputs so future graders can be replayed without querying the model again.
  • Document whether the metric is measuring capability, reliability, user value, or risk.

Non-examples:

  • A leaderboard point estimate without sample size.
  • A benchmark score produced with an undocumented prompt template.
  • A model-graded result without judge identity, rubric, or agreement check.
  • A robustness claim measured only on the easiest in-distribution examples.
  • An online win declared before the randomization and logging checks pass.

Worked evaluation pattern for temperature scaling:

  1. Define the evaluation population in words before writing code.
  2. Choose the smallest metric set that answers the decision question.
  3. Compute the point estimate and an uncertainty statement together.
  4. Run a slice or paired analysis to check whether the aggregate hides structure.
  5. Archive raw outputs, scores, and seeds before changing the prompt or grader.

For AI systems, temperature scaling is especially delicate because the same model can be used with many prompts, decoding policies, tools, retrieval contexts, and safety filters. The measured quantity is therefore a property of the system configuration, not just the base weights.

AI connectionEvaluation consequence
PromptingTreat prompt templates as part of the protocol, not as invisible setup
DecodingTemperature and sampling change both mean score and variance
RetrievalRetrieved context creates an extra source of failure and leakage
Tool useTool errors need separate attribution from model reasoning errors
Safety layerGuardrail behavior can improve risk metrics while changing capability metrics

Implementation checklist:

  • Use deterministic seeds for synthetic or sampled evaluation subsets.
  • Print metric denominators, not only percentages.
  • Keep missing, invalid, timeout, and refusal outcomes explicit.
  • Prefer typed result records over loose CSV columns.
  • Separate raw model outputs from normalized grader inputs.
  • Track the smallest reproducible command that generated the result.
  • Record whether the estimate is item-weighted, token-weighted, user-weighted, or domain-weighted.
  • Write the decision rule before seeing the final score whenever the result will guide a release.

The mathematical habit to build is skepticism with structure. A score is not ignored because it is noisy; it is interpreted through the design that produced it. Temperature scaling is one place where that habit becomes concrete.

5.2 Platt scaling

Platt scaling is part of the canonical scope of calibration and uncertainty. In this chapter, the object under study is not merely a dataset or a model, but the full probabilistic forecast: the items, prompts, outputs, graders, uncertainty statements, and decision rules that turn model behavior into evidence.

The basic mathematical pattern is an empirical estimator. For a model or system mm evaluated on items z1,,znz_1,\ldots,z_n, the local estimate is written

ECE=1ni=1nNLL.\operatorname{ECE} = \frac{1}{n}\sum_{i=1}^n \ell_{\mathrm{NLL}}.

The formula is intentionally simple. The difficulty lies in deciding what counts as an item, which loss or score is meaningful, whether the items are independent, and whether the estimate answers the real product or research question. For platt scaling, those choices determine whether the reported number is evidence or decoration.

A useful invariant is that every evaluation claim should be reproducible as a tuple (m,T,π,g,ρ)(m,\mathcal{T},\pi,g,\rho), where mm is the system, T\mathcal{T} is the task sample, π\pi is the prompt or intervention policy, gg is the grader, and ρ\rho is the aggregation rule. If any part of this tuple is missing, the number cannot be audited.

ComponentWhat to recordWhy it matters
Item definitionIDs, source, split, and allowed transformationsPrevents accidental drift in platt scaling
Scoring ruleExact formula for \ell_{\mathrm{NLL}}Makes comparisons repeatable
AggregationMean, weighted mean, worst group, or pairwise modelDetermines the scientific claim
UncertaintyStandard error, interval, or posterior summarySeparates signal from sampling noise
Audit trailCode version and random seedsMakes failures debuggable

Examples of correct use:

  • Report platt scaling with item count, prompt protocol, grader version, and a confidence interval.
  • Use paired comparisons when two models answer the same evaluation items.
  • Inspect at least one meaningful slice before concluding that the aggregate result is reliable.
  • Store raw outputs so future graders can be replayed without querying the model again.
  • Document whether the metric is measuring capability, reliability, user value, or risk.

Non-examples:

  • A leaderboard point estimate without sample size.
  • A benchmark score produced with an undocumented prompt template.
  • A model-graded result without judge identity, rubric, or agreement check.
  • A robustness claim measured only on the easiest in-distribution examples.
  • An online win declared before the randomization and logging checks pass.

Worked evaluation pattern for platt scaling:

  1. Define the evaluation population in words before writing code.
  2. Choose the smallest metric set that answers the decision question.
  3. Compute the point estimate and an uncertainty statement together.
  4. Run a slice or paired analysis to check whether the aggregate hides structure.
  5. Archive raw outputs, scores, and seeds before changing the prompt or grader.

For AI systems, platt scaling is especially delicate because the same model can be used with many prompts, decoding policies, tools, retrieval contexts, and safety filters. The measured quantity is therefore a property of the system configuration, not just the base weights.

AI connectionEvaluation consequence
PromptingTreat prompt templates as part of the protocol, not as invisible setup
DecodingTemperature and sampling change both mean score and variance
RetrievalRetrieved context creates an extra source of failure and leakage
Tool useTool errors need separate attribution from model reasoning errors
Safety layerGuardrail behavior can improve risk metrics while changing capability metrics

Implementation checklist:

  • Use deterministic seeds for synthetic or sampled evaluation subsets.
  • Print metric denominators, not only percentages.
  • Keep missing, invalid, timeout, and refusal outcomes explicit.
  • Prefer typed result records over loose CSV columns.
  • Separate raw model outputs from normalized grader inputs.
  • Track the smallest reproducible command that generated the result.
  • Record whether the estimate is item-weighted, token-weighted, user-weighted, or domain-weighted.
  • Write the decision rule before seeing the final score whenever the result will guide a release.

The mathematical habit to build is skepticism with structure. A score is not ignored because it is noisy; it is interpreted through the design that produced it. Platt scaling is one place where that habit becomes concrete.

5.3 Isotonic regression

Isotonic regression is part of the canonical scope of calibration and uncertainty. In this chapter, the object under study is not merely a dataset or a model, but the full probabilistic forecast: the items, prompts, outputs, graders, uncertainty statements, and decision rules that turn model behavior into evidence.

The basic mathematical pattern is an empirical estimator. For a model or system mm evaluated on items z1,,znz_1,\ldots,z_n, the local estimate is written

ECE=1ni=1nNLL.\operatorname{ECE} = \frac{1}{n}\sum_{i=1}^n \ell_{\mathrm{NLL}}.

The formula is intentionally simple. The difficulty lies in deciding what counts as an item, which loss or score is meaningful, whether the items are independent, and whether the estimate answers the real product or research question. For isotonic regression, those choices determine whether the reported number is evidence or decoration.

A useful invariant is that every evaluation claim should be reproducible as a tuple (m,T,π,g,ρ)(m,\mathcal{T},\pi,g,\rho), where mm is the system, T\mathcal{T} is the task sample, π\pi is the prompt or intervention policy, gg is the grader, and ρ\rho is the aggregation rule. If any part of this tuple is missing, the number cannot be audited.

ComponentWhat to recordWhy it matters
Item definitionIDs, source, split, and allowed transformationsPrevents accidental drift in isotonic regression
Scoring ruleExact formula for \ell_{\mathrm{NLL}}Makes comparisons repeatable
AggregationMean, weighted mean, worst group, or pairwise modelDetermines the scientific claim
UncertaintyStandard error, interval, or posterior summarySeparates signal from sampling noise
Audit trailCode version and random seedsMakes failures debuggable

Examples of correct use:

  • Report isotonic regression with item count, prompt protocol, grader version, and a confidence interval.
  • Use paired comparisons when two models answer the same evaluation items.
  • Inspect at least one meaningful slice before concluding that the aggregate result is reliable.
  • Store raw outputs so future graders can be replayed without querying the model again.
  • Document whether the metric is measuring capability, reliability, user value, or risk.

Non-examples:

  • A leaderboard point estimate without sample size.
  • A benchmark score produced with an undocumented prompt template.
  • A model-graded result without judge identity, rubric, or agreement check.
  • A robustness claim measured only on the easiest in-distribution examples.
  • An online win declared before the randomization and logging checks pass.

Worked evaluation pattern for isotonic regression:

  1. Define the evaluation population in words before writing code.
  2. Choose the smallest metric set that answers the decision question.
  3. Compute the point estimate and an uncertainty statement together.
  4. Run a slice or paired analysis to check whether the aggregate hides structure.
  5. Archive raw outputs, scores, and seeds before changing the prompt or grader.

For AI systems, isotonic regression is especially delicate because the same model can be used with many prompts, decoding policies, tools, retrieval contexts, and safety filters. The measured quantity is therefore a property of the system configuration, not just the base weights.

AI connectionEvaluation consequence
PromptingTreat prompt templates as part of the protocol, not as invisible setup
DecodingTemperature and sampling change both mean score and variance
RetrievalRetrieved context creates an extra source of failure and leakage
Tool useTool errors need separate attribution from model reasoning errors
Safety layerGuardrail behavior can improve risk metrics while changing capability metrics

Implementation checklist:

  • Use deterministic seeds for synthetic or sampled evaluation subsets.
  • Print metric denominators, not only percentages.
  • Keep missing, invalid, timeout, and refusal outcomes explicit.
  • Prefer typed result records over loose CSV columns.
  • Separate raw model outputs from normalized grader inputs.
  • Track the smallest reproducible command that generated the result.
  • Record whether the estimate is item-weighted, token-weighted, user-weighted, or domain-weighted.
  • Write the decision rule before seeing the final score whenever the result will guide a release.

The mathematical habit to build is skepticism with structure. A score is not ignored because it is noisy; it is interpreted through the design that produced it. Isotonic regression is one place where that habit becomes concrete.

5.4 Validation split discipline

Validation split discipline is part of the canonical scope of calibration and uncertainty. In this chapter, the object under study is not merely a dataset or a model, but the full probabilistic forecast: the items, prompts, outputs, graders, uncertainty statements, and decision rules that turn model behavior into evidence.

The basic mathematical pattern is an empirical estimator. For a model or system mm evaluated on items z1,,znz_1,\ldots,z_n, the local estimate is written

ECE=1ni=1nNLL.\operatorname{ECE} = \frac{1}{n}\sum_{i=1}^n \ell_{\mathrm{NLL}}.

The formula is intentionally simple. The difficulty lies in deciding what counts as an item, which loss or score is meaningful, whether the items are independent, and whether the estimate answers the real product or research question. For validation split discipline, those choices determine whether the reported number is evidence or decoration.

A useful invariant is that every evaluation claim should be reproducible as a tuple (m,T,π,g,ρ)(m,\mathcal{T},\pi,g,\rho), where mm is the system, T\mathcal{T} is the task sample, π\pi is the prompt or intervention policy, gg is the grader, and ρ\rho is the aggregation rule. If any part of this tuple is missing, the number cannot be audited.

ComponentWhat to recordWhy it matters
Item definitionIDs, source, split, and allowed transformationsPrevents accidental drift in validation split discipline
Scoring ruleExact formula for \ell_{\mathrm{NLL}}Makes comparisons repeatable
AggregationMean, weighted mean, worst group, or pairwise modelDetermines the scientific claim
UncertaintyStandard error, interval, or posterior summarySeparates signal from sampling noise
Audit trailCode version and random seedsMakes failures debuggable

Examples of correct use:

  • Report validation split discipline with item count, prompt protocol, grader version, and a confidence interval.
  • Use paired comparisons when two models answer the same evaluation items.
  • Inspect at least one meaningful slice before concluding that the aggregate result is reliable.
  • Store raw outputs so future graders can be replayed without querying the model again.
  • Document whether the metric is measuring capability, reliability, user value, or risk.

Non-examples:

  • A leaderboard point estimate without sample size.
  • A benchmark score produced with an undocumented prompt template.
  • A model-graded result without judge identity, rubric, or agreement check.
  • A robustness claim measured only on the easiest in-distribution examples.
  • An online win declared before the randomization and logging checks pass.

Worked evaluation pattern for validation split discipline:

  1. Define the evaluation population in words before writing code.
  2. Choose the smallest metric set that answers the decision question.
  3. Compute the point estimate and an uncertainty statement together.
  4. Run a slice or paired analysis to check whether the aggregate hides structure.
  5. Archive raw outputs, scores, and seeds before changing the prompt or grader.

For AI systems, validation split discipline is especially delicate because the same model can be used with many prompts, decoding policies, tools, retrieval contexts, and safety filters. The measured quantity is therefore a property of the system configuration, not just the base weights.

AI connectionEvaluation consequence
PromptingTreat prompt templates as part of the protocol, not as invisible setup
DecodingTemperature and sampling change both mean score and variance
RetrievalRetrieved context creates an extra source of failure and leakage
Tool useTool errors need separate attribution from model reasoning errors
Safety layerGuardrail behavior can improve risk metrics while changing capability metrics

Implementation checklist:

  • Use deterministic seeds for synthetic or sampled evaluation subsets.
  • Print metric denominators, not only percentages.
  • Keep missing, invalid, timeout, and refusal outcomes explicit.
  • Prefer typed result records over loose CSV columns.
  • Separate raw model outputs from normalized grader inputs.
  • Track the smallest reproducible command that generated the result.
  • Record whether the estimate is item-weighted, token-weighted, user-weighted, or domain-weighted.
  • Write the decision rule before seeing the final score whenever the result will guide a release.

The mathematical habit to build is skepticism with structure. A score is not ignored because it is noisy; it is interpreted through the design that produced it. Validation split discipline is one place where that habit becomes concrete.

5.5 Calibration under shift

Calibration under shift is part of the canonical scope of calibration and uncertainty. In this chapter, the object under study is not merely a dataset or a model, but the full probabilistic forecast: the items, prompts, outputs, graders, uncertainty statements, and decision rules that turn model behavior into evidence.

The basic mathematical pattern is an empirical estimator. For a model or system mm evaluated on items z1,,znz_1,\ldots,z_n, the local estimate is written

ECE=1ni=1nNLL.\operatorname{ECE} = \frac{1}{n}\sum_{i=1}^n \ell_{\mathrm{NLL}}.

The formula is intentionally simple. The difficulty lies in deciding what counts as an item, which loss or score is meaningful, whether the items are independent, and whether the estimate answers the real product or research question. For calibration under shift, those choices determine whether the reported number is evidence or decoration.

A useful invariant is that every evaluation claim should be reproducible as a tuple (m,T,π,g,ρ)(m,\mathcal{T},\pi,g,\rho), where mm is the system, T\mathcal{T} is the task sample, π\pi is the prompt or intervention policy, gg is the grader, and ρ\rho is the aggregation rule. If any part of this tuple is missing, the number cannot be audited.

ComponentWhat to recordWhy it matters
Item definitionIDs, source, split, and allowed transformationsPrevents accidental drift in calibration under shift
Scoring ruleExact formula for \ell_{\mathrm{NLL}}Makes comparisons repeatable
AggregationMean, weighted mean, worst group, or pairwise modelDetermines the scientific claim
UncertaintyStandard error, interval, or posterior summarySeparates signal from sampling noise
Audit trailCode version and random seedsMakes failures debuggable

Examples of correct use:

  • Report calibration under shift with item count, prompt protocol, grader version, and a confidence interval.
  • Use paired comparisons when two models answer the same evaluation items.
  • Inspect at least one meaningful slice before concluding that the aggregate result is reliable.
  • Store raw outputs so future graders can be replayed without querying the model again.
  • Document whether the metric is measuring capability, reliability, user value, or risk.

Non-examples:

  • A leaderboard point estimate without sample size.
  • A benchmark score produced with an undocumented prompt template.
  • A model-graded result without judge identity, rubric, or agreement check.
  • A robustness claim measured only on the easiest in-distribution examples.
  • An online win declared before the randomization and logging checks pass.

Worked evaluation pattern for calibration under shift:

  1. Define the evaluation population in words before writing code.
  2. Choose the smallest metric set that answers the decision question.
  3. Compute the point estimate and an uncertainty statement together.
  4. Run a slice or paired analysis to check whether the aggregate hides structure.
  5. Archive raw outputs, scores, and seeds before changing the prompt or grader.

For AI systems, calibration under shift is especially delicate because the same model can be used with many prompts, decoding policies, tools, retrieval contexts, and safety filters. The measured quantity is therefore a property of the system configuration, not just the base weights.

AI connectionEvaluation consequence
PromptingTreat prompt templates as part of the protocol, not as invisible setup
DecodingTemperature and sampling change both mean score and variance
RetrievalRetrieved context creates an extra source of failure and leakage
Tool useTool errors need separate attribution from model reasoning errors
Safety layerGuardrail behavior can improve risk metrics while changing capability metrics

Implementation checklist:

  • Use deterministic seeds for synthetic or sampled evaluation subsets.
  • Print metric denominators, not only percentages.
  • Keep missing, invalid, timeout, and refusal outcomes explicit.
  • Prefer typed result records over loose CSV columns.
  • Separate raw model outputs from normalized grader inputs.
  • Track the smallest reproducible command that generated the result.
  • Record whether the estimate is item-weighted, token-weighted, user-weighted, or domain-weighted.
  • Write the decision rule before seeing the final score whenever the result will guide a release.

The mathematical habit to build is skepticism with structure. A score is not ignored because it is noisy; it is interpreted through the design that produced it. Calibration under shift is one place where that habit becomes concrete.

Skill Check

Test this lesson

Answer 4 quick questions to lock in the lesson and feed your adaptive practice queue.

--
Score
0/4
Answered
Not attempted
Status
1

Which module does this lesson belong to?

2

Which section is covered in this lesson content?

3

Which term is most central to this lesson?

4

What is the best way to use this lesson for real learning?

Your answers save locally first, then sync when account storage is available.
Practice queue