跳到主内容
@wquguru
精选88r/Rag(Reddit)技巧与观点

企业级RAG系统两阶段澄清机制架构设计

Designing a two-stage clarification mechanism for an enterprise RAG system ,looking for architectural feedback

原文
发到 X
推荐理由

RAG工程师必看,两阶段澄清有效解决了指代不明和检索后多义性问题,给出了具体架构和测试用例,极具落地参考价值。

I'm building an enterprise handbook RAG chatbot and experimenting with a two-stage clarification mechanism. I'd appreciate feedback from people who have built RAG systems in production.

我正在构建一个企业手册 RAG 聊天机器人,并尝试一种两阶段澄清机制。非常希望得到那些在生产环境中构建过 RAG 系统的人的反馈。

The problem I'm trying to solve is that users often ask questions that are ambiguous, but the ambiguity can come from two different places:

我要解决的问题是:用户经常提出含糊不清的问题,但这种歧义可能来自两个不同的方面:

  • Conversation context: The question is unclear before retrieval because the conversation contains multiple possible references.
  • Retrieved knowledge: The question looks understandable on its own, but retrieving the handbook reveals multiple possible policies or interpretations.
  • 对话上下文:在检索之前,由于对话中包含多个可能的指代对象,导致问题不清楚。
  • 检索到的知识:问题本身看起来可以理解,但检索企业手册后发现存在多种可能的政策或解释。

My proposed architecture

我提出的架构

I'm experimenting with two clarification stages using the same prompted LLM which is qwen/qwen3.8-27b without fine-tuning.

我正在使用同一个提示词 LLM(qwen/qwen3.8-27b,未经微调)进行两个阶段的澄清实验。

Stage 1 — Pre-retrieval clarification

第一阶段 — 检索前澄清

Input:

输入:

  • Original user question
  • Recent conversation history
  • 原始用户问题
  • 最近的对话历史

The model decides whether the question is already ambiguous based on the conversation context.

模型根据对话上下文判断问题是否已经存在歧义。

If CLEAR, the system proceeds with query rewriting and retrieval.

如果为 CLEAR(清晰),系统将执行查询重写和检索。

If CLARIFY, it asks the user a question without retrieving handbook documents.

如果为 CLARIFY(需澄清),则向用户提问,而不检索企业手册文档。

Stage 2 — Post-retrieval clarification

第二阶段 — 检索后澄清

Input:

输入:

  • Original user question
  • Conversation history
  • Retrieved and reranked handbook chunks
  • 原始用户问题
  • 对话历史
  • 检索并重新排序的企业手册片段

The model checks whether the retrieved content introduces multiple materially different interpretations that require the user to clarify.

模型检查检索到的内容是否引入了多种实质性的不同解释,从而需要用户进行澄清。

If CLEAR, a separate answer-generation stage produces the response.

如果为 CLEAR(清晰),则由独立的答案生成阶段产生回复。

If CLARIFY, the system asks a question grounded in the retrieved policies.

如果为 CLARIFY(需澄清),系统会基于检索到的政策提出问题。

The existing retrieval threshold and in-scope checks remain responsible for retrieval relevance and out-of-scope handling. The clarification stages only return CLEAR or CLARIFY.

现有的检索阈值和范围检查仍负责处理检索相关性和超出范围的情况。澄清阶段仅返回 CLEAR 或 CLARIFY。

Some test cases I'm using

我使用的一些测试用例

1. Pre-retrieval clarification

1. 检索前澄清

Conversation:

对话:

User: "Explain annual leave and casual leave."

用户:"解释年假和事假。"

User: "How many days can I take?"

用户:"我可以休多少天?"

Expected: CLARIFY.

预期:CLARIFY(澄清)。

The previous conversation contains two possible leave types, so the system should ask which one the user means before retrieval.

之前的对话包含两种可能的假期类型,因此系统在检索前应询问用户指的是哪一种。

New conversation:

新对话:

User: "How many days of leave can I take?"

用户:"我可以休多少天假?"

Expected: CLARIFY.

预期:CLARIFY(澄清)。

There is no conversation context identifying the leave type.

没有上下文能确定假期类型。

2. Post-retrieval clarification

2. 检索后的澄清

User: "Am I eligible for an allowance?"

用户:"我是否有资格领取津贴?"

Expected: CLARIFY.

预期:CLARIFY(澄清)。

The retrieved handbook contains different policies for Attendance Allowance and Phone Bill Allowance. The question itself doesn't identify which one the user means.

检索到的员工手册中包含出勤津贴和电话费津贴的不同政策。问题本身并未指明用户指的是哪一种。

User: "How much allowance do I get?"

用户:"我能拿多少津贴?"

Expected: CLARIFY if retrieval reveals different reimbursement rules for private vehicle and public transport.

预期:如果检索结果显示私家车和公共交通的报销规则不同,则进行 CLARIFY(澄清)。

3. CLEAR — answer without clarification

3. CLEAR — 无需澄清直接回答

  • "What leave policies are available?"
  • "Compare casual leave and earned leave."
  • "Explain attendance allowance and phone bill allowance."
  • "How many casual leave days do I get?"
  • "有哪些休假政策?"
  • "比较事假和积存假。"
  • "解释出勤津贴和电话费津贴。"
  • "我能休多少天事假?"

These are either overview requests, explicit comparisons, or sufficiently specific questions.

这些请求要么是概述性质的,要么是明确的对比,或者是足够具体的问题。

One important distinction: I don't want the system to ask for clarification just because multiple documents or policies were retrieved. If the user explicitly asks for an overview, list, or comparison, it should answer directly.

一个重要的区别:我不希望系统仅仅因为检索到了多份文档或政策就要求澄清。如果用户明确要求概述、列表或对比,系统应直接回答。

Questions for the community

向社区提出的问题

  • Architecture: Does separating pre-retrieval and post-retrieval clarification make sense, or would you handle both decisions in a single LLM call after retrieval? What trade-offs have you encountered in production?
  • Broad versus ambiguous questions: For example, if a user asks "What is the leave policy?", would you retrieve the data and provide an overview of the available leave types, then invite the user to choose one for more detail?But if they ask "How many days of leave can I take?", would you ask which leave type they mean before answering?I'm interested in how you design this behavior without making the chatbot over-clarify or forcing users to know the available policy categories before they can get useful information.
  • Evaluation: How would you evaluate whether clarification is genuinely necessary? I'm particularly interested in avoiding over-clarification, where the system keeps asking questions simply because multiple policies were retrieved, even though it could provide a useful answer.
  • 架构:将检索前澄清和检索后澄清分开是否合理,或者你们会在检索后通过单次 LLM 调用处理这两种决策?在生产环境中遇到了哪些权衡取舍?
  • 宽泛与模糊的问题:例如,如果用户问“请假政策是什么?”,你会检索数据并提供可用假期类型的概述,然后邀请用户选择一种以获取更详细的信息吗?但如果他们问“我可以休多少天假?”,你会在回答之前询问他们指的是哪种假期类型吗?我感兴趣的是你如何设计这种行为,而不会让聊天机器人过度澄清或迫使用户在获得有用信息之前就必须了解可用的政策类别。
  • 评估:你将如何评估澄清是否真正必要?我特别关注避免过度澄清,即系统仅仅因为检索到了多项政策就不断提问,尽管它本可以提供有用的答案。

I'm interested in practical engineering experience, failure cases, and alternative architectures and not just theoretical recommendations.

我对实际的工程经验、失败案例以及替代架构感兴趣,而不仅仅是理论上的建议。

Thanks!

谢谢!

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件