Atlas

Roadmap

Retrieval Optimization

Query Transformation

Mar 30, 2026

In This Chapter

  • The main idea behind this part of the RAG system
  • The trade-offs that matter in practice
  • The interview framing that makes the topic easier to explain

What Query Transformation Means

Query transformation means rewriting or expanding the user's question before retrieval.

The intended goal is to preserve the user's intent while making it easier for the retriever to match against stored documents.

Why It Helps

Users often ask short, vague, or conversational questions.

Documents are usually written in more explicit language.

That mismatch hurts retrieval.

Examples:

  • user asks: How do refunds work for enterprise?
  • docs say: Enterprise plans are eligible for a 30-day money-back guarantee

The intent matches, but the wording does not fully match.

Common Forms

Query transformation usually takes one of these forms:

  • rewriting: make the query clearer
  • expansion: add likely related terms
  • decomposition: split one question into smaller retrieval steps

The core idea is always the same: improve retrieval input quality.

These forms are not equally useful in every system:

  • rewriting fits simple FAQ-style retrieval
  • expansion can help recall but adds more noise risk
  • decomposition is more useful for multi-hop or agentic workflows

Example

original query:
"How do refunds work for enterprise?"

rewritten query:
"What is the refund policy for enterprise plans?"
text

The rewritten version is more aligned with typical document language.

Tradeoffs

Query transformation can improve recall, but it also introduces risk.

Common failure modes:

  • the rewrite changes the meaning
  • the expanded query adds noise
  • the system becomes harder to debug

That is why it should be used carefully, especially for high-stakes domains.

When It Is Worth Using

Query transformation is most useful when the main problem is query-document mismatch.

That usually means:

  • users ask in vague or conversational language
  • documents use formal terminology
  • retrieval is close but inconsistent

If retrieval is failing because chunking, embeddings, or filters are weak, query transformation is usually not the first fix.

When Not to Use It First

It should not be treated as the default answer to weak retrieval.

If the real failure is:

  • poor chunking
  • weak embeddings
  • broken metadata filtering

then rewriting the query only hides the upstream problem.

Where It Fits

A common pipeline is:

user query
-> transform query
-> retrieve candidates
-> rerank
-> generate answer
text

It is an optimization layer, not a replacement for strong chunking, embeddings, and filters.

Key Questions

Q: What is query transformation in RAG?

Query transformation means rewriting, expanding, or restructuring the user's question before retrieval so it matches the document space more effectively. It is used to improve retrieval quality without changing the user's underlying intent.

Q: Why does query transformation help retrieval?

Because user questions are often conversational, incomplete, or phrased differently from the source documents. A transformed query can align better with document terminology, which improves recall.

Q: What is the main risk of query transformation?

The main risk is semantic drift. If the transformed query changes the intent or adds misleading terms, retrieval quality can get worse instead of better.

Q: When is query transformation the right optimization, and when is it not?

It is the right optimization when the main issue is mismatch between user phrasing and document phrasing. It is not the right first move when retrieval is weak because of chunking, embeddings, or filtering problems. In those cases, transforming the query treats the symptom rather than the cause.