Spaces:
Sleeping
Sleeping
Clarify how reviewers can run and inspect outputs
Browse files- training/README.md +17 -10
training/README.md
CHANGED
|
@@ -8,12 +8,16 @@ Re-runnable training pipeline for the API Contract Validator environment, using
|
|
| 8 |
|---|---|
|
| 9 |
| `baseline.py` | Run the untrained model on every task; write `baseline_scores.json` |
|
| 10 |
| `train.py` | GRPO training loop β connects to env, rolls out, trains LoRA |
|
|
|
|
|
|
|
| 11 |
| `plot.py` | Build `reward_curve.png` and `before_after.png` for the README |
|
| 12 |
| `grpo_colab.ipynb` | One-click Colab notebook (open in Colab β Runtime β Run all) |
|
| 13 |
|
| 14 |
## Recommended path β HF Jobs (best for the finale)
|
| 15 |
|
| 16 |
-
HF Jobs runs in the cloud, doesn't disconnect, and bills against your
|
|
|
|
|
|
|
| 17 |
|
| 18 |
### Run 1 β Smoke test (~$0.30, 5 min)
|
| 19 |
|
|
@@ -21,15 +25,16 @@ Verifies the pipeline works end-to-end before committing to a long run.
|
|
| 21 |
|
| 22 |
```bash
|
| 23 |
hf jobs uv run \
|
| 24 |
-
--with "trl" --with "unsloth" --with "openenv-core[core]>=0.2.2" \
|
| 25 |
-
--with "wandb" --with "matplotlib" --with "datasets" --with "openai" \
|
| 26 |
--flavor t4-small \
|
| 27 |
-s HF_TOKEN -s WANDB_API_KEY \
|
| 28 |
-e BASE_MODEL=unsloth/Qwen2.5-1.5B-Instruct-bnb-4bit \
|
| 29 |
-e ENV_URL=https://pushpam14-api-contract-validator.hf.space \
|
| 30 |
-e MAX_STEPS=10 \
|
|
|
|
|
|
|
| 31 |
-e WANDB_RUN=smoke-test \
|
| 32 |
-
-
|
|
|
|
| 33 |
```
|
| 34 |
|
| 35 |
If this errors, **don't proceed**. Fix the error, re-run smoke test until it returns clean.
|
|
@@ -40,8 +45,6 @@ Best balance of model size, speed, and cost for our $60 budget. L4 has 24 GB whi
|
|
| 40 |
|
| 41 |
```bash
|
| 42 |
hf jobs uv run \
|
| 43 |
-
--with "trl" --with "unsloth" --with "openenv-core[core]>=0.2.2" \
|
| 44 |
-
--with "wandb" --with "matplotlib" --with "datasets" --with "openai" \
|
| 45 |
--flavor l4x1 \
|
| 46 |
-s HF_TOKEN -s WANDB_API_KEY \
|
| 47 |
-e BASE_MODEL=unsloth/Qwen2.5-7B-Instruct-bnb-4bit \
|
|
@@ -53,7 +56,9 @@ hf jobs uv run \
|
|
| 53 |
-e WANDB_PROJECT=openenv-contract-guardian \
|
| 54 |
-e WANDB_RUN=grpo-7b-l4-300steps \
|
| 55 |
-e PUSH_TO_HUB=pushpam14/api-contract-validator-grpo-7b \
|
| 56 |
-
-
|
|
|
|
|
|
|
| 57 |
```
|
| 58 |
|
| 59 |
### Run 3 β Insurance run on second account (~$0.40, ~45 min)
|
|
@@ -63,8 +68,6 @@ Use your second HF account in parallel as a safety net. Smaller model = faster,
|
|
| 63 |
```bash
|
| 64 |
# Use your SECOND HF account's token here
|
| 65 |
hf jobs uv run \
|
| 66 |
-
--with "trl" --with "unsloth" --with "openenv-core[core]>=0.2.2" \
|
| 67 |
-
--with "wandb" --with "matplotlib" --with "datasets" --with "openai" \
|
| 68 |
--flavor t4-small \
|
| 69 |
-s HF_TOKEN -s WANDB_API_KEY \
|
| 70 |
-e BASE_MODEL=unsloth/Qwen2.5-1.5B-Instruct-bnb-4bit \
|
|
@@ -72,7 +75,9 @@ hf jobs uv run \
|
|
| 72 |
-e MAX_STEPS=200 \
|
| 73 |
-e WANDB_RUN=grpo-1.5b-t4-200steps \
|
| 74 |
-e PUSH_TO_HUB=YOUR_SECOND_ACCOUNT/api-contract-validator-grpo-1.5b \
|
| 75 |
-
-
|
|
|
|
|
|
|
| 76 |
```
|
| 77 |
|
| 78 |
### Hardware β model size cheatsheet
|
|
@@ -103,6 +108,8 @@ hf jobs list
|
|
| 103 |
|
| 104 |
Open `grpo_colab.ipynb` in Colab. Set `HF_TOKEN` and `WANDB_API_KEY` in the secrets pane. Hit **Runtime β Run all**. Free T4, but disconnects after 3 hours and only fits the 1.5B model.
|
| 105 |
|
|
|
|
|
|
|
| 106 |
## Alternative: Local GPU
|
| 107 |
|
| 108 |
```bash
|
|
|
|
| 8 |
|---|---|
|
| 9 |
| `baseline.py` | Run the untrained model on every task; write `baseline_scores.json` |
|
| 10 |
| `train.py` | GRPO training loop β connects to env, rolls out, trains LoRA |
|
| 11 |
+
| `run_in_hf_jobs.py` | Self-bootstrapping HF Jobs launcher used for the submitted run |
|
| 12 |
+
| `run_trained_inference.py` | HF Jobs inference script for the trained LoRA adapter |
|
| 13 |
| `plot.py` | Build `reward_curve.png` and `before_after.png` for the README |
|
| 14 |
| `grpo_colab.ipynb` | One-click Colab notebook (open in Colab β Runtime β Run all) |
|
| 15 |
|
| 16 |
## Recommended path β HF Jobs (best for the finale)
|
| 17 |
|
| 18 |
+
HF Jobs runs in the cloud, doesn't disconnect, and bills against your hackathon credit.
|
| 19 |
+
|
| 20 |
+
Important: `hf jobs uv run` uploads exactly one Python file. The submitted run therefore used [`run_in_hf_jobs.py`](run_in_hf_jobs.py), which clones this repo inside the job and then calls `training.train.main()`. This avoids import errors from sibling modules such as `inference.py`, `client.py`, and `server/*`.
|
| 21 |
|
| 22 |
### Run 1 β Smoke test (~$0.30, 5 min)
|
| 23 |
|
|
|
|
| 25 |
|
| 26 |
```bash
|
| 27 |
hf jobs uv run \
|
|
|
|
|
|
|
| 28 |
--flavor t4-small \
|
| 29 |
-s HF_TOKEN -s WANDB_API_KEY \
|
| 30 |
-e BASE_MODEL=unsloth/Qwen2.5-1.5B-Instruct-bnb-4bit \
|
| 31 |
-e ENV_URL=https://pushpam14-api-contract-validator.hf.space \
|
| 32 |
-e MAX_STEPS=10 \
|
| 33 |
+
-e NUM_GENERATIONS=2 \
|
| 34 |
+
-e GIT_REF=main \
|
| 35 |
-e WANDB_RUN=smoke-test \
|
| 36 |
+
-d \
|
| 37 |
+
api_contract_validator/training/run_in_hf_jobs.py
|
| 38 |
```
|
| 39 |
|
| 40 |
If this errors, **don't proceed**. Fix the error, re-run smoke test until it returns clean.
|
|
|
|
| 45 |
|
| 46 |
```bash
|
| 47 |
hf jobs uv run \
|
|
|
|
|
|
|
| 48 |
--flavor l4x1 \
|
| 49 |
-s HF_TOKEN -s WANDB_API_KEY \
|
| 50 |
-e BASE_MODEL=unsloth/Qwen2.5-7B-Instruct-bnb-4bit \
|
|
|
|
| 56 |
-e WANDB_PROJECT=openenv-contract-guardian \
|
| 57 |
-e WANDB_RUN=grpo-7b-l4-300steps \
|
| 58 |
-e PUSH_TO_HUB=pushpam14/api-contract-validator-grpo-7b \
|
| 59 |
+
-e GIT_REF=main \
|
| 60 |
+
-d \
|
| 61 |
+
api_contract_validator/training/run_in_hf_jobs.py
|
| 62 |
```
|
| 63 |
|
| 64 |
### Run 3 β Insurance run on second account (~$0.40, ~45 min)
|
|
|
|
| 68 |
```bash
|
| 69 |
# Use your SECOND HF account's token here
|
| 70 |
hf jobs uv run \
|
|
|
|
|
|
|
| 71 |
--flavor t4-small \
|
| 72 |
-s HF_TOKEN -s WANDB_API_KEY \
|
| 73 |
-e BASE_MODEL=unsloth/Qwen2.5-1.5B-Instruct-bnb-4bit \
|
|
|
|
| 75 |
-e MAX_STEPS=200 \
|
| 76 |
-e WANDB_RUN=grpo-1.5b-t4-200steps \
|
| 77 |
-e PUSH_TO_HUB=YOUR_SECOND_ACCOUNT/api-contract-validator-grpo-1.5b \
|
| 78 |
+
-e GIT_REF=main \
|
| 79 |
+
-d \
|
| 80 |
+
api_contract_validator/training/run_in_hf_jobs.py
|
| 81 |
```
|
| 82 |
|
| 83 |
### Hardware β model size cheatsheet
|
|
|
|
| 108 |
|
| 109 |
Open `grpo_colab.ipynb` in Colab. Set `HF_TOKEN` and `WANDB_API_KEY` in the secrets pane. Hit **Runtime β Run all**. Free T4, but disconnects after 3 hours and only fits the 1.5B model.
|
| 110 |
|
| 111 |
+
The notebook is intentionally committed without outputs so reviewers can run it cleanly. The completed submitted run outputs are committed under `api_contract_validator/results/` and linked from the main README.
|
| 112 |
+
|
| 113 |
## Alternative: Local GPU
|
| 114 |
|
| 115 |
```bash
|