Post

HN
Hacker News

Don't classify, hallucinate!

Ranked #3 on Hacker News with 15 points and 3 comments.

Using LLMs to classify products, search queries, etc is by now boring. Yet it can still be difficult to constrains the LLM’s output to the legal vocabulary of brands, colors, categories, etc your system allows.

In the Wayfair WANDS e-commerce dataset, for example, you want to classify a query like “wood coffee table” into its most appropriate category. Of which there are hundreds:

The classic way to implement this would be with structured outputs. You tell your provide it must constrain its outputs to a list of legal values. In Pydantic, you create a giant literal of legal output values:

This works. But there’s a way to do this a lot cheaper with small / dumb models at scale. Not to mention, there’s an upper limit you can send

Luckily, there’s an easy pattern that makes LLM classification pretty seamless.

Just ask a dumb LLM to invent plausible, fake classifications for your query: