Skip to content

jigangz/ask-your-docs

Repository files navigation

🧾 Ask Your Docs — Answers with receipts

Turn any PDF, handbook, or contract into an assistant that answers with cited sources — and honestly says "I don't know" when the answer isn't in your documents.

The problem with most document chatbots: they make things up. This one can't — every claim carries a citation with an exact quote you can click and verify, and off-document questions get a refusal instead of a hallucination.

✨ What it does

  • Citations on every answer — each claim links to the exact passage it came from; click a citation chip and the source highlights in the Receipts panel
  • Refuses to guess — questions the documents don't cover get an honest "not in these documents" instead of invented facts
  • Confidence score — every answer shows how fully the sources support it
  • 3 preloaded sample libraries — employee handbook, product manual, lease agreement; zero signup to try
  • Upload your own — PDF / Markdown / TXT, parsed in your browser; chunks are embedded via the API and held in client memory only — nothing is stored server-side

🔧 How it works

Document ──► section-aware chunking ──► MiniLM embeddings (Transformers.js)
                                              │
Question ──► embed ──► hybrid retrieval ──────┤
             (dense cosine + BM25, fused      │
              with Reciprocal Rank Fusion)    ▼
                                   top-6 passages ──► Llama 3.3 70B (Groq)
                                                       strict JSON: answer +
                                                       citations + confidence
                                                       + refusal flag
  • Hybrid retrieval: semantic vector search catches meaning; BM25 catches exact terms (model numbers, dollar amounts); RRF fuses both rankings
  • Grounded generation: the model may only use retrieved passages; citations are validated server-side against the actual chunk ids
  • Zero database: sample embeddings are precomputed at build time; uploads live in browser memory. The whole thing deploys as a single Next.js app

🚀 Run locally

npm install
echo "GROQ_API_KEY=your_key_here" > .env.local   # free key at console.groq.com
npm run dev                                       # → http://localhost:3000

Rebuild the sample libraries (only needed if you edit content/samples/):

npm run build:samples

📦 Deploy

One-click on Vercel: import the repo, set GROQ_API_KEY, deploy. No database, no other services.

🧱 Stack

Next.js 16 (App Router) · TypeScript · Tailwind CSS 4 · Transformers.js (all-MiniLM-L6-v2) · Groq (llama-3.3-70b-versatile) · hand-rolled BM25 + RRF


Built by Jigang (Harry) Zhou — full-stack & AI engineer, Vancouver BC. FastAPI · Next.js · RAG · agents. Want this on your team's documents? Let's talk.

About

RAG document Q&A with clickable citations that refuses to hallucinate - hybrid retrieval (dense + BM25 + RRF), Groq Llama 3.3, in-browser embeddings, Next.js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors