Skip to main content

Query Reformulation

Overview

In a multi-turn conversation, users often ask follow-up questions that reference previous context:
“How does the Builder pattern work?” “And for Bedrock?”
The second question makes no sense to the vector store in isolation. Query reformulation solves this by rewriting the question into a self-contained query before retrieval:
“How does the Builder pattern work with AWS Bedrock in RAGLight?”
This dramatically improves retrieval accuracy in conversational RAG.

How it works

When reformulation=True, the pipeline adds a reformulate step before retrieval:
The same LLM configured for generation is used for reformulation. If there is no conversation history yet (first turn), the question is passed through unchanged — no extra LLM call is made. The reformulated question is logged at INFO level so you can inspect what the model produced.

Configuration

Reformulation is enabled by default. You can disable it explicitly if needed.

Via RAGConfig (simple API)

Via the Builder API


When reformulation helps

When to disable it


Summary

  • Reformulation rewrites follow-up questions into standalone queries
  • Enabled by default in RAGConfig and Builder.build_rag()
  • Uses the same LLM as generation — no extra model needed
  • No-op on the first turn (no history)
  • Disable via reformulation=False