RAG_Techniques Documentation

This repository showcases various advanced techniques for Retrieval-Augmented Generation (RAG) systems. Each technique has a detailed notebook tutorial.

29,976 stars Jupyter Notebook 2 files ยท ~20,684 tokens #agentic-rag#ai#embeddings#generative-ai#gpt#langchain#llama-index#llm
RAW Doc

RAG Techniques

A community-driven collection of 41 runnable Jupyter notebooks teaching Retrieval-Augmented Generation (RAG), from foundational retrieval and chunking through adaptive, agentic, graph-based and self-correcting systems. Each notebook is self-contained: the intuition behind one technique, a full implementation, and the paper or source it derives from. This is a teaching repository rather than a library, so there is no package to install and no public API. Authored by Nir Diamant. Licensed under a custom non-commercial license.

Core Documents

  • README: Overview, the full technique index, prerequisites and quick start.
  • CONTRIBUTING: How to add a technique and the pull request checklist.
  • AGENTS: Repository conventions for AI coding agents.
  • helper_functions.py: Shared loaders, splitters and retrieval utilities imported across notebooks.
  • LICENSE: Custom non-commercial license. Read before any commercial reuse.

Foundational RAG

Chunking and Indexing

Query Transformation

  • Query Transformations: Rewrite, expand and decompose a query before retrieving.
  • HyDE: Embed a hypothetical answer instead of the question, then retrieve against it.
  • HyPE: Move the hypothetical step to index time by embedding generated prompts.

Retrieval Strategies

Iterative and Self-Correcting RAG

  • Self-RAG: The model decides when to retrieve, and critiques its own retrieved evidence.
  • CRAG: Corrective RAG. Grade retrieved documents and fall back to web search when they are weak.
  • Reliable RAG: Validation and hallucination checks layered over a standard pipeline.
  • Retrieval with Feedback Loop: Learn from user feedback to improve future retrieval.
  • Agentic RAG: An agent plans, retrieves, reflects and retries across multiple steps.
  • MemoRAG: A global memory over the corpus that guides retrieval.

Graph RAG

Structured and Multimodal

Evaluation