Query Clarification and Disambiguation
What you'll learn: How RAG systems can resolve vague or ambiguous user queries by adding context or prompting for clarification before retrieving documents.
The Problem with Ambiguous Queries
When users ask "Tell me about Python," do they mean the programming language or the snake? In retrieval systems, ambiguous queries lead to irrelevant document retrieval, which then produces poor LLM responses. Unlike query rewriting (which you just learned), query clarification focuses on detecting and resolving ambiguity before retrieval begins.
How Query Clarification Works
Think of it like a librarian who asks, "Which Python did you mean?" before fetching books. The system can:
- Detect ambiguity: Use an LLM to identify when a query has multiple interpretations
- Add context automatically: Enrich the query using conversation history or user profile metadata
- Ask clarifying questions: Generate targeted follow-up questions ("Are you asking about Python the programming language?")
- Disambiguate via LLM: Use the LLM to select the most likely interpretation given available context
Practical Approaches
Context injection: If you know the user previously asked about machine learning, append that context: "Python programming language in the context of ML."
Interactive clarification: Generate 2-3 quick clarification options and let the user select before retrieval proceeds.
Confidence-based gating: Only trigger clarification when the system detects low confidence in query understanding, avoiding friction for clear queries.
This technique sits between the user's raw query and your retrieval phase, ensuring that what you search for actually matches user intent.
Key Takeaway: Query clarification catches ambiguous queries early by either automatically adding context or asking targeted questions, preventing irrelevant retrievals and improving downstream RAG quality.