liveBook · Manning

Query generation

As explained in Retrieval Augmented Generation, The Foundational Ideas

A query generator is a component that transforms a user input into multiple alternative queries for information retrieval.

Query generation transforms one ambiguous user input into multiple retrieval queries. In RAG-Fusion, it widens coverage by targeting different facets or sub-intents instead of merely producing near-identical rephrasings. section 8.2 section 8.1

The generated queries run in parallel against the retrieval system. Their results provide a broader candidate set, which a later fusion step filters into a more complete context for answer generation. section 8.4 section 8.1

A useful generator decomposes an apparently simple request into distinct information needs:

  • “What is the best laptop for college?” can produce queries about durability, portability, budget, and battery life. section 8.2
  • Simple rephrasings often retrieve overlapping documents because they preserve the same average intent. section 8.2
  • Increasing query breadth differs from increasing one query’s depth: several queries with small k seek wider coverage before fusion restores precision. section 8.1

Prompt-driven generation

A prompt can ask an LLM to generate N alternative search queries, each targeting a different facet, sub-intent, or interpretation, with one query per line. The approach requires no specialized rewriting model, although dedicated models remain an option when generation becomes a larger concern. section 8.2

You are a search assistant. The user has asked: "{question}". Generate {N} alternative search queries that target different facets, sub-intents, or interpretations of this question. Each query should explore a distinct angle so that together they cover the full intent. Return one query per line, no numbering.
 

Use the supplied prompt template to generate distinct search perspectives rather than surface-level paraphrases. section 8.2

How Retrieval Augmented Generation, The Foundational Ideas covers it

How deep it goes
Explains facet decomposition, parallel retrieval, and fusion but stops short of detailed prompt optimization or model training.
Examples
Demonstrates laptop recommendations through durability, portability, price, and battery-life queries.
What it assumes
Assumes familiarity with retrieval and RAG, while teaching facet decomposition from an ordinary user query.
What you can do after
Apply it via an LLM prompt to generate facet-specific queries before parallel retrieval.
How it connects
Connects query generation with RAG-Fusion, retrieval, rank fusion, query rewriting, query decomposition, HyDE, and reranking.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Retrieval Augmented Generation, The Foundational Ideas. The section links point to the parts of the book it draws on.