Instructions to use litert-community/Qwen3-4B-Thinking-2507 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT-LM
How to use litert-community/Qwen3-4B-Thinking-2507 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=litert-community/Qwen3-4B-Thinking-2507 \ --prompt="Write me a poem"
- LiteRT
How to use litert-community/Qwen3-4B-Thinking-2507 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
Qwen3-4B-Thinking-2507 β LiteRT-LM (blockwise int4)
Qwen/Qwen3-4B-Thinking-2507 converted to
the LiteRT-LM (.litertlm) format for on-device inference with Google's
LiteRT-LM runtime (the engine behind the official
litert-community/* models).
Qwen3-4B-Thinking-2507 is a dense 4B reasoning model (Qwen3ForCausalLM, 36 layers) that
operates exclusively in thinking mode β it emits a <think>β¦</think> chain before its answer β
so it rides the existing Qwen3 converter and runtime directly.
| File | model.litertlm β int4 block 128 (~2.3 GB) |
| Quantization | int4 weights (symmetric) + OCTAV optimal-clipping; embeddings INT8 (externalized section) |
| Compute | integer |
| Context (KV cache) | 4096 |
| Base model | Qwen/Qwen3-4B-Thinking-2507 |
| Decode speed | ~14 tok/s (iPhone 17 Pro, GPU) Β· ~67 tok/s (Mac M-series, GPU) |
β οΈ It's a reasoning model β give it room to think
This model generates a <think>β¦</think> reasoning chain, then the answer. Run it with
max_tokens β₯ 2048 β at a short limit it gets cut off mid-thought and never reaches the answer.
(All quality numbers below were measured at 2048.)
Quality β GSM8K parity
Measured on GSM8K (n=100, greedy, 0-shot chain-of-thought, max_tokens 2048, identical prompt and answer-extraction for every row).
| Configuration | GSM8K |
|---|---|
| bf16 (reference) | 90.0% |
| LiteRT int4 β block 128 | 86.0% (β4 pt) |
int4 is at parity (β4 pt). Note: evaluating a reasoning model at a short token budget badly
understates int4 β the longer int4 reasoning chains get truncated before the answer; benchmark
reasoning models with max_tokens β₯ 2048.
Why block 128 (and not block 32)? For this reasoning model the block-32 build degraded more
(β9 pt) and produced corrupted output under the iPhone GPU delegate, while block 128 is robust
on every backend, ~40 % faster to decode (ΒΌ the dequant scales β which matters when generating
long <think> chains), and stays at β4 pt parity. So only the block-128 build is published.
Usage
# build litert-lm from https://github.com/google-ai-edge/litert-lm, then:
litert_lm_main \
--model_path model.litertlm \
--backend gpu \
--input_prompt "A bat and a ball cost \$1.10. The bat costs \$1.00 more than the ball. How much is the ball?"
The .litertlm bundle carries the tokenizer and prompt template (Qwen3 ChatML β
<|im_start|>role\nβ¦<|im_end|>, stop token <|im_end|>), so no separate tokenizer files are
needed. The model produces a <think>β¦</think> block followed by its answer.
Run on Android
Update (July 2026): Google AI Edge Gallery v1.0.16+ can import litert-lm models directly from Hugging Face inside the app (tap +) β no computer or
adbneeded. The manual steps below are only required on older builds or for sideloading a local file.
The official Google AI Edge Gallery app runs
.litertlm models on-device:
- Install a recent Gallery (package
com.google.ai.edge.gallery, 1.0.15+ supports.litertlm). - Download
model.litertlmand push it:adb push model.litertlm /sdcard/Download/ - In the app tap +, pick the file, choose the GPU backend, and raise the max-tokens setting (β₯2048).
- Chat β the bundle already carries the tokenizer and Qwen3 chat template.
A 4B int4 build needs ~2.5 GB free RAM; reboot the phone first if memory is tight.
Run on desktop (LiteRT-LM CLI)
The same .litertlm bundle runs on macOS / Linux / Windows with the official
LiteRT-LM CLI β including as a
local OpenAI-compatible API server:
pip install litert-lm
litert-lm import --from-huggingface-repo litert-community/Qwen3-4B-Thinking-2507 model.litertlm qwen3-4b-thinking-2507
litert-lm run qwen3-4b-thinking-2507 # interactive chat in the terminal
litert-lm serve # local OpenAI-compatible API server
Run on iPhone
Verified on iPhone 17 Pro (LiteRT-LM Swift runtime): loads and generates at ~14 tok/s.
Conversion
Converted with the official litert-torch
converter β a standard Qwen3ForCausalLM, so it uses the existing Qwen3 path with no custom graph
code. Recipe: blockwise-128 int4 + OCTAV (INT4 weights, block 128, symmetric, OCTAV
optimal-clipping), embeddings INT8, KV cache 4096.
from litert_torch.generative.export_hf.export import export
export(
model="Qwen/Qwen3-4B-Thinking-2507",
output_dir="out",
quantization_recipe="qwen3_int4_block128_octav.json", # blockwise-128 int4 + OCTAV, int8 embeddings
cache_length=4096,
externalize_embedder=True,
)
License
Apache-2.0, inherited from the base model Qwen/Qwen3-4B-Thinking-2507.
- Downloads last month
- 532
Model tree for litert-community/Qwen3-4B-Thinking-2507
Base model
Qwen/Qwen3-4B-Thinking-2507