Kartik Dhasmana

↑↓ moveenter openctrlk toggle

pdf-qa.md CASE STUDY

[03] AI · case study

PDF Q&A

Drop in a PDF and ask it questions in plain English. Every answer comes with the passages it was based on, so you can check it.

PDF Q&A: asking a question about an uploaded document

What it does

Upload a PDF of up to about 200 pages and ask anything about it. The app finds the parts of the document that matter for your question, hands them to an LLM and shows the answer next to the exact chunks it used.

It also remembers the conversation, so follow-up questions work the way you'd expect.

How it works

  1. readPulls the text out of the PDF with PyPDF2 and cleans it up.
  2. splitCuts it into ~1000-character chunks with 200 characters of overlap, breaking on sentence boundaries so ideas don't get cut in half.
  3. embedTurns every chunk into a 384-dimension vector with a small sentence-transformers model (MiniLM).
  4. indexStores the vectors in a FAISS index for exact similarity search.
  5. searchEmbeds the question the same way and pulls the 3 closest chunks.
  6. answerSends those chunks and the question to Llama 3.3 70B through the Groq API, then shows the answer with its sources.

The code is split into small modules that each do one job: config, PDF processing, chunking, embeddings, the vector store, retrieval, LLM calls and one that ties them together.

← All projects

Got a project or a role in mind? :)