Run this model with HF Jobs
Run litert-community/MNN-Pocket-0.3B-Dec-LiteRT on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/litert-community/MNN-Pocket-0.3B-Dec-LiteRT. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/litert-community/MNN-Pocket-0.3B-Dec-LiteRT on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use litert-community/MNN-Pocket-0.3B-Dec-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/MNN-Pocket-0.3B-Dec-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
MNN-Pocket-0.3B-Dec for LiteRT
This repository is a conversion of taobao-mnn/MNN-Pocket-0.3B-Dec to LiteRT, made with litert-torch 0.10.0 for LiteRT 2.3.0: on a Galaxy S26 NPU in Burst mode, the source model card's example takes a median 11.3 ms (2026-11-07).
taobao-mnn/MNN-Pocket-0.3B-Dec is a decision model built on taobao-mnn/MNN-Pocket-0.3B. It takes a state and typed questions (choice, noul, score) and returns the probability of every candidate in one forward pass. It is not a chat model and never generates text.
Here the LoRA adapter is folded into the weights, and the linear-layer weights are stored as float16. Eight graphs take requests of up to 64, 96, 128, 256, 512, 768, 1,024 and 2,048 tokens. Each graph takes the embeddings of the request's tokens, the rotary tables and the attention mask, and returns the hidden states after the final norm. The same computation also comes in two forms written for an NPU: for the Qualcomm NPU at all eight lengths, and for the Google Tensor NPU at 64 to 256 tokens (see Which file). The Python host in host/ does the rest as the source model's inference.py does: it builds the request, picks the smallest graph that holds it, and reads the answers with the source model's head and temperature.
Run it
With the hf CLI (pip install huggingface_hub) and Python 3.12 to 3.14 (the pinned packages do not install on older versions):
hf download litert-community/MNN-Pocket-0.3B-Dec-LiteRT --local-dir MNN-Pocket-0.3B-Dec-LiteRT --exclude "*_npu*" --exclude "*_tensor*"
cd MNN-Pocket-0.3B-Dec-LiteRT
python3 -m venv .venv
.venv/bin/pip install -r host/requirements.txt
.venv/bin/python examples/run_examples.py --check
The two --exclude patterns skip the NPU files (10.0 GB), which the Python host does not use. The last line runs the three example requests on the CPU and the GPU and compares them with the source model's answers. It was run on a Mac, where the GPU is Metal. To skip the GPU, add --backend cpu.
In your own code, the host takes the request of the source model's predict and returns the same answer shape:
import sys
sys.path.insert(0, "host")
from pocket_dec_litert import PocketDecisionLiteRT
model = PocketDecisionLiteRT.from_pretrained(".", backend="gpu") # or backend="cpu"
result = model.predict(
state=(
"The shoes arrived, but they are the wrong size. "
"I want to send them back for an exchange. "
"Payment and delivery were fine."
),
questions={
"department": {
"type": "choice",
"instructions": "Which team should handle this customer request?",
"criteria": {
"returns": "Returns, exchanges and refunds",
"billing": "Charges, invoices and payment problems",
},
}
},
)
print(result["answers"]["department"])
That request is the source model card's example, 60 tokens. Its probabilities:
| Option | Source model, float32 CPU | This repository, CPU | This repository, Metal at float32 |
|---|---|---|---|
returns |
0.86392 | 0.86379 | 0.86379 |
billing |
0.13608 | 0.13621 | 0.13621 |
A request longer than 2,048 tokens raises ValueError; the host never cuts it. The source model's own limit is 32,768 tokens.
On a GPU, set float32 precision. The host does, with GpuOptions(enforce_f32=True). On Android, set CompiledModel.GpuOptions.Precision.FP32 in Kotlin or kLiteRtDelegatePrecisionFp32 in the C API. An app that sets no precision gets FP16 on both phones: on the 128-token file, all 322 questions had the same probabilities as FP16 to every digit. FP16 changes the answers. On the 128-, 256-, 512-, 1,024- and 2,048-token files (the 768-token file was not run at FP16), among questions whose top two options are more than 0.02 apart, the winner changed on up to 5 of 305 on the Galaxy S26, 1 of 305 on the Pixel 11 Pro and 9 of 2,314 on Apple Metal at its default precision. A probability moved by up to 0.068, 0.029 and 0.058.
Which file
| To run on | Files | |
|---|---|---|
| A CPU or a GPU | mnn-pocket-0.3b-dec_L<n>_fp16w.tflite |
The files the Python host loads |
| The NPU of the Galaxy S26 (Qualcomm SM8850) | mnn-pocket-0.3b-dec_L<n>_fp16w_npu_SM8850.tflite |
Compiled for this chip ahead of time |
| A Qualcomm NPU, compiled on the phone | mnn-pocket-0.3b-dec_L<n>_fp16w_npu.tflite |
LiteRT compiles it on the phone at the first load. Tested here on the SM8850 only |
| The NPU of the Pixel 11 Pro (Google Tensor G6) | mnn-pocket-0.3b-dec_L<n>_fp16w_tensor.tflite |
64 to 256 tokens. LiteRT compiles it on the phone at the first load |
<n> is the longest request the file takes. Pick the smallest file that holds the request.
How close it is to the source model
The reference is the source model's inference.py, unchanged, on its own files: float32, CPU, one thread. The Mac runs used 2,409 questions: 2,000 from the typed-decisions test split, 402 from the requests of litert-community/Kev-0.8B-LiteRT and 7 from the examples here. Each file ran the requests that fit it. The phones ran a fixed subset: 71, 278, 322, 61, 142, 124, 127 and 16 questions on the files from 64 to 2,048 tokens. A near tie is a question whose two most likely options in the reference are 0.02 or less apart.
| Where | Runtime | Files | Same winner, not near ties | Same winner, near ties | Largest |Δp| | Mean |Δp| |
|---|---|---|---|---|---|---|
| Apple M4 Max | CPU, 4 threads | 8 | all | all | 0.0021 | ≤ 1.9e-4 |
| Apple M4 Max | Metal, float32 | 8 | all | all | 0.0021 | ≤ 1.9e-4 |
| Galaxy S26 | CPU | 8 | all | all | 0.0021 | ≤ 1.9e-4 |
| Galaxy S26 | GPU, FP32 | 8 | all | all | 0.0021 | ≤ 1.9e-4 |
| Galaxy S26 | GPU, FP16 with FP32 accumulation | 8 | all | 44 of 54 | 0.0126 | ≤ 0.0018 |
| Galaxy S26 | NPU, the Qualcomm files | 8 | all | 42 of 54 | 0.0190 | ≤ 0.0017 |
| Pixel 11 Pro | CPU | 8 | all | all | 0.0021 | ≤ 1.9e-4 |
| Pixel 11 Pro | GPU, FP32 | 8 | all | all | 0.0021 | ≤ 1.9e-4 |
| Pixel 11 Pro | NPU, the Tensor files | 4 | all | all | 0.0110 | ≤ 0.0017 |
Every row meets the bar set before the runs: the same winner on every question that is not a near tie, a largest difference of at most 0.02 and a mean of at most 0.002. On the Galaxy S26's NPU, from 64 to 1,024 tokens, the files compiled ahead of time and the files compiled on the phone gave the same probabilities to every digit. FP16 with FP32 accumulation on the Pixel 11 Pro misses the mean on 3 of the 6 files it ran. Plain FP16 misses on every file of both phones. All the tables are in REPRODUCE.md.
The forms that are not exact can flip a near tie. In the source model's default example, department is 0.41064 shipping against 0.40709 returns. FP32, the CPU and the Google Tensor NPU answer shipping, as the source model does. FP16 with FP32 accumulation and the Qualcomm NPU answer returns.
Speed
A call writes the inputs, runs the graph and reads the hidden states back. Each number is the median of 20 calls after 5 warm-up calls in one process, except the phones' 1,024-token numbers on the GPU and the Pixel 11 Pro's CPU: those are the median of 8 calls after 2 warm-up calls. Each request ran on the smallest file that holds it. On the Mac, the host's tokenizing, input building and head added 0.16 ms at 60 tokens and 2.7 ms at 1,024 tokens, measured with the 128- and 1,024-token files. The source model's rows are one predict() call, which includes those steps.
| Where | Runtime | 60 tokens (the example above) | 85 tokens (3 questions) | 1,024 tokens |
|---|---|---|---|---|
| Galaxy S26 | NPU, the SM8850 files, Burst | 11.3 ms | 16.0 ms | 203.4 ms |
| Galaxy S26 | GPU, FP16 with FP32 accumulation | 28.2 ms | 43.6 ms | 371.6 ms* |
| Galaxy S26 | GPU, FP32 | 37.6 ms | 48.2 ms | 530.3 ms* |
| Galaxy S26 | CPU, 4 threads | 41.1 ms | 60.9 ms | not listed |
| Pixel 11 Pro | GPU, FP32 | 120.9 ms | 129.1 ms | 1,020.7 ms |
| Pixel 11 Pro | CPU, 6 threads | 128.7 ms | 179.5 ms | 2,871.7 ms* (5 threads) |
| Apple M4 Max | Metal, float32 | 12.6 ms | 13.4 ms | 90.2 ms |
| Apple M4 Max | CPU, 4 threads | 29.7 ms | 41.1 ms | 380.9 ms |
| Apple M4 Max | Source model, PyTorch on the Apple GPU (MPS), float32 | 32.5 ms | 35.2 ms | 110.1 ms |
| Apple M4 Max | Source model, PyTorch on the CPU, 4 threads, float32 | 51.2 ms | 60.1 ms | 445.1 ms |
* The phone capped its clocks in the last seconds of the run. "Not listed" means it capped them from the first seconds of every run of that request. Forms that miss the bar are left out: FP16 on both phones, and FP16 with FP32 accumulation on the Pixel 11 Pro.
Before this update, a request of 513 to 768 tokens ran on the 1,024-token files; it now fits the 768-token files. We timed a 586-token request with 5 questions on both files in the order 1,024, 768, 768, 1,024. The 768-token file took 31 to 32 % less time on the Galaxy S26's NPU (the SM8850 files, Burst: 140.1 ms in the one run without a clock cap; the other three runs show one), 30 to 31 % less on the Pixel 11 Pro's GPU at FP32 (716.4 ms, the median of 8 calls after 2 warm-up calls), 33 % less on Metal at float32 and 42 to 43 % less on the Mac's CPU at 4 threads. The runs are in REPRODUCE.md.
On the Qualcomm NPU, set the HTP performance mode to Burst. Without it, the calls on the Galaxy S26 took 5.5 to 6.7 times as long: 76.3 ms against 11.3 ms for the 60-token example. Our runner set it on the Galaxy S26 through LiteRT's C API, as htp_performance_mode = 2 (kLiteRtQualcommHtpPerformanceModeBurst) in the Qualcomm options. In Kotlin the same option is CompiledModel.QualcommOptions(htpPerformanceMode = CompiledModel.QualcommOptions.HtpPerformanceMode.BURST), set as qualcommOptions of CompiledModel.Options.
On the Galaxy S26, an SM8850 file loads in 0.2 s (64 tokens) to 0.5 s (1,024 tokens) and 1.2 s (2,048 tokens), and the process peaks at 0.55 to 0.70 GB. A file compiled on the phone takes 9 s (64 tokens) to 315 s (1,024 tokens) at its first load and peaks at 2.8 to 5.0 GB. Later loads read the compiled result when the app gives LiteRT a compiler cache directory (kLiteRtEnvOptionTagCompilerCacheDir in the C API's environment options, as our runner did); without one, every load compiles again. The 2,048-token file did not finish compiling on the phone: our memory watch stopped it at 7.0 GB, when the phone's available memory fell below 1.5 GB. Every file ran on the NPU in one partition, with all 2,600 ops. The NPU files write SiLU with EXP in place of LOGISTIC, because the NPU's LOGISTIC returned 0 for inputs below about −5.7 (measured on the same phone with QAIRT 2.47, on another model's graph). Running them also needs LiteRT's Qualcomm NPU runtime (Maven litert-npu-runtime-qualcomm 2.3.0) and Qualcomm's QAIRT 2.50 libraries; the SM8850 files were compiled with QAIRT 2.50.
The Tensor files ran on the Pixel 11 Pro's NPU through LiteRT's Google Tensor NPU runtime (Maven litert-npu-runtime-google-tensor 2.3.0), each in one partition with all its ops on the NPU. With no Google Tensor options set, the 60-token example took a median 23.4 ms on this NPU and the 85-token request 24.8 ms, about 5.2 times as fast as the same phone's GPU at FP32 (120.9 and 129.1 ms in the table above). Setting the Google Tensor NPU option performance_mode to 5 (Burst) or 3 (High Performance) made the same files faster, and the probabilities were unchanged in every digit: measured again in the same sessions, the 60-token example took a median 16.5 to 18.6 ms in four runs (two at each mode) against 23.4 to 24.7 ms in six runs with no options set, and the 85-token request 16.3 to 19.8 ms in two runs at Burst against 24.9 to 25.7 ms in two runs with no options set. We passed the option as text in the runtime's Google Tensor options (performance_mode = 5 for Burst). The Tensor files compute each norm on its input divided by 4 times its mean absolute value, which gives the same result in exact arithmetic. This NPU ran the graphs in FP16, where values below 2^-14 became 0; in the other files the squares of small values in the norms were lost, and the Qualcomm NPU files changed the winner on up to 31 of 305 questions there. Compiling on the phone takes much of its memory: two 512-token graphs of the other forms, the Qualcomm _npu file among them, were stopped by our memory watch before they finished. No 512-token Tensor file was compiled, so the Tensor files stop at 256 tokens; longer requests run on the Pixel 11 Pro's GPU at FP32.
The phones' CPU rows use 4 threads on the Galaxy S26 and 6 on the Pixel 11 Pro: on the 128-token file no other count we tried was faster, and the probabilities equal those of one thread to every digit. On the 1,024-token request the Pixel 11 Pro capped its clocks in every run, and its fastest run used 5 threads. Set the count: with no CPU options, LiteRT 2.3.0's C API ran on one thread, and the 128-token file took 1.3 times as long as at 4 threads on the Galaxy S26 and 2.2 times as long on the Pixel 11 Pro. An earlier version of this card listed one-thread rows as 4 threads, because our test runner passed the thread count under an option name that LiteRT 2.3.0 does not read.
On both phones, the process peaks at about 2.6 GB of resident memory on the GPU at FP32 and 1.5 GB on the CPU with the 128-token file. Creating the GPU model at FP32 takes 1.6 to 3.2 s on the Galaxy S26 and 15 to 33 s on the Pixel 11 Pro. LiteRT's GPU cache (serializationDir, modelCacheKey, serializeProgramCache and serializeExternalTensors in CompiledModel.GpuOptions) cut the Pixel 11 Pro's creation of the 128-token model from 15.5 s to 1.8 to 2.0 s, but each call then took 12 to 19 % longer. On the Galaxy S26 it cut 1.6 s to 1.3 s at the same speed. The cache takes 0.93 GiB on disk and raises the process's peak by about 0.9 GiB; the first run, which writes it, took 1.4 s (Galaxy S26) and 2.3 s (Pixel 11 Pro) longer to create the model and peaked 1.2 to 1.7 GiB higher.
The phones ran LiteRT 2.3.0 through its C API, and the Mac computed their inputs with the host's code. This repository has no Android host yet: an Android app has to port host/pocket_dec_litert.py.
Files
| File | Size | What it is |
|---|---|---|
mnn-pocket-0.3b-dec_L{64,96,128,256,512,768,1024,2048}_fp16w.tflite |
489 MB each | The graphs for the CPU and the GPU, one per request length |
mnn-pocket-0.3b-dec_L{64,96,128,256,512,768,1024,2048}_fp16w_npu_SM8850.tflite |
494 to 606 MB | The Qualcomm NPU graphs, compiled for the SM8850 |
mnn-pocket-0.3b-dec_L{64,96,128,256,512,768,1024,2048}_fp16w_npu.tflite |
489 MB each | The Qualcomm NPU graphs, compiled on the phone |
mnn-pocket-0.3b-dec_L{64,96,128,256}_fp16w_tensor.tflite |
489 MB each | The Google Tensor NPU graphs |
embedding.safetensors |
117 MB | The source model's token table, its bytes unchanged |
tokenizer.json, decision_head.safetensors, temperature.json |
The source model's files, unchanged | |
host/, examples/ |
The Python host, the example requests and the source model's answers | |
conversion/, REPRODUCE.md, SHA256SUMS |
The scripts, every check, and the checksums. On the Mac that made them, the scripts rebuild the 20 graphs other than the SM8850 files byte for byte. Compiled again, the 64- and 768-token SM8850 files were the same computation, not the same bytes |
License
Apache License 2.0, as the source model: LICENSE and NOTICE.
- Downloads last month
- 1,730
Model tree for litert-community/MNN-Pocket-0.3B-Dec-LiteRT
Base model
taobao-mnn/MNN-Pocket-0.3B-Base