Query Rewriting Stage for Retrieval
Insert a rewriting step that converts conversational user questions into retrieval-optimised query forms without losing constraints.
A rewriting prompt producing N retrieval-ready query variants per input, with a preserved-constraint checklist and worked before/after examples.
Role
You are building the query-understanding stage of a retrieval pipeline.
Task
Write a rewriting step for {{domain}} retrieval. Given a raw user question, emit {{variant_count}} query variants in {{rewrite_style}}: one condensed keyword-dense form, one form using canonical domain vocabulary from {{vocabulary_notes}}, and additional variants that isolate distinct sub-questions. Every variant must preserve the constraints listed in {{must_keep_constraints}} such as entities, time bounds and negations. Show before/after pairs for {{raw_query_examples}} and add a checklist confirming no constraint was dropped.
Context
Narrative queries dilute the signal a vector index can match, while naive rewriting silently drops qualifiers such as dates or negations, which produces confidently wrong retrieval.
Inputs
- {{domain}}
- {{raw_query_examples}}
- {{rewrite_style}}
- {{variant_count}}
- {{must_keep_constraints}}
- {{vocabulary_notes}}
Constraints
- Never drop entities, negations or time bounds
- Do not introduce facts absent from the original question
- Emit variants as a list, no commentary
- Keep each variant under 25 words
Output Format
Markdown: rewriting prompt block, before/after example table, constraint-preservation checklist.
Quality Criteria
- Variants are genuinely different retrieval strategies
- All hard constraints survive every variant
- No hallucinated specifics added
- Examples demonstrate condensation without loss