Skip to content

mondalsou/regdociq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RegDocIQ

A minimal RAG (Retrieval-Augmented Generation) demo for PDF question-answering. Upload any PDF, ask questions, and get cited answers grounded in the document text.

No vector database. No embeddings. Just BM25 keyword retrieval + an LLM via OpenRouter.

How It Works

PDF → page chunks → BM25 search → top-k chunks → LLM → cited answer
  1. Extractpypdf reads the PDF page by page
  2. Chunk — text split into ~180-word overlapping windows
  3. Retrieve — BM25 scores chunks against the user's question
  4. Generate — top chunks sent as context to an LLM via OpenRouter
  5. Cite — the LLM is prompted to cite every claim with [Source N]

Stack

Component Choice
Retrieval BM25 (no embeddings needed)
LLM deepseek/deepseek-v4-flash via OpenRouter
UI Streamlit
PDF parsing pypdf

Quick Start

1. Clone and install

git clone https://github.com/mondalsou/regdociq.git
cd regdociq
pip install -r requirements.txt

2. Set your API key

cp .env.example .env
# edit .env and paste your OpenRouter API key

Get a free key at openrouter.ai/keys.

3. Run the Streamlit app

streamlit run streamlit_app.py

Open http://localhost:8501, upload a PDF, and start asking questions.

4. Or run the notebook

Open rag_demo.ipynb in Jupyter, set PDF_PATH to your PDF, and run all cells step by step.

jupyter notebook rag_demo.ipynb

Project Structure

regdociq/
├── streamlit_app.py   # Streamlit web app
├── rag_demo.ipynb     # Step-by-step notebook walkthrough
├── requirements.txt   # Python dependencies
└── .env.example       # API key template

Changing the Model

Edit MODEL_NAME at the top of streamlit_app.py or rag_demo.ipynb:

MODEL_NAME = "deepseek/deepseek-v4-flash"   # fast and cheap
# MODEL_NAME = "openai/gpt-4o-mini"         # alternative
# MODEL_NAME = "anthropic/claude-haiku-4-5" # alternative

Any model on OpenRouter works as a drop-in replacement.

License

MIT

About

Minimal PDF RAG demo: BM25 retrieval + LLM via OpenRouter. Upload any PDF, ask questions, get cited answers. No vector DB needed.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors