Query Rewriting
Improving a search query before RAG to find more relevant documents.
Why is it needed
Users rarely formulate questions perfectly. They might ask:
"What about the warranty?"
Without context, it's unclear which product is being referred to. If vector search is launched immediately, the result will be weak.
How it works
flowchart LR
A[Question] --> B[LLM rephrases]
B --> C[Clear query]
C --> D[Search]
D --> E[Answer]
Techniques
- Simple rephrasing — a complete and unambiguous question;
- Multi-query — several query variants;
- HyDE — hypothetical answer first, then similar search;
- Query Expansion — adding synonyms.