This prompt is designed for the query rewriting layer of a Retrieval-Augmented Generation (RAG) pipeline that serves multi-turn conversational search. Its job is to reconstruct a user's incomplete follow-up question into a fully specified, standalone query before it hits your vector or keyword index. The ideal user is a search engineer or RAG developer who observes retrieval failures on follow-up turns—queries like 'What about last quarter?' or 'And for enterprise customers?' that return irrelevant or empty results because the retrieval system treats them in isolation. You need this prompt when your application maintains a conversation history and users routinely ask questions that depend on prior turns for their full meaning.
Prompt
Ellipsis Expansion Prompt for Conversational Search

When to Use This Prompt
Identify where ellipsis expansion fits in your conversational search pipeline and when a simpler approach will do.
The prompt operates on a specific input shape: the current incomplete query plus the relevant conversation history. It does not perform retrieval, generate answers, or manage dialogue state. It should be positioned after turn boundary detection—so you know which prior turns are still in scope—and before retrieval execution. In a typical RAG architecture, this means inserting the expansion step between the conversational router and the retrieval backend. The output is a single rewritten query string that carries forward missing clauses, modifiers, and entities from prior turns. You can then pass that expanded query to your existing retrieval pipeline without changing your indexing or ranking logic.
Do not use this prompt when queries are already self-contained, when your retrieval system has native multi-turn context handling, or when the conversation history is unavailable. It is also the wrong tool for resolving coreference (pronouns like 'it' or 'they'), which requires a separate anaphora resolution step. If your users rarely ask follow-up questions, or if your sessions are single-turn by design, the added latency and token cost of ellipsis expansion will not pay for itself. For high-stakes domains—legal search, clinical reference, financial audit—always log the original query alongside the expanded version and consider a human review step before the rewritten query becomes the retrieval source of record.
Before deploying, build a small test harness with at least ten elliptical query pairs drawn from your actual user logs. Each test case should include the conversation history, the incomplete follow-up, and the expected expanded query. Run these through the prompt and measure exact-match accuracy and semantic equivalence. Common failure modes include over-expansion (adding clauses the user did not intend), under-expansion (missing a carried-forward modifier), and temporal anchor drift (resolving 'last quarter' against the wrong reference date). If your eval shows more than 10% failure on real user queries, consider adding few-shot examples to the prompt or tightening the output constraints before moving to production.
Use Case Fit
Where the Ellipsis Expansion Prompt works, where it fails, and the operational conditions required before you put it in front of users.
Good Fit: Verb Phrase Ellipsis
Use when: users ask short follow-ups like 'Does it also work for Python?' where the main verb and object are omitted. Guardrail: confirm the prior turn contains a complete verb phrase before expanding; if the antecedent is ambiguous, generate multiple candidate expansions and score them.
Good Fit: Noun Phrase Ellipsis
Use when: a follow-up references a subset or modifier of a noun from the prior turn, such as 'What about the free tier?' after discussing pricing plans. Guardrail: validate that the expanded noun phrase matches an entity present in the conversation history; log mismatches for review.
Bad Fit: Standalone Queries
Avoid when: the user's query is already a complete, self-contained retrieval request with no missing clauses. Guardrail: add a pre-check step that classifies whether the query contains ellipsis before invoking expansion; skip the prompt entirely for standalone queries to save latency and tokens.
Bad Fit: Multi-Turn Gapping Across Distant Turns
Avoid when: the gap spans more than two turns back or crosses a clear topic boundary. Guardrail: implement a turn-distance limit and a topic-shift detector; if the antecedent is too far or the topic changed, fall back to a broader conversation summary instead of precise ellipsis expansion.
Required Inputs
Required: the current elliptical query, the immediately prior user turn, and the system's last response. Guardrail: if any of these three inputs is missing or truncated, do not attempt expansion; return the query as-is with a flag indicating insufficient context.
Operational Risk: Over-Expansion
Risk: the model adds clauses or modifiers that were not implied, creating a query that retrieves irrelevant or misleading documents. Guardrail: run the expanded query through a semantic similarity check against the original plus context; reject expansions below a similarity threshold and log for prompt tuning.
Copy-Ready Prompt Template
A copy-ready prompt for expanding elliptical follow-up queries using prior conversation context before retrieval.
This template resolves elliptical constructions in conversational search—incomplete follow-up queries where the user omits clauses, verbs, or noun phrases carried forward from prior turns. Without expansion, a query like 'What about last month?' fails against a retrieval index because it lacks the subject, metric, and filter context established earlier. The prompt instructs the model to reconstruct the full, standalone query by merging the current turn with the relevant prior context, making it safe to pass directly to a vector store, keyword index, or hybrid retrieval pipeline.
textYou are a query rewriting engine for a conversational search system. Your job is to expand elliptical follow-up queries into complete, standalone retrieval queries by carrying forward missing clauses, modifiers, and entities from the conversation history. ## INPUT [CURRENT_QUERY] [CONVERSATION_HISTORY] ## INSTRUCTIONS 1. Identify what is missing from [CURRENT_QUERY] that was present in [CONVERSATION_HISTORY]. Look for: - Verb phrase ellipsis (e.g., 'What about last month?' missing the action) - Noun phrase ellipsis (e.g., 'Show me the other one' missing the entity) - Gapping (e.g., 'Sales increased and costs too' missing the verb) - Implicit modifiers (e.g., 'Any updates?' missing the subject) 2. Reconstruct a complete, self-contained query that: - Preserves the user's original intent and terminology - Carries forward only the necessary missing elements from prior turns - Does not add information not present in the history - Is suitable for direct execution against a retrieval index 3. If [CURRENT_QUERY] is already complete and self-contained, return it unchanged. 4. If the reference is ambiguous and cannot be resolved from [CONVERSATION_HISTORY], return the original query and set [CONFIDENCE] to LOW. ## OUTPUT FORMAT Return a JSON object with these fields: { "expanded_query": "The complete, standalone query string", "ellipsis_type": "verb_phrase | noun_phrase | gapping | implicit_modifier | none", "carried_forward": ["list of elements carried from prior turns"], "confidence": "HIGH | MEDIUM | LOW", "original_query": "[CURRENT_QUERY]" } ## CONSTRAINTS - Do not invent facts, entities, or filters not present in [CONVERSATION_HISTORY]. - Do not change the user's intent or add speculative expansions. - If multiple prior turns exist, prioritize the most recent relevant turn for resolution. - Preserve any explicit negation from the current query. ## EXAMPLES Example 1 — Verb Phrase Ellipsis: [CURRENT_QUERY]: "What about last month?" [CONVERSATION_HISTORY]: "User: Show me revenue by region for Q3. Assistant: Here is the revenue breakdown by region for Q3." Output: { "expanded_query": "Show me revenue by region for last month", "ellipsis_type": "verb_phrase", "carried_forward": ["revenue by region", "show me"], "confidence": "HIGH", "original_query": "What about last month?" } Example 2 — Noun Phrase Ellipsis: [CURRENT_QUERY]: "What's the conversion rate for the other one?" [CONVERSATION_HISTORY]: "User: Compare conversion rates for Campaign Alpha and Campaign Beta. Assistant: Campaign Alpha has a 3.2% conversion rate." Output: { "expanded_query": "What's the conversion rate for Campaign Beta?", "ellipsis_type": "noun_phrase", "carried_forward": ["conversion rate", "Campaign Beta"], "confidence": "HIGH", "original_query": "What's the conversion rate for the other one?" } Example 3 — No Ellipsis: [CURRENT_QUERY]: "Show me Q4 revenue for the EMEA region" [CONVERSATION_HISTORY]: "User: What were our top products in Q3? Assistant: The top products in Q3 were..." Output: { "expanded_query": "Show me Q4 revenue for the EMEA region", "ellipsis_type": "none", "carried_forward": [], "confidence": "HIGH", "original_query": "Show me Q4 revenue for the EMEA region" }
Before deploying, test this prompt against a golden dataset of elliptical query pairs covering verb phrase ellipsis, noun phrase ellipsis, gapping, and implicit modifiers. Validate that expanded_query matches expected ground truth and that confidence scores correlate with actual correctness. For high-risk domains where incorrect expansion could surface wrong documents, route LOW confidence outputs to a human review queue or fall back to the original unexpanded query with a broader retrieval strategy.
Prompt Variables
Inputs the Ellipsis Expansion Prompt needs to resolve incomplete follow-up queries. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to check that the input is well-formed and safe to use.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CURRENT_QUERY] | The incomplete follow-up question that contains an elliptical construction | What about last Tuesday? | Must be a non-empty string. Check for minimum length of 2 characters. Reject null or whitespace-only input. Log if query is identical to prior turn without new content. |
[CONVERSATION_HISTORY] | The preceding dialogue turns needed to resolve the ellipsis, formatted as ordered speaker-utterance pairs | User: Show me sales for Q3. Assistant: Here is the Q3 report. User: What about Q4? | Must contain at least 1 prior turn. Validate that each turn has a speaker label and utterance. Truncate to last N turns if exceeding context budget. Strip any system prompts or tool calls from history before insertion. |
[ELLIPSIS_TYPE_HINT] | An optional classification of the ellipsis type to guide the model's resolution strategy | verb_phrase_ellipsis | Must be one of the allowed enum values: verb_phrase_ellipsis, noun_phrase_ellipsis, gapping, sluicing, null. If null, the model must infer the type. Validate against the enum before passing to the prompt. |
[OUTPUT_SCHEMA] | The expected JSON structure for the expanded query and metadata | {"expanded_query": "string", "carried_forward_clauses": ["string"], "ellipsis_type": "string", "confidence": 0.0-1.0} | Must be a valid JSON Schema or example object. Parse the schema before use to confirm it is valid JSON. Ensure the schema includes a confidence field for downstream routing decisions. |
[MAX_EXPANSION_LENGTH] | The maximum token or character length allowed for the expanded query to prevent unbounded output | 150 tokens | Must be a positive integer. Validate that the value is within the model's output token limit. If the expanded query exceeds this length, the harness should truncate and log a warning. Default to 200 tokens if not specified. |
[GROUNDING_RULES] | Instructions that require the model to only carry forward clauses explicitly present in the history, preventing hallucinated additions | Only reuse clauses verbatim from prior turns. Do not invent new entities, dates, or constraints. | Must be a non-empty string. Review for contradictions with other prompt sections. Test with adversarial history inputs to confirm the model does not add unsupported details. Log any expansion that introduces terms not found in history. |
Implementation Harness Notes
How to wire the ellipsis expansion prompt into a conversational search application with validation, retries, and logging.
The ellipsis expansion prompt is not a standalone utility; it is a pre-retrieval transformation step in a conversational RAG pipeline. The application must capture the current user utterance and the prior conversational context, inject them into the prompt template, and use the model's output as the rewritten query before any vector or keyword search executes. This means the harness must manage session state, decide how many prior turns to include, and handle cases where the model fails to produce a valid expansion.
Implement a validation layer immediately after the model response. Check that the output is non-empty, differs from the raw user input in a meaningful way, and does not introduce hallucinated entities not present in the conversation history. If the expansion is identical to the input or contains novel named entities, log a warning and fall back to the original query. For high-reliability systems, run a second pass: compare the expanded query against a set of forbidden patterns (e.g., unresolved pronouns like 'it' or 'they' still present) and trigger a retry with explicit instructions to resolve remaining elliptical constructions. Use a lightweight model (e.g., GPT-4o-mini or Claude Haiku) for this validation step to keep latency low.
Wire the prompt into your retrieval pipeline with structured logging. Record the original query, the conversation context window used, the expanded query, the validation result, and the retrieval hit count. This trace data is essential for debugging retrieval failures—when a follow-up question returns poor results, you can inspect whether the expansion dropped a critical modifier or carried forward an irrelevant clause. Set a maximum context window of 3-5 prior turns to avoid diluting the current query with stale information. For production deployments, implement a circuit breaker: if expansion latency exceeds 500ms or the model returns errors on more than 5% of requests, bypass expansion and use the raw query until the issue is resolved. Do not use this prompt for single-turn, standalone queries where no elliptical resolution is needed—the overhead adds latency without benefit.
Expected Output Contract
Defines the required fields, types, and validation rules for the expanded query output. Use this contract to parse and validate the model response before passing it to your retrieval system.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
expanded_query | string | Must be non-empty and differ from [CURRENT_QUERY] by at least one token. Parse check: string length > 0. | |
resolved_ellipsis_type | enum: verb_phrase | noun_phrase | gapping | none | Must match one of the allowed enum values. Schema check: enum membership. If 'none', expanded_query should equal [CURRENT_QUERY]. | |
carried_forward_context | string | null | If resolved_ellipsis_type is not 'none', must contain the exact clause or phrase carried forward from [CONVERSATION_HISTORY]. Null allowed only when type is 'none'. Citation check: substring must appear in [CONVERSATION_HISTORY]. | |
source_turn_index | integer | null | Must be a valid index into the [CONVERSATION_HISTORY] array or null. If not null, the carried_forward_context must be verifiable against the turn at this index. Range check: 0 <= index < len(history). | |
confidence | number | Must be a float between 0.0 and 1.0 inclusive. Confidence threshold: if < 0.7, flag for human review or fallback to raw [CURRENT_QUERY]. | |
ambiguity_flag | boolean | Must be true if multiple valid expansions are possible from the conversation context. If true, the system should log the ambiguity and consider returning multiple candidate queries. | |
alternative_expansions | array of strings | null | If ambiguity_flag is true, should contain 1-3 alternative expanded query strings. Each must be non-empty. Null allowed when ambiguity_flag is false. Array length check: 0 < length <= 3. |
Common Failure Modes
Ellipsis expansion fails silently in production when the model guesses missing clauses, carries forward stale modifiers, or resolves gaps against the wrong prior turn. These cards cover the most frequent failure patterns and the operational checks that catch them before retrieval returns irrelevant results.
Wrong Antecedent Turn Selection
What to watch: The model resolves an elliptical gap against turn N-3 when the user intended turn N-1, especially after topic shifts or corrections. The expanded query imports irrelevant constraints from stale context. Guardrail: Include turn recency scoring in the prompt and log which prior turn was used as the resolution source. Add an eval that checks whether the selected antecedent turn matches the ground-truth reference.
Over-Expansion with Hallucinated Clauses
What to watch: The model adds modifiers, entities, or constraints that were never present in the conversation history, fabricating specificity to make the query look complete. This produces high-confidence but wrong retrieval results. Guardrail: Diff the expanded query against the conversation history to detect introduced terms. Add a constraint requiring every added clause to be traceable to a specific prior turn, and flag untraceable additions for human review.
Under-Expansion with Missing Critical Context
What to watch: The model produces a query that is grammatically complete but semantically incomplete, dropping essential modifiers like date ranges, entity types, or scope constraints from the prior turn. Retrieval returns overly broad results. Guardrail: Maintain a checklist of required context dimensions from the prior turn and validate that each dimension is either carried forward or explicitly dropped with a logged reason. Run recall evals against session-aware ground truth.
Negation Scope Collapse
What to watch: When a prior turn contains negation and the follow-up is elliptical, the model either drops the negation entirely or applies it to the wrong clause. A query like 'Show me ones that don't have that issue' loses the exclusion constraint. Guardrail: Explicitly extract and preserve negation signals from prior turns as structured constraints. Validate that the expanded query retains the correct negation scope by testing against positive and negative example sets.
Gapping Pattern Misalignment
What to watch: For gapping constructions like 'Sales increased in Q1 and revenue in Q2,' the model misaligns the parallel structure and produces a query that swaps predicates or arguments. The expanded query asks for the wrong metric in the wrong time period. Guardrail: Include gapping-specific test cases in your eval suite with explicit predicate-argument alignment checks. Add a structural validation step that verifies parallel slots are filled from the correct source clauses.
Implicit Reference Over-Resolution
What to watch: The model treats vague follow-ups as elliptical when the user is actually asking a new, underspecified question. It forces a connection to prior context and produces a query that answers a different question than the user intended. Guardrail: Add a gating step before expansion that classifies whether the follow-up is truly elliptical or a new underspecified query. If confidence is low, generate both an expanded query and a standalone query, then route to a disambiguation step.
Evaluation Rubric
Criteria for evaluating the quality of ellipsis expansion outputs before deploying the prompt to production. Each criterion includes a pass standard, failure signal, and test method.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Verb Phrase Ellipsis Resolution | The expanded query correctly carries forward the verb phrase from the prior turn without altering its meaning. | The verb phrase is missing, replaced with a different action, or the original predicate structure is corrupted. | Run 20 curated test cases with known verb phrase ellipsis patterns. Compare expanded output against ground-truth queries using exact match and semantic similarity threshold > 0.95. |
Noun Phrase Ellipsis Resolution | The expanded query restores the missing noun phrase head and modifiers from the antecedent turn. | The noun phrase is omitted, replaced with a generic placeholder, or the wrong antecedent is selected. | Use a golden dataset of 15 noun phrase ellipsis examples. Validate that the head noun and all modifiers from the antecedent appear in the output. |
Gapping Pattern Resolution | The expanded query reconstructs the full clause by inserting the elided verb and shared arguments from the prior turn. | The gapped clause is left incomplete, the wrong verb is inserted, or argument structure is misaligned. | Test against 10 gapping pattern cases. Parse output with a dependency parser and verify that the reconstructed clause has the same predicate-argument structure as the antecedent. |
No Hallucinated Content | The expanded query contains only terms present in the current turn or explicitly carried forward from prior turns. | The output introduces entities, modifiers, or constraints not present in the conversation history. | Diff the expanded query tokens against the union of current turn and prior turn tokens. Flag any novel content words. Human review flagged cases for false positives. |
Preservation of Current Turn Intent | The expanded query preserves the specific constraint, entity, or focus introduced in the current turn. | The expansion overrides or dilutes the current turn's new information with prior context. | Compare the expanded query against the current turn using a constraint extraction model. Verify all constraints from the current turn are present in the output. |
Multi-Turn Antecedent Selection | When multiple prior turns exist, the prompt selects the correct antecedent turn for ellipsis resolution. | The prompt resolves against the wrong prior turn, pulling in irrelevant or conflicting context. | Create test sessions with 3-5 turns where only one turn contains the correct antecedent. Measure antecedent selection accuracy across 25 multi-turn sessions. |
Output Format Compliance | The output is a single standalone query string with no extra commentary, explanation, or formatting. | The output includes preamble text, multiple candidate queries, markdown formatting, or conversational filler. | Validate output against a regex schema expecting a single plain-text query string. Reject any output containing newlines, bullet points, or explanatory text. |
Empty or Underspecified Input Handling | When the current turn is too vague to resolve even with context, the prompt returns the original query unchanged or signals low confidence. | The prompt hallucinates a specific query from insufficient evidence or expands with low-probability guesses. | Feed 10 intentionally underspecified follow-ups. Verify the output either matches the input exactly or includes a structured confidence field below threshold. No fabricated constraints allowed. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a small conversation history window (last 2-3 turns). Skip strict output validation and focus on whether the expanded query reads naturally. Test with a handful of ellipsis patterns: verb phrase ellipsis ('did it'), noun phrase ellipsis ('the red one'), and gapping ('Alice filed the report and Bob the ticket').
Watch for
- The model carrying forward wrong clauses when multiple candidates exist in history
- Over-expansion that adds details the user didn't intend
- Missing the distinction between ellipsis and topic shift—the model may expand when the user actually changed subjects

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us