Extract data from documents

Intermediate · 7 min · Pull structured fields from documents with traceable, spot-checked values.

  • 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

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.

Your prompt, assembled

 
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?

Transfer

Next

Next: Classify and triage text — when the pile of text needs sorting rather than fields.