~ portfolio

Satvik Sawhney

software engineer

loading000%
case studyshipped

Ask Your PDF.

Public RAG reference demo · FAISS + OpenAI Ada-2

Most RAG tutorials skip the part where you decide why FAISS instead of pgvector — and that decision matters more than the demo.
askyourpdf · faiss + ada-290% retrieval
pdf
chunks → embeddings
answer
01the problem

Document Q&A is a clear win for retrieval: a user has a 50-page PDF and a question, and a model that's seen the whole file at once can answer better than one searching keywords. But building it requires opinionated choices (chunking, embedding model, index, scoring) that public examples often hand-wave. I wanted to ship a reference that made the choices visible.

02the approach

PDFs get chunked, embedded with OpenAI Ada-2, and indexed in FAISS. At query time the user's question gets embedded and the top-k chunks come back ranked by similarity, fed to the LLM with the question for a grounded answer. The Streamlit UI keeps everything front-and-center so the data flow is observable — chunks shown, scores shown, answer shown.

03decisions i made

The choices that mattered, with the reasoning at the time.

  1. FAISS over pgvector / managed vector stores

    FAISS is in-process, well-documented, and the de facto starting point for vector search — exactly the right call for a reference app where the goal is teaching rather than scaling. Anyone forking it can swap to pgvector or a managed store if their production constraints demand it.

    decision · 01
  2. OpenAI Ada-2 for embeddings

    Ada-2 was the strongest off-the-shelf embedding at the time with a reasonable cost-per-token. Hitting 90% retrieval accuracy on PDFs typical of the use case told me the embedding choice was carrying its weight rather than being the bottleneck.

    decision · 02
  3. Streamlit, not Next.js

    Streamlit lets a Python-only contributor iterate on the retrieval pipeline without context-switching to a JS toolchain. For a learning artifact that's the right trade — the lesson is the pipeline, not the UI.

    decision · 03
05what happened

Shipped as a public reference: working end-to-end on real PDFs, 90% retrieval accuracy, 35% faster query turnaround than the keyword-search baseline for the same documents. Published with the codebase open and a video walkthrough.

retrieval accuracy
90%
vs keyword search
+35%
embedding model
Ada-2
06what i’d do differently

Ada-2 is now superseded — text-embedding-3-small / -large are the obvious upgrade for both quality and cost. If I were teaching this today I'd also include a chunking-strategy comparison (fixed-window vs semantic vs structural), since chunking matters at least as much as the embedding choice and most demos skip it.

stack
PythonStreamlitLangChainFAISSOpenAI
Ask Your PDF — Satvik Sawhney