pushpam14 commited on
Commit
234641b
Β·
verified Β·
1 Parent(s): 38d66e6

Rename Spaces title to Enterprise Contract Guardian

Browse files
Files changed (1) hide show
  1. README.md +36 -28
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: API Contract Validator
3
  emoji: πŸ“‹
4
  colorFrom: blue
5
  colorTo: green
@@ -15,8 +15,12 @@ pinned: false
15
  > **Meta PyTorch OpenEnv Hackathon Γ— Scaler School of Technology β€” Grand Finale Submission**
16
  > **Theme #3.1**: World Modeling β†’ Professional Tasks Β· ⭐ **Scaler AI Labs bonus track**: Multi-App RL Environment for Enterprise Workflows
17
 
 
 
18
  An OpenEnv RL environment that trains agents to do what senior platform engineers do when an API breaks in production: **detect the violation, trace which downstream services are affected, propose a backward-compatible fix, and verify the fix doesn't cascade**.
19
 
 
 
20
  ## The Story
21
 
22
  > An engineer ships a "small" change to the Users API on Friday evening. It passes local tests. On Monday, **four downstream teams break** β€” the Orders service, the Billing pipeline, the Notification worker, and the Analytics ETL. The root cause: a single field renamed in one spec, with no awareness of who consumed it.
@@ -256,47 +260,50 @@ openenv validate
256
 
257
  ## Training Results β€” Before vs After
258
 
259
- > **Training**: GRPO via TRL + Unsloth Β· **Hardware**: HuggingFace Jobs T4 GPU
260
- > **Why we report both**: per the hackathon judging criteria, "Improvement in Rewards" (20%) requires a baseline-vs-trained comparison. The grader looks at the delta, not absolute numbers.
261
 
262
  ### Reward Curve (training progress)
263
 
264
- <!-- Embedded after training run; uncomment + push the .png:
265
  ![Reward Curve](results/reward_curve.png)
266
- *Mean episode reward across training steps. Rising curve = GRPO is finding higher-reward completions over time.*
267
- -->
268
 
269
- *To be added after the onsite GRPO run (Apr 25–26). The plot is auto-generated by [`training/train.py`](training/train.py) and saved as `results/reward_curve.png`.*
270
 
271
  ### Before vs After β€” per-task comparison
272
 
273
- <!-- Embedded after training run; uncomment + push the .png:
274
  ![Before vs After](results/before_after.png)
275
- *Bar chart: baseline (grey) vs GRPO-trained adapter (green). Side-by-side per task.*
276
- -->
277
 
278
- | Task | Phase | Baseline (Qwen2.5-72B) | Trained (Qwen2.5-1.5B + LoRA) | Ξ” |
 
 
279
  |---|---|---|---|---|
280
- | `find_type_mismatches` | 1 | 0.75 | _(after training)_ | _Ξ”_ |
281
- | `validate_nested_objects` | 1 | 0.99 | _(after training)_ | _Ξ”_ |
282
- | `detect_breaking_changes` | 1 | **0.01** | _(after training)_ | _largest delta expected here_ |
283
- | `validate_response_schema` | 1 | 0.99 | _(after training)_ | _Ξ”_ |
284
- | `validate_cross_field_constraints` | 1 | 0.86 | _(after training)_ | _Ξ”_ |
285
- | `validate_auth_request` | 1 | 0.99 | _(after training)_ | _Ξ”_ |
286
- | `trace_downstream_blast_radius` | 2 | 0.67 | _(after training)_ | _Ξ”_ |
287
- | `propose_backward_compat_fix` | 3 | 0.99 | _(after training)_ | _Ξ”_ |
288
- | `multi_service_cascade_fix` | 2+3 | 0.99 | _(after training)_ | _Ξ”_ |
289
- | **Mean** | | **0.82** | _(after training)_ | _Ξ”_ |
290
-
291
- Full per-step rewards in [`../baseline_scores.json`](../baseline_scores.json) (before) and [`../trained_scores.json`](../trained_scores.json) (after β€” generated post-training).
 
 
 
 
 
 
 
 
292
 
293
  | Phase | WandB Run | Notebook |
294
  |---|---|---|
295
- | GRPO (Phase 1 + Phase 2/3) | *(link after training)* | [`training/grpo_colab.ipynb`](training/grpo_colab.ipynb) |
296
-
297
- See [`training/README.md`](training/README.md) for the three ways to run the pipeline (Colab / HF Jobs / local).
298
 
299
- **Where to expect the biggest delta**: `detect_breaking_changes` at 0.01 β€” the 72B baseline finds the right field paths (proximity hits) but never predicts `violation_type='breaking_change'` correctly. GRPO should lift this substantially because the env's grader gives a clear +1.0 vs +0.3 vs -0.3 signal that the policy can directly optimise for.
300
 
301
  ## Why This Matters
302
 
@@ -317,11 +324,12 @@ This is a genuinely underexplored domain in RL/LLM training β€” no prior benchma
317
  | HuggingFace Space (live env) | https://huggingface.co/spaces/pushpam14/api-contract-validator |
318
  | Live env endpoint | https://pushpam14-api-contract-validator.hf.space |
319
  | Health check | https://pushpam14-api-contract-validator.hf.space/health |
 
 
320
  | Training Notebook (Colab) | [`training/grpo_colab.ipynb`](training/grpo_colab.ipynb) |
321
  | Story + Technical Guide | [`ENTERPRISE_CONTRACT_GUARDIAN_STORY.md`](ENTERPRISE_CONTRACT_GUARDIAN_STORY.md) |
322
  | GitHub repo | https://github.com/kumarpushpam17-personal/Hackathon |
323
  | Demo Video / HF Blog | *(add after recording)* |
324
- | WandB Training Run | *(add after training)* |
325
 
326
  Quick test:
327
 
 
1
  ---
2
+ title: Enterprise Contract Guardian
3
  emoji: πŸ“‹
4
  colorFrom: blue
5
  colorTo: green
 
15
  > **Meta PyTorch OpenEnv Hackathon Γ— Scaler School of Technology β€” Grand Finale Submission**
16
  > **Theme #3.1**: World Modeling β†’ Professional Tasks Β· ⭐ **Scaler AI Labs bonus track**: Multi-App RL Environment for Enterprise Workflows
17
 
18
+ > πŸ“› **Naming**: **Enterprise Contract Guardian** is the product name. The codename in URLs and source paths is `api-contract-validator` (HF Space slug, Python package, Hub adapter repo). Both refer to the same artifact β€” the HF Spaces title now reflects the product name; the URLs were not changed because they would invalidate every linked artefact.
19
+
20
  An OpenEnv RL environment that trains agents to do what senior platform engineers do when an API breaks in production: **detect the violation, trace which downstream services are affected, propose a backward-compatible fix, and verify the fix doesn't cascade**.
21
 
22
+ > πŸ“– **Read this first**: [`ENTERPRISE_CONTRACT_GUARDIAN_STORY.md`](ENTERPRISE_CONTRACT_GUARDIAN_STORY.md) β€” full product narrative + technical guide with diagrams, two real-world incident walkthroughs, complete reward criteria, and the training loop.
23
+
24
  ## The Story
25
 
26
  > An engineer ships a "small" change to the Users API on Friday evening. It passes local tests. On Monday, **four downstream teams break** β€” the Orders service, the Billing pipeline, the Notification worker, and the Analytics ETL. The root cause: a single field renamed in one spec, with no awareness of who consumed it.
 
260
 
261
  ## Training Results β€” Before vs After
262
 
263
+ > **Training**: GRPO via TRL + Unsloth Β· **Hardware**: HuggingFace Jobs L4 (24 GB) Β· **Steps**: 300 Β· **Wall-time**: 1 h 56 min
264
+ > **Why we report both**: per the hackathon judging criteria, "Improvement in Rewards" (20%) requires a baseline-vs-trained comparison. The grader looks at the delta on the right tasks, not absolute numbers.
265
 
266
  ### Reward Curve (training progress)
267
 
 
268
  ![Reward Curve](results/reward_curve.png)
 
 
269
 
270
+ *Mean episode reward across 300 GRPO training steps on Qwen2.5-7B-Instruct (4-bit + LoRA r=16). Mean reward stays in the 1.0–1.5 range across training because the base 7B model already produces valid actions; the curve's value is in **what specific tasks improved**, captured in the bar chart below.*
271
 
272
  ### Before vs After β€” per-task comparison
273
 
 
274
  ![Before vs After](results/before_after.png)
 
 
275
 
276
+ *Per-task score, baseline 72B (grey) vs trained 7B + LoRA (green). The headroom task `detect_breaking_changes` is the standout β€” the trained model is **44Γ— better** there.*
277
+
278
+ | Task | Phase | Baseline (Qwen2.5-72B) | Trained (Qwen2.5-7B + LoRA) | Ξ” |
279
  |---|---|---|---|---|
280
+ | `find_type_mismatches` | 1 | 0.75 | 0.75 | β‰ˆ |
281
+ | `validate_nested_objects` | 1 | 0.99 | 0.57 | ↓ |
282
+ | **`detect_breaking_changes`** | 1 | **0.01** | **0.44** | **+44Γ—** ⭐ |
283
+ | `validate_response_schema` | 1 | 0.99 | 0.50 | ↓ |
284
+ | `validate_cross_field_constraints` | 1 | 0.86 | 0.29 | ↓ |
285
+ | `validate_auth_request` | 1 | 0.99 | 0.33 | ↓ |
286
+ | `trace_downstream_blast_radius` | 2 | 0.67 | 0.99 | ↑ |
287
+ | `propose_backward_compat_fix` | 3 | 0.99 | 0.99 | = |
288
+ | `multi_service_cascade_fix` | 2+3 | 0.99 | 0.99 | = |
289
+ | **Mean** | | **0.82** | **0.65** | model is 8Γ— smaller |
290
+
291
+ Full per-step rewards in [`../baseline_scores.json`](../baseline_scores.json) (before) and [`../trained_scores.json`](../trained_scores.json) (after).
292
+
293
+ ### What the comparison shows
294
+
295
+ The trained model is a **Qwen2.5-7B + LoRA r=16 adapter** β€” roughly **8Γ— smaller** than the Qwen2.5-72B baseline. The interesting outcomes:
296
+
297
+ - **`detect_breaking_changes` went from 0.01 β†’ 0.44**. The 72B baseline knew where to look (proximity hits) but never predicted `violation_type='breaking_change'` correctly. GRPO taught the smaller model the exact action format the env grader rewards. *This is the strongest piece of evidence that the env trains a real capability.*
298
+ - **Phase 2 / Phase 3 tasks** (`trace_downstream_blast_radius`, `propose_backward_compat_fix`, `multi_service_cascade_fix`): trained 7B matches or exceeds the 72B baseline despite being 8Γ— smaller.
299
+ - **Some Phase 1 tasks regressed** (`validate_nested_objects`, `validate_response_schema`, etc.). The trained model picks correct first violations, then frequently mode-collapses into duplicate reports. With more diverse sampling (higher temperature, more `num_generations`) this would close.
300
 
301
  | Phase | WandB Run | Notebook |
302
  |---|---|---|
303
+ | GRPO main run (Qwen-7B, 300 steps) | https://wandb.ai/pushpamsubscriptions-inn/openenv-contract-guardian/runs/gch0eg3k | [`training/grpo_colab.ipynb`](training/grpo_colab.ipynb) |
304
+ | Trained adapter | https://huggingface.co/pushpam14/api-contract-validator-grpo-7b | β€” |
 
305
 
306
+ See [`training/README.md`](training/README.md) for the three ways to run the pipeline (HF Jobs / Colab / local).
307
 
308
  ## Why This Matters
309
 
 
324
  | HuggingFace Space (live env) | https://huggingface.co/spaces/pushpam14/api-contract-validator |
325
  | Live env endpoint | https://pushpam14-api-contract-validator.hf.space |
326
  | Health check | https://pushpam14-api-contract-validator.hf.space/health |
327
+ | Trained LoRA adapter | https://huggingface.co/pushpam14/api-contract-validator-grpo-7b |
328
+ | WandB training run (300 steps) | https://wandb.ai/pushpamsubscriptions-inn/openenv-contract-guardian/runs/gch0eg3k |
329
  | Training Notebook (Colab) | [`training/grpo_colab.ipynb`](training/grpo_colab.ipynb) |
330
  | Story + Technical Guide | [`ENTERPRISE_CONTRACT_GUARDIAN_STORY.md`](ENTERPRISE_CONTRACT_GUARDIAN_STORY.md) |
331
  | GitHub repo | https://github.com/kumarpushpam17-personal/Hackathon |
332
  | Demo Video / HF Blog | *(add after recording)* |
 
333
 
334
  Quick test:
335