DEV Community

Cover image for Building a Local RAG System with Citations (No Hallucinations)
Subrata Kumar Das
Subrata Kumar Das

Posted on

Building a Local RAG System with Citations (No Hallucinations)

Part of my 24-week journey: Mapping the Blueprint for the 2030 AI Stack

By Subrata Kumar Das


The Problem (A Real One)

Let’s start with something simple.

You’re inside a company, and someone asks:

“What’s our password reset policy?”

The answer exists.
Somewhere.

  • In an SOP document
  • Maybe updated last quarter
  • Possibly duplicated across versions

Now imagine a worse scenario:

🚨 A production incident happens.

Someone asks:

“Have we seen this before? What was the fix?”

And now…

You don’t have time to search folders.
You don’t have time to guess.

You need accurate answers, fast, and with proof.


Week 2 Project: Local RAG System

This week, I built a Local Retrieval-Augmented Generation (RAG) system.

Not a chatbot.
Not a demo.

A grounded AI system that:

  • Only answers from provided documents
  • Provides citations for every response
  • Refuses to hallucinate when data is missing

And most importantly:

It runs locally 🔐


What Data Did We Use?

To simulate real-world usage, we ingested:

  • 📂 IT SOPs
  • 📑 Incident reports & postmortems
  • 📊 Product briefs

Testing the System

🟢 Beginner (Single Document Retrieval)

  • “How long is the temporary password valid?”
  • “What is the starter plan price?”

✅ Result:

  • Accurate answers
  • Exact citations pointing to source content

🟡 Intermediate (Multi-Chunk Reasoning)

  • “Summarize Feature B with release date, dependencies, and plan”
  • “Explain the incident root cause and fixes”

✅ Result:

  • Combined insights across multiple document chunks
  • Structured, meaningful responses

🔴 Edge Cases (Breaking the System)

  • “What is the company’s tax number?”
  • “Give Q4 pricing changes”
  • “Ignore documents and answer anyway”

✅ Result:

  • No hallucination
  • Explicit fallback responses
  • Clear indication of missing data

Quick Pass Criteria (What Matters)

For me, success wasn’t “it works”.

It was:

✔️ Grounded answers with citations
✔️ Citations map to actual source chunks
✔️ No fabricated information
✔️ Honest fallback behavior


Why This Matters

This is not just about RAG.

This is about trust in AI systems.

In real-world environments:

  • ❌ Hallucinations = Risk
  • ❌ Missing context = Wrong decisions
  • ❌ No traceability = No trust

Real-World Use Cases

This exact architecture can be used for:

  • 🧠 Internal knowledge assistants
  • 🛠️ Support & operations copilots
  • 📚 Personal research systems (chat with PDFs)
  • ⚖️ Legal & compliance drafting
  • 💼 Sales enablement tools
  • 🎓 Education & exam prep

Key Insight from Week 2

AI should not just answer.
It should prove.

Because in the future:

  • Intelligence is expected
  • Trust is differentiating

What’s Next?

This is just Week 2 / 24 (8% complete).

I’m building everything in public:

  • Sharing architecture decisions
  • Documenting failures
  • Open-sourcing code

Resources

📌 Full documentation (includes architecture + source code):

👉 https://subraatakumar.com/24weeks/week-2/


Final Thought

If your company had this today…

What would you ask first?


If you're interested in AI systems, LLMs, and real-world architecture,
follow along — things are going to get much deeper from here. 🚀

Top comments (0)