liveBook · Manning

Query rewriting

As explained in Essential GraphRAG

Query rewriting is the transformation of a user query into a formulation that better matches the language and context of target documents.

Query rewriting transforms a user query into alternative phrasings that better match the terminology and context of target documents. It addresses a common vector-retrieval failure: semantically important documents may be missed when query and corpus language differ. section 3.0

Use query rewriting to improve retrieval when:

  • The query embedding does not align closely with documents containing the needed information. section 3.0
  • The user’s intent is expressed differently from the language used in information-rich documents. section 3.0
  • The retriever needs contextual summaries, paraphrases, or hypothetical questions alongside exact text. section 3.4

Two rewriting strategies

Hypothetical document retriever and step-back prompting reformulate the retrieval input so it better bridges user intent and document content. section 3.0 section 3.4

Figure 3.1 Query rewriting by using the step-back technique to increase the vector retrieval accuracy
figure

Shows how step-back rewriting can increase vector-retrieval accuracy. section 3.0

How Essential GraphRAG covers it

How deep it goes
Explains the terminology gap, names major strategies, and extends matching to summaries, paraphrases, and hypothetical questions.
Examples
Uses hypothetical document retrieval, step-back prompting, contextual summaries, paraphrases, and hypothetical question embeddings.
What it assumes
Assumes text embeddings and vector similarity search, while motivating rewriting through their incomplete retrieval accuracy and recall.
What you can do after
Apply it via hypothetical document retrieval or step-back prompting to improve document matching and retrieved-answer relevance.
How it connects
Connects query rewriting with text embeddings, vector similarity search, RAG, hypothetical document retrieval, step-back prompting, and parent document retrieval.

Also explained in

Compare how 5 books explain query rewriting →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Essential GraphRAG. The section links point to the parts of the book it draws on.