In production AI, your evaluation harness is your real specification. If your eval allows schema drift, rewards a loophole, or ignores probability calibration, any strong optimizer—human or AI—will ship broken behavior that scores 100%.
1. Schema Drift & Constrained Decoding
Ask an LLM to emit a 6,000-token structured JSON config with strict enum values, and you will quickly see schema drift: near the end of a long generation, attention dilutes and models fall back on English habits—inventing plausible-sounding fake enums (like "MGR_DAY" instead of "MGR_MORNING", or shortening "OFFICE_HIDER" to "OFFICE").
- Basic
json_objectmode only checks brackets and commas, not domain invariants. - Constrained Decoding (
strict: trueStructured Outputs,xgrammar,Outlines,llguidance) compiles your JSON Schema into a finite-state machine that masks every invalid token's logit to \(-\infty\) before Softmax—guaranteeing 100% schema adherence at inference time.
2. Goodhart's Law & Five Defenses for Reliable Evals
Whenever you hand an optimizer a single proxy score, Reward Hacking (Goodhart's Law) kicks in: it finds the cheapest loophole that inflates the metric while violating the spirit of the task (editing unit tests to pass, writing bloated responses to game length-biased judges, or exploiting unrealistic benchmark loopholes).
Five practical defenses used in serious AI evals and alignment testing:
- Constrained Multi-Objective Grading: Never optimize one scalar alone. Grade primary performance subject to hard safety, latency, cost, and compliance floors.
- Pressure / Value-Conflict Tests: Easy, sunny-day prompts rarely reveal failure modes. Test right at the stress boundary (tight budgets, conflicting instructions, adversarial edge cases) where cutting corners becomes tempting.
- Audit the Trace, Not Just the Final Output: Two runs can return the same final answer—one by genuine reasoning, one by silently swallowing an error or bypassing a check. Inspect tool calls and intermediate actions.
- Unannounced / Held-Out Splits: Keep a private test suite with unseen seeds and edge cases to catch overfitting and benchmark memorization.
- Lock the Referee: Never let the evaluated agent modify its own test suite, grading rubric, or environment rules.
3. Calibration: Making Confidence Numbers Honest
Accuracy only tells you how often a model's top guess is right. Calibration tells you whether you can trust its stated confidence—crucial for automated routing, medical/fraud thresholds, and knowing when an assistant should abstain.
- Measure it with ECE (Expected Calibration Error): Group predictions into confidence bins and compute the weighted gap between average confidence and empirical accuracy: \[\text{ECE} = \sum_{m=1}^{M} \frac{|B_m|}{n}\,\big|\operatorname{acc}(B_m) - \operatorname{conf}(B_m)\big|\]
- Train with Proper Scoring Rules: Cross-Entropy (Log Loss) and Brier Score are mathematically structured so the only way to minimize expected loss is to output true probabilities—bluffing always hurts.
- Fix overconfidence cheaply with Temperature Scaling: Fit a single scalar \(T > 0\) on a held-out validation set via \(\operatorname{softmax}(\mathbf{z}/T)\). Top-1 accuracy stays 100% unchanged while probabilities become honest.
- Score rubrics smoothly with Expected Rubric Score: When using an LLM-as-a-judge on a 1–5 scale, compute \(\mathbb{E}[L] = \sum_i L_i p_i\) from the token probabilities instead of snapping to a noisy integer
argmax.