Spaces:
Running
Running
File size: 2,094 Bytes
7f8e91d 7110676 7f8e91d 7110676 7f8e91d 7110676 7f8e91d 7110676 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ---
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**

## 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.
|