Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Query rewriting

Topic: Retrieval and RAGAlso called query expansion, query transformation

Definition

Using a model to turn a user's question into one or more better search queries before retrieval, to find more relevant results.

In more detail

User questions are often short, vague or depend on the conversation: 'what about the second one?' means nothing to a search index. A rewriting step resolves references from the chat history, fixes spelling, expands abbreviations, splits multi-part questions into several queries or generates alternative phrasings whose results are merged.

It adds a model call and some latency, and a bad rewrite can lose the user's meaning, so log original and rewritten queries side by side and include rewritten queries in your retrieval evals.

  • Agentic RAG

    Retrieval-augmented generation in which an agent decides when and how to search, often running several searches and refining queries.

  • Hybrid search

    Combining keyword search, such as BM25, with vector search and merging the results into one ranking, often with reciprocal rank fusion.

  • HyDE

    Hypothetical Document Embeddings: a model writes a fake answer to the query, and that answer's embedding is used to search for real documents.

  • Retrieval-augmented generation (RAG)

    Retrieving relevant documents and adding them to the prompt before the model generates an answer from them.

  • RAG fundamentals: retrieval before generation

    What RAG is and how retrieval-augmented generation works, when it beats long context or fine-tuning, and a minimal working pipeline in about 80 lines of Python.

    TutorialBeginner30 min

  • Retrieval-augmented generation

    Fetching relevant documents and adding them to a prompt to ground answers.

    SkillIntermediate

  • HyDE

    Hypothetical Document Embeddings: a model writes a fake answer to the query, and that answer's embedding is used to search for real documents.

    Glossary