Aurnik's Thoughts (I have lots)

Handling LLM classification with speed without sacrificing accuracy

Once we identify the independent topics from a support conversation, each topic then enters the rest of the analysis pipeline which starts with classification.

We classify into five categories: bug report, feature request, documentation gap, no action needed, and a catchall for everything else.

Pass 1: Quick classification

Topics first go through a simple classification using a GPT mini model. This has the additional benefits of saving time and money, but the point is that we want to see if a “dumber” model is able to easily extract a classification with a high confidence score. Some LLMs don’t expose any way to gauge confidence, but GPT has logprobs which gives exact numbers for token probabilities.

This requires not using structured output, which would cause the confidence scores to be based on the correctness of the JSON result (which is constrained by the schema, thus always returning close to 100% confidence) rather than the actual classification result.

Part of making logprobs work well included simplifying the naming of the different classifications, because initially there were some that had similar structure (CREATE_BUG_REPORT, CREATE_FEATURE_REQUEST) which would then return multiple tokens including CREATE_ with high confidence.

  • CREATE_BUG_REPORT -> BUG
  • CREATE_FEATURE_REQUEST -> FEATURE
  • CREATE_DOCUMENTATION -> DOCS Even just including “report” and “request” would treat “_RE” as a token, which wasn’t ideal when we could instead get probabilities for singular, distinct tokens.

The confidence score from logprobs is still unhelpful sometimes as it’s not a real predictor of correctness. It’s not unusual to get a confidence score of 99+% on an incorrect classification. Thus, we use Other as a catchall in the first pass. If the classification isn’t Other and has high confidence, we move on in the analysis pipeline. Otherwise, the topic would get sent to:

Pass 2: Improved classification

This rarely gets triggered, but if it does, it usually means that the first pass needed more information. We improve upon the first pass in a few ways:

  1. Constrain the options: We usually only need to consider 2-3 of our 5 classification options, because we can see based on top_logprobs what the next top choices were.
  2. Add context: Sometimes a customer may report something as broken but that thing doesn’t actually exist, so we add additional context from the product knowledge we’ve built up from studying conversations over time. This comes from analyzing existing documentation as well as regularly updating information stored about what types of issues customers mention across support conversations.
  3. Use a stronger model: With the addition of the added context (the biggest differentiator of this pass) we upgrade the model used to take advantage of stronger reasoning.

Evaluation

Our eval has a variety of real support conversations ranging in complexity and descriptiveness. We measure precision, recall, and F1, as shown here:

comment from the first eval that was run during a GitHub Action triggered whenever classifier code is changed

Over time we have tried to improve classification through improving the prompt, adding different pieces of context, and purposefully trying to introduce variability to affect logprobs. The evals have become a necessity to judge what we’re doing that actually improves classifications across a varied dataset. In one case, we tried to structure the prompt to focus more on staff responses and ended up having clear bug reports get labeled as OTHER and NO_ACTION. The eval forces us to treat the F1 score as our signal of whether the classification step is actually improving.