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 |
akhiilll/forgeenv (OpenEnv FastAPI server)akhiilll/forgeenv-repair-agent (LoRA + artifacts)akhiilll/forgeenv-demo (Gradio UI)1flowchart LR
2 U[User / Judge] -->|broken script + error trace| D[Demo Space\nakhiilll/forgeenv-demo]
3 D -->|unified diff patch| U
4
5 subgraph TrainOnce[Training (HF Jobs GPU)]
6 J[Training Job\n(SFT + GRPO)]
7 E[Environment Space\nakhiilll/forgeenv]
8 M[Model Repo\nakhiilll/forgeenv-repair-agent]
9 J <--> |reset/step, obs/reward| E
10 J -->|push LoRA + artifacts| M
11 end
12
13 D -. optional model usage .-> M1flowchart TB
2 API[OpenEnv FastAPI server\n`forgeenv/env/server.py`\n/health + reset + step] --> ENV[ForgeEnvironment (hub)\n`forgeenv/env/forge_environment.py`]
3
4 ENV --> TASKS[Task sampler + seed corpus\n`forgeenv/tasks/*`]
5 ENV --> ROLES[Roles (prompting + parsing)\n`forgeenv/roles/*`]
6 ENV --> PRIMS[Primitives (break + repair)\n`forgeenv/primitives/*`]
7 ENV --> DRIFT[Library drift engine\n`forgeenv/drift/library_drift_engine.py`]
8 ENV --> VERIFY[Verifiers\nvisible + held-out\n`forgeenv/verifier/*`]
9
10 VERIFY --> SANDBOX[Sandbox execution\nAST validator + simulation\n`forgeenv/sandbox/*`]1flowchart TB
2 SETUP[Install deps\n(torch/trl/unsloth/openenv…)] --> SFT[SFT warmstart\nformat + basics]
3 SFT --> SAVE1[Save SFT adapter]
4 SAVE1 --> GRPO_REPAIR[GRPO Repair Agent (Solver)\n`forgeenv/training/grpo_repair.py`]
5 GRPO_REPAIR <--> |episodes + rewards| ENVSPACE[Env Space\n`akhiilll/forgeenv`]
6 GRPO_REPAIR --> PUSH[Upload\nadapter + tokenizer + plots + repair_library]
7 PUSH --> HUB[Model Repo\n`akhiilll/forgeenv-repair-agent`]1flowchart TB
2 SFT2[SFT warmstart] --> CH[GRPO Drift Generator (Challenger)]
3 CH --> FILTER[Filter/select breakages\nusing p_hat from multiple solver attempts]
4 FILTER --> SOLVER[GRPO Repair Agent (Solver)]
5 SOLVER --> CHvisible_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 akhiilllscripts/jobs/train_repair_agent.py (what we used for the successful run)notebooks/forgeenv_train.ipynb (useful for iteration)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.