PDF Chat
Upload PDFs and chat with their contents using RAG — the quintessential LLM engineering project.
Project walkthrough
PDF Chat
Project Goal
The canonical RAG project — chat with any PDF using semantic search.
- →Upload PDFs and index them locally
- →Chunk, embed, and store in ChromaDB
- →Answer questions with retrieved context
- →Stream responses in a Streamlit chat UI
Use ← → arrow keys or buttons to navigate the walkthrough
Time breakdown (6h)
Each phase maps to the estimated hours — follow in order for a realistic build schedule.
Upload & extraction
1h- •Streamlit file uploader with multi-PDF support
- •PyPDF text extraction with page metadata
Chunking & embedding
2h- •RecursiveCharacterTextSplitter with 500-token chunks, 50 overlap
- •Batch embed and persist to ChromaDB collection
- •Re-index on new upload without duplicating
RAG retrieval pipeline
2h- •Top-k retrieval with similarity threshold
- •Prompt template with source citations
- •Streaming response via LangChain callback
UI polish
1h- •Chat history sidebar
- •Show retrieved chunk previews
- •Loading spinner during indexing
Architecture
Uploaded PDFs are split into overlapping chunks, embedded, and stored in ChromaDB. User questions trigger a similarity search to retrieve top-k chunks, which are injected into the LLM prompt as context for a grounded, streaming answer.
Scroll inside the frame to explore · use + / − to zoom up to 200%
Prerequisites
- Python 3.11+ with pip or uv
- OpenAI API key for embeddings and chat
- Basic understanding of RAG (retrieval-augmented generation)
- Familiarity with LangChain document loaders and vector stores
- Streamlit basics for rapid UI prototyping
Setup steps
- Install langchain, chromadb, streamlit, and pypdf
- Create a Streamlit app with PDF file uploader
- Configure ChromaDB persistent directory for local storage
- Set embedding model (text-embedding-3-small) and chat model
- Add a sample PDF (e.g., course syllabus) for smoke testing
- Run streamlit run app.py and verify Q&A works
Features to build
- PDF upload
- Chunking pipeline
- Semantic search
- Streaming chat
Expected result
Upload a 20-page PDF, ask 3 questions about its contents, and receive streaming answers with cited page numbers — demonstrating grounded retrieval with no hallucinated facts outside the document.
Resume bullet points
- →Developed a RAG-based PDF chat application with ChromaDB vector store
- →Optimized chunking strategy improving answer relevance by 40%
