Skip to content
    AI engineering roles via the DiamantAI Collective.See open roles
    Query EnhancementRAG Techniques

    Query Transformations

    This code implements three query transformation techniques to enhance the retrieval process in Retrieval-Augmented Generation (RAG) systems: 1. Query Rewriting 2. Step-back Prompting 3. Sub-query Decomposition Each technique aims to improve the relevance and comprehensiveness of retrieved information by modifying or expanding the original query.

    RAG systems often face challenges in retrieving the most relevant information, especially when dealing with complex or ambiguous queries. These query transformation techniques address this issue by reformulating queries to better match relevant documents or to retrieve more comprehensive information.

    What you'll learn

    • 1
      Query Rewriting: Reformulates queries to be more specific and detailed.
    • 2
      Step-back Prompting: Generates broader queries for better context retrieval.
    • 3
      Sub-query Decomposition: Breaks down complex queries into simpler sub-queries.

    About this tutorial

    This hands-on Jupyter notebook is part of RAG Techniques, a free open-source repository by Nir Diamant covering rag techniques with runnable code examples and detailed explanations.

    Free and open-sourceRunnable Jupyter notebookActive community support
    Go deeper · Amazon Bestseller in Generative AI

    RAG Made Simple

    The book that extends this repo: 22 RAG techniques with the intuition behind each, side-by-side comparisons of when each wins (and quietly fails), and original illustrations.

    Get it on Amazon

    ⭐ 4.4 stars · 1,500+ readers · Kindle $9.99 · Paperback $24.99 · Free with Kindle Unlimited

    More Query Enhancement tutorials

    More from RAG Techniques