# Information Extraction

Extract structured fields from files or parsed documents using a JSON Schema, retaining source-tracking information where available.

Use it for defined fields such as contract details, receipt values, or resume information. For free-form summaries, use [AI Inference](ai-inference.md).

## Define input and fields

Supply either upstream `documents` or `files` for this node to parse. Do not supply both.

| Setting | Description |
| --- | --- |
| Extraction schema | Required JSON Schema defining field names, types, and constraints |
| Extraction instructions | Optional explanation of field meanings and requirements |
| Layout-sensitive fields | Fields whose interpretation depends on page position, such as supplier and recipient |
| Page filter | Limits source pages; leave empty to process all pages |
| Debug records | Off by default; records some call details for troubleshooting |

File input must use valid, unique Catalog `file_id` values.

## Choose an extraction mode

| Mode | Results and failure behavior |
| --- | --- |
| One combined result, `n_to_1` | Default; all inputs contribute to one result |
| One result per source, `n_to_n` | Produces separate results by source file; supports a failure policy |

The default `n_to_n` policy is `per_item`: failed sources retain error objects while other sources continue. With `fail_fast`, a failure stops the batch. Before writing a batch to a table, separate successful results from errors and write only successful data.

## Use the output

`result` is a JSON string for a single result; `results` contains result strings returned by source. `mode` identifies the mode, and `sources_tracking` contains available field-source information.

Distinguish JSON strings from objects when binding to downstream inputs. A single result can feed the JSON input of [Save to MOI Table](../data-io/save-table.md). Process individual results and error states before using multiple results.

## Example: extract a contract number

Flow: General Document Parsing → Information Extraction → Save to MOI Table.

Example schema:

```json
{
  "type": "object",
  "properties": {
    "contract_number": {"type": "string", "description": "Contract number"}
  },
  "required": ["contract_number"]
}
```

Choose combined-result mode and explain what identifies the contract number. After running, verify the extracted number and its source.

## Related pages

- [Variables and data flow](../../variables-and-data.md)
- [Run and debug](../../run-debug.md)
