An entity recognizer can gain half an F1 point while becoming worse on the cases that matter to a downstream linker. The aggregate number is useful for comparison, but it cannot tell us whether errors come from tokenization, missing clinical abbreviations, inconsistent boundaries, label confusion, or annotation noise.
Error analysis is the bridge between an evaluation result and the next experiment. The goal is not to collect colourful examples. It is to partition errors so that each large bucket suggests a different intervention.
Start with the evaluation contract
For exact-match span evaluation, a predicted entity is correct only when its start offset, end offset, and type equal a gold entity:
With the resulting counts,
Before inspecting examples, write down the contract:
- Are spans represented by characters, bytes, or token indexes?
- Are end offsets inclusive or exclusive?
- Is evaluation strict, overlap-based, or both?
- Are discontinuous or nested entities supported?
- Does Unicode normalization happen before offsets are created?
- Is micro averaging used across entity types?
An offset conversion bug can look exactly like a boundary weakness. Reconstruct the substring from every evaluated span and assert that it equals the stored entity text.
Pair spans before classifying errors
Construct a bipartite graph between unmatched predictions and unmatched gold entities. Connect spans that overlap. A simple deterministic pairing strategy is:
- prefer pairs with the greatest intersection-over-union;
- break ties with matching entity type;
- leave spans with no overlap unpaired.
For character intervals and ,
This pairing does not change the official metric. It only provides a stable unit for diagnosis. A maximum-weight bipartite matching is useful when nested entities make greedy pairing ambiguous; for flat clinical NER, sorted greedy matching is often sufficient and easier to audit.
Use a mutually intelligible taxonomy
The first pass should classify each error by its visible geometry:
| Bucket | Prediction versus gold | Typical example |
|---|---|---|
| Exact boundary, wrong type | same interval, different label | symptom predicted as diagnosis |
| Left boundary | same end, different start | drops a modifier |
| Right boundary | same start, different end | includes punctuation or dosage |
| Containment | one span strictly contains the other | includes section heading |
| Crossing overlap | both boundaries differ | tokenization or coordination |
| Spurious | prediction has no overlapping gold span | abbreviation ambiguity |
| Missed | gold span has no overlapping prediction | rare surface form |
Then add orthogonal attributes rather than creating hundreds of composite labels:
- entity type and document section;
- mention length in tokens;
- seen or unseen normalized surface form;
- abbreviation, misspelling, number, or negation cue;
- sentence length and distance to relevant context;
- model confidence and margin between the top labels;
- annotator or source corpus, when those fields are available.
This structure lets us ask useful questions such as “Are right-boundary errors concentrated in medication mentions containing dose and route?” without hard-coding that scenario into the primary taxonomy.
Definition
Boundary error
A paired prediction and gold span have a boundary error when their intervals overlap but are not equal. Type correctness should be recorded separately: a prediction can have both a boundary error and a type error.
Build an auditable error record
Do not reduce the analysis to a notebook cell that prints nearby text. Store a serializable record that can be sorted, sampled, and diffed between model versions.
type Span = {
start: number;
end: number; // exclusive
label: string;
text: string;
};
type Geometry =
| "exact"
| "left-boundary"
| "right-boundary"
| "containment"
| "crossing"
| "spurious"
| "missed";
type ErrorRecord = {
documentId: string;
prediction?: Span;
gold?: Span;
geometry: Geometry;
typeCorrect: boolean | null;
context: string;
confidence?: number;
attributes: string[];
};
function overlaps(a: Span, b: Span): boolean {
return Math.max(a.start, b.start) < Math.min(a.end, b.end);
}Include document identifiers and offsets, but handle clinical text according to the data-use agreement. An error dashboard should not become an uncontrolled copy of sensitive notes.
Slice by mechanism, not only by label
Per-type recall reveals that MEDICATION is weaker than PROBLEM, but it still
mixes several mechanisms. More diagnostic slices include:
- lexical novelty: mention surface form never occurred in training;
- context dependence: abbreviation requires its section or surrounding tokens;
- composition: multi-token mention contains a head plus modifiers;
- format variation: unit, punctuation, casing, or OCR noise;
- label interaction: two adjacent entities create an illegal or unlikely BIO transition;
- guideline ambiguity: equally plausible spans receive different annotations.
Always report each slice’s support beside its metric. A 30-point recall drop on three entities is an investigation prompt, not a reliable population estimate.
Inspect the pipeline boundaries
In a biomedical system, the recognizer rarely stands alone. A predicted span may be passed to assertion detection, normalization, and entity linking. Evaluate at those interfaces.
Tokenization and offsets
Compare character spans before subword alignment and after reconstruction. Hyphens,
Vietnamese combining marks, units such as mg/mL, and de-identified placeholders
deserve explicit tests. If the gold label begins inside a tokenizer token, document
the alignment policy rather than silently rounding.
CRF constraints
Count illegal BIO sequences before any repair step. If a CRF eliminates illegal transitions but boundary errors persist, the issue is probably in emissions or annotation rather than structural decoding. Inspect transition scores only after confirming their row/column convention.
Entity linking
Measure whether the gold concept is recoverable from the gold span and from the predicted span. The difference separates retrieval weakness from upstream boundary damage. A linker tolerant of modifiers may make some strict NER errors operationally harmless; an exact lexical linker may amplify them.
Compare models on the same entities
Two aggregate reports hide whether model B truly fixes model A. Join predictions by document and gold entity, then build four sets:
- correct for both models;
- fixed by the new model;
- regressed by the new model;
- wrong for both.
Read comparable samples from the fixed and regressed sets. If improvements mainly come from frequent short mentions while regressions hit long rare mentions, the same F1 delta has a different interpretation than a uniform improvement.
A useful review sheet includes the sentence, gold span, both predictions, both confidences, taxonomy fields, and a short analyst note. Blind the model names during manual review when practical; knowledge of which system is “new” invites motivated explanations.
Turn buckets into experiments
An error bucket is valuable when it changes a decision:
| Observation | Plausible next test |
|---|---|
| unseen abbreviations dominate misses | abbreviation expansion or retrieval-augmented features |
| long medication spans lose dose suffixes | guideline review, targeted examples, boundary objective |
| errors cluster after subword splits | audit label alignment and tokenizer normalization |
| exact span, wrong semantic type | improve contextual representation or revise label definitions |
| gold inconsistencies dominate reviewed errors | double annotation and adjudication |
| NER boundary errors barely affect linking | optimize the end-to-end metric as well as strict F1 |
Avoid changing the model, decoder, augmentation, and annotation rules in one step. The taxonomy should make a small causal experiment possible.
A compact review protocol
For each model checkpoint:
- freeze the evaluation script and dataset version;
- compute strict metrics and per-type supports;
- pair overlapping unmatched spans;
- assign geometry automatically;
- stratify by type, novelty, length, and section;
- manually review balanced samples from the largest and most costly buckets;
- compare fixes and regressions against the previous model;
- write one hypothesis, one intervention, and one expected slice-level change.
The result is not merely a better report. It is a feedback system connecting data, model structure, decoding, and downstream behavior—exactly the information a single F1 score necessarily discards.
References
Further reading
- Chinchor and Sundheim. “MUC-5 Evaluation Metrics.” Fifth Message Understanding Conference, 1993.
- Fu, Liu, and Neubig. “Interpretable Multi-dataset Evaluation for Named Entity Recognition.” EMNLP, 2020.
- Reimers and Gurevych. “Reporting Score Distributions Makes a Difference.” EMNLP, 2017.