Instructions to use mlboydaisuke/Qwen2.5-3B-Instruct-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT-LM
How to use mlboydaisuke/Qwen2.5-3B-Instruct-LiteRT with LiteRT-LM:
# LiteRT-LM runs on various platforms (Android, iOS, Windows, Linux, macOS, IoT, Web/WASM) # and supports many APIs (C++, Python, Kotlin, Swift, JavaScript, Flutter). # For platform-specific integration guides, please refer to the official developer website: # https://ai.google.dev/edge/litert-lm # To try LiteRT-LM, the easiest way is to use our CLI tool. # 1. Install the LiteRT-LM CLI tool: pip install -U litert-lm # 2. Download and run this model locally: # See: https://ai.google.dev/edge/litert-lm/cli litert-lm run \ --from-huggingface-repo=mlboydaisuke/Qwen2.5-3B-Instruct-LiteRT \ --prompt="Write me a poem"
- LiteRT
How to use mlboydaisuke/Qwen2.5-3B-Instruct-LiteRT with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: qwen-research
|
| 4 |
+
license_link: LICENSE
|
| 5 |
+
base_model: Qwen/Qwen2.5-3B-Instruct
|
| 6 |
+
tags:
|
| 7 |
+
- litert
|
| 8 |
+
- litert-lm
|
| 9 |
+
- litertlm
|
| 10 |
+
- on-device
|
| 11 |
+
- edge
|
| 12 |
+
- qwen2
|
| 13 |
+
- gptq
|
| 14 |
+
pipeline_tag: text-generation
|
| 15 |
+
library_name: litert-lm
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Qwen2.5-3B-Instruct β LiteRT-LM (GPTQ-calibrated int4, block 128)
|
| 19 |
+
|
| 20 |
+
**Built with Qwen.**
|
| 21 |
+
|
| 22 |
+
[Qwen/Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct) converted to the
|
| 23 |
+
**LiteRT-LM** (`.litertlm`) format for on-device inference with Google's
|
| 24 |
+
[LiteRT-LM](https://github.com/google-ai-edge/litert-lm) runtime (the engine behind the
|
| 25 |
+
`litert-community/*` models).
|
| 26 |
+
|
| 27 |
+
What makes this build different: the int4 weights are **not re-quantized from scratch** β they carry
|
| 28 |
+
**Qwen's official GPTQ calibration**
|
| 29 |
+
([Qwen/Qwen2.5-3B-Instruct-GPTQ-Int4](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct-GPTQ-Int4)),
|
| 30 |
+
transported **losslessly** into the LiteRT bundle via `ai-edge-quantizer`'s
|
| 31 |
+
`dequantized_weight_recovery` (blockwise support, nightly β₯ 0.8.0.dev20260703). You get
|
| 32 |
+
calibrated-int4 quality at block-128 speed, with no calibration step in the conversion.
|
| 33 |
+
|
| 34 |
+
| | |
|
| 35 |
+
|---|---|
|
| 36 |
+
| **File** | `model.litertlm` β int4 **block 128** (~1.75 GB) |
|
| 37 |
+
| **Quantization** | int4 weights (symmetric, blockwise-128) on **Qwen's official GPTQ grid**; embeddings + lm_head INT8 |
|
| 38 |
+
| **Compute** | integer (dynamic int8 activations) |
|
| 39 |
+
| **Context (KV cache)** | 4096 |
|
| 40 |
+
| **Base model** | Qwen/Qwen2.5-3B-Instruct (36 layers, `Qwen2ForCausalLM`) |
|
| 41 |
+
| **Decode speed** | ~74 tok/s (Mac M-series, GPU) |
|
| 42 |
+
|
| 43 |
+
## Quality β GSM8K parity
|
| 44 |
+
|
| 45 |
+
Measured on GSM8K (n=100, greedy, 0-shot chain-of-thought, max_tokens 512, identical prompt and
|
| 46 |
+
answer-extraction for every row).
|
| 47 |
+
|
| 48 |
+
| Configuration | GSM8K |
|
| 49 |
+
|---|---|
|
| 50 |
+
| bf16 (reference) | 81.0% |
|
| 51 |
+
| Qwen official GPTQ-Int4, dequantized in PyTorch (n=50) | 82.0% |
|
| 52 |
+
| **LiteRT int4 β block 128 (this file)** | **75.0%** (β6 pt vs bf16) |
|
| 53 |
+
|
| 54 |
+
The official GPTQ calibration itself is lossless on GSM8K (82.0 vs 81.0 = noise), so the β6 pt is
|
| 55 |
+
the cost of the on-device execution format (integer compute), not of the 4-bit weights. The 8-question
|
| 56 |
+
smoke gate reads **8/8** (arithmetic, factual, translation β all correct, terse clean answers, no
|
| 57 |
+
degeneration).
|
| 58 |
+
|
| 59 |
+
## Usage
|
| 60 |
+
|
| 61 |
+
```bash
|
| 62 |
+
# build litert-lm from https://github.com/google-ai-edge/litert-lm, then:
|
| 63 |
+
litert_lm_main \
|
| 64 |
+
--model_path model.litertlm \
|
| 65 |
+
--backend gpu \
|
| 66 |
+
--input_prompt "Natalia sold clips to 48 friends in April, and half as many in May. How many altogether?"
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
The `.litertlm` bundle carries the tokenizer and prompt template (Qwen2 ChatML β
|
| 70 |
+
`<|im_start|>role\nβ¦<|im_end|>`), so no separate tokenizer files are needed.
|
| 71 |
+
|
| 72 |
+
## Run on Android
|
| 73 |
+
|
| 74 |
+
> **Update (July 2026):** [Google AI Edge Gallery](https://github.com/google-ai-edge/gallery)
|
| 75 |
+
> **v1.0.16+** can import litert-lm models **directly from Hugging Face** inside the app (tap **+**)
|
| 76 |
+
> β no computer or `adb` needed. The manual steps below are only required on older builds or for
|
| 77 |
+
> sideloading a local file.
|
| 78 |
+
|
| 79 |
+
The official **[Google AI Edge Gallery](https://github.com/google-ai-edge/gallery)** app runs
|
| 80 |
+
`.litertlm` models on-device:
|
| 81 |
+
|
| 82 |
+
1. Install a **recent** Gallery (package `com.google.ai.edge.gallery`, 1.0.15+ supports `.litertlm`).
|
| 83 |
+
2. Download `model.litertlm` and push it: `adb push model.litertlm /sdcard/Download/`
|
| 84 |
+
3. In the app tap **+**, pick the file, and choose the **GPU** backend.
|
| 85 |
+
4. Chat β the bundle already carries the tokenizer and Qwen2 chat template.
|
| 86 |
+
|
| 87 |
+
## Conversion β GPTQ grid pass-through
|
| 88 |
+
|
| 89 |
+
Converted with the official [`litert-torch`](https://github.com/google-ai-edge/litert-torch)
|
| 90 |
+
converter. Instead of a data-free int4 recipe, the quantization stage uses
|
| 91 |
+
`ai-edge-quantizer`'s **`dequantized_weight_recovery`** algorithm (blockwise support landed
|
| 92 |
+
2026-06-11, nightly-only at the time of conversion): the official GPTQ checkpoint is dequantized to
|
| 93 |
+
fp32 (exact β fp16 scale Γ int4 is exactly representable in fp32), and recovery re-derives the
|
| 94 |
+
per-block scales bit-exactly, so the deployed int4 grid **is** Qwen's calibrated grid.
|
| 95 |
+
|
| 96 |
+
```json
|
| 97 |
+
[
|
| 98 |
+
{"regex": ".*", "operation": "*",
|
| 99 |
+
"algorithm_key": "dequantized_weight_recovery",
|
| 100 |
+
"op_config": {"weight_tensor_config": {"num_bits": 4, "symmetric": true,
|
| 101 |
+
"granularity": "BLOCKWISE_128", "dtype": "INT"},
|
| 102 |
+
"compute_precision": "INTEGER"}},
|
| 103 |
+
{"regex": ".*", "operation": "EMBEDDING_LOOKUP",
|
| 104 |
+
"algorithm_key": "min_max_uniform_quantize",
|
| 105 |
+
"op_config": {"weight_tensor_config": {"num_bits": 8, "symmetric": true,
|
| 106 |
+
"granularity": "CHANNELWISE", "dtype": "INT"}}},
|
| 107 |
+
{"regex": ".*(logits_output|Linear_lm_head).*", "operation": "FULLY_CONNECTED",
|
| 108 |
+
"algorithm_key": "min_max_uniform_quantize",
|
| 109 |
+
"op_config": {"weight_tensor_config": {"num_bits": 8, "symmetric": true,
|
| 110 |
+
"granularity": "CHANNELWISE", "dtype": "INT"}}}
|
| 111 |
+
]
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
(The embedding / tied lm_head is not GPTQ-quantized upstream, so it goes to INT8. KV cache 4096.)
|
| 115 |
+
|
| 116 |
+
## License
|
| 117 |
+
|
| 118 |
+
**Qwen Research License** (see `LICENSE`), inherited from the base model
|
| 119 |
+
[Qwen/Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct). **Non-commercial
|
| 120 |
+
(research/evaluation) use only** β for commercial use, request a license from Alibaba Cloud.
|
| 121 |
+
|
| 122 |
+
This repository is a **modified distribution** of the Qwen materials: the model weights were
|
| 123 |
+
quantized (official GPTQ int4 grid, transported via `dequantized_weight_recovery`) and repackaged
|
| 124 |
+
into the LiteRT-LM `.litertlm` format as described in the Conversion section above. Attribution
|
| 125 |
+
notice is in `NOTICE`. Built with Qwen.
|