Skip to content
hritekuthaiahPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

DocChat — RAG Document Q&A Assistant

Ask natural-language questions about any PDF and get answers grounded in the document's actual content, with the source passages shown. Built from scratch to understand every part of a Retrieval-Augmented Generation (RAG) pipeline — no high-level framework hiding the internals.

What it does

  • Loads a PDF and splits it into overlapping text chunks
  • Embeds each chunk locally (free, on-device) and stores them in a Chroma vector database
  • Retrieves the most semantically relevant chunks for each question
  • Sends those chunks to the OpenAI API to generate a grounded answer
  • Refuses to answer ("I don't know based on the document") when the answer isn't in the source — reducing hallucination

How it works

Indexing (once): PDF -> chunk -> embed -> store in Chroma Answering (per Q): question -> embed -> retrieve top-k chunks -> LLM answers with that context

Tech stack

  • Python
  • OpenAI API (gpt-4o-mini) — answer generation
  • Chroma — local vector database + embeddings (all-MiniLM-L6-v2)
  • pypdf — PDF text extraction
  • python-dotenv — API key management

Setup

  1. Clone the repo and cd into it
  2. Create a virtual environment and install dependencies: python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
  3. Copy .env.example to .env and add your OpenAI API key
  4. Put a PDF named document.pdf in the folder
  5. Run it: python app.py
  6. Ask questions in the terminal; type quit to exit

Key design decisions

  • Chunk with overlap so meaning isn't split across boundaries
  • Embeddings run locally (free, private); only answer generation calls the API
  • A strict grounding prompt keeps answers faithful to the document
  • Index once, then loop on questions — retrieval stays fast, no re-embedding per query

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages