darkmaniac7 commited on
Commit
5e95543
·
verified ·
1 Parent(s): 2d83c93

Add MNN Q4 conversion for TokForge mobile inference

Browse files
Files changed (9) hide show
  1. .gitattributes +2 -0
  2. README.md +98 -0
  3. config.json +10 -0
  4. embeddings_bf16.bin +3 -0
  5. export_args.json +42 -0
  6. llm.mnn +3 -0
  7. llm.mnn.weight +3 -0
  8. llm_config.json +12 -0
  9. 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,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ pipeline_tag: text-generation
6
+ base_model: mistralai/Mistral-7B-Instruct-v0.3
7
+ tags:
8
+ - mnn
9
+ - mistral
10
+ - mobile
11
+ - on-device
12
+ - tokforge
13
+ - uncensored
14
+ - abliterated
15
+ ---
16
+
17
+ # Mistral-7B-Instruct-v0.3-MNN
18
+
19
+ Pre-converted [Mistral 7B Instruct v0.3](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3) in MNN format for on-device inference with [TokForge](https://tokforge.ai).
20
+
21
+ > **Original model by [Mistral AI](https://huggingface.co/Mistral AI)** — converted to MNN Q4 for mobile deployment.
22
+
23
+ ## Model Details
24
+
25
+ | | |
26
+ |---|---|
27
+ | **Architecture** | Mistral (sliding window attention, 32 layers, GQA) |
28
+ | **Parameters** | 7B (4-bit quantized) |
29
+ | **Format** | MNN (Alibaba Mobile Neural Network) |
30
+ | **Quantization** | W4A16 (4-bit weights, block size 128) |
31
+ | **Vocab** | 32,768 tokens |
32
+ | **Source** | [mistralai/Mistral-7B-Instruct-v0.3](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3) |
33
+
34
+ ## Description
35
+
36
+ Mistral AI's 7B Instruct v0.3 — the model that started the open-source LLM revolution. Updated to v0.3 with extended vocabulary and function calling support. One of the most popular and battle-tested open models. Excellent balance of quality and speed.
37
+
38
+ ## Files
39
+
40
+ | File | Description |
41
+ |------|-------------|
42
+ | `llm.mnn` | Model computation graph |
43
+ | `llm.mnn.weight` | Quantized weight data (Q4, block=128) |
44
+ | `llm_config.json` | Model config with Jinja chat template |
45
+ | `tokenizer.txt` | Tokenizer vocabulary |
46
+ | `config.json` | MNN runtime config |
47
+
48
+ ## Usage with TokForge
49
+
50
+ This model is optimized for **[TokForge](https://tokforge.ai)** — a free Android app for private, on-device LLM inference.
51
+
52
+ 1. Download [TokForge from the Play Store](https://tokforge.ai)
53
+ 2. Open the app → Models → Download this model
54
+ 3. Start chatting — runs 100% locally, no internet required
55
+
56
+ ### Recommended Settings
57
+
58
+ | Setting | Value |
59
+ |---------|-------|
60
+ | Backend | OpenCL (Qualcomm) / Vulkan (MediaTek) / CPU (fallback) |
61
+ | Precision | Low |
62
+ | Threads | 4 |
63
+ | Thinking | Off (or On for thinking-capable models) |
64
+
65
+
66
+
67
+ ## Performance
68
+
69
+ Actual speed varies by device, thermal state, and generation length. Typical ranges for this model size:
70
+
71
+ | Device | SoC | Backend | tok/s |
72
+ |---|---|---|---|
73
+ | RedMagic 11 Pro | SM8850 | OpenCL | ~15-18 tok/s |
74
+ | Lenovo TB520FU | SM8650 | OpenCL | ~10-12 tok/s |
75
+
76
+ ## Attribution
77
+
78
+ This is an MNN conversion of **[Mistral 7B Instruct v0.3](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3)** by **[Mistral AI](https://huggingface.co/Mistral AI)**. All credit for the model architecture, training, and fine-tuning goes to the original author(s). This conversion only changes the runtime format for mobile deployment.
79
+
80
+ ## Limitations
81
+
82
+ - Intended for TokForge / MNN on-device inference on Android
83
+ - This is a runtime bundle, not a standard Transformers training checkpoint
84
+ - Quantization (Q4) may slightly reduce quality compared to the full-precision original
85
+ - Abliterated/uncensored models have had safety filters removed — **use responsibly**
86
+
87
+ ## Community
88
+
89
+ - **Website:** [tokforge.ai](https://tokforge.ai)
90
+ - **Discord:** [Join our Discord](https://discord.gg/Acv3CBtfVm)
91
+ - **GitHub:** [TokForge on GitHub](https://github.com/darkmaniac7/Elysium)
92
+
93
+ ## Export Details
94
+
95
+ Converted using MNN's `llmexport` pipeline:
96
+ ```bash
97
+ python llmexport.py --path mistralai/Mistral-7B-Instruct-v0.3 --export mnn --quant_bit 4 --quant_block 128
98
+ ```
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
+ }
embeddings_bf16.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f6844d1e657509198ee0e494d9f8e09efc4f55ffcca197a8f54465c6b6405d96
3
+ size 268435456
export_args.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "path": "/root/models/hf_convert_queue/Mistral-7B-Instruct-v0.3",
3
+ "type": null,
4
+ "tokenizer_path": "/root/models/hf_convert_queue/Mistral-7B-Instruct-v0.3",
5
+ "eagle_path": null,
6
+ "lora_path": null,
7
+ "gptq_path": null,
8
+ "dst_path": "/root/models/hf_uploads/Mistral-7B-Instruct-v0.3-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": true,
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": false
42
+ }
llm.mnn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:335a0c12d911731a5a97664b0b0c842ec112ae088b39c44902237f3efccd4734
3
+ size 557656
llm.mnn.weight ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f144b54f32593843aa5e347654afbcff65e97a53be492825d8f80e5ece9c9ee6
3
+ size 4003500886
llm_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "mistral",
3
+ "hidden_size": 4096,
4
+ "attention_mask": "float",
5
+ "attention_type": "full",
6
+ "is_mrope": false,
7
+ "jinja": {
8
+ "chat_template": "{%- if messages[0][\"role\"] == \"system\" %}\n {%- set system_message = messages[0][\"content\"] %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set loop_messages = messages %}\n{%- endif %}\n{%- if not tools is defined %}\n {%- set tools = none %}\n{%- endif %}\n{%- set user_messages = loop_messages | selectattr(\"role\", \"equalto\", \"user\") | list %}\n\n{#- This block checks for alternating user/assistant messages, skipping tool calling messages #}\n{%- set ns = namespace() %}\n{%- set ns.index = 0 %}\n{%- for message in loop_messages %}\n {%- if not (message.role == \"tool\" or message.role == \"tool_results\" or (message.tool_calls is defined and message.tool_calls is not none)) %}\n {%- if (message[\"role\"] == \"user\") != (ns.index % 2 == 0) %}\n {{- raise_exception(\"After the optional system message, conversation roles must alternate user/assistant/user/assistant/...\") }}\n {%- endif %}\n {%- set ns.index = ns.index + 1 %}\n {%- endif %}\n{%- endfor %}\n\n{{- bos_token }}\n{%- for message in loop_messages %}\n {%- if message[\"role\"] == \"user\" %}\n {%- if tools is not none and (message == user_messages[-1]) %}\n {{- \"[AVAILABLE_TOOLS] [\" }}\n {%- for tool in tools %}\n {%- set tool = tool.function %}\n {{- '{\"type\": \"function\", \"function\": {' }}\n {%- for key, val in tool.items() if key != \"return\" %}\n {%- if val is string %}\n {{- '\"' + key + '\": \"' + val + '\"' }}\n {%- else %}\n {{- '\"' + key + '\": ' + val|tojson }}\n {%- endif %}\n {%- if not loop.last %}\n {{- \", \" }}\n {%- endif %}\n {%- endfor %}\n {{- \"}}\" }}\n {%- if not loop.last %}\n {{- \", \" }}\n {%- else %}\n {{- \"]\" }}\n {%- endif %}\n {%- endfor %}\n {{- \"[/AVAILABLE_TOOLS]\" }}\n {%- endif %}\n {%- if loop.last and system_message is defined %}\n {{- \"[INST] \" + system_message + \"\\n\\n\" + message[\"content\"] + \"[/INST]\" }}\n {%- else %}\n {{- \"[INST] \" + message[\"content\"] + \"[/INST]\" }}\n {%- endif %}\n {%- elif message.tool_calls is defined and message.tool_calls is not none %}\n {{- \"[TOOL_CALLS] [\" }}\n {%- for tool_call in message.tool_calls %}\n {%- set out = tool_call.function|tojson %}\n {{- out[:-1] }}\n {%- if not tool_call.id is defined or tool_call.id|length != 9 %}\n {{- raise_exception(\"Tool call IDs should be alphanumeric strings with length 9!\") }}\n {%- endif %}\n {{- ', \"id\": \"' + tool_call.id + '\"}' }}\n {%- if not loop.last %}\n {{- \", \" }}\n {%- else %}\n {{- \"]\" + eos_token }}\n {%- endif %}\n {%- endfor %}\n {%- elif message[\"role\"] == \"assistant\" %}\n {{- \" \" + message[\"content\"]|trim + eos_token}}\n {%- elif message[\"role\"] == \"tool_results\" or message[\"role\"] == \"tool\" %}\n {%- if message.content is defined and message.content.content is defined %}\n {%- set content = message.content.content %}\n {%- else %}\n {%- set content = message.content %}\n {%- endif %}\n {{- '[TOOL_RESULTS] {\"content\": ' + content|string + \", \" }}\n {%- if not message.tool_call_id is defined or message.tool_call_id|length != 9 %}\n {{- raise_exception(\"Tool call IDs should be alphanumeric strings with length 9!\") }}\n {%- endif %}\n {{- '\"call_id\": \"' + message.tool_call_id + '\"}[/TOOL_RESULTS]' }}\n {%- else %}\n {{- raise_exception(\"Only user and assistant roles are supported, with the exception of an initial optional system message!\") }}\n {%- endif %}\n{%- endfor %}\n",
9
+ "bos": "<s>",
10
+ "eos": "</s>"
11
+ }
12
+ }
tokenizer.txt ADDED
The diff for this file is too large to render. See raw diff