jevrecipes

Recipe catalog / extraction-fidelity

Grade extraction fidelity

extraction-fidelity is a Jev recipe from the jev-recipes TypeScript package. How faithfully does extracted represent the facts in source, without invented, altered, or dropped values, on a five-level rubric? Use it when you need to grade a structured extraction against its source document before trusting, storing, or acting on the values.

Last updated .

Explore this recipe interactively · Source and implementation guide · Markdown version

How do I use extraction-fidelity in TypeScript?

Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.

import { extractionFidelity } from 'jev-recipes/extraction-fidelity';

const result = await extractionFidelity({
  "source": "Invoice INV-2041 issued 3 March 2026 to Harbor Lighting Ltd for 12 LED fixtures at $85.00 each. Subtotal $1,020.00, tax $81.60, total $1,101.60. Payment due 2 April 2026.",
  "extracted": "{\"invoiceNumber\":\"INV-2041\",\"issued\":\"2026-03-03\",\"customer\":\"Harbor Lighting Ltd\",\"total\":1101.6,\"due\":\"2026-04-02\"}",
  "minConfidence": 0.8
});
console.log(result);

What input does extraction-fidelity take?

FieldTypeNeeded
sourcestringRequired
extractedstringRequired
minConfidencenumberOptional
Full input and result schemas
{
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "source": {
        "type": "string"
      },
      "extracted": {
        "type": "string"
      },
      "minConfidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      }
    },
    "required": [
      "source",
      "extracted"
    ]
  },
  "result": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "model": {
        "type": "string"
      },
      "usage": {
        "type": "object",
        "properties": {
          "input_tokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "output_tokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "input_tokens",
          "output_tokens"
        ],
        "additionalProperties": false
      },
      "status": {
        "type": "string",
        "enum": [
          "ready",
          "review"
        ]
      },
      "score": {
        "type": "number",
        "minimum": 0
      },
      "level": {
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      },
      "confidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "probabilities": {
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      },
      "fidelity": {
        "type": "string",
        "enum": [
          "poor",
          "low",
          "fair",
          "high",
          "exact"
        ]
      }
    },
    "required": [
      "model",
      "usage",
      "status",
      "score",
      "level",
      "confidence",
      "probabilities",
      "fidelity"
    ],
    "additionalProperties": false
  }
}

What does a extraction-fidelity result look like?

This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo extraction-fidelity.

{
  "model": "demo-fixture",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0
  },
  "status": "ready",
  "score": 3.04,
  "level": 3,
  "confidence": 0.81,
  "probabilities": {
    "0": 0,
    "1": 0.01,
    "2": 0.06,
    "3": 0.81,
    "4": 0.12
  },
  "fidelity": "high"
}

Input

See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas. extracted is a string; pass the output of JSON.stringify for a structured record.

Result

fidelity is one of poor, low, fair, high, or exact, taken from the most likely rubric level. level is that level's index from 0 to 4. score is Jev's expected value across the rubric and can fall between levels; use it to rank extractions or set an acceptance threshold.

A result is ready when confidence meets minConfidence. Otherwise it is review and still carries the graded values for inspection. probabilities is keyed by level index.

Reuse and calls

Uses the shared score helper. This folder owns the fidelity question, the rubric wording, and the review policy. A live invocation makes one logical Jev request.

Limits

The rubric grades agreement between extracted and source. It does not check whether the source is accurate or current, and it does not know your schema, so a field the extractor was never asked for counts as an omission only when the source states it. The grade is a single number for the whole extraction; it does not say which value is wrong or missing. Add a per-field check when you need to correct specific values.

Example input

demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo extraction-fidelity shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe extraction-fidelity to inspect the input and result schemas.

How accurate is extraction-fidelity?

Current synthetic measurement

jev-1.13.0 / 2026-10-04 / 60 development cases

Scoring revision 2.

100%All-case accuracy
0Sent for review
0Failed calls / cases

60 ready decisions, with 100% accuracy among those decisions.

95% case-level interval: 94% to 100%. Related synthetic cases are correlated.

This measures the recorded dataset, not general readiness. Label sources: author-synthetic: AI-authored synthetic boundary cases for jev-recipes; labels have not had independent human review.

Use the evaluation guide to measure this decision on your own labeled cases.

What are the limits of extraction-fidelity?