A community-driven hub of 42+ runnable notebooks covering RAG techniques from foundational to cutting-edge - the intuition, the code, and the references to build more accurate, context-rich retrieval systems. Use it as a repeatable review, validation or hardening pass.
Advanced RAG Techniques π
Snapshot 2026-08-04 16:17:00 UTC Β· version 1
Research document
Advanced RAG Techniques π
A community-driven hub of 42+ runnable notebooks covering RAG techniques from foundational to cutting-edge - the intuition, the code, and the references to build more accurate, context-rich retrieval systems. Use it as a repeatable review, validation or hardening pass.
Editorial note: curated source snapshot published by Collider.club under the MIT License. Source attribution is preserved in the front matter.
Source snapshot
Advanced RAG Techniques π
Elevating Your Retrieval-Augmented Generation Systems
A community-driven hub of 42+ runnable notebooks covering RAG techniques from foundational to cutting-edge - the intuition, the code, and the references to build more accurate, context-rich retrieval systems.
π From RAG prototypes to production
Prompt to Production - my full course on building software with AI the way professionals do: the methods and paradigms behind reliable, efficient, modular production systems, taught systematically. 17 modules, each pairing a video lecture with a hands-on lab, from your first structured prompt to a working production system.
π Try a full module, free
| π¬ 7-minute video lecture |
π οΈ Hands-on tutorial |
π€ AI assistant inside Claude Code |
One npm install adds the module's AI assistant to your Claude Code, and it guides you through the tutorial as you build.
Sponsors β€οΈ
We gratefully acknowledge the organizations and individuals who have made significant contributions to this project.
Company Sponsors
Individual Sponsors
π« Stay Updated!
| π Cutting-edge Updates |
π‘ Expert Insights |
π― Top 0.1% Content |
Join over 50,000 AI enthusiasts getting unique cutting-edge insights and free tutorials! Plus, subscribers get exclusive early access and special 33% discounts to my book and the upcoming RAG Techniques course!
π¬ Prefer video?
I break these ideas down into short, one-idea-per-episode explainers on YouTube.
|
RAG Explained: Why AI Gets Your Own Documents Wrong why chunks overlap, what "meaning space" is, and where simple RAG breaks down |
How Do You Search a Spreadsheet by Meaning? turn each row into one labelled line and search the table by meaning |
How Do You Know Your RAG Answer Isn't Made Up? three checkpoints that catch a bad chunk on the way in and an unsupported claim on the way out |
Why Does RAG Return a Paragraph When You Asked for One Fact? why a paragraph's embedding is a blend that points at nothing in particular |
Introduction
Retrieval-Augmented Generation (RAG) is revolutionizing the way we combine information retrieval with generative AI. This repository showcases a curated collection of advanced techniques designed to supercharge your RAG systems, enabling them to deliver more accurate, contextually relevant, and comprehensive responses.
Our goal is to provide a valuable resource for researchers and practitioners looking to push the boundaries of what's possible with RAG. By fostering a collaborative environment, we aim to accelerate innovation in this exciting field.
π Go deeper: the book
RAG Made Simple - the 400-page visual companion to this repo. Amazon Bestseller in Generative AI Β· 1,500+ readers Β· β 4.6
Get it - 33% off with code RAGKING β Β· Read Chapter 1 free
Related Projects
π Agents Towards Production - code-first tutorials for shipping production-grade GenAI agents, prototype to scale.
π€ GenAI Agents - a broad collection of AI agent implementations and tutorials.
ποΈ Prompt Engineering Techniques - prompting strategies from basics to advanced.
π§ Agent Memory Techniques - 30 notebooks on agent memory: vector stores, knowledge graphs, Mem0, MemGPT, Zep, Graphiti.
Join the community
Contributions make this better - propose ideas, share techniques, or give feedback via CONTRIBUTING.md.
r/EducationalAI Β· Discord Β· LinkedIn
Key Features
- π§ State-of-the-art RAG enhancements
- π Comprehensive documentation for each technique
- π οΈ Practical implementation guidelines
- π Regular updates with the latest advancements
Advanced Techniques
Explore our extensive list of cutting-edge RAG techniques:
Recently added: MemoRAG (memory-augmented retrieval), End-to-End RAG Evaluation, Open-RAG-Eval, JSON RAG. 42 notebooks and growing.
π± Foundational RAG Techniques
Simple RAG π±
- π¬ Watch it explained: RAG Explained: Why AI Gets Your Own Documents Wrong β the intuition behind this notebook in 7 minutes: why chunks overlap, what "meaning space" actually is, and where simple RAG breaks down.
- LangChain:
- LlamaIndex:
- Runnable Script
Overview π
Introducing basic RAG techniques ideal for newcomers.
Implementation π οΈ
Start with basic retrieval queries and integrate incremental learning mechanisms.
Simple RAG using a CSV file π§©
- π¬ Watch it explained: How Do You Search a Spreadsheet by Meaning? β turn each row into one labelled line and search the table by meaning; ask which customers are "in South American countries" and the Chile record comes back even though those words never appear.
- LangChain:
- LlamaIndex:
Overview π
Introducing basic RAG using CSV files.
Implementation π οΈ
This uses CSV files to create basic retrieval and integrates with openai to create question and answering system.
-
- π¬ Watch it explained: How Do You Know Your RAG Answer Isn't Made Up? β the three checkpoints that catch a bad chunk on the way in and an unsupported claim on the way out, plus the source highlighting that lets a skeptical reader verify the answer themselves.
Overview π
Enhances the Simple RAG by adding validation and refinement to ensure the accuracy and relevance of retrieved information.
Implementation π οΈ
Check for retrieved document relevancy and highlight the segment of docs used for answering.
Choose Chunk Size π
- LangChain:
- Runnable Script
Overview π
Selecting an appropriate fixed size for text chunks to balance context preservation and retrieval efficiency.
Implementation π οΈ
Experiment with different chunk sizes to find the optimal balance between preserving context and maintaining retrieval speed for your specific use case.
Proposition Chunking βοΈβπ₯:
- π¬ Watch it explained: Why Does RAG Return a Paragraph When You Asked for One Fact? β why a paragraph's embedding is a blend that points at nothing in particular, how a language model rewrites the chunk as single self-contained facts, and what the quality gate throws away.
Overview π
Breaking down the text into concise, complete, meaningful sentences allowing for better control and handling of specific queries (especially extracting knowledge).
Implementation π οΈ
- πͺ Proposition Generation: The LLM is used in conjunction with a custom prompt to generate factual statements from the document chunks.
- β Quality Checking: The generated propositions are passed through a grading system that evaluates accuracy, clarity, completeness, and conciseness.
-
Overview π
RAG with JSON documents is a method of using JSON files to create a retrieval and question answering system.
Implementation π οΈ
- π Data Loading & Extraction: JSON data with multiple fields per entry is loaded, and most relevant text fields are combined to generate an embedding.
- π Retrieval: The system retrieves the most relevant JSON entries based on the user's query.
Additional Resources π
- The Propositions Method: Enhancing Information Retrieval for AI Systems - A comprehensive blog post exploring the benefits and implementation of proposition chunking in RAG systems.
π Query Enhancement
Query Transformations π
- LangChain:
- Runnable Script
Overview π
Modifying and expanding queries to improve retrieval effectiveness.
Implementation π οΈ
- βοΈ Query Rewriting: Reformulate queries to improve retrieval.
- π Step-back Prompting: Generate broader queries for better context retrieval.
- π§© Sub-query Decomposition: Break complex queries into simpler sub-queries.
Hypothetical Questions (HyDE Approach) β
- LangChain:
- Runnable Script
Overview π
Generating hypothetical questions to improve alignment between queries and data.
Implementation π οΈ
Create hypothetical questions that point to relevant locations in the data, enhancing query-data matching.
Additional Resources π
- HyDE: Exploring Hypothetical Document Embeddings for AI Retrieval - A short blog post explaining this method clearly.
π Context and Content Enrichment
Hypothetical Prompt Embeddings (HyPE) βπ
- LangChain:
- Runnable Script
Overview π
HyPE (Hypothetical Prompt Embeddings) is an enhancement to traditional RAG retrieval that precomputes hypothetical prompts at the indexing stage, but inseting the chunk in their place. This transforms retrieval into a question-question matching task. This avoids the need for runtime synthetic answer generation, reducing inference-time computational overhead while improving retrieval alignment.
Implementation π οΈ
- π Precomputed Questions: Instead of embedding document chunks, HyPE generates multiple hypothetical queries per chunk at indexing time.
- π Question-Question Matching: User queries are matched against stored hypothetical questions, leading to better retrieval alignment.
- β‘ No Runtime Overhead: Unlike HyDE, HyPE does not require LLM calls at query time, making retrieval faster and cheaper.
- π Higher Precision & Recall: Improves retrieval context precision by up to 42 percentage points and claim recall by up to 45 percentage points.
Additional Resources π
- Preprint: Hypothetical Prompt Embeddings (HyPE) - Research paper detailing the method, evaluation, and benchmarks.
Contextual Chunk Headers :label::
Overview π
Contextual chunk headers (CCH) is a method of creating document-level and section-level context, and prepending those chunk headers to the chunks prior to embedding them.
Implementation π οΈ
Create a chunk header that includes context about the document and/or section of the document, and prepend that to each chunk in order to improve the retrieval accuracy.
Additional Resources π
dsRAG: open-source retrieval engine that implements this technique (and a few other advanced RAG techniques)
Relevant Segment Extraction π§©:
Overview π
Relevant segment extraction (RSE) is a method of dynamically constructing multi-chunk segments of text that are relevant to a given query.
Implementation π οΈ
Perform a retrieval post-processing step that analyzes the most relevant chunks and identifies longer multi-chunk segments to provide more complete context to the LLM.
Context Enrichment Techniques π
- LangChain:
- LlamaIndex:
- Runnable Script
Overview π
Enhancing retrieval accuracy by embedding individual sentences and extending context to neighboring sentences.
Implementation π οΈ
Retrieve the most relevant sentence while also accessing the sentences before and after it in the original text.
- Semantic Chunking π§
- LangChain:
- Runnable Script
Overview π
Dividing documents based on semantic coherence rather than fixed sizes.
Implementation π οΈ
Use NLP techniques to identify topic boundaries or coherent sections within documents for more meaningful retrieval units.
Additional Resources π
- Semantic Chunking: Improving AI Information Retrieval - A comprehensive blog post exploring the benefits and implementation of semantic chunking in RAG systems.
- Contextual Compression ποΈ
- LangChain:
- Runnable Script
Overview π
Compressing retrieved information while preserving query-relevant content.
Implementation π οΈ
Use an LLM to compress or summarize retrieved chunks, preserving key information relevant to the query.
- Document Augmentation through Question Generation for Enhanced Retrieval
- LangChain:
- Runnable Script
Overview π
This implementation demonstrates a text augmentation technique that leverages additional question generation to improve document retrieval within a vector database. By generating and incorporating various questions related to each text fragment, the system enhances the standard retrieval process, thus increasing the likelihood of finding relevant documents that can be utilized as context for generative question answering.
Implementation π οΈ
Use an LLM to augment text dataset with all possible questions that can be asked to each document.
π Advanced Retrieval Methods
Fusion Retrieval π
- LangChain:
- LlamaIndex:
- Runnable Script
Overview π
Optimizing search results by combining different retrieval methods.
Implementation π οΈ
Combine keyword-based search with vector-based search for more comprehensive and accurate retrieval.
Intelligent Reranking π
- LangChain:
- LlamaIndex:
- Runnable Script
Overview π
Applying advanced scoring mechanisms to improve the relevance ranking of retrieved results.
Implementation π οΈ
- π§ LLM-based Scoring: Use a language model to score the relevance of each retrieved chunk.
- π Cross-Encoder Models: Re-encode both the query and retrieved documents jointly for similarity scoring.
- π Metadata-enhanced Ranking: Incorporate metadata into the scoring process for more nuanced ranking.
Additional Resources π
- Relevance Revolution: How Re-ranking Transforms RAG Systems - A comprehensive blog post exploring the power of re-ranking in enhancing RAG system performance.
Multi-faceted Filtering π
Overview π
Applying various filtering techniques to refine and improve the quality of retrieved results.
Implementation π οΈ
- π·οΈ Metadata Filtering: Apply filters based on attributes like date, source, author, or document type.
- π Similarity Thresholds: Set thresholds for relevance scores to keep only the most pertinent results.
- π Content Filtering: Remove results that don't match specific content criteria or essential keywords.
- π Diversity Filtering: Ensure result diversity by filtering out near-duplicate entries.
Hierarchical Indices ποΈ
- LangChain:
- Runnable Script
Overview π
Creating a multi-tiered system for efficient information navigation and retrieval.
Implementation π οΈ
Implement a two-tiered system for document summaries and detailed chunks, both containing metadata pointing to the same location in the data.
Additional Resources π
- Hierarchical Indices: Enhancing RAG Systems - A comprehensive blog post exploring the power of hierarchical indices in enhancing RAG system performance.
Dartboard Retrieval π―
Overview π
Optimizing over Relevant Information Gain in Retrieval
Implementation π οΈ
- Combine both relevance and diversity into a single scoring function and directly optimize for it.
- POC showing plain simple RAG underperforming when the database is dense, and the dartboard retrieval outperforming it.
Multi-modal Retrieval π½οΈ
Overview π
Extending RAG capabilities to handle diverse data types for richer responses.
Implementation π οΈ
- Multi-model RAG with Multimedia Captioning: - Caption and store all the other multimedia data like pdfs, ppts, etc., with text data in vector store and retrieve them together.
- Multi-model RAG with Colpali: - Instead of captioning convert all the data into image, then find the most relevant images and pass them to a vision large language model.
π Iterative and Adaptive Techniques
Retrieval with Feedback Loops π
- LangChain:
- Runnable Script
Overview π
Implementing mechanisms to learn from user interactions and improve future retrievals.
Implementation π οΈ
Collect and utilize user feedback on the relevance and quality of retrieved documents and generated responses to fine-tune retrieval and ranking models.
Adaptive Retrieval π―
- LangChain:
- Runnable Script
Overview π
Dynamically adjusting retrieval strategies based on query types and user contexts.
Implementation π οΈ
Classify queries into different categories and use tailored retrieval strategies for each, considering user context and preferences.
π Evaluation
DeepEval Evaluation: | Comprehensive RAG system evaluation |
Overview π
Performing evaluations Retrieval-Augmented Generation systems, by covering several metrics and creating test cases.
Implementation π οΈ
Use the
deepevallibrary to conduct test cases on correctness, faithfulness and contextual relevancy of RAG systems.GroUSE Evaluation: | Contextually-grounded LLM evaluation |
Overview π
Evaluate the final stage of Retrieval-Augmented Generation using metrics of the GroUSE framework and meta-evaluate your custom LLM judge on GroUSE unit tests.
Implementation π οΈ
Use the
grousepackage to evaluate contextually-grounded LLM generations with GPT-4 on the 6 metrics of the GroUSE framework and use unit tests to evaluate a custom Llama 3.1 405B evaluator.End-to-End RAG Evaluation: | Complete evaluation pipeline |
Overview π
A comprehensive tutorial covering evaluation criteria selection, LLM-as-a-judge metrics, RAGAS integration, and full evaluation pipeline assembly.
Implementation π οΈ
- Build custom metrics for completeness, relevance, and hallucination detection using the RAG-12000 dataset.
Open-RAG-Eval: | Open-source RAG evaluation |
Overview π
Demonstrates the open-rag-eval library for evaluation using UMBRELA scoring, AutoNuggetizer, and citation/hallucination detection.
Implementation π οΈ
- Evaluate RAG pipelines using multiple open-source metrics against the FIQA financial dataset.
π§ Memory-Augmented Retrieval
MemoRAG: | Memory-augmented retrieval |
Overview π
A from-scratch implementation of MemoRAG - a memory-augmented RAG system with key-value pair extraction, surrogate query generation, and multi-query retrieval.
Implementation π οΈ
- Build a complete MemoryStore with FAISS-based retrieval, surrogate queries, and comparison evaluation against standard RAG.
π¬ Explainability and Transparency
- Explainable Retrieval π
This HTML preview is truncated for page performance. The canonical Markdown file contains the complete snapshot.
Why MDRSS assigned this score
- evidence comes from multiple domains
- some evidence URLs look like primary-source hosts
Evidence (4)
concept:rag-and-knowledge-systemsorg:collider-club Discussion 0
Sign in to join the discussion.