Agentic AI Notebook
Back to Projects
BeginnerPhase 3 6 hours(broken down below)

PDF Chat

Upload PDFs and chat with their contents using RAG — the quintessential LLM engineering project.

PythonLangChainChromaDBStreamlit

Project walkthrough

PDF Chat

1 / 6

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.

100%
Loading diagram...

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

  1. Install langchain, chromadb, streamlit, and pypdf
  2. Create a Streamlit app with PDF file uploader
  3. Configure ChromaDB persistent directory for local storage
  4. Set embedding model (text-embedding-3-small) and chat model
  5. Add a sample PDF (e.g., course syllabus) for smoke testing
  6. 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%

Interview questions

How do you choose chunk size for PDF RAG?
Balance context window limits with retrieval precision — 300–800 tokens with 10–20% overlap works for most docs. Evaluate on a golden Q&A set and tune until faithfulness scores plateau.
What happens when retrieval returns irrelevant chunks?
Add a similarity score threshold, increase top-k then re-rank, or use hybrid search (BM25 + vectors). Prompt the LLM to say 'not found in document' when context doesn't support an answer.