One question can be phrased many ways, and each phrasing retrieves a slightly different set of chunks. Multi-query expansion generates several variants of the same question, runs each against the retriever, and merges the results, so a chunk that one phrasing misses is caught by another. LlamaIndex shows this as query rewriting: generate multiple search queries from a single input query, then execute all of them against a retriever and fuse the results.
What you need
- A question that retrieves poorly with a single phrasing
- A language model to generate the variants
- A fusion rule for merging ranked lists, such as reciprocal rank fusion
Step 1: Generate three to five variants
Ask the model to produce several search queries from the single input question, one per line, each asking the same thing in different words. Four variants is a reasonable starting point; more variants cost more searches.
Step 2: Run every variant and collect the chunks
Run each variant against the retriever with the same top-k, and collect all the returned chunks. Deduplicate by chunk ID, since the same chunk will appear under several variants.
Step 3: Fuse the lists and keep the top set
Merge the ranked lists with reciprocal rank fusion or a simple score sum, and keep the top results for the model. Check the merged set contains the right chunk before passing it on.
Worked example: synthetic multi-query expansion for one question
The table below is a synthetic example. It shows the expected result of expanding one question; no search was run.
| Variant | Top chunk found | In merged top 5? |
|---|---|---|
| Refund window days | Refund policy | Yes |
| How long to return | Refund policy | Yes |
| Money back period | Returns page | Yes |
| Cancel order refund | Cancellation policy | Yes |
Expected result (UNTESTED). the four variants together surface the refund policy chunk, which one phrasing alone missed. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Each variant is another search, so expansion multiplies retrieval cost and latency.
- Variants that drift in meaning pull in irrelevant chunks, so check the merged set before using it.
- Expansion helps retrieval coverage, not generation: the model still needs the right chunks to answer well.
- Deduplicate by chunk ID before fusing, or the same chunk counted twice will dominate the ranking.
