Problem
A bank's NLP team classifies chatbot messages, call transcripts and customer comments with BERT-style encoders. Prompting an LLM with descriptions of 300+ classes needs tens of thousands of prompt tokens, makes the model invent or confuse labels, takes seconds per request and requires a GPU. The team wanted to know when an LLM classifier beats BERT, and whether the gain survives a production limit of 15 requests per second under one second.
Example from the article: the first-line chatbot routes each message to one of 302 intents, with more than 300 thousand labeled samples and a RoBERTa model in production.
Solution in brief
Do not generate text: take the last-layer hidden state of a small LLM (up to about 1B parameters), put an ordinary classification head on top and fine-tune the model, fully or with a LoRA adapter. An LLM classifier wins on small labeled sets and long texts with complex meaning, and BERT stays competitive on large sets and short texts. Distillation into BERTA carries part of the gain to a CPU model.
Questions this case answers
- How to classify text into hundreds of labels when prompting a generative model is too slow, too long and unstable
- How to pick between a fine-tuned small LLM and a classic encoder given the number of labeled examples and the text length
- How to transfer the quality of a large fine-tuned model into a cheap CPU-only model under a latency limit
- How to classify text into hundreds of classes with an LLM when prompting bloats the context and hallucinates labels?
Tools and methods
- Gemma, Qwen — decoder models used as encoders
- LoRA fine-tuning — alternative to full tuning of the backbone, trained together with the head
- BERTA, RoBERTa, RuModernBERT — baselines; BERTA is also the distillation student
- Logit distillation — teacher logits plus true labels train a CPU-friendly student
Google or a one-time email code. No password.