--- title: Pdf RAG Chatbot emoji: 🏢 colorFrom: gray colorTo: yellow sdk: gradio sdk_version: 6.2.0 app_file: app.py pinned: false short_description: 'Chat with your pdf ' --- # 📄 PDF RAG Chatbot A Retrieval Augmented Generation (RAG) chatbot that allows you to upload PDF documents and have conversations based on their content using AI. ## Tech Stack - **UI**: Gradio - **LLM**: Groq (Llama 3.3 70B) - **Framework**: LangChain - **Embeddings**: HuggingFace (all-MiniLM-L6-v2) - **Vector Store**: FAISS - **PDF Processing**: PyPDF ## Installation 1. Clone the repository: ```bash git clone cd pdf-rag-chatbot ``` 2. Install dependencies: ```bash pip install -r requirements.txt ``` 3. Set up your Groq API key: ```bash export GROQ_API_KEY="your-api-key-here" ``` Get your free API key from [Groq Console](https://console.groq.com) ## Usage 1. Run the application: ```bash python app.py ``` 2. Open your browser to the displayed URL (usually `http://localhost:7860`) 3. Upload a PDF file 4. Wait for processing to complete 5. Start asking questions about the PDF content! ## How It Works 1. **PDF Processing**: The uploaded PDF is split into smaller chunks 2. **Embedding**: Each chunk is converted into a vector embedding 3. **Vector Storage**: Embeddings are stored in FAISS for fast retrieval 4. **Query**: When you ask a question, the system finds the most relevant chunks 5. **Response**: The LLM generates an answer based on the retrieved context ## Environment Variables - `GROQ_API_KEY`: Your Groq API key (required) ## Deployment ### Hugging Face Spaces 1. Create a new Space on Hugging Face 2. Upload all files 3. Add `GROQ_API_KEY` to Space secrets 4. Your app will be live! ### Local Development ```bash python app.py ``` ## Example Questions After uploading a PDF, you can ask questions like: - "What is the main topic of this document?" - "Summarize the key points" - "What does the document say about [specific topic]?" - "Can you explain [concept] from the document?"