Add files using upload-large-folder tool
Browse files- .gitattributes +2 -0
- README.md +75 -0
- config.json +10 -0
- config_cpu.json +1 -0
- export_args.json +42 -0
- llm.mnn +3 -0
- llm.mnn.json +0 -0
- llm.mnn.weight +3 -0
- llm_config.json +18 -0
- onnx/llm.onnx +3 -0
- tokenizer.txt +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ 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 |
+
llm.mnn filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
llm.mnn.weight filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- tokforge
|
| 7 |
+
- mnn
|
| 8 |
+
- android
|
| 9 |
+
- mobile
|
| 10 |
+
- speculative-decoding
|
| 11 |
+
- qwen3
|
| 12 |
+
- draft-model
|
| 13 |
+
- text-generation
|
| 14 |
+
pipeline_tag: text-generation
|
| 15 |
+
inference: false
|
| 16 |
+
base_model:
|
| 17 |
+
- Qwen/Qwen3-0.6B
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# Qwen3-0.6B-kl-baseline-20k-MNN
|
| 21 |
+
|
| 22 |
+
Small `Qwen3-0.6B` draft model exported for **TokForge + MNN** speculative decoding on Android.
|
| 23 |
+
|
| 24 |
+
This is a practical, mobile-oriented draft bundle rather than a standard Transformers checkpoint. It is intended to be paired with larger Qwen3 targets inside TokForge.
|
| 25 |
+
|
| 26 |
+
## Why this repo exists
|
| 27 |
+
|
| 28 |
+
This model is one of the strongest lightweight draft candidates we have for mobile speculative decoding:
|
| 29 |
+
|
| 30 |
+
- trained on `20K` teacher samples
|
| 31 |
+
- KL-distilled from a `Qwen3-8B` teacher
|
| 32 |
+
- exported as a ready-to-use `MNN` bundle
|
| 33 |
+
- tuned for the classic `CPU draft + GPU/CPU target` TokForge flow
|
| 34 |
+
|
| 35 |
+
## Best-known use
|
| 36 |
+
|
| 37 |
+
- Draft model backend: `CPU`
|
| 38 |
+
- Draft threads: `2`
|
| 39 |
+
- Draft predict length: `d=3`
|
| 40 |
+
- Typical target pairing: `Qwen3-8B` in TokForge
|
| 41 |
+
|
| 42 |
+
## Benchmark snapshot
|
| 43 |
+
|
| 44 |
+
On RedMagic SM8850 with `Qwen3-8B` target:
|
| 45 |
+
|
| 46 |
+
- AR baseline: `13.9 tok/s`
|
| 47 |
+
- This draft model: `18.1 tok/s`
|
| 48 |
+
- Uplift: about `+30%`
|
| 49 |
+
|
| 50 |
+
Training acceptance (`alpha`) at the final logged epoch:
|
| 51 |
+
|
| 52 |
+
- `0.7178`
|
| 53 |
+
|
| 54 |
+
## Included files
|
| 55 |
+
|
| 56 |
+
- `llm.mnn`
|
| 57 |
+
- `llm.mnn.weight`
|
| 58 |
+
- `llm_config.json`
|
| 59 |
+
- `config.json`
|
| 60 |
+
- `config_cpu.json`
|
| 61 |
+
- tokenizer files
|
| 62 |
+
- ONNX export artifact for reference
|
| 63 |
+
|
| 64 |
+
## Notes
|
| 65 |
+
|
| 66 |
+
- This is **not** a drop-in Transformers repo for HF Inference.
|
| 67 |
+
- It is a runtime bundle for **TokForge / MNN**.
|
| 68 |
+
- If you want the safest current mobile draft option, this is one of the best places to start.
|
| 69 |
+
|
| 70 |
+
## TokForge
|
| 71 |
+
|
| 72 |
+
- Website: [tokforge.ai](https://tokforge.ai)
|
| 73 |
+
- Discord: [Join the Discord](https://discord.gg/Acv3CBtfVm)
|
| 74 |
+
|
| 75 |
+
If you benchmark this on your own device, feel free to share results in Discord.
|
config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"llm_model": "llm.mnn",
|
| 3 |
+
"llm_weight": "llm.mnn.weight",
|
| 4 |
+
"backend_type": "cpu",
|
| 5 |
+
"thread_num": 4,
|
| 6 |
+
"precision": "low",
|
| 7 |
+
"memory": "low",
|
| 8 |
+
"sampler_type": "penalty",
|
| 9 |
+
"penalty": 1.1
|
| 10 |
+
}
|
config_cpu.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"max_new_tokens":16,"llm_model":"llm.mnn","llm_weight":"llm.mnn.weight","backend_type":"cpu","thread_num":2,"precision":"low","memory":"low","sampler_type":"greedy"}
|
export_args.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"path": "/root/specdraft-finetune/runs/kl_06b_8b_20k_v1/merged",
|
| 3 |
+
"type": null,
|
| 4 |
+
"tokenizer_path": "/root/specdraft-finetune/runs/kl_06b_8b_20k_v1/merged",
|
| 5 |
+
"eagle_path": null,
|
| 6 |
+
"lora_path": null,
|
| 7 |
+
"gptq_path": null,
|
| 8 |
+
"dst_path": "/root/models/Qwen3-0.6B-kl-baseline-20k-MNN",
|
| 9 |
+
"verbose": false,
|
| 10 |
+
"test": null,
|
| 11 |
+
"export": "mnn",
|
| 12 |
+
"onnx_slim": false,
|
| 13 |
+
"quant_bit": 4,
|
| 14 |
+
"quant_block": 128,
|
| 15 |
+
"visual_quant_bit": null,
|
| 16 |
+
"visual_quant_block": null,
|
| 17 |
+
"lm_quant_bit": 4,
|
| 18 |
+
"lm_quant_block": 128,
|
| 19 |
+
"mnnconvert": "../../../build/MNNConvert",
|
| 20 |
+
"ppl": false,
|
| 21 |
+
"awq": false,
|
| 22 |
+
"hqq": false,
|
| 23 |
+
"omni": false,
|
| 24 |
+
"transformer_fuse": false,
|
| 25 |
+
"group_conv_native": false,
|
| 26 |
+
"smooth": false,
|
| 27 |
+
"sym": false,
|
| 28 |
+
"visual_sym": false,
|
| 29 |
+
"seperate_embed": false,
|
| 30 |
+
"lora_split": false,
|
| 31 |
+
"calib_data": null,
|
| 32 |
+
"act_bit": 16,
|
| 33 |
+
"embed_bit": 16,
|
| 34 |
+
"act_sym": false,
|
| 35 |
+
"quant_config": null,
|
| 36 |
+
"generate_for_npu": false,
|
| 37 |
+
"skip_weight": false,
|
| 38 |
+
"omni_epochs": 20,
|
| 39 |
+
"omni_lr": 0.005,
|
| 40 |
+
"omni_wd": 0.0001,
|
| 41 |
+
"tie_word_embeddings": true
|
| 42 |
+
}
|
llm.mnn
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:60abd21312c88f8d9080422b2c53f0b6e486122d563a9d96694dfa490a7a4dcd
|
| 3 |
+
size 503616
|
llm.mnn.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
llm.mnn.weight
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d738562d4acc3b0d2514c47b333cede62e79abbe490a4d2c07cb3681612415a4
|
| 3 |
+
size 335769842
|
llm_config.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "qwen3",
|
| 3 |
+
"hidden_size": 1024,
|
| 4 |
+
"attention_mask": "float",
|
| 5 |
+
"attention_type": "full",
|
| 6 |
+
"is_mrope": false,
|
| 7 |
+
"jinja": {
|
| 8 |
+
"chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0].role == 'system' %}\n {{- messages[0].content + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0].content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" and 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\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string %}\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 loop.index0 > ns.last_query_index %}\n {%- if loop.last or (not loop.last and reasoning_content) %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content.strip('\\n') + '\\n</think>\\n\\n' + content.lstrip('\\n') }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls %}\n {%- for tool_call in message.tool_calls %}\n {%- if (loop.first and content) or (not loop.first) %}\n {{- '\\n' }}\n {%- endif %}\n {%- if tool_call.function %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {%- if tool_call.arguments is string %}\n {{- tool_call.arguments }}\n {%- else %}\n {{- tool_call.arguments | tojson }}\n {%- endif %}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is false %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- endif %}\n{%- endif %}",
|
| 9 |
+
"eos": "<|im_end|>"
|
| 10 |
+
},
|
| 11 |
+
"tie_embeddings": [
|
| 12 |
+
248254706,
|
| 13 |
+
326045938,
|
| 14 |
+
9723904,
|
| 15 |
+
4,
|
| 16 |
+
128
|
| 17 |
+
]
|
| 18 |
+
}
|
onnx/llm.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4f6a7dd04a510ff7dbd6b99297daeb37e91aa93c6ea54cf17c7424d9a9decd4a
|
| 3 |
+
size 933136
|
tokenizer.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|