Kovacreations commited on
Commit
7709263
·
0 Parent(s):

Duplicate from Kovacreations/Primus

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +35 -0
  2. PRIMUS_PAPER.md +98 -0
  3. README.md +80 -0
  4. chat_template.jinja +222 -0
  5. config.json +132 -0
  6. model-00001-of-00099.safetensors +3 -0
  7. model-00002-of-00099.safetensors +3 -0
  8. model-00003-of-00099.safetensors +3 -0
  9. model-00004-of-00099.safetensors +3 -0
  10. model-00005-of-00099.safetensors +3 -0
  11. model-00006-of-00099.safetensors +3 -0
  12. model-00007-of-00099.safetensors +3 -0
  13. model-00008-of-00099.safetensors +3 -0
  14. model-00009-of-00099.safetensors +3 -0
  15. model-00010-of-00099.safetensors +3 -0
  16. model-00011-of-00099.safetensors +3 -0
  17. model-00012-of-00099.safetensors +3 -0
  18. model-00013-of-00099.safetensors +3 -0
  19. model-00014-of-00099.safetensors +3 -0
  20. model-00015-of-00099.safetensors +3 -0
  21. model-00016-of-00099.safetensors +3 -0
  22. model-00017-of-00099.safetensors +3 -0
  23. model-00018-of-00099.safetensors +3 -0
  24. model-00019-of-00099.safetensors +3 -0
  25. model-00020-of-00099.safetensors +3 -0
  26. model-00021-of-00099.safetensors +3 -0
  27. model-00022-of-00099.safetensors +3 -0
  28. model-00023-of-00099.safetensors +3 -0
  29. model-00024-of-00099.safetensors +3 -0
  30. model-00025-of-00099.safetensors +3 -0
  31. model-00026-of-00099.safetensors +3 -0
  32. model-00027-of-00099.safetensors +3 -0
  33. model-00028-of-00099.safetensors +3 -0
  34. model-00029-of-00099.safetensors +3 -0
  35. model-00030-of-00099.safetensors +3 -0
  36. model-00031-of-00099.safetensors +3 -0
  37. model-00032-of-00099.safetensors +3 -0
  38. model-00033-of-00099.safetensors +3 -0
  39. model-00034-of-00099.safetensors +3 -0
  40. model-00035-of-00099.safetensors +3 -0
  41. model-00036-of-00099.safetensors +3 -0
  42. model-00037-of-00099.safetensors +3 -0
  43. model-00038-of-00099.safetensors +3 -0
  44. model-00039-of-00099.safetensors +3 -0
  45. model-00040-of-00099.safetensors +3 -0
  46. model-00041-of-00099.safetensors +3 -0
  47. model-00042-of-00099.safetensors +3 -0
  48. model-00043-of-00099.safetensors +3 -0
  49. model-00044-of-00099.safetensors +3 -0
  50. model-00045-of-00099.safetensors +3 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
PRIMUS_PAPER.md ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Primus: A Coding Model That Fixes What Developers Complain About
2
+
3
+ **Kovalabs** · August 2026
4
+
5
+ ## Abstract
6
+
7
+ We present Primus, a 295B-parameter coding model fine-tuned from Tencent Hy3 using the APEX method stack. Unlike frontier models optimized for benchmark scores, Primus is optimized for the five complaints developers actually have about AI coding assistants: regression-free repair, scope discipline, ask-vs-guess behavior, API honesty, and terseness. We introduce TIDE (Trajectory-level Iterative DPO with Execution anchors), a step-anchored preference optimization method that assigns credit/blame at the exact causal step rather than smeared over whole trajectories. We also present CAT (Consequence-Augmented Training), which teaches the model to predict blast radius before acting, and SENTINEL, an anti-reward-hacking verifier. On our pre-registered 15-axis scorecard, Primus achieves [X/15] wins vs Claude Fable 5, with all losses published.
8
+
9
+ ## 1. Introduction
10
+
11
+ Developers don't complain about benchmark scores. They complain that AI coding assistants:
12
+ 1. **Break adjacent functionality** while fixing the requested bug
13
+ 2. **Change 47 files** when asked for a one-line fix
14
+ 3. **Guess** when they should ask for clarification
15
+ 4. **Invent APIs** that don't exist
16
+ 5. **Write essays** instead of minimal diffs
17
+
18
+ Existing coding models optimize for SWE-bench and similar benchmarks, which measure "can it fix the issue" but not "does it break everything else." Primus is built to fix the complaints, not just the benchmarks.
19
+
20
+ ## 2. The APEX Method Stack
21
+
22
+ ### 2.1 CAT — Consequence-Augmented Training
23
+ Every training sample includes a consequence prediction: before acting, the model predicts `files_at_risk`, `tests_at_risk`, `risk_class`, and `minimal_plan`. This creates an internal "blast radius" model that activates at inference time.
24
+
25
+ ### 2.2 TIDE — Step-Anchored DPO
26
+ Standard DPO treats a failed trajectory as one "rejected" sample, training down 39 good steps along with the 1 bad step. TIDE anchors the preference pair at the exact causal step:
27
+ - **prompt** = everything before the failing step
28
+ - **rejected** = the failing step
29
+ - **chosen** = the recovery step (or gold fix)
30
+
31
+ This teaches the model *which specific action* caused the failure, not just "this trajectory was bad."
32
+
33
+ ### 2.3 SENTINEL — Anti-Reward-Hacking
34
+ Detects when the model games metrics instead of solving tasks: test tampering, skip-added, tautological asserts, mock exploits, scope dishonesty, cross-verifier disagreement.
35
+
36
+ ### 2.4 AEGIS — Adaptive Best-of-N (Inference Time)
37
+ At inference, sample N candidates, CAT-predict consequence for each, and select the safest effective option. Not just highest logprob — lowest risk.
38
+
39
+ ### 2.5 SONAR — External Memory
40
+ A persistent `STATE.md` file that survives context window limits on marathon tasks (multi-hour repo work).
41
+
42
+ ## 3. Training
43
+
44
+ - **Base:** Tencent Hy3 (295B MoE, 21B active, 192 experts top-8)
45
+ - **Method:** LoRA (r=64, α=128) SFT → TIDE-DPO → RLVR sprint
46
+ - **Data:** 31,453 decontaminated samples (priors, CAT units, behavior demonstrations, TIDE pairs)
47
+ - **Hardware:** 8× RTX PRO 6000 (764GB VRAM), ~78 hours SFT, ~11 hours DPO
48
+ - **Decontamination:** All training data checked against eval benchmarks; no SWE-Gym/SWE-bench overlap in RLVR
49
+
50
+ ## 4. Evaluation
51
+
52
+ ### 4.1 Pre-Registered Scorecard (15 axes)
53
+ | Benchmark | K3 | Fable 5 | GLM-5.2 | Primus | Win? |
54
+ |---|---|---|---|---|---|
55
+ | Terminal-Bench 2.1 | 88.3 | 88.0 | 82.7 | [TBD] | [TBD] |
56
+ | PostTrainBench | 36.6 | 41.4 | 34.3 | [TBD] | [TBD] |
57
+ | MLS-Bench-Lite | 48.3 | 49.9 | 40.4 | [TBD] | [TBD] |
58
+ | SciCode | 58.7 | 60.2 | 50.5 | [TBD] | [TBD] |
59
+ | Kimi Code Bench 2.0 | 72.9 | 76.9 | 64.2 | [TBD] | [TBD] |
60
+ | ProgramBench | 77.8 | 76.8 | 63.7 | [TBD] | [TBD] |
61
+ | FrontierSWE | 81.2 | 86.6 | 67.3 | [TBD] | [TBD] |
62
+ | SWE-bench Pro | 45.0 | 52.0 | 38.0 | [TBD] | [TBD] |
63
+ | SWE-Marathon | 42.0 | 35.0 | 13.0 | [TBD] | [TBD] |
64
+ | DeepSWE | 67.5 | 70.0 | 46.2 | [TBD] | [TBD] |
65
+ | **DevPain (5 axes)** | — | — | — | [TBD] | **sweep target** |
66
+
67
+ ### 4.2 DevPain Suite
68
+ Our own sealed benchmark measuring the five developer complaints. Full results published with the model.
69
+
70
+ ## 5. Results
71
+
72
+ [To be filled after eval completes]
73
+
74
+ ## 6. Limitations
75
+
76
+ - LoRA-only (not full fine-tune) — some capability ceiling
77
+ - Teacher cascade (Kimi k2.7) was not used in final training due to API issues
78
+ - RLVR sprint was simplified best-of-N, not full GRPO
79
+ - SWE-bench Pro and Marathon remain challenging
80
+
81
+ ## 7. Ethics & Reproducibility
82
+
83
+ - All training data decontaminated against eval benchmarks
84
+ - All losses published, not just wins
85
+ - Harness open-sourced: [github.com/kovalabs/nebula](https://github.com/kovalabs/nebula)
86
+ - Model card: [huggingface.co/kovalabs/primus](https://huggingface.co/kovalabs/primus)
87
+
88
+ ## 8. Future Work
89
+
90
+ - FORGE: per-domain LoRA specialists + gated merge
91
+ - HELM: milestone ladders for sparse-reward marathon tasks
92
+ - Full GRPO with TRL (not simplified best-of-N)
93
+ - Teacher cascade integration (Cloudflare/Runpod)
94
+ - ACT loop: active curriculum training from failure autopsy
95
+
96
+ ---
97
+
98
+ *Primus: first, do no harm to the codebase.*
README.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - code
5
+ - agent
6
+ - merged
7
+ - fine-tuned
8
+ ---
9
+
10
+ # Primus
11
+
12
+ **A coding model that fixes what developers actually complain about.**
13
+
14
+ Primus is a 295B-parameter coding model fine-tuned using the APEX method stack. Unlike frontier models optimized for benchmark scores, Primus is optimized for the five complaints developers have about AI coding assistants:
15
+
16
+ 1. **Regression-free repair** — fixes the bug without breaking adjacent functionality
17
+ 2. **Scope discipline** — changes only what you asked for, not 47 files
18
+ 3. **Ask-vs-guess** — asks clarifying questions instead of guessing wrong
19
+ 4. **API honesty** — never invents functions or libraries that don't exist
20
+ 5. **Terseness** — minimal diffs, no essays
21
+
22
+ ## Method
23
+
24
+ - **Training:** LoRA SFT → TIDE-DPO → RLVR sprint
25
+ - **Data:** 31,453 decontaminated samples (priors, CAT units, behavior demonstrations, TIDE pairs)
26
+ - **Hardware:** 8× RTX PRO 6000 (764GB VRAM)
27
+
28
+ ## The APEX Stack
29
+
30
+ - **CAT** (Consequence-Augmented Training): Predicts blast radius before acting
31
+ - **TIDE** (Step-Anchored DPO): Assigns credit/blame at the exact causal step
32
+ - **SENTINEL**: Anti-reward-hacking verifier
33
+ - **AEGIS**: Adaptive best-of-N at inference (safest effective option)
34
+ - **SONAR**: External memory for long-horizon tasks
35
+
36
+ ## Usage
37
+
38
+ ```python
39
+ from transformers import AutoModelForCausalLM, AutoTokenizer
40
+
41
+ model = AutoModelForCausalLM.from_pretrained(
42
+ "kovacreations/primus",
43
+ trust_remote_code=True,
44
+ device_map="auto",
45
+ torch_dtype="bfloat16"
46
+ )
47
+ tok = AutoTokenizer.from_pretrained("kovacreations/primus", trust_remote_code=True)
48
+
49
+ messages = [
50
+ {"role": "system", "content": "You are Primus, a coding assistant. Write clean, minimal code."},
51
+ {"role": "user", "content": "Fix the null pointer in auth.py"}
52
+ ]
53
+ prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
54
+ inputs = tok(prompt, return_tensors="pt").to(model.device)
55
+ out = model.generate(**inputs, max_new_tokens=2048)
56
+ print(tok.decode(out[0], skip_special_tokens=True))
57
+ ```
58
+
59
+ ## Scorecard
60
+
61
+ Pre-registered 15-axis scorecard with all results published (wins and losses):
62
+
63
+ - 10 public benchmarks (Terminal-Bench, SWE-bench, etc.)
64
+ - 5 DevPain axes (regression, scope, ask, API honesty, terseness)
65
+
66
+ ## Research Paper
67
+
68
+ See [PRIMUS_PAPER.md](PRIMUS_PAPER.md) for the full method description, training details, and analysis.
69
+
70
+ ## Harness
71
+
72
+ Open-source evaluation harness: [github.com/kovalabs/nebula](https://github.com/kovalabs/nebula)
73
+
74
+ ## License
75
+
76
+ Apache 2.0. Decontaminated training data. All losses published.
77
+
78
+ ---
79
+
80
+ *Primus: first, do no harm to the codebase.*
chat_template.jinja ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#- ----------‑‑‑ special token variables ‑‑‑---------- -#}
2
+ {%- set HYTK = ':opensource' %}
3
+ {%- set eos_token = '<|hy_eos{}|>'.format(HYTK) %}
4
+ {%- set bos_token = '<|hy_begin_of_sentence{}|>'.format(HYTK) %}
5
+ {%- set pad_token = '<|hy_pad{}|>'.format(HYTK) %}
6
+ {%- set user_token = '<|hy_User{}|>'.format(HYTK) %}
7
+ {%- set assistant_token = '<|hy_Assistant{}|>'.format(HYTK) %}
8
+ {%- set think_begin_token = '<think{}>'.format(HYTK) %}
9
+ {%- set think_end_token = '</think{}>'.format(HYTK) %}
10
+ {%- set toolcalls_begin_token = '<tool_calls{}>'.format(HYTK) %}
11
+ {%- set toolcalls_end_token = '</tool_calls{}>'.format(HYTK) %}
12
+ {%- set toolcall_begin_token = '<tool_call{}>'.format(HYTK) %}
13
+ {%- set toolcall_end_token = '</tool_call{}>'.format(HYTK) %}
14
+ {%- set toolsep_token = '<tool_sep{}>'.format(HYTK) %}
15
+ {%- set argkey_begin_token = '<arg_key{}>'.format(HYTK) %}
16
+ {%- set argkey_end_token = '</arg_key{}>'.format(HYTK) %}
17
+ {%- set argvalue_begin_token = '<arg_value{}>'.format(HYTK) %}
18
+ {%- set argvalue_end_token = '</arg_value{}>'.format(HYTK) %}
19
+ {%- set toolresponses_begin_token = '<tool_responses{}>'.format(HYTK) %}
20
+ {%- set toolresponses_end_token = '</tool_responses{}>'.format(HYTK) %}
21
+ {%- set toolresponse_begin_token = '<tool_response{}>'.format(HYTK) %}
22
+ {%- set toolresponse_end_token = '</tool_response{}>'.format(HYTK) %}
23
+ {%- set reasoning_mode_token = '<|reasoning_mode{}|>'.format(HYTK) %}
24
+
25
+ {#- ----------‑‑‑ hyperparameters variables ‑‑‑---------- -#}
26
+ {%- if not add_generation_prompt is defined %}
27
+ {%- set add_generation_prompt = false %}
28
+ {%- endif %}
29
+ {%- if not preserved_thinking is defined %}
30
+ {%- if not tools %}
31
+ {%- set preserved_thinking = false %}
32
+ {%- else %}
33
+ {%- set preserved_thinking = true %}
34
+ {%- endif %}
35
+ {%- endif %}
36
+ {%- if not is_training is defined %}
37
+ {%- set is_training = false %}
38
+ {%- endif %}
39
+
40
+ {%- if not reasoning_effort is defined %}
41
+ {%- set reasoning_effort = 'no_think' %}
42
+ {%- elif reasoning_effort not in ['high', 'low', 'no_think'] %}
43
+ {%- if reasoning_effort is none %}
44
+ {{- raise_exception('reasoning_effort error : None, should be no_think/low/high') }}
45
+ {%- else %}
46
+ {{- raise_exception('reasoning_effort error : ' + reasoning_effort + ', should be no_think/low/high') }}
47
+ {%- endif %}
48
+ {%- endif %}
49
+
50
+ {%- if fallback_strategy is defined and fallback_strategy == 'reasoning_toolcall_retry' %}
51
+ {%- set reasoning_effort = 'high' %}
52
+ {%- set add_generation_prompt = false %}
53
+ {%- endif %}
54
+ {%- if not raw_last_assistant is defined %}
55
+ {%- set raw_last_assistant = false %}
56
+ {%- endif %}
57
+
58
+ {%- macro visible_text(content) -%}
59
+ {%- if content is string -%}
60
+ {{- content }}
61
+ {%- elif content is iterable and content is not mapping -%}
62
+ {%- for item in content -%}
63
+ {%- if item is mapping and item.type == 'text' -%}
64
+ {{- item.text }}
65
+ {%- elif item is string -%}
66
+ {{- item }}
67
+ {%- endif -%}
68
+ {%- endfor -%}
69
+ {%- elif content is none -%}
70
+ {{- '' }}
71
+ {%- else -%}
72
+ {{- content }}
73
+ {%- endif -%}
74
+ {%- endmacro -%}
75
+
76
+ {%- set ns = namespace(last_user_index=-1) %}
77
+ {%- set sp_ns = namespace(system_prompt='', is_first_sp=true) %}
78
+ {%- for message in messages %}
79
+ {%- if message['role'] == 'system' %}
80
+ {%- set sp_ns.system_prompt = sp_ns.system_prompt + visible_text(message['content']) %}
81
+ {%- endif %}
82
+ {%- if message['role'] == 'user' %}
83
+ {%- set ns.last_user_index = loop.index0 %}
84
+ {%- endif %}
85
+ {%- endfor %}
86
+ {%- if reasoning_effort is defined and reasoning_effort is string and reasoning_effort != '' and not tools %}
87
+ {%- set sp_ns.system_prompt = sp_ns.system_prompt + reasoning_mode_token + 'reasoning_effort:' + reasoning_effort %}
88
+ {%- endif %}
89
+ {{- bos_token }}
90
+ {{- sp_ns.system_prompt }}
91
+ {%- if tools %}
92
+ {%- if sp_ns.system_prompt != '' %}
93
+ {{- '\n\n# Tools\n\nYou may call one or more functions to assist with the user query.' }}
94
+ {%- else %}
95
+ {{- '# Tools\n\nYou may call one or more functions to assist with the user query.' }}
96
+ {%- endif %}
97
+ {{- '\n\nYou are provided with function signatures within <tools></tools> XML tags:' }}
98
+ {{- '\n<tools>\n' }}
99
+ {%- for tool in tools %}
100
+ {%- if loop.index0 > 0 %}
101
+ {{- '\n' }}
102
+ {%- endif %}
103
+ {{- tool | tojson }}
104
+ {%- endfor %}
105
+ {{- '\n</tools>\n\n' }}
106
+ {{- 'For function call returns, you should first print ' + toolcalls_begin_token + '\n' }}
107
+ {{- 'For each function call, you should return object like:\n' }}
108
+ {{- toolcall_begin_token + '{function-name}' + toolsep_token + '\n' }}
109
+ {{- argkey_begin_token + '{arg-key-1}' + argkey_end_token + '\n' }}
110
+ {{- argvalue_begin_token + '{arg-value-1}' + argvalue_end_token + '\n' }}
111
+ {{- argkey_begin_token + '{arg-key-2}' + argkey_end_token + '\n' }}
112
+ {{- argvalue_begin_token + '{arg-value-2}' + argvalue_end_token + '\n' }}
113
+ {{- '...\n' }}
114
+ {{- toolcall_end_token + '\n' }}
115
+ {%- if reasoning_effort is defined and reasoning_effort is string and reasoning_effort != '' %}
116
+ {{- 'At the end of function call returns, you should print ' + toolcalls_end_token + reasoning_mode_token + 'reasoning_effort:' + reasoning_effort }}
117
+ {%- else %}
118
+ {{- 'At the end of function call returns, you should print ' + toolcalls_end_token }}
119
+ {%- endif %}
120
+ {%- endif %}
121
+
122
+ {%- set prev_ns = namespace(is_tool=false, is_tool_first=true) %}
123
+ {%- set last_ns = namespace(last_is_assistant=false) %}
124
+ {%- for message in messages %}
125
+ {%- if message['role'] == 'user' %}
126
+ {%- if prev_ns.is_tool %}
127
+ {{- toolresponses_end_token }}
128
+ {%- endif %}
129
+ {{- user_token + visible_text(message['content']) }}
130
+ {%- set prev_ns.is_tool = false %}
131
+ {%- endif %}
132
+ {%- if message['role'] == 'assistant' %}
133
+ {%- if is_training %}
134
+ {%- if 'reasoning_content' in message and message['reasoning_content'] is string %}
135
+ {%- set rc = message['reasoning_content'] %}
136
+ {%- elif 'reasoning' in message and message['reasoning'] is string %}
137
+ {%- set rc = message['reasoning'] %}
138
+ {%- else %}
139
+ {%- set rc = none %}
140
+ {%- endif %}
141
+ {%- if rc is not none %}
142
+ {%- set content = think_begin_token + rc + think_end_token + visible_text(message['content']) %}
143
+ {%- else %}
144
+ {%- set content = think_begin_token + think_end_token + visible_text(message['content']) %}
145
+ {%- endif %}
146
+ {%- else %}
147
+ {%- if ((preserved_thinking is defined and preserved_thinking) or loop.index0 > ns.last_user_index) %}
148
+ {%- if 'reasoning_content' in message and message['reasoning_content'] is string %}
149
+ {%- set rc = message['reasoning_content'] %}
150
+ {%- elif 'reasoning' in message and message['reasoning'] is string %}
151
+ {%- set rc = message['reasoning'] %}
152
+ {%- else %}
153
+ {%- set rc = none %}
154
+ {%- endif %}
155
+ {%- if rc is not none %}
156
+ {%- set content = think_begin_token + rc + think_end_token + visible_text(message['content']) %}
157
+ {%- else %}
158
+ {%- set content = think_begin_token + think_end_token + visible_text(message['content']) %}
159
+ {%- endif %}
160
+ {%- else %}
161
+ {%- set content = think_begin_token + think_end_token + visible_text(message['content']) %}
162
+ {%- endif %}
163
+ {%- endif %}
164
+ {%- if prev_ns.is_tool %}
165
+ {{- toolresponses_end_token }}
166
+ {%- endif %}
167
+ {{- assistant_token }}
168
+ {%- if message['tool_calls'] is defined and message['tool_calls'] %}
169
+ {%- set prev_ns.is_tool_first = true %}
170
+ {{- content }}
171
+ {{- toolcalls_begin_token + '\n' }}
172
+ {%- for tool in message['tool_calls'] %}
173
+ {%- set arguments = tool['function']['arguments'] %}
174
+ {{- toolcall_begin_token + tool['function']['name'] + toolsep_token + '\n' }}
175
+ {%- for key, value in arguments.items() %}
176
+ {{- argkey_begin_token + key + argkey_end_token + '\n' }}
177
+ {%- if value is not string %}
178
+ {%- set value = value | tojson(ensure_ascii=False) %}
179
+ {%- endif %}
180
+ {{- argvalue_begin_token + value + argvalue_end_token + '\n' }}
181
+ {%- endfor %}
182
+ {{- toolcall_end_token + '\n' }}
183
+ {%- endfor %}
184
+ {{- toolcalls_end_token + eos_token }}
185
+ {%- else %}
186
+ {%- if loop.last and raw_last_assistant %}
187
+ {{- visible_text(message['content']) }}
188
+ {%- elif not loop.last or is_training %}
189
+ {{- content + eos_token }}
190
+ {%- else %}
191
+ {{- content }}
192
+ {%- endif %}
193
+ {%- endif %}
194
+ {%- set prev_ns.is_tool = false %}
195
+ {%- endif %}
196
+ {%- if message['role'] == 'tool' %}
197
+ {%- set prev_ns.is_tool = true %}
198
+ {%- if prev_ns.is_tool_first %}
199
+ {{- toolresponses_begin_token + '\n' }}
200
+ {%- set prev_ns.is_tool_first = false %}
201
+ {%- endif %}
202
+ {{- toolresponse_begin_token + '\n' + visible_text(message['content']) + '\n' + toolresponse_end_token + '\n' }}
203
+ {%- endif %}
204
+ {%- if loop.last and message['role'] == 'assistant' %}
205
+ {%- set last_ns.last_is_assistant = true %}
206
+ {%- endif %}
207
+
208
+ {%- endfor %}
209
+ {%- if prev_ns.is_tool %}
210
+ {{- toolresponses_end_token }}
211
+ {%- endif %}
212
+ {%- if add_generation_prompt %}
213
+ {%- if not last_ns.last_is_assistant %}
214
+ {%- if reasoning_effort is defined and reasoning_effort in ['low', 'high'] %}
215
+ {{- assistant_token + think_begin_token }}
216
+ {%- elif reasoning_effort is defined and reasoning_effort == 'no_think' %}
217
+ {{- assistant_token + think_begin_token + think_end_token }}
218
+ {%- else %}
219
+ {{- assistant_token }}
220
+ {%- endif %}
221
+ {%- endif %}
222
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "HYV3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 120000,
8
+ "dtype": "bfloat16",
9
+ "enable_attention_fp32_softmax": false,
10
+ "enable_lm_head_fp32": true,
11
+ "enable_moe_fp32_combine": false,
12
+ "eod_token_id": 120026,
13
+ "eos_token_id": 120025,
14
+ "expert_hidden_dim": 1536,
15
+ "first_k_dense_replace": 1,
16
+ "head_dim": 128,
17
+ "hidden_act": "silu",
18
+ "hidden_size": 4096,
19
+ "initializer_range": 0.006,
20
+ "intermediate_size": 13312,
21
+ "max_position_embeddings": 262144,
22
+ "mlp_bias": false,
23
+ "mlp_layer_types": [
24
+ "dense",
25
+ "sparse",
26
+ "sparse",
27
+ "sparse",
28
+ "sparse",
29
+ "sparse",
30
+ "sparse",
31
+ "sparse",
32
+ "sparse",
33
+ "sparse",
34
+ "sparse",
35
+ "sparse",
36
+ "sparse",
37
+ "sparse",
38
+ "sparse",
39
+ "sparse",
40
+ "sparse",
41
+ "sparse",
42
+ "sparse",
43
+ "sparse",
44
+ "sparse",
45
+ "sparse",
46
+ "sparse",
47
+ "sparse",
48
+ "sparse",
49
+ "sparse",
50
+ "sparse",
51
+ "sparse",
52
+ "sparse",
53
+ "sparse",
54
+ "sparse",
55
+ "sparse",
56
+ "sparse",
57
+ "sparse",
58
+ "sparse",
59
+ "sparse",
60
+ "sparse",
61
+ "sparse",
62
+ "sparse",
63
+ "sparse",
64
+ "sparse",
65
+ "sparse",
66
+ "sparse",
67
+ "sparse",
68
+ "sparse",
69
+ "sparse",
70
+ "sparse",
71
+ "sparse",
72
+ "sparse",
73
+ "sparse",
74
+ "sparse",
75
+ "sparse",
76
+ "sparse",
77
+ "sparse",
78
+ "sparse",
79
+ "sparse",
80
+ "sparse",
81
+ "sparse",
82
+ "sparse",
83
+ "sparse",
84
+ "sparse",
85
+ "sparse",
86
+ "sparse",
87
+ "sparse",
88
+ "sparse",
89
+ "sparse",
90
+ "sparse",
91
+ "sparse",
92
+ "sparse",
93
+ "sparse",
94
+ "sparse",
95
+ "sparse",
96
+ "sparse",
97
+ "sparse",
98
+ "sparse",
99
+ "sparse",
100
+ "sparse",
101
+ "sparse",
102
+ "sparse",
103
+ "sparse"
104
+ ],
105
+ "model_type": "hy_v3",
106
+ "moe_intermediate_size": 1536,
107
+ "moe_router_enable_expert_bias": true,
108
+ "moe_router_use_sigmoid": true,
109
+ "num_attention_heads": 64,
110
+ "num_experts": 192,
111
+ "num_experts_per_tok": 8,
112
+ "num_hidden_layers": 80,
113
+ "num_key_value_heads": 8,
114
+ "num_nextn_predict_layers": 1,
115
+ "num_shared_experts": 1,
116
+ "output_router_logits": true,
117
+ "pad_token_id": 120002,
118
+ "qk_norm": true,
119
+ "rms_norm_eps": 1e-05,
120
+ "rope_parameters": {
121
+ "rope_theta": 11158840.0,
122
+ "rope_type": "default"
123
+ },
124
+ "route_norm": true,
125
+ "router_scaling_factor": 2.826,
126
+ "sep_token_id": 120007,
127
+ "tie_word_embeddings": false,
128
+ "transformers_version": "5.15.0.dev0",
129
+ "use_cache": true,
130
+ "use_grouped_mm": false,
131
+ "vocab_size": 120832
132
+ }
model-00001-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:66c9811c1a6f3a8c89e0e252b5991ee0112c8b6dd91a0a06c7863dc6c0200c16
3
+ size 7247829008
model-00002-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:438bfdf0685abb46abf98d83b0abec150096f68951ad61af60fe5cbd9c915ac7
3
+ size 7247829584
model-00003-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0112623ad063ea80a559d4ba02b72877a7d9cfe7fd80f57448efad0c006309e6
3
+ size 7247829584
model-00004-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b289f1c54b9645d03a3acb93e0af23b9c897cd38a389db1a601170e5ae2302e3
3
+ size 7247829584
model-00005-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fdc11262b41aceaf68aefbda84088a909dc2d1344781315b50763ad457b0d60
3
+ size 7247829584
model-00006-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c63adc9dcbaebef3c6876a95b966f2880b3259f28e89093316299ac23499445e
3
+ size 1073745312
model-00007-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:768a4a6797d0f18d3658db19256dc837b9bf8207be5853d1e534aac4fe2dc9b4
3
+ size 7247829008
model-00008-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1a02ea7da3ae3fa4feea8d4b31ab15f88b73d33b9789691b9a7310710ae7c28
3
+ size 7247829584
model-00009-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09dbd820bd4dcb306976105266dbb017b2d0f1a8019bd37b6dbd4bf859e35c59
3
+ size 7247829584
model-00010-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9bd6929f27a8bea148d20d709e82762b3593767ac5604be4a91e11c498249827
3
+ size 7247829584
model-00011-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29c8d8a926246569e553a1486b1d9f40774ed4bc46ff6a33e3e425ea76bb5e16
3
+ size 7247829584
model-00012-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f03adb53cbf5e2ff5200b8358374f5109ec1ce996679875c3a75a2b7ea986077
3
+ size 1073742272
model-00013-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a8222ce5abf81d4cdf72fc8ff23d37d09cfc972552b7db1e2f63adcaf15d249
3
+ size 7247829008
model-00014-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fcc9f1aed84d47e68df595eff48272e6726c77e96c78d89ded6294ce958e6332
3
+ size 7247829584
model-00015-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3e7c4360e3782e60bd4e43b029e66818a2bbd513794d34503e0c7ceaecd1b92
3
+ size 7247829584
model-00016-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1547e4a234524ee22e45155bf18a763e5a7ad3bcfd19fce86ee1332131ca9510
3
+ size 7247829584
model-00017-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d6e18ece70a4813a408b894a0399bd830c18a6888788b263bfef17b880272c4
3
+ size 7247829584
model-00018-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f69f7c228609cfb2c994c86fd5ec33cbc792cf38c0e399e7ff6a35b7267b0a48
3
+ size 1073746912
model-00019-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20e4912b081ddf058497e07a00a76715cf7d58a108020528dd9469a0d0971d24
3
+ size 7247829008
model-00020-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09bcddf356c7098e82688d818a331f36a10973a67184c8430832271882035487
3
+ size 7247829584
model-00021-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f9de5be0d34f3fad73d011e6c73c5da89b2813c03e52c61cb2ed0391beeb27b2
3
+ size 7247829584
model-00022-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6682fe3970c95511dc7e25c96394a0adf1b6cedc227613f2902e6a960dae0bb
3
+ size 7247829584
model-00023-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52d9924ead7e25ddf5019cc7e9504b3dc113f4777202f05cb9916d55f2a25ea2
3
+ size 7247829584
model-00024-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6da22a75d48894da525c85b3bc41748e4d68dc214a8d4e828239835b22da646
3
+ size 1067458192
model-00025-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e428cd287456c189baac90b1ca8aa2d0d9e1cb453faf0ca827a062913874c84
3
+ size 7247829008
model-00026-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3f98207f6205818674908052efb4c3adeed6ce73154617323177df347a6da4d
3
+ size 7247829584
model-00027-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:59946d434bd2e6377c68728b5417285c77510ccc13a2c873b0ad96002f5a3914
3
+ size 7247829584
model-00028-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dcd50b4691e61a45a06f0a8c7a461e71de1e6fe55951ba23439eba90a764fa03
3
+ size 7247829584
model-00029-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9a7b69c60dbb9afdc447bb0dc06a643846ef83da32b9206c1ca9b37b6e91d6a
3
+ size 7247829584
model-00030-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9a4c2cec9b58f0bd9b4907596fefd4d8c18808158f8abd4bb7c7d8810491581
3
+ size 1065220848
model-00031-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2e0f20db6780b593af07b38158163df6af4ccd76f35b6506dead303f60730a7
3
+ size 7247829008
model-00032-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:51216f9f9d6658aea0277e9e73a91083223193d9b166ab62961290be3050a9a1
3
+ size 7247829584
model-00033-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:986014e11dbc2ebbd20465f7a7a7558bc7e6640d76753cf6e308ef91a1c73833
3
+ size 7247829584
model-00034-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70225673b81ed882c341329979749df9ebf3d76397bc062cd8d45985578b6aaa
3
+ size 7247829584
model-00035-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:496c6fa66c557193f11c3bc8c53da798293ba4dd549055d6d7228a74d8f3f47b
3
+ size 7247829584
model-00036-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f27a414abc0c63d17dd384efc22d6f567d9dd717132834e055a05a015fcbaf4
3
+ size 1057352200
model-00037-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:96d1b08006c13931f68c4974cf90b48eb027da6da70bd79e83d436e04bf1c5de
3
+ size 7247829008
model-00038-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b0a8a47f60b4471bdb316d4019f14cd6361d4e69619ff52d0ba03246278de3f
3
+ size 7247829584
model-00039-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e32ce985b17809bc2702adfff736c4dba28162dd3c014b356e7903e0ef32cae5
3
+ size 7247829584
model-00040-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd189895394021bc96f86ec9aaf81850f1bd5d832df94c4a96aff4b765598f8d
3
+ size 7247829584
model-00041-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3973686874599c9c0b886b43387a0b05f073752aed07de84db823f709ea8ae87
3
+ size 7247829584
model-00042-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50841884bd8a563a18ae65c946031fb7bde5efaf4cd76cbd2206a3befa4a804d
3
+ size 1056967864
model-00043-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f3fe90acd2f05b6a5e3e7c5f386b9022f88a22f0014b407bb3338134360699c
3
+ size 7247829008
model-00044-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f5dfcc9a31b58f575f9f76d413aaff20ae71ff007f6a914082bd448ffbe5d9c
3
+ size 7247829584
model-00045-of-00099.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d54a762394c124e668f9591ce11f687caaa9d63ea986f95ffb11ca193ceed30a
3
+ size 7247829584