# Ambiguous Query Expansion

## The Problem

Short or ambiguous queries get expanded incorrectly, leading to irrelevant retrievals or missing the user's actual intent.

### Symptoms

* ❌ Query "API" retrieves too broadly
* ❌ Ambiguous term interpreted wrong
* ❌ Over-expansion adds noise
* ❌ Cannot disambiguate intent
* ❌ Retrieves multiple unrelated topics

### Real-World Example

```
Query: "Python"

Could mean:
→ Python programming language (tech docs)
→ Python the snake (if you have wildlife content)
→ Monty Python (if you have entertainment content)

Retrieval returns:
→ Mix of all interpretations
→ Mostly irrelevant for user's actual intent
→ AI confused by mixed context
```

***

## Deep Technical Analysis

### Ambiguity Types

**Polysemy:**

```
"Bank":
→ Financial institution
→ River bank

"Spring":
→ Season
→ Coiled metal
→ Spring framework (Java)

Without context, cannot determine intent
```

**Short Queries:**

```
"API" - Too generic
Could be:
→ REST API
→ GraphQL API
→ Specific API endpoint docs
→ API authentication
→ API pricing

Retrieves everything, too broad
```

### Contextual Disambiguation

**Conversation History:**

```
Turn 1: "Tell me about authentication"
Turn 2: "What about API?"

"API" in context of "authentication":
→ Likely means API authentication
→ Not API pricing or design

Use conversation to narrow intent
```

**User Profile/Role:**

```
User: Developer (role metadata)
Query: "deployment"

Interpret as:
→ Code deployment (technical)

vs

User: Marketing
Query: "deployment"

Interpret as:
→ Feature rollout (business)

Role-based disambiguation
```

### Query Clarification

**Ask Back:**

```
Query: "API" (ambiguous)

AI: "I found information about API authentication, API endpoints,
and API rate limits. Which would you like to know about?"

User clarifies → precise retrieval
```

**Suggest Intent:**

```
Query: "Configure Python"

AI detects ambiguity, suggests:
→ "Did you mean: Configure Python for development?"
→ Or: "Configure Python SDK for our API?"

User selects → proceed with clear intent
```

### Controlled Expansion

**Domain-Specific Expansion:**

```
General expansion (bad):
"API" → [api, application programming interface, endpoint, service, ...]

Domain-specific (better):
"API" in tech docs → [REST API, GraphQL, API authentication, API key, rate limit]

Controlled vocabulary based on domain
```

**Relevance Feedback:**

```
Initial retrieval:
→ Retrieve diverse results
→ Show to user (quick preview)
→ User clicks relevant ones
→ Re-retrieve with refined query

Interactive disambiguation
```

***

## How to Solve

**Use conversation context to disambiguate queries + implement query clarification (ask user to specify) + apply role/domain-based interpretation + controlled vocabulary expansion (domain-specific) + require minimum query length (e.g., 3+ words) + use intent classification before retrieval + implement relevance feedback loop.** See [Ambiguous Queries](/rag-scenarios-and-solutions/accuracy/ambiguous-questions.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.twig.so/rag-scenarios-and-solutions/accuracy/ambiguous-questions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
