IDP — Build Classifier
IDP — Build Classifier
Section titled “IDP — Build Classifier”Type: idp-build-classifier · Package: IDP Activities v1.20.4 · Output: object
Since: v1.2.0
Builds the schema that identifies which kind of document you are looking at, from the list of taxonomies you know. You run it through AI — Extract before extracting, and the playbook decides whether to carry on.
Why this is needed
Section titled “Why this is needed”Because IDP — Ground does not cover this case, and it is worth understanding why.
Grounding verifies “this text is written in the document”. It does not verify “this document is the type I think it is”. If you give a purchase order to an invoice taxonomy:
- If you are lucky, the model returns
nullfor everything and the whole document goes to review. Costly (a person looks at it) but nothing bad is stored. - If you are not, the purchase order carries a number that looks like an invoice number. The model fills it in. And grounding confirms it, because that text really is in the document. High confidence, accepted automatically, wrong data stored without anyone seeing it.
That second case is what justifies classifying first.
How it works
Section titled “How it works”It validates each taxonomy (the same rules as IDP — Build Schema), checks that no two share the same documentType and builds a JSON Schema with an enum of types that always includes unknown. It does not call the model: the log only says how many types it was built for.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
taxonomies | string | List | — | The taxonomies to choose between: paths to .json files, the JSON as text or the objects. A single one is fine too. Their documentType and description are what the model reads to tell them apart. |
Optional parameters
Section titled “Optional parameters”None.
Output
Section titled “Output”Returns an object with the JSON Schema, ready to pass as schema to AI — Extract. The model’s answer with that schema carries two fields:
| Field | What it is |
|---|---|
documentType | One of your taxonomies’ documentType values, or "unknown". |
reason | What in the document made it decide that. |
The enum builds itself
Section titled “The enum builds itself”The list of types comes from the taxonomies themselves, so it cannot drift out of sync: you add a new type and the classifier knows it without you touching anything. Each taxonomy’s description is passed to the model as context to tell them apart, which is another reason to write it well.
Example
Section titled “Example”IDP — Build Classifier taxonomies = [asset("taxonomies/invoice.json"), asset("taxonomies/purchase-order.json")] → output: classifier
IDP — Load Document path = docPath → output: docAI — Extract prompt = doc["text"] schema = classifier model = "claude-haiku-4-5" → output: kindIf condition = kind["documentType"] == "supplier-invoice" ...extract with the invoice taxonomyElse Log message = "Discarded: " + kind["documentType"] + " — " + kind["reason"]Classifying is cheap: the document goes in once and the answer is two fields, so a small model is enough. What it really saves is what it prevents — not paying for the full extraction of a document that did not belong.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'taxonomies' is required. / 'taxonomies' is empty; there is nothing to tell apart. | No taxonomy was passed. |
Two taxonomies declare the same documentType '…'. The model cannot tell apart two kinds with the same name. | Two taxonomies with the same documentType (case-insensitive). Rename one. |
'taxonomy' is not valid JSON: … / The taxonomy must declare a 'documentType'. / Field '…' has no 'description'. … | A taxonomy is invalid. See the errors in IDP — Build Schema. |
Related activities
Section titled “Related activities”- IDP — Build Schema — the next step, once you know what it is.
- IDP — Classify — ready-to-use per-page classification.
- IDP — Ground — verifies the values, not the document type.