athina-ai/rag-cookbooks

This repository contains various advanced techniques for Retrieval-Augmented Generation (RAG) systems.

Jupyter Notebook

2,575

54 commits

updated Feb 17, 2025

See the code

README

LinkedIn  Twitter  Share  Share  Share

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

Advanced + Agentic RAG Cookbooks👨🏻‍💻

Welcome to the comprehensive collection of advanced + agentic Retrieval-Augmented Generation (RAG) techniques.

Introduction🚀

RAG is a popular method that improves accuracy and relevance by finding the right information from reliable sources and transforming it into useful answers. This repository covers the most effective advanced + agentic RAG techniques with clear implementations and explanations.

The main goal of this repository is to provide a helpful resource for researchers and developers looking to use advanced RAG techniques in their projects. Building these techniques from scratch takes time, and finding proper evaluation methods can be challenging. This repository simplifies the process by offering ready-to-use implementations and guidance on how to evaluate them.

[!NOTE] This repository starts with naive RAG as a foundation and progresses to advanced and agentic techniques. It also includes research papers/references for each RAG technique, which you can explore for further reading.

Introduction to RAG💡

Large Language Models are trained on a fixed dataset, which limits their ability to handle private or recent information. They can sometimes "hallucinate", providing incorrect yet believable answers. Fine-tuning can help but it is expensive and not ideal for retraining again and again on new data. The Retrieval-Augmented Generation (RAG) framework addresses this issue by using external documents to improve the LLM's responses through in-context learning. RAG ensures that the information provided by the LLM is not only contextually relevant but also accurate and up-to-date.

final diagram

There are four main components in RAG:

Indexing: First, documents (in any format) are split into chunks, and embeddings for these chunks are created. These embeddings are then added to a vector store.

Retriever: Then, the retriever finds the most relevant documents based on the user's query, using techniques like vector similarity from the vector store.

Augment: After that, the Augment part combines the user's query with the retrieved context into a prompt, ensuring the LLM has the information needed to generate accurate responses.

Generate: Finally, the combined query and prompt are passed to the model, which then generates the final response to the user's query.

These components of RAG allow the model to access up-to-date, accurate information and generate responses based on external knowledge. However, to ensure RAG systems are functioning effectively, it’s essential to evaluate their performance.

RAG Evaluation📊

Evaluating RAG applications is important for understanding how well these systems work. We can see how effectively they combine information retrieval with generative models by checking their accuracy and relevance. This evaluation helps improve RAG applications in tasks like text summarization, chatbots, and question-answering. It also identifies areas for improvement, ensuring that these systems provide trustworthy responses as information changes. Overall, effective evaluation helps optimize performance and builds confidence in RAG applications for real-world use. These notebooks contain an end-to-end RAG implementation + RAG evaluation part in Athina AI.

evals diagram

Advanced RAG Techniques⚙️

Here are the details of all the Advanced RAG techniques covered in this repository.

TechniqueToolsDescriptionNotebooks
Naive RAGLangChain, Pinecone, Athina AICombines retrieved data with LLMs for simple and effective responses.Open In Colab
Hybrid RAGLangChain, Chromadb, Athina AICombines vector search and traditional methods like BM25 for better information retrieval.Open In Colab
Hyde RAGLangChain, Weaviate, Athina AICreates hypothetical document embeddings to find relevant information for a query.Open In Colab
Parent Document RetrieverLangChain, Chromadb, Athina AIBreaks large documents into small parts and retrieves the full document if a part matches the query.Open In Colab
RAG fusionLangChain, LangSmith, Qdrant, Athina AIGenerates sub-queries, ranks documents with Reciprocal Rank Fusion, and uses top results for accurate responses.Open In Colab
Contextual RAGLangChain, Chromadb, Athina AICompresses retrieved documents to keep only relevant details for concise and accurate responses.Open In Colab
Rewrite Retrieve ReadLangChain, Chromadb, Athina AIImproves query, retrieves better data, and generates accurate answers.Open In Colab
Unstructured RAGLangChain, LangGraph, FAISS, Athina AI, UnstructuredThis method designed to handle documents that combine text, tables, and images.Open In Colab

Agentic RAG Techniques⚙️

Here are the details of all the Agentic RAG techniques covered in this repository.

TechniqueToolsDescriptionNotebooks
Basic Agentic RAGLangChain, FAISS, Athina AIAgentic RAG uses AI agents to find and generate answers using tools like vectordb and web searches.Open In Colab
Corrective RAGLangChain, LangGraph, Chromadb, Athina AIRefines relevant documents, removes irrelevant ones or does the web search.Open In Colab
Self RAGLangChain, LangGraph, FAISS, Athina AIReflects on retrieved data to ensure accurate and complete responses.Open In Colab
Adaptive RAGLangChain, LangGraph, FAISS, Athina AIAdjusts retrieval methods based on query type, using indexed data or web search.Open In Colab
ReAct RAGLangChain, LangGraph, FAISS, Athina AISystem combining reasoning and retrieval for context-aware responsesOpen In Colab

Demo🎬

A quick demo of how each notebook works:

https://github.com/user-attachments/assets/c6f17961-40a1-4cca-ab1f-2c8fa3d71a7a

Getting Started🛠️

First, clone this repository by using the following command:

git clone https://github.com/athina-ai/rag-cookbooks.git

Next, navigate to the project directory:

cd rag-cookbooks

Once you are in the 'rag-cookbooks' directory, follow the detailed implementation for each technique.

Creators + Contributors👨🏻‍💻

Contributors

Contributing🤝

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

License📝

This project is licensed under MIT License

ai
chromadb
cookbooks
faiss
langchain
llm
llms
openai
pinecone
python
qdrant
rag
tutorials
weaviate

athina-ai/rag-cookbooks

This repository contains various advanced techniques for Retrieval-Augmented Generation (RAG) systems.

Jupyter Notebook

2,575

54 commits

updated Feb 17, 2025

See the code

README

LinkedIn  Twitter  Share  Share  Share

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

Advanced + Agentic RAG Cookbooks👨🏻‍💻

Welcome to the comprehensive collection of advanced + agentic Retrieval-Augmented Generation (RAG) techniques.

Introduction🚀

RAG is a popular method that improves accuracy and relevance by finding the right information from reliable sources and transforming it into useful answers. This repository covers the most effective advanced + agentic RAG techniques with clear implementations and explanations.

The main goal of this repository is to provide a helpful resource for researchers and developers looking to use advanced RAG techniques in their projects. Building these techniques from scratch takes time, and finding proper evaluation methods can be challenging. This repository simplifies the process by offering ready-to-use implementations and guidance on how to evaluate them.

[!NOTE] This repository starts with naive RAG as a foundation and progresses to advanced and agentic techniques. It also includes research papers/references for each RAG technique, which you can explore for further reading.

Introduction to RAG💡

Large Language Models are trained on a fixed dataset, which limits their ability to handle private or recent information. They can sometimes "hallucinate", providing incorrect yet believable answers. Fine-tuning can help but it is expensive and not ideal for retraining again and again on new data. The Retrieval-Augmented Generation (RAG) framework addresses this issue by using external documents to improve the LLM's responses through in-context learning. RAG ensures that the information provided by the LLM is not only contextually relevant but also accurate and up-to-date.

final diagram

There are four main components in RAG:

Indexing: First, documents (in any format) are split into chunks, and embeddings for these chunks are created. These embeddings are then added to a vector store.

Retriever: Then, the retriever finds the most relevant documents based on the user's query, using techniques like vector similarity from the vector store.

Augment: After that, the Augment part combines the user's query with the retrieved context into a prompt, ensuring the LLM has the information needed to generate accurate responses.

Generate: Finally, the combined query and prompt are passed to the model, which then generates the final response to the user's query.

These components of RAG allow the model to access up-to-date, accurate information and generate responses based on external knowledge. However, to ensure RAG systems are functioning effectively, it’s essential to evaluate their performance.

RAG Evaluation📊

Evaluating RAG applications is important for understanding how well these systems work. We can see how effectively they combine information retrieval with generative models by checking their accuracy and relevance. This evaluation helps improve RAG applications in tasks like text summarization, chatbots, and question-answering. It also identifies areas for improvement, ensuring that these systems provide trustworthy responses as information changes. Overall, effective evaluation helps optimize performance and builds confidence in RAG applications for real-world use. These notebooks contain an end-to-end RAG implementation + RAG evaluation part in Athina AI.

evals diagram

Advanced RAG Techniques⚙️

Here are the details of all the Advanced RAG techniques covered in this repository.

TechniqueToolsDescriptionNotebooks
Naive RAGLangChain, Pinecone, Athina AICombines retrieved data with LLMs for simple and effective responses.Open In Colab
Hybrid RAGLangChain, Chromadb, Athina AICombines vector search and traditional methods like BM25 for better information retrieval.Open In Colab
Hyde RAGLangChain, Weaviate, Athina AICreates hypothetical document embeddings to find relevant information for a query.Open In Colab
Parent Document RetrieverLangChain, Chromadb, Athina AIBreaks large documents into small parts and retrieves the full document if a part matches the query.Open In Colab
RAG fusionLangChain, LangSmith, Qdrant, Athina AIGenerates sub-queries, ranks documents with Reciprocal Rank Fusion, and uses top results for accurate responses.Open In Colab
Contextual RAGLangChain, Chromadb, Athina AICompresses retrieved documents to keep only relevant details for concise and accurate responses.Open In Colab
Rewrite Retrieve ReadLangChain, Chromadb, Athina AIImproves query, retrieves better data, and generates accurate answers.Open In Colab
Unstructured RAGLangChain, LangGraph, FAISS, Athina AI, UnstructuredThis method designed to handle documents that combine text, tables, and images.Open In Colab

Agentic RAG Techniques⚙️

Here are the details of all the Agentic RAG techniques covered in this repository.

TechniqueToolsDescriptionNotebooks
Basic Agentic RAGLangChain, FAISS, Athina AIAgentic RAG uses AI agents to find and generate answers using tools like vectordb and web searches.Open In Colab
Corrective RAGLangChain, LangGraph, Chromadb, Athina AIRefines relevant documents, removes irrelevant ones or does the web search.Open In Colab
Self RAGLangChain, LangGraph, FAISS, Athina AIReflects on retrieved data to ensure accurate and complete responses.Open In Colab
Adaptive RAGLangChain, LangGraph, FAISS, Athina AIAdjusts retrieval methods based on query type, using indexed data or web search.Open In Colab
ReAct RAGLangChain, LangGraph, FAISS, Athina AISystem combining reasoning and retrieval for context-aware responsesOpen In Colab

Demo🎬

A quick demo of how each notebook works:

https://github.com/user-attachments/assets/c6f17961-40a1-4cca-ab1f-2c8fa3d71a7a

Getting Started🛠️

First, clone this repository by using the following command:

git clone https://github.com/athina-ai/rag-cookbooks.git

Next, navigate to the project directory:

cd rag-cookbooks

Once you are in the 'rag-cookbooks' directory, follow the detailed implementation for each technique.

Creators + Contributors👨🏻‍💻

Contributors

Contributing🤝

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

License📝

This project is licensed under MIT License

ai
chromadb
cookbooks
faiss
langchain
llm
llms
openai
pinecone
python
qdrant
rag
tutorials
weaviate

Significant stargazers

Nouamane Tazi

474 followers · starred Dec 2024

Harrison Chase

10,215 followers · starred Dec 2024

Bear Huang

15 followers · starred Dec 2024

Anindyadeep

215 followers · starred Dec 2024