harshit2312 commited on
Commit
c8c2578
·
verified ·
1 Parent(s): 0d37291

Add Toolsmith SFT and GRPO LoRA adapters

Browse files
LICENSE.OpenMDW-1.1.txt ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ OpenMDW License Agreement, version 1.1 (OpenMDW-1.1)
2
+
3
+ By exercising rights granted to you under this agreement, you accept and agree
4
+ to its terms.
5
+
6
+ As used in this agreement, "Model Materials" means the materials provided to
7
+ you under this agreement, consisting of: (1) one or more machine learning
8
+ models (including architecture and parameters); and (2) all related artifacts
9
+ (including associated data, documentation and software) that are provided to
10
+ you hereunder.
11
+
12
+ Subject to your compliance with this agreement, permission is hereby granted,
13
+ free of charge, to deal in the Model Materials without restriction, including
14
+ under all copyright, patent, database, and trade secret rights included or
15
+ embodied therein.
16
+
17
+ If you distribute any portion of the Model Materials, you shall retain in your
18
+ distribution (1) a copy of this agreement, and (2) all copyright notices and
19
+ other notices of origin included in the Model Materials that are applicable to
20
+ your distribution.
21
+
22
+ If you file, maintain, or voluntarily participate in a lawsuit against any
23
+ person or entity asserting that the Model Materials directly or indirectly
24
+ infringe any patent or copyright, then all rights and grants made to you
25
+ hereunder are terminated, unless that lawsuit was in response to a
26
+ corresponding lawsuit first brought against you.
27
+
28
+ This agreement does not impose any restrictions or obligations with respect to
29
+ any use, modification, or sharing of any outputs generated by using the Model
30
+ Materials.
31
+
32
+ THE MODEL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
33
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
+ FITNESS FOR A PARTICULAR PURPOSE, TITLE, NONINFRINGEMENT, ACCURACY, OR THE
35
+ ABSENCE OF LATENT OR OTHER DEFECTS OR ERRORS, WHETHER OR NOT DISCOVERABLE, ALL
36
+ TO THE GREATEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW.
37
+
38
+ YOU ARE SOLELY RESPONSIBLE FOR (1) CLEARING RIGHTS OF OTHER PERSONS THAT MAY
39
+ APPLY TO THE MODEL MATERIALS OR ANY USE THEREOF, INCLUDING WITHOUT LIMITATION
40
+ ANY PERSON'S COPYRIGHTS OR OTHER RIGHTS INCLUDED OR EMBODIED IN THE MODEL
41
+ MATERIALS; (2) OBTAINING ANY NECESSARY CONSENTS, PERMISSIONS OR OTHER RIGHTS
42
+ REQUIRED FOR ANY USE OF THE MODEL MATERIALS; OR (3) PERFORMING ANY DUE
43
+ DILIGENCE OR UNDERTAKING ANY OTHER INVESTIGATIONS INTO THE MODEL MATERIALS OR
44
+ ANYTHING INCORPORATED OR EMBODIED THEREIN.
45
+
46
+ IN NO EVENT SHALL THE PROVIDERS OF THE MODEL MATERIALS BE LIABLE FOR ANY CLAIM,
47
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
48
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MODEL MATERIALS, THE
49
+ USE THEREOF OR OTHER DEALINGS THEREIN.
NOTICE.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ NVIDIA-Nemotron-Labs-Dory1.0-4B-BF16, by NVIDIA, under OpenMDW-1.1.
README.md CHANGED
@@ -1,3 +1,108 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: other
3
+ license_name: openmdw-1.1
4
+ license_link: https://huggingface.co/harshit2312/dory-4b-toolsmith-lora/blob/main/LICENSE.OpenMDW-1.1.txt
5
+ base_model: nvidia/NVIDIA-Nemotron-Labs-Dory1.0-4B-BF16
6
+ library_name: peft
7
+ pipeline_tag: text-generation
8
+ tags:
9
+ - lora
10
+ - peft
11
+ - code-repair
12
+ - tool-use
13
+ - sft
14
+ - grpo
15
  ---
16
+
17
+ # Toolsmith LoRA adapters for Dory 1.0 4B
18
+
19
+ Two LoRA adapters for [NVIDIA Nemotron Labs Dory 1.0 4B](https://huggingface.co/nvidia/NVIDIA-Nemotron-Labs-Dory1.0-4B-BF16)
20
+ that repair small single-function Python bugs through four tools (`read_file`,
21
+ `edit_file`, `run_visible_tests`, `submit_patch`) in the Toolsmith episode protocol.
22
+ Code, task generator, sandbox, recorded runs, and the comparison and viewer tools:
23
+ https://github.com/hr231/toolsmith-rl
24
+
25
+ | Subfolder | Method | Best at |
26
+ | --- | --- | --- |
27
+ | `sft/` | LoRA SFT on 500 verified demonstrations | Overall accuracy (97.4%) |
28
+ | `grpo/` | Stateful GRPO from the prompt-only model, no demonstrations | Hardest split (challenge 34/40) |
29
+
30
+ ## Evaluation
31
+
32
+ | Model | dev | test_iid | test_compositional | challenge | All |
33
+ | --- | --- | --- | --- | --- | --- |
34
+ | Prompt-only Dory 1.0 4B | 82/100 | 80/100 | 70/100 | 23/40 | 255/340 (75.0%) |
35
+ | SFT LoRA | 100/100 | 100/100 | 100/100 | 31/40 | 331/340 (97.4%) |
36
+ | GRPO LoRA (from prompt-only) | 98/100 | 92/100 | 95/100 | 34/40 | 319/340 (93.8%) |
37
+
38
+ Same 340 frozen tasks for every model (seed 17, temperature 1.0, top_p 0.95, 256 new
39
+ tokens per turn, 8 tool calls per episode). A task counts only if the submitted
40
+ patch passes private input/output checks in a fresh Docker container. No model
41
+ submitted a wrong patch.
42
+
43
+ - **`sft`:** +22.4 points over the prompt-only model (95% CI +17.9 to +26.8; 77 tasks
44
+ gained, 1 lost), mostly from concise tool use: 150 new tokens per episode instead
45
+ of 308.
46
+ - **`grpo`:** +18.8 points over the prompt-only model (95% CI +14.1 to +23.5; 70 tasks
47
+ gained, 6 lost) and the best model on the challenge split. Overall it trails `sft`
48
+ by 3.5 points (95% CI -5.9 to -1.2); 18 of its 21 failures are turns that ran past
49
+ the 256-token limit.
50
+
51
+ ## Training
52
+
53
+ - **`sft`:** one epoch over 500 replay-verified demonstrations (read file, run tests,
54
+ edit, run tests, submit): 63 optimizer steps, learning rate 2e-4 with 3 warmup
55
+ steps then linear decay, 8-example accumulation, gradient clipping at 1.0. Loss
56
+ covers only the tokens the model generates at inference (tool calls and the
57
+ end-of-turn token).
58
+ - **`grpo`:** TRL GRPO from a fresh LoRA on the prompt-only model: 150 steps, one
59
+ train task per step, 4 independent multi-turn episodes per task, learning rate
60
+ 2e-5, KL 0.02 against the frozen starting adapter, dropout disabled. Reward is 1
61
+ when the submitted patch passes the private checks, else 0; tool results are
62
+ masked from the loss. Only 14 of the 150 steps had reward variance. One T4, 4.9
63
+ hours.
64
+ - **Shared:** rank 16, alpha 32, dropout 0.05 on the 180 linear layers inside the
65
+ base model's attention blocks (15.6M parameters); the MLPs and the LM head are not
66
+ adapted. fp16 base weights with fp32 LoRA weights on T4 GPUs.
67
+ - GRPO started from `sft` received no reward variance in 150 steps and ended
68
+ identical to `sft`, so it is not included.
69
+
70
+ ## Usage
71
+
72
+ The base model needs Transformers from huggingface/transformers#50099 (commit
73
+ `fcc6924dfbac964f00787859b568c867ef5ad4cb`) until Dory support is released.
74
+
75
+ ```python
76
+ import torch
77
+ from peft import PeftModel
78
+ from transformers import AutoModelForCausalLM, AutoTokenizer
79
+
80
+ base = "nvidia/NVIDIA-Nemotron-Labs-Dory1.0-4B-BF16"
81
+ revision = "f6c832e6963ddb74f62c75813a3e8c74b1af67b1"
82
+ tokenizer = AutoTokenizer.from_pretrained(base, revision=revision)
83
+ model = AutoModelForCausalLM.from_pretrained(base, revision=revision, dtype=torch.float16)
84
+ model = PeftModel.from_pretrained(model, "harshit2312/dory-4b-toolsmith-lora", subfolder="sft").merge_and_unload()
85
+ ```
86
+
87
+ Use `subfolder="grpo"` for the GRPO adapter. Prompts, tool schemas, and the strict
88
+ tool-call parser are in `toolsmith.inference`; `toolsmith.evaluation.run_episode`
89
+ runs a full episode against a sandbox. Settings used for every result: 2 recurrent
90
+ loops, `enable_thinking=False`, temperature 1.0, top_p 0.95. Run generated code only
91
+ inside an isolated sandbox.
92
+
93
+ ## Limitations
94
+
95
+ - Trained and evaluated on synthetic, templated, single-function tasks; results do
96
+ not transfer to real repositories.
97
+ - Single training seed; confidence intervals cover task sampling only.
98
+ - `sft` learned the demonstrations' fixed five-call script: after a failed test it
99
+ re-submits unchanged code or re-runs the test until its budget ends.
100
+ - `grpo` still over-explains on some edit turns (18 of 340 tasks end truncated), and
101
+ recovery after a second failing test remains rare.
102
+ - The base model's terms apply, including NVIDIA's guidance in its model card.
103
+
104
+ ## License and notice
105
+
106
+ Distributed under the [OpenMDW-1.1](LICENSE.OpenMDW-1.1.txt) agreement with this
107
+ notice of origin: "NVIDIA-Nemotron-Labs-Dory1.0-4B-BF16, by NVIDIA, under
108
+ OpenMDW-1.1." Using the adapters requires the base model under its own terms.
grpo/adapter_config.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "nvidia/NVIDIA-Nemotron-Labs-Dory1.0-4B-BF16",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "kasa_config": null,
16
+ "layer_replication": null,
17
+ "layers_pattern": null,
18
+ "layers_to_transform": null,
19
+ "loftq_config": {},
20
+ "lora_alpha": 32,
21
+ "lora_bias": false,
22
+ "lora_dropout": 0.05,
23
+ "lora_ga_config": null,
24
+ "megatron_config": null,
25
+ "megatron_core": "megatron.core",
26
+ "modules_to_save": null,
27
+ "monteclora_config": null,
28
+ "peft_type": "LORA",
29
+ "peft_version": "0.21.2",
30
+ "qalora_group_size": 16,
31
+ "r": 16,
32
+ "rank_pattern": {},
33
+ "revision": null,
34
+ "target_modules": [
35
+ "v_proj",
36
+ "self_attn.gate_proj",
37
+ "k_proj",
38
+ "o_proj",
39
+ "q_proj"
40
+ ],
41
+ "target_parameters": null,
42
+ "task_type": "CAUSAL_LM",
43
+ "trainable_token_indices": null,
44
+ "use_bdlora": null,
45
+ "use_dora": false,
46
+ "use_qalora": false,
47
+ "use_rslora": false,
48
+ "velora_config": null
49
+ }
grpo/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:292cf826c736aa38b1e3d69b4a3e2963364eb37bbca1281073700021b166d52a
3
+ size 62569976
sft/adapter_config.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "nvidia/NVIDIA-Nemotron-Labs-Dory1.0-4B-BF16",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "kasa_config": null,
16
+ "layer_replication": null,
17
+ "layers_pattern": null,
18
+ "layers_to_transform": null,
19
+ "loftq_config": {},
20
+ "lora_alpha": 32,
21
+ "lora_bias": false,
22
+ "lora_dropout": 0.05,
23
+ "lora_ga_config": null,
24
+ "megatron_config": null,
25
+ "megatron_core": "megatron.core",
26
+ "modules_to_save": null,
27
+ "monteclora_config": null,
28
+ "peft_type": "LORA",
29
+ "peft_version": "0.21.2",
30
+ "qalora_group_size": 16,
31
+ "r": 16,
32
+ "rank_pattern": {},
33
+ "revision": null,
34
+ "target_modules": [
35
+ "k_proj",
36
+ "v_proj",
37
+ "o_proj",
38
+ "q_proj",
39
+ "self_attn.gate_proj"
40
+ ],
41
+ "target_parameters": null,
42
+ "task_type": "CAUSAL_LM",
43
+ "trainable_token_indices": null,
44
+ "use_bdlora": null,
45
+ "use_dora": false,
46
+ "use_qalora": false,
47
+ "use_rslora": false,
48
+ "velora_config": null
49
+ }
sft/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:42fd457245d3f04c68c04f6e4514dc113f312189bcaed200a45fbd94f7fc426f
3
+ size 62569976