The Architecture, End to End
📄 Ingest
Documents are read — OCR for scans — and split into chunks with metadata (document, page, section) preserved.
🧠 Index
Chunks are embedded and stored in a vector store for semantic search; a keyword index (BM25) runs alongside.
🔎 Retrieve
At query time, hybrid retrieval (keyword + semantic) finds the relevant passages, fused and re-ranked.
📎 Generate
The model answers only from retrieved context, attaching inline citations to the exact passages.
✅ Verify
Users open citations and check; evaluation measures retrieval quality and answer accuracy continuously.
For the hands-on build, start with How to Build a RAG System in 30 Minutes (Local, Free) — a working prototype with Ollama and ChromaDB — then harden it with the pieces below.
Retrieval Quality Is the Ceiling
Every answer is limited by what retrieval finds. Two decisions dominate:
- Hybrid retrieval. Keyword (BM25) catches exact terms, citations, and IDs; semantic vectors catch paraphrase. Fused and re-ranked, they beat either alone. See What Is Hybrid Search?.
- Chunking with context. Legal and technical documents need document-aware or contextual chunking so meaning survives the split. See Advanced RAG: Chunking Strategies Compared.
Grounded Generation: Answer Only From What You Retrieved
Grounding is a hard instruction: the model may answer only from the retrieved passages — no memory, no invention — and must attach citations to specific chunks. Enterprise RAG deployments report 70–90% hallucination reduction versus memory-based generation. The remaining errors are what citations and evaluation catch.
⚠️ Citation-shaped hallucinations are real. Systems invent page numbers and document titles that don't exist. Build a verification step: every citation must resolve to an actual chunk in the index. Test it by opening citations — see RAG Evaluation.
Proving It: The Verification Layer
"Proves it" has two meanings, and you need both:
- To the user: inline citations they can click and check. This is the trust layer — see RAG With Citations Is Now Table Stakes.
- To the organization: continuous evaluation — retrieval recall, answer accuracy against a labeled set, and citation resolution rate. This is the production layer.
A complete, working reference for both is Lawyer Assistant: hybrid search, cited answers, 96% citation accuracy in its own benchmarks, and 100% on-device privacy. Architecture in Lawyer Assistant: A Privacy-First Legal AI Built on a Local RAG Pipeline.
Run It Where Your Documents Live
For most organizations, the documents that matter most are the ones that can't leave the building — contracts, patient records, financials, proprietary specs. The RAG stack above runs entirely on your own hardware: embeddings, vector store, and model all local, with nothing sent to a third party. Private RAG for regulated work is covered in Private RAG for Regulated Industries.
Frequently Asked Questions (FAQ)
How does a RAG system answer from my documents?
Your documents are chunked, embedded, and indexed. When a question arrives, the system retrieves the most relevant passages, then the model answers using only that context. Grounding answers in retrieved documents reduces hallucinations by an estimated 70-90%.
How does it prove where the answer came from?
With citations: each claim links to the exact document, page, and passage it came from. Users open the citation and verify. The system should also be evaluated — retrieval quality, answer accuracy, and citation resolution — so errors are caught, not trusted.
What are the key components?
Ingestion with OCR, chunking with metadata, embeddings, a vector store, hybrid retrieval (BM25 + semantic), reranking, grounded generation, a citation layer, and continuous evaluation.
How long does it take to build a basic version?
A working local prototype with Ollama and ChromaDB can be built in about 30 minutes for a small corpus. Production quality — hybrid retrieval, reranking, citations, evaluation — takes longer, but the 30-minute starter is a real foundation.
What's the difference from just asking ChatGPT?
ChatGPT answers from memory and can't show you its source. A RAG system answers from your documents and cites them — verifiable, grounded, and private when run locally.
🔍 Need a RAG system that answers from your documents?
I design and deploy retrieval systems with citation-grounded answers — for legal, healthcare, finance, and enterprise knowledge work, through Haal Lab. Contact me for a scoping conversation.