r1cksync commited on
Commit
aa4671b
·
1 Parent(s): d505de0

blog+readme: document the two prior deep-training rounds (legacy SB3 + hybrid Ollama/Groq PPO on 11 tasks); cite training code; add 3-panel deep-training chart

Browse files
Files changed (3) hide show
  1. BLOG.md +77 -4
  2. README.md +25 -3
  3. assets/blog/legacy_deep_training.png +3 -0
BLOG.md CHANGED
@@ -260,9 +260,24 @@ visualisation channel during demos and judging.
260
 
261
  ---
262
 
263
- ## 4 · How we actually trained — two passes
264
 
265
- ### Pass A · Legacy MLP baseline (proves the env is solvable)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
 
267
  Before any LLM work, we needed to know the reward signal isn't broken.
268
  We ran a stable‑baselines3 PPO agent against a **gym wrapper** of the env,
@@ -305,9 +320,67 @@ a real signal in there for any policy that bothers to investigate before
305
  acting. The action distribution from the trained MLP is
306
  `6× query_logs → submit_postmortem` — it memorised the *minimum sufficient
307
  investigation* for the easy/medium tasks. That's a floor. Now the question
308
- is: can an LLM agent do better on the **hard** version?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
 
310
- ### Pass B · LLM agent on 381 procedural scenarios
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
 
312
  This is the headline run. The same env, but two changes:
313
 
 
260
 
261
  ---
262
 
263
+ ## 4 · How we actually trained — three rounds, two regimes
264
 
265
+ We ran two regimes of training, in three rounds:
266
+
267
+ * **Deep regime** (round 1 + round 2) — many PPO updates per task, on a small
268
+ hand‑curated set of **7–11 tasks**. The point: prove the rubric is
269
+ learnable, debug the reward signal, and validate that an LLM actor with a
270
+ judge critic gives a usable advantage estimate before paying for a long
271
+ GPU run.
272
+ * **Shallow regime** (round 3) — short PPO loop per task, but on the full
273
+ **381 procedural scenarios** with saboteur + Slack noise + multi‑fault.
274
+ The point: prove that the same loop generalises to a hard, broad,
275
+ adversarial task pool — and ship a LoRA adapter for the demo.
276
+
277
+ The deep rounds came first; they're the reason we trusted the reward
278
+ signal enough to spend three free Kaggle accounts on the shallow round.
279
+
280
+ ### Pass A · Round 1 — Legacy SB3 PPO/MLP (proves the env is solvable)
281
 
282
  Before any LLM work, we needed to know the reward signal isn't broken.
283
  We ran a stable‑baselines3 PPO agent against a **gym wrapper** of the env,
 
320
  acting. The action distribution from the trained MLP is
321
  `6× query_logs → submit_postmortem` — it memorised the *minimum sufficient
322
  investigation* for the easy/medium tasks. That's a floor. Now the question
323
+ was: can an *LLM* actor learn the same signal and does a judge‑style
324
+ critic produce useful advantages?
325
+
326
+ ### Pass A · Round 2 — Hybrid LLM‑actor + judge‑critic on 11 hand‑curated tasks
327
+
328
+ Before committing GPU minutes to a 381‑task LoRA fine‑tune, we ran three
329
+ shorter PPO loops with a tiny LLM actor and three different critic
330
+ backends, all on **11 hand‑curated tasks** (`task1`…`task11` — the easy +
331
+ medium + hard archetypes plus their variants). All three runs share the
332
+ same trainer:
333
+ [`rl-agent/training/train_hybrid.py`](https://github.com/r1cksync/meta-rl-hack/blob/main/incident-commander/rl-agent/training/train_hybrid.py).
334
+
335
+ | Round | Actor | Critic | Updates | Episodes | Mean R | Best per‑task | Mitigation rate | Logs |
336
+ | --- | --- | --- | ---: | ---: | ---: | ---: | ---: | --- |
337
+ | **v2** | heuristic | none (PPO baseline) | 33 | 99 | 1.17 | 1.60 (`task1`,`task4`) | **100%** | [`ppo-v2-heuristic/`](https://github.com/r1cksync/meta-rl-hack/tree/main/incident-commander/rl-agent/checkpoints/ppo-v2-heuristic) |
338
+ | **v3** | Qwen2.5:0.5b (Ollama) | heuristic fallback | 12 | 36 | 1.32 | 1.72 (`task10`) | 69% | [`ppo-v3-hybrid-ollama-bedrock/`](https://github.com/r1cksync/meta-rl-hack/tree/main/incident-commander/rl-agent/checkpoints/ppo-v3-hybrid-ollama-bedrock) |
339
+ | **v4** | Qwen2.5:0.5b (Ollama) | **Groq Llama‑3.1‑8B‑instant** | 12 | 36 | **1.78** | **2.41** (`task9`) | 44% | [`ppo-v4-hybrid-ollama-groq/`](https://github.com/r1cksync/meta-rl-hack/tree/main/incident-commander/rl-agent/checkpoints/ppo-v4-hybrid-ollama-groq) |
340
+
341
+ Every row is a real run — `metrics.jsonl` + `summary.json` + reward‑breakdown
342
+ history all sit in the linked checkpoint folders. The trainer is invoked as:
343
+
344
+ ```bash
345
+ # v2 — pure heuristic actor, PPO baseline
346
+ python -m rl_agent.training.train_hybrid --mode heuristic \
347
+ --out-dir rl-agent/checkpoints/ppo-v2-heuristic
348
+
349
+ # v3 — Ollama Qwen2.5:0.5b actor + heuristic critic (Bedrock fallback)
350
+ python -m rl_agent.training.train_hybrid \
351
+ --mode hybrid-ollama-bedrock --ollama-model qwen2.5:0.5b \
352
+ --out-dir rl-agent/checkpoints/ppo-v3-hybrid-ollama-bedrock
353
+
354
+ # v4 — Ollama Qwen2.5:0.5b actor + Groq Llama‑3.1‑8B‑instant critic
355
+ python -m rl_agent.training.train_hybrid \
356
+ --mode hybrid-ollama-groq --ollama-model qwen2.5:0.5b \
357
+ --groq-model llama-3.1-8b-instant \
358
+ --out-dir rl-agent/checkpoints/ppo-v4-hybrid-ollama-groq
359
+ ```
360
 
361
+ ![Hybrid PPO loops on 11 tasks policy loss collapses, entropy compresses, Groq critic delivers the highest mean reward](assets/blog/legacy_deep_training.png)
362
+
363
+ *Three signs the deep regime worked:*
364
+
365
+ * **Policy loss collapses on every run.** v2 falls from 1.20 → 0.083
366
+ (**−93%**) over 33 updates; v3 and v4 both fall from 1.10 → 0.50 (**−55%**)
367
+ in just 12 updates. Same shape, same trajectory — the loop is healthy.
368
+ * **Entropy compresses smoothly** from ~2.0 → 0.39 (v2) and ~1.9 → 1.21
369
+ (v3/v4) — the actor distribution is sharpening on a coherent strategy,
370
+ not collapsing prematurely.
371
+ * **Per‑task max reward keeps rising.** v4's Qwen2.5 actor with the Groq
372
+ Llama‑3.1‑8B critic posts mean reward **2.41 on `task9`**, **2.39 on
373
+ `task1`**, **2.29 on `task10`** — well above the heuristic v2 ceiling of
374
+ 1.60. The judge‑critic is providing a useful signal.
375
+
376
+ What this established: (a) the reward signal is dense enough that a 0.5B
377
+ LLM actor moves it; (b) a frozen LLM judge as critic produces advantages
378
+ that actually push the policy upward (v4 > v3 > v2 on mean reward); (c) PPO
379
+ hyper‑parameters lifted from these runs (γ=0.95, λ=0.92, clip=0.2, KL=0.02,
380
+ entropy=0.01) are the same ones we used in Pass B. It's the bridge that
381
+ made the 381‑task run worth attempting.
382
+
383
+ ### Pass B · Round 3 — LLM agent on 381 procedural scenarios
384
 
385
  This is the headline run. The same env, but two changes:
386
 
README.md CHANGED
@@ -31,7 +31,7 @@ Built for the **Meta PyTorch OpenEnv Hackathon x Scaler School of Technology, 20
31
  | 💻 **Source (GitHub)** | [r1cksync/meta-rl-hack](https://github.com/r1cksync/meta-rl-hack) |
32
  | 📊 **Training notebooks (Kaggle)** | [`kaggle/`](kaggle/) (3 shards × Phi-3.5 + DeepSeek-R1) · [`notebooks/`](notebooks/) (legacy SB3 PPO baseline) |
33
  | 📦 **Trained adapters** | [`kaggle ran notebooks/shard {1,2,3}/adapter_kaggle{N}/`](kaggle%20ran%20notebooks/) |
34
- | 🎚️ **Per-update training logs** | [`kaggle ran notebooks/shard {1,2,3}/training_kaggle{N}.json`](kaggle%20ran%20notebooks/) · [`rl-agent/checkpoints/training_metrics.json`](rl-agent/checkpoints/training_metrics.json) |
35
 
36
  ---
37
 
@@ -298,9 +298,31 @@ python -m rl_agent.eval \
298
 
299
  ---
300
 
301
- ## Actual Training We Ran (PPO + LoRA, 3 Kaggle Shards)
302
 
303
- The GRPO roadmap above was the original plan; in practice we ran a custom PPO loop with a dual-model setup that fit comfortably on free Kaggle T4s. The full live numbers are visible at [`/showcase`](https://sagnik-mukherjee-incodent-commander.hf.space/showcase).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
 
305
  ### Models
306
 
 
31
  | 💻 **Source (GitHub)** | [r1cksync/meta-rl-hack](https://github.com/r1cksync/meta-rl-hack) |
32
  | 📊 **Training notebooks (Kaggle)** | [`kaggle/`](kaggle/) (3 shards × Phi-3.5 + DeepSeek-R1) · [`notebooks/`](notebooks/) (legacy SB3 PPO baseline) |
33
  | 📦 **Trained adapters** | [`kaggle ran notebooks/shard {1,2,3}/adapter_kaggle{N}/`](kaggle%20ran%20notebooks/) |
34
+ | 🎚️ **Per-update training logs** | **Round 3 (shallow, 381 tasks):** [`kaggle ran notebooks/shard {1,2,3}/training_kaggle{N}.json`](kaggle%20ran%20notebooks/) · **Round 2 (deep, 11 tasks):** [`rl-agent/checkpoints/ppo-v{2,3,4}-*/metrics.jsonl`](rl-agent/checkpoints/) · **Round 1 (legacy SB3):** [`rl-agent/checkpoints/training_metrics.json`](rl-agent/checkpoints/training_metrics.json) |
35
 
36
  ---
37
 
 
298
 
299
  ---
300
 
301
+ ## Actual Training We Ran (3 rounds, 2 regimes)
302
 
303
+ The GRPO roadmap above was the original plan; in practice we ran a custom PPO loop in two regimes — **deep training on a small task set** first, then **shallow training on all 381 procedural scenarios**. Three real rounds, all with full logs, all reproducible from this repo. The full live numbers are visible at [`/showcase`](https://sagnik-mukherjee-incodent-commander.hf.space/showcase) and discussed at length in [`BLOG.md`](BLOG.md) §4.
304
+
305
+ | Round | Regime | Tasks | Algorithm | Updates | Headline result | Code | Logs |
306
+ |---|---|---:|---|---:|---|---|---|
307
+ | **1 · Legacy SB3** | deep | 7 | SB3 PPO + MLP, 200 k timesteps | 5 evals | mean reward **1.05**, **100% success** over 90 episodes | [`rl-agent/training/train_enhanced.py`](rl-agent/training/train_enhanced.py) + [`gym_wrapper.py`](rl-agent/training/gym_wrapper.py) | [`training_metrics.json`](rl-agent/checkpoints/training_metrics.json) · [`evaluation_report.json`](rl-agent/checkpoints/evaluation_report.json) |
308
+ | **2 · Hybrid v2/v3/v4** | deep | 11 | Custom PPO, heuristic + small-LLM actor + judge critic | 12–33 | policy loss **−93% (v2)** / **−55% (v3,v4)**; v4 mean reward **1.78**, max **2.41** on `task9` | [`rl-agent/training/train_hybrid.py`](rl-agent/training/train_hybrid.py) (+ [`groq_critic.py`](rl-agent/training/groq_critic.py)) | [`ppo-v2-heuristic/`](rl-agent/checkpoints/ppo-v2-heuristic) · [`ppo-v3-hybrid-ollama-bedrock/`](rl-agent/checkpoints/ppo-v3-hybrid-ollama-bedrock) · [`ppo-v4-hybrid-ollama-groq/`](rl-agent/checkpoints/ppo-v4-hybrid-ollama-groq) |
309
+ | **3 · LoRA fine-tune** | shallow | **381** | Custom PPO + LoRA, Phi-3.5-mini actor + DeepSeek-R1 critic, 3 Kaggle shards | 60 / shard | KL & loss decay **50–66%** across all 3 shards; novelty categories all show positive Δ reward (+0.30 → +1.05) | [`scripts/run_training.py`](scripts/run_training.py) + [`colab/train_lib.py`](colab/train_lib.py) + [`scripts/merge_lora_adapters.py`](scripts/merge_lora_adapters.py) | [`shard 1/training_kaggle1.json`](kaggle%20ran%20notebooks/shard%201/training_kaggle1.json) · [`shard 2/training_kaggle2.json`](kaggle%20ran%20notebooks/shard%202/training_kaggle2.json) · [`shard 3/training_kaggle3.json`](kaggle%20ran%20notebooks/shard%203/training_kaggle3.json) |
310
+
311
+ **Why two regimes?** Round 1 + 2 (deep) prove the rubric is learnable on a small, well-understood task set — they're how we debugged the reward shaper, validated that a frozen LLM judge produces useful advantages, and locked the PPO hyper-parameters. Round 3 (shallow) takes those exact hyper-parameters and runs them across the full 381-scenario procedural curriculum on three free Kaggle T4 accounts in parallel.
312
+
313
+ **Headline numbers from the deep runs (Round 2):**
314
+
315
+ | Run | Actor | Critic | Episodes | Mean reward | Top per-task mean | Mitigation rate |
316
+ |---|---|---|---:|---:|---|---:|
317
+ | `ppo-v2-heuristic` | heuristic | none | 99 | 1.17 | 1.60 (`task1`,`task4`) | **100%** |
318
+ | `ppo-v3-hybrid-ollama-bedrock` | Qwen2.5:0.5b (Ollama) | heuristic-fallback | 36 | 1.32 | 1.72 (`task10`) | 69% |
319
+ | `ppo-v4-hybrid-ollama-groq` | Qwen2.5:0.5b (Ollama) | **Groq Llama-3.1-8B-instant** | 36 | **1.78** | **2.41** (`task9`) | 44% |
320
+
321
+ Across all three deep runs, policy loss collapses (1.20 → 0.083 over 33 updates for v2; 1.10 → 0.50 over 12 updates for v3/v4), entropy compresses (~2.0 → 0.39 for v2; ~1.9 → 1.21 for v3/v4), and v4's small-LLM actor with the Groq Llama-3.1-8B critic clears the heuristic ceiling on the hardest tasks. Plots and the full discussion live in [`BLOG.md` §4](BLOG.md).
322
+
323
+ ### Round 3 — LoRA fine-tune on 381 scenarios (the headline run)
324
+
325
+ Round 3 is the run that ships the merged LoRA adapter on top of `microsoft/Phi-3.5-mini-instruct`. It uses the same PPO hyper-parameters validated by rounds 1 + 2.
326
 
327
  ### Models
328
 
assets/blog/legacy_deep_training.png ADDED

Git LFS Details

  • SHA256: 3c6a51e5a7422ad02097d3fe7fe6d60a4fd1e7dcba37fd1eccffab2ab9f4c1d5
  • Pointer size: 131 Bytes
  • Size of remote file: 123 kB