Query reformulation for RAG that preserves the user's constraints
Sources checked 3 min read · By the Eval Suites editors
In brief
In a conversation, query reformulation can turn a follow-up into a standalone search query. A good rewrite carries forward the details the user still depends on, such as a date, a location, a price limit or an exclusion. Check those details before judging whether the rewritten query finds better evidence.
Specify what a rewrite must preserve
Write down what the earlier turns established, what the latest turn changes, and what is still unknown. The CANARD paper frames conversational question rewriting as producing a self-contained question with the same answer. Ma and colleagues' Rewrite–Retrieve–Read pipeline places the rewrite before retrieval. Those two ideas give you two places to look when a follow-up fails.[1][2]
A follow-up can override an earlier constraint. If the user says the date changed, update the date and carry forward the other requirements. If the user says either venue works, widen the location. If two venues fit “over there” and the history never resolved which one the user meant, label the expected behavior as a clarification.
Replay a follow-up with four near matches
In this fictional Riverlight Garden fixture, the first request is “Find a wheelchair-accessible class at North Hall on Saturday, March 14, 2026. Under $45, and no ceramics.” The user follows with “What about the following Saturday?” The rewrite must use March 21, 2026, keep North Hall and wheelchair accessibility, and retain both the strict price limit and the ceramics exclusion.
| Record | Fixture attributes | Expected assessment |
|---|---|---|
| RG21 | Printmaking at North Hall, accessible, $44 | Qualifies |
| RG22 | Drawing at North Hall, accessible, $45 | Outside the strict limit |
| RG23 | Ceramics at North Hall, accessible, $35 | Matches the explicitly excluded subject |
| RG24 | Printmaking at East Hall, accessible, $30 | Wrong venue |
| RG25 | Printmaking at North Hall, stair access only, $20 | Fails the accessibility requirement |
Review the rewritten text and any structured filters together. A passing rewrite can say “Accessible non-ceramics classes at North Hall on March 21, 2026, priced below $45.” A rewrite that turns “below $45” into “$45 or less” fails the intent check even if RG21 still ranks first. If a rewrite preserves all constraints but RG22 reaches the final results, inspect the price-filter implementation.
Add one turn and rerun the same five records. The user says “March 21 works. $45 is fine too.” Change the price operator from strictly below to at most $45. The eligible set is now RG21 and RG22. A rewriter that preserves the first request by leaving the old price operator in place fails this second case. The pair detects both dropping an active constraint and retaining a constraint the user changed.
Separate rewrite errors from retrieval errors
- Create cases for referents, date changes, exclusions, numeric boundaries and ambiguous requests. For each case, record the required entities and operators, acceptable evidence IDs and the expected response if clarification is needed.
- Save the exact query and filters that each candidate sends. Run a baseline and the candidate against the same index, retrieval settings and cutoff. Use a human-written reference rewrite as a diagnostic control.
- Mark intent preservation first. Then record whether the evidence reached the cutoff and whether an ineligible record passed through. Compare the same cases under each version.
- Inspect every case where the rewrite looks better but changes the task. A matching document can reach the cutoff by chance even when a query loses a constraint.
If the reference rewrite also misses RG21, inspect the corpus and retriever before changing the rewriter. If the reference finds RG21 and the model rewrite drops accessibility, fix the rewrite or its filter handoff. Preserve a known miss and a known passing case in your held-out evaluation dataset.
Related suites
Related reading
Sources
- 1. Can You Unpack That? Learning to Rewrite Questions-in-Context · EMNLP-IJCNLP 2019 · Paper · Sources checked
- 2. Query Rewriting in Retrieval-Augmented Large Language Models · EMNLP 2023 · Paper · Sources checked