GA

google-ai-edge/litert-samples

Developer tools
477 stars Quality 70 Trend 66Apache-2.0

LiteRT and LiteRT-LM sample apps, model recipes, agent skills and utilities.

Overview

🌍 Ecosystem • 🤗 Hugging Face Hub • 🚀 Quickstart (Level 1–5) • 📱 Sample Apps • 🧪 Model Recipes • 🤖 Agent Skills • 📂 Repo Map Welcome to — the central developer hub for * (Google's high-performance, cross-platform, production-proven on-device inference, powering Google and 3P applications globally, succeeding TensorFlow Lite) and * (Google's specialized orchestration layer for running LLMs with LiteRT, unlocking maximum performance and efficiency). Whether you want to , , or , this repository takes you from first run to production deployment. * 🦋 : Added a full multimodal Flutter app (samples/litert/flutter/) running voice chat, live camera detection, RAG, and agent skills across Android, iOS, macOS, Linux, Raspberry Pi 5, Jetson Orin, and Qualcomm VENTUNO Q — plus a 3-act showcase (samples/litert/flutter_intel_npu/) running Gemma 4 across CPU, GPU, and NPU.

README


Welcome to litert-samples — the central developer hub for

  • LiteRT (Google’s high-performance, cross-platform, production-proven on-device inference, powering Google and 3P applications globally, succeeding TensorFlow Lite) and
  • LiteRT-LM (Google’s specialized orchestration layer for running LLMs with LiteRT, unlocking maximum performance and efficiency).

Whether you want to try a model in your browser in 30 seconds, drop a pre-converted model from Hugging Face litert-community into a mobile/desktop/web app, or convert, quantize, verify, and benchmark a new checkpoint on CPU, GPU, and NPU, this repository takes you from first run to production deployment.


🔥 What’s New

  • 🦋 Cross-Platform Flutter & Intel NPU Showcases: Added a full multimodal Flutter app (samples/litert/flutter/) running voice chat, live camera detection, RAG, and agent skills across Android, iOS, macOS, Linux, Raspberry Pi 5, Jetson Orin, and Qualcomm VENTUNO Q — plus a 3-act Intel Core Ultra NPU showcase (samples/litert/flutter_intel_npu/) running Gemma 4 across CPU, GPU, and NPU.
  • 📱 LiteRT Model Zoo (34 Tasks in One App): Expanded samples/litert_model_zoo/ to 21 Vision, 8 Audio, and 5 Text Decision models via the LiteRT CompiledModel API, streaming verified weights on-demand from litert-community.
  • 🎙️ Offline Voice Assistant & Embodied Robotics: Added an offline Android voice assistant with tool calling (samples/litert_lm/voice_assistant/) and a Raspberry Pi Reachy voice robot that sees, hears, reasons, and speaks (samples/litert_lm/reachy-voice-robot/).
  • 🌐 Client-Side WebGPU Demos & Chrome Extension: Added 5 zero-server browser demos built on @litertjs/core (samples/web_demos/: SAM 2.1, CLIPSeg, MoGe-2 3D, PP-OCRv5, Matcha-TTS) and a Chrome Extension for on-page OCR, TTS, and 3D photo hover.
  • 🧪 End-to-End Model Conversion Cookbook & Recipes: Added models/conversion.md and reproducible conversion/verification pipelines under models/ for MiniCPM5-2B, Hunyuan Hy-MT2-1.8B, Nemotron-3-Nano-4B, Bonsai Image 4B, Qwen3-TTS, SAM 3, Zipformer ASR, wav2vec2 KWS, and GLiNER2.5.
  • 🏆 Real-Device Cloud Benchmarking & AI Agent Skills: Added Google Cloud Developer Device Platform (DDP) Colab notebooks, the LiteRT Performance Leaderboard, and 9 end-to-end SKILL.md playbooks (skills/) for AI coding agents.

🌍 The Google AI Edge & LiteRT Ecosystem

litert-samples connects the entire google-ai-edge open-source stack with the Hugging Face litert-community model ecosystem:

flowchart LR
    subgraph Source["1. Author & Convert"]
        PT["PyTorch / JAX / TF& HF Safetensors"] --> TORCH["litert-torch &ai-edge-quantizer"]
        REC["litert-samples/models/Conversion Recipes"] -.->|Scripts & Gates| TORCH
    end

    subgraph Hub["2. Model Hub (Hugging Face)"]
        TORCH -->|".tflite & .litertlm"| HF["🤗 litert-community400+ Ready-to-Run Models"]
    end

    subgraph Runtime["3. On-Device Runtimes & CLI"]
        HF --> RT["LiteRT RuntimeCompiledModel & Tensor API"]
        HF --> LM["LiteRT-LM EngineLLMs, VLMs & Tool Calling"]
        HF --> CLI["LiteRT-CLI (litert)1-Command Run & Benchmark"]
    end

    subgraph Silicon["4. Hardware Acceleration"]
        RT & LM --> HW["CPU (XNNPACK)GPU (ML Drift / OpenCL / Metal / WebGPU)NPU (Qualcomm, Google Tensor, MediaTek, Intel)"]
    end

    subgraph Apps["5. Apps, Web & Benchmarks (This Repo)"]
        HW --> SAMP["📱 samples/ • 🌐 web_demos/🏆 benchmark/ • 🤖 skills/"]
    end

Ecosystem Repositories at a Glance

Repository / Hub Role in the Stack Artifact / API
google-ai-edge/LiteRT Core on-device runtime featuring the CompiledModel API (V2), C++ Tensor API, LiteRT.js (WebGPU/WASM), and unified GPU/NPU acceleration. .tflite
google-ai-edge/LiteRT-LM Production inference engine for LLMs & VLMs (prefill/decode orchestration, KV cache, multimodal vision/audio towers, tool calling). .litertlm
huggingface.co/litert-community Official community hub hosting 400+ pre-converted, quantized, and verified .tflite and .litertlm models ready for on-device deployment. .tflite, .litertlm
google-ai-edge/litert-samples (You are here) Reference apps (Android, iOS, Flutter, Web, Linux/Pi), conversion recipes (models/), DDP benchmarks (benchmark/), and agent skills (skills/). End-to-End Code
google-ai-edge/LiteRT-CLI Unified command-line tool (litert) to download, convert, quantize, run, and benchmark models locally or on cloud device farms (--ddp). litert CLI
google-ai-edge/litert-torch & ai-edge-quantizer PyTorch-to-LiteRT converter, Generative Torch API for re-authoring LLMs, and accuracy-safe PTQ/quantization toolkit (fp16 / int8 / int4). Python SDK
google-ai-edge/gallery & model-explorer End-user showcase app for trying local GenAI models (gallery) and interactive hierarchical graph visualizer/debugger (model-explorer). App & Visualizer

🤗 Hugging Face litert-community Hub

Every sample application, web demo, and recipe in this repository is tightly integrated with Hugging Face litert-community — no manual conversion is required to get started, and no heavy model weights are bloated into git history.

🧭 Discover & Compare Models Instantly

Interactive Portal What You Can Do Source in This Repo
🤗 litert-community Organization Browse 400+ pre-converted models across LLMs, VLMs, ASR, TTS, Image Generation, Detection, Segmentation, and Depth. models/
🔍 Find Your Models (HF Space) Filter every litert-community model by family, parameter size, task, on-device latency/tokens-per-sec, conversion recipe, and copy ready-to-run litert CLI commands. community/models_page/
📈 Trending & Weekly Picks (HF Space) Track trending & newest edge models, weekly community picks, matching apps in litert-samples, and live browser Spaces. community/trending_page/

🌟 Featured Model Families on litert-community

💡 Browse by Hardware & Platform Collections on Hugging Face: Android • iOS • Web LLM • Web Classical • Desktop • Google Tensor TPU • Qualcomm NPU


🚀 Getting Started: From Zero to Production

We organized this repository progressively so you can start at the depth that matches your goal:

  1. Level 1 — Zero Install (30s): Run client-side WebGPU/WASM demos right in your browser.
  2. Level 2 — 3-Minute CLI Quickstart: Download, run, and benchmark any litert-community model in 3 commands.
  3. Level 3 — Run & Build Sample Apps: Build full apps for Android, iOS, Flutter, macOS, Windows, Linux, Web, and Raspberry Pi.
  4. Level 4 — Convert & Quantize Models: Turn Hugging Face / PyTorch checkpoints into verified .litertlm and .tflite artifacts.
  5. Level 5 — Agent Skills & Cloud Device Farm: Automate the entire lifecycle with AI coding agents and benchmark on real cloud phones.

🌐 Level 1 — Try in Your Browser (Zero Install)

Experience LiteRT running 100% client-side in your browser via LiteRT.js (WebGPU + multi-threaded WASM) with weights streamed directly from litert-community:


⚡ Level 2 — Run & Benchmark from the Terminal (3 Minutes)

Use LiteRT-CLI (litert) or LiteRT-LM (litert-lm) to pull any model from litert-community and run or benchmark it immediately:

# 1. Install LiteRT-CLI and LiteRT-LM
pip install litert-cli-nightly

# 2. Run an LLM (.litertlm) from Hugging Face litert-community
litert download litert-community/Qwen3-0.6B
litert lm run Qwen3-0.6B.litertlm --prompt "Explain on-device AI in two sentences."

# 3. Benchmark any .tflite or .litertlm model locally or on real cloud phones (--ddp)
litert download litert-community/efficientnet_b1
litert benchmark efficientnet_b1.tflite --gpu

☁️ No phone attached? Run benchmarks on real physical Android & iOS devices in Google Cloud’s Developer Device Platform (DDP) directly from Colab — see benchmark/developer_device_platform/.


📱 Level 3 — Explore Sample Applications

All runnable applications live under samples/. New applications use the LiteRT CompiledModel API (for .tflite models with automatic GPU/NPU acceleration and zero-copy buffers) and LiteRT-LM (for .litertlm generative models).

🌟 Flagship Multi-Model & Cross-Platform Apps

Sample App Highlights & Modality Platforms & Accelerators Models Used (litert-community)
samples/litert_model_zoo/ 34 Tasks in One Android App (21 Vision, 8 Audio, 5 Text Decision). On-demand SHA-256 verified downloads from HF, live latency/backend cards, 122 JVM tests. Android (CompiledModel GPU / CPU) 34 repos on litert-community (RF-DETR, PIDNet, MODNet, DINOv2, PP-OCRv5, Depth Anything 3, Zipformer, Matcha-TTS, Laya, etc.)
samples/litert/flutter/ All-in-One Edge AI Assistant: Spoken voice chat, live camera object detection + visual memory, local RAG knowledge base, and function-calling agent skills. Android, iOS, macOS, Linux, Windows, Raspberry Pi 5, Jetson Orin, Qualcomm VENTUNO Q, Intel Core Ultra PCs (CPU / GPU / NPU) Gemma 4 E2B, EmbeddingGemma 2, Whisper Base, Moonshine Tiny, Inflect-Nano-v2, YOLO26n
samples/litert/flutter_intel_npu/ 3-Act Hardware Showcase: Compare CPU vs. GPU vs. Intel Core Ultra NPU in a live speed race, 45-min transcript Q&A, and live 3D scene narration. Windows 11 (Intel Core Ultra CPU / GPU / NPU), macOS (CPU / Metal GPU) Gemma 4 E2B & Gemma 4 12B
samples/litert_lm/voice_assistant/ 100% Offline Voice Agent: Listens to speech, executes device tool calls (alarm, timer, calendar), and speaks back offline. Android (Kotlin) Gemma 4 E2B + Zipformer CR-CTC + KittenTTS Nano
samples/litert_lm/reachy-voice-robot/ Embodied Voice Robot: Sees via camera, hears questions, reasons with Gemma, and speaks aloud on Raspberry Pi. Raspberry Pi (Python) Gemma 4 E2B + Moonshine Tiny + Inflect-Nano-v2 + YOLO26
samples/litert/phototalk_sample_app/ Vision + LLM Pipeline: Combines CompiledModel image classification with LiteRT-LM multimodal conversation. Android (Kotlin) EfficientNet-Lite0 + Gemma 4 E2B / Gemma 3 1B / FastVLM-0.5B

⚡ NPU & TPU Hardware-Accelerated Samples

Sample Directory Target Silicon What It Demonstrates
samples/litert/google/sample_app_tpu/ Google Tensor TPU (Pixel) Multimodal chat with Gemma 4 E2B (gemma-4-E2B-it_Google_Tensor_G5.litertlm) on Pixel Tensor TPU.
samples/litert/qualcomm/llm_chatbot_npu/ Qualcomm Snapdragon NPU Multimodal chat (text, image, audio) with Gemma 4 E2B and FastVLM-0.5B on Snapdragon 8 Elite NPU.
samples/litert/qualcomm/gemma3/ & gemma4/ & fast_vlm/ Qualcomm NPU / GPU / CPU Dedicated Gemma 3 1B, Gemma 4 E2B, and FastVLM 0.5B Android apps with NPU compilation guides.
samples/litert/qualcomm/mobilenet_v2/ & object_detection/ Qualcomm NPU (JIT & AOT) Zero-config on-device JIT NPU compilation (MobileNet-v2) and live camera NPU object detection (EfficientDet-Lite0).
samples/litert/colab/ Multi-Vendor NPU AOT Interactive Colab tutorial for Ahead-of-Time (AOT) NPU compilation with LiteRT.

🎨 Vision, Speech, Audio & Text Task Samples (samples/litert/)

Sample Task Platforms litert-community Model(s)
speech_recognition/ Multi-model Automatic Speech Recognition (ASR) Android, Python Parakeet TDT/CTC 0.6B, Whisper Tiny, Moonshine Tiny, Qwen3-ASR-0.6B
text_to_speech_lm/ LLM-based TTS with zero-shot voice cloning Android, Python Qwen3-TTS-12Hz-0.6B-Base
text_to_speech_streaming/ Ultra-light (15M, 32 MB) sentence-streaming TTS with live TTFA/RTF metrics Android, Python KittenTTS Nano + Matcha-TTS G2P
text_to_speech/ Fast neural Text-to-Speech Android, iOS Matcha-TTS
image_generation/ On-device Text-to-Image diffusion iOS, macOS Bonsai-Image-ternary-4B
image_segmentation/ Real-time camera segmentation (CPU, GPU, NPU JIT/AOT) Android (Kotlin & C++), iOS (Swift) MediaPipe-Selfie-Segmentation
zero_shot_classification/ Runtime-defined zero-shot text decisions (choice, score, yes/no) Android (CPU / GPU / NPU JIT) Laya-Multilingual-LiteRT
semantic_similarity/ C++ sentence embedding & similarity Linux, Android (C++) embeddinggemma-300m
image_classification/, text_classification/, digit_classifier/ Starter CompiledModel API templates for Vision & Text Android EfficientNet-Lite, BERT Classifier, MNIST
samples/end_to_end/imagenet/ End-to-end PyTorch conversion → preprocessing → evaluation pipeline Python / Android ImageNet classifiers

🖥️ Dedicated Hardware & Platform Setup Guides (samples/platforms/)

Step-by-step instructions to build, deploy, and run LiteRT & LiteRT-LM demos on specific hardware targets:


🧪 Level 4 — Convert & Quantize Models (models/)

Want to bring a new Hugging Face checkpoint to LiteRT and publish it to litert-community? Start with the Model Conversion Cookbook (models/conversion.md).

Two Conversion Lanes + C++ Tensor API

Model Type Output Artifact Target Runtime Guide & Tooling
Text LLMs & Multimodal VLMs .litertlm bundle LiteRT-LM Cookbook §1–11 + litert-conversion-workflow
Vision, Audio, Diffusion & Encoders .tflite graph(s) LiteRT CompiledModel API Cookbook §12 + utilities/litert_gpu_toolkit/
Zero-Converter C++ Graphs Native C++ binary / WASM LiteRT Tensor API models/*/tensor_api/ & samples/tensor_api_playground/

Worked Model Recipes in models/

Each directory under models/ is a complete, reproducible recipe containing export scripts, numerical parity checks against the source checkpoint, and published weights on Hugging Face:

Recipe Directory Task & Architecture Artifact Source Checkpoint Published Weights on Hugging Face
models/minicpm/minicpm5_2b/ Chat LLM with optional `` reasoning (CPU & GPU) .litertlm openbmb/MiniCPM5-2B litert-community/MiniCPM5-2B
models/hunyuan/hy_mt2_1_8b/ 33-language Translation LLM (CPU & GPU) .litertlm tencent/Hy-MT2-1.8B litert-community/Hy-MT2-1.8B
models/nemotron/nemotron_3_nano_4b/ Mamba2-Attention Hybrid Reasoning LLM .litertlm nvidia/NVIDIA-Nemotron-3-Nano-4B-BF16 litert-community/Nemotron-3-Nano-4B
models/bonsai/bonsai_image_4b/ Ternary 4B Text-to-Image Diffusion (3 graphs + host loop) .tflite prism-ml/bonsai-image-ternary-4B-unpacked litert-community/Bonsai-Image-ternary-4B
models/qwen/qwen3_tts/ Qwen3-TTS 0.6B Speech Synthesis (3 graphs + C++ Tensor API) .tflite & Tensor API Qwen/Qwen3-TTS-12Hz-0.6B-Base litert-community/Qwen3-TTS-12Hz-0.6B-Base
models/sam3/sam3_image/ Text-prompted Detection & Segmentation (3 GPU-resident graphs) .tflite facebookresearch/sam3 mlboydaisuke/SAM3-LiteRT
models/zipformer/zipformer_ctc/ Streaming/Offline Speech Recognition (Zipformer-medium CR-CTC) .tflite Zengwei/icefall-asr-... litert-community/Zipformer-medium-CR-CTC-LiteRT
models/wav2vec2/wav2vec2_kws/ Keyword Spotting (wav2vec2 2-graph split) .tflite superb/wav2vec2-base-superb-ks litert-community/wav2vec2-keyword-spotting
models/gliner/gliner2_5_small/ Zero-shot Named Entity Extraction (GLiNER2.5 Small) .tflite fastino/gliner2.5-small-v1 litert-community/GLiNER2.5-Small-LiteRT
models/sam2/sam2_hiera_tiny_video/ Video & Image Object Tracking (C++ Tensor API, iOS & Web Demo) Tensor API SAM 2.1 Hiera-Tiny SAM2.1-Hiera-Tiny-Image-Encoder
models/llada/llada_8b/tensor_api/ Diffusion Language Model Denoise Step (LLaDA-8B) Tensor API LLaDA-8B —

🤖 Level 5 — Automate with AI Agent Skills & DDP Benchmarks

1. AI Coding Agent Skills (skills/)

Point your AI coding agent (Claude Code, Gemini CLI, Cursor, etc.) at skills/ to automate model conversion, GPU surgical patching, quantization, verification, benchmarking, and Android app generation.

2. Real-Device Cloud Benchmarking (benchmark/)

Don’t have a fleet of test phones? Run reproducible benchmarks on real phones in Google Cloud’s Developer Device Platform (DDP) straight from your browser:

Resource Description Launch
litert_cli_benchmark.ipynb Benchmark any litert-community .tflite or .litertlm model on cloud phones with litert benchmark --ddp.
ddp_cli_benchmark.ipynb Multi-device fleet benchmarking for Gemma 4 E2B using gcloud beta device-run with warmup & cooldown control.
embedding_gemma_ddp_benchmark.ipynb Benchmark tri-modal (text + image + audio) EmbeddingGemma on DDP devices.
benchmark/leaderboard/ & benchmark/ios/ Data-driven Performance Leaderboard and iOS XCTest / Metal benchmark harness. View Leaderboard

📂 Repository Structure

litert-samples/
├── samples/                        # 📱 Runnable sample applications across platforms
│   ├── litert/                     # Core LiteRT CompiledModel API & NPU/GPU samples (Android, iOS, Flutter, C++, Python)
│   ├── litert_model_zoo/           # 34-task Android Model Zoo app streaming on-demand from HF litert-community
│   ├── litert_lm/                  # LiteRT-LM agentic showcases (Offline Android Voice Assistant, Raspberry Pi Reachy Robot)
│   ├── web_demos/                  # Client-side WebGPU/WASM demos (@litertjs/core) + Chrome Extension
│   ├── tensor_api_playground/      # Interactive browser playground for the C++ LiteRT Tensor API
│   ├── platforms/                  # Hardware setup guides (Android, iOS, NVIDIA Jetson, Qualcomm VENTUNO Q, Raspberry Pi, Intel PCs)
│   ├── end_to_end/                 # Full conversion-to-deployment pipelines (ImageNet)
│   └── litert_interpreter/         # Legacy TensorFlow Lite Interpreter API reference samples (maintenance mode)
├── models/                         # 🧪 End-to-end model conversion recipes & verification gates
│   ├── conversion.md               # Step-by-step Model Conversion Cookbook (.litertlm & .tflite)
│   └── //           # Reproducible export, quantization & verification recipes linked to litert-community
├── skills/                         # 🤖 SKILL.md playbooks for AI coding agents (convert, quantize, verify, benchmark, scaffold)
├── benchmark/                      # 🏆 Real-device performance benchmarking suite
│   ├── leaderboard/                # Live performance leaderboard UI & measurement datasets (Android, iOS, macOS)
│   ├── developer_device_platform/  # Colab notebooks for benchmarking on Google Cloud DDP real phones
│   ├── ios/                        # Xcode / XCTest benchmark framework for local & DDP iPhones
│   └── driver/                     # Matrix runners and result collectors for building leaderboard rows
├── community/                      # 🤗 Source apps for Hugging Face litert-community Spaces
│   ├── models_page/                # Powers huggingface.co/spaces/litert-community/find-your-models
│   └── trending_page/              # Powers huggingface.co/spaces/litert-community/trending-models
└── utilities/                      # 🛠️ Shared libraries & conversion toolkits
    ├── common/                     # Shared Kotlin helpers for Android (CompiledModelRunner, camera, audio, tensor math)
    └── litert_gpu_toolkit/         # PyTorch pre-conversion surgical patches & post-conversion GPU residency checker

🛑 AI Coding Directives (For Developers & Coding Agents)

When authoring new application or inference code with LiteRT:

  • ✅ MUST USE: The LiteRT CompiledModel API for .tflite models (Kotlin, C++, Swift, Python, JS) and LiteRT-LM for .litertlm LLM/VLM bundles.
  • ❌ DO NOT USE: The legacy TensorFlow Lite Interpreter API (tflite::Interpreter, org.tensorflow.lite.Interpreter, tf.lite.Interpreter) or manual delegate wiring. Samples under samples/litert_interpreter/ are preserved only for legacy migration reference.
  • 🔄 MIGRATING: Follow the LiteRT Migration Guide or run the litert-compiled-model-migration agent skill.

📚 Official Documentation & Resources


🤝 Contributing & License

Contributions of new sample apps, model conversion recipes, and community models are welcome!

  1. Read CONTRIBUTING.md and GOVERNANCE.md.
  2. To contribute a converted .tflite or .litertlm model, follow the Model Conversion Cookbook and publish to Hugging Face litert-community.
  3. Licensed under the Apache License 2.0 — see LICENSE for details.

Disclaimer: This is a sample repository maintained by Google. It is provided “as is” without warranty of any kind.

View the full README on GitHub

Recommended Tools

Try a different keyword or remove a filter.

Install

npx skillfish add google-ai-edge/litert-samples
New to MCP? Start with the mcpskill.org guide →