Code and dense tables are folded away. Open any of them on demand.
What is expected calibration error?
Expected calibration error (ECE) measures how far a classifier's confidence is from its actual accuracy. Predictions are grouped into confidence bins, commonly fifteen equal-width bins; in each bin the gap between average confidence and accuracy is weighted by the bin's share of predictions, and the gaps are summed. Zero means perfectly calibrated on that data.
A classifier is calibrated if, among all the predictions it makes with confidence c, the fraction that are correct is c. Of the tickets routed with 80% confidence, about 80% should be routed correctly. Calibration is separate from accuracy: a model can be highly accurate and badly calibrated (always 99% sure, right 90% of the time) or poorly accurate and well calibrated (60% sure, right 60% of the time).
Calibration matters whenever a probability is used as a probability: to set a threshold, to combine with a cost, to decide when to escalate. See calibrated probabilities.
The definition
ECE, popularised by Naeini et al. (2015) and Guo et al. (2017), estimates the average gap between confidence and accuracy by binning predictions:
Show technical detailsHide technical details· text sample
It is a weighted average of the per-bin gaps, weighted by how many predictions fall in each bin. Zero means perfectly calibrated on this sample; the maximum is 1. A reliability diagram plots acc(B_m) against conf(B_m); a calibrated model lies on the diagonal, and an over-confident one sits below it.
Laya's package implements exactly this in ece_score: 15 equal-width bins, with the first bin closed at 0 so that zero-confidence predictions are counted.
A worked example
Ten predictions, three bins for readability:
Show technical detailsHide technical details· 3 rows × 6 columns
| Bin | Predictions | Mean confidence | Accuracy | Gap | Weight |
|---|---|---|---|---|---|
| 0.0 to 0.5 | 2 | 0.45 | 0.50 | 0.05 | 0.2 |
| 0.5 to 0.8 | 3 | 0.70 | 0.33 | 0.37 | 0.3 |
| 0.8 to 1.0 | 5 | 0.94 | 0.80 | 0.14 | 0.5 |
Show technical detailsHide technical details· text sample
The model is over-confident in the middle and top bins: it claims 0.70 and 0.94 but delivers 0.33 and 0.80. A temperature above 1 would pull those confidences down; see temperature scaling.
Reading a reliability diagram
A reliability diagram makes the same information visual. Plot one point per bin, with mean confidence on the x-axis and accuracy on the y-axis, and draw the diagonal. Points below the diagonal mean over-confidence; points above it mean under-confidence. Adding a histogram of how many predictions fall in each bin shows which gaps matter: a large gap in a bin with 1% of predictions contributes little to ECE, while a small gap in the bin holding most predictions can dominate it. For a decision system, the bins near your operating threshold deserve the closest look, because that is where calibration errors turn into wrong automated actions.
Pitfalls
ECE is useful but has well-documented weaknesses (Nixon et al., 2019; Kumar et al., 2019):
- It depends on binning. The number of bins and whether they are equal-width or equal-mass change the value. Compare ECE only when computed the same way. Equal-width bins with most predictions near 1.0 leave most bins nearly empty.
- It is biased with small samples. With few predictions per bin, noise inflates gaps. Report the sample size, and prefer several hundred items or more.
- It is not a proper scoring rule. A model that always predicts the base rate can have near-zero ECE and be useless. Always report ECE alongside a proper score such as Brier or log loss; see proper scoring rules.
- Top-label ECE ignores the rest of the distribution. The standard version uses only the top probability. Classwise variants check every class but need more data.
- "Confidence" must be defined. Different systems report different confidence signals. Compute ECE on the quantity you will actually threshold.
- Averages hide subgroups. A good overall ECE can conceal a language or question type that is badly miscalibrated.
What Laya's published ECE figures say
The model card reports several ECE numbers. Reading them carefully:
| Figure | Value | What it means |
|---|---|---|
| English checkpoint, mean ECE as shipped | 0.466 | Heavily over-confident out of the box |
| After per-bucket temperature refit | 0.081 | Most of the error is removable post hoc |
| Multilingual checkpoint, as shipped / after refit | 0.314 / 0.106 | Same pattern |
| Laya (routed) vs Jev 1.13.0 in the comparison table | 0.081 vs 0.246 | Laya's figure is post-temperature; Jev's is third-party published |
| typed-decisions benchmark, fine-tuned checkpoint vs Jev | 0.213 vs 0.144 | Before domain temperature fitting, Jev is better calibrated here |
| English checkpoint on Hindi (MASSIVE) | 0.855 | Near-total miscalibration on text it cannot read |
Two honest conclusions. First, Laya's probabilities become well calibrated after temperature fitting, and the card is explicit that the headline 0.081 depends on it. Second, calibration depends on reaching the right checkpoint: the 0.855 figure is why language routing exists.
A note on definitions: Laya's API returns two things you could call confidence: the top probability in probabilities, and a confidence field that is 1 − H(p)/log k for choice and score questions and max(p, 1 − p) for noul. The two have different scales. For comparability with published ECE numbers, compute ECE on the top probability; to evaluate a gate, compute accuracy against coverage on whichever field you gate on.
Computing ECE on Laya Studio responses
Collect a labelled sample and send each item through the API:
Show technical detailsHide technical details· bash sample
Then compute ECE with the same binning Laya's package uses:
Show technical detailsHide technical details· python sample
Report ECE with the Brier score and the sample size, per question and per language. If ECE is high, fit a temperature and re-measure on held-out data. Billing is per input token. Sign up for 5 free runs and see the docs.
Frequently asked questions
What is a good ECE value?
Is lower ECE always better?
How many bins should I use?
Why is Laya's ECE so different before and after temperature scaling?
Should I compute ECE on the confidence field or the top probability?
How do you calculate expected calibration error?
What is the difference between ECE and the Brier score?
Sources
- Naeini, Cooper & Hauskrecht (2015), Obtaining Well Calibrated Probabilities Using Bayesian Binning (AAAI)
- Guo et al. (2017), On Calibration of Modern Neural Networks
- Nixon et al. (2019), Measuring Calibration in Deep Learning
- Kumar, Liang & Ma (2019), Verified Uncertainty Calibration
- Laya model card
- Laya source code (common.py: ece_score)
Last updated . Laya Studio is an independent hosted service for the open-source Laya model (Apache-2.0, © Convai Innovations) and is not affiliated with Convai Innovations or TypeSafe.
Next articleLanguage routing: picking the checkpoint that can read the inputWhat language routing is: detect the script and language of each input, then send it to a model that can read it. How Laya's router decides in under 1 ms.