File size: 2,033 Bytes
0662542
 
 
 
 
 
 
 
 
 
 
 
0cf7776
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
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 <your-repo-url>
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?"