Part 2 · Finding the evidence · Chapter 7
Asking the question better
In one sentence: the words a person uses to ask are seldom the best words to search with, so we rewrite the question into one or several search queries before we search.
Why you should care
A search engine sees only the query. If the query is a long, chatty paragraph, keyword search is pulled toward its filler words. If the query is three words, it may miss half of what the person wanted. Query rewriting is the cheapest step in a RAG pipeline to change, and it changes everything after it.
Words you need
- Information need
- What the person really wants to know. The query is only one attempt to say it.
- Query rewriting
- Turning the person's words into a query that searches better. Also called query reformulation.
- Query variant
- One of several different queries written for the same information need.
- Multi-query
- Searching with several variants and merging the results.
- Query expansion
- Adding words to a query, for example synonyms.
- Decomposition
- Splitting a question with several parts into one query per part.
- HyDE
- Hypothetical document embeddings. A language model writes a made-up answer, and the search uses that answer as the query.
- Deterministic
- Giving the same output every time for the same input. A rule is deterministic. A language model usually is not.
Core The idea
In TREC RAG 2026 the question is a narrative: a paragraph in which a person explains what they want to know and why. Here is one we made up in the same style.
This is a good statement of an information need and a poor keyword query. It has several parts: how the decision is made, what it costs, how long a repair lasts. It also has words that will match the wrong documents, such as “town”, “spring” and “last”.
There are four families of rewrites.
| Family | What it does | Good for | Risk |
|---|---|---|---|
| Shorten | Keep only the important words, or one sentence | Keyword search on long questions | Dropping the one word that mattered |
| Expand | Add synonyms and related words | Vocabulary mismatch | Drifting off topic |
| Decompose | One query for each part of the question | Questions with several parts | More searches, more off-target documents |
| Imagine the answer | A language model writes a possible answer and you search with it (HyDE) | Dense search, where an answer looks more like a document than a question does | The made-up answer can be wrong and lead the search the wrong way |
You do not have to pick one. Write several variants, search with each, and fuse the lists (Chapter 8). A document that several variants find is a safer bet than one that a single variant finds.
Rules or a language model?
A rewrite can be made by a simple rule, such as “take the first sentence”, or by a language model. Rules are free, instant and the same every time. A language model writes better queries and costs money, takes time, and may give a different rewrite on each run. A different rewrite means different documents and a different score, which makes experiments harder to repeat. Start with rules. Add a model when you can measure that it helps.
Watch and read
- VideoRAG from scratch: Part 5 (Query Translation, Multi Query) LangChain. A short lesson on searching with several rewrites of one question. Link checked 15 Nov 2026
- VideoLearn RAG From Scratch freeCodeCamp, taught by a LangChain engineer. The full course. Its query translation chapters cover multi-query, fusion, decomposition and HyDE. Link checked 15 Nov 2026
- PaperPrecise Zero-Shot Dense Retrieval without Relevance Labels Gao, Ma, Lin and Callan, 2022. The HyDE paper. Checked 15 Nov 2026
For the two videos we confirmed that the link opens and the title and channel match. We have not watched them through.
How we did it at TREC 2026
For every retrieval run in the RAG track we made seven variants of each narrative, all by rule. No language model wrote any query. This table shows what our code produces for the made-up narrative above.
| Variant | Rule | Query for the bridge narrative |
|---|---|---|
full | The whole narrative | All three sentences |
firstsent | First sentence | Our town's river bridge was closed last spring after inspectors found cracks. |
first2sent | First two sentences | The first sentence plus “I want to understand how engineers decide …” |
lastsent | Last sentence | What does each option cost, and how long does a repair last? |
firstlast | First and last sentence | The two sentences above, joined |
kw15 | Drop common words and repeats, keep the 15 longest words | inspectors engineers repaired replaced whether bridge closed spring cracks decide option repair river after found |
kw8 | The same, 8 longest words | inspectors engineers repaired replaced whether bridge closed spring |
Each variant went to BM25. The seven lists were fused with RRF. The run isu-bm25-rrf7 is exactly this and nothing more.
Why rules? Two reasons. First, the queries are the same every time we build a run, so two of our runs never differ because of a query. Second, we wanted one run with no language model in it at all, as a floor.
In RAGTIME the topic already comes in parts: a title and a longer problem statement. We sent both as separate queries (Chapter 11). In Change Detection one group of runs expands the question with words from example documents once those documents have arrived in the stream (Chapter 39).
What surprised us
kw8 in the table. It kept “whether” and “spring” and dropped “cracks”, “repair” and “cost”. The rule assumes that long words carry the topic. That is often true and sometimes badly wrong. The variant lastsent has the opposite problem here: “What does each option cost, and how long does a repair last?” does not contain the word “bridge”. Each variant alone is weak. We relied on fusion to cover for them, and we never measured each variant alone on the official judgments, so we cannot say which ones helped and which ones only added off-target documents. That would be a good student project.
Try it
- Write a narrative of three sentences about something you want to know. Produce the seven variants by hand with our rules.
- Which variant would you search with if you could use only one? Which one is clearly bad?
- Ask a language model for three search queries for the same narrative. Compare them with the rule-based ones. Ask again. Did you get the same three?
- Improve the keyword rule. One idea: rank words by how rare they are in the collection, which is the IDF from Chapter 5, and not by their length.
Check yourself
- Why is a narrative a poor keyword query?
- Name the four families of rewrites.
- Give one advantage of rule-based rewrites and one of rewrites by a language model.
- What is the risk of HyDE?
- Why does searching with several weak variants and fusing them often beat one variant?
Answers
- It is long, has several parts, and holds filler words that match off-target documents.
- Shorten, expand, decompose, and imagine the answer.
- Rules: free, fast and the same every time. A language model: better wording, and it can add words the person did not use.
- The made-up answer may be wrong, and the search then finds documents that agree with the mistake.
- The variants fail in different ways. A document found by several of them is more likely to be on topic.
Go deeper
- Pseudo-relevance feedback. Search once, assume the top documents are relevant, take words from them, and search again. RM3 is the classic method. It needs no language model.
- Generated expansions. Methods such as query2doc add a passage written by a language model to the query. They help keyword search too, because the passage holds the vocabulary of an answer.
- Step-back and decomposition prompts. A model can be asked for a more general question first, or for the sub-questions. Each one is a new search.
- Query performance prediction. Can you tell, before judging, that a variant is bad? Signals include how rare its words are and how much its results agree with the other variants.
- Repeatability. If a model writes your queries, save every query to a file and treat the file as data. Our rule-based variants need no such file, since the code makes the same queries again.
- Project idea. Take our seven rules and one public test collection. Score each variant alone, then every way of leaving one out of the fusion. Which variant can you remove at no cost?