Raw view: Extract Structured Data From a Document
No invisible, zero-width, or bidi-control characters detected.
<document>
{{DOCUMENT}}
</document>
Extract data from the document above into JSON that validates against the schema below. The output will be parsed by a program, so the JSON must be exact: valid syntax, the schema's types, nothing extra.
<json_schema>
{{JSON_SCHEMA}}
</json_schema>
<extraction_rules>
{{EXTRACTION_RULES}}
</extraction_rules>
<extraction_rules> may define field-specific guidance: date formats, unit normalization, how to handle multiple candidates, which section a field usually lives in. Follow them over your defaults. If empty, use the defaults below.
Default rules:
1. Fill a field only with information present in <document>. If the document does not contain a value, use `null` (or an empty array for array fields). Never fabricate, never fill from general knowledge, never carry a value from one record to another because it "probably applies".
2. Normalize formats to what the schema's types and `format` hints demand: dates to ISO 8601 (`YYYY-MM-DD`), numbers as numbers not strings (strip currency symbols and thousands separators; put currency in its own field only if the schema has one), booleans as `true`/`false`.
3. When several candidate values exist for a single-valued field, choose the one the document presents as authoritative (a signature block over a header, a "Total" over a subtotal, the latest date over earlier ones) and record the choice in `_notes`.
4. When a value must be inferred rather than read (a year from context, a total computed from line items), include it only if the schema allows and record it in `_notes` with the inference. Prefer `null` over a weak inference.
5. Quote the source span for each extracted field in `_evidence` as a short verbatim excerpt, enough to locate it in the document. This lets a reviewer verify without re-reading.
6. Before emitting, walk the schema's `required` list and confirm every required field is present, then check each type. If a required field is genuinely absent from the document, set it to `null` and explain in `_notes`; do not invent a value to satisfy the validator.
## Output format
Return exactly one JSON object and nothing else: no prose before or after, no Markdown code fence, no comments inside the JSON.
The object has three top-level keys:
- `"data"`: the extracted object, conforming to <json_schema>.
- `"_evidence"`: an object mapping each populated field path (dot notation, e.g. `"invoice.total"`) to the verbatim excerpt it came from.
- `"_notes"`: an array of strings, one per judgment call: inferences, disambiguations, required fields left null and why. Empty array if none.
If <document> is not the kind of document the schema describes (for example, the schema is for invoices and the document is a cover letter), return `{"data": null, "_evidence": {}, "_notes": ["Document does not match schema: <one-sentence reason>"]}`.