初始化项目,由ModelHub XC社区提供模型
Model: tawer12/qwen3-4b-recursive-sft-v3.2 Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||
202
LICENSE
Normal file
202
LICENSE
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2024 Alibaba Cloud
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
145
README.md
Normal file
145
README.md
Normal file
@@ -0,0 +1,145 @@
|
||||
---
|
||||
language:
|
||||
- en
|
||||
license: apache-2.0
|
||||
library_name: transformers
|
||||
pipeline_tag: text-generation
|
||||
base_model: Qwen/Qwen3-4B-Base
|
||||
base_model_relation: finetune
|
||||
tags:
|
||||
- math
|
||||
- recursive-reasoning
|
||||
- supervised-fine-tuning
|
||||
- qwen3
|
||||
datasets:
|
||||
- openai/gsm8k
|
||||
---
|
||||
|
||||
# Qwen3-4B Recursive SFT V3.2
|
||||
|
||||
This is the **original-tag recursive V3.2 balanced SFT checkpoint**. It is not
|
||||
V3.1, the JSON variant, the flattened baseline, or an RL-finetuned model.
|
||||
The weights and tokenizer are unchanged from the final saved checkpoint named
|
||||
`qwen3-4b-recursive-sft-v3.2-balanced`.
|
||||
|
||||
The model was trained from Qwen3-4B-Base with additional recursive protocol
|
||||
tokens. It was not initialized from the already SFT-trained V3.1 model.
|
||||
It is a research math-solving model, not a general-purpose chat assistant.
|
||||
|
||||
## Download
|
||||
|
||||
No ZIP extraction or login is required:
|
||||
|
||||
```python
|
||||
from huggingface_hub import snapshot_download
|
||||
|
||||
snapshot_download(
|
||||
"tawer12/qwen3-4b-recursive-sft-v3.2",
|
||||
local_dir="qwen3-4b-recursive-sft-v3.2",
|
||||
)
|
||||
```
|
||||
|
||||
The two safetensors shards, tokenizer files, and configuration files must be
|
||||
kept together. `release_manifest.json` lists file sizes and SHA256 checksums.
|
||||
The download is approximately 8.06 GB. There are no optimizer states, pickled
|
||||
training arguments, intermediate checkpoints, training examples, or evaluation
|
||||
rollouts in this repository.
|
||||
|
||||
## Training
|
||||
|
||||
V3.2 downsamples only direct-solve examples from the expanded V3.1 call-level
|
||||
training corpus, retaining the decomposition and aggregation examples unchanged.
|
||||
|
||||
| Setting | Value |
|
||||
| --- | --- |
|
||||
| Decomposition examples | 4,707 |
|
||||
| Direct-solve examples | 4,707: 530 root, 4,177 child |
|
||||
| Aggregation examples | 4,712 |
|
||||
| Total component-level examples | 14,126 |
|
||||
| Unique source problems represented | 5,241 |
|
||||
| Configured epochs | 6 |
|
||||
| Optimizer updates | 660 |
|
||||
| Global batch | 128 component calls, not 128 source problems |
|
||||
| GPUs / per-device batch / accumulation | 8 / 1 / 16 |
|
||||
| Maximum sequence length | 2,048 tokens |
|
||||
| Learning rate / weight decay | 1e-5 / 0.01 |
|
||||
| Warmup / scheduler | 10% / cosine |
|
||||
| Precision / seed | BF16 / 1 |
|
||||
| Objective | Output-token-only causal language modeling |
|
||||
|
||||
The six epochs approximately match the previous four-epoch V3.1 run's total
|
||||
example exposure; this is not an exactly token- or update-matched experiment.
|
||||
The corpus contains independent component calls, not necessarily complete trees
|
||||
after downsampling. No syntax repair was applied: 387 targets retain known
|
||||
defects under the newer strict `Final answer:` requirement. The training summary
|
||||
is included separately from the raw training state.
|
||||
|
||||
## Recursive Inference
|
||||
|
||||
Inputs are **raw recursive prompt strings**, not Qwen chat-template conversations.
|
||||
Use `prompts/recursive_sft_prefix_prompt.txt`. Preserve protocol special tokens
|
||||
when decoding (`skip_special_tokens=False`). A single generation returns one
|
||||
action, not necessarily the entire solution:
|
||||
|
||||
- `SOLVE_DIRECTLY`: solve the supplied problem.
|
||||
- `DECOMPOSE`: propose at least two child paths for the engine to execute.
|
||||
- `AGGREGATE`: combine child answers when the engine requests aggregation.
|
||||
|
||||
The bundled `recursive_engine.py` provides a standalone, unconstrained baseline
|
||||
engine. This example executes a complete tree:
|
||||
|
||||
```bash
|
||||
pip install 'transformers==4.51.1' torch accelerate huggingface_hub
|
||||
```
|
||||
|
||||
```python
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from huggingface_hub import snapshot_download
|
||||
|
||||
snapshot = Path(snapshot_download("tawer12/qwen3-4b-recursive-sft-v3.2"))
|
||||
sys.path.insert(0, str(snapshot))
|
||||
from recursive_engine import RecursiveEngine, load_model_and_tokenizer
|
||||
|
||||
model, tokenizer = load_model_and_tokenizer(str(snapshot), dtype="bf16", device_map="auto")
|
||||
engine = RecursiveEngine(
|
||||
model=model,
|
||||
tokenizer=tokenizer,
|
||||
prefix_template=(snapshot / "prompts/recursive_sft_prefix_prompt.txt").read_text(),
|
||||
max_new_tokens=2048,
|
||||
temperature=0.0,
|
||||
top_p=1.0,
|
||||
max_depth=3,
|
||||
max_calls=10,
|
||||
)
|
||||
result = engine.rollout("What is the smallest multiple of 5 greater than -32?")
|
||||
print(result.full_trace)
|
||||
print(result.final_answer, result.parsed_ok, result.parse_errors)
|
||||
```
|
||||
|
||||
For this bundled legacy engine, `max_calls=10` is a **whole-tree model-call limit**,
|
||||
including the root and aggregations, not ten children per node. The newer
|
||||
constrained GRPO/evaluation implementation in the
|
||||
[math-recursive repository](https://github.com/0315jaewon/math-recursive)
|
||||
has separate per-decomposition and whole-tree limits. Do not conflate them.
|
||||
The example helper enables the generation cache even though the saved training
|
||||
configuration has `use_cache=false`.
|
||||
|
||||
## Limitations And Attribution
|
||||
|
||||
Format validity and answer correctness are distinct. A malformed downstream call
|
||||
can invalidate a tree, and well-formed child answers can be mathematically wrong.
|
||||
Decomposition paths may be dependent or underspecified. Aggregation receives
|
||||
child answer summaries rather than their full reasoning. The standalone engine
|
||||
executes children sequentially; critical-path token counts are not measured
|
||||
parallel wall-clock speedups. Grammar constraints are external decoding support,
|
||||
not an intrinsic guarantee supplied by this checkpoint.
|
||||
|
||||
The historical helper's answer extraction is not an authoritative benchmark
|
||||
grader; use explicit root-answer grading and the standard evaluation protocol
|
||||
for comparisons. No new benchmark accuracy claims are made in this release.
|
||||
|
||||
This is a modified, fine-tuned version of the Qwen team's Apache-2.0
|
||||
Qwen3-4B-Base model. The upstream license is included in `LICENSE`. GSM8K supplies
|
||||
the curated training questions. The model card and publishing recipe were added
|
||||
for this V3.2 release on 2026-09-30.
|
||||
36
added_tokens.json
Normal file
36
added_tokens.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"</action>": 151672,
|
||||
"</parallel>": 151674,
|
||||
"</path>": 151676,
|
||||
"</problem>": 151670,
|
||||
"</think>": 151668,
|
||||
"</tool_call>": 151658,
|
||||
"</tool_response>": 151666,
|
||||
"<action>": 151671,
|
||||
"<parallel>": 151673,
|
||||
"<path>": 151675,
|
||||
"<problem>": 151669,
|
||||
"<think>": 151667,
|
||||
"<tool_call>": 151657,
|
||||
"<tool_response>": 151665,
|
||||
"<|box_end|>": 151649,
|
||||
"<|box_start|>": 151648,
|
||||
"<|endoftext|>": 151643,
|
||||
"<|file_sep|>": 151664,
|
||||
"<|fim_middle|>": 151660,
|
||||
"<|fim_pad|>": 151662,
|
||||
"<|fim_prefix|>": 151659,
|
||||
"<|fim_suffix|>": 151661,
|
||||
"<|im_end|>": 151645,
|
||||
"<|im_start|>": 151644,
|
||||
"<|image_pad|>": 151655,
|
||||
"<|object_ref_end|>": 151647,
|
||||
"<|object_ref_start|>": 151646,
|
||||
"<|quad_end|>": 151651,
|
||||
"<|quad_start|>": 151650,
|
||||
"<|repo_name|>": 151663,
|
||||
"<|video_pad|>": 151656,
|
||||
"<|vision_end|>": 151653,
|
||||
"<|vision_pad|>": 151654,
|
||||
"<|vision_start|>": 151652
|
||||
}
|
||||
30
config.json
Normal file
30
config.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"architectures": [
|
||||
"Qwen3ForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 151643,
|
||||
"eos_token_id": 151643,
|
||||
"head_dim": 128,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 2560,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 9728,
|
||||
"max_position_embeddings": 32768,
|
||||
"max_window_layers": 36,
|
||||
"model_type": "qwen3",
|
||||
"num_attention_heads": 32,
|
||||
"num_hidden_layers": 36,
|
||||
"num_key_value_heads": 8,
|
||||
"rms_norm_eps": 1e-06,
|
||||
"rope_scaling": null,
|
||||
"rope_theta": 1000000,
|
||||
"sliding_window": null,
|
||||
"tie_word_embeddings": true,
|
||||
"torch_dtype": "bfloat16",
|
||||
"transformers_version": "4.51.1",
|
||||
"use_cache": false,
|
||||
"use_sliding_window": false,
|
||||
"vocab_size": 151677
|
||||
}
|
||||
6
generation_config.json
Normal file
6
generation_config.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"bos_token_id": 151643,
|
||||
"eos_token_id": 151643,
|
||||
"max_new_tokens": 2048,
|
||||
"transformers_version": "4.51.1"
|
||||
}
|
||||
151388
merges.txt
Normal file
151388
merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
model-00001-of-00002.safetensors
Normal file
3
model-00001-of-00002.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bfbbbe85189139434cf416640d45ba70c374ca01b00c80323bef8e8679e7b4c6
|
||||
size 4965889280
|
||||
3
model-00002-of-00002.safetensors
Normal file
3
model-00002-of-00002.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:00a3f550612694718240c6051c491e6b7bf44f80c5d31802d67abdc8666ad9b0
|
||||
size 3077766632
|
||||
405
model.safetensors.index.json
Normal file
405
model.safetensors.index.json
Normal file
@@ -0,0 +1,405 @@
|
||||
{
|
||||
"metadata": {
|
||||
"total_size": 8043610112
|
||||
},
|
||||
"weight_map": {
|
||||
"model.embed_tokens.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.20.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.20.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.20.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.20.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.20.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.21.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.21.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.21.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.21.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.21.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.21.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.21.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.21.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.21.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.22.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.23.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.24.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.25.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.26.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.27.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.28.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.29.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.3.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.3.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.30.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.30.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.30.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.30.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.30.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.30.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.30.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.30.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.30.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.31.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.32.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.33.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.34.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.self_attn.k_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.self_attn.q_norm.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.35.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
||||
"model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.4.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.4.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.self_attn.k_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.self_attn.q_norm.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
||||
"model.norm.weight": "model-00002-of-00002.safetensors"
|
||||
}
|
||||
}
|
||||
19
prompts/recursive_sft_prefix_prompt.txt
Normal file
19
prompts/recursive_sft_prefix_prompt.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
You are a stateless recursive math solver.
|
||||
|
||||
Every call receives one self-contained <problem> and returns one <action>.
|
||||
|
||||
Allowed actions:
|
||||
- SOLVE_DIRECTLY: solve the current problem directly.
|
||||
- DECOMPOSE: create useful standalone subproblems inside <parallel>.
|
||||
- AGGREGATE: combine path results into the answer for a parent problem.
|
||||
|
||||
If using DECOMPOSE, immediately follow the <action>...</action> block with exactly one <parallel>...</parallel> block containing at least two <path>...</path> blocks.
|
||||
|
||||
Each <path> must be self-contained and answerable without seeing the output of another path. A path may return a partial result such as a value, formula, lemma, case result, candidate set, constraint, or verification.
|
||||
|
||||
Put all reasoning, results, and checks inside the <action>...</action> block.
|
||||
Use only these tags: <problem>, </problem>, <action>, </action>, <parallel>, </parallel>, <path>, </path>.
|
||||
|
||||
<problem>
|
||||
{PROBLEM}
|
||||
</problem>
|
||||
570
recursive_engine.py
Normal file
570
recursive_engine.py
Normal file
@@ -0,0 +1,570 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Recursive inference engine for stateless recursive math-solving models."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
TAG_RE = re.compile(r"</?(problem|action|parallel|path)>", re.IGNORECASE)
|
||||
NUMBER_RE = re.compile(r"-?\d+(?:,\d{3})*(?:\.\d+)?|-?\d+/\d+")
|
||||
FINAL_ANSWER_LINE_RE = re.compile(
|
||||
r"(?im)^[ \t]*Final[ \t]+answer[ \t]*:[ \t]*(?P<answer>[^\n]+)$"
|
||||
)
|
||||
DEFAULT_PREFIX_PROMPT_FILE = Path("prompts") / "recursive_sft_prefix_prompt.txt"
|
||||
FORCED_ROOT_OUTPUT_PREFIXES = {
|
||||
"SOLVE_DIRECTLY": "<action>\nSOLVE_DIRECTLY\n",
|
||||
"DECOMPOSE": "<action>\nDECOMPOSE\n</action>\n<parallel>\n",
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class ModelCall:
|
||||
call_id: int
|
||||
depth: int
|
||||
role: str
|
||||
problem: str
|
||||
input_text: str
|
||||
output_text: str
|
||||
input_tokens: int
|
||||
output_tokens: int
|
||||
action_type: str | None = None
|
||||
parse_error: str | None = None
|
||||
forced_output_prefix: str = ""
|
||||
|
||||
|
||||
@dataclass
|
||||
class RolloutResult:
|
||||
problem: str
|
||||
final_answer: str | None
|
||||
full_trace: str
|
||||
calls: list[ModelCall] = field(default_factory=list)
|
||||
parse_errors: list[str] = field(default_factory=list)
|
||||
critical_path_tokens: int = 0
|
||||
stopped_reason: str = "completed"
|
||||
|
||||
@property
|
||||
def parsed_ok(self) -> bool:
|
||||
return not self.parse_errors
|
||||
|
||||
@property
|
||||
def model_call_count(self) -> int:
|
||||
return len(self.calls)
|
||||
|
||||
|
||||
@dataclass
|
||||
class NodeResult:
|
||||
final_answer: str | None
|
||||
trace: str
|
||||
critical_path_tokens: int
|
||||
parse_errors: list[str]
|
||||
stopped_reason: str = "completed"
|
||||
|
||||
|
||||
def load_prefix_template(path: str | Path | None = None) -> str:
|
||||
prompt_path = Path(path) if path is not None else DEFAULT_PREFIX_PROMPT_FILE
|
||||
return prompt_path.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def format_model_input(problem: str, prefix_template: str) -> str:
|
||||
return prefix_template.strip().replace("{PROBLEM}", problem.strip())
|
||||
|
||||
|
||||
def token_count(tokenizer: Any, text: str) -> int:
|
||||
return len(tokenizer.encode(text, add_special_tokens=False))
|
||||
|
||||
|
||||
def extract_blocks(text: str, tag: str) -> list[str]:
|
||||
return [
|
||||
match.group(1).strip()
|
||||
for match in re.finditer(rf"<{tag}>(.*?)</{tag}>", text, flags=re.DOTALL | re.IGNORECASE)
|
||||
]
|
||||
|
||||
|
||||
def normalize_answer(value: Any) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
text = str(value).strip()
|
||||
if not text:
|
||||
return None
|
||||
if "####" in text:
|
||||
text = text.split("####")[-1].strip()
|
||||
boxed = re.findall(r"\\boxed\{([^{}]+)\}", text)
|
||||
if boxed:
|
||||
text = boxed[-1]
|
||||
final = re.findall(r"(?i)Final\s+answer\s*:\s*([^\n<]+)", text)
|
||||
if final:
|
||||
text = final[-1]
|
||||
text = text.replace("$", "").replace(",", "")
|
||||
text = re.sub(r"\\(?:text|mathrm)\{([^{}]+)\}", r"\1", text)
|
||||
text = re.sub(r"\s+", "", text)
|
||||
text = text.rstrip(".")
|
||||
return text or None
|
||||
|
||||
|
||||
def extract_final_answer(text: str) -> str | None:
|
||||
patterns = [
|
||||
r"(?i)Final\s+answer\s*:\s*([^\n<]+)",
|
||||
r"(?i)answer\s+is\s*([^\n<]+)",
|
||||
r"\\boxed\{([^{}]+)\}",
|
||||
]
|
||||
for pattern in patterns:
|
||||
matches = re.findall(pattern, text)
|
||||
if matches:
|
||||
return normalize_answer(matches[-1])
|
||||
matches = NUMBER_RE.findall(text)
|
||||
if matches:
|
||||
return normalize_answer(matches[-1])
|
||||
return None
|
||||
|
||||
|
||||
def answers_match(pred: str | None, gt: str | None) -> bool:
|
||||
pred_norm = normalize_answer(pred)
|
||||
gt_norm = normalize_answer(gt)
|
||||
if pred_norm is None or gt_norm is None:
|
||||
return False
|
||||
|
||||
if pred_norm == gt_norm:
|
||||
return True
|
||||
|
||||
try:
|
||||
from math_verify import LatexExtractionConfig, parse, verify
|
||||
|
||||
pred_parsed = parse(pred_norm, extraction_config=[LatexExtractionConfig()])
|
||||
gt_parsed = parse(gt_norm, extraction_config=[LatexExtractionConfig()])
|
||||
if pred_parsed and gt_parsed and verify(gt_parsed, pred_parsed):
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return pred_norm.lower() == gt_norm.lower()
|
||||
|
||||
|
||||
def find_matching_tag(text: str, tag: str, open_start: int, open_end: int) -> tuple[int, int] | None:
|
||||
depth = 1
|
||||
for match in TAG_RE.finditer(text, open_end):
|
||||
token = match.group(0).lower()
|
||||
name = match.group(1).lower()
|
||||
if name != tag:
|
||||
continue
|
||||
if token.startswith("</"):
|
||||
depth -= 1
|
||||
if depth == 0:
|
||||
return match.start(), match.end()
|
||||
else:
|
||||
depth += 1
|
||||
return None
|
||||
|
||||
|
||||
def parse_model_output(output: str) -> tuple[str, list[str]]:
|
||||
action_match = re.search(r"<action>(.*?)</action>", output, flags=re.DOTALL | re.IGNORECASE)
|
||||
if not action_match:
|
||||
raise ValueError("missing <action>...</action> block")
|
||||
|
||||
action_body = action_match.group(1).strip()
|
||||
first_line = action_body.splitlines()[0].strip().upper() if action_body else ""
|
||||
if first_line.startswith("SOLVE_DIRECTLY"):
|
||||
return "SOLVE_DIRECTLY", []
|
||||
if first_line.startswith("AGGREGATE"):
|
||||
return "AGGREGATE", []
|
||||
if not first_line.startswith("DECOMPOSE"):
|
||||
raise ValueError(f"unknown action type in first action line: {first_line!r}")
|
||||
|
||||
next_nonspace = re.search(r"\S", output[action_match.end() :])
|
||||
if not next_nonspace:
|
||||
raise ValueError("DECOMPOSE action is not followed by <parallel>")
|
||||
|
||||
parallel_start = action_match.end() + next_nonspace.start()
|
||||
if not output[parallel_start:].lower().startswith("<parallel>"):
|
||||
raise ValueError("DECOMPOSE action is not immediately followed by <parallel>")
|
||||
|
||||
parallel_open_end = parallel_start + len("<parallel>")
|
||||
close = find_matching_tag(output, "parallel", parallel_start, parallel_open_end)
|
||||
if close is None:
|
||||
raise ValueError("unclosed <parallel> block")
|
||||
parallel_body = output[parallel_open_end : close[0]]
|
||||
paths = extract_blocks(f"<parallel>{parallel_body}</parallel>", "path")
|
||||
if len(paths) < 2:
|
||||
raise ValueError(f"DECOMPOSE parallel block has {len(paths)} path(s), expected at least 2")
|
||||
if any(not path for path in paths):
|
||||
raise ValueError("DECOMPOSE parallel block contains an empty path")
|
||||
return "DECOMPOSE", paths
|
||||
|
||||
|
||||
def validate_action_protocol(output: str, action_type: str, role: str) -> None:
|
||||
"""Enforce role-specific actions and explicit answers for terminal calls."""
|
||||
normalized_role = role.strip().lower()
|
||||
if normalized_role == "root":
|
||||
allowed_actions = {"DECOMPOSE", "SOLVE_DIRECTLY"}
|
||||
elif normalized_role == "aggregate":
|
||||
allowed_actions = {"AGGREGATE"}
|
||||
elif normalized_role == "child" or normalized_role.startswith("path_"):
|
||||
allowed_actions = {"DECOMPOSE", "SOLVE_DIRECTLY"}
|
||||
else:
|
||||
raise ValueError(f"unknown call role: {role!r}")
|
||||
|
||||
if action_type not in allowed_actions:
|
||||
expected = " or ".join(sorted(allowed_actions))
|
||||
raise ValueError(
|
||||
f"{normalized_role} call returned {action_type}, expected {expected}"
|
||||
)
|
||||
|
||||
if action_type not in {"SOLVE_DIRECTLY", "AGGREGATE"}:
|
||||
return
|
||||
|
||||
action_match = re.search(
|
||||
r"<action>(.*?)</action>", output, flags=re.DOTALL | re.IGNORECASE
|
||||
)
|
||||
action_body = action_match.group(1) if action_match else ""
|
||||
final_answer = FINAL_ANSWER_LINE_RE.search(action_body)
|
||||
if final_answer is None or not final_answer.group("answer").strip():
|
||||
raise ValueError(f"{action_type} action is missing a non-empty Final answer: line")
|
||||
|
||||
|
||||
def extract_final_answer_display(text: str) -> str | None:
|
||||
patterns = [
|
||||
r"(?i)Final\s+answer\s*:\s*([^\n<]+)",
|
||||
r"\\boxed\{([^{}]+)\}",
|
||||
]
|
||||
for pattern in patterns:
|
||||
matches = re.findall(pattern, text)
|
||||
if matches:
|
||||
return matches[-1].strip().rstrip(".")
|
||||
return None
|
||||
|
||||
|
||||
def child_result_summary(result: NodeResult) -> str:
|
||||
display = extract_final_answer_display(result.trace)
|
||||
if display is not None:
|
||||
return display
|
||||
if result.final_answer is not None:
|
||||
return str(result.final_answer)
|
||||
fallback = extract_final_answer(result.trace)
|
||||
if fallback is not None:
|
||||
return str(fallback)
|
||||
return "PARSE_ERROR" if result.parse_errors else "UNKNOWN"
|
||||
|
||||
|
||||
def build_aggregation_problem(parent_problem: str, paths: list[str], child_results: list[NodeResult]) -> str:
|
||||
lines = [
|
||||
f"The original problem is: {parent_problem.strip()}",
|
||||
"The paths spawned were:",
|
||||
]
|
||||
for idx, (path, result) in enumerate(zip(paths, child_results), start=1):
|
||||
summary = child_result_summary(result)
|
||||
lines.append(f"{idx}. {path.strip()} (Result: {summary}).")
|
||||
lines.append("Aggregate these results to find the answer to the original problem.")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
class RecursiveEngine:
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
model: Any,
|
||||
tokenizer: Any,
|
||||
prefix_template: str,
|
||||
max_new_tokens: int = 768,
|
||||
temperature: float = 0.0,
|
||||
top_p: float = 1.0,
|
||||
top_k: int | None = None,
|
||||
max_depth: int = 3,
|
||||
max_calls: int = 10,
|
||||
force_root_action: str | None = None,
|
||||
) -> None:
|
||||
self.model = model
|
||||
self.tokenizer = tokenizer
|
||||
self.prefix_template = prefix_template
|
||||
self.max_new_tokens = max_new_tokens
|
||||
self.temperature = temperature
|
||||
self.top_p = top_p
|
||||
self.top_k = top_k
|
||||
self.max_depth = max_depth
|
||||
self.max_calls = max_calls
|
||||
normalized_force = force_root_action.upper() if force_root_action else None
|
||||
if normalized_force not in {None, *FORCED_ROOT_OUTPUT_PREFIXES}:
|
||||
raise ValueError(
|
||||
"force_root_action must be SOLVE_DIRECTLY, DECOMPOSE, or None"
|
||||
)
|
||||
self.force_root_action = normalized_force
|
||||
self.calls: list[ModelCall] = []
|
||||
|
||||
def generate_once(self, input_text: str, *, output_prefix: str = "") -> str:
|
||||
import torch
|
||||
|
||||
generation_input = input_text + output_prefix
|
||||
inputs = self.tokenizer(generation_input, return_tensors="pt")
|
||||
device = next(self.model.parameters()).device
|
||||
inputs = {key: value.to(device) for key, value in inputs.items()}
|
||||
generation_kwargs = {
|
||||
"max_new_tokens": self.max_new_tokens,
|
||||
"do_sample": self.temperature > 0,
|
||||
"top_p": self.top_p,
|
||||
"use_cache": True,
|
||||
"pad_token_id": self.tokenizer.pad_token_id or self.tokenizer.eos_token_id,
|
||||
"eos_token_id": self.tokenizer.eos_token_id,
|
||||
}
|
||||
if self.temperature > 0:
|
||||
generation_kwargs["temperature"] = self.temperature
|
||||
if self.top_k is not None:
|
||||
generation_kwargs["top_k"] = self.top_k
|
||||
with torch.no_grad():
|
||||
generated = self.model.generate(
|
||||
**inputs,
|
||||
**generation_kwargs,
|
||||
)
|
||||
new_tokens = generated[0, inputs["input_ids"].shape[1] :]
|
||||
continuation = self.tokenizer.decode(new_tokens, skip_special_tokens=False).strip()
|
||||
return output_prefix + continuation
|
||||
|
||||
def rollout(self, problem: str) -> RolloutResult:
|
||||
self.calls = []
|
||||
root = self._solve_node(problem=problem, depth=0, role="root")
|
||||
return RolloutResult(
|
||||
problem=problem,
|
||||
final_answer=root.final_answer,
|
||||
full_trace=root.trace,
|
||||
calls=self.calls,
|
||||
parse_errors=root.parse_errors,
|
||||
critical_path_tokens=root.critical_path_tokens,
|
||||
stopped_reason=root.stopped_reason,
|
||||
)
|
||||
|
||||
def _solve_node(self, *, problem: str, depth: int, role: str) -> NodeResult:
|
||||
if len(self.calls) >= self.max_calls:
|
||||
return NodeResult(
|
||||
final_answer=None,
|
||||
trace="",
|
||||
critical_path_tokens=0,
|
||||
parse_errors=[f"max model calls exceeded ({self.max_calls})"],
|
||||
stopped_reason="max_calls",
|
||||
)
|
||||
if depth > self.max_depth:
|
||||
return NodeResult(
|
||||
final_answer=None,
|
||||
trace="",
|
||||
critical_path_tokens=0,
|
||||
parse_errors=[f"max recursion depth exceeded ({self.max_depth})"],
|
||||
stopped_reason="max_depth",
|
||||
)
|
||||
|
||||
input_text = format_model_input(problem, self.prefix_template)
|
||||
forced_output_prefix = ""
|
||||
if depth == 0 and role == "root" and self.force_root_action is not None:
|
||||
forced_output_prefix = FORCED_ROOT_OUTPUT_PREFIXES[self.force_root_action]
|
||||
output_text = self.generate_once(
|
||||
input_text,
|
||||
output_prefix=forced_output_prefix,
|
||||
)
|
||||
generated_output = (
|
||||
output_text[len(forced_output_prefix) :]
|
||||
if forced_output_prefix and output_text.startswith(forced_output_prefix)
|
||||
else output_text
|
||||
)
|
||||
call = ModelCall(
|
||||
call_id=len(self.calls) + 1,
|
||||
depth=depth,
|
||||
role=role,
|
||||
problem=problem,
|
||||
input_text=input_text,
|
||||
output_text=output_text,
|
||||
input_tokens=token_count(self.tokenizer, input_text + forced_output_prefix),
|
||||
output_tokens=token_count(self.tokenizer, generated_output),
|
||||
forced_output_prefix=forced_output_prefix,
|
||||
)
|
||||
self.calls.append(call)
|
||||
own_tokens = call.input_tokens + call.output_tokens
|
||||
|
||||
try:
|
||||
action_type, paths = parse_model_output(output_text)
|
||||
validate_action_protocol(output_text, action_type, role)
|
||||
call.action_type = action_type
|
||||
except ValueError as exc:
|
||||
call.parse_error = str(exc)
|
||||
return NodeResult(
|
||||
final_answer=None,
|
||||
trace=output_text,
|
||||
critical_path_tokens=own_tokens,
|
||||
parse_errors=[f"call_{call.call_id}: {exc}"],
|
||||
stopped_reason="parse_error",
|
||||
)
|
||||
|
||||
if action_type in {"SOLVE_DIRECTLY", "AGGREGATE"}:
|
||||
return NodeResult(
|
||||
final_answer=extract_final_answer(output_text),
|
||||
trace=output_text,
|
||||
critical_path_tokens=own_tokens,
|
||||
parse_errors=[],
|
||||
)
|
||||
|
||||
child_results = [
|
||||
self._solve_node(problem=path, depth=depth + 1, role=f"path_{idx}")
|
||||
for idx, path in enumerate(paths, start=1)
|
||||
]
|
||||
aggregate_problem = build_aggregation_problem(problem, paths, child_results)
|
||||
aggregate_result = self._solve_node(
|
||||
problem=aggregate_problem,
|
||||
depth=depth + 1,
|
||||
role="aggregate",
|
||||
)
|
||||
child_trace = "\n\n".join(
|
||||
f"<problem>\n{path.strip()}\n</problem>\n{result.trace.strip()}"
|
||||
for path, result in zip(paths, child_results)
|
||||
)
|
||||
full_trace = "\n\n".join(
|
||||
part
|
||||
for part in [
|
||||
output_text.strip(),
|
||||
child_trace.strip(),
|
||||
f"<problem>\n{aggregate_problem.strip()}\n</problem>\n{aggregate_result.trace.strip()}",
|
||||
]
|
||||
if part
|
||||
)
|
||||
child_critical = max((result.critical_path_tokens for result in child_results), default=0)
|
||||
parse_errors: list[str] = []
|
||||
stopped_reason = "completed"
|
||||
for result in child_results + [aggregate_result]:
|
||||
parse_errors.extend(result.parse_errors)
|
||||
if result.stopped_reason != "completed":
|
||||
stopped_reason = result.stopped_reason
|
||||
|
||||
return NodeResult(
|
||||
final_answer=aggregate_result.final_answer,
|
||||
trace=full_trace,
|
||||
critical_path_tokens=own_tokens + child_critical + aggregate_result.critical_path_tokens,
|
||||
parse_errors=parse_errors,
|
||||
stopped_reason=stopped_reason,
|
||||
)
|
||||
|
||||
|
||||
def load_model_and_tokenizer(model_path: str, dtype: str = "bf16", device_map: str | None = None) -> tuple[Any, Any]:
|
||||
import torch
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
||||
if tokenizer.pad_token is None:
|
||||
tokenizer.pad_token = tokenizer.eos_token
|
||||
|
||||
dtype_map = {
|
||||
"bf16": torch.bfloat16,
|
||||
"fp16": torch.float16,
|
||||
"fp32": torch.float32,
|
||||
"auto": "auto",
|
||||
}
|
||||
torch_dtype = dtype_map.get(dtype, torch.bfloat16)
|
||||
kwargs: dict[str, Any] = {
|
||||
"torch_dtype": torch_dtype,
|
||||
"trust_remote_code": True,
|
||||
}
|
||||
if device_map:
|
||||
kwargs["device_map"] = device_map
|
||||
model = AutoModelForCausalLM.from_pretrained(model_path, **kwargs)
|
||||
if not device_map:
|
||||
model = model.to("cuda" if torch.cuda.is_available() else "cpu")
|
||||
# SFT checkpoints commonly persist use_cache=False from gradient checkpointing.
|
||||
# Generation should always use the KV cache, or long rollouts become prohibitively slow.
|
||||
model.config.use_cache = True
|
||||
model.eval()
|
||||
return model, tokenizer
|
||||
|
||||
|
||||
def row_to_eval_record(
|
||||
item: dict[str, Any],
|
||||
*,
|
||||
idx: int,
|
||||
split: str,
|
||||
problem_field: str | None,
|
||||
answer_field: str | None,
|
||||
) -> dict[str, Any]:
|
||||
p_field = problem_field or infer_field(item, ["problem", "question", "input"])
|
||||
a_field = answer_field or infer_field(item, ["answer", "target", "final_answer", "solution"])
|
||||
if p_field is None:
|
||||
raise ValueError(f"Could not infer problem field. Available fields: {list(item.keys())}")
|
||||
return {
|
||||
"id": str(item.get("id", item.get("unique_id", f"{split}_{idx:06d}"))),
|
||||
"problem": str(item[p_field]),
|
||||
"answer": str(item[a_field]) if a_field and item.get(a_field) is not None else None,
|
||||
"raw": dict(item),
|
||||
}
|
||||
|
||||
|
||||
def load_eval_jsonl(
|
||||
*,
|
||||
path: str | Path,
|
||||
problem_field: str | None,
|
||||
answer_field: str | None,
|
||||
limit: int | None,
|
||||
start_index: int = 0,
|
||||
) -> list[dict[str, Any]]:
|
||||
rows: list[dict[str, Any]] = []
|
||||
path = Path(path)
|
||||
with path.open("r", encoding="utf-8") as handle:
|
||||
for absolute_idx, line in enumerate(handle):
|
||||
if absolute_idx < start_index:
|
||||
continue
|
||||
if limit is not None and len(rows) >= limit:
|
||||
break
|
||||
if not line.strip():
|
||||
continue
|
||||
item = json.loads(line)
|
||||
rows.append(
|
||||
row_to_eval_record(
|
||||
item,
|
||||
idx=absolute_idx,
|
||||
split="jsonl",
|
||||
problem_field=problem_field,
|
||||
answer_field=answer_field,
|
||||
)
|
||||
)
|
||||
return rows
|
||||
|
||||
|
||||
def load_eval_dataset(
|
||||
*,
|
||||
dataset: str,
|
||||
dataset_config: str | None,
|
||||
split: str,
|
||||
problem_field: str | None,
|
||||
answer_field: str | None,
|
||||
limit: int | None,
|
||||
start_index: int = 0,
|
||||
) -> list[dict[str, Any]]:
|
||||
from datasets import load_dataset
|
||||
|
||||
ds = load_dataset(dataset, dataset_config, split=split) if dataset_config else load_dataset(dataset, split=split)
|
||||
if start_index:
|
||||
ds = ds.select(range(start_index, len(ds)))
|
||||
if limit is not None:
|
||||
ds = ds.select(range(min(limit, len(ds))))
|
||||
|
||||
rows: list[dict[str, Any]] = []
|
||||
for idx, item in enumerate(ds, start=start_index):
|
||||
rows.append(
|
||||
row_to_eval_record(
|
||||
dict(item),
|
||||
idx=idx,
|
||||
split=split,
|
||||
problem_field=problem_field,
|
||||
answer_field=answer_field,
|
||||
)
|
||||
)
|
||||
return rows
|
||||
|
||||
|
||||
def infer_field(item: dict[str, Any], candidates: list[str]) -> str | None:
|
||||
for candidate in candidates:
|
||||
if candidate in item:
|
||||
return candidate
|
||||
return None
|
||||
|
||||
|
||||
def write_jsonl(path: str | Path, rows: list[dict[str, Any]]) -> None:
|
||||
path = Path(path)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with path.open("w", encoding="utf-8") as handle:
|
||||
for row in rows:
|
||||
handle.write(json.dumps(row, ensure_ascii=False) + "\n")
|
||||
70
release_manifest.json
Normal file
70
release_manifest.json
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"release_id": "recursive-v32-balanced-sft-20260930",
|
||||
"repo_id": "tawer12/qwen3-4b-recursive-sft-v3.2",
|
||||
"files": {
|
||||
"added_tokens.json": {
|
||||
"bytes": 889,
|
||||
"sha256": "ea312cabd6f72c50ad7872764a696f7649faa7d7feb50ed559c4c8b57f470f93"
|
||||
},
|
||||
"config.json": {
|
||||
"bytes": 728,
|
||||
"sha256": "67becd184e89537add154c69746a7156eb5ba4f920de3593e8c222b691356caa"
|
||||
},
|
||||
"generation_config.json": {
|
||||
"bytes": 117,
|
||||
"sha256": "bd03c5abee61c7bba94010a6885933427b45575109c54c7d988299536038cff8"
|
||||
},
|
||||
"merges.txt": {
|
||||
"bytes": 1671853,
|
||||
"sha256": "8831e4f1a044471340f7c0a83d7bd71306a5b867e95fd870f74d0c5308a904d5"
|
||||
},
|
||||
"model-00001-of-00002.safetensors": {
|
||||
"bytes": 4965889280,
|
||||
"sha256": "bfbbbe85189139434cf416640d45ba70c374ca01b00c80323bef8e8679e7b4c6"
|
||||
},
|
||||
"model-00002-of-00002.safetensors": {
|
||||
"bytes": 3077766632,
|
||||
"sha256": "00a3f550612694718240c6051c491e6b7bf44f80c5d31802d67abdc8666ad9b0"
|
||||
},
|
||||
"model.safetensors.index.json": {
|
||||
"bytes": 32819,
|
||||
"sha256": "bf3fe31be2e4638e5dbf7f6b22440f1c8114eca746e26dcd066072ce4a107df5"
|
||||
},
|
||||
"special_tokens_map.json": {
|
||||
"bytes": 466,
|
||||
"sha256": "6f6d29f6e47c31e7eff04a20e7abf1b955ce6fb2d0dae0125913bfe07d689dba"
|
||||
},
|
||||
"tokenizer.json": {
|
||||
"bytes": 11424140,
|
||||
"sha256": "958d2af197119658030225f794b51571c30893aa31b2d34168a3977947941fff"
|
||||
},
|
||||
"tokenizer_config.json": {
|
||||
"bytes": 10965,
|
||||
"sha256": "bed722fbe66989d377b5c72ef2ff623a7b4d1f185a52db443acd63d09eeee3b1"
|
||||
},
|
||||
"vocab.json": {
|
||||
"bytes": 2776833,
|
||||
"sha256": "ca10d7e9fb3ed18575dd1e277a2579c16d108e32f27439684afa0e10b1440910"
|
||||
},
|
||||
"README.md": {
|
||||
"bytes": 5663,
|
||||
"sha256": "07250b88cba864cc283ec8c88cfd764ec3bff342bd08850feb3f4d011374c170"
|
||||
},
|
||||
"LICENSE": {
|
||||
"bytes": 11343,
|
||||
"sha256": "832dd9e00a68dd83b3c3fb9f5588dad7dcf337a0db50f7d9483f310cd292e92e"
|
||||
},
|
||||
"prompts/recursive_sft_prefix_prompt.txt": {
|
||||
"bytes": 937,
|
||||
"sha256": "dc622e5bc70a1a5970827d70ca764128b07a9b32514ebe2c032ce9da7a147f85"
|
||||
},
|
||||
"recursive_engine.py": {
|
||||
"bytes": 20007,
|
||||
"sha256": "a82dcb108b23e3de1e84c443e753f9b3ca8eb29a19c18848bcbab96c7f8c4fdc"
|
||||
},
|
||||
"training_summary.json": {
|
||||
"bytes": 899,
|
||||
"sha256": "c3c61eb753e7c306a2365792ad5aa5381313141a14198de8877babc9217ab5a8"
|
||||
}
|
||||
}
|
||||
}
|
||||
26
special_tokens_map.json
Normal file
26
special_tokens_map.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"additional_special_tokens": [
|
||||
"<problem>",
|
||||
"</problem>",
|
||||
"<action>",
|
||||
"</action>",
|
||||
"<parallel>",
|
||||
"</parallel>",
|
||||
"<path>",
|
||||
"</path>"
|
||||
],
|
||||
"eos_token": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:958d2af197119658030225f794b51571c30893aa31b2d34168a3977947941fff
|
||||
size 11424140
|
||||
299
tokenizer_config.json
Normal file
299
tokenizer_config.json
Normal file
@@ -0,0 +1,299 @@
|
||||
{
|
||||
"add_bos_token": false,
|
||||
"add_prefix_space": false,
|
||||
"added_tokens_decoder": {
|
||||
"151643": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151644": {
|
||||
"content": "<|im_start|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151645": {
|
||||
"content": "<|im_end|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151646": {
|
||||
"content": "<|object_ref_start|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151647": {
|
||||
"content": "<|object_ref_end|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151648": {
|
||||
"content": "<|box_start|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151649": {
|
||||
"content": "<|box_end|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151650": {
|
||||
"content": "<|quad_start|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151651": {
|
||||
"content": "<|quad_end|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151652": {
|
||||
"content": "<|vision_start|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151653": {
|
||||
"content": "<|vision_end|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151654": {
|
||||
"content": "<|vision_pad|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151655": {
|
||||
"content": "<|image_pad|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151656": {
|
||||
"content": "<|video_pad|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151657": {
|
||||
"content": "<tool_call>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151658": {
|
||||
"content": "</tool_call>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151659": {
|
||||
"content": "<|fim_prefix|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151660": {
|
||||
"content": "<|fim_middle|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151661": {
|
||||
"content": "<|fim_suffix|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151662": {
|
||||
"content": "<|fim_pad|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151663": {
|
||||
"content": "<|repo_name|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151664": {
|
||||
"content": "<|file_sep|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151665": {
|
||||
"content": "<tool_response>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151666": {
|
||||
"content": "</tool_response>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151667": {
|
||||
"content": "<think>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151668": {
|
||||
"content": "</think>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": false
|
||||
},
|
||||
"151669": {
|
||||
"content": "<problem>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151670": {
|
||||
"content": "</problem>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151671": {
|
||||
"content": "<action>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151672": {
|
||||
"content": "</action>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151673": {
|
||||
"content": "<parallel>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151674": {
|
||||
"content": "</parallel>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151675": {
|
||||
"content": "<path>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"151676": {
|
||||
"content": "</path>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
}
|
||||
},
|
||||
"additional_special_tokens": [
|
||||
"<problem>",
|
||||
"</problem>",
|
||||
"<action>",
|
||||
"</action>",
|
||||
"<parallel>",
|
||||
"</parallel>",
|
||||
"<path>",
|
||||
"</path>"
|
||||
],
|
||||
"bos_token": null,
|
||||
"chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0].role == 'system' %}\n {{- messages[0].content + '\\n\\n' }}\n {%- endif %}\n {{- \"# 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>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\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\" }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0].content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n{%- endfor %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set content = message.content %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is defined and message.reasoning_content is not none %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- if '</think>' in message.content %}\n {%- set content = message.content.split('</think>')[-1].lstrip('\\n') %}\n {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- if loop.index0 > ns.last_query_index %}\n {%- if loop.last or (not loop.last and reasoning_content) %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content.strip('\\n') + '\\n</think>\\n\\n' + content.lstrip('\\n') }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls %}\n {%- for tool_call in message.tool_calls %}\n {%- if (loop.first and content) or (not loop.first) %}\n {{- '\\n' }}\n {%- endif %}\n {%- if tool_call.function %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {%- if tool_call.arguments is string %}\n {{- tool_call.arguments }}\n {%- else %}\n {{- tool_call.arguments | tojson }}\n {%- endif %}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is false %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- endif %}\n{%- endif %}",
|
||||
"clean_up_tokenization_spaces": false,
|
||||
"eos_token": "<|endoftext|>",
|
||||
"errors": "replace",
|
||||
"extra_special_tokens": {},
|
||||
"model_max_length": 131072,
|
||||
"pad_token": "<|endoftext|>",
|
||||
"split_special_tokens": false,
|
||||
"tokenizer_class": "Qwen2Tokenizer",
|
||||
"unk_token": null
|
||||
}
|
||||
29
training_summary.json
Normal file
29
training_summary.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"stage": "SFT",
|
||||
"base_model": "Qwen/Qwen3-4B-Base",
|
||||
"source_checkpoint_name": "qwen3-4b-recursive-sft-v3.2-balanced",
|
||||
"component_examples": 14126,
|
||||
"decomposition_examples": 4707,
|
||||
"direct_examples": 4707,
|
||||
"aggregation_examples": 4712,
|
||||
"unique_source_problems": 5241,
|
||||
"configured_epochs": 6,
|
||||
"optimizer_updates": 660,
|
||||
"final_epoch": 5.951302378255946,
|
||||
"global_component_batch_size": 128,
|
||||
"training_gpu_count": 8,
|
||||
"per_device_batch_size": 1,
|
||||
"gradient_accumulation_steps": 16,
|
||||
"max_sequence_length": 2048,
|
||||
"learning_rate": 1e-05,
|
||||
"weight_decay": 0.01,
|
||||
"warmup_ratio": 0.1,
|
||||
"scheduler": "cosine",
|
||||
"seed": 1,
|
||||
"precision": "bf16",
|
||||
"gradient_checkpointing": true,
|
||||
"loss": "output_tokens_only",
|
||||
"prompt_representation": "raw_recursive_strings_not_chat_template",
|
||||
"protocol": "original_tags_not_json",
|
||||
"known_unrepaired_terminal_answer_targets": 387
|
||||
}
|
||||
1
vocab.json
Normal file
1
vocab.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user