SJTUFreshman commited on
Commit
7c14598
·
verified ·
1 Parent(s): 5d3cb04

Add a loadable root adapter and default loading entry point

Browse files

Expose the existing final MuSiQue Qwen3-1.7B SLS adapter at the root with matching tokenizer files. Preserve checkpoint paths and record root aliases in the manifest and checksum list.

.gitattributes CHANGED
@@ -275,3 +275,4 @@ assets/figures/Figure1.pdf filter=lfs diff=lfs merge=lfs -text
275
  assets/figures/Figure2.pdf filter=lfs diff=lfs merge=lfs -text
276
  assets/figures/Figure4.pdf filter=lfs diff=lfs merge=lfs -text
277
  assets/figures/Figure5.pdf filter=lfs diff=lfs merge=lfs -text
 
 
275
  assets/figures/Figure2.pdf filter=lfs diff=lfs merge=lfs -text
276
  assets/figures/Figure4.pdf filter=lfs diff=lfs merge=lfs -text
277
  assets/figures/Figure5.pdf filter=lfs diff=lfs merge=lfs -text
278
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -130,6 +130,8 @@ At each step, the current task state is processed by one model from the sliced-m
130
 
131
  | Path | Contents |
132
  | --- | --- |
 
 
133
  | `<benchmark>/PD/<Qwen3-model>/<checkpoint>/` | Protocol distillation (SFT) adapters |
134
  | `<benchmark>/SLS/<Qwen3-model>/<checkpoint>/` | Step-level supervision (RL) adapters |
135
  | `assets/figures/` | Study figures and previews |
@@ -140,6 +142,8 @@ At each step, the current task state is processed by one model from the sliced-m
140
 
141
  The release contains **233 surviving checkpoints across 29 model-stage groups**, approximately **41.39 GiB** including tokenizer assets and configuration. Each selected final training run retains all its surviving `checkpoint-*` exports and its `final` export. Some checkpoints place the adapter in a nested `policy_adapter/` directory, with the tokenizer in the parent directory. MultiPL-E 1.7B is PD-only.
142
 
 
 
143
  Weights are byte-for-byte unchanged. Adapter configurations use the corresponding `Qwen/Qwen3-*` base-model IDs, and JSON metadata has local server paths normalized and credential fields removed. Baseline, ablation, and homogeneous-model weights are outside this release, as are optimizer/RNG states, pickled training arguments, and training data.
144
 
145
  ## 🚀 Quickstart
@@ -152,24 +156,23 @@ python -m pip install -U torch transformers peft accelerate huggingface_hub
152
 
153
  ### 2️⃣ Download and load one adapter
154
 
 
 
155
  ```python
156
- from huggingface_hub import snapshot_download
157
  from transformers import AutoModelForCausalLM, AutoTokenizer
158
- from peft import PeftModel
159
 
160
  repo_id = "SJTUFreshman/collaborativelearning"
161
- subfolder = "MuSiQue/SLS/Qwen3-1.7B/final"
162
- snapshot = snapshot_download(repo_id, allow_patterns=[f"{subfolder}/*"])
163
- adapter_path = f"{snapshot}/{subfolder}"
164
 
165
- tokenizer = AutoTokenizer.from_pretrained(adapter_path)
166
  base_model = AutoModelForCausalLM.from_pretrained(
167
- "Qwen/Qwen3-1.7B", torch_dtype="auto", device_map="auto"
168
  )
169
- model = PeftModel.from_pretrained(base_model, adapter_path)
170
  ```
171
 
172
- Choose the matching base model recorded in `manifest.json`. For a nested `policy_adapter` checkpoint, load the adapter from that directory and the tokenizer from its parent; [load_adapter.py](load_adapter.py) handles both layouts. The frozen base-model weights are downloaded from the original Qwen repositories.
173
 
174
  To download all published checkpoints:
175
 
 
130
 
131
  | Path | Contents |
132
  | --- | --- |
133
+ | `adapter_config.json`, `adapter_model.safetensors` | Default adapter: MuSiQue SLS, Qwen3-1.7B, `final` |
134
+ | `tokenizer.json`, `tokenizer_config.json`, `chat_template.jinja` | Tokenizer for the default adapter |
135
  | `<benchmark>/PD/<Qwen3-model>/<checkpoint>/` | Protocol distillation (SFT) adapters |
136
  | `<benchmark>/SLS/<Qwen3-model>/<checkpoint>/` | Step-level supervision (RL) adapters |
137
  | `assets/figures/` | Study figures and previews |
 
142
 
143
  The release contains **233 surviving checkpoints across 29 model-stage groups**, approximately **41.39 GiB** including tokenizer assets and configuration. Each selected final training run retains all its surviving `checkpoint-*` exports and its `final` export. Some checkpoints place the adapter in a nested `policy_adapter/` directory, with the tokenizer in the parent directory. MultiPL-E 1.7B is PD-only.
144
 
145
+ The repository root provides a directly loadable copy of `MuSiQue/SLS/Qwen3-1.7B/final`. It is one agent's adapter for that task, not a combined model for all benchmarks. Its five root files are byte-identical aliases of the checkpoint assets, adding no new trained checkpoint. All checkpoint subfolder paths remain available.
146
+
147
  Weights are byte-for-byte unchanged. Adapter configurations use the corresponding `Qwen/Qwen3-*` base-model IDs, and JSON metadata has local server paths normalized and credential fields removed. Baseline, ablation, and homogeneous-model weights are outside this release, as are optimizer/RNG states, pickled training arguments, and training data.
148
 
149
  ## 🚀 Quickstart
 
156
 
157
  ### 2️⃣ Download and load one adapter
158
 
159
+ The default root adapter uses **Qwen3-1.7B** and the final **MuSiQue SLS** checkpoint:
160
+
161
  ```python
 
162
  from transformers import AutoModelForCausalLM, AutoTokenizer
163
+ from peft import PeftConfig, PeftModel
164
 
165
  repo_id = "SJTUFreshman/collaborativelearning"
166
+ adapter_config = PeftConfig.from_pretrained(repo_id)
 
 
167
 
168
+ tokenizer = AutoTokenizer.from_pretrained(repo_id)
169
  base_model = AutoModelForCausalLM.from_pretrained(
170
+ adapter_config.base_model_name_or_path, torch_dtype="auto", device_map="auto"
171
  )
172
+ model = PeftModel.from_pretrained(base_model, repo_id)
173
  ```
174
 
175
+ For another checkpoint, use [load_adapter.py](load_adapter.py) with its subfolder, for example `load_adapter("MATH/SLS/Qwen3-4B/final")`. Calling `load_adapter()` without a subfolder loads only the five root adapter/tokenizer files. Choose the matching base model recorded in `manifest.json`. For a nested `policy_adapter` checkpoint, the helper loads the adapter from that directory and the tokenizer from its parent. The frozen base-model weights are downloaded from the original Qwen repositories.
176
 
177
  To download all published checkpoints:
178
 
SHA256SUMS CHANGED
The diff for this file is too large to render. See raw diff
 
adapter_config.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "Qwen/Qwen3-1.7B",
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
+ "layer_replication": null,
16
+ "layers_pattern": null,
17
+ "layers_to_transform": null,
18
+ "loftq_config": {},
19
+ "lora_alpha": 64,
20
+ "lora_bias": false,
21
+ "lora_dropout": 0.05,
22
+ "lora_ga_config": null,
23
+ "megatron_config": null,
24
+ "megatron_core": "megatron.core",
25
+ "modules_to_save": null,
26
+ "peft_type": "LORA",
27
+ "peft_version": "0.19.1",
28
+ "qalora_group_size": 16,
29
+ "r": 64,
30
+ "rank_pattern": {},
31
+ "revision": null,
32
+ "target_modules": [
33
+ "k_proj",
34
+ "v_proj",
35
+ "o_proj",
36
+ "q_proj"
37
+ ],
38
+ "target_parameters": null,
39
+ "task_type": "CAUSAL_LM",
40
+ "trainable_token_indices": null,
41
+ "use_bdlora": null,
42
+ "use_dora": false,
43
+ "use_qalora": false,
44
+ "use_rslora": false
45
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d148e71ce3b277ecc47fb67b736e0c5d57c3f5e7121b45f7d5a65d9d4bed233
3
+ size 102790608
chat_template.jinja ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if message.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if loop.index0 > ns.last_query_index %}
44
+ {%- if loop.last or (not loop.last and reasoning_content) %}
45
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
46
+ {%- else %}
47
+ {{- '<|im_start|>' + message.role + '\n' + content }}
48
+ {%- endif %}
49
+ {%- else %}
50
+ {{- '<|im_start|>' + message.role + '\n' + content }}
51
+ {%- endif %}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if (loop.first and content) or (not loop.first) %}
55
+ {{- '\n' }}
56
+ {%- endif %}
57
+ {%- if tool_call.function %}
58
+ {%- set tool_call = tool_call.function %}
59
+ {%- endif %}
60
+ {{- '<tool_call>\n{"name": "' }}
61
+ {{- tool_call.name }}
62
+ {{- '", "arguments": ' }}
63
+ {%- if tool_call.arguments is string %}
64
+ {{- tool_call.arguments }}
65
+ {%- else %}
66
+ {{- tool_call.arguments | tojson }}
67
+ {%- endif %}
68
+ {{- '}\n</tool_call>' }}
69
+ {%- endfor %}
70
+ {%- endif %}
71
+ {{- '<|im_end|>\n' }}
72
+ {%- elif message.role == "tool" %}
73
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
74
+ {{- '<|im_start|>user' }}
75
+ {%- endif %}
76
+ {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
+ {{- '\n</tool_response>' }}
79
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
+ {{- '<|im_end|>\n' }}
81
+ {%- endif %}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- if add_generation_prompt %}
85
+ {{- '<|im_start|>assistant\n' }}
86
+ {%- if enable_thinking is defined and enable_thinking is false %}
87
+ {{- '<think>\n\n</think>\n\n' }}
88
+ {%- endif %}
89
+ {%- endif %}
load_adapter.py CHANGED
@@ -7,10 +7,27 @@ from peft import PeftModel
7
  from transformers import AutoModelForCausalLM, AutoTokenizer
8
 
9
 
10
- def load_adapter(subfolder, revision=None):
 
 
 
 
 
 
 
 
 
 
11
  repo_id = 'SJTUFreshman/collaborativelearning'
 
 
 
12
  tokenizer_folder = str(Path(subfolder).parent).replace('\\', '/') if subfolder.endswith('/policy_adapter') else subfolder
13
- snapshot = snapshot_download(repo_id, revision=revision, allow_patterns=[subfolder+'/*', tokenizer_folder+'/tokenizer*', tokenizer_folder+'/chat_template.jinja', tokenizer_folder+'/special_tokens_map.json'])
 
 
 
 
14
  adapter_dir = Path(snapshot)/subfolder
15
  config = json.loads((adapter_dir/'adapter_config.json').read_text())
16
  tokenizer = AutoTokenizer.from_pretrained(Path(snapshot)/tokenizer_folder)
@@ -21,8 +38,8 @@ def load_adapter(subfolder, revision=None):
21
 
22
  if __name__ == '__main__':
23
  parser = argparse.ArgumentParser()
24
- parser.add_argument('subfolder')
25
  parser.add_argument('--revision')
26
  args = parser.parse_args()
27
  model, tokenizer = load_adapter(args.subfolder, args.revision)
28
- print('Loaded', args.subfolder)
 
7
  from transformers import AutoModelForCausalLM, AutoTokenizer
8
 
9
 
10
+ ROOT_FILES = [
11
+ 'adapter_config.json',
12
+ 'adapter_model.safetensors',
13
+ 'tokenizer.json',
14
+ 'tokenizer_config.json',
15
+ 'chat_template.jinja',
16
+ ]
17
+
18
+
19
+ def load_adapter(subfolder=None, revision=None):
20
+ """Load the root MuSiQue 1.7B SLS adapter, or a checkpoint subfolder."""
21
  repo_id = 'SJTUFreshman/collaborativelearning'
22
+ subfolder = (subfolder or '').replace('\\', '/').strip('/')
23
+ if subfolder == '.':
24
+ subfolder = ''
25
  tokenizer_folder = str(Path(subfolder).parent).replace('\\', '/') if subfolder.endswith('/policy_adapter') else subfolder
26
+ patterns = (
27
+ [subfolder+'/*', tokenizer_folder+'/tokenizer*', tokenizer_folder+'/chat_template.jinja', tokenizer_folder+'/special_tokens_map.json']
28
+ if subfolder else ROOT_FILES
29
+ )
30
+ snapshot = snapshot_download(repo_id, revision=revision, allow_patterns=patterns)
31
  adapter_dir = Path(snapshot)/subfolder
32
  config = json.loads((adapter_dir/'adapter_config.json').read_text())
33
  tokenizer = AutoTokenizer.from_pretrained(Path(snapshot)/tokenizer_folder)
 
38
 
39
  if __name__ == '__main__':
40
  parser = argparse.ArgumentParser()
41
+ parser.add_argument('subfolder', nargs='?', help='Checkpoint directory; default: root MuSiQue 1.7B SLS adapter')
42
  parser.add_argument('--revision')
43
  args = parser.parse_args()
44
  model, tokenizer = load_adapter(args.subfolder, args.revision)
45
+ print('Loaded', args.subfolder or 'root (MuSiQue/SLS/Qwen3-1.7B/final)')
manifest.json CHANGED
The diff for this file is too large to render. See raw diff
 
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9015c7b9bcc5ac57906c55460048b82b9dfcdef34eb1f781c079da50de99f3d0
3
+ size 11422749
tokenizer_config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|im_start|>",
10
+ "<|im_end|>",
11
+ "<|object_ref_start|>",
12
+ "<|object_ref_end|>",
13
+ "<|box_start|>",
14
+ "<|box_end|>",
15
+ "<|quad_start|>",
16
+ "<|quad_end|>",
17
+ "<|vision_start|>",
18
+ "<|vision_end|>",
19
+ "<|vision_pad|>",
20
+ "<|image_pad|>",
21
+ "<|video_pad|>"
22
+ ],
23
+ "is_local": true,
24
+ "local_files_only": false,
25
+ "model_max_length": 131072,
26
+ "pad_token": "<|endoftext|>",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "Qwen2Tokenizer",
29
+ "unk_token": null
30
+ }