https://github.com/razamehar/self-correcting-agentic-rag-corrective-rag
https://github.com/razamehar/self-correcting-agentic-rag-corrective-rag
agentic-ai agentic-rag chromadb corrective-rag langchain langgraph large-language-models openai python rag retrieval-augmented-generation tavily
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/razamehar/self-correcting-agentic-rag-corrective-rag
- Owner: razamehar
- Created: 2025-06-22T01:52:19.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-06-22T02:34:25.000Z (4 months ago)
- Last Synced: 2025-06-22T03:24:16.825Z (3 months ago)
- Topics: agentic-ai, agentic-rag, chromadb, corrective-rag, langchain, langgraph, large-language-models, openai, python, rag, retrieval-augmented-generation, tavily
- Language: Jupyter Notebook
- Homepage:
- Size: 11.3 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Self-correcting Agentic RAG
This project presents a Retrieval-Augmented Generation system that intelligently combines multi-step document retrieval, dynamic query rewriting, document relevance grading, and web search augmentation. Designed as a self-correcting agent, it iteratively refines queries and supplements retrieved knowledge with real-time web data when existing documents fall short—delivering precise, contextually relevant answers to user questions.
---
## Features
- **Document Loading and Preprocessing:** Load PDFs and split them into chunks for retrieval.
- **Vector Store Initialization:** Embed documents using OpenAI embeddings and index them for similarity search.
- **Ensemble Retriever:** Combines parent document retriever and keyword-based retriever for better results.
- **Document Grading:** Scores retrieved documents by relevance to the question and filters out low-quality ones.
- **Query Rewriting:** Improves user queries for better retrieval when documents are insufficient.
- **Web Search Integration:** Adds recent and relevant web search results when the retrieved documents are not relevant.
- **RAG Chain for Generation:** Generates answers from retrieved documents and the rewritten query.
- **Flexible StateGraph Workflow:** Controls the multi-step process from retrieval to final generation with conditional branching.---
## Worflow
## Setup Instructions
### Requirements
- Python 3.8+
- OpenAI API Key
- Required Python packages:
- `openai`
- `langchain`
- `some_vectorstore_library` (your vector store choice, e.g., Chromadb, FAISS)
- `tavily` or your web search API client### Installation:
1. Clone the Repository:
```bash
git clone https://github.com/razamehar/Self-Correcting-Agentic-RAG-Corrective-RAG.git
cd Self-Correcting-Agentic-RAG-Corrective-RAG
```2. Install dependencies:
```bash
pip install -r requirements.txt
```### Contact
For any questions or clarifications, please contact Raza Mehar at [raza.mehar@gmail.com].