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

# Cascade classifier

> Five layers, dispatched per tier, turning a raw prompt into a structured intent with reasoning.

Five layers, dispatched per tier. The cascade is what turns a raw prompt into a
structured intent + reasoning evidence.

## The layers

1. **L1 — Lexical + adversarial.** Always runs. Keyword + regex scoring +
   injection detection. Cheap; can short-circuit when one intent dominates.
2. **L2 — Embedding similarity.** Cosine similarity against per-intent centroids
   built from the card's reference prompts.
3. **L3 — Contrastive scoring.** Ranks survivors by discriminative margin
   against the negative set.
4. **L4 — LLM judgment with reasoning.** Adjudicates ambiguous cases; produces
   structured supporting / disqualifying evidence + alternatives\_considered.
5. **L5 — Per-org fine-tuned classifier.** Ultraviolet only. Trained on your
   org's classifier\_corrections.

## Per-tier dispatch

* **Violet** — L1 only.
* **Deep Violet** — L1 → L2 → L3 → L4.
* **Ultraviolet** — L1 → L2 → L3 → L4 → L5.

## The evidence document

Every dispense + every intent\_event row carries a `classification_evidence`
JSONB blob. It captures:

* The final `intent_id` + confidence
* Which layers were consulted
* Supporting / disqualifying evidence (human-readable strings)
* Alternatives considered
* Cost + latency rolled across all layers
* Adversarial verdict from L1

The Decision Feed on your dashboard renders this as a "Why was this picked?"
panel under each row.

## Confidence thresholds

Each intent card carries a `classification` block with `match_threshold` +
`ambiguous_floor`. Confidence above `match_threshold` accepts directly; between
the two it routes through approval (when `route_ambiguous_to_approval` is true);
below the floor it denies.

## Corrections feed

Reviewers can correct any classification straight from the Decision Feed.
Corrections stream into `classifier_corrections`. Once an Ultraviolet org
crosses 250 unique-prompt corrections (or 100 + 30 days since the last
fine-tune), the nightly fine-tune driver triggers a new L5 model.
