detal65 schmidt-sebastian commited on
Commit
a304731
·
0 Parent(s):

Duplicate from litert-community/Qwen2.5-1.5B-Instruct

Browse files

Co-authored-by: Sebastian Schmidt <schmidt-sebastian@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
+ Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv1280.task filter=lfs diff=lfs merge=lfs -text
37
+ Qwen2.5-1.5B-Instruct_multi-prefill-seq_f32_ekv1280.task filter=lfs diff=lfs merge=lfs -text
38
+ Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv4096.task filter=lfs diff=lfs merge=lfs -text
39
+ Qwen2.5-1.5B-Instruct_seq128_q8_ekv4096.task filter=lfs diff=lfs merge=lfs -text
40
+ Qwen2.5-1.5B-Instruct_seq128_q8_ekv1280.task filter=lfs diff=lfs merge=lfs -text
41
+ Qwen2.5-1.5B-Instruct_multi-prefill-seq_f32_ekv4096.task filter=lfs diff=lfs merge=lfs -text
42
+ Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv4096.litertlm filter=lfs diff=lfs merge=lfs -text
43
+ Qwen2.5-1.5B-Instruct_multi-prefill-seq_f32_ekv4096.litertlm filter=lfs diff=lfs merge=lfs -text
Qwen2.5-1.5B-Instruct_multi-prefill-seq_f32_ekv1280.task ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:edec401a8dd8de5409a5a1618e73ade59385d7a275b383b5c664e99882949c6d
3
+ size 6181747452
Qwen2.5-1.5B-Instruct_multi-prefill-seq_f32_ekv1280.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ab9a3ba9e6257e5f5db44dc649411ecdfa3ce94434dedddb936e7d4b76c735c
3
+ size 6188010576
Qwen2.5-1.5B-Instruct_multi-prefill-seq_f32_ekv4096.litertlm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:708483abb477c10dd8db8cc6b4995bbd9cd2deda5539249a37c218028a669391
3
+ size 6182436864
Qwen2.5-1.5B-Instruct_multi-prefill-seq_f32_ekv4096.task ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:addf45e6d75f60c9cd34bdf42d84f896f5b7b4faba6ee9f631bf6139de6af087
3
+ size 6182391796
Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv1280.task ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d867a7c93a6acf2892f08e0174e2f6f351ad256b7e3cfb6d6cd9c89794b42e0
3
+ size 1597913616
Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv1280.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12068a341b293a7b51c05f79b23f00d29de1440812c8a194c6a4abf76a0acad7
3
+ size 1622844504
Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv4096.litertlm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4a9b7289365ab80fe599b844b77ad253eb3c53fb0e5d963d699146a6f01255e
3
+ size 1597922856
Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv4096.task ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82968d0a6c3872cf016fdbcfc591571605f4c7fd2b0f64d2533df502cc6596b3
3
+ size 1598556720
Qwen2.5-1.5B-Instruct_seq128_f32_ekv1280.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:68298400b7553acef3e5c0141d11e87e5a6039ded1c64824700714d56712e7fe
3
+ size 6183266448
Qwen2.5-1.5B-Instruct_seq128_q8_ekv1280.task ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8771564e61c908c2199bcaa28b0ff9c5f55afb2ae73fbe263142a067113968df
3
+ size 1567364648
Qwen2.5-1.5B-Instruct_seq128_q8_ekv1280.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2da4ae4e7ba1c4aebf0aec4a079a7889efa9eb059ed552e78e4c12573a62ebe2
3
+ size 1571458816
Qwen2.5-1.5B-Instruct_seq128_q8_ekv4096.task ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98c289e1c43cc592ac535594d5de4bdde449e8dc012ac66909064b6880f8b717
3
+ size 1567364648
README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-1.5B-Instruct
4
+ pipeline_tag: text-generation
5
+ library_name: litert-lm
6
+ tags:
7
+ - chat
8
+ ---
9
+
10
+ # litert-community/Qwen2.5-1.5B-Instruct
11
+
12
+ This model provides a few variants of
13
+ [Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) that are ready for
14
+ deployment on Android using the
15
+ [LiteRT (fka TFLite) stack](https://ai.google.dev/edge/litert),
16
+ [MediaPipe LLM Inference API](https://ai.google.dev/edge/mediapipe/solutions/genai/llm_inference) (in maintenance-only mode) and
17
+ [LiteRT-LM](https://github.com/google-ai-edge/LiteRT-LM).
18
+
19
+ ## Use the models
20
+
21
+ ### Colab
22
+
23
+ *Disclaimer: The target deployment surface for the LiteRT models is
24
+ Android/iOS/Web and the stack has been optimized for performance on these
25
+ targets. Trying out the system in Colab is an easier way to familiarize yourself
26
+ with the LiteRT stack, with the caveat that the performance (memory and latency)
27
+ on Colab could be much worse than on a local device.*
28
+
29
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/#fileId=https://huggingface.co/litert-community/Qwen2.5-1.5B-Instruct/blob/main/notebook.ipynb)
30
+
31
+ ### Android
32
+
33
+ #### Edge Gallery App
34
+ * Download or build the [app](https://github.com/google-ai-edge/gallery?tab=readme-ov-file#-get-started-in-minutes) from GitHub.
35
+
36
+ * Install the [app](https://play.google.com/store/apps/details?id=com.google.ai.edge.gallery&pli=1) from Google Play.
37
+
38
+ * Follow the instructions in the app.
39
+
40
+ #### LiteRT-LM in your own app
41
+
42
+ Add `com.google.ai.edge.litertlm:litertlm-android` to your app as shown in the
43
+ [LiteRT-LM Kotlin guide](https://ai.google.dev/edge/litert-lm/android), and load
44
+ `Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv4096.litertlm` from this repository.
45
+ This file needs LiteRT-LM 0.18.0 or newer.
46
+
47
+ ### iOS
48
+
49
+ * See the [LLM Inference guide for iOS](https://ai.google.dev/edge/mediapipe/solutions/genai/llm_inference/ios)
50
+ (MediaPipe, in maintenance-only mode). The iOS sample app this section
51
+ linked was removed from mediapipe-samples.
52
+
53
+ For sample apps, see [google-ai-edge/litert-samples](https://github.com/google-ai-edge/litert-samples).
54
+
55
+ ## Performance
56
+
57
+ ### Android
58
+
59
+ Note that all benchmark stats are from a Samsung S25 Ultra and multiple prefill signatures enabled.
60
+
61
+ <table border="1">
62
+ <tr>
63
+ <th style="text-align: left">Backend</th>
64
+ <th style="text-align: left">Quantization scheme</th>
65
+ <th style="text-align: left">Context length</th>
66
+ <th style="text-align: left">Prefill (tokens/sec)</th>
67
+ <th style="text-align: left">Decode (tokens/sec)</th>
68
+ <th style="text-align: left">Time-to-first-token (sec)</th>
69
+ <th style="text-align: left">Model size (MB)</th>
70
+ <th style="text-align: left">Peak RSS Memory (MB)</th>
71
+ <th style="text-align: left">GPU Memory (RSS in MB)</th>
72
+ <th></th>
73
+ </tr>
74
+ <tr>
75
+ <td><p style="text-align: left">CPU</p></td>
76
+ <td><p style="text-align: left">fp32 (baseline)</p></td>
77
+ <td><p style="text-align: right">1280</p></td>
78
+ <td><p style="text-align: right">49.50</p></td>
79
+ <td><p style="text-align: right">10 tk/s</p></td>
80
+ <td><p style="text-align: right">21.25 s</p></td>
81
+ <td><p style="text-align: right">6182 MB</p></td>
82
+ <td><p style="text-align: right">6254 MB</p></td>
83
+ <td><p style="text-align: right">N/A</p></td>
84
+ <td><p style="text-align: left"><a style="text-decoration: none" href="https://huggingface.co/litert-community/Qwen2.5-1.5B-Instruct/resolve/main/Qwen2.5-1.5B-Instruct_multi-prefill-seq_f32_ekv1280.task">&#128279;</a></p></td>
85
+ </tr>
86
+ <tr>
87
+ <td><p style="text-align: left">CPU</p></td>
88
+ <td><p style="text-align: left">dynamic_int8</p></td>
89
+ <td><p style="text-align: right">1280</p></td>
90
+ <td><p style="text-align: right">297.58</p></td>
91
+ <td><p style="text-align: right">34.25 tk/s</p></td>
92
+ <td><p style="text-align: right">3.71 s</p></td>
93
+ <td><p style="text-align: right">1598 MB</p></td>
94
+ <td><p style="text-align: right">1997 MB</p></td>
95
+ <td><p style="text-align: right">N/A</p></td>
96
+ <td><p style="text-align: left"><a style="text-decoration: none" href="https://huggingface.co/litert-community/Qwen2.5-1.5B-Instruct/resolve/main/Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv1280.task">&#128279;</a></p></td>
97
+ </tr>
98
+ <tr>
99
+ <td><p style="text-align: left">CPU</p></td>
100
+ <td><p style="text-align: left">dynamic_int8</p></td>
101
+ <td><p style="text-align: right">4096</p></td>
102
+ <td><p style="text-align: right">162.72 tk/s</p></td>
103
+ <td><p style="text-align: right">26.06 tk/s</p></td>
104
+ <td><p style="text-align: right">6.57 s</p></td>
105
+ <td><p style="text-align: right">1598 MB</p></td>
106
+ <td><p style="text-align: right">2216 MB</p></td>
107
+ <td><p style="text-align: right">N/A</p></td>
108
+ <td><p style="text-align: left"><a style="text-decoration: none" href="https://huggingface.co/litert-community/Qwen2.5-1.5B-Instruct/resolve/main/Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv4096.task">&#128279;</a></p></td>
109
+ </tr>
110
+ <tr>
111
+ <td><p style="text-align: left">GPU</p></td>
112
+ <td><p style="text-align: left">dynamic_int8</p></td>
113
+ <td><p style="text-align: right">1280</p></td>
114
+ <td><p style="text-align: right">1667.75 tk/s</p></td>
115
+ <td><p style="text-align: right">30.88 tk/s</p></td>
116
+ <td><p style="text-align: right">3.63 s</p></td>
117
+ <td><p style="text-align: right">1598 MB</p></td>
118
+ <td><p style="text-align: right">1846 MB</p></td>
119
+ <td><p style="text-align: right">1505 MB</p></td>
120
+ <td><p style="text-align: left"><a style="text-decoration: none" href="https://huggingface.co/litert-community/Qwen2.5-1.5B-Instruct/resolve/main/Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv1280.task">&#128279;</a></p></td>
121
+ </tr>
122
+ <tr>
123
+ <td><p style="text-align: left">GPU</p></td>
124
+ <td><p style="text-align: left">dynamic_int8</p></td>
125
+ <td><p style="text-align: right">4096</p></td>
126
+ <td><p style="text-align: right">933.45 tk/s</p></td>
127
+ <td><p style="text-align: right">27.30 tk/s</p></td>
128
+ <td><p style="text-align: right">4.77 s</p></td>
129
+ <td><p style="text-align: right">1598 MB</p></td>
130
+ <td><p style="text-align: right">1869 MB</p></td>
131
+ <td><p style="text-align: right">1505 MB</p></td>
132
+ <td><p style="text-align: left"><a style="text-decoration: none" href="https://huggingface.co/litert-community/Qwen2.5-1.5B-Instruct/resolve/main/Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv4096.task">&#128279;</a></p></td>
133
+ </tr>
134
+
135
+ </table>
136
+
137
+ * For the list of supported quantization schemes see [supported-schemes](https://github.com/google-ai-edge/ai-edge-torch/tree/main/ai_edge_torch/generative/quantize#supported-schemes).
138
+ For these models, we are using prefill signature lengths of 32, 128, 512 and 1280.
139
+ * Model Size: measured by the size of the .tflite flatbuffer (serialization
140
+ format for LiteRT models)
141
+ * Memory: indicator of peak RAM usage
142
+ * The inference on CPU is accelerated via the LiteRT
143
+ [XNNPACK](https://github.com/google/XNNPACK) delegate with 4 threads
144
+ * Benchmark is run with cache enabled and initialized. During the first run,
145
+ the time to first token may differ.
146
+
147
+
148
+ ## Known runtime issues
149
+
150
+ From a conversation preface (the system message, initial messages, tools and extra context a conversation is created with) that has tools and no messages, LiteRT-LM renders the `Qwen2.5-1.5B-Instruct_multi-prefill-seq_q8_ekv4096.litertlm` file's chat template with an empty message list, and the template reads `messages[0]` without checking that the list is non-empty, so the render fails with `Failed to apply template: undefined value`. This happens in two places: when the preface is prefilled at creation (`prefillPrefaceOnInit = true` in Kotlin, `prefillPrefaceOnInit: true` on the web, `SetPrefillPrefaceOnInit(true)` in C++; the default is false), where creating the conversation fails with that error, and in the preface render (`renderPrefaceIntoString()` in Kotlin and Swift, `RenderPrefaceIntoString()` in C++, `litert_lm_conversation_render_preface_to_string` in the C API). The same happens with extra context (such as `enable_thinking`) and no messages, and in the preface render with an empty preface (run in the runtime on one Qwen3 template; the other templates rendered with minijinja 2.14 and jinja2). Read in the source of LiteRT-LM 0.17.0, 0.18.1 and main; measured with LiteRT-LM 0.18.1 (the litert-lm package from PyPI) through its C API on this file's template text. The default path, where the first message is rendered together with the preface, is not affected: the Python API and the CLI of 0.18.1 expose neither the flag nor the preface render, and Google AI Edge Gallery sets neither (its source as read on 2026-10-25). A system message or any initial message in the conversation config avoids it. `Qwen2.5-1.5B-Instruct_multi-prefill-seq_f32_ekv4096.litertlm` carries no Jinja chat template and is not affected: the template the runtime builds for it only loops over the messages.
notebook.ipynb ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": []
7
+ },
8
+ "kernelspec": {
9
+ "name": "python3",
10
+ "display_name": "Python 3"
11
+ },
12
+ "language_info": {
13
+ "name": "python"
14
+ }
15
+ },
16
+ "cells": [
17
+ {
18
+ "cell_type": "markdown",
19
+ "source": [
20
+ "# Install Dependencies"
21
+ ],
22
+ "metadata": {
23
+ "id": "39AMoCOa1ckc"
24
+ }
25
+ },
26
+ {
27
+ "metadata": {
28
+ "id": "VoHxuLPu7s37"
29
+ },
30
+ "cell_type": "code",
31
+ "source": [
32
+ "! wget -q https://github.com/protocolbuffers/protobuf/releases/download/v3.19.0/protoc-3.19.0-linux-x86_64.zip\n",
33
+ "! unzip -o protoc-3.19.0-linux-x86_64.zip -d /usr/local/"
34
+ ],
35
+ "outputs": [],
36
+ "execution_count": null
37
+ },
38
+ {
39
+ "cell_type": "markdown",
40
+ "source": [
41
+ "## Install LiteRT Pipeline"
42
+ ],
43
+ "metadata": {
44
+ "id": "qGAaAKzYK5ei"
45
+ }
46
+ },
47
+ {
48
+ "cell_type": "code",
49
+ "source": [
50
+ "!pip install git+https://github.com/google-ai-edge/ai-edge-apis.git#subdirectory=litert_tools"
51
+ ],
52
+ "metadata": {
53
+ "id": "43tAeO0AZ7zp"
54
+ },
55
+ "execution_count": null,
56
+ "outputs": []
57
+ },
58
+ {
59
+ "cell_type": "markdown",
60
+ "source": [
61
+ "# Create Pipeline from model file"
62
+ ],
63
+ "metadata": {
64
+ "id": "K5okZCTgYpUd"
65
+ }
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "source": [
70
+ "from litert_tools.pipeline import pipeline\n",
71
+ "runner = pipeline.load(\"Qwen2.5-1.5B-Instruct_seq128_q8_ekv1280.task\", repo_id=\"litert-community/Qwen2.5-1.5B-Instruct\")"
72
+ ],
73
+ "metadata": {
74
+ "id": "3t47HAG2tvc3"
75
+ },
76
+ "execution_count": null,
77
+ "outputs": []
78
+ },
79
+ {
80
+ "cell_type": "markdown",
81
+ "source": [
82
+ "# Generate text from model"
83
+ ],
84
+ "metadata": {
85
+ "id": "dASKx_JtYXwe"
86
+ }
87
+ },
88
+ {
89
+ "cell_type": "code",
90
+ "source": [
91
+ "# Disclaimer: Model performance demonstrated with the Python API in this notebook is not representative of performance on a local device.\n",
92
+ "prompt = \"What is the capital of France?\"\n",
93
+ "output = runner.generate(prompt)"
94
+ ],
95
+ "metadata": {
96
+ "id": "wT9BIiATkjzL"
97
+ },
98
+ "execution_count": null,
99
+ "outputs": []
100
+ }
101
+ ]
102
+ }