Text Generation
Transformers.js
ONNX
qwen3_5_text
webgpu
onnxruntime
onnxruntime-genai
q4
q4f16
int4
cuda
Mixture of Experts
conversational
Instructions to use webbrain-one/Ling-3.0-tiny-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use webbrain-one/Ling-3.0-tiny-ONNX with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-generation', 'webbrain-one/Ling-3.0-tiny-ONNX');
Add files using upload-large-folder tool
Browse files- .gitattributes +3 -0
- README.md +121 -80
- SHA256SUMS +4 -0
- config.json +126 -1
- config_bailing_original.json +83 -0
- onnx/model_q4f16.onnx +3 -0
- onnx/model_q4f16.onnx_data +3 -0
- onnx/model_q4f16.onnx_data_1 +3 -0
- onnx/model_q4f16.onnx_data_2 +3 -0
- tokenizer_config.json +2 -1
.gitattributes
CHANGED
|
@@ -35,3 +35,6 @@ saved_model/**/* 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
|
| 37 |
model.onnx.data 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
|
| 37 |
model.onnx.data filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
onnx/model_q4f16.onnx_data_1 filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
onnx/model_q4f16.onnx_data filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
onnx/model_q4f16.onnx_data_2 filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,22 +1,25 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
base_model: inclusionAI/Ling-3.0-tiny
|
| 4 |
-
library_name:
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
tags:
|
| 7 |
- onnx
|
|
|
|
|
|
|
| 8 |
- onnxruntime
|
| 9 |
- onnxruntime-genai
|
| 10 |
- q4
|
|
|
|
| 11 |
- int4
|
| 12 |
- cuda
|
| 13 |
- moe
|
| 14 |
- text-generation
|
| 15 |
---
|
| 16 |
|
| 17 |
-
# Ling-3.0-tiny ONNX — Q4 CUDA
|
| 18 |
|
| 19 |
-
|
| 20 |
[`inclusionAI/Ling-3.0-tiny`](https://huggingface.co/inclusionAI/Ling-3.0-tiny),
|
| 21 |
a 7.9B-total / 1.3B-active-parameter hybrid reasoning MoE model.
|
| 22 |
|
|
@@ -25,52 +28,97 @@ a 7.9B-total / 1.3B-active-parameter hybrid reasoning MoE model.
|
|
| 25 |
> release. Read the [original model card](https://huggingface.co/inclusionAI/Ling-3.0-tiny)
|
| 26 |
> for training, evaluation, intended use, and base-model limitations.
|
| 27 |
|
| 28 |
-
|
|
| 29 |
-
|---|---|
|
| 30 |
-
|
|
| 31 |
-
|
|
| 32 |
-
| Quantization | Q4 weight-only, block size 32 |
|
| 33 |
-
| Activations / cache | FP16 |
|
| 34 |
-
| Router math | FP32 |
|
| 35 |
-
| Context length | 131,072 tokens, subject to available VRAM |
|
| 36 |
-
| Download size | 4.849 GB / 4.516 GiB |
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
specialized layers with dense approximations:
|
| 42 |
|
| 43 |
-
|
| 44 |
-
- 6 Multi-Latent Attention (MLA) layers with KV cache
|
| 45 |
-
- 23 sparse MoE layers with 128 routed experts, top-8 group-limited routing,
|
| 46 |
-
expert bias, and one shared expert
|
| 47 |
-
- one dense MLP layer at the start of the decoder
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
`
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
|
|
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
```
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
```bash
|
| 67 |
-
pip install -
|
| 68 |
-
|
| 69 |
-
|
| 70 |
```
|
| 71 |
|
| 72 |
-
## Run with Python
|
| 73 |
-
|
| 74 |
```python
|
| 75 |
import numpy as np
|
| 76 |
import onnxruntime_genai as og
|
|
@@ -78,14 +126,10 @@ from transformers import AutoTokenizer
|
|
| 78 |
|
| 79 |
model_dir = "Ling-3.0-tiny-ONNX"
|
| 80 |
model = og.Model(model_dir)
|
| 81 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
| 82 |
-
model_dir,
|
| 83 |
-
trust_remote_code=True,
|
| 84 |
-
)
|
| 85 |
|
| 86 |
-
messages = [{"role": "user", "content": "Explain why the sky is blue."}]
|
| 87 |
input_ids = tokenizer.apply_chat_template(
|
| 88 |
-
|
| 89 |
add_generation_prompt=True,
|
| 90 |
tokenize=True,
|
| 91 |
return_tensors="np",
|
|
@@ -94,66 +138,63 @@ input_ids = tokenizer.apply_chat_template(
|
|
| 94 |
|
| 95 |
params = og.GeneratorParams(model)
|
| 96 |
params.set_search_options(
|
| 97 |
-
max_length=int(input_ids.shape[-1]) +
|
| 98 |
do_sample=False,
|
| 99 |
)
|
| 100 |
|
| 101 |
generator = og.Generator(model, params)
|
| 102 |
generator.append_tokens(np.asarray(input_ids[0], dtype=np.int32))
|
| 103 |
-
|
| 104 |
prompt_length = int(input_ids.shape[-1])
|
|
|
|
| 105 |
while not generator.is_done():
|
| 106 |
generator.generate_next_token()
|
| 107 |
|
| 108 |
-
|
| 109 |
-
print(tokenizer.decode(generated, skip_special_tokens=True))
|
| 110 |
```
|
| 111 |
|
| 112 |
-
|
| 113 |
-
model card recommends `temperature=1.0`, `top_p=0.95`, and `top_k=20` for
|
| 114 |
-
thinking-mode sampling.
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
-
|
| 119 |
-
|
| 120 |
-
-
|
| 121 |
-
-
|
| 122 |
-
-
|
| 123 |
-
|
| 124 |
|
| 125 |
-
|
| 126 |
-
|
| 127 |
|
| 128 |
## Validation
|
| 129 |
|
| 130 |
-
The complete artifact
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
```bash
|
| 140 |
-
sha256sum -c SHA256SUMS
|
| 141 |
-
```
|
| 142 |
|
| 143 |
## Limitations
|
| 144 |
|
| 145 |
-
- This graph targets the CUDA execution provider and uses ONNX Runtime contrib
|
| 146 |
-
operators that older runtime versions do not provide.
|
| 147 |
- Q4 quantization can change outputs and quality relative to the original BF16
|
| 148 |
checkpoint. No benchmark parity claim is made here.
|
| 149 |
-
-
|
| 150 |
-
by
|
| 151 |
-
-
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
## Attribution and license
|
| 155 |
|
| 156 |
The model architecture, checkpoint, tokenizer, and chat template are by
|
| 157 |
-
[inclusionAI](https://huggingface.co/inclusionAI). This conversion retains the
|
| 158 |
-
base model's MIT license. Please cite and credit the
|
| 159 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
base_model: inclusionAI/Ling-3.0-tiny
|
| 4 |
+
library_name: transformers.js
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
tags:
|
| 7 |
- onnx
|
| 8 |
+
- transformers.js
|
| 9 |
+
- webgpu
|
| 10 |
- onnxruntime
|
| 11 |
- onnxruntime-genai
|
| 12 |
- q4
|
| 13 |
+
- q4f16
|
| 14 |
- int4
|
| 15 |
- cuda
|
| 16 |
- moe
|
| 17 |
- text-generation
|
| 18 |
---
|
| 19 |
|
| 20 |
+
# Ling-3.0-tiny ONNX — Q4 WebGPU + CUDA
|
| 21 |
|
| 22 |
+
Community ONNX conversion of
|
| 23 |
[`inclusionAI/Ling-3.0-tiny`](https://huggingface.co/inclusionAI/Ling-3.0-tiny),
|
| 24 |
a 7.9B-total / 1.3B-active-parameter hybrid reasoning MoE model.
|
| 25 |
|
|
|
|
| 28 |
> release. Read the [original model card](https://huggingface.co/inclusionAI/Ling-3.0-tiny)
|
| 29 |
> for training, evaluation, intended use, and base-model limitations.
|
| 30 |
|
| 31 |
+
| Target | Files | Runtime | Download |
|
| 32 |
+
|---|---|---|---:|
|
| 33 |
+
| Browser WebGPU | `onnx/model_q4f16.onnx` + 3 data shards | Transformers.js 4.2+ | 4.849 GB / 4.516 GiB |
|
| 34 |
+
| NVIDIA CUDA | `model.onnx` + `model.onnx.data` | ONNX Runtime GenAI | 4.849 GB / 4.516 GiB |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
The WebGPU layout follows the standard Transformers.js `q4f16` contract used
|
| 37 |
+
by browser-oriented ONNX repositories: the graph is under `onnx/`, external
|
| 38 |
+
tensor data is split into three sub-2 GB files, activations and cache are FP16,
|
| 39 |
+
and hybrid recurrent-cache names use the Qwen3.5-compatible convention already
|
| 40 |
+
supported by Transformers.js.
|
| 41 |
|
| 42 |
+
## Run in the browser with WebGPU
|
|
|
|
| 43 |
|
| 44 |
+
Install Transformers.js 4.2 or newer:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
```bash
|
| 47 |
+
npm install "@huggingface/transformers@^4.2.0"
|
| 48 |
+
```
|
| 49 |
|
| 50 |
+
```javascript
|
| 51 |
+
import { pipeline, TextStreamer } from '@huggingface/transformers';
|
| 52 |
+
|
| 53 |
+
const generator = await pipeline(
|
| 54 |
+
'text-generation',
|
| 55 |
+
'webbrain-one/Ling-3.0-tiny-ONNX',
|
| 56 |
+
{
|
| 57 |
+
device: 'webgpu',
|
| 58 |
+
dtype: 'q4f16',
|
| 59 |
+
},
|
| 60 |
+
);
|
| 61 |
+
|
| 62 |
+
const messages = [
|
| 63 |
+
{ role: 'user', content: 'Explain why the sky is blue in two sentences.' },
|
| 64 |
+
];
|
| 65 |
+
|
| 66 |
+
const output = await generator(messages, {
|
| 67 |
+
max_new_tokens: 128,
|
| 68 |
+
do_sample: false,
|
| 69 |
+
tokenizer_encode_kwargs: { enable_thinking: false },
|
| 70 |
+
streamer: new TextStreamer(generator.tokenizer, {
|
| 71 |
+
skip_prompt: true,
|
| 72 |
+
skip_special_tokens: true,
|
| 73 |
+
}),
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
console.log(output[0].generated_text.at(-1)?.content);
|
| 77 |
+
```
|
| 78 |
|
| 79 |
+
For thinking mode, set `enable_thinking: true`. The original model card
|
| 80 |
+
recommends `temperature: 1.0`, `top_p: 0.95`, and `top_k: 20` when sampling in
|
| 81 |
+
thinking mode.
|
| 82 |
|
| 83 |
+
### Browser requirements
|
| 84 |
+
|
| 85 |
+
- A current desktop browser with WebGPU enabled; Chrome or Edge is recommended.
|
| 86 |
+
- Approximately 4.85 GB of model downloads on first load, plus browser cache.
|
| 87 |
+
- Enough GPU memory for all weights, runtime buffers, state, and the requested
|
| 88 |
+
context. The 1.3B active-parameter figure reduces compute, but all 7.9B model
|
| 89 |
+
parameters still need to be stored.
|
| 90 |
+
- Start with a short prompt and modest `max_new_tokens`, then increase context
|
| 91 |
+
after confirming memory use on the target device.
|
| 92 |
+
|
| 93 |
+
This graph depends on WebGPU implementations of `MatMulNBits`, `QMoE`,
|
| 94 |
+
`LinearAttention`, `CausalConvWithState`, and `GroupQueryAttention`. It is not a
|
| 95 |
+
WASM/CPU fallback model.
|
| 96 |
+
|
| 97 |
+
## Use from WebBrain
|
| 98 |
+
|
| 99 |
+
Use the same repository ID and standard Transformers.js settings:
|
| 100 |
+
|
| 101 |
+
```text
|
| 102 |
+
model: webbrain-one/Ling-3.0-tiny-ONNX
|
| 103 |
+
device: webgpu
|
| 104 |
+
dtype: q4f16
|
| 105 |
+
task: text-generation
|
| 106 |
```
|
| 107 |
|
| 108 |
+
WebBrain should select `onnx/model_q4f16.onnx` and fetch the three external-data
|
| 109 |
+
files declared by `config.json`.
|
| 110 |
+
|
| 111 |
+
## Run the CUDA variant with Python
|
| 112 |
+
|
| 113 |
+
The repository also retains the separately validated CUDA-targeted ONNX Runtime
|
| 114 |
+
GenAI graph.
|
| 115 |
|
| 116 |
```bash
|
| 117 |
+
pip install "onnxruntime-gpu>=1.28.0" \
|
| 118 |
+
"onnxruntime-genai-cuda>=0.15.2" \
|
| 119 |
+
"transformers>=4.57,<5"
|
| 120 |
```
|
| 121 |
|
|
|
|
|
|
|
| 122 |
```python
|
| 123 |
import numpy as np
|
| 124 |
import onnxruntime_genai as og
|
|
|
|
| 126 |
|
| 127 |
model_dir = "Ling-3.0-tiny-ONNX"
|
| 128 |
model = og.Model(model_dir)
|
| 129 |
+
tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)
|
|
|
|
|
|
|
|
|
|
| 130 |
|
|
|
|
| 131 |
input_ids = tokenizer.apply_chat_template(
|
| 132 |
+
[{"role": "user", "content": "Explain why the sky is blue."}],
|
| 133 |
add_generation_prompt=True,
|
| 134 |
tokenize=True,
|
| 135 |
return_tensors="np",
|
|
|
|
| 138 |
|
| 139 |
params = og.GeneratorParams(model)
|
| 140 |
params.set_search_options(
|
| 141 |
+
max_length=int(input_ids.shape[-1]) + 128,
|
| 142 |
do_sample=False,
|
| 143 |
)
|
| 144 |
|
| 145 |
generator = og.Generator(model, params)
|
| 146 |
generator.append_tokens(np.asarray(input_ids[0], dtype=np.int32))
|
|
|
|
| 147 |
prompt_length = int(input_ids.shape[-1])
|
| 148 |
+
|
| 149 |
while not generator.is_done():
|
| 150 |
generator.generate_next_token()
|
| 151 |
|
| 152 |
+
print(tokenizer.decode(generator.get_sequence(0)[prompt_length:], skip_special_tokens=True))
|
|
|
|
| 153 |
```
|
| 154 |
|
| 155 |
+
## Architecture and quantization
|
|
|
|
|
|
|
| 156 |
|
| 157 |
+
- 18 Kimi Delta Attention layers with recurrent and convolution state
|
| 158 |
+
- 6 Multi-Latent Attention layers with KV cache
|
| 159 |
+
- 23 sparse MoE layers with 128 routed experts, top-8 group-limited routing,
|
| 160 |
+
expert bias, and one shared expert
|
| 161 |
+
- one dense MLP layer at the start of the decoder
|
| 162 |
+
- symmetric Q4/block-32 dense and routed-expert weights
|
| 163 |
+
- FP16 embeddings, activations, recurrent state, and KV cache
|
| 164 |
+
- FP32 MoE router weights and routing math
|
| 165 |
|
| 166 |
+
The ONNX graph contains 235 `MatMulNBits`, 23 `QMoE`, 18 `LinearAttention`,
|
| 167 |
+
18 `CausalConvWithState`, and 6 `GroupQueryAttention` nodes.
|
| 168 |
|
| 169 |
## Validation
|
| 170 |
|
| 171 |
+
- The complete CUDA artifact generated successfully on an NVIDIA GeForce RTX
|
| 172 |
+
5090 with ONNX Runtime GenAI 0.15.2 and ONNX Runtime GPU 1.28.0.
|
| 173 |
+
- The WebGPU repack was verified tensor-for-tensor against the CUDA graph; all
|
| 174 |
+
4,835,749,912 external tensor bytes are identical.
|
| 175 |
+
- Transformers.js 4.2.0 loads the config, dispatches `Qwen3_5ForCausalLM`, finds
|
| 176 |
+
all 18 recurrent/conv caches and 6 attention caches, and applies the original
|
| 177 |
+
Ling tokenizer/chat template.
|
| 178 |
+
- Browser WebGPU generation validation is required before treating this variant
|
| 179 |
+
as production-ready.
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
## Limitations
|
| 182 |
|
|
|
|
|
|
|
| 183 |
- Q4 quantization can change outputs and quality relative to the original BF16
|
| 184 |
checkpoint. No benchmark parity claim is made here.
|
| 185 |
+
- Browser support, GPU limits, shader compilation time, and memory behavior vary
|
| 186 |
+
by operating system, browser version, and GPU driver.
|
| 187 |
+
- The advertised 131,072-token context is architectural; practical browser
|
| 188 |
+
context is limited by available GPU memory.
|
| 189 |
+
- The WebGPU config uses Transformers.js's existing `qwen3_5_text` hybrid-cache
|
| 190 |
+
adapter solely as a runtime compatibility layer. The underlying graph and
|
| 191 |
+
weights remain Ling/Bailing Hybrid, preserved in
|
| 192 |
+
`config_bailing_original.json`.
|
| 193 |
|
| 194 |
## Attribution and license
|
| 195 |
|
| 196 |
The model architecture, checkpoint, tokenizer, and chat template are by
|
| 197 |
+
[`inclusionAI`](https://huggingface.co/inclusionAI). This conversion retains the
|
| 198 |
+
base model's MIT license. Please cite and credit the
|
| 199 |
+
[original Ling-3.0-tiny release](https://huggingface.co/inclusionAI/Ling-3.0-tiny)
|
| 200 |
+
when using or redistributing this artifact.
|
SHA256SUMS
CHANGED
|
@@ -1,2 +1,6 @@
|
|
| 1 |
cdd5029c67a427156a92938f8389482e597324f05ff1b08b364e473b9e75da11 model.onnx
|
| 2 |
172b0b42e7cca0df85ada36b05d554a3a5a3fd5ad48492ae55b651c1684d796e model.onnx.data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
cdd5029c67a427156a92938f8389482e597324f05ff1b08b364e473b9e75da11 model.onnx
|
| 2 |
172b0b42e7cca0df85ada36b05d554a3a5a3fd5ad48492ae55b651c1684d796e model.onnx.data
|
| 3 |
+
e5061a07964a9eb4ce3744b66781ceecae0fd8a18f75a8de87836a0be1ba75d5 onnx/model_q4f16.onnx
|
| 4 |
+
6b507c4b84ee133d5dedf4ad2fda48119628d8637f0e502adf7182b9d9f72c3d onnx/model_q4f16.onnx_data
|
| 5 |
+
de1da14397accd5b2470a0877fd4c4f4a703131feb1267e5686ff8091a8030c6 onnx/model_q4f16.onnx_data_1
|
| 6 |
+
edba67f32660ad177bfad6dc7f42bef0e5606cef96bfa51040aad550d2a24eb9 onnx/model_q4f16.onnx_data_2
|
config.json
CHANGED
|
@@ -1 +1,126 @@
|
|
| 1 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen3_5ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_dropout": 0.0,
|
| 6 |
+
"embedding_dropout": 0.0,
|
| 7 |
+
"eos_token_id": 156895,
|
| 8 |
+
"expert_swiglu_limit_list": null,
|
| 9 |
+
"first_k_dense_replace": 1,
|
| 10 |
+
"gated_attention_proj_granularity_type": "head_wise",
|
| 11 |
+
"group_norm_size": 1,
|
| 12 |
+
"head_dim": 192,
|
| 13 |
+
"hidden_act": "silu",
|
| 14 |
+
"hidden_size": 1536,
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"intermediate_size": 4608,
|
| 17 |
+
"kda_lower_bound": -5,
|
| 18 |
+
"kda_safe_gate": true,
|
| 19 |
+
"kv_lora_rank": 512,
|
| 20 |
+
"layer_group_size": 4,
|
| 21 |
+
"linear_silu": true,
|
| 22 |
+
"max_position_embeddings": 131072,
|
| 23 |
+
"max_window_layers": 20,
|
| 24 |
+
"moe_intermediate_size": 512,
|
| 25 |
+
"moe_router_enable_expert_bias": true,
|
| 26 |
+
"moe_shared_expert_intermediate_size": 512,
|
| 27 |
+
"mtp_loss_scaling_factor": 0,
|
| 28 |
+
"mtp_use_kda": false,
|
| 29 |
+
"n_group": 8,
|
| 30 |
+
"no_kda_lora": true,
|
| 31 |
+
"norm_topk_prob": true,
|
| 32 |
+
"num_attention_heads": 16,
|
| 33 |
+
"num_experts": 128,
|
| 34 |
+
"num_experts_per_tok": 8,
|
| 35 |
+
"num_hidden_layers": 24,
|
| 36 |
+
"num_key_value_heads": 16,
|
| 37 |
+
"num_kv_heads_for_linear_attn": 0,
|
| 38 |
+
"num_nextn_predict_layers": 0,
|
| 39 |
+
"num_shared_experts": 1,
|
| 40 |
+
"output_dropout": 0.0,
|
| 41 |
+
"output_router_logits": false,
|
| 42 |
+
"pad_token_id": 156892,
|
| 43 |
+
"partial_rotary_factor": 0.3333333333333333,
|
| 44 |
+
"q_lora_rank": 256,
|
| 45 |
+
"qk_head_dim": 192,
|
| 46 |
+
"qk_nope_head_dim": 128,
|
| 47 |
+
"qk_rope_head_dim": 64,
|
| 48 |
+
"rms_norm_eps": 1e-06,
|
| 49 |
+
"rope_interleave": true,
|
| 50 |
+
"rope_scaling": null,
|
| 51 |
+
"rope_theta": 6000000,
|
| 52 |
+
"rotary_dim": 64,
|
| 53 |
+
"routed_scaling_factor": 2.5,
|
| 54 |
+
"router_dtype": "fp32",
|
| 55 |
+
"scale_router_input": false,
|
| 56 |
+
"score_function": "sigmoid",
|
| 57 |
+
"scoring_func": "sigmoid",
|
| 58 |
+
"seq_aux": true,
|
| 59 |
+
"share_expert_swiglu_limit_list": null,
|
| 60 |
+
"short_conv_kernel_size": 4,
|
| 61 |
+
"tie_word_embeddings": false,
|
| 62 |
+
"topk_group": 4,
|
| 63 |
+
"topk_method": "noaux_tc",
|
| 64 |
+
"transformers_version": "4.45.0",
|
| 65 |
+
"up_proj_norm": false,
|
| 66 |
+
"use_bias": false,
|
| 67 |
+
"use_cache": true,
|
| 68 |
+
"use_kda_lora": false,
|
| 69 |
+
"use_mla_nope": false,
|
| 70 |
+
"use_nGPT": false,
|
| 71 |
+
"use_qk_norm": true,
|
| 72 |
+
"use_qkv_bias": false,
|
| 73 |
+
"v_head_dim": 128,
|
| 74 |
+
"value_norm": false,
|
| 75 |
+
"vocab_size": 157184,
|
| 76 |
+
"model_type": "qwen3_5_text",
|
| 77 |
+
"torch_dtype": "bfloat16",
|
| 78 |
+
"dtype": "float16",
|
| 79 |
+
"full_attention_interval": 4,
|
| 80 |
+
"layer_types": [
|
| 81 |
+
"linear_attention",
|
| 82 |
+
"linear_attention",
|
| 83 |
+
"linear_attention",
|
| 84 |
+
"full_attention",
|
| 85 |
+
"linear_attention",
|
| 86 |
+
"linear_attention",
|
| 87 |
+
"linear_attention",
|
| 88 |
+
"full_attention",
|
| 89 |
+
"linear_attention",
|
| 90 |
+
"linear_attention",
|
| 91 |
+
"linear_attention",
|
| 92 |
+
"full_attention",
|
| 93 |
+
"linear_attention",
|
| 94 |
+
"linear_attention",
|
| 95 |
+
"linear_attention",
|
| 96 |
+
"full_attention",
|
| 97 |
+
"linear_attention",
|
| 98 |
+
"linear_attention",
|
| 99 |
+
"linear_attention",
|
| 100 |
+
"full_attention",
|
| 101 |
+
"linear_attention",
|
| 102 |
+
"linear_attention",
|
| 103 |
+
"linear_attention",
|
| 104 |
+
"full_attention"
|
| 105 |
+
],
|
| 106 |
+
"linear_conv_kernel_dim": 4,
|
| 107 |
+
"linear_key_head_dim": 128,
|
| 108 |
+
"linear_value_head_dim": 128,
|
| 109 |
+
"linear_num_key_heads": 16,
|
| 110 |
+
"linear_num_value_heads": 16,
|
| 111 |
+
"mamba_ssm_dtype": "float16",
|
| 112 |
+
"rope_parameters": {
|
| 113 |
+
"mrope_interleaved": true,
|
| 114 |
+
"partial_rotary_factor": 0.3333333333333333,
|
| 115 |
+
"rope_theta": 6000000,
|
| 116 |
+
"rope_type": "default"
|
| 117 |
+
},
|
| 118 |
+
"transformers.js_config": {
|
| 119 |
+
"use_external_data_format": {
|
| 120 |
+
"model_q4f16.onnx": 3
|
| 121 |
+
},
|
| 122 |
+
"kv_cache_dtype": {
|
| 123 |
+
"q4f16": "float16"
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
}
|
config_bailing_original.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"BailingMoeV3ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_dropout": 0.0,
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "configuration_bailing_moe_v3.BailingMoeV3Config",
|
| 8 |
+
"AutoModel": "modeling_bailing_moe_v3.BailingMoeV3Model",
|
| 9 |
+
"AutoModelForCausalLM": "modeling_bailing_moe_v3.BailingMoeV3ForCausalLM"
|
| 10 |
+
},
|
| 11 |
+
"embedding_dropout": 0.0,
|
| 12 |
+
"eos_token_id": 156895,
|
| 13 |
+
"expert_swiglu_limit_list": null,
|
| 14 |
+
"first_k_dense_replace": 1,
|
| 15 |
+
"gated_attention_proj_granularity_type": "head_wise",
|
| 16 |
+
"group_norm_size": 1,
|
| 17 |
+
"head_dim": 128,
|
| 18 |
+
"hidden_act": "silu",
|
| 19 |
+
"hidden_size": 1536,
|
| 20 |
+
"initializer_range": 0.02,
|
| 21 |
+
"intermediate_size": 4608,
|
| 22 |
+
"kda_lower_bound": -5,
|
| 23 |
+
"kda_safe_gate": true,
|
| 24 |
+
"kv_lora_rank": 512,
|
| 25 |
+
"layer_group_size": 4,
|
| 26 |
+
"linear_silu": true,
|
| 27 |
+
"max_position_embeddings": 131072,
|
| 28 |
+
"max_window_layers": 20,
|
| 29 |
+
"moe_intermediate_size": 512,
|
| 30 |
+
"moe_router_enable_expert_bias": true,
|
| 31 |
+
"moe_shared_expert_intermediate_size": 512,
|
| 32 |
+
"mtp_loss_scaling_factor": 0,
|
| 33 |
+
"mtp_use_kda": false,
|
| 34 |
+
"n_group": 8,
|
| 35 |
+
"no_kda_lora": true,
|
| 36 |
+
"norm_topk_prob": true,
|
| 37 |
+
"num_attention_heads": 16,
|
| 38 |
+
"num_experts": 128,
|
| 39 |
+
"num_experts_per_tok": 8,
|
| 40 |
+
"num_hidden_layers": 24,
|
| 41 |
+
"num_key_value_heads": 16,
|
| 42 |
+
"num_kv_heads_for_linear_attn": 0,
|
| 43 |
+
"num_nextn_predict_layers": 0,
|
| 44 |
+
"num_shared_experts": 1,
|
| 45 |
+
"output_dropout": 0.0,
|
| 46 |
+
"output_router_logits": false,
|
| 47 |
+
"pad_token_id": 156892,
|
| 48 |
+
"partial_rotary_factor": 0.5,
|
| 49 |
+
"q_lora_rank": 256,
|
| 50 |
+
"qk_head_dim": 192,
|
| 51 |
+
"qk_nope_head_dim": 128,
|
| 52 |
+
"qk_rope_head_dim": 64,
|
| 53 |
+
"rms_norm_eps": 1e-06,
|
| 54 |
+
"rope_interleave": true,
|
| 55 |
+
"rope_scaling": null,
|
| 56 |
+
"rope_theta": 6000000,
|
| 57 |
+
"rotary_dim": 64,
|
| 58 |
+
"routed_scaling_factor": 2.5,
|
| 59 |
+
"router_dtype": "fp32",
|
| 60 |
+
"scale_router_input": false,
|
| 61 |
+
"score_function": "sigmoid",
|
| 62 |
+
"scoring_func": "sigmoid",
|
| 63 |
+
"seq_aux": true,
|
| 64 |
+
"share_expert_swiglu_limit_list": null,
|
| 65 |
+
"short_conv_kernel_size": 4,
|
| 66 |
+
"tie_word_embeddings": false,
|
| 67 |
+
"topk_group": 4,
|
| 68 |
+
"topk_method": "noaux_tc",
|
| 69 |
+
"transformers_version": "4.45.0",
|
| 70 |
+
"up_proj_norm": false,
|
| 71 |
+
"use_bias": false,
|
| 72 |
+
"use_cache": true,
|
| 73 |
+
"use_kda_lora": false,
|
| 74 |
+
"use_mla_nope": false,
|
| 75 |
+
"use_nGPT": false,
|
| 76 |
+
"use_qk_norm": true,
|
| 77 |
+
"use_qkv_bias": false,
|
| 78 |
+
"v_head_dim": 128,
|
| 79 |
+
"value_norm": false,
|
| 80 |
+
"vocab_size": 157184,
|
| 81 |
+
"model_type": "bailing_hybrid",
|
| 82 |
+
"torch_dtype": "bfloat16"
|
| 83 |
+
}
|
onnx/model_q4f16.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e5061a07964a9eb4ce3744b66781ceecae0fd8a18f75a8de87836a0be1ba75d5
|
| 3 |
+
size 811364
|
onnx/model_q4f16.onnx_data
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6b507c4b84ee133d5dedf4ad2fda48119628d8637f0e502adf7182b9d9f72c3d
|
| 3 |
+
size 1984862080
|
onnx/model_q4f16.onnx_data_1
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:de1da14397accd5b2470a0877fd4c4f4a703131feb1267e5686ff8091a8030c6
|
| 3 |
+
size 1943274240
|
onnx/model_q4f16.onnx_data_2
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:edba67f32660ad177bfad6dc7f42bef0e5606cef96bfa51040aad550d2a24eb9
|
| 3 |
+
size 907613952
|
tokenizer_config.json
CHANGED
|
@@ -2110,5 +2110,6 @@
|
|
| 2110 |
"model_max_length": 131072,
|
| 2111 |
"pad_token": "<|endoftext|>",
|
| 2112 |
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 2113 |
-
"trust_remote_code": true
|
|
|
|
| 2114 |
}
|
|
|
|
| 2110 |
"model_max_length": 131072,
|
| 2111 |
"pad_token": "<|endoftext|>",
|
| 2112 |
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 2113 |
+
"trust_remote_code": true,
|
| 2114 |
+
"chat_template": "{#- Bailing V3 chat template -#}\n{#- Supports: thinking option, tool calling -#}\n\n{#- ==================== thinking option normalization ==================== -#}\n{%- if enable_thinking is defined %}\n{%- if enable_thinking %}\n{%- set thinking_option = 'on' %}\n{%- else %}\n{%- set thinking_option = 'off' %}\n{%- endif %}\n{%- elif thinking_option is not defined %}\n{%- set thinking_option = 'on' %}\n{%- endif %}\n\n{#- ==================== preserved thinking ==================== -#}\n{% set preserved_thinking = true %}\n\n{#- ==================== system message ==================== -#}\n{{- '<role>SYSTEM</role>' }}\n{%- if tools %}\n {%- if messages[0].role == 'system' %}\n {{- messages[0].content + '\\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\\nIf none of the functions can be used, point it out. If the given question lacks the parameters required by the function, also point it out.\\nIf you need to use a function, for each function call, output the function name and arguments within the following XML format:\\n<tool_call>{function-name}\\n<arg_key>{arg-key-1}</arg_key>\\n<arg_value>{arg-value-1}</arg_value>\\n<arg_key>{arg-key-2}</arg_key>\\n<arg_value>{arg-value-2}</arg_value>\\n...\\n</tool_call>\\n\" }}\n {%- if messages[0].role == 'system' and messages[0].content is string and ('detailed thinking on' in messages[0].content or 'detailed thinking off' in messages[0].content) %}\n {{- '<|role_end|>' }}\n {%- else %}\n {{- 'detailed thinking ' + thinking_option + '<|role_end|>' }}\n {%- endif %}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {%- if 'detailed thinking on' in messages[0].content or 'detailed thinking off' in messages[0].content %}\n {{- messages[0].content + '<|role_end|>' }}\n {%- else %}\n {{- messages[0].content + '\\n' }}\n {{- 'detailed thinking ' + thinking_option + '<|role_end|>' }}\n {%- endif %}\n {% else %}\n {{- 'detailed thinking ' + thinking_option + '<|role_end|>' }}\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 message.content is string 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.content is string %}\n {%- set content = message.content %}\n {%- else %}\n {%- set content = '' %}\n {%- endif %}\n {%- if message.role == \"user\" %}\n {{- '<role>HUMAN</role>' + message.content + '<|role_end|>' }}\n {%- elif message.role == \"system\" and not loop.first %}\n {{- '<role>SYSTEM</role>' + message.content + '<|role_end|>' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string and message.reasoning_content != '' %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- if '</think>' in content %}\n {%- set reasoning_content = content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- if preserved_thinking or loop.index0 > ns.last_query_index %}\n {%- if reasoning_content != '' %}\n {{- '<role>ASSISTANT</role>' + '\\n<think>' + reasoning_content.strip('\\n') + '</think>' + content.lstrip('\\n') }}\n {%- else %}\n {{- '<role>ASSISTANT</role>\\n<think></think>' + content }}\n {%- endif %}\n {%- else %}\n {{- '<role>ASSISTANT</role>\\n<think></think>' + 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 {%- set tc = tool_call %}\n {%- if tool_call.function %}\n {%- set tc = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>' + tc.name }}\n {% set _args = tc.arguments %}\n {%- for k, v in _args.items() %}\n {{- '<arg_key>' + k + '</arg_key>' }}\n {{- '\\n<arg_value>' }}\n {%- if v is string %}\n {{- v }}\n {%- else %}\n {{- v | tojson(ensure_ascii=False) }}\n {%- endif %}\n {{- '</arg_value>' }}\n {%- endfor %}\n {{- '\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|role_end|>' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<role>OBSERVATION</role>' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|role_end|>' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n\n{#- ==================== generation prompt ==================== -#}\n{%- if add_generation_prompt %}\n {{- '<role>ASSISTANT</role>' }}\n {%- if thinking_option == 'on' %}\n {{- '\\n<think>' }}\n {%- elif thinking_option == 'off' %}\n {{- '\\n<think></think>' }}\n {%- endif %}\n{%- endif %}"
|
| 2115 |
}
|