How We Bolted RAG onto Intent Classification, or Lost in Translation to LLM-ese

Nikita Sykhrannov, Alexey Mironov, Egor Myshko20 Feb 2025

Problem

Domclick runs a customer-service chatbot that sorts user messages into intents (topics) and routes them to scenarios. This is a supervised text classifier, so every new intent or label update goes through the labeling team, data scientists and developers, and reaches production slowly. Topics in real estate and mortgage lending overlap and drift, and labeling needs domain experts. The team wanted a shorter time to market for new intents, fewer people in the chain and less labeling, with real-time classification.

Example from the article: a user writes "I paid off my mortgage, what next?", and the system must return the chatbot scenarios ranked by relevance.

Solution in brief

A retrieval step plus an LLM ranker replace the classifier. Each intent is described by anchor questions written by analysts. The incoming message is embedded, the closest anchors are retrieved with a per-intent cap, and a fine-tuned 9B LLM picks the best-matching ones. A new intent then needs only new anchors, not a retrained model.

Questions this case answers
  • How to classify short texts into a changing set of classes defined by editable example phrases, so that adding a class needs no retraining of a supervised model
  • How to pick candidate examples for a ranking prompt so that the prompt fits the latency budget and still covers several competing classes
  • How to serve a fine-tuned LLM in real time when the same code must run on CPU-only build machines and on GPU production nodes
  • How to add new chatbot intents without a labeling, retraining and release cycle?

Tools and methods

  • RAG, question-to-question matching — embed the query, retrieve anchors, LLM ranks them
  • Anchor selection (FIRST_K, TOP_N, TOP_N_PER_INTENT) — short but diverse prompt
  • saiga_gemma2_9b with QLoRA — the ranker, fine-tuned on cleaned labels
  • GGUF and llama.cpp — one inference format for CPU and GPU, 6.5x faster
  • Canary rollout and A/B test — online check on 50% of traffic
Continue reading — it's free

Google or a one-time email code. No password.