← Back to Projects
Basic RAG Chatbot
Upload a PDF, chunk it, embed it, and chat with it. The 'hello world' of RAG — but done properly.
What you'll learn
- Loading and chunking documents
- Creating embeddings and storing them in a vector database
- Retrieval + generation pipeline
- Basic prompt engineering for grounded answers
Architecture
PDF upload → text extraction (PyPDF2/pdfplumber)
→ chunking (recursive, 500 tokens, 50 overlap)
→ embedding (OpenAI text-embedding-3-small or open-source)
→ store in ChromaDB
→ query: embed question → retrieve top-k → LLM generates answer with context
Steps
- Build a simple UI (Streamlit or Gradio) with a file upload widget
- Extract text from the PDF, split into chunks using recursive character splitter
- Embed all chunks, store in ChromaDB with metadata (page number, filename)
- On user query: embed the question, retrieve top-5 chunks
- Construct a prompt: "Answer based on:
chunks. Question:query" - Stream the LLM response
- Add a "sources" section that shows which chunks were used