Views
No views yet
A self-improving RL environment that teaches LLMs to fix HuggingFace training scripts as the ecosystem evolves.
Trainer.train() is renamed, a tokenizer kwarg disappears, a
dataset column is restructured. Today, humans patch these. ForgeEnv turns
that patching loop into a verifiable RL task so a model can learn to do
it autonomously, and keep doing it as the libraries drift further.| Artifact | URL |
|---|---|
| Environment Space (Docker) | https://huggingface.co/spaces/akhiilll/forgeenv |
| Demo Space (Gradio + ZeroGPU) | https://huggingface.co/spaces/akhiilll/forgeenv-demo |
| Trained model (LoRA) | https://huggingface.co/akhiilll/forgeenv-repair-agent |
| Training notebook (Colab) | notebooks/forgeenv_train.ipynb |
┌──────────────────┐
│ Teacher (deter- │ curriculum →
│ ministic) │ {RenameApiCall, DeprecateImport, …}
└──────────────────┘
│ target_category
▼
┌────────────────────────────────────────────────────────────────┐
│ ForgeEnvironment (OpenEnv) │
│ reset() → drift_gen obs (script, target_category) │
│ step(BreakageAction) → repair obs (broken_script, trace) │
│ step(RepairAction) → reward, breakdown, held-out scores │
│ │
│ ┌───────────────────┐ ┌──────────────────────┐ │
│ │ Drift Generator │ │ Repair Agent │ │
│ │ (LLM, GRPO) │ │ (LLM, GRPO + SFT) │ │
│ └───────────────────┘ └──────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────┐ │
│ │ Simulator (AST + heuristic exec) + Visible Verifier │ │
│ │ + Held-out Evaluator + Library Drift Engine │ │
│ └───────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────┘visible_reward
├─ execution_success (sandboxed run / heuristic simulator)
├─ ast_well_formed (parses + no forbidden globals)
├─ format_compliance (valid unified diff or full-script replacement)
├─ minimality (smaller diffs preferred — anti-rewrite)
└─ no_forbidden_globals (locked-down execution check)
held_out_evaluator (NOT used for training, used for evals only)
├─ executed_cleanly
├─ matches_target_api (semantic correctness)
└─ regression_free (other tests still pass)| Agent | Mean visible reward | Success rate (held-out exec) |
|---|---|---|
| Baseline (no-op) | 0.90 | 50 % |
| Trained (oracle) | 1.51 | 86 % |
artifacts/plots/):baseline_vs_trained.png — reward distribution, baseline vs trained.training_reward_curve.png — reward trajectory across episodes.success_by_category.png — per-primitive success rates.repair_library.json of curated successful repairs is also
pushed alongside the LoRA checkpoint.1# 1. install (env-only deps, no torch needed for the env itself)
2pip install -e .[openenv]
3pip install -e .[dev]
4
5# 2. run the test suite
6pytest -q # 74 tests — full env + roles + reward + training
7
8# 3. spin up the environment locally
9uvicorn forgeenv.env.server:app --port 7860
10
11# 4. generate the demo artifacts (plots + repair_library.json + eval JSON)
12python scripts/generate_artifacts.py --n_baseline 50 --n_trained 50
13
14# 5. push to HF Spaces
15export HF_TOKEN=hf_...
16python scripts/deploy_spaces.py --user akhiilllnotebooks/forgeenv_train.ipynb — open
it on Colab with a T4 or A100 and re-run end-to-end.forgeenv/ # importable Python package (env + roles + training)
env/ # OpenEnv wrapper: actions, observations, server
sandbox/ # AST validator + heuristic simulator
verifier/ # visible verifier + held-out evaluator
primitives/ # 8 breakage + 8 repair primitives + drift taxonomy
tasks/ # 10-script HF seed corpus + sampler
roles/ # Drift Generator + Repair Agent + Teacher
drift/ # Library drift engine (non-stationary verification)
training/ # SFT, GRPO repair, GRPO drift, rollout, plots
artifacts/ # repair-library curation
forgeenv-space/ # files we push to the OpenEnv Space (Docker)
demo-space/ # files we push to the Gradio demo Space
notebooks/forgeenv_train.ipynb # Colab training pipeline
warmstart/ # 64 SFT pairs for repair agent + 64 for drift gen
scripts/
generate_artifacts.py # plots + eval_results.json + repair_library.json
deploy_spaces.py # one-shot push to HF Spaces
artifacts/ # generated plots + curated repair library
tests/ # 74 pytest testsos.system,
etc.) before reward is computed.