RavindranadhM/schemesaathi
Note for GitHub visitors: The table above is required configuration for the HuggingFace Spaces deployment. It is not part of the documentation.
SchemeSaathi ๐ฎ๐ณ
<div align="center">
<br>
Production-grade agentic RAG system for discovering Indian government welfare schemes.
**๐ Live Demo** ยท **๐ GitHub**
</div>
Problem Statement
India has 3,400+ central and state welfare schemes covering agriculture, education, health, housing, employment, and social welfare. Most eligible citizens never find them โ due to language barriers, complex documentation, and poor discoverability. SchemeSaathi solves this with a stateful AI agent grounded in official government data.
Live Demo
โ [huggingface.co/spaces/RavindranadhM/schemesaathi](https://huggingface.co/spaces/RavindranadhM/schemesaathi)
Example queries to try:
- "I am a 35-year-old SC farmer in Karnataka with income โน80,000. What schemes am I eligible for?"
- "I am a widow in Maharashtra from a BPL family. What pension schemes exist?"
- "BTech student in Bangalore โ what scholarships and internship schemes are available?"
- "What is PM KISAN and who is eligible?"
System Architecture
User Query (English or Hindi)
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Semantic Cache โ โโโโ HIT โโโ Response in ~50ms
โ Redis + cosine 0.92 โ
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โ MISS
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Scope Gate โ Pure keyword classifier โ zero LLM cost
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Profile Parser โ 60+ cityโstate mappings + regex
โ โ Groq Llama-3.1-8B fallback for Hindi
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Hybrid Retriever โ BGE-M3 dense cosine similarity
โ โ Name-boosted exact scheme matching
โ โ Profile-aware re-scoring:
โ โ Central +0.05 (all citizens)
โ โ Matching state +0.15
โ โ Other state โ0.10
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Grader โ Vector score threshold โฅ 0.55
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Generator โ Groq โ Llama-3.3-70B, grounded with citations
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Memory Node โ Session summary, Groq Llama-3.1-8B
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โผ
Final ResponseEvaluation
Evaluated on a 15-query golden dataset using Llama-3.3-70B as judge (no OpenAI dependency):
Tech Stack
Data Pipeline
myscheme.gov.in CSV (3,400 schemes)
โ
โผ
Hierarchical Chunker
โโโ Summary chunks ~200 tokens โ parent chunk, broad retrieval
โโโ Section chunks ~400 tokens โ eligibility / benefits / documents / process
โโโ Fact chunks ~80 tokens โ numeric facts, amounts, age limits
โ
โผ
BGE-M3 Embeddings โ 27,262 chunks ร 1024 dimensions
โ
โผ
Qdrant Vector Store
โโโ Payload indexes: level ยท chunk_type ยท scheme_id ยท parent_idKey Engineering Decisions
Metadata-first retrieval โ Every chunk carries 15 metadata fields. Hard pre-filtering by state and level cuts the search space ~85% before vector search runs.
Profile-aware re-scoring โ Central schemes +0.05 (apply to all citizens). Matching-state schemes +0.15. Other-state schemes โ0.10. Eliminates irrelevant state-specific results.
1 LLM call per query โ Scope gate (keyword), grader (vector threshold), and profile parser (regex + city mapping) run without LLM. Only the generator uses Groq โ efficient on free-tier quotas.
City-to-state resolution โ 60+ Indian cities mapped to states at query time. "Bangalore" โ Karnataka. Improves retrieval without extra API calls.
Semantic caching โ Query embeddings cached in Redis with cosine similarity lookup. Cache hits ~50ms vs ~25s full pipeline.
Project Structure
schemesaathi/
โโโ ingestor/
โ โโโ data_loader.py CSV โ structured scheme dicts
โ โโโ cleaner.py Text normalisation
โ โโโ chunker.py Hierarchical chunking (summary/section/fact)
โ โโโ embedder.py BGE-M3 dense embeddings
โ โโโ qdrant_loader.py Upload with metadata payload indexes
โ
โโโ agent/
โ โโโ graph.py LangGraph StateGraph definition
โ โโโ state.py AgentState TypedDict
โ โโโ prompts.py All prompts
โ โโโ nodes/
โ โโโ cache_check.py Redis semantic cache lookup
โ โโโ scope_gate.py Keyword scope classifier
โ โโโ profile_parser.py City-to-state + keyword extraction
โ โโโ retriever.py Hybrid retrieval + profile re-scoring
โ โโโ grader.py Vector score threshold filter
โ โโโ generator.py Groq Llama-3.3-70B generation
โ โโโ memory.py Session summary compression
โ
โโโ api/
โ โโโ main.py FastAPI app + CORS + static files
โ โโโ routes/
โ โโโ query.py POST /query โ rate limited
โ โโโ health.py GET /health
โ
โโโ eval/
โ โโโ ragas_eval.py Evaluation pipeline
โ โโโ score_responses.py LLM-as-judge scoring
โ โโโ results/ RAGAS scores JSON
โ
โโโ frontend/
โโโ index.html Single-file production UILegal
Data sourced from myscheme.gov.in under the National Data Sharing and Accessibility Policy (NDSAP). For informational purposes only โ verify eligibility at official government portals before applying.
<div align="center">
Built by Ravindranadh M ยท B.Tech Robotics & Automation ยท REVA University, Bengaluru
</div>
