A Streamlit-based RAG chatbot that answers questions strictly from a fixed set of PDFs using Pinecone for retrieval and Groq for fast generation.
- Hybrid Search: Combines semantic understanding with keyword matching for better retrieval
- Streaming Responses: See answers appear in real-time
- PDF-only answers: Responses are generated exclusively from your uploaded PDFs
- Source citations: Every answer includes PDF filename and page number
- Auto-indexing: PDFs are automatically indexed on first run
- Fast inference: Uses Groq for rapid LLM responses
- No hallucinations: Strict prompt engineering ensures factual answers
| Component | Technology |
|---|---|
| Frontend | Streamlit |
| Embeddings | OpenRouter (text-embedding-3-small) |
| Keyword Search | BM25 (pinecone-text) |
| Vector DB | Pinecone (hosted) |
| LLM | Groq API |
| PDF Extraction | pdfplumber |
git clone https://github.com/Pranavharshans/PDF-RAG.git
cd PDF-RAG
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtcp .env.example .envEdit .env with your API keys:
OPENROUTER_API_KEY- Get from OpenRouterGROQ_API_KEY- Get from Groq ConsolePINECONE_API_KEY- Get from Pinecone ConsolePINECONE_INDEX_NAME- Name for your Pinecone index
Create a serverless index in Pinecone with these exact settings:
| Setting | Value |
|---|---|
| Dimensions | 1536 |
| Metric | dotproduct (required for hybrid search) |
Important: Must use
dotproductmetric, notcosine!
Place your PDF files in the data/pdfs/ directory.
streamlit run app.pyThe application will automatically index your PDFs on first run.
PDF-RAG/
├── app.py # Main Streamlit application
├── indexer.py # Automatic indexing logic (hybrid)
├── data/
│ ├── pdfs/ # Place PDF files here
│ └── bm25_model.json # Fitted BM25 model (auto-generated)
├── utils/
│ ├── __init__.py
│ ├── bm25_encoder.py # BM25 sparse encoder
│ ├── chunking.py # Text splitting logic
│ ├── embeddings.py # OpenRouter embedding calls
│ ├── pinecone_utils.py # Pinecone operations (hybrid)
│ └── pdf_loader.py # PDF text extraction
├── requirements.txt
├── .env.example
├── GUIDE.md # Detailed setup guide
└── README.md
- Open the Streamlit app in your browser
- Type your question about the college department
- The system will:
- Search using hybrid search (semantic + keyword)
- Stream the answer in real-time
- Display source citations (PDF name + page number)
- Answers are generated only from indexed PDF content
- If information is not found, the system responds with a fallback message
- All answers include source citations (PDF name + page number)
- No external knowledge or speculation is used
See GUIDE.md for detailed setup instructions and troubleshooting.
MIT