What happened
Doug Turnbull details a strategy for product classification in e-commerce that utilizes Large Language Models (LLMs) in a novel way. Instead of forcing the LLM to conform to a strict, pre-defined taxonomy – represented by Pydantic’s FullyQualifiedClassifications – he asks the model to invent plausible furniture classifications.
The core idea is leveraging the LLM's ability to ‘hallucinate’ creative, yet seemingly relevant, categories based on a given query like 'brown coffee table'. This approach bypasses the need to ship the entire schema to the LLM each time, significantly reducing computational overhead. The experiment focuses on the Wayfair WANDS dataset. The conventional approach would involve defining all possible product classifications – hundreds of nested categories – within the model’s constraints. However, Turnbull's method involves asking the LLM simply to generate new classification terms. For example, for ‘brown coffee table’, the system prompts the LLM with a prompt designed to elicit specific classifications ( hallucination_prompt). The LLM then outputs seemingly relevant terms like 'Furniture / Living Room Furniture / Coffee Tables & End Tables / Coffee Tables'.
Why it matters
This technique is significant because traditional LLM-based classification relies on careful schema engineering, which can be time-consuming and limit the model's creative output.
By allowing the LLM to generate classifications independently, Turnbull reduces the operational complexity and cost of scaling these systems. The key value proposition is a more flexible and adaptable approach to product categorization that doesn’t require constant updates to a rigid taxonomy.
But, but, but…
The core caveat, as with any reliance on LLM-generated content, lies in the potential for inaccuracies or irrelevant outputs.
The initial output from the LLM – ‘Furniture / Living Room / Tables / Coffee’ – is demonstrably unhelpful, showcasing the need for a post-processing step to resolve these generated classifications into a genuine, validated vocabulary. This resolves to the real, valid classification as determined through MiniLM embeddings.
“You can now resolve that into the real vocabulary. It’s very cheap to build an in-memory set of embeddings of the REAL classifications.”
— Dr Non
The counter-take
The industry often assumes rigorous, pre-defined taxonomies are essential for accurate product classification. This demonstrates that a simpler, more creative approach – even one relying on ‘hallucination’ – can be equally effective and significantly cheaper at scale.
The AI angle
This approach represents an upgrade in LLM utilization—moving from strict control to leveraging the model's generative capabilities. It creates asymmetry in cost; cheaper generation combined with a relatively inexpensive embedding process yields a surprisingly effective solution.
