Two LoRA adapters for NVIDIA Nemotron Labs Dory 1.0 4B
that repair small single-function Python bugs through four tools (read_file,
edit_file, run_visible_tests, submit_patch) in the Toolsmith episode protocol.
Code, task generator, sandbox, recorded runs, and the comparison and viewer tools:
https://github.com/hr231/toolsmith-rl
| Subfolder | Method | Best at |
|---|---|---|
sft/ |
LoRA SFT on 500 verified demonstrations | Overall accuracy (97.4%) |
grpo/ |
Stateful GRPO from the prompt-only model, no demonstrations | Hardest split (challenge 34/40) |
| Model | dev | test_iid | test_compositional | challenge | All |
|---|---|---|---|---|---|
| Prompt-only Dory 1.0 4B | 82/100 | 80/100 | 70/100 | 23/40 | 255/340 (75.0%) |
| SFT LoRA | 100/100 | 100/100 | 100/100 | 31/40 | 331/340 (97.4%) |
| GRPO LoRA (from prompt-only) | 98/100 | 92/100 | 95/100 | 34/40 | 319/340 (93.8%) |
Same 340 frozen tasks for every model (seed 17, temperature 1.0, top_p 0.95, 256 new tokens per turn, 8 tool calls per episode). A task counts only if the submitted patch passes private input/output checks in a fresh Docker container. No model submitted a wrong patch.
sft: +22.4 points over the prompt-only model (95% CI +17.9 to +26.8; 77 tasks
gained, 1 lost), mostly from concise tool use: 150 new tokens per episode instead
of 308.grpo: +18.8 points over the prompt-only model (95% CI +14.1 to +23.5; 70 tasks
gained, 6 lost) and the best model on the challenge split. Overall it trails sft
by 3.5 points (95% CI -5.9 to -1.2); 18 of its 21 failures are turns that ran past
the 256-token limit.sft: one epoch over 500 replay-verified demonstrations (read file, run tests,
edit, run tests, submit): 63 optimizer steps, learning rate 2e-4 with 3 warmup
steps then linear decay, 8-example accumulation, gradient clipping at 1.0. Loss
covers only the tokens the model generates at inference (tool calls and the
end-of-turn token).grpo: TRL GRPO from a fresh LoRA on the prompt-only model: 150 steps, one
train task per step, 4 independent multi-turn episodes per task, learning rate
2e-5, KL 0.02 against the frozen starting adapter, dropout disabled. Reward is 1
when the submitted patch passes the private checks, else 0; tool results are
masked from the loss. Only 14 of the 150 steps had reward variance. One T4, 4.9
hours.sft received no reward variance in 150 steps and ended
identical to sft, so it is not included.The base model needs Transformers from huggingface/transformers#50099 (commit
fcc6924dfbac964f00787859b568c867ef5ad4cb) until Dory support is released.
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = "nvidia/NVIDIA-Nemotron-Labs-Dory1.0-4B-BF16"
revision = "f6c832e6963ddb74f62c75813a3e8c74b1af67b1"
tokenizer = AutoTokenizer.from_pretrained(base, revision=revision)
model = AutoModelForCausalLM.from_pretrained(base, revision=revision, dtype=torch.float16)
model = PeftModel.from_pretrained(model, "harshit2312/dory-4b-toolsmith-lora", subfolder="sft").merge_and_unload()
Use subfolder="grpo" for the GRPO adapter. Prompts, tool schemas, and the strict
tool-call parser are in toolsmith.inference; toolsmith.evaluation.run_episode
runs a full episode against a sandbox. Settings used for every result: 2 recurrent
loops, enable_thinking=False, temperature 1.0, top_p 0.95. Run generated code only
inside an isolated sandbox.
sft learned the demonstrations' fixed five-call script: after a failed test it
re-submits unchanged code or re-runs the test until its budget ends.grpo still over-explains on some edit turns (18 of 340 tasks end truncated), and
recovery after a second failing test remains rare.Distributed under the OpenMDW-1.1 agreement with this notice of origin: "NVIDIA-Nemotron-Labs-Dory1.0-4B-BF16, by NVIDIA, under OpenMDW-1.1." Using the adapters requires the base model under its own terms.
grpo/adapter_model.safetensors 63 MBsft/adapter_model.safetensors 63 MB