CoolFace
Apppublic

RavindranadhM/schemesaathi

sourceHugging Facemitupdated 3mo agoView on Hugging Face
1likes
App README
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">

Python FastAPI LangGraph Qdrant BGE-M3 Groq Redis License

<br>

Production-grade agentic RAG system for discovering Indian government welfare schemes.

**๐Ÿš€ Live Demo** &nbsp;ยท&nbsp; **๐Ÿ“– 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 Response

Evaluation

Evaluated on a 15-query golden dataset using Llama-3.3-70B as judge (no OpenAI dependency):

MetricScore
Answer Relevancy0.95
Context Precision0.86
Overall0.77

Tech Stack

ComponentTechnology
Agent OrchestrationLangGraph 1.0 โ€” stateful graph, 6 nodes
Vector StoreQdrant Cloud โ€” 27,262 chunks, HNSW index, 4 payload indexes
EmbeddingsBGE-M3 (BAAI/bge-m3) โ€” 1024-dim dense, Hindi + English
LLM GenerationGroq Llama-3.3-70B
LLM Memory / ParsingGroq Llama-3.1-8B
Semantic CacheRedis โ€” cosine similarity, 0.92 threshold, 24h TTL
APIFastAPI + SlowAPI โ€” async, 10 req/min per IP
Data3,400 schemes from myscheme.gov.in (NDSAP licensed)

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_id

Key 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 UI

Legal

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 &nbsp;ยท&nbsp; B.Tech Robotics & Automation &nbsp;ยท&nbsp; REVA University, Bengaluru

</div>