Retrieval-Augmented Generation from an UPSC aspirant

Abhishek KumarAbhishek Kumar
4 min read

The Analogy: Constitution and RAG

Imagine the Indian Constitution. It is the supreme guiding text, but it is too vast for any individual to remember word-for-word. A UPSC aspirant or a judge cannot recall all 448 articles instantly.

Instead, they:

  • Retrieve the relevant article (say, Article 21 - Right to Life).

  • Interpret and generate an explanation using their knowledge, reasoning, and precedent.

That is exactly how RAG works:

  • The retriever is like a legal clerk who quickly finds the right constitutional provision or past judgment.

  • The generator is like a judge or policy expert, who reads the retrieved text and gives you a well-reasoned, contextual answer.

Without retrieval, an LLM is like a lawyer relying only on memory - it may hallucinate or misquote. With retrieval, it’s grounded in the actual "Constitution of knowledge" stored in your database.

But why RAG ?

In today’s world, where information is scattered like thousands of legal articles, acts, and constitutional provisions, Artificial Intelligence needs a way to be both knowledge-rich and context-aware. That’s exactly where RAG (Retrieval-Augmented Generation) comes into play.

RAG combines two superpowers:

  1. Retrieval – fetching the most relevant knowledge from a trusted database (like a digital law library).

  2. Generation – using a language model to answer queries in natural language.

Think of it as an AI lawyer who, before advising you, opens up the right law books, case laws, and constitutional articles to ensure the advice is grounded in facts.

How RAG Works (Step by Step)

  1. Query - User asks: “What are the fundamental duties of an Indian citizen?”

  2. Retriever - AI searches a knowledge base (like a digital constitution library) and finds Article 51A.

  3. Generator - AI then combines this retrieved article with its language ability to generate a clear, human-like explanation.

Instead of hallucinating duties, it gives:
“According to Article 51A, fundamental duties include respecting the Constitution, cherishing our heritage, protecting the environment, and striving for excellence in all spheres of life.”

This is precise, reliable, and backed by retrieval.

What Is RAG Retrieval-Augmented Generation? - Flattered with Flutter

Real-Life Example

Imagine you are a UPSC aspirant. You type into a RAG-based assistant:
"Tell me about Article 370 and its current status."

  • A normal LLM might give outdated or generic information.

  • A RAG-powered system retrieves the 2019 constitutional amendment and Supreme Court verdicts, and then explains:
    “Article 370 granted special status to Jammu & Kashmir. However, on 5th August 2019, the Parliament abrogated its provisions. The Supreme Court upheld this decision in 2023, stating...”

This is like having a Constitutional expert + Supreme Court library in your pocket.

Implementation of RAG (Technical Side)

  • Step 1: Create Knowledge Base - Load documents (constitution, acts, company policies, medical research, etc.) into a vector database (like Qdrant, Pinecone, Weaviate, FAISS). They will index it .

  • Step 2: Embeddings - Convert text into embeddings (numerical representations of meaning).

  • Step 3: Retrieval - When a user asks a query, fetch the top relevant chunks from the database.

  • Step 4: Generation - Pass both the query + retrieved chunks to an LLM (like GPT, LLaMA, or Mistral).

  • Step 5: Output - Get a contextual, grounded response.

Think of this pipeline as the Lok Sabha Question Hour:

  • A member asks a question (user query).

  • Relevant ministries provide official documents (retrieval).

  • The Minister explains with reasoning and policy context (generation).

The Tech Buffet #12: Improve RAG Pipelines With These 3 Indexing Methods

Uses of RAG

  1. Law & Governance - Legal assistants that retrieve correct constitutional provisions, acts, or case laws.

  2. Healthcare - Doctors asking AI: “What’s the recommended treatment for TB under WHO guidelines?” → AI retrieves WHO TB policy documents.

  3. Education (UPSC, CA, JEE prep) - Students can ask: “Summarize all constitutional amendments from 1950 to 2023.”

  4. Corporate - Employees query company HR policy instead of searching 200-page PDFs.

  5. Research & Journalism - AI journalist pulls verified government notifications before reporting.

Why RAG Matters

Our Constitution ensures governance is grounded in law, not random opinions.
Similarly, RAG ensures AI is grounded in facts, not hallucinations.

Just as a judge cannot invent a new article of the Constitution, an AI should not invent fake facts. RAG prevents this by always retrieving from the official source of truth.

0
Subscribe to my newsletter

Read articles from Abhishek Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abhishek Kumar
Abhishek Kumar

I have heart !