rag-citations / README.md
BonusLockSMith's picture
#10 RAG Q&A with Citations - construction KB (private validation build)
7110676 verified
|
Raw History Blame Contribute Delete
2.09 kB
---
title: RAG Q&A with Citations
emoji: πŸ“š
colorFrom: gray
colorTo: indigo
sdk: docker
app_port: 7860
pinned: false
short_description: Grounded, cited answers over a construction KB Β· 30-in-15 #10
---
# RAG Q&A with Citations πŸ“š
Ask a question and get an answer **grounded only in a curated knowledge base**, with **inline `[n]`
citations** to the exact sources β€” and an honest **"I don't know"** when the answer isn't in the KB.
No hallucinating past the sources. Demo knowledge base: **construction & home remodeling**.
> Project **#10** of my *"30 AI Projects in 15 Days"* build-in-public challenge.
**β–Ά Live demo: https://ask.gritai.solutions**
![demo](demo.png)
## Why it's different
Most chatbots will confidently make things up. This one is **retrieval-grounded and attributed**: it
answers *only* from the sources it retrieved, cites each claim, and refuses to guess when the KB doesn't
cover the question. That's the pattern real production RAG needs β€” trust and traceability.
## How it works
- **Chunk β†’ embed β†’ retrieve β†’ answer.** The KB is embedded with **fastembed** (`BAAI/bge-small-en-v1.5`,
ONNX/CPU β€” no GPU, no torch). A question is embedded and matched by cosine similarity to the top sources.
- **Grounded answer with forced tool-use:** Claude answers using only the retrieved sources, returns
inline `[n]` citations, and a `found` flag β€” if the sources don't answer the question, it says so.
- The UI shows the answer with clickable citations and the exact source passages below.
## Run locally
```bash
pip install -r requirements.txt
export ANTHROPIC_API_KEY=sk-ant-...
python app.py # http://127.0.0.1:7860
```
## Deploy (always-on)
Ships with a `Dockerfile` β€” works on **Hugging Face Spaces**, Render, Railway, or Fly.io.
Set `ANTHROPIC_API_KEY` as a secret. Embeddings are local (no other keys).
*Pro tier (roadmap): point it at your own private document set β€” hosted, grounded, cited.*
---
Built by **Robert Lucyk** Β· [GritAI Solutions](https://gritai.solutions) Β· part of the 30-in-15 challenge.