> ## Documentation Index
> Fetch the complete documentation index at: https://docs.insight.nobly.dk/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring the classification tree

> Author the classification tree that drives AI document classification: branches, descriptions, extraction prompts, allowed keywords, page cap, and dataset-matching guidance.

## Where it lives

The tree is edited under **Admin settings → AI → Document classification**. Viewing requires the
*AI configuration view* permission; saving requires *AI configuration manage*.

Everything document classification needs is configured on this one page: the tree itself, the main
extraction prompt, the OCR page cap, and the dataset-matching guidance.

## Anatomy of the tree

The tree's **root branches are everything the AI may classify an upload as** — a document
matching none of them gets no suggestion. Each branch can hold sub-branches, splitting a broad
category into progressively more specific ones. A branch with no children is a **leaf**, where
keyword extraction runs.

Each branch has:

| Field                                                 | What it does                                                                                                                                                                                                                    |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Branch name**                                       | The label shown at that classification step and in the walk shown to users. Must be unique among its siblings.                                                                                                                  |
| **When to choose this branch**                        | Plain language describing what a document in this branch looks like. This is what the AI reads when deciding — quote exact phrases when near-identical branches must be told apart.                                             |
| **Document type**                                     | Stamped on the path when the walk passes through this branch: it becomes the type suggestion. Exactly one branch on every root-to-leaf path must set it.                                                                        |
| **Shared extraction prompt** / **Keyword extraction** | Extraction instructions. On a branch with children they are *shared context*, passed down to every leaf below; on a leaf they guide the final extraction call itself.                                                           |
| **Allowed keywords**                                  | The keywords extraction may fill for documents passing through here. Empty inherits the level above — or all of the stamped type's keywords if no level restricts. Branches underneath can only narrow the set, never widen it. |

**Split into sub-branches** turns a leaf into a decision step: extraction moves to the new
leaves, which receive the branch's prompt on top of their own. Use it when one description can no
longer handle a branch's variety.

## Writing good branch descriptions

The *when to choose* text is the single biggest lever for classification quality:

* **Use the document's own words.** The AI must quote evidence for every choice, so descriptions
  containing phrases that literally appear in those documents ("dividend statement",
  "lease agreement") give it something to anchor on.
* **Say what a branch is *not* for.** When two branches attract the same documents, give the
  losing branch an explicit exclusion ("not for shareholder or dividend paperwork").
* **Keep siblings contrastive.** The AI only ever compares siblings at one level — write each
  description so it separates that branch from the others *at the same level*, not from the whole
  tree.

<Tip>
  If users report a document type landing in the wrong branch, check the walk in the confidence
  tooltip: it shows which step went wrong and what evidence was quoted. Sharpen the two competing
  descriptions rather than adding more branches.
</Tip>

## Prompts

* **Main extraction prompt** — part of every extraction call, whichever branch a document takes.
  The classification steps never see it. Put universal rules here (formatting, "leave a keyword
  out when its value cannot be read", language conventions).
* **Branch prompts** accumulate down the path: a leaf's extraction call receives the main prompt,
  every parent's shared prompt, then its own — in that order, in a single call with the document
  text. Write instructions once at the highest level they apply to instead of copying them into
  every leaf.

## Max pages

**Max pages** caps how many pages are OCR'd per document; empty uses the default of 20. It is the one
page cap for the whole analysis — classification and keyword extraction read the same text. Set
it when your documents front-load their identity (letterhead, first-page summaries) and tail
pages only add cost.

## Dataset-matching guidance

When an extracted keyword value must map to an entry from a keyword dataset, the AI receives a
shortlist of candidates together with the **matching guidance** configured on this page. Only the
guidance section of that prompt is editable — the fixed part that makes the AI return a specific
candidate cannot be changed. Leave it empty to use the built-in default.

## Validation

Saving validates the tree and rejects, with a message naming the offending branch:

* A blank branch name, or the reserved name "None of the above".
* Duplicate names among root branches or among siblings.
* A path stamping two document types, or a leaf whose path stamps none.
* The same document type stamped on two different branches.
* An allowed-keywords set that widens what a level above restricted.

The same rules run in the editor before the request is sent, so most mistakes are caught as you
type.

## Import and export

**Export** downloads the tree as a JSON file; **Import** loads one into the editor for review —
nothing is applied until you press **Save**. Use export/import to move a tree between
environments or to keep versioned backups before larger restructurings.
