Inferensys

Prompt

Ambiguity Resolution via Decomposition Prompt

A practical prompt playbook for using Ambiguity Resolution via Decomposition Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for the Ambiguity Resolution via Decomposition Prompt.

This prompt is for search relevance engineers and RAG architects who need to handle ambiguous user queries before they hit a retrieval index. The job-to-be-done is detecting terms or phrases in a single user query that have multiple plausible meanings, then generating a separate set of disambiguated sub-questions for each interpretation. The ideal user is someone who already has a working retrieval pipeline and is now hardening it against a common failure mode: the user asks about 'jaguar speed,' and the system doesn't know whether to retrieve documents about animals, cars, or a vintage operating system. This prompt is not a general-purpose query rewriter. Do not use it when the query is already unambiguous, when you need a single best-guess expansion, or when the downstream system cannot handle multiple parallel retrieval branches.

The prompt requires the original user query, a description of the retrieval corpus or domain, and an output schema that captures each interpretation as a named cluster with its own sub-questions and a confidence score. You should wire this into a pre-retrieval stage where the output feeds a branching retrieval step: each interpretation cluster triggers its own set of searches, and the results are either merged with interpretation labels or routed to a disambiguation follow-up with the user. The confidence score is critical for deciding whether to run all branches silently or to surface the ambiguity to the user for clarification. A low-confidence interpretation cluster (below 0.6, for example) might be dropped or flagged for human review in high-stakes domains like legal or clinical search.

Before deploying this prompt, build a small eval set of ambiguous queries with known interpretations and verify that the model detects all plausible meanings without over-generating spurious ones. Common failure modes include missing a rare but valid interpretation, collapsing two distinct meanings into one cluster, or assigning high confidence to a hallucinated interpretation that has no corpus support. If your retrieval corpus is narrow and domain-specific, provide that domain context in the prompt to constrain the interpretation space. After retrieval, consider a downstream verification step that checks whether the retrieved documents actually support each interpretation before presenting results to the user.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Ambiguity Resolution via Decomposition Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your retrieval pipeline before integrating it.

01

Good Fit: Ambiguous Entity Queries

Use when: User queries contain terms with multiple real-world referents (e.g., 'Mercury' could be a planet, element, car, or insurer). Guardrail: The prompt generates one set of sub-questions per interpretation, each tagged with a confidence score. Route interpretations below a confidence threshold to a clarification prompt instead of retrieval.

02

Bad Fit: Single-Intent Factoid Lookups

Avoid when: The query is a straightforward factoid with one clear interpretation (e.g., 'What is the capital of France?'). Guardrail: Running decomposition on unambiguous queries adds latency and token cost without improving recall. Use a lightweight ambiguity classifier upstream and skip decomposition when confidence is high.

03

Required Inputs

What you must provide: The raw user query string, a list of known ambiguous terms in your domain (optional but improves precision), and a target number of interpretations. Guardrail: Without a domain-specific ambiguity list, the model may miss collisions that matter to your corpus or over-decompose on irrelevant polysemy. Maintain a curated ambiguity registry.

04

Operational Risk: Retrieval Fan-Out

Risk: Each interpretation spawns multiple sub-questions, multiplying retrieval calls and latency. A query with 3 interpretations and 4 sub-questions each produces 12 retrieval rounds. Guardrail: Cap the total number of interpretations and sub-questions. Use the confidence scores to prune low-probability interpretations before retrieval. Monitor p95 latency in production.

05

Operational Risk: Confidence Score Drift

Risk: The model may assign high confidence to an incorrect interpretation, causing the RAG pipeline to retrieve and synthesize irrelevant evidence. Guardrail: Implement a post-retrieval evidence check. If retrieved passages for a high-confidence interpretation have low relevance scores, discard that interpretation and fall back to the next candidate or a clarification prompt.

06

Bad Fit: Real-Time Chat with Strict Latency Budgets

Avoid when: The system requires sub-second response times and the user expects an immediate answer. Guardrail: Decomposition adds a full model round-trip before retrieval begins. For latency-sensitive chat, use a cached ambiguity map for known terms or defer decomposition to an async clarification step.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template that detects ambiguous terms in a user query and generates disambiguated sub-question sets for each plausible interpretation.

This prompt template is the core of the ambiguity resolution workflow. It takes a user query that contains terms with multiple possible meanings—such as homonyms, domain collisions, or underspecified references—and produces a structured decomposition that separates each interpretation into its own set of sub-questions. The output includes a confidence score for each interpretation, allowing downstream retrieval logic to prioritize, merge, or present clarification options to the user before executing expensive search operations.

text
You are an ambiguity detection and query decomposition specialist. Your job is to analyze a user query, identify terms or phrases that have multiple plausible interpretations, and generate separate sets of disambiguated sub-questions for each interpretation.

## INPUT
User Query: [QUERY]
Domain Context: [DOMAIN_CONTEXT]

## INSTRUCTIONS
1. Identify every term or phrase in the query that could reasonably be interpreted in more than one way within the given domain context.
2. For each ambiguous term, list the plausible interpretations. An interpretation is plausible if a reasonable user in this domain could intend it.
3. Generate a set of interpretations by combining the plausible meanings. Each interpretation set represents one coherent reading of the entire query.
4. For each interpretation set, generate 2-5 sub-questions that, when answered, would fully resolve the query under that interpretation. Each sub-question must be independently retrievable.
5. Assign a confidence score between 0.0 and 1.0 to each interpretation set, representing how likely this reading matches the user's original intent. Scores across all interpretation sets must sum to 1.0.
6. If the query has only one clear interpretation, return a single interpretation set with a confidence of 1.0 and explain why no ambiguity was detected.

## CONSTRAINTS
- Do not invent interpretations that are not supported by the query text and domain context.
- Sub-questions must be self-contained and not depend on answers from other sub-questions within the same interpretation set.
- Use the exact terminology from each interpretation to make sub-questions precise.
- If the domain context is insufficient to disambiguate, note this in the ambiguity_notes field.

## OUTPUT SCHEMA
Return a JSON object with this structure:
{
  "original_query": "string",
  "ambiguous_terms": [
    {
      "term": "string",
      "interpretations": ["string"]
    }
  ],
  "interpretation_sets": [
    {
      "id": "string",
      "reading": "string",
      "confidence": number,
      "sub_questions": [
        {
          "id": "string",
          "question": "string",
          "target_evidence_type": "fact|definition|procedure|comparison|list"
        }
      ]
    }
  ],
  "ambiguity_notes": "string"
}

## EXAMPLES
[EXAMPLES]

## RISK LEVEL
[RISK_LEVEL]

Adapt this template by populating [DOMAIN_CONTEXT] with a description of the system's knowledge scope—such as 'enterprise HR policies' or 'programming language documentation'—to constrain plausible interpretations. The [EXAMPLES] placeholder should contain 2-3 few-shot demonstrations showing queries with genuine ambiguity and their correct decompositions. Set [RISK_LEVEL] to 'low', 'medium', or 'high' to adjust the model's caution; for high-risk domains like healthcare or legal, add an explicit instruction to flag interpretations that could cause harm if wrong. After generating the decomposition, validate the output JSON against the schema before passing interpretation sets to your retrieval layer. If the top confidence score is below 0.6, route the query to a clarification prompt that asks the user to pick the intended meaning rather than executing low-confidence retrievals.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Ambiguity Resolution via Decomposition Prompt. Wire these placeholders into your RAG harness before calling the model.

PlaceholderPurposeExampleValidation Notes

[AMBIGUOUS_QUERY]

The user query containing ambiguous terms, entities, or underspecified constraints that need disambiguation

What are the benefits of Java?

Required. Must be a non-empty string. Reject if length < 3 characters or > 2000 characters. Log and escalate if query appears to be a system command or injection attempt.

[DOMAIN_CONTEXT]

Optional domain or application scope to constrain plausible interpretations

software engineering job market

Optional. If provided, must be a string under 500 characters. If null, the model will consider all plausible domains. Validate that domain context does not contradict the query.

[USER_ROLE]

Optional role or persona of the user to bias interpretation toward relevant meanings

backend developer evaluating programming languages

Optional. If provided, must be a string under 300 characters. Use to disambiguate when multiple interpretations are equally plausible. Null allowed.

[MAX_INTERPRETATIONS]

Upper bound on the number of distinct interpretations to generate

3

Required. Must be an integer between 1 and 10. Default to 3 if not specified. Values above 5 may increase latency without proportional value. Validate as integer; reject floats or strings.

[CONFIDENCE_THRESHOLD]

Minimum confidence score for an interpretation to be included in output

0.3

Required. Must be a float between 0.0 and 1.0. Default to 0.2. Interpretations below this threshold are dropped. Validate as numeric; reject non-numeric values. Log when threshold is set above 0.7 as it may suppress valid low-confidence interpretations.

[OUTPUT_SCHEMA]

JSON schema or format specification for the disambiguation output

See output contract: interpretations array with interpretation_label, confidence_score, sub_questions fields

Required. Must be a valid JSON schema or a reference to a known schema ID. Validate that schema includes required fields: interpretation_label, confidence_score, sub_questions. Reject schemas missing these fields.

[RETRIEVAL_INDEX_TYPE]

Target index type to optimize sub-question formulation for

hybrid (dense vector + sparse keyword)

Optional. Accepted values: dense, sparse, hybrid, graph, sql. If null, sub-questions will be written for general-purpose retrieval. Validate against allowed enum. Log if value is unrecognized.

[SESSION_HISTORY]

Prior conversation turns for context-dependent disambiguation

User previously asked about JVM performance tuning

Optional. If provided, must be an array of turn objects with role and content fields. Null allowed. Validate that history does not exceed context window budget. Truncate to last 5 turns if longer.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the ambiguity resolution prompt into a production retrieval pipeline with validation, routing, and fallback logic.

The Ambiguity Resolution via Decomposition Prompt is designed to sit before your primary retrieval step. When a user query enters the system, this prompt acts as a pre-retrieval classifier and expander. It detects whether the query contains ambiguous terms—entity collisions, domain-specific jargon with multiple meanings, or underspecified constraints—and, if so, generates multiple sets of disambiguated sub-questions, one for each plausible interpretation. The downstream harness then decides whether to run all interpretation sets in parallel, present the user with a clarifying question, or route based on confidence scores. This prompt is not a retrieval step itself; it produces structured metadata that controls how retrieval executes.

Integration pattern: Wire this prompt into a pre-retrieval service that receives the raw user query and any available session context. The model call should use a low-latency model (e.g., GPT-4o-mini, Claude Haiku, or a fine-tuned small model) because this step adds latency before the main retrieval. The output must be parsed as strict JSON with a schema that includes: is_ambiguous (boolean), interpretations (array of objects with interpretation_label, confidence [0-1], and sub_questions [array of strings]), and original_query. If is_ambiguous is false, the harness passes the original query directly to retrieval. If true, the harness checks the highest confidence score: above a threshold (e.g., 0.7), it may auto-execute the top interpretation's sub-questions; below that, it should surface the interpretations to the user for disambiguation. Validation: Before routing, validate that each interpretation has at least one sub-question, that confidence values are within [0,1], and that no interpretation label is empty. Reject malformed outputs and retry once with a stricter schema reminder. Logging: Log the original query, the ambiguity flag, the number of interpretations, and the chosen routing path. This data is critical for tuning the confidence threshold and identifying query patterns that cause false positives or missed ambiguities.

Failure modes to handle in the harness: (1) The model fails to detect ambiguity when it exists—mitigate by maintaining a shadow evaluation set of known-ambiguous queries and periodically running them through the prompt to check recall. (2) The model over-decomposes a clear query into unnecessary sub-questions—mitigate by setting a minimum confidence threshold for the is_ambiguous flag and by capping the number of interpretations (e.g., max 5). (3) The generated sub-questions drift from the original intent—mitigate by including a post-retrieval evaluation step that checks whether retrieved evidence from each sub-question set is relevant to the original query. Tool integration: If your system has access to entity resolution APIs or knowledge graph lookups, pass resolved entity IDs as additional context into this prompt to reduce false ambiguity detections. Human review: For high-stakes domains (legal, medical, financial), always route ambiguous queries with confidence below 0.9 to a human-in-the-loop review queue before executing retrieval. Never auto-resolve ambiguity when the cost of wrong retrieval is high.

Next steps after implementation: Once the harness is live, monitor the ratio of ambiguous to unambiguous queries, the distribution of confidence scores, and the downstream retrieval quality metrics (recall@k, answer faithfulness) for queries that went through the disambiguation path versus those that didn't. Use this data to tune the confidence threshold and to build a regression test suite of ambiguous queries with expected interpretations. Avoid the temptation to remove the human-in-the-loop path prematurely—ambiguity resolution is a long-tail problem, and edge cases will surface in production that no eval set captures.

PRACTICAL GUARDRAILS

Common Failure Modes

Ambiguity resolution via decomposition is powerful but brittle. These are the most common failure modes when generating disambiguated sub-questions, along with practical checks to prevent them before they reach retrieval.

01

Interpretation Collapse

What to watch: The model generates only one interpretation when the query is genuinely ambiguous, missing plausible alternative meanings. This happens when the dominant sense of a term overwhelms minority senses. Guardrail: Require a minimum of two candidate interpretations in the output schema. If the model cannot find a second, it must explicitly state 'no alternative interpretation found' rather than silently collapsing.

02

Spurious Disambiguation

What to watch: The model invents interpretations that are grammatically possible but contextually implausible, wasting retrieval budget on irrelevant sub-questions. This often occurs with domain-specific terms the model doesn't fully understand. Guardrail: Include a confidence score for each interpretation and set a minimum threshold (e.g., 0.7) before an interpretation generates sub-questions. Log low-confidence interpretations for review rather than executing them.

03

Sub-Question Drift

What to watch: Generated sub-questions drift away from the original query's intent, introducing assumptions or narrowing scope in ways that exclude relevant evidence. Each decomposition step can amplify small misinterpretations. Guardrail: Add a post-generation validation step that checks each sub-question against the original query for semantic containment. Flag sub-questions that introduce new constraints not present in the source.

04

Overlapping Sub-Questions

What to watch: Multiple sub-questions target the same retrieval space, producing duplicate results and wasted compute. This is common when interpretations differ only in phrasing rather than substance. Guardrail: Compute pairwise similarity between generated sub-questions before execution. Merge or drop sub-questions above a similarity threshold (e.g., cosine similarity > 0.85) to deduplicate the retrieval plan.

05

Missing Entity Grounding

What to watch: Ambiguous terms like 'Apple' or 'Java' are disambiguated into interpretations without mapping them to canonical entity IDs or knowledge graph nodes. Retrieval then returns mixed results for both senses. Guardrail: Require each interpretation to include an entity grounding field with a canonical identifier when the ambiguous term maps to a known entity in your system. If no grounding exists, flag the interpretation for human clarification.

06

Confidence Inflation

What to watch: The model assigns high confidence scores to all interpretations, making the scoring mechanism useless for filtering or prioritization. This defeats the purpose of confidence-gated retrieval. Guardrail: Calibrate confidence by including a few-shot example where at least one interpretation is marked low-confidence with an explanation. Add a validator that rejects outputs where all scores cluster above 0.9 without variance.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of disambiguated sub-question sets before integrating the prompt into a production RAG pipeline. Each criterion targets a specific failure mode of ambiguity resolution.

CriterionPass StandardFailure SignalTest Method

Interpretation Coverage

All plausible interpretations of the ambiguous term are identified and generate a distinct sub-question set.

A common interpretation is missing, or a single interpretation is forced without acknowledging alternatives.

Human review against a pre-defined list of known ambiguities for the test query; check if the output count matches the expected number of interpretations.

Sub-Question Independence

Each sub-question within an interpretation set is self-contained and answerable without referencing other sub-questions.

A sub-question contains pronouns like 'it' or 'this' that refer to another sub-question's expected answer.

Parse each sub-question for unresolved anaphora; attempt to answer each in isolation using a mock retriever.

Confidence Score Calibration

The confidence score for each interpretation correlates with the linguistic plausibility of that reading in the given context.

A highly unlikely interpretation receives a confidence score above 0.8, or the most likely interpretation scores below 0.5.

Compare the model's confidence ranking against a human-ranked list of interpretations for 20 ambiguous queries; check for rank correlation.

Disambiguation Rationale Quality

The rationale for each interpretation correctly identifies the ambiguous term and explains the semantic shift.

The rationale is generic ('this could mean different things'), hallucinates a meaning, or fails to name the ambiguous token.

LLM-as-judge check: does the rationale text contain the exact ambiguous word and a valid dictionary definition for each sense?

Schema Compliance

Output is valid JSON matching the [OUTPUT_SCHEMA] with all required fields present and correctly typed.

Missing interpretations array, a sub-question string is null, or confidence_score is a string instead of a number.

Automated schema validation using a JSON Schema validator against the expected structure before downstream processing.

No Premature Resolution

The prompt generates multiple interpretation sets even when one seems dominant; it does not collapse ambiguity into a single answer.

Output contains only one interpretation with a confidence score of 1.0 for a genuinely ambiguous query like 'What is the best bank?'

Test with a curated set of 10 highly ambiguous queries; fail if the output contains fewer than 2 interpretations for any of them.

Sub-Question Retrievability

Generated sub-questions use specific, index-friendly keywords likely to match documents in the target knowledge base.

Sub-questions are phrased as abstract, philosophical questions or use overly conversational language that would fail a keyword search.

Execute each sub-question against a test index; pass if the top-5 results have an average relevance score above a set threshold.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet). Remove the strict JSON output schema initially and ask for a markdown list of interpretations with sub-questions. Focus on getting the decomposition logic right before adding harness constraints.

Prompt modification

Replace the [OUTPUT_SCHEMA] block with: Return a markdown list. For each interpretation, provide a confidence score (0-1), the disambiguated meaning, and 2-4 sub-questions.

Watch for

  • The model collapsing multiple interpretations into one
  • Confidence scores that are always 0.9+ without real discrimination
  • Sub-questions that rephrase the original query instead of disambiguating it
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.