CoolFace
Apppublic

Yalpha/AGRITECH-META

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

๐ŸŒฑ AgriDecisionEnv v3 โ€“ Sustainable Farming RL Environment

OpenEnv Docker RL Sustainability Status

๐Ÿš€ Overview

AgriDecisionEnv v3 is a real-world OpenEnv-compatible environment designed to evaluate AI agents on multi-season agricultural decision-making under uncertainty, delayed effects, and resource constraints.

The environment models how farmers must balance:

  • โ€”๐ŸŒพ Crop yield (short-term productivity)
  • โ€”๐ŸŒ Soil health (long-term sustainability)
  • โ€”๐Ÿ’ง Water usage (groundwater limits)
  • โ€”๐Ÿ’ฐ Budget constraints (economic feasibility)

This environment evaluates agent performance under delayed rewards, stochastic climate conditions, and resource constraints, closely mimicking real-world agricultural decision-making.


๐ŸŒ Real-World Motivation

Over 33% of global arable land is degraded due to:

  • โ€”monocropping
  • โ€”excessive fertilizer use
  • โ€”unsustainable irrigation

Existing systems rely on static heuristics and fail under dynamic conditions.

๐Ÿ‘‰ This project provides a benchmark environment for training and evaluating intelligent agents capable of adaptive, long-term agricultural decision-making.


๐Ÿง  Environment Design

The environment simulates a farm across multiple seasons. At each timestep, the agent observes the current state and selects actions.

๐Ÿ” Interaction Loop

State โ†’ Agent โ†’ Action โ†’ Environment โ†’ New State + Reward


๐Ÿ“Š Scenario Initialization

ScenarioNitrogenMoistureGroundwaterBudget
default0.500.500.70120
fertile0.750.650.90150
drought0.450.200.35100
degraded0.250.450.6080

๐Ÿ” Observation Space

FieldTypeRangeDescription
nitrogenfloat[0, 1]Soil nitrogen level
moisturefloat[0, 1]Soil moisture level
soil_qualityfloat[0, 1]Derived soil health metric
last_cropstrrice/wheat/nonePrevious crop
seasonint[0, 10]Current timestep
weatherstrrainy/normal/droughtClimate condition
groundwaterfloat[0, 1]Available groundwater
budgetfloat[0, 150]Remaining resources

๐ŸŽฏ Action Space

FieldTypeRangeDescription
cropstrrice/wheat/noneCrop selection
fertilizerfloat[0, 1]Fertilizer level
irrigationfloat[0, 1]Irrigation level

โš™๏ธ Reward Function

reward = clamp( yield_score

  • โ€”soilqualitybonus
  • โ€”fertilizer_penalty
  • โ€”delayedfertilizerpenalty
  • โ€”irrigation_penalty
  • โ€”monocrop_penalty
  • โ€”groundwater_penalty
  • โ€”budget_penalty , 0.0, 1.0)

Key Properties

  • โ€”Dense reward signal (not sparse)
  • โ€”Penalizes unsustainable practices
  • โ€”Encourages long-term planning
  • โ€”Strictly normalized to [0.0, 1.0]

๐Ÿงช Task Design

๐ŸŸข Easy (1 step)

  • โ€”Objective: maximize immediate yield
  • โ€”Deterministic
  • โ€”No delayed effects

๐ŸŸก Medium (3 steps)

  • โ€”Objective: balance yield and soil improvement
  • โ€”Introduces temporal dependencies
  • โ€”Penalizes overuse

๐Ÿ”ด Hard (5 steps)

  • โ€”Includes:
  • โ€”stochastic weather
  • โ€”delayed fertilizer effects
  • โ€”groundwater depletion
  • โ€”budget constraints

๐Ÿ‘‰ Tests long-term sustainability strategies


๐Ÿ“ˆ Baseline Results

LLM Agent (via OpenAI client + HF router)

TaskScore
Easy0.47
Medium0.36
Hard0.33

Rule-Based Baselines

AgentAvg RewardFinal SoilFinal Budget
Random0.350.88-58.0
Greedy0.350.54-47.5
Rule-Based0.180.262.5

๐Ÿ‘‰ Rule-based agent conserves budget but trades off yield; greedy/random overspend


๐Ÿค– Inference (OpenAI Client)

The agent uses the OpenAI client interface for all LLM calls.

Required environment variables:

  • โ€”APIBASEURL
  • โ€”MODEL_NAME
  • โ€”HF_TOKEN

Logging Format (STRICT)

[START] [STEP] [END]

โœ” Required for evaluation โœ” Fully reproducible


๐Ÿงฑ Project Structure

agriv3/ โ”œโ”€โ”€ models.py โ”œโ”€โ”€ env.py โ”œโ”€โ”€ tasks/ โ”œโ”€โ”€ baselineagents.py โ”œโ”€โ”€ inference.py โ”œโ”€โ”€ openenv.yaml โ”œโ”€โ”€ Dockerfile โ””โ”€โ”€ README.md


โš™๏ธ Setup & Usage

Local

pip install pydantic openai HFTOKEN=yourtoken python inference.py

Docker

docker build -t agri-env . docker run -e HFTOKEN=yourtoken agri-env

Hugging Face Spaces

  • โ€”SDK: Docker
  • โ€”Tag: openenv
  • โ€”Must respond to /reset

โœ… OpenEnv Compliance

  • โ€”reset() โ†’ Observation
  • โ€”step(action) โ†’ (Observation, float reward, done, info)
  • โ€”state() โ†’ Observation

โœ” Typed models โœ” Deterministic grading โœ” Reward range [0,1] โœ” Docker-compatible


๐Ÿง  Why This Matters

This environment models:

  • โ€”real agricultural trade-offs
  • โ€”long-term sustainability challenges
  • โ€”constrained decision-making under uncertainty

๐Ÿ‘‰ Useful for:

  • โ€”RL benchmarking
  • โ€”LLM evaluation
  • โ€”policy simulation

๐Ÿ Conclusion

AgriDecisionEnv v3 is a realistic and scalable benchmark for evaluating intelligent agents in sustainable agriculture โ€” where short-term gains often conflict with long-term survival.