AI Workflow Templates
ExtractionadvancedHITL requiredupdated 2026-08-11

Structured Data Extraction

Extract a validated JSON object from messy text (invoices, resumes, forms) with a schema and a bounded repair loop.

#extraction#json#schema#validation
View source →

Tools in the pipeline

  • llm
    extract-model
    Emit JSON matching the schema.
  • validator
    validator
    Parse against Zod / JSON Schema.
  • llm
    repair
    At most two retries with validator errors.
  • human
    reviewer
    Handle needs_review fields after retries fail.
Stack: LLM · Zod / JSON Schema

What it does

Pulls structured fields out of unstructured documents and guarantees the output matches a schema. The model emits JSON; a validator checks it; on failure the errors are fed back for a bounded repair attempt.

Pipeline

  1. Define — a strict schema (types, required fields, enums).
  2. Extract — prompt the model to emit JSON matching the schema.
  3. Validate — parse against the schema (e.g. Zod / JSON Schema).
  4. Repair — on validation error, return the errors to the model for up to 2 retries.
  5. Escalate — after retries fail, flag for human review with the raw output attached.

Guardrails

Never accept unvalidated output downstream. Cap repair retries to avoid loops and cost blowups. For low-confidence fields (e.g. a total that doesn't reconcile), mark them needs_review rather than passing a bad value through.

Structural dry-run

No model call. Validates required fields only.

Prefills the example payload for Invoice. Edit it, then run.

Related