出典:Hacker News原文を見る ↗
原文の著作権は出典元に帰属します。当サイトでは収録、翻訳、体裁調整のみを行います。
解説と影響
Don't classify, hallucinate!
文章的核心论点在于,分类任务往往要求模型在信息不完整或边界模糊的情况下做出非此即彼的判断,这本身就容易出错。而"幻觉"式的生成路径则允许模型先提出一个假设性的标签或类别,随后通过外部验证、用户反馈或后续推理来确认或推翻这一假设。作者认为,这种"先假设、后验证"的流程在某些场景下比直接分类更灵活,也更符合人类处理不确定信息的方式。原文未提供具体的实验数据或基准测试结果,讨论更多停留在方法论层面。
从技术背景来看,这一观点与大语言模型时代的"生成式推理"趋势相呼应。传统分类器输出的是固定类别集合上的概率分布,而生成式模型可以产出自然语言形式的假设,再借助工具调用、检索增强或自我一致性检查来收敛到可靠答案。Hacker News 评论区中,部分用户对这一思路表示认可,认为它在开放域问答和低资源分类任务中有应用潜力;也有观点指出,"幻觉"一词在此处带有修辞色彩,实际所指更接近"假设生成"而非模型产生事实性错误。目前该帖获得 39 分、10 条评论,讨论规模适中。
值得注意的是,将"幻觉"重新定义为一种可管理的中间步骤,而非单纯的模型缺陷,这一视角与近期业界对 AI 可靠性的讨论形成对照。例如,在涉及敏感数据的场景中——如税务系统——分类或信息处理的错误可能带来严重后果,因此"先假设、后验证"的流程是否适用于高风险领域仍需审慎评估。原文未就此类应用场景展开具体分析。
参考資料
出典原文
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:
Furniture / Office Furniture / Desks Furniture / Living Room Furniture / Coffee Tables & End Tables / Coffee Tables Furniture / Living Room Furniture / Coffee Tables & End Tables / End & Side Tables Décor & Pillows / Decorative Pillows & Blankets / Throw Pillows Furniture / Bedroom Furniture / Dressers & Chests
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:
from typing import Literal from pydantic import BaseModel, Field
FullyQualifiedClassifications = Literal[ 'Furniture / Bedroom Furniture / Beds & Headboards / Beds', 'Furniture / Living Room Furniture / Chairs & Seating / Accent Chairs', 'Rugs / Area Rugs', ...
times 500
]
class QueryClassification(BaseModel): """ Structured representation of a search query for furniture e-commerce. Inherits keywords from the base Query model and adds category and sub-category. """ classifications: list[FullyQualifiedClassifications] = Field( description="A possible classification for the product." )
response = client.responses.parse( model="gpt-5.4-mini", input="Classify the query: brown coffee table", text_format=QueryClassification, )
print(response.output_parsed.message)
Outputs: Furniture / Living Room Furniture / Coffee Tables & End Tables / Coffee Tables
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:
hallucination_prompt = f""" Your task is to create novel, never seen before, furniture, home goods, or hardware classification that best fit a search query.
Product classifications might look like:
Furniture / Living Room Furniture / Coffee Tables & End Tables / Coffee Tables Décor & Pillows / Decorative Pillows & Blankets / Throw Pillows Furniture / Bedroom Furniture / Dressers & Chests Kitchen & Tabletop / Kitchen Organization / Food Storage & Canisters School Furniture and Supplies / School Furniture / School Chairs & Seating / Stackable Chairs Baby & Kids / Toddler & Kids Bedroom Furniture / Kids Beds
Here's the query to generate classifications for:
brown coffee table
Now we’re not sending the list of legal classifications. We’re instead, asking the LLM to make stuff up:
response = client.responses.parse( model="gpt-5.4-mini", input=hallucinationprompt, textformat=list[str], )
It’ll then make up some BS that doesn’t actually exist in your real taxonomy like:
Furniture / Living Room / Tables / Coffee
Well that’s not very helpful.
Actually it’s extremely helpful. 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. As I’ve done in this notebook and this utility.
In the notebook, I compute a MiniLM embedding of every real Wayfair classification. I compute the embedding of the fake, hypothetical embedding from the LLM. I then dot product the fake embedding into the real ones to find the most similar. Producing:
Furniture / Living Room Furniture / Coffee Tables & End Tables / Coffee Tables
You can give these hallucination tasks to dumb / cheap LLMs. And you don’t need to ship the schema over to the LLM every time.
Upcoming events: Vectors Week
Join me for Vectors Week, a series of events about vector retrieval, hybrid search, and building your own vector database.
图片