0 means the two structures are identical; higher scores mean more fields drifted from the reference.
Reach for this when you have a golden dataset — examples paired with the exact JSON a correct model run should produce — and you want to know how close the output got, not just whether it was perfect. Typical cases:
- Structured extraction. The model pulls fields out of a document (invoice line items, contact records, form data) and you have hand-labeled JSON for each example. A binary match collapses “one wrong field” and “everything wrong” into the same score; distance tells them apart, which is what you want when tracking regressions across prompt or model changes.
- Tool call arguments. An agent emits a tool call whose
argumentsobject should match a known-good payload. Per-field distance pinpoints whether the model is consistently dropping one argument vs. hallucinating a different shape entirely. - Prompt-change A/B. You’re comparing two prompt versions against the same golden references. Mean distance moves smoothly as quality changes; mean exact-match doesn’t, because most diffs are partial.
output == reference. Use distance when partial credit matters.
Code
- Python
- TypeScript
Input mapping
Output configuration
Continuous score:
The categorical
label is informational; the score is the primary signal.

