กลับไปหน้า Tools

GetNotes Tools

NirDiamant/RAG_Techniques

Tool นี้คืออะไร

Repository นี้รวบรวมโน้ตบุ๊กกว่า 42 รายการที่สามารถรันได้ ครอบคลุมเทคนิค RAG ตั้งแต่พื้นฐานจนถึงขั้นสูง พร้อมโค้ดและข้อมูลอ้างอิง เพื่อช่วยนักพัฒนาสร้างระบบ RAG ที่แม่นยำและมีบริบทครบถ้วนยิ่งขึ้น

ข้อมูลโปรเจกต์

ดาว

28.9K

Forks

3.5K

License

ไม่ระบุ

อัปเดต GitHub ล่าสุด

26 ก.ค. 2569

เพิ่มใน GetNotes

14 ก.ค. 2569

Repository

NirDiamant/RAG_Techniques

เหมาะกับงาน

AI และ Agentsข้อมูลและ Analytics

เหมาะกับอาชีพ

Ecosystem

Jupyter Notebook

แปลและเรียบเรียงโดย AI

เนื้อหาฉบับภาษาไทย

ใช้อ่านเพื่อทำความเข้าใจเบื้องต้น โปรดตรวจสอบรายละเอียดสำคัญกับเอกสารต้นฉบับด้านล่าง

เทคนิค RAG ขั้นสูง 🚀

ยกระดับระบบ Retrieval-Augmented Generation ของคุณ

ศูนย์รวมโน้ตบุ๊กที่สามารถรันได้กว่า 42 รายการ ซึ่งครอบคลุมเทคนิค RAG ตั้งแต่พื้นฐานไปจนถึงล้ำสมัย ทั้งแนวคิด โค้ด และข้อมูลอ้างอิง เพื่อสร้างระบบการดึงข้อมูลที่แม่นยำและมีบริบทครบถ้วนยิ่งขึ้น


PRs Welcome LinkedIn Twitter Reddit Discord Sponsor

ผู้สนับสนุน ❤️

เราขอขอบคุณองค์กรและบุคคลที่ได้ให้การสนับสนุนที่สำคัญแก่โปรเจกต์นี้

ผู้สนับสนุนองค์กร

ผู้สนับสนุนรายบุคคล

📫 ติดตามข่าวสาร!

Subscribe to DiamantAI Newsletter

เข้าร่วมกับผู้ที่ชื่นชอบ AI กว่า 50,000 คน เพื่อรับข้อมูลเชิงลึกที่ล้ำสมัยและบทเรียนฟรีที่ไม่เหมือนใคร! นอกจากนี้ สมาชิกยังได้รับสิทธิ์เข้าถึงก่อนใครและส่วนลดพิเศษ 33% สำหรับหนังสือของฉันและคอร์ส RAG Techniques ที่กำลังจะมาถึง!

DiamantAI's newsletter

บทนำ

Retrieval-Augmented Generation (RAG) กำลังปฏิวัติวิธีการรวมการดึงข้อมูลเข้ากับ AI เชิงสร้างสรรค์ Repository นี้รวบรวมเทคนิคขั้นสูงที่คัดสรรมาอย่างดี ซึ่งออกแบบมาเพื่อเพิ่มประสิทธิภาพระบบ RAG ของคุณ ทำให้สามารถให้คำตอบที่แม่นยำ มีบริบทที่เกี่ยวข้อง และครอบคลุมมากยิ่งขึ้น

เป้าหมายของเราคือการจัดหาแหล่งข้อมูลอันทรงคุณค่าสำหรับนักวิจัยและผู้ปฏิบัติงานที่ต้องการผลักดันขีดจำกัดของ RAG ด้วยการส่งเสริมสภาพแวดล้อมการทำงานร่วมกัน เรามุ่งมั่นที่จะเร่งสร้างนวัตกรรมในสาขาที่น่าตื่นเต้นนี้

📖 เจาะลึกยิ่งขึ้น: หนังสือ

RAG Made Simple - คู่มือภาพประกอบ 400 หน้าสำหรับ repo นี้ หนังสือขายดีของ Amazon ในหมวด Generative AI · ผู้อ่านกว่า 1,500 คน · ⭐ 4.6

รับเลย - ลด 33% ด้วยโค้ด RAGKING → · อ่านบทที่ 1 ฟรี

โปรเจกต์ที่เกี่ยวข้อง

🚀 Agents Towards Production - บทเรียนที่เน้นโค้ดเป็นหลักสำหรับการนำ GenAI agents ระดับโปรดักชันไปใช้งานจริง ตั้งแต่การสร้างต้นแบบจนถึงการขยายขนาด

🤖 GenAI Agents - ชุดรวมการใช้งานและบทเรียนเกี่ยวกับ AI agent ที่หลากหลาย

🖋️ Prompt Engineering Techniques - กลยุทธ์การพร้อมต์ตั้งแต่พื้นฐานจนถึงขั้นสูง

🧠 Agent Memory Techniques - โน้ตบุ๊ก 30 รายการเกี่ยวกับหน่วยความจำของเอเจนต์: vector stores, knowledge graphs, Mem0, MemGPT, Zep, Graphiti

เข้าร่วมชุมชน

การมีส่วนร่วมทำให้สิ่งนี้ดียิ่งขึ้น - เสนอแนวคิด แบ่งปันเทคนิค หรือให้ข้อเสนอแนะผ่าน CONTRIBUTING.md

r/EducationalAI · Discord · LinkedIn

คุณสมบัติหลัก

  • 🧠 การปรับปรุง RAG ที่ล้ำสมัย
  • 📚 เอกสารประกอบที่ครอบคลุมสำหรับแต่ละเทคนิค
  • 🛠️ แนวทางการนำไปใช้งานจริง
  • 🌟 อัปเดตเป็นประจำด้วยความก้าวหน้าล่าสุด

เทคนิคขั้นสูง

สำรวจรายการเทคนิค RAG ล้ำสมัยที่ครอบคลุมของเรา:

เพิ่มล่าสุด: MemoRAG (memory-augmented retrieval), End-to-End RAG Evaluation, Open-RAG-Eval, JSON RAG. 42 โน้ตบุ๊ก และเพิ่มขึ้นเรื่อยๆ

#หมวดหมู่เทคนิคดู
1พื้นฐาน 🌱Basic RAG
2พื้นฐาน 🌱RAG with CSV Files
3พื้นฐาน 🌱Reliable RAG
4พื้นฐาน 🌱Optimizing Chunk Sizes
5พื้นฐาน 🌱Proposition Chunking
6การปรับปรุง Query 🔍Query Transformations
7การปรับปรุง Query 🔍HyDE (Hypothetical Document Embedding)
8การปรับปรุง Query 🔍HyPE (Hypothetical Prompt Embedding)
9การเสริมบริบท 📚Contextual Chunk Headers
10การเสริมบริบท 📚Relevant Segment Extraction
11การเสริมบริบท 📚Context Window Enhancement
12การเสริมบริบท 📚Semantic Chunking
13การเสริมบริบท 📚Contextual Compression
14การเสริมบริบท 📚Document Augmentation
15การดึงข้อมูลขั้นสูง 🚀Fusion Retrieval
16การดึงข้อมูลขั้นสูง 🚀Reranking
17การดึงข้อมูลขั้นสูง 🚀Multi-faceted Filtering
18การดึงข้อมูลขั้นสูง 🚀Hierarchical Indices
19การดึงข้อมูลขั้นสูง 🚀Dartboard Retrieval
20การดึงข้อมูลขั้นสูง 🚀Multi-modal RAG with Captioning
21เทคนิคแบบวนซ้ำ 🔁Retrieval with Feedback Loop [](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main

🌱 เทคนิค RAG พื้นฐาน

  1. 1Simple RAG 🌱- **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_rag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_rag.ipynb) - **LlamaIndex**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_rag_with_llamaindex.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_rag_with_llamaindex.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/simple_rag.py)** ภาพรวม 🔎แนะนำเทคนิค RAG พื้นฐานที่เหมาะสำหรับผู้เริ่มต้น การนำไปใช้งาน 🛠️เริ่มต้นด้วยการสืบค้นข้อมูลพื้นฐานและผสานรวมกลไกการเรียนรู้แบบเพิ่มพูน
  2. 2Simple RAG โดยใช้ไฟล์ CSV 🧩- **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_csv_rag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_csv_rag.ipynb) - **LlamaIndex**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_csv_rag_with_llamaindex.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_csv_rag_with_llamaindex.ipynb) ภาพรวม 🔎แนะนำ RAG พื้นฐานโดยใช้ไฟล์ CSV การนำไปใช้งาน 🛠️ใช้วิธีนี้เพื่อสร้างการสืบค้นข้อมูลพื้นฐานจากไฟล์ CSV และผสานรวมกับ OpenAI เพื่อสร้างระบบถาม-ตอบ
  3. 3**Reliable RAG 🏷️**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/reliable_rag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/reliable_rag.ipynb) ภาพรวม 🔎ปรับปรุง Simple RAG โดยเพิ่มการตรวจสอบความถูกต้องและการปรับแต่งเพื่อให้แน่ใจว่าข้อมูลที่ดึงมามีความแม่นยำและเกี่ยวข้อง การนำไปใช้งาน 🛠️ตรวจสอบความเกี่ยวข้องของเอกสารที่ดึงมาและเน้นส่วนของเอกสารที่ใช้ในการตอบคำถาม
  4. 4Choose Chunk Size 📏- **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/choose_chunk_size.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/choose_chunk_size.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/choose_chunk_size.py)** ภาพรวม 🔎การเลือกขนาดที่เหมาะสมสำหรับส่วนข้อความ (text chunks) เพื่อรักษาสมดุลระหว่างการเก็บรักษาบริบทและการดึงข้อมูลที่มีประสิทธิภาพ การนำไปใช้งาน 🛠️ทดลองใช้ขนาด chunk ที่แตกต่างกันเพื่อหาสมดุลที่เหมาะสมที่สุดระหว่างการรักษาบริบทและการรักษาความเร็วในการดึงข้อมูลสำหรับกรณีการใช้งานเฉพาะของคุณ
  5. 5**Proposition Chunking ⛓️‍💥**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/proposition_chunking.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/proposition_chunking.ipynb) ภาพรวม 🔎การแบ่งข้อความเป็นประโยคที่กระชับ สมบูรณ์ และมีความหมาย เพื่อให้สามารถควบคุมและจัดการการสืบค้นเฉพาะเจาะจงได้ดีขึ้น (โดยเฉพาะการสกัดความรู้) การนำไปใช้งาน 🛠️- 💪 **การสร้างข้อเสนอ (Proposition Generation):** ใช้ LLM ร่วมกับ prompt ที่กำหนดเองเพื่อสร้างข้อความที่เป็นข้อเท็จจริงจากส่วนของเอกสาร - ✅ **การตรวจสอบคุณภาพ (Quality Checking):** ข้อเสนอที่สร้างขึ้นจะถูกส่งผ่านระบบการให้คะแนนที่ประเมินความถูกต้อง ความชัดเจน ความสมบูรณ์ และความกระชับ
  6. 6**[Simple RAG with JSON](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/json_rag.ipynb)** ภาพรวม 🔎RAG กับเอกสาร JSON เป็นวิธีการใช้ไฟล์ JSON เพื่อสร้างระบบการสืบค้นและถาม-ตอบ การนำไปใช้งาน 🛠️- 📄 **การโหลดและสกัดข้อมูล:** ข้อมูล JSON ที่มีหลายฟิลด์ต่อหนึ่งรายการจะถูกโหลด และฟิลด์ข้อความที่เกี่ยวข้องมากที่สุดจะถูกรวมเข้าด้วยกันเพื่อสร้าง embedding - 🔍 **การสืบค้น:** ระบบจะดึงรายการ JSON ที่เกี่ยวข้องมากที่สุดตามคำถามของผู้ใช้

แหล่งข้อมูลเพิ่มเติม 📚

🔍 การปรับปรุงการสืบค้น (Query Enhancement)

  1. 1Query Transformations 🔄- **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/query_transformations.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/query_transformations.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/query_transformations.py)** ภาพรวม 🔎การปรับเปลี่ยนและขยายคำถามเพื่อปรับปรุงประสิทธิภาพการสืบค้น การนำไปใช้งาน 🛠️- ✍️ **การเขียนคำถามใหม่ (Query Rewriting):** ปรับปรุงคำถามเพื่อเพิ่มประสิทธิภาพการสืบค้น - 🔙 **การใช้ Step-back Prompting:** สร้างคำถามที่กว้างขึ้นเพื่อการดึงบริบทที่ดีขึ้น - 🧩 **การแยกคำถามย่อย (Sub-query Decomposition):** แบ่งคำถามที่ซับซ้อนออกเป็นคำถามย่อยที่ง่ายขึ้น
  2. 2Hypothetical Questions (HyDE Approach) ❓- **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/all_rag_techniques/HyDe_Hypothetical_Document_Embedding.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/HyDe_Hypothetical_Document_Embedding.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/HyDe_Hypothetical_Document_Embedding.py)** ภาพรวม 🔎การสร้างคำถามสมมติเพื่อปรับปรุงความสอดคล้องระหว่างคำถามและข้อมูล การนำไปใช้งาน 🛠️สร้างคำถามสมมติที่ชี้ไปยังตำแหน่งที่เกี่ยวข้องในข้อมูล ซึ่งช่วยเพิ่มประสิทธิภาพในการจับคู่คำถามกับข้อมูล แหล่งข้อมูลเพิ่มเติม 📚- **[HyDE: Exploring Hypothetical Document Embeddings for AI Retrieval](https://newsletter.diamant-ai.com/p/hyde-exploring-hypothetical-document?r=336pe4&utm_campaign=post&utm_medium=web)** - บล็อกโพสต์สั้นๆ ที่อธิบายวิธีการนี้อย่างชัดเจน

📚 การเสริมบริบทและเนื้อหา (Context and Content Enrichment)

  1. 1Hypothetical Prompt Embeddings (HyPE) ❓🚀- **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/HyPE_Hypothetical_Prompt_Embedding.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_ra

เอกสารโปรเจกต์

อ่านเอกสารต้นฉบับ

README วิธีติดตั้ง วิธีใช้งาน และข้อกำหนดจาก repository ต้นฉบับ

ดูไฟล์บน GitHub

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.


PRs Welcome LinkedIn Twitter Reddit Discord Sponsor

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

One npm install adds the module's AI assistant to your Claude Code, and it guides you through the tutorial as you build.

Claim your free module

Sponsors ❤️

We gratefully acknowledge the organizations and individuals who have made significant contributions to this project.

Company Sponsors

Contextual AIContextual AICodeRabbitCodeRabbit

Individual Sponsors

📫 Stay Updated!

Subscribe to DiamantAI Newsletter

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!

DiamantAI's newsletter

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

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.

#CategoryTechniqueView
1Foundational 🌱Basic RAG
2Foundational 🌱RAG with CSV Files
3Foundational 🌱Reliable RAG
4Foundational 🌱Optimizing Chunk Sizes
5Foundational 🌱Proposition Chunking
6Query Enhancement 🔍Query Transformations
7Query Enhancement 🔍HyDE (Hypothetical Document Embedding)
8Query Enhancement 🔍HyPE (Hypothetical Prompt Embedding)
9Context Enrichment 📚Contextual Chunk Headers
10Context Enrichment 📚Relevant Segment Extraction
11Context Enrichment 📚Context Window Enhancement
12Context Enrichment 📚Semantic Chunking
13Context Enrichment 📚Contextual Compression
14Context Enrichment 📚Document Augmentation
15Advanced Retrieval 🚀Fusion Retrieval
16Advanced Retrieval 🚀Reranking
17Advanced Retrieval 🚀Multi-faceted FilteringDescribed below (no notebook yet)
18Advanced Retrieval 🚀Hierarchical Indices
19Advanced Retrieval 🚀Dartboard Retrieval
20Advanced Retrieval 🚀Multi-modal RAG with Captioning
21Iterative Techniques 🔁Retrieval with Feedback Loop
22Iterative Techniques 🔁Adaptive Retrieval
23Evaluation 📊DeepEval
24Evaluation 📊GroUSE
25Explainability 🔬Explainable Retrieval
26Advanced Architecture 🏗️Graph RAG with LangChain
27Advanced Architecture 🏗️Microsoft GraphRAG
28Advanced Architecture 🏗️RAPTOR
29Advanced Architecture 🏗️Agentic RAG with Contextual AI
30Advanced Architecture 🏗️Self-RAG
31Advanced Architecture 🏗️Corrective RAG (CRAG)
32Advanced Architecture 🏗️Local Graph RAG with Verifiable Attribution
33Evaluation 📊End-to-End RAG Evaluation
34Evaluation 📊Open-RAG-Eval
35Advanced 🔬MemoRAG
36Special Technique 🌟Sophisticated Controllable Agent

🌱 Foundational RAG Techniques

  1. 1Simple RAG 🌱- **🎬 Watch it explained**: **[RAG Explained: Why AI Gets Your Own Documents Wrong](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=main-readme&click=youtube-simple-rag-list&target=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DrRCfl4aRYJs&retarget=0&text=youtube-simple-rag-list)** — the intuition behind this notebook in 7 minutes: why chunks overlap, what "meaning space" actually is, and where simple RAG breaks down. - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_rag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_rag.ipynb) - **LlamaIndex**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_rag_with_llamaindex.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_rag_with_llamaindex.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/simple_rag.py)** Overview 🔎Introducing basic RAG techniques ideal for newcomers. Implementation 🛠️Start with basic retrieval queries and integrate incremental learning mechanisms.
  2. 2Simple RAG using a CSV file 🧩- **🎬 Watch it explained**: **[How Do You Search a Spreadsheet by Meaning?](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=main-readme&click=youtube-csv-rag-list&target=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFkeEJz2fh90&retarget=0&text=youtube-csv-rag-list)** — 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**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_csv_rag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_csv_rag.ipynb) - **LlamaIndex**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_csv_rag_with_llamaindex.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/simple_csv_rag_with_llamaindex.ipynb) 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.
  3. 3**Reliable RAG 🏷️**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/reliable_rag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/reliable_rag.ipynb)- **🎬 Watch it explained**: **[How Do You Know Your RAG Answer Isn't Made Up?](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=main-readme&click=youtube-reliable-rag-list&target=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DoVI2GA8jn7w&retarget=0&text=youtube-reliable-rag-list)** — 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.
  4. 4Choose Chunk Size 📏 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/choose_chunk_size.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/choose_chunk_size.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/choose_chunk_size.py)** 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.
  5. 5**Proposition Chunking ⛓️‍💥**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/proposition_chunking.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/proposition_chunking.ipynb) 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.
  6. 6**[Simple RAG with JSON](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/json_rag.ipynb)** 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 📚

🔍 Query Enhancement

  1. 1Query Transformations 🔄 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/query_transformations.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/query_transformations.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/query_transformations.py)** 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.
  2. 2Hypothetical Questions (HyDE Approach) ❓ - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/all_rag_techniques/HyDe_Hypothetical_Document_Embedding.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/HyDe_Hypothetical_Document_Embedding.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/HyDe_Hypothetical_Document_Embedding.py)** 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](https://newsletter.diamant-ai.com/p/hyde-exploring-hypothetical-document?r=336pe4&utm_campaign=post&utm_medium=web)** - A short blog post explaining this method clearly.

📚 Context and Content Enrichment

  1. 1Hypothetical Prompt Embeddings (HyPE) ❓🚀 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/HyPE_Hypothetical_Prompt_Embeddings.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/HyPE_Hypothetical_Prompt_Embeddings.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/HyPE_Hypothetical_Prompt_Embeddings.py)** 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)](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=5139335)** - Research paper detailing the method, evaluation, and benchmarks.
  2. 2**Contextual Chunk Headers :label:**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/contextual_chunk_headers.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/contextual_chunk_headers.ipynb) 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](https://github.com/D-Star-AI/dsRAG)**: open-source retrieval engine that implements this technique (and a few other advanced RAG techniques)
  3. 3**Relevant Segment Extraction 🧩**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/relevant_segment_extraction.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/relevant_segment_extraction.ipynb) 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.
  4. 4Context Enrichment Techniques 📝

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.

  1. 1Semantic Chunking 🧠

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 📚

  1. 1Contextual Compression 🗜️

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.

  1. 1Document Augmentation through Question Generation for Enhanced Retrieval

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

  1. 1Fusion Retrieval 🔗 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/fusion_retrieval.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/fusion_retrieval.ipynb) - **LlamaIndex**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/fusion_retrieval_with_llamaindex.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/fusion_retrieval_with_llamaindex.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/fusion_retrieval.py)** Overview 🔎Optimizing search results by combining different retrieval methods. Implementation 🛠️Combine keyword-based search with vector-based search for more comprehensive and accurate retrieval.
  2. 2Intelligent Reranking 📈 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/reranking.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/reranking.ipynb) - **LlamaIndex**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/reranking_with_llamaindex.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/reranking_with_llamaindex.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/reranking.py)** 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](https://newsletter.diamant-ai.com/p/relevance-revolution-how-re-ranking?r=336pe4&utm_campaign=post&utm_medium=web)** - A comprehensive blog post exploring the power of re-ranking in enhancing RAG system performance.
  3. 3Multi-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.
  4. 4Hierarchical Indices 🗂️ - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/hierarchical_indices.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/hierarchical_indices.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/hierarchical_indices.py)** 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](https://newsletter.diamant-ai.com/p/hierarchical-indices-enhancing-rag?r=336pe4&utm_campaign=post&utm_medium=web)** - A comprehensive blog post exploring the power of hierarchical indices in enhancing RAG system performance.
  5. 5Dartboard Retrieval 🎯- **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/dartboard.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/dartboard.ipynb) 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.
  6. 6Multi-modal Retrieval 📽️ Overview 🔎Extending RAG capabilities to handle diverse data types for richer responses. Implementation 🛠️- **Multi-model RAG with Multimedia Captioning**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/multi_model_rag_with_captioning.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/multi_model_rag_with_captioning.ipynb) - 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**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/multi_model_rag_with_colpali.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/multi_model_rag_with_colpali.ipynb) - 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

  1. 1Retrieval with Feedback Loops 🔁 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/retrieval_with_feedback_loop.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/retrieval_with_feedback_loop.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/retrieval_with_feedback_loop.py)** 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.
  2. 2Adaptive Retrieval 🎯 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/adaptive_retrieval.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/adaptive_retrieval.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/adaptive_retrieval.py)** 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

  1. 1**DeepEval Evaluation**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/evaluation/evaluation_deep_eval.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/evaluation/evaluation_deep_eval.ipynb) | Comprehensive RAG system evaluation | Overview 🔎Performing evaluations Retrieval-Augmented Generation systems, by covering several metrics and creating test cases. Implementation 🛠️Use the `deepeval` library to conduct test cases on correctness, faithfulness and contextual relevancy of RAG systems.
  2. 2**GroUSE Evaluation**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/evaluation/evaluation_grouse.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/evaluation/evaluation_grouse.ipynb) | 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 `grouse` package 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.
  3. 3**End-to-End RAG Evaluation**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/evaluation/end-2-end_rag_evaluation.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/evaluation/end-2-end_rag_evaluation.ipynb) | 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.
  4. 4**Open-RAG-Eval**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/evaluation/open-rag-eval-example.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/evaluation/open-rag-eval-example.ipynb) | 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

  1. 1**MemoRAG**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/all_rag_techniques/memorag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/memorag.ipynb) | 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

  1. 1Explainable Retrieval 🔍 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/explainable_retrieval.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/explainable_retrieval.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/explainable_retrieval.py)** Overview 🔎Providing transparency in the retrieval process to enhance user trust and system refinement. Implementation 🛠️Explain why certain pieces of information were retrieved and how they relate to the query.

🏗️ Advanced Architectures

  1. 1Agentic RAG with Contextual AI 🤖 - **Agentic RAG**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/all_rag_techniques/Agentic_RAG.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/Agentic_RAG.ipynb) Overview 🔎Building production-ready agentic RAG pipelines for financial document analysis with Contextual AI's managed platform. This comprehensive tutorial demonstrates how to leverage agentic RAG to solve complex queries through intelligent query reformulation, document parsing, reranking, and grounded language models. Implementation 🛠️- **Document Parser**: Enterprise-grade parsing with vision models for complex tables, charts, and multi-page documents - **Instruction-Following Reranker**: SOTA reranker with instruction-following capabilities for handling conflicting information - **Grounded Language Model (GLM)**: World's most grounded LLM specifically engineered to minimize hallucinations for RAG use cases - **LMUnit**: Natural language unit testing framework for evaluating and optimizing RAG system performance
  2. 2Graph RAG with Milvus Vector Database 🔍 - **Graph RAG with Milvus**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/all_rag_techniques/graphrag_with_milvus_vectordb.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/graphrag_with_milvus_vectordb.ipynb) Overview 🔎A simple yet powerful approach to implement Graph RAG using Milvus vector databases. This technique significantly improves performance on complex multi-hop questions by combining relationship-based retrieval with vector search and reranking. Implementation 🛠️- Store both text passages and relationship triplets (subject-predicate-object) in separate Milvus collections - Perform multi-way retrieval by querying both collections - Use an LLM to rerank retrieved relationships based on their relevance to the query - Retrieve the final passages based on the most relevant relationships
  3. 3Knowledge Graph Integration (Graph RAG) 🕸️ - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/graph_rag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/graph_rag.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/graph_rag.py)** Overview 🔎Incorporating structured data from knowledge graphs to enrich context and improve retrieval. Implementation 🛠️Retrieve entities and their relationships from a knowledge graph relevant to the query, combining this structured data with unstructured text for more informative responses.
  4. 4GraphRag (Microsoft) 🎯- **GraphRag**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/Microsoft_GraphRag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/Microsoft_GraphRag.ipynb) Overview 🔎Microsoft GraphRAG (Open Source) is an advanced RAG system that integrates knowledge graphs to improve the performance of LLMs Implementation 🛠️• Analyze an input corpus by extracting entities, relationships from text units. generates summaries of each community and its constituents from the bottom-up.
  5. 5RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval 🌳 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/raptor.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/raptor.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/raptor.py)** Overview 🔎Implementing a recursive approach to process and organize retrieved information in a tree structure. Implementation 🛠️Use abstractive summarization to recursively process and summarize retrieved documents, organizing the information in a tree structure for hierarchical context.
  6. 6Self RAG 🔁 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/self_rag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/self_rag.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/self_rag.py)** Overview 🔎A dynamic approach that combines retrieval-based and generation-based methods, adaptively deciding whether to use retrieved information and how to best utilize it in generating responses. Implementation 🛠️• Implement a multi-step process including retrieval decision, document retrieval, relevance evaluation, response generation, support assessment, and utility evaluation to produce accurate, relevant, and useful outputs.
  7. 7Corrective RAG 🔧 - **LangChain**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/crag.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/crag.ipynb) - **[Runnable Script](https://github.com/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques_runnable_scripts/crag.py)** Overview 🔎A sophisticated RAG approach that dynamically evaluates and corrects the retrieval process, combining vector databases, web search, and language models for highly accurate and context-aware responses. Implementation 🛠️• Integrate Retrieval Evaluator, Knowledge Refinement, Web Search Query Rewriter, and Response Generator components to create a system that adapts its information sourcing strategy based on relevance scores and combines multiple sources when necessary.
  8. 8Local Graph RAG with Verifiable Attribution 🔗- **NetworkX + Ollama**: [<img src="https://img.shields.io/badge/GitHub-View-blue" height="20">](https://github.com/NirDiamant/RAG_TECHNIQUES/blob/main/all_rag_techniques/graph_rag_local_attribution.ipynb) [<img src="https://colab.research.google.com/assets/colab-badge.svg" height="20">](https://colab.research.google.com/github/NirDiamant/RAG_Techniques/blob/main/all_rag_techniques/graph_rag_local_attribution.ipynb) Overview 🔎A privacy-first Graph RAG implementation running entirely locally with Ollama. Uses NetworkX for multi-hop graph traversal and provides sentence-level attribution — every claim traces back to the exact source sentence, unlike Vector RAG's chunk-level attribution. Implementation 🛠️• Extract entities and relationships from documents using a local LLM, building a knowledge graph with full source provenance. Combine vector similarity search (entry points) with graph traversal (multi-hop expansion). Generate answers with inline citations that map each claim to its source document, sentence, and graph path.

🌟 Special Advanced Technique 🌟

  1. 1**[Sophisticated Controllable Agent for Complex RAG Tasks 🤖](https://github.com/NirDiamant/Controllable-RAG-Agent)** Overview 🔎An advanced RAG solution designed to tackle complex questions that simple semantic similarity-based retrieval cannot solve. This approach uses a sophisticated deterministic graph as the "brain" 🧠 of a highly controllable autonomous agent, capable of answering non-trivial questions from your own data. Implementation 🛠️• Implement a multi-step process involving question anonymization, high-level planning, task breakdown, adaptive information retrieval and question answering, continuous re-planning, and rigorous answer verification to ensure grounded and accurate responses.

Getting Started

To begin implementing these advanced RAG techniques in your projects:

  1. 1Clone this repository:git clone https://github.com/NirDiamant/RAG_Techniques.git
  2. 2Navigate to the technique you're interested in:cd all_rag_techniques/technique-name
  3. 3Follow the detailed implementation guide in each technique's directory.

📚 Recommended reading

This list contains Amazon affiliate links. As an Amazon Associate I earn from qualifying purchases. Every book below is one I've read and genuinely recommend to engineers working in this space. The companion book to this repo is featured separately at the top of this README.


🌟 Support This Project: Your sponsorship fuels innovation in RAG technologies. Become a sponsor to help maintain and expand this valuable resource!

📚 More from the same author

Prompt Engineering: Master the Art of AI Interaction - the prompting foundation that makes RAG work better. Same visual approach, 22 hands-on techniques.

Run a course, newsletter, or dev community? You can earn 25% recommending RAG Made Simple to your audience.

Contributing

We welcome contributions from the community! If you have a new technique or improvement to suggest:

  1. 1Fork the repository
  2. 2Create your feature branch: git checkout -b feature/AmazingFeature
  3. 3Commit your changes: git commit -m 'Add some AmazingFeature'
  4. 4Push to the branch: git push origin feature/AmazingFeature
  5. 5Open a pull request

Contributors

Contributors

License

This project is licensed under a custom non-commercial license - see the LICENSE file for details.


⭐️ If you find this repository helpful, please consider giving it a star!

Keywords: RAG, Retrieval-Augmented Generation, NLP, AI, Machine Learning, Information Retrieval, Natural Language Processing, LLM, Embeddings, Semantic Search, PydanticAI, Agent Frameworks

#agentic-rag#ai#embeddings#generative-ai#gpt#langchain#llama-index#llm#llms#machine-learning#nlp#openai