Classify
Category: Processing
The Classify activity assigns a document class (type) to each document, so the right extraction schema and business rules apply. Classification uses the document's OCR text, its page images, or both.
Settings
The Classify step's panel has six blocks, all folded when it opens. Folded, each block says what it holds, in grey where a value is what a new step starts with and in black where someone changed it. A step saved before a setting existed shows what that setting does without it, or Not set where that depends on whether the step runs on its own or in one call with Extract.
The classes, their descriptions, the classification guidelines and the name of unrecognized documents belong to the project: every Classify step uses them, and where the panel edits them it says Project. Which classes the step offers, its own words for a class or for the guidelines, and everything else belong to this step alone, so two Classify steps can offer different classes, use different models or read different pages.
Classes. Folded, it shows how many classes the step offers ("All 6 classes", or "4 of 6 classes") and whether new classes are discovered.
| Setting | What it does | A new step starts with |
|---|---|---|
| Edit classification settings | Opens Classification Settings: the project's classes with their descriptions, the classification guidelines, which classes this step offers, and the step's own description of a class. | All classes |
| Name for unrecognized documents (Project) | The class a document gets when it matches none of the others; see Unknown. Rename it to suit your reviewers, for example into their language. It is renamed as any class is: it keeps its identity, and rules that name it follow. No other class can take this name, nor Unknown. | Unknown |
| Discover additional classes | Lets the model propose a new class when a document matches none; see Discovering classes. Not available on a step that offers only some classes: clearing a class's box switches it off. | Off. A new project's step starts with it on. |
Instructions (Project). The classification guidelines, edited in place and saved as you type, and the class descriptions, edited in Classification Settings (Edit class descriptions). Every Classify step sends them, unless it has its own. When the workflow has more than one Classify step, Use different guidelines in this step gives this step guidelines of its own, under the shared ones: the box opens empty, with the shared text in grey, and nothing is saved until you type. Clearing it, or Use the shared guidelines, goes back to the shared ones; Send no guidelines sends none. With one Classify step there is nothing for the step's own to differ from, so the box is not offered; a step that already has guidelines of its own still shows them. The block also names the classes this step describes in its own words. The step's JSON view, in the panel's footer, writes the same keys. A guideline or a description can also refer to a value the transaction brings, such as {{ meta:po_number }}: see Metadata in Guidelines and Descriptions.
Model.
| Setting | What it does | A new step starts with |
|---|---|---|
| Model | The model this step uses. Tenant default follows the model your organization set for classification. | Tenant default |
| Decision model | Where the feature is on: the model asked before the one above, which reads the page images as well as the text whatever What the model reads says (A decision model first). Default follows the deployment's; None asks none. | Default |
| What the model reads | Image and Text, Image Only or Text Only, for the model above. Text Only is the cheapest, and usually enough: a document's opening words say what it is. A text-only model reads Text Only. | Text Only |
| Send images of pages without text | With Text Only, still send the image of a page that has no text (a blank page, a photo), so a scan is classified instead of left Unknown. Not available for text-only models. | On |
| Include reasoning | Asks the model to explain each classification; reviewers see the reason. | On |
Rules. The step's classification rules, one before the model and one after it: folded, what each does ("1 condition", "Script", "Off" or "None"), and Edit rules to open them. In the dialog, Save writes your changes to the step and Cancel drops them. A condition with no class, or with nothing to compare, cannot be saved: the dialog says which condition to finish. See Classification rules.
Advanced.
| Setting | What it does | A new step starts with |
|---|---|---|
| Max image pages, Max text pages | How many pages are sent as images, and how many as text. A document's type is almost always decided by its opening pages, and fewer pages keep the call cheap. Empty: every page. | 3 and 3 |
| Answer length | The longest answer the model may give. | Your organization's length for classification |
Exits. Where the transaction goes after the step, and the failure exit.
The step's switch in the panel's header turns it off: an off step leaves documents unclassified.
Classification Settings
Opened from the Classes block, and from the Transaction Viewer. It opens with what classification does: it decides what type each document is, and picks one of the classes listed, by their descriptions. When the workflow has more than one Classify step, the dialog names the step it shows; from the Transaction Viewer, Settings of chooses whose settings to change. With one Classify step it says nothing of steps.
- The tick boxes. Every class has one, and every class starts ticked: a step with every box ticked offers every class, and any class added later. Clear a box and the step offers only the ticked ones; the cleared classes fold into Not used at the bottom of the list. Tick the last one again, or choose Use all classes, and the step offers every class again. A line above the list says which ("All 8 classes are used, and any class added later", "6 of 8 classes are used"). The step offers at least one class, so the last tick stays. Documents that match none of them go to the class for unrecognized documents, which closes the list, marked Always used. A class you add here is ticked too, and is used by every step that offers all classes.
- The classes are the project's. Add class adds one; the icons on a class rename, duplicate or delete it, for every step. Select a class to change its name, description or hotkey.
- A description for classification. A class's description is shared: every step that uses the class sends it. When another step reads it too (a Split step, or another Classify step), the opened class says so ("Shared: splitting uses it too") and offers Use a different description for classification (in the step's name when there are several Classify steps): a box of its own, under the shared one, that starts empty, with the shared text in grey, and saves nothing until you type. Clearing it, or Use the shared description, goes back to the shared one. Send no description sends the class name alone. The class is marked Own description for classification while it has one, folded or not.
- Classification Guidelines, folded at the top, are shared. With more than one Classify step, the step's own guidelines have their box there too; the folded header is marked when the step has them.
- Discover additional classes, at the bottom of the dialog, works only in Playground runs; Memory, Evaluation and a published version never discover. While it is on, the project's Playground transactions go through classification one at a time, so processing is slower. It is off and greyed while the step offers only some classes, and clearing a box while it is on switches it off.
The step also has a confidence threshold (0.7), with no control in the panel: a classification below it is marked for review. A Review or Agent Review step marks documents by its own thresholds instead, which are the ones to change.
A new project starts in discovery mode: it has no classes yet, and the model is asked to propose a document type for whatever arrives in the Playground. Once you have settled on a class list, turn Discover additional classes off so the model chooses from your classes instead of inventing new ones.
Discovering classes
While Discover additional classes is on, the step classifies a transaction's documents one at a time, so each one sees the classes the documents before it proposed. Two documents of a new type then share one class instead of each inventing a name for it. Turning the setting off brings back parallel classification.
How the model decides
The classification call gives the model three things, and nothing else:
- What it can look at - the document's page images, its OCR text, or both, depending on What the model reads. A decision model asked first reads up to eight page images and the text, whatever that setting says.
- The list of document classes, each as its name plus its description. The description is the model's only instruction about what belongs in that class, so it does the heavy lifting. Write it the way you would explain the class to a new colleague, and say what distinguishes it from the neighbouring class rather than just restating the name.
- The classification guidelines, passed through verbatim. Use them for rules that span classes and so belong to no single description: "if it shows both an invoice number and a payment reference, it is a remittance advice, not an invoice".
The model returns the class it picked, a confidence score from 0 to 1, alternative classes it also considered, and, when Include Reasoning is on, an explanation of why it chose that class. A classification whose confidence falls below the step's confidence threshold is flagged for review instead of being accepted silently.
So when classification is wrong, sharpening the class descriptions is the first thing to try, and the guidelines are the second. Both are cheaper and more robust than a classification rule, which encodes a fixed promise about the data.
A decision model first
Asking a decision model first is in Preview: your system administrator turns it on for the deployment, your organization or a project, and it may already be on for the whole deployment. Where it is on, a step follows the deployment's default decision model unless it is set to None.
A Classify step can ask a decision model before its language model. A decision model does not write text: given the classes as options and the document's text and page images, it answers which class fits and how probable each class is, in a fraction of a second and at a fraction of the cost.
By default a step asks the deployment's default decision model, where the deployment has one and it applies to the step: the feature is on for the project, your organization may use that model, and the step's language model is one of the deployment's (its own, your organization's default for Classify, or the deployment's). A step on one of your own language models asks a decision model only when it names one. Where none applies, the step classifies with its language model alone, as before. A step can also name another decision model, or None.
With one asked, the decision model answers every document first, from its text and up to eight of its page images (always, whatever What the model reads says, since the images decide documents the text alone does not), and its answer is the document's unless:
- its probability for the class it chose is below the model's acceptance threshold;
- another class comes close to it;
- the step discovers classes and the decision model found none that fits;
- the call failed.
Then the language model classifies the document exactly as it would without a decision model. The thresholds are set by DocAI Fabric for each decision model from measurements, not by a setting: on the accounts payable documents DocAI Fabric measured, with gpt-6-luna as the language model, asking the decision model first made no document worse than the language model alone. A step on another language model uses the same thresholds. A step that classifies and extracts in one call holds the decision model to a stricter threshold, since that call reads every page while the decision model reads the step's own pages. A decision model not yet measured accepts no answer, so every document goes on to the language model, and its answers are only recorded.
A class the decision model gave has no explanation, whatever Include Reasoning says, and is reviewed by the step's confidence threshold as any other. Where Classify and Extract share one call, a document the decision model decided makes no shared call: Extract extracts its class's fields itself.
Choosing one. Where the feature is on for the project, the step's Model block has a Decision model picker beside the model:
- Default (Decision-1.1), the deployment's default decision model, which a new step and every step that never chose one follow. It reads Default (none for this project) where the deployment has none your organization may use, and Default (none for this step's model) where the step names one of your own language models.
- None: the language model alone.
- A decision model your organization may use, the deployment's or one of your own. One marked records only is not measured yet, so it accepts no answer.
If the deployment's default decision model cannot be reached because of its configuration (a key refused, a deployment removed), each document goes on to the language model and the step does not fail; a decision model the step names itself fails the step in that case, as a language model does.
What it records. Every document of such a step keeps the decision model's answer:
- In the viewer, the classification details say who decided: "Decided by decision-1.1, 0.97", or what the decision model chose and why the language model was asked ("decision-1.1: Invoice 0.62, below its threshold; classified by the generative model").
- In the Activity Log, each document's line starts with the decision model's answer, and a closing line counts the run: how many documents it decided, why the rest went on, how often the language model was called and how often it changed the class.
- In the API,
GET /transactions/{transaction_id}gives each document'sclassification_decision: the model, the class it chose and its probability, its two alternatives, whether its answer was accepted (accepted) and, when not, why (routed:below_threshold,close_alternative,catch_all_discoveryorerror), andfrom_default, true when the model was the deployment's default. - In the workflow API and the Assistant, a step's
decision_model_idis absent ornullto follow the default,""for none, or a decision model's id. - A post-classification rule reads it as
classification.decision.
Pages and documents without text
A page with no text is a normal page: a blank page, a photo of a person, a signature sheet. OCR reads it and finds nothing, and that is not an error.
- Some pages of a document have text: classification works as usual. Each page without text is marked to the model as "(no text on this page)".
- No page has text, and page images are sent (the model reads images, or Send images of pages without text is on): the model classifies from the images.
- No page has text, and no image is sent: there is nothing for the model to read, so it is not called. The pre-classification rule still runs first and can assign a class (from the file name, for example). Otherwise the document is classified as Unknown with confidence 0, which flags it for review, and then the post-classification rule runs and can still assign a class. The Activity Log says "LLM not called: no text on any page, and page images are not sent". This happens even with Discover additional classes on: with nothing to read, there is nothing to name.
Max text pages limits which pages are read. If the first pages are all blank and the text starts later, raise the limit, or turn on Send images of pages without text.
A page that never went through OCR is different. If the step sends text and a page has no OCR result at all (there is no OCR step before Classify, or OCR is off in it), the step fails at once and says which pages, instead of classifying from the rest. Add an OCR step, or send page images.
Re-running a single document from the transaction viewer follows the same rules.
Unknown: the built-in fallback class
When the model classifies against a fixed class list, Unknown is always one of its options. You do not need to create it, and no class of yours can take its name: creating, renaming or copying a class to Unknown is refused, and so is the name you gave unrecognized documents, if you renamed them.
Whenever your project has document classes and Discover additional classes is off, an Unknown class is added to the list the model sees, described as "use when the document does not clearly match any of the other predefined types". It gives the model a way to say "none of these" instead of forcing a wrong answer out of a document that genuinely does not belong to any of your classes.
The model's answer is always one of the classes the step offers. An answer that repeats a class's line from the list, its name and then its description, is that class. Any other answer that is not one of the classes, a class's name followed by other words included, is classified as Unknown with confidence 0, so it is flagged for review, and the classification reasoning quotes what the model answered.
What follows from a document being classified as Unknown:
- Extraction is skipped entirely for it. Unknown has no class-specific fields, so there is nothing to extract, and the document is marked with a note saying so.
- Class-specific fields cannot be added to it in the Transaction Viewer. Assign it a real class first, or add the field as a general field.
- A reviewer can change the document's type by hand, which brings that class's fields with it. On a production transaction the choice is among the classes of the published version it ran under, as in the rest of the Transaction Viewer.
- A document set to Unknown by hand, in the Transaction Viewer or by the assistant, takes the name your project gives unrecognized documents, as a classified one does.
Treat a run with many Unknown documents as a signal: either a class is missing from your list, or the descriptions do not cover the variants that arrive in practice.
One exception is worth knowing: with Discover additional classes on, which is how a new project starts, Unknown is not offered at all. The model is asked to propose a specific new document type instead, because "invent a name for it" and "give up" are contradictory instructions. Unknown becomes available once you turn discovery off and classify against a fixed class list.
Giving every document the same class
Turning the step off leaves documents unclassified, which also means no class-specific extraction fields and no class-scoped business rules apply to them.
When the answer is known in advance rather than decided per document (the project handles a single document type, or a feed only ever delivers one type) keep classification on and add a pre-classification rule with a single condition using the Always (any document) target and that one class. Every document is then classified as that class, and the model is never called, so there is no AI cost. See Always below.
Classification rules
Two optional rules run around the model call, configured in the Classify step's Rules block (Edit rules).
Pre-classification rule runs first, before the model is called. Each condition tests the source file name, the document text, a transaction metadata value, or an extracted field, or uses the Always (any document) target, which matches everything. It then resolves to one or more classes:
- One class: the document is classified straight away and the model is never called. Useful when the file name alone settles the question.
- Several classes: the document still goes to the model, but the model may only choose among those classes, plus Unknown, which a narrowed list always offers: narrowing turns off class discovery for that document. Use this when a signal narrows the answer without settling it, for example a file name prefix that proves the document belongs to the invoice family but not which member of it.
When a condition names several classes, the builder shows an LLM decides badge on that condition, and the confidence input disappears because the model supplies its own confidence.
Post-classification rule runs after the model and can override the result. It can read the class the model picked, its confidence, and the candidate classes the pre-rule narrowed it to, so it can apply a fallback when the model was not confident within the range.
Conditions are evaluated top to bottom and the first match wins. If nothing matches, the model classifies against the full class list.
Either rule assigns only a class the step offers: one of the classes the step selects (every class when it selects none), or Unknown. The rule builder lists only those classes, and the assistant refuses a rule that names another. A class outside them, in a rule written by hand or one from before the step chose its classes, is ignored, and the document is classified as though the rule had not matched: the model chooses after a pre-rule, and the model's answer stands after a post-rule. The Activity Log names the class that was ignored. Where the step discovers classes (automatic discovery, in a Playground run), a rule may also name a class the project does not have yet, which is then added.
The Regex match type takes a JavaScript regular expression. Matching is case-insensitive and the pattern may match anywhere in the text, so leave out ^, $ and the inline flag (?i), which JavaScript rejects. The builder checks the pattern as you type and shows the compile error under it; Regex help opens a short reference and Build with AI writes the pattern from a description. See Regular Expressions for the full introduction.
When a rule fails
A rule is one function: a pattern that does not compile or a line that throws stops every condition in it, including the ones above the error that would have matched. That is a failed step, not a silent fall-through to the model. The transaction takes the activity's Failed exit if one is wired (Handling failures), and otherwise fails, and the Activity Log records the rule (pre or post), the document, and the error text. A rule that cannot run never hands its documents to the model, because a document the rule should have classified without an AI call would otherwise get an AI answer that nothing in the transaction explains.
Three things prevent this at authoring time: the builder withholds a rule with an invalid regex until it is fixed, the assistant refuses to save one, and saving the workflow refuses a custom rule the rule engine would never run, naming the step. That is code that reaches a prototype or a constructor (.prototype, .constructor, __proto__) or loads a module (require): write Object.hasOwn(obj, key) instead of Object.prototype.hasOwnProperty.call(obj, key), and Array.from(x) instead of Array.prototype methods called on x.
Reading the Activity Log
Each document the step processes leaves a classified as row in the transaction's Activity Log, so you can see how the class was decided rather than only that the step ran:
- whether the pre-classification rule was configured, matched nothing, assigned the class, narrowed the model to a candidate set, or named a class the step does not offer
- whether the model was called, and with what answer and confidence
- whether the post-classification rule matched nothing, overrode the answer, or named a class the step does not offer
Use it to confirm that a file-name rule really skipped the model, or to see which stage produced a class you did not expect. Very large transactions record the first 100 documents and count the rest in one line.
Always
The Always (any document) target has no comparison to fill in: the condition fires for every document. Two ways to use it:
- As the only condition, to assign one class (or narrow to one candidate set) for everything the step sees, while keeping classification on for the rules and the review threshold.
- As the last condition, as a catch-all: the specific conditions above it handle what they recognise, and everything else falls into a default class instead of going to the model.
Because the first match wins, any condition placed below an Always condition never runs. The builder marks those conditions so they are easy to spot.
Notes
- The text of the pages Classify reads, and their words when it also extracts, is held under the same text limit as Extract's: a document over it fails with the cause Too much text to read.
- A document already classified upstream (for example by a Transform
set_document_classcall) keeps its class; Classify skips it.