Extract data from documents
- data extraction
- verification
Extraction is not summarizing. You do not want readable prose about the contract — you want one row per contract with the same four values in the same four columns, each traceable to the sentence it came from. Where a summary compresses language, extraction copies values and refuses to interpret them.
The extraction contract
- Name the columns before anything else:
Supplier | Term end | Notice period | Renewal type. - One row per item — one contract, one invoice, one form. Not “the agreements”.
- Copy, never compute. “Copy dates and periods verbatim; do not calculate or convert anything.” Model arithmetic is not a calculator; a normalized date is an invented date.
- A quote column. Require the exact sentence each row’s values come from. Now every value can be checked with a glance, and values that cannot be quoted come back
not stated. - Output only the rows. No commentary around the table — the structured-output rule — so it can be pasted straight into a sheet.
Why the quote column changes everything
An extraction without sources asks you to trust the machine on exactly the numbers that matter. With a source quote per row, verification shrinks from “re-read every contract” to “read six sentences”. It is the grounding pattern from the grounding lesson, applied to table building.
Then do the sampling pass
Extractions deserve a spot-check, not faith. Open the source for five rows — mix the first and last, not the cleanest ones — and compare against the quote. If one value drifted, stop and re-run with a stricter instruction; one wrong row means the batch is untrustworthy. And if you asked for totals: never accept a model-computed total. Extract the raw numbers and let the spreadsheet add them — it is a calculator.
Long documents
For a folder, work in chunks: one document per request (or a batch of similar ones), same columns every time, collecting rows you control. The workflow is the same one from working with long input, and your collected rows are the memory the chat does not have.
A sizing tip from practice: keep each extraction batch small enough to sample in five minutes — six contracts, a dozen invoices. Beyond that, the spot-check quietly turns into a second job, and unverified tables are exactly the ones that get trusted by accident. Small, verified batches beat one big unchecked pull.
Practice
Assemble a document-extraction prompt
Six supplier contracts sit in a folder as plain text. Finance needs renewal and termination details in a spreadsheet by Friday — and every value must be traceable to the sentence it came from.
Fill every field to assemble a prompt that extracts one row per contract — then compare with a strong example.
A strong example (self-assessment — not machine-graded)
Extract one row per supplier contract from the six texts below. Columns: Supplier | Term end | Notice period | Renewal type | Source quote. The Source quote column must contain the exact sentence each row's values come from. If a value cannot be quoted from the text, write 'not stated' in its cell instead. Copy dates and periods verbatim from the text. Do not calculate, convert or normalize any date or duration. Output only the table, with no commentary around it. Contracts: [paste the six contracts]
Hint
Which column proves a value instead of asking you to trust it?
What rule stops the model from computing a date you did not ask it to compute?
Why this is the answer
The assembled prompt names the columns, fixes one row per contract and adds the step that makes extraction verifiable: a Source quote column, so checking a value means reading one sentence. 'Copy, never compute' blocks the silent normalization that turns an extracted date into an invented one, and 'not stated' keeps gaps visible instead of filled.
Transfer
- Contracts: renewal dates, notice periods, obligations — with quotes.
- Invoices and receipts: amounts and dates into the expense tracker.
- Forms and applications: fields into a comparison sheet,
not statedwhere the form is silent.
Next
Next: Classify and triage text — when the pile of text needs sorting rather than fields.