danielhanchen commited on
Commit
639014a
·
verified ·
1 Parent(s): f97b86d

Upload folder using huggingface_hub

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 +1 -0
  2. README.md +295 -0
  3. chat_template.jinja +86 -0
  4. config.json +57 -0
  5. configuration_bailing_moe_v2.py +84 -0
  6. generation_config.json +9 -0
  7. model-00001-of-00155.safetensors +3 -0
  8. model-00002-of-00155.safetensors +3 -0
  9. model-00003-of-00155.safetensors +3 -0
  10. model-00004-of-00155.safetensors +3 -0
  11. model-00005-of-00155.safetensors +3 -0
  12. model-00006-of-00155.safetensors +3 -0
  13. model-00007-of-00155.safetensors +3 -0
  14. model-00008-of-00155.safetensors +3 -0
  15. model-00009-of-00155.safetensors +3 -0
  16. model-00010-of-00155.safetensors +3 -0
  17. model-00011-of-00155.safetensors +3 -0
  18. model-00012-of-00155.safetensors +3 -0
  19. model-00013-of-00155.safetensors +3 -0
  20. model-00014-of-00155.safetensors +3 -0
  21. model-00015-of-00155.safetensors +3 -0
  22. model-00016-of-00155.safetensors +3 -0
  23. model-00017-of-00155.safetensors +3 -0
  24. model-00018-of-00155.safetensors +3 -0
  25. model-00019-of-00155.safetensors +3 -0
  26. model-00020-of-00155.safetensors +3 -0
  27. model-00021-of-00155.safetensors +3 -0
  28. model-00022-of-00155.safetensors +3 -0
  29. model-00023-of-00155.safetensors +3 -0
  30. model-00024-of-00155.safetensors +3 -0
  31. model-00025-of-00155.safetensors +3 -0
  32. model-00026-of-00155.safetensors +3 -0
  33. model-00027-of-00155.safetensors +3 -0
  34. model-00028-of-00155.safetensors +3 -0
  35. model-00029-of-00155.safetensors +3 -0
  36. model-00030-of-00155.safetensors +3 -0
  37. model-00031-of-00155.safetensors +3 -0
  38. model-00032-of-00155.safetensors +3 -0
  39. model-00033-of-00155.safetensors +3 -0
  40. model-00034-of-00155.safetensors +3 -0
  41. model-00035-of-00155.safetensors +3 -0
  42. model-00036-of-00155.safetensors +3 -0
  43. model-00037-of-00155.safetensors +3 -0
  44. model-00038-of-00155.safetensors +3 -0
  45. model-00039-of-00155.safetensors +3 -0
  46. model-00040-of-00155.safetensors +3 -0
  47. model-00041-of-00155.safetensors +3 -0
  48. model-00042-of-00155.safetensors +3 -0
  49. model-00043-of-00155.safetensors +3 -0
  50. model-00044-of-00155.safetensors +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* 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
 
 
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
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - unsloth
4
+ base_model:
5
+ - inclusionAI/Ling-1T
6
+ license: mit
7
+ pipeline_tag: text-generation
8
+ library_name: transformers
9
+ ---
10
+ > [!NOTE]
11
+ > Includes Unsloth **chat template fixes**! <br> For `llama.cpp`, use `--jinja`
12
+ >
13
+
14
+ <div>
15
+ <p style="margin-top: 0;margin-bottom: 0;">
16
+ <em><a href="https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf">Unsloth Dynamic 2.0</a> achieves superior accuracy & outperforms other leading quants.</em>
17
+ </p>
18
+ <div style="display: flex; gap: 5px; align-items: center; ">
19
+ <a href="https://github.com/unslothai/unsloth/">
20
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
21
+ </a>
22
+ <a href="https://discord.gg/unsloth">
23
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
24
+ </a>
25
+ <a href="https://docs.unsloth.ai/">
26
+ <img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
27
+ </a>
28
+ </div>
29
+ </div>
30
+
31
+
32
+ <p align="center">
33
+ <img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*4QxcQrBlTiAAAAAAQXAAAAgAemJ7AQ/original" width="100"/>
34
+ </p>
35
+
36
+ <p align="center">🤗 <a href="https://huggingface.co/inclusionAI">Hugging Face</a>&nbsp;&nbsp; | &nbsp;&nbsp;🤖 <a href="https://modelscope.cn/organization/inclusionAI">ModelScope </a>&nbsp;&nbsp; | &nbsp;&nbsp;🐙 <a href="https://zenmux.ai/inclusionai/ling-1t?utm_source=hf_inclusionAI">Experience Now</a></p>
37
+
38
+
39
+ ## Introduction
40
+
41
+ **Ling-1T** is the first flagship *non-thinking* model in the Ling 2.0 series, featuring **1 trillion total parameters** with **≈ 50 billion active parameters per token**.
42
+ Built on the Ling 2.0 architecture, Ling-1T is designed to push the limits of *efficient reasoning* and *scalable cognition*.
43
+
44
+ Pre-trained on **20 trillion+ high-quality, reasoning-dense tokens**, Ling-1T-base supports up to **128K context length** and adopts an **evolutionary chain-of-thought (Evo-CoT)** process across mid-training and post-training.
45
+ This curriculum greatly enhances the model’s efficiency and reasoning depth, allowing Ling-1T to achieve **state-of-the-art performance** on multiple complex reasoning benchmarks—balancing **accuracy** and **efficiency**.
46
+
47
+
48
+ ### Flagship-Level Efficient Reasoning
49
+
50
+ <p align="center">
51
+ <img src="https://mdn.alipayobjects.com/huamei_bcz3yt/afts/img/YiXwTb4Q_vsAAAAAT-AAAAgADkV7AQFr/original"/>
52
+ <p>
53
+
54
+ <p align="center">
55
+ <img src="https://mdn.alipayobjects.com/huamei_bcz3yt/afts/img/MEh7Q5FtzbAAAAAAUQAAAAgADkV7AQFr/original"/>
56
+ <p>
57
+
58
+ We comprehensively evaluated Ling-1T against leading flagship models, including both **open-source giants** (e.g., *DeepSeek-V3.1-Terminus*, *Kimi-K2-Instruct-0905*) and **closed-source APIs** (*GPT-5-main*, *Gemini-2.5-Pro*).
59
+ Across code generation, software development, competition-level mathematics, professional math, and logical reasoning, Ling-1T consistently demonstrates **superior complex reasoning ability** and overall advantage.
60
+
61
+ In the **AIME 25** benchmark, Ling-1T extends the **Pareto frontier** of reasoning accuracy vs. reasoning length, showcasing its strength in **“efficient thinking and precise reasoning.”**
62
+
63
+ <p align="center">
64
+ <img src="https://mdn.alipayobjects.com/huamei_bcz3yt/afts/img/J8ciS5KbIrwAAAAAceAAAAgADkV7AQFr/original"/>
65
+ <p>
66
+
67
+ ### Aesthetic Understanding and Front-End Generation
68
+
69
+ Ling-1T excels in visual reasoning and front-end code generation tasks, combining deep semantic understanding with precise code synthesis.
70
+ We introduce a hybrid *Syntax–Function–Aesthetics* reward mechanism, enabling the model to not only generate correct and functional code but also demonstrate a refined sense of **visual aesthetics**.
71
+ On **ArtifactsBench**, [Ling-1T](https://zenmux.ai/inclusionai/ling-1t?utm_source=hf_inclusionAI) ranks **first among open-source models**, and the benchmark visualizations in this card were, in fact, *generated by Ling-1T itself*.
72
+
73
+
74
+ ### Emergent Intelligence at Trillion-Scale
75
+
76
+ Scaling to the trillion-parameter level has revealed strong **emergent reasoning and transfer capabilities**.
77
+ For example, in the **BFCL V3** tool-use benchmark, Ling-1T achieves **≈ 70% tool-call accuracy** with only light instruction tuning—despite having seen no large-scale trajectory data during training.
78
+ [Ling-1T](https://zenmux.ai/inclusionai/ling-1t?utm_source=hf_inclusionAI) can:
79
+
80
+ * Interpret complex natural-language instructions
81
+ * Transform abstract logic into functional visual components
82
+ * Generate cross-platform compatible front-end code
83
+ * Create stylistically controlled marketing copy and multi-lingual text
84
+
85
+ These capabilities form the foundation for **general, collaborative human–AI intelligence**, which we aim to advance together with the open-source community through Ling-1T’s release.
86
+
87
+
88
+ ### Pre-Training at Trillion Scale
89
+
90
+ The Ling 2.0 architecture was designed from the ground up for trillion-scale efficiency, guided by the **Ling Scaling Law** ([arXiv:2507.17702](https://arxiv.org/abs/2507.17702)).
91
+ This ensures architectural and hyperparameter scalability even under **1e25–1e26 FLOPs** of compute.
92
+
93
+ Key architectural innovations include:
94
+
95
+ * **1T total / 50B active parameters** with a **1/32 MoE activation ratio**
96
+ * **MTP layers** for enhanced compositional reasoning
97
+ * **Aux-loss-free**, **sigmoid-scoring expert routing** with **zero-mean updates**
98
+ * **QK Normalization** for fully stable convergence
99
+
100
+ <p align="center">
101
+ <img src="https://mdn.alipayobjects.com/huamei_bcz3yt/afts/img/naA9TJe7ttIAAAAAVRAAAAgADkV7AQFr/original"/>
102
+ <p>
103
+
104
+ Ling-1T is the **largest FP8-trained foundation model** known to date.
105
+ FP8 mixed-precision training yields **15%+ end-to-end speedup**, improved memory efficiency, and maintains **≤ 0.1% loss deviation** from BF16 across **1T tokens**.
106
+ A fine-grained, **heterogeneous 1F1B interleaved pipeline** further boosts utilization by 40 %+.
107
+ System-level optimizations—fused kernels, communication scheduling, recomputation, checkpointing, simulation, and telemetry—ensure stable trillion-scale training.
108
+
109
+ <p align="center">
110
+ <img src="https://mdn.alipayobjects.com/huamei_bcz3yt/afts/img/y5UVSKACgLEAAAAAVcAAAAgADkV7AQFr/original"/>
111
+ <p>
112
+
113
+ Pre-training used over **20T high-quality tokens**, with **> 40% reasoning-dense data** in later stages.
114
+ Mid-training introduced **curated chain-of-thought corpora** for “**reasoning pre-activation**”, improving downstream reasoning stability.
115
+ A custom **WSM (Warmup–Stable–Merge)** LR scheduler([arXiv:2507.17634](https://arxiv.org/abs/2507.17634)) with mid-train checkpoint merging simulates LR decay and boosts generalization.
116
+
117
+
118
+ ### Post-Training and Evo-CoT Optimization
119
+
120
+ Built upon mid-training reasoning activation, post-training adopts **Evo-CoT (Evolutionary Chain-of-Thought)** for progressive reasoning enhancement under controllable cost.
121
+ This approach continually expands the **Pareto frontier** of reasoning accuracy vs. efficiency—ideal for reflexive non-thinking models.
122
+
123
+ For reinforcement learning, we introduce **LPO (Linguistics-Unit Policy Optimization)** —a novel sentence-level policy optimization method.
124
+ Unlike GRPO (token-level) or GSPO (sequence-level) algorithms, LPO treats *sentences* as the natural semantic action units, enabling precise alignment between rewards and reasoning behavior.
125
+ Empirically, LPO offers superior **training stability** and **generalization** across reasoning tasks.
126
+
127
+ <p align="center">
128
+ <img src="https://mdn.alipayobjects.com/huamei_bcz3yt/afts/img/kbEWT4BGEQQAAAAAWwAAAAgADkV7AQFr/original"/>
129
+ <p>
130
+ <p align="center">
131
+ <img src="https://mdn.alipayobjects.com/huamei_bcz3yt/afts/img/aF5LRqK5LMcAAAAAZHAAAAgADkV7AQFr/original"/>
132
+ <p>
133
+
134
+ ## Evaluation
135
+
136
+ Ling-1T has been extensively evaluated across **knowledge**, **code**, **math**, **reasoning**, **agent**, and **alignment** benchmarks.
137
+ It currently stands as the **best open-source flagship non-thinking model**, rivaling closed-source APIs in complex reasoning while maintaining exceptional efficiency and interpretability.
138
+
139
+ <p align="center">
140
+ <img src="https://mdn.alipayobjects.com/huamei_bcz3yt/afts/img/KrwiQZEDHV0AAAAAWkAAAAgADkV7AQFr/original"/>
141
+ <p>
142
+
143
+
144
+ ## Model Downloads
145
+
146
+ You can download Ling-1T from the following table. If you are located in mainland China, we also provide the model on ModelScope.cn to speed up the download process.
147
+
148
+ <center>
149
+
150
+ | **Model** | **Context Length** | **Download** |
151
+ | :-------: | :----------------: | :-------------------------------------------------------------------------------------------------------------------------------------------: |
152
+ | Ling-1T | 32K -> 128K (YaRN) | [🤗 HuggingFace](https://huggingface.co/inclusionAI/Ling-1T) &nbsp;&nbsp; [🤖 ModelScope](https://www.modelscope.cn/models/inclusionAI/Ling-1T) |
153
+
154
+ </center>
155
+
156
+ Note: If you are interested in previous version, please visit the past model collections in [Huggingface](https://huggingface.co/inclusionAI) or [ModelScope](https://modelscope.cn/organization/inclusionAI).
157
+
158
+
159
+ ## Quickstart
160
+
161
+ ### 🚀 Try Online
162
+
163
+ You can experience Ling-1T online at: [ZenMux](https://zenmux.ai/inclusionai/ling-1t?utm_source=hf_inclusionAI)
164
+
165
+ ### 🔌 API Usage
166
+
167
+ You can also use Ling-1T through API calls:
168
+
169
+ ```python
170
+ from openai import OpenAI
171
+
172
+ # 1. Initialize the OpenAI client
173
+ client = OpenAI(
174
+ # 2. Point the base URL to the ZenMux endpoint
175
+ base_url="https://zenmux.ai/api/v1",
176
+ # 3. Replace with the API Key from your ZenMux user console
177
+ api_key="<your ZENMUX_API_KEY>",
178
+ )
179
+
180
+ # 4. Make a request
181
+ completion = client.chat.completions.create(
182
+ # 5. Specify the model to use in the format "provider/model-name"
183
+ model="inclusionai/ling-1t",
184
+ messages=[
185
+ {
186
+ "role": "user",
187
+ "content": "What is the meaning of life?"
188
+ }
189
+ ]
190
+ )
191
+
192
+ print(completion.choices[0].message.content)
193
+ ```
194
+
195
+ ## Deployment
196
+
197
+ ### SGLang
198
+
199
+ #### Environment Preparation
200
+
201
+ We will later submit our model to the SGLang official release. Now we can prepare the environment by following these steps:
202
+ ```shell
203
+ pip3 install -U sglang sgl-kernel
204
+ ```
205
+
206
+ #### Run Inference
207
+
208
+ Both BF16 and FP8 models are supported by SGLang now. It depends on the dtype of the model in ${MODEL_PATH}.
209
+
210
+ Here is the example to run Ling-1T with multiple GPU nodes, where the master node IP is ${MASTER_IP} and server port is ${PORT}:
211
+
212
+ - Start server:
213
+ ```bash
214
+ # Node 0:
215
+ python -m sglang.launch_server --model-path $MODEL_PATH --tp-size 8 --pp-size 4 --dp-size 1 --trust-remote-code --dist-init-addr $MASTER_IP:2345 --port $PORT --nnodes 4 --node-rank 0
216
+
217
+ # Node 1:
218
+ python -m sglang.launch_server --model-path $MODEL_PATH --tp-size 8 --pp-size 4 --dp-size 1 --trust-remote-code --dist-init-addr $MASTER_IP:2345 --port $PORT --nnodes 4 --node-rank 1
219
+
220
+ # Node 2:
221
+ python -m sglang.launch_server --model-path $MODEL_PATH --tp-size 8 --pp-size 4 --dp-size 1 --trust-remote-code --dist-init-addr $MASTER_IP:2345 --port $PORT --nnodes 4 --node-rank 2
222
+
223
+ # Node 3:
224
+ python -m sglang.launch_server --model-path $MODEL_PATH --tp-size 8 --pp-size 4 --dp-size 1 --trust-remote-code --dist-init-addr $MASTER_IP:2345 --port $PORT --nnodes 4 --node-rank 3
225
+
226
+ # This is only an example. Please adjust arguments according to your actual environment.
227
+ ```
228
+
229
+ - Client:
230
+
231
+ ```shell
232
+ curl -s http://${MASTER_IP}:${PORT}/v1/chat/completions \
233
+ -H "Content-Type: application/json" \
234
+ -d '{"model": "auto", "messages": [{"role": "user", "content": "What is the capital of France?"}]}'
235
+ ```
236
+
237
+ More usage can be found [here](https://docs.sglang.ai/basic_usage/send_request.html)
238
+
239
+ ### vLLM
240
+
241
+ #### Environment Preparation
242
+
243
+ ```bash
244
+ pip install vllm==0.11.0
245
+ ```
246
+
247
+ #### Run Inference:
248
+
249
+ Here is the example to deploy the model with multiple GPU nodes, where the master node IP is ${MASTER_IP}, server port is ${PORT} and the path of model is ${MODEL_PATH}:
250
+
251
+ ```bash
252
+ # step 1. start ray on all nodes
253
+
254
+ # step 2. start vllm server only on node 0:
255
+ vllm serve $MODEL_PATH --port $PORT --served-model-name my_model --trust-remote-code --tensor-parallel-size 8 --pipeline-parallel-size 4 --gpu-memory-utilization 0.85
256
+
257
+ # This is only an example, please adjust arguments according to your actual environment.
258
+ ```
259
+
260
+ To handle long context in vLLM using YaRN, we need to follow these two steps:
261
+ 1. Add a `rope_scaling` field to the model's `config.json` file, for example:
262
+ ```json
263
+ {
264
+ ...,
265
+ "rope_scaling": {
266
+ "factor": 4.0,
267
+ "original_max_position_embeddings": 32768,
268
+ "type": "yarn"
269
+ }
270
+ }
271
+ ```
272
+ 2. Use an additional parameter `--max-model-len` to specify the desired maximum context length when starting the vLLM service.
273
+
274
+ For detailed guidance, please refer to the vLLM [`instructions`](https://docs.vllm.ai/en/latest/).
275
+
276
+
277
+
278
+ ## Limitations & Future Plans
279
+
280
+ While **[Ling-1T](https://zenmux.ai/inclusionai/ling-1t?utm_source=hf_inclusionAI)** has made strong progress in efficient reasoning, cross-domain generalization, and training efficiency, several limitations remain:
281
+
282
+ * **GQA-based attention**: stable for long-context reasoning but relatively costly. Future versions will adopt **hybrid attention** to improve efficiency.
283
+ * **Limited agentic ability**: current model has room to grow in multi-turn interaction, long-term memory, and tool use.
284
+ * **Instruction and identity issues**: occasional deviations or role confusion may occur; future updates will enhance **alignment and consistency**.
285
+
286
+ The future versions of Ling-1T will continue to evolve in architecture, reasoning, and alignment, advancing the series toward more general intelligence.
287
+
288
+
289
+ ## License
290
+
291
+ This code repository is licensed under [the MIT License](https://github.com/inclusionAI/Ling-V2/blob/main/LICENSE).
292
+
293
+ ## FAQ
294
+ Recommended temperature? **0.7**
295
+ Recommended top_p? **0.95**
chat_template.jinja ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% set thinking_option = 'off' %}
2
+ {{- '<role>SYSTEM</role>' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n' }}
5
+ {%- endif %}
6
+ {%- if tools %}
7
+ {{- "# 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>" }}
8
+ {%- for tool in tools %}
9
+ {{- "\n" }}
10
+ {{- tool | tojson }}
11
+ {%- endfor %}
12
+ {{- "\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>\n" }}
13
+ {%- endif %}
14
+ {{- 'detailed thinking ' + thinking_option + '<|role_end|>' }}
15
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
16
+ {%- for message in messages[::-1] %}
17
+ {%- set index = (messages|length - 1) - loop.index0 %}
18
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
19
+ {%- set ns.multi_step_tool = false %}
20
+ {%- set ns.last_query_index = index %}
21
+ {%- endif %}
22
+ {%- endfor %}
23
+ {%- for message in messages %}
24
+ {%- if message.content is string %}
25
+ {%- set content = message.content %}
26
+ {%- else %}
27
+ {%- set content = '' %}
28
+ {%- endif %}
29
+ {%- if message.role == "user" %}
30
+ {{- '<role>HUMAN</role>' + message.content + '<|role_end|>' }}
31
+ {%- elif message.role == "system" and not loop.first %}
32
+ {{- '<role>SYSTEM</role>' + message.content + '<|role_end|>' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = ((content.split('</think>')|first).rstrip('\n').split('<think>')|last).lstrip('\n') %}
40
+ {%- set content = (content.split('</think>')|last).lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if loop.index0 > ns.last_query_index %}
44
+ {%- if reasoning_content %}
45
+ {{- '<role>ASSISTANT</role>' + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
46
+ {%- else %}
47
+ {{- '<role>ASSISTANT</role>' + content }}
48
+ {%- endif %}
49
+ {%- else %}
50
+ {{- '<role>ASSISTANT</role>' + content }}
51
+ {%- endif %}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if (loop.first and content) or (not loop.first) %}
55
+ {{- '\n' }}
56
+ {%- endif %}
57
+ {%- if tool_call.function %}
58
+ {%- set tool_call = tool_call.function %}
59
+ {%- endif %}
60
+ {{- '<tool_call>\n{"name": "' }}
61
+ {{- tool_call.name }}
62
+ {{- '", "arguments": ' }}
63
+ {%- if tool_call.arguments is string %}
64
+ {{- tool_call.arguments }}
65
+ {%- else %}
66
+ {{- tool_call.arguments | tojson }}
67
+ {%- endif %}
68
+ {{- '}\n</tool_call>' }}
69
+ {%- endfor %}
70
+ {%- endif %}
71
+ {{- '<|role_end|>' }}
72
+ {%- elif message.role == "tool" %}
73
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
74
+ {{- '<role>OBSERVATION</role>' }}
75
+ {%- endif %}
76
+ {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
+ {{- '\n</tool_response>' }}
79
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
+ {{- '<|role_end|>' }}
81
+ {%- endif %}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- if add_generation_prompt %}
85
+ {{- '<role>ASSISTANT</role>' }}
86
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BailingMoeV2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "auto_map": {
7
+ "AutoConfig": "configuration_bailing_moe_v2.BailingMoeV2Config",
8
+ "AutoModel": "modeling_bailing_moe_v2.BailingMoeV2Model",
9
+ "AutoModelForCausalLM": "modeling_bailing_moe_v2.BailingMoeV2ForCausalLM"
10
+ },
11
+ "torch_dtype": "bfloat16",
12
+ "embedding_dropout": 0.0,
13
+ "eos_token_id": 156892,
14
+ "first_k_dense_replace": 4,
15
+ "head_dim": 128,
16
+ "hidden_act": "silu",
17
+ "hidden_size": 8192,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 18432,
20
+ "max_position_embeddings": 32768,
21
+ "max_window_layers": 20,
22
+ "moe_intermediate_size": 2048,
23
+ "moe_router_enable_expert_bias": true,
24
+ "mtp_loss_scaling_factor": 0,
25
+ "n_group": 8,
26
+ "norm_head": false,
27
+ "norm_softmax": false,
28
+ "norm_topk_prob": true,
29
+ "num_attention_heads": 64,
30
+ "num_experts": 256,
31
+ "num_experts_per_tok": 8,
32
+ "num_hidden_layers": 80,
33
+ "num_key_value_heads": 8,
34
+ "num_nextn_predict_layers": 0,
35
+ "num_shared_experts": 1,
36
+ "output_dropout": 0.0,
37
+ "output_router_logits": false,
38
+ "pad_token_id": 157150,
39
+ "rms_norm_eps": 1e-06,
40
+ "rope_scaling": null,
41
+ "rope_theta": 600000,
42
+ "rotary_dim": 64,
43
+ "routed_scaling_factor": 2.5,
44
+ "router_dtype": "fp32",
45
+ "score_function": "sigmoid",
46
+ "tie_word_embeddings": false,
47
+ "topk_group": 4,
48
+ "transformers_version": "4.57.1",
49
+ "unsloth_fixed": true,
50
+ "use_bias": false,
51
+ "use_cache": true,
52
+ "use_qk_norm": true,
53
+ "use_qkv_bias": false,
54
+ "use_rmsnorm": true,
55
+ "using_split_qkv_in_self_attention": false,
56
+ "vocab_size": 157184
57
+ }
configuration_bailing_moe_v2.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Bailing MoE V2 model configuration"""
2
+
3
+ from transformers.configuration_utils import PretrainedConfig
4
+
5
+
6
+ class BailingMoeV2Config(PretrainedConfig):
7
+
8
+ def __init__(
9
+ self,
10
+ vocab_size=157184,
11
+ hidden_size=2048,
12
+ intermediate_size=5120,
13
+ num_hidden_layers=20,
14
+ num_attention_heads=16,
15
+ num_key_value_heads=4,
16
+ hidden_act="silu",
17
+ use_qkv_bias=False, # bailing only
18
+ use_bias=False, # bailing only
19
+ rms_norm_eps=1e-06,
20
+ tie_word_embeddings=False, # PretrainedConfig key, here change default value.
21
+ embedding_dropout=0.0,
22
+ attention_dropout=0.0,
23
+ output_dropout=0.0,
24
+ initializer_range=0.02,
25
+ max_position_embeddings=32768,
26
+ rope_theta=600000.0,
27
+ use_cache=True,
28
+ max_window_layers=20,
29
+ rope_scaling=None,
30
+ pad_token_id=156892,
31
+ eos_token_id=156892,
32
+ num_experts=256,
33
+ num_shared_experts=1,
34
+ num_experts_per_tok=8,
35
+ n_group=8,
36
+ topk_group=4,
37
+ moe_intermediate_size=512,
38
+ first_k_dense_replace=1,
39
+ head_dim=128,
40
+ output_router_logits=False,
41
+ use_qk_norm=True,
42
+ num_nextn_predict_layers=0,
43
+ mtp_loss_scaling_factor=0,
44
+ moe_router_enable_expert_bias=True,
45
+ routed_scaling_factor=1.0,
46
+ **kwargs,
47
+ ):
48
+ self.num_hidden_layers = num_hidden_layers
49
+ self.vocab_size = vocab_size
50
+ self.hidden_size = hidden_size
51
+ self.intermediate_size = intermediate_size
52
+ self.num_attention_heads = num_attention_heads
53
+ self.num_key_value_heads = num_key_value_heads
54
+ self.hidden_act = hidden_act
55
+ self.use_qkv_bias = use_qkv_bias
56
+ self.use_bias = use_bias
57
+ self.rms_norm_eps = rms_norm_eps
58
+ self.embedding_dropout = embedding_dropout
59
+ self.attention_dropout = attention_dropout
60
+ self.output_dropout = output_dropout
61
+ self.num_nextn_predict_layers = num_nextn_predict_layers
62
+ self.mtp_loss_scaling_factor = mtp_loss_scaling_factor
63
+ self.initializer_range = initializer_range
64
+ self.max_position_embeddings = max_position_embeddings
65
+ self.rope_theta = rope_theta
66
+ self.use_cache = use_cache
67
+ self.max_window_layers = max_window_layers
68
+ self.head_dim = head_dim or self.hidden_size // self.num_attention_heads
69
+ self.rope_scaling = rope_scaling
70
+ self.use_qk_norm = use_qk_norm
71
+ self.moe_router_enable_expert_bias = moe_router_enable_expert_bias
72
+ self.routed_scaling_factor = routed_scaling_factor
73
+
74
+ # MoE configs
75
+ self.num_experts = num_experts
76
+ self.num_shared_experts = num_shared_experts
77
+ self.num_experts_per_tok = num_experts_per_tok
78
+ self.n_group = n_group
79
+ self.topk_group = topk_group
80
+ self.moe_intermediate_size = moe_intermediate_size
81
+ self.first_k_dense_replace = first_k_dense_replace
82
+ self.output_router_logits = output_router_logits
83
+
84
+ super().__init__(pad_token_id=pad_token_id, eos_token_id=eos_token_id, tie_word_embeddings=tie_word_embeddings, **kwargs)
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 156891,
3
+ "eos_token_id": [
4
+ 156892,
5
+ 156895
6
+ ],
7
+ "pad_token_id": 156892,
8
+ "transformers_version": "4.52.3"
9
+ }
model-00001-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:02b5cbbf76f7b21e54a936db254aef54aa4196d8a729c93ce6e26e7467c9448c
3
+ size 2575302800
model-00002-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8bd28b5ae46d9bfd9a606fb9a3d78145a82ccc683cba6046d0778c5cff62774b
3
+ size 17179933360
model-00003-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34fe8fa1233a826f93c2017ed28346c917d208acba742f9e499bdf862e29a15a
3
+ size 10708107872
model-00004-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4228da5f6d58a79560d41a80f697562ff44f7bbb9803a5890783fececb0c601d
3
+ size 3288489872
model-00005-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:49a3a53e41ac87a436a1786c24d0323287974562c92548307770dcb2b3b422dd
3
+ size 17179933360
model-00006-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d8ec47016f9a3d68b949eb59194c1721855edaa58e5c06f6f1de110a1b9f5779
3
+ size 8657075832
model-00007-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01cf04ff48fe7d7d9a2770a8a95ac9cdd0e64b58b1197035a490f7f766c64602
3
+ size 17179933360
model-00008-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:333488f4b27ff934a3fa3164da9325320c0944fad308da2e478b30e4a729a14d
3
+ size 8589966712
model-00009-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:008d73992a834cefbfc1f2f56ecdb32d1738f68d28cd2df4157f3cae5a0107d4
3
+ size 17179933360
model-00010-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f0aecdfbf532e98b935915b0841d01be6960a6e1716ff58833acd5704f4ce6a
3
+ size 8657075832
model-00011-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a488ad4f161015436e9f4ff84a9777e0778043aa01aa5b46bfea8f5fd9182ce3
3
+ size 17179933360
model-00012-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:383093458cbad7d3fc8ab944a5d9e47ef9e01b514e1558bdcafa46fe6cf5cc7c
3
+ size 8589966712
model-00013-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2069456d5f45c0ab79c493504d101b908a3cabb03ff16434254924835312e3eb
3
+ size 17179933360
model-00014-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6432062b2480faf01fd834cc3a56d23730f63a3ceb2edb2cc38473282e8b8a69
3
+ size 10490163984
model-00015-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c585d0611f633e6005a1aaff570c2063316a02995a85c5de37b34c73cc23189d
3
+ size 17179933872
model-00016-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2775dcc6573a9473beb946bd0166c4a01f2f6f9b8d5ccbd3facffd778e6f9250
3
+ size 8657076088
model-00017-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3619ed11511840a7bb5b123505d2cff512c72363a23aac618258a13d6c7d1ef0
3
+ size 17179933872
model-00018-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d59267abd6626bf0e90a35b9fa30cf6c7d887a6fad811c92029fd4c8ce27083a
3
+ size 8589966968
model-00019-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21adbbd374b63a8bc5e50f9466ce0aad7d5246f84c3daaeee43d70b65bbee154
3
+ size 17179933872
model-00020-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad841c7b90c64ec1050762ae562627b7ec9f9ab132a66d8e88e6338439b24d37
3
+ size 8657076088
model-00021-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:380b6583db0da7e30a87a5b8e096d5773085a4d53ede7498e23735c934d03490
3
+ size 17179933872
model-00022-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d50cc291578e241e0af278fbdf34b196baaa1620b99b027c4536ce5309af803a
3
+ size 8589966968
model-00023-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7f2c73f58ef51962d88c22536b807ba0fd3c01544209e2a686dc0c65ad132c2e
3
+ size 17179933872
model-00024-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a08d3eeb95f6289dd9af1e441cf4c05891f9c764ab7e990c6e76e2b4af86c22d
3
+ size 10490164272
model-00025-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6878d24020df6bf0453a99fe3011a210a5f55e4acced37d3634e3e057ea99dbc
3
+ size 17179933872
model-00026-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77282b6a5d29a1c70401004d0e05e614379a4cf0d95d804ef957207bf6899222
3
+ size 8657076088
model-00027-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:281173419752769f7f75df827e1ae6fd2f0eaf8b45264e7c671221a7b64d7428
3
+ size 17179933872
model-00028-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1688f9e2ec553ad717fd0d66aee51a5940e18c4ab92c5b7854a43490e0e24fb9
3
+ size 8589966968
model-00029-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db40bd9419270afc67edb8d0a8dc69d9d1099f892b9ae11fdc1242d0b9279a3e
3
+ size 17179933872
model-00030-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c403ade0ebdd0054d297541f878bfedad6bdfc9ed22978eeab61d8efdb415482
3
+ size 8657076088
model-00031-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e883b038c46d2aeba5684db61d230b6350e89b1ac0ee143ed73d0096a49b70dd
3
+ size 17179933872
model-00032-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f885a5608a7158d6f0a55d8e20ace0f22cecca25f54a66069c66e08df5159061
3
+ size 8589966968
model-00033-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ecb9d25417c4b5c8b38dae83b1fb545e691e1b73d906fa04ca0ecad78c22aad
3
+ size 17179933872
model-00034-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3778e8558dae08ae7d15f1a56a9336fc54080365ea614ddeefddc1f73d10904e
3
+ size 10490164272
model-00035-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83952cf51e885baf669717b6715df137b346a6a30d0ca10a8cb8cb8e7601cefa
3
+ size 17179933872
model-00036-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9634b8b63c9aa27b4d26de509c35a3573faad4f480881cd06a338e78c7319371
3
+ size 8657076088
model-00037-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5006fc1db0febe78c7aa5806fa2216366e8eeaa1ce35490eddb0e4b19075322
3
+ size 17179933872
model-00038-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c749514f6a116cd9e92fde5806fd1d8f9ddf9cc8109d5ee4e661048cbf30e7ac
3
+ size 8589966968
model-00039-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7795ccc126467aaaf1b541ef57b67a63815095468beed6b677cd1babe650002
3
+ size 17179933872
model-00040-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:65a272b0c3386985097812a3d6cd32eb3e338725d1870bc9ed36915d241b24c5
3
+ size 8657076088
model-00041-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2495349816f2a677d8ef73711ba8f9094917ec2ce7b27c01c7fce6bdd9d1cfcb
3
+ size 17179933872
model-00042-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:66f7ac37d2d6bea6df36ab4596ee402242d3037abea2c15fe1377e92281b89f6
3
+ size 8589966968
model-00043-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eaf78374089e06fec5abb6838efb0e7fc1a6c6c38bc840a123a5aa1b1cf82197
3
+ size 17179933872
model-00044-of-00155.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d36c97a6e7a86c5796656a88abd1171a403937c11490c837e4eb382c6559be67
3
+ size 10490164272