Adarsh290406/gov-scheme-env
๐๏ธ Gov Scheme Finder โ OpenEnv Environment
A real-world Reinforcement Learning environment where AI agents learn to match Indian citizens to the correct government schemes by asking smart questions.
Built for the OpenEnv Hackathon โ implements the full OpenEnv step() / reset() / state() API.
๐ Motivation
India has 500+ government welfare schemes but most citizens don't know which ones they qualify for. A rural farmer may miss out on crop insurance. A disabled student may never hear about disability scholarships. A BPL family may not know they qualify for free health insurance.
This environment trains AI agents to solve that problem โ by learning to ask the right questions and recommend the most relevant scheme for any citizen profile.
๐ฎ How It Works
reset() โ A new random citizen arrives (profile hidden from agent)
step() โ Agent asks a question OR recommends a scheme
state() โ Returns current known info about the citizenThe agent starts blind. It must ask smart questions to reveal information, then recommend the correct government scheme. Every wrong move costs reward.
๐๏ธ Action Space (14 actions)
๐ Reward System
Reward decay per step โ forces agent to be decisive.
๐ฎ RL Features
- Noise โ Citizens sometimes give wrong answers (10-20% on medium/hard)
- Scheme Expiry โ Schemes can expire mid-episode
- Incomplete Info โ Citizens sometimes say "I don't know"
- Partial Eligibility โ Partial match rewards
- Context-aware penalties โ Irrelevant questions penalized
- Weighted citizens โ Reflects real India demographics
๐ Tasks
๐ Project Structure
gov-scheme-env/
โโโ models.py # Pydantic models
โโโ environment.py # Core logic โ reset(), step(), state()
โโโ app.py # FastAPI server
โโโ inference.py # Hackathon inference script (API_BASE_URL, HF_TOKEN, MODEL_NAME)
โโโ baseline.py # Local baseline script (Groq)
โโโ generate_schemes.py # Auto-generates schemes.json
โโโ schemes.json # 67 real Indian government schemes
โโโ Dockerfile # HF Spaces deployment
โโโ openenv.yaml # Environment metadata
โโโ requirements.txt # Dependencies
โโโ tasks/
โโโ easy.py
โโโ medium.py
โโโ hard.py๐ Setup
git clone https://github.com/Adarsh290406/gov-scheme-env.git
cd gov-scheme-env
pip install -r requirements.txtRun server:
python app.pyRun baseline (local, uses Groq):
Create .env:
OPENAI_API_KEY=your_groq_key_herepython inference.pyRun inference script (hackathon, uses HF router):
Set environment variables:
API_BASE_URL=https://router.huggingface.co/v1
MODEL_NAME=meta-llama/Llama-3.1-8B-Instruct
HF_TOKEN=your_hf_token_herepython inference.pyDocker:
docker build -t gov-scheme-finder .
docker run -p 7860:7860 --env-file .env gov-scheme-finder๐ Baseline Scores
Model: llama-3.1-8b-instant via Groq (OpenAI-compatible)
The baseline agent uses a reasoning-driven approach โ it asks questions with the highest information gain per step (occupation โ disability/gender/land ownership โ confirm BPL), narrows the scheme space after each answer, and recommends confidently once enough attributes are confirmed. This makes it an effective RL training baseline: the agent genuinely reasons rather than guessing, so RL can learn from the reward signal in a meaningful way.
๐ ๏ธ Built With
Python 3.10+ | FastAPI | Pydantic | Uvicorn | OpenEnv | Groq
๐ License
MIT License
