# LLM Classification: Fix the Taxonomy Before the Model

> Most classification failures are label definition failures. Learn how to design a taxonomy, handle abstention and class imbalance, and check whether a model beats a cheap baseline.

Source: https://ailoot.ai/blog/en/llm-classification-taxonomy-before-model/
Canonical: https://ailoot.ai/blog/en/llm-classification-taxonomy-before-model/
Language: en
Publisher: Ailoot (https://ailoot.ai/)
Translation: guide-100350
Revision: sha256-8037b320b0c1f4017dfe6cc2443b36b30560275fe6ad9336c88d06a05ca7a854


Classification is the task where a model looks most obviously superior to the alternative, and where it most often loses to a logistic regression that took an afternoon. It is also the task where the accuracy number you report is most likely to be meaningless.

Both problems have the same root. Classification quality depends on how well labels are defined. Disagreement between people is a signal to examine the definitions and labels; it does not establish a hard limit on model performance.

## Measure human agreement before you measure the model

Take a hundred items and have two people label them independently. If they agree 75 percent of the time, treat that as a useful indicator, not a hard model ceiling. A score of 80 percent does not by itself prove that the evaluation labels are noisy. Examine the disagreements and validate the model against carefully reviewed labels.

Low agreement can indicate overlapping or missing categories, unclear instructions, difficult examples or labelling errors. Examine disagreements before deciding what to change.

Fixing the taxonomy is unglamorous work that pays better than anything you can do to the prompt. Merge categories that annotators confuse. Split categories where the disagreement is about two genuinely different things sharing a name. Add the category that people keep forcing into "other". Then re-measure agreement.

## Definitions with boundaries, not synonyms

A label description that reads "Billing: issues related to billing" is a synonym, not a definition. It tells the model nothing it did not already infer from the label name.

Useful definitions state the boundary. What is included, what is specifically excluded and where it goes instead, and one concrete example of the near-miss case. "Billing: charges, invoices, refunds and payment failures. Does not include subscription plan changes, which are Account. A failed card on an upgrade attempt is Billing."

The exclusions do most of the work, because misclassification happens at boundaries rather than in the middle of a category. Write the definition by looking at the pairs that annotators confused, and put the disambiguation directly in the definition rather than in a general instruction that applies to everything.

## Abstention is a first-class outcome

Force a model to choose from a fixed list and it will always choose, including for items that belong to none of them and items that are genuinely ambiguous. Those forced choices are indistinguishable from confident correct ones in your output.

Give it an explicit way out and say when to use it. Not a vague "other" bucket, which becomes a dumping ground, but a specific abstention with a reason: outside taxonomy, insufficient information, or multiple categories apply equally.

```
{"label": "abstain", "reason": "insufficient_information",
 "candidates": ["billing", "account"]}
```

The abstention rate is then a live quality metric. A sudden rise means your input distribution shifted, which is exactly the signal you want and which a forced-choice classifier hides entirely by continuing to emit confident labels. Route abstentions to a review queue, and use what comes back to extend the taxonomy, following the pattern in deciding where a human review step belongs.

## Class imbalance breaks your metric and your prompt

If 90 percent of items are one class, a classifier that always predicts that class scores 90 percent. Accuracy is worthless here and yet it is what gets reported.

Use per-class precision and recall and a confusion matrix. The matrix tells you the specific thing you need: which pairs get confused, in which direction. A model that misses 40 percent of the rare urgent class while scoring 92 percent overall is a failure, and only the per-class numbers show it.

Imbalance also affects the prompt. If your few-shot examples mirror the real distribution, nine of ten demonstrate the majority class and the model learns that the majority class is usually right. Balance the examples across classes rather than sampling them naturally, and be aware that the last examples in the prompt carry extra weight, for the reasons in managing few-shot example sets.

## Beat a cheap baseline or do not ship

Before deploying a model classifier, build a baseline: TF-IDF features with logistic regression, or a small fine-tuned encoder. Measure its quality and total costs for your model and workflow, including development, hosting and inference, before comparing it with alternatives.

On tasks with a few thousand labelled examples and a stable taxonomy, the baseline is frequently competitive and sometimes better. Cost per item matters enormously at classification volumes, so measure and compare the total costs of each approach in your own workflow.

Where the model genuinely wins is the cold start, when you have a taxonomy and no labelled data at all, and on tasks requiring real world knowledge or nuance that surface features cannot capture. A good pattern is to use the model to label a training set, verify a sample by hand, then train the cheap classifier on it and keep the model for the low-confidence tail. The economics of that split are the subject of working out when a cheap model is enough.

## Confidence, and why the model's own number is not it

Ask a model how confident it is and it will produce a number that looks like a probability and behaves like a style choice. Self-reported confidence clusters at round values, shifts with phrasing, and correlates weakly with correctness.

Token logprobs on the label token are a better signal where your provider exposes them, because they reflect the actual distribution over choices rather than a verbalised guess. They are still uncalibrated, so map them to real probabilities using a held-out set before you threshold on them.

Agreement across samples can provide a useful signal. Run the classification three times at nonzero temperature and inspect disagreements. Three identical answers do not guarantee correctness: correlated systematic errors can produce the same wrong answer. Validate the signal on labelled data and compare its costs with alternatives; repeated calls add expense, so consider gating them on a first-pass signal.

## Multi-label and hierarchy need different handling

If an item can carry several labels, do not ask for a list from a flat taxonomy and hope. Ask a yes-or-no question per label, or per group of related labels, which gives you an independent decision for each and avoids the model settling on a plausible-looking set of two.

For hierarchical taxonomies, classify top-down. Choose the top-level category, then choose within it using only that branch's definitions. This keeps the number of options in each decision small, keeps the definitions in context focused, and lets you report accuracy at each level, which tells you whether errors are coarse or fine.

The cost is more calls per item, so batch where you can and cache the shared taxonomy prefix, since the definitions dominate the input tokens and are identical across every item.

## A shipping checklist

Measure inter-annotator agreement and fix the taxonomy until it is acceptable. Write definitions with explicit exclusions drawn from real confusions. Add an abstention path with reasons and monitor its rate. Report per-class precision and recall with a confusion matrix, never aggregate accuracy. Benchmark against a cheap classifier and justify the difference in cost.

Then pin the model and the prompt version together, and re-run the evaluation set whenever either changes, because a taxonomy that was correctly applied by one checkpoint is not automatically applied the same way by the next. The mechanics of that are covered in pinning model versions rather than tracking a floating alias.



<!-- ailoot-promo:20a54c7d57681d5af8ffd43be4cab43aed359c1759aab5b0d6c46330569115e2 -->
<p>Explore <a href="https://ailoot.ai/">OpenAI API access through Ailoot</a> for your next project. Developers can use one Ailoot-issued key for 1,284 models and variants across 15 categories, putting Ailoot among the world’s largest AI routers by model count. The catalogue covers text with GPT or Claude, images with FLUX, video with Kling, voice with Eleven v4, music with Suno, 3D assets with Tripo3D and ranking with Cohere Rerank.</p>
<p>Use Mercury Decide, Jev or Clef through Ailoot to add structured decisions to your workflow. Pair them with models that analyze documents and generate text.</p>
<p>Build your classification and routing features into an app with the <a href="https://ailoot.ai/">Ailoot API</a>. Monitor model usage across projects and manage company spend through one workspace.</p>
<p>Ailoot adds new flagship models at launch, and one subscription covers the full catalogue. Find a promo code in your account at <a href="https://ailoot.ai/">https://ailoot.ai/</a>. Ailoot subscriptions and promo codes offer up to 50% off official provider API prices.</p>
<!-- /ailoot-promo -->


## Ailoot · The company and its project portfolio

Ailoot combines established operating experience, a large client base, stable service and ongoing KPI control.

The company and its project portfolio: millions of customers; monthly sales in the billions.

Ailoot brings that operating experience to API access for AI features in customer products, agents, applications and automations.
