翻篇收录说明
翻篇网页快照

Run Gemma on-device with LiteRT-LM - Gemma Docs

https://gemma.ai/deployment/litert/

最近抓取:2026-12-03 10:41:10(北京时间)

最近内容变化:2026-11-30 08:48:09(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Run Gemma 4 on-device with LiteRT-LM — CLI install, prebuilt .litertlm weights, and exporting your own fine-tune.

正文摘录

Run Gemma on-device with LiteRT-LM¶ Models Gemma 4 Uses LiteRT View as markdown LiteRT-LM is Google AI Edge's runtime for running language models directly on a device — Android, iOS, macOS, Windows, Linux and Raspberry Pi — with CPU, GPU and NPU acceleration and no network round trip. Sizes supported today LiteRT-LM ships E2B and E4B, with larger models coming. The selector above offers the two sizes with published .litertlm weights. Install¶ uv tool install litert-lm Run¶ Weights are pulled straight from the Hugging Face LiteRT Community: litert-lm run \ --from-huggingface-repo=litert-community/gemma-4-E2B-it-litert-lm \ gemma-4-E2B-it.litertlm \ --prompt="What is the capital of France?" Multi-Token Prediction¶ LiteRT-LM supports MTP, which speeds up decoding with no quality loss: up to 2.2x on mobile GPUs and 1.5x on mobile CPUs. Google recommends MTP for every task on GPU backends, and for E4B on CPU. On E2B on CPU it helps most with rewriting, summarizing and coding, but can slow down freeform generation slightly — so enable it selectively there. Deploy your own fine-tune¶ Export Safetensors — including a model you have fine-tuned — to the .litertlm format: uv tool install litert-torch-nightly litert-torch export_hf \ --model=google/gemma-4-E2B-it \ --output_dir=/tmp/gemma4 \ --externalize_embedder \ --jinja_chat_template_override=litert-community/gemma-4-E2B-it-litert-lm Then run the exported bundle the same way: litert-lm run /tmp/gemma4/model.litertlm --prompt="What is the capital of France?" Model sizes¶ Size .litertlm bundle E2B 2.58 GB E4B 3.65 GB Google publishes measured prefill, decode and time-to-first-token figures per device and backend on the Gemma 4 LiteRT-LM page. Platform guides¶ LiteRT-LM has APIs for the CLI, Python, Android (Kotlin), iOS (Swift) and C++. See the LiteRT-LM documentation for each. To try Gemma on a phone without writing code, use the AI Edge Gallery.