Image-Text-to-Text
LiteRT-LM
LiteRT
litertlm
on-device
multimodal
vision-language
Mixture of Experts
Instructions to use litert-community/Inkling-2-Mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT-LM
How to use litert-community/Inkling-2-Mini 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 # A single .litertlm file in the repo is picked automatically; otherwise the CLI asks which one to run # (or pass its name right after the repo id). litert-lm run \ --from-huggingface-repo=litert-community/Inkling-2-Mini \ --prompt="Write me a poem"
- LiteRT
How to use litert-community/Inkling-2-Mini 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
|
Download README.md from litert-community/Inkling-2-Mini: direct link, hf CLI and curl.
- Browser
- Download file 8.85 kB
-
https://huggingface.co/litert-community/Inkling-2-Mini/resolve/main/README.md
- Command line
-
hf download hf://litert-community/Inkling-2-Mini/README.md
-
curl -L -o README.md https://huggingface.co/litert-community/Inkling-2-Mini/resolve/main/README.md
8.85 kB
| license: apache-2.0 | |
| base_model: thinkingmachines/Inkling-2-Mini | |
| base_model_relation: quantized | |
| library_name: litert-lm | |
| pipeline_tag: image-text-to-text | |
| tags: | |
| - litert | |
| - litert-lm | |
| - litertlm | |
| - on-device | |
| - multimodal | |
| - vision-language | |
| - moe | |
| # Inkling-2-Mini LiteRT-LM | |
| This repository is a conversion of [thinkingmachines/Inkling-2-Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini) to LiteRT-LM, for text and image input. On an Apple M4 Max with 128 GB, the one Mac it was tried on, a text-only benchmark with a 1,024-token prompt decoded 256 tokens at 7.05 tok/s on the GPU (WebGPU) and 3.36 tok/s on the CPU, with LiteRT-LM 0.19.2 (2026-11-22). | |
| [LiteRT-LM](https://github.com/google-ai-edge/LiteRT-LM) is Google's runtime for running language models on your own device. Download the 27.74 GB file [`Inkling-2-Mini_int8.litertlm`](https://huggingface.co/litert-community/Inkling-2-Mini/blob/main/Inkling-2-Mini_int8.litertlm). Its first run on each backend writes caches next to it: the file and the caches of both backends take 80.67 GB of disk. Run these commands in its folder, from a fresh Python 3.13 virtual environment: they install the runtime, download a public photo, pad it to a square and ask about it on the GPU. | |
| ```bash | |
| pip install litert-lm==0.19.2 pillow | |
| curl -L -o cat.jpeg https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg | |
| python3 -c "from PIL import Image, ImageOps; im = ImageOps.exif_transpose(Image.open('cat.jpeg')).convert('RGB'); s = max(im.size); sq = Image.new('RGB', (s, s)); sq.paste(im); sq.save('cat_square.png')" | |
| litert-lm run Inkling-2-Mini_int8.litertlm --backend gpu --vision-backend gpu --attachment cat_square.png --prompt "Describe this picture." | |
| ``` | |
| On the CPU: | |
| ```bash | |
| litert-lm run Inkling-2-Mini_int8.litertlm --backend cpu --vision-backend cpu --attachment cat_square.png --prompt "Describe this picture." | |
| ``` | |
| The GPU command printed its thought between `[thinking]` and `[/thinking]`, then this answer: | |
| ```text | |
| <|message_model|><|content_text|>The photo shows a very fluffy, stocky cat-like animal—likely a Pallas’s cat/manul—walking across a snow-covered surface. Its thick fur is a mix of gray, tan, and brown with darker mottling, and a light dusting of frost or snow sits along its back. The animal has a rounded face, small rounded ears, dark stripes around the muzzle and eyes, and a somewhat grumpy expression. One front leg is reaching forward and slightly blurred, suggesting motion, while the other legs are planted on the snow. | |
| In the background are vertical pale tree trunks, possibly birch, with dark markings and frost, plus a chain-link fence visible at the left edge. The lower part of the image is a solid black band.<|end_message|> | |
| ``` | |
| ## When it does not work | |
| - **Phones.** Not tried: the file is larger than the 12 GB of memory of a Galaxy S26. | |
| - **Prompts over 4,096 tokens.** The context holds 4,096 tokens, and a picture takes 256 of them. Given a longer prompt, the CPU command above printed `An error occurred` on stdout and a Python traceback on stderr that ends with `RuntimeError: INVALID_ARGUMENT: Input token ids are too long. Exceeding the maximum number of tokens allowed: 7480 >= 4096`. It still exited with code 0, so the output is the only sign of the failure. | |
| - **Pictures that are not square.** The runtime stretches every picture to 640 × 640 pixels without keeping its proportions, so a circle in a wide picture becomes an oval. Pad the picture to a square first, black at the right and bottom, as the `python3` command above does. | |
| ## First run | |
| | | GPU (WebGPU) | CPU | | |
| |---|---:|---:| | |
| | Caches the commands above wrote | 25.90 GB | 27.03 GB | | |
| | First run of the commands above, reply included | 102 s | 224 s | | |
| | Engine creation in a first text-only run, writing the caches | 38.18 s | 22.44 s | | |
| | Engine creation in later text-only runs, reading those caches | 3.252–3.513 s | 0.445–0.935 s | | |
| ## Performance | |
| | Backend | Prefill (tok/s) | Decode (tok/s) | Time to first token | | |
| |---|---:|---:|---:| | |
| | GPU (WebGPU) | 80.75 | 7.05 | 12.82 s | | |
| | CPU (XNNPACK, default threads) | 40.46 | 3.36 | 25.61 s | | |
| Apple M4 Max (128 GB, macOS 27.0), LiteRT-LM 0.19.2 from PyPI, a 1,024-token text prompt and 256 generated tokens, the median of 3 processes, measured on 2026-11-22. | |
| Speed is still being tuned (updates follow). | |
| ## Memory | |
| | Peak memory footprint | GPU (WebGPU) | CPU | | |
| |---|---:|---:| | |
| | 1,024-token text prompt, 256 tokens out | about 11 GB | 9.15 GB | | |
| | One picture and a short question | 16.54–16.60 GB | 4.76–4.86 GB | | |
| ## Accuracy | |
| | Check | GPU (WebGPU) | CPU | | |
| |---|---:|---:| | |
| | 12 short text questions: answer correct | 12 / 12 | 12 / 12 | | |
| | The same 12: every reply token less than 1.0 logit below the author's model's top token | 12 / 12 | 12 / 12 | | |
| | 3 pictures: every reply token less than 1.0 logit below the author's model's top token | 3 / 3 | 3 / 3 | | |
| | One of them, a receipt with 16 lines of text: found in the answer | 14 / 16 | 15 / 16 | | |
| | 3-turn conversation: third answer correct | pass | pass | | |
| The pictures went to the author's model as the same 640 × 640 pixels. | |
| The author's model found all 16 from a different input: the picture at its own size, 768 image tokens instead of 256, at the lowest thinking effort. | |
| None of the WebGPU runs above printed a `Validation error` message. | |
| ## Limitations | |
| - After each complete reply, LiteRT-LM prefills the reply again into the KV cache, thought included, so the thought stays in the conversation and counts toward the 4,096 tokens. In a two-turn WebGPU conversation through the Python API, the context held 605 tokens after the first turn: the cat picture, its question and the reply, 184 of them the thought. On LiteRT-LM 0.19.2, the reply's stream in the Python API ended only after this prefill: 3.5–7.4 s after `<|end_message|>` arrived on the CPU and 6.6–8.6 s on WebGPU. Through the Python API, the thought arrives in a separate `thinking` channel. | |
| - Start a new conversation after a message fails because it does not fit in the 4,096-token context. On LiteRT-LM 0.19.2, after such a failure, the next three messages in the same conversation, two of them short, all failed with `INTERNAL: Task failed with state: 7`, while a new conversation answered. This was measured once with another file, not with this one. | |
| - The model's markers `<|message_model|>`, `<|content_text|>` and `<|end_message|>` come out as text, in the command's output and in the reply text of the Python API. Remove them in your app. | |
| - On the CPU, the same greedy question can get a different reply in a new process. On WebGPU, the photo asked in two processes got the same reply both times. | |
| - Create one Engine per conversation. This file keeps a running state for its short convolutions, and on LiteRT-LM 0.19.2 a new conversation on the same Engine can continue from the previous conversation's state ([LiteRT-LM#3165](https://github.com/google-ai-edge/LiteRT-LM/issues/3165)). This was not measured on this file. | |
| - After the first turn of a conversation, LiteRT-LM can put a token of the conversation into the KV cache without its embedding, because in this file the text embedder is a model of its own and the decoder takes embeddings. Later answers can then differ from what the model answers to the same messages in one prompt. This was read in the source of LiteRT-LM 0.19.1 and measured with 0.18.1 on WeVisOne-VL-2B and Qwen2.5-Coder-1.5B-Instruct, not on this file. One question per conversation avoids it, as does a new conversation that starts with the earlier messages and the new question. | |
| - Tool calls were not tried with this file. | |
| ## How it was made | |
| - The file was converted from the author's revision `ed40e7da625f594fc9c4990f5f66be24873c22d7`, which stores the experts in NVFP4 and MXFP8 and the other weights in bf16. | |
| - The file holds four models: the text embedder, the text decoder, the vision encoder and the vision adapter. The author's `mtp.safetensors` is not in it. | |
| - It keeps int8 weights per output channel for the experts, the lm_head and most other linear layers, and fp32 weights for the routers, the attention-residual queries and two small integer-valued matrices. The text embedder's token table is int8, with one scale per row. The vision encoder and adapter keep fp32 weights. | |
| - It declares fp32 activations for all four models. | |
| - The tokenizer is the author's `tokenizer.json`, byte for byte. | |
| - The file's chat template is the author's, with six edits for LiteRT-LM's template engine. | |
| ## License | |
| Apache 2.0, the license of the author's model: [LICENSE](https://huggingface.co/litert-community/Inkling-2-Mini/blob/main/LICENSE). The author's [Model Acceptable Use Policy](https://thinkingmachines.ai/model-acceptable-use-policy/) covers modified versions like this one. | |