A sophisticated Retrieval-Augmented Generation (RAG) system that implements a corrective multi-stage workflow using LangGraph. This system combines document retrieval, relevance grading, query transformation, and web search to provide comprehensive and accurate responses.
- Smart Document Retrieval: Uses Qdrant vector store for efficient document retrieval
- Document Relevance Grading: Employs Claude 3.5 sonnet to assess document relevance
- Query Transformation: Improves search results by optimizing queries when needed
- Web Search Fallback: Uses Tavily API for web search when local documents aren't sufficient
- Multi-Model Approach: Combines OpenAI embeddings and Claude 3.5 sonnet for different tasks
- Interactive UI: Built with Streamlit for easy document upload and querying
-
Clone the Repository:
git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git cd rag_tutorials/corrective_rag
-
Install Dependencies:
pip install -r requirements.txt
-
Set Up API Keys: You'll need to obtain the following API keys:
- OpenAI API key (for embeddings)
- Anthropic API key (for Claude 3.5 sonnet as LLM)
- Tavily API key (for web search)
- Qdrant Cloud Setup
- Visit Qdrant Cloud
- Create an account or sign in
- Create a new cluster
- Get your credentials:
- Qdrant API Key: Found in API Keys section
- Qdrant URL: Your cluster URL (format:
https://xxx-xxx.aws.cloud.qdrant.io
)
-
Run the Application:
streamlit run corrective_rag.py
-
Use the Application:
- Upload documents or provide URLs
- Enter your questions in the query box
- View the step-by-step Corrective RAG process
- Get comprehensive answers
- LangChain: For RAG orchestration and chains
- LangGraph: For workflow management
- Qdrant: Vector database for document storage
- Claude 3.5 sonnet: Main language model for analysis and generation
- OpenAI: For document embeddings
- Tavily: For web search capabilities
- Streamlit: For the user interface