Keep the BERT Classifier and Route the Rest
In 2019 the playbook was one model. bert-base-uncased, a linear head, 38 intents, a weekly test slice, F1 around 0.84. A new intent meant a week of labeling and a training job. That is a good system when the list of intents is closed.
This year the list stopped being closed. "Refund to a different card" showed up on a Tuesday, and a lot of tickets were not an intent at all. They were "write the reply." A classifier has no slot for that. A generative model does, and it will also write a reply in cases where it should have refused. We wrote down what the API actually felt like in August. This note is the routing decision that followed.
The formulas under the argument
The generative model did not arrive from nowhere. Search still starts from a count, and a count still has to be corrected for words that appear everywhere. Then a word becomes a vector, because a column of counts cannot say that "login" and "sign-in" are neighbors.
TF-IDF(t, d, D) = TF(t, d) × IDF(t, D)
TF(t, d) = (count of t in d) / (terms in d)
IDF(t, D) = log( |D| / (1 + documents containing t) )
L = (1/T) Σ_t Σ_{−c ≤ j ≤ c, j ≠ 0} log P(w_{t+j} | w_t)
P(w_o | w_t) = exp(u_o · v_t) / Σ_{w=1}^{W} exp(u_w · v_t)
TF-IDF is why a rare word beats a common one: divide by how often the term shows up in the corpus, inside a log so the correction does not explode. The skip-gram loss is why a word can be a point. u and v are the two vectors for a word, context and center. The dot product goes up when those words really do sit near each other. The sum in the denominator runs over the whole vocabulary, which is why training code uses negative samples instead of that sum. BERT is the same bet with context: the vector depends on the sentence. Asking the model to continue the sentence, instead of to name a class, is the step the API made cheap. The arithmetic for a real corpus is in the indexing note.
The threshold
We kept the classifier. We put a rule in front of the API.
- If the head's largest softmax is at least 0.55, return that intent and the template that goes with it. The call never leaves the building. It comes back in well under 50ms.
- If the largest softmax is below 0.55, send the ticket to the API with eight examples in the prompt, temperature 0, and the same 8 second cutoff as in August.
On the week we turned this on, the held-out long tail was 30 tickets the classifier had no class for. The prompted model got the intent right on 21 of them. Of the 9 misses, 6 were confident and wrong. Those 6 went to a person and then to the labeling queue. They did not go to the customer as a draft that only looked finished.
0.55 is not a universal constant. We plotted the softmax of the correct class on the weekly slice against the softmax on a pile of out-of-scope tickets. The curves crossed near there. Copy the number onto a different head and you have copied our plot. Draw your own.
What changed in the weekly routine
We stopped opening a labeling task for every new phrasing. We stopped training a fresh head because a stakeholder reworded an intent that the old head already caught. We stopped sending the common tickets, the ones the classifier already gets right, through an API call that costs seconds and can invent a policy.
The encoder remains the right tool when the label set is stable and you have hundreds of examples for each label. The generative model is the right tool when you have eight examples and a person will read the draft. Deleting either one is the mistake. The production change is the threshold.