Query expansion
Rewriting a user’s search into several fuller queries, with synonyms and related terms, before searching, so short or vague questions still find matches.
Users type two words; documents use other words. A model rewrites the query into variants (or a hypothetical answer to search with), each variant is searched, and the results are merged. It raises recall noticeably for vague questions, at the cost of an extra model call and some latency. Negative terms, things the user does not want, can be extracted the same way and used as filters.
Related terms
- Hybrid search: Combining keyword search (such as BM25) with vector search, so results match both exact terms and meaning.
- RAG (retrieval-augmented generation): Finding relevant documents first and putting them into the prompt, so the model answers from them.
- Vector database (pgvector and others): A database that stores embeddings and finds the nearest ones to a query vector quickly, which is the search step behind most RAG systems.
