A Retrieval-Augmented Generation (RAG) chatbot that lets you upload any PDF and chat with it. Built with LangChain, FAISS, HuggingFace embeddings, Groq (Llama 3.3 70B), and Streamlit.
Large Language Models are powerful but have two key limitations: they don't know your private/domain-specific documents, and they hallucinate when asked about content outside their training data. DocChat solves this by grounding every answer in the user's own documents — making it useful for querying research papers, company reports, manuals, legal documents, or study material without reading hundreds of pages manually.
┌─────────────────────────────────────────┐
│ INGESTION (once) │
PDF upload ──▶ PyPDFLoader ──▶ RecursiveCharacter │
│ TextSplitter (1000/200)│
│ │ │
│ ▼ │
│ HuggingFace Embeddings (MiniLM-L6-v2) │
│ │ │
│ ▼ │
│ FAISS Vector Index (in-memory) │
└─────────────────────────────────────────┘
┌─────────────────────────────────────────┐
│ QUERY TIME (per turn) │
User query ──▶ Embed query ──▶ FAISS similarity │
│ search (top k=4) │
│ │ │
│ ▼ │
│ Augmented prompt (context + history │
│ + question) │
│ │ │
│ ▼ │
│ Groq LLM (Llama 3.3 70B) ──▶ Answer │
└─────────────────────────────────────────┘
| Component | Choice | Why |
|---|---|---|
| Orchestration | LangChain (LCEL) | Standard framework for composing RAG pipelines |
| LLM | Groq — Llama 3.3 70B | Free tier, extremely fast inference, strong open model |
| Embeddings | all-MiniLM-L6-v2 (local) |
Free, fast, no API cost, good quality for semantic search |
| Vector store | FAISS | Lightweight, in-memory, no external DB needed |
| Chunking | 1000 chars, 200 overlap | Balances context completeness vs retrieval precision |
| UI | Streamlit | Rapid chat UI with file upload and session state |
Anti-hallucination: the system prompt restricts the model to answer only from retrieved context, and the UI shows the exact retrieved chunks (with file + page) under each answer for transparency.
# 1. Clone and enter the project
git clone https://github.com/dishaa28/rag-chatbot.git
cd rag-chatbot
# 2. Create a virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Mac/Linux
# 3. Install dependencies
pip install -r requirements.txt
# 4. Add your Groq API key (free at console.groq.com)
copy .env.example .env # then paste your key into .env
# (or just enter the key in the sidebar at runtime)
# 5. Launch
streamlit run app.pyThen open http://localhost:8501, upload one or more PDFs, click Process Documents, and start asking questions.
rag-chatbot/
├── app.py # Streamlit chat UI
├── rag_pipeline.py # Ingestion, chunking, embeddings, FAISS, RAG chain
├── requirements.txt
├── .env.example
└── README.md
- Persist the FAISS index to disk (
vectorstore.save_local) to avoid re-indexing - Support more formats (DOCX, TXT, web pages via
WebBaseLoader) - History-aware retrieval (rewrite follow-up questions before searching)
- Deploy on Streamlit Community Cloud / Hugging Face Spaces