[ ← back to projects ]
> cat case-studies/documentbot.md

DocumentBot RAG System

Type
Course project (NLP, 7th semester) — built solo
Role
Sole developer — full system, backend and frontend
Stack
FastAPI, PostgreSQL, Pinecone, LLaMA Text Embed v2, BGE-Reranker-v2-m3, Gemini 2.5 Flash, React/TypeScript
Status
Fully built and functional, with a retained evaluation
Later reused
RAG engine extended into BinderDocs
< FastAPI />< React />< Pinecone />< RAG />
> the situation

Anyone working with a large document collection runs into the same wall: keyword search doesn't understand what you're actually asking, and reading through everything manually doesn't scale. DocumentBot was built to solve that directly: upload documents, ask questions in natural language, get answers with citations back to the specific source chunks — and ask a follow-up without repeating context.

> what was built

Document ingestion and chunking — PDF, DOCX, and TXT uploads processed asynchronously, split into 500-token chunks with 50-token overlap using tiktoken, so a chunk boundary doesn't sever the context a question depends on.

Embedding and vector storage — chunks embedded with LLaMA Text Embed v2 (1024-dimensional) and stored in Pinecone, partitioned by namespace. Retrieval and reranking — top 6 candidates matched by cosine similarity, reranked with BGE-Reranker-v2-m3 down to the top 3 most relevant.

Answer generation — Gemini 2.5 Flash generates the answer from the reranked chunks plus the last 5 messages of conversation history, returning source citations with similarity scores. Frontend — React + TypeScript with drag-and-drop upload, real-time job status tracking, and a dashboard surfacing upload stats and chat analytics.

> results
85%
Retrieval relevance (top-3, semantic only)
92%
Retrieval relevance (top-3, after reranking)
< 5%
False positive rate
88% / 10% / 2%
Answer accuracy (human eval, n=50)
accurate / partial / incorrect
~1.5s
Query response time
target was under 2s
100+
Concurrent users tested
target was 50+

Reranking alone moved retrieval relevance from 85% to 92% at top-3 — a direct, measured before/after comparison.

> the lesson

The retrieval step is where most RAG systems actually win or lose — not the language model doing the final write-up. Reranking retrieved chunks before generation is what took this from "usually finds the right chunk" to "reliably finds the right chunk."