palak563 commited on
Commit
1459c84
Β·
1 Parent(s): 04437e7

readme file updated

Browse files
Files changed (1) hide show
  1. my_env/README.md +68 -21
my_env/README.md CHANGED
@@ -19,6 +19,19 @@ This environment teaches an AI to make that decision smartly by looking at:
19
  The AI learns by getting **reward scores** β€” good decisions get high scores, bad decisions get low scores!
20
 
21
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  ## 🌱 Real World Problem It Solves
24
 
@@ -38,16 +51,27 @@ Every day the AI:
38
  4. **Learns** from the score and does better next time!
39
 
40
  ---
 
 
 
 
 
 
 
 
 
 
41
 
42
- ## πŸ’§ Actions (What AI Can Do)
43
 
44
- | Action | Water Added | When to Use |
45
- |--------|------------|-------------|
46
- | `none` | 0mm | Soil is wet enough or it's raining |
47
- | `low` | 10mm | Soil is slightly dry |
48
- | `medium` | 25mm | Soil is moderately dry |
49
- | `high` | 50mm | Soil is very dry |
50
 
 
 
 
 
 
 
51
  ---
52
 
53
  ## πŸ‘€ Observations (What AI Can See)
@@ -86,15 +110,17 @@ Every day the AI:
86
 
87
  ---
88
 
89
- ## πŸ“Š Scoring
90
 
91
  | Score | Meaning |
92
  |-------|---------|
93
- | 1.0 | Perfect moisture for current crop stage |
94
- | 0.5 | Acceptable but not ideal |
95
- | 0.0 | Wrong moisture level |
96
- | -0.5 | Very wrong (too wet or wasted water) |
97
- | -1.0 | Crop is dying (too dry!) |
 
 
98
 
99
  **Bonus:** AI gets penalized if it waters crops on rainy days (water waste!)
100
 
@@ -120,6 +146,16 @@ http://localhost:8000/docs
120
  ```
121
 
122
  ---
 
 
 
 
 
 
 
 
 
 
123
 
124
  ## πŸ§ͺ Test the Endpoints
125
 
@@ -140,7 +176,7 @@ curl -X POST http://localhost:8000/step \
140
  curl http://localhost:8000/tasks
141
  ```
142
 
143
- ### Run baseline agent:
144
  ```bash
145
  curl http://localhost:8000/baseline?city=Indore
146
  ```
@@ -163,15 +199,24 @@ python baseline.py --city Mumbai
163
  python baseline.py --city Delhi
164
  ```
165
 
166
- Expected output:
167
- ```
168
- Task 1 (Basic Moisture Control): 0.86
169
- Task 2 (Weather Adaptive): 0.68
170
- Task 3 (Full Season Management): 0.30
171
- Average Score: 0.61
172
- ```
173
 
174
  ---
 
 
 
 
 
 
 
 
 
175
 
176
  ## πŸ“ Project Structure
177
  ```
@@ -205,6 +250,8 @@ my_env/
205
  | `/grader` | POST | Get score for completed episode |
206
  | `/baseline` | GET | Run baseline agent, get scores |
207
  | `/docs` | GET | Interactive API documentation |
 
 
208
 
209
  ---
210
 
 
19
  The AI learns by getting **reward scores** β€” good decisions get high scores, bad decisions get low scores!
20
 
21
  ---
22
+ ## πŸ€– LLM Integration
23
+
24
+ This environment uses a Large Language Model (LLM) as the decision-making agent.
25
+
26
+ At each step:
27
+ - The current state is passed to the LLM
28
+ - The LLM reasons about irrigation needs
29
+ - It outputs a structured JSON action
30
+
31
+ This ensures:
32
+ - No hardcoded decision logic
33
+ - Fully AI-driven behavior
34
+ - Generalizable across tasks
35
 
36
  ## 🌱 Real World Problem It Solves
37
 
 
51
  4. **Learns** from the score and does better next time!
52
 
53
  ---
54
+ ## πŸ” RL Interaction Loop
55
+
56
+ 1. `reset()` β†’ initialize environment
57
+ 2. `state()` β†’ get observation
58
+ 3. LLM generates action
59
+ 4. `step(action)` β†’ environment updates
60
+ 5. reward returned (0–1)
61
+ 6. loop continues
62
+
63
+ This follows OpenEnv RL standards.
64
 
65
+ ## πŸ’§ Actions (LLM-Driven)
66
 
67
+ The AI agent generates actions dynamically using an LLM.
 
 
 
 
 
68
 
69
+ Each step returns:
70
+
71
+ - `irrigate`: true/false
72
+ - `water_amount`: value between 0–100
73
+
74
+ This enables flexible and intelligent irrigation decisions instead of fixed rules.
75
  ---
76
 
77
  ## πŸ‘€ Observations (What AI Can See)
 
110
 
111
  ---
112
 
113
+ ## πŸ“Š Scoring (Normalized Rewards)
114
 
115
  | Score | Meaning |
116
  |-------|---------|
117
+ | 1.0 | Perfect |
118
+ | 0.7 | Good |
119
+ | 0.4 | Acceptable |
120
+ | 0.1 | Poor |
121
+ | 0.0 | Failure |
122
+
123
+ All rewards are clamped between 0.0 and 1.0.
124
 
125
  **Bonus:** AI gets penalized if it waters crops on rainy days (water waste!)
126
 
 
146
  ```
147
 
148
  ---
149
+ ## πŸ€– Run LLM Inference Script
150
+
151
+ Set environment variables first:
152
+
153
+ ```bash
154
+ export API_BASE_URL="https://router.huggingface.co/v1"
155
+ export MODEL_NAME="meta-llama/Llama-3.3-70B-Instruct"
156
+ export HF_TOKEN="your_token_here"
157
+
158
+
159
 
160
  ## πŸ§ͺ Test the Endpoints
161
 
 
176
  curl http://localhost:8000/tasks
177
  ```
178
 
179
+ ### Run LLM evaluation script:
180
  ```bash
181
  curl http://localhost:8000/baseline?city=Indore
182
  ```
 
199
  python baseline.py --city Delhi
200
  ```
201
 
202
+ ## πŸ“Š Baseline Results (LLM Agent)
203
+
204
+ Task 1 (Basic Moisture Control): 1.00
205
+ Task 2 (Weather Adaptive): 0.98
206
+ Task 3 (Full Season Management): 0.80
207
+
208
+ Average Score: 0.93
209
 
210
  ---
211
+ ## βš™οΈ Environment Variables
212
+
213
+ The following variables are required:
214
+
215
+ - API_BASE_URL β†’ LLM endpoint
216
+ - MODEL_NAME β†’ model used for inference
217
+ - HF_TOKEN β†’ authentication token
218
+
219
+ Set them before running inference or deployment.
220
 
221
  ## πŸ“ Project Structure
222
  ```
 
250
  | `/grader` | POST | Get score for completed episode |
251
  | `/baseline` | GET | Run baseline agent, get scores |
252
  | `/docs` | GET | Interactive API documentation |
253
+ | `/ui` | GET | Interactive farm UI |
254
+ | `/inference-step` | POST | Single LLM decision |
255
 
256
  ---
257