Gemma on Mobile & Web: Best Practices for On-Device AI with MediaPipe
Google for DevelopersApril 2, 202513 min12,804 views
30 connectionsยท36 entities in this videoโWhy On-Device AI?
- ๐ก Running AI models on mobile and web devices offers significant advantages over cloud-based solutions, primarily due to privacy, latency, cost, and offline availability.
- ๐ฐ Eliminating cloud bills enables different business models, especially for free or single-payment apps, by avoiding variable costs associated with user LLM interactions.
- ๐ On-device processing ensures that sensitive user data remains on the device, enhancing privacy and security.
- โ๏ธ Offline availability means applications can function reliably even without an internet connection, crucial for travel or areas with poor signal.
- โก Reduced latency provides a faster response time for users, as data doesn't need to travel to a server and back, especially beneficial with smaller, optimized models.
System vs. In-App AI Models
- ๐ค System AI (e.g., Gemini Nano on Android, Apple Intelligence on iOS) integrates LLMs directly into the platform, offering large, capable models that are easy to use but limited in customization.
- ๐ฑ In-app AI involves bundling models directly into your application, providing full flexibility, customization, and fine-tuning capabilities.
- โ๏ธ While system models offer convenience and power, in-app models provide greater control and can be optimized for specific use cases and a wider range of devices.
Gemma 3 1B: A Powerful In-App Model
- โจ Gemma 3 1B is highlighted as an exceptional in-app model, particularly for its size and performance.
- ๐ฆ Quantized, it's only 529 megabytes, making it easy to download over the air, and under 400 megabytes when zipped.
- ๐ป It can run on devices with as little as 4GB of RAM, making it accessible on a vast majority of user devices.
- ๐ Performance is impressive, with speeds of 2500 tokens per second for pre-fill and 56 tokens per second for decoding, feeling almost instant for many tasks.
Use Cases and Best Practices
- ๐ฃ๏ธ Natural Language UI Control: Applications can be driven by natural language commands, allowing users to interact with features like flight booking or chart customization without navigating complex menus.
- โ๏ธ Text Generation: Powerful applications can be built for tasks like data captioning (e.g., workout summaries), summarization of in-app content, and generating smart replies for messaging.
- ๐ฎ In-game Dialogue: NPCs can generate custom, context-aware dialogue, enhancing player immersion.
- ๐ฏ Customization is Key: For smaller models like Gemma 1B, few-shot prompting or fine-tuning on custom data significantly improves results.
- ๐ Retrieval Augmented Generation (RAG): For querying large datasets, RAG on-device, supported by the new Google AI Edge RAG SDK, allows for efficient retrieval and coherent response generation.
Integrating Gemma with MediaPipe
- ๐ ๏ธ The MediaPipe LLM Inference API provides a cross-platform solution for running Gemma on Android, iOS, and Web.
- ๐ It offers high performance by optimizing for both CPU and GPU, a rare feature on mobile platforms.
- ๐ป Integration is simplified with just a few lines of code in Kotlin, Swift, or JavaScript, making it accessible for developers to configure, initialize, and run Gemma within their applications.
Knowledge graph36 entities ยท 30 connections
How they connect
An interactive map of every person, idea, and reference from this conversation. Hover to trace connections, click to explore.
Hover ยท drag to explore
36 entities
Chapters7 moments
Key Moments
Transcript51 segments
Full Transcript
Topics14 themes
Whatโs Discussed
GemmaOn-Device AIMobile AIWeb AIMediaPipeLLM Inference APILiteRTPrivacyLatencyOffline AvailabilityGemma 3 1BRetrieval Augmented Generation (RAG)Fine-TuningFew-Shot Prompting
Smart Objects36 ยท 30 links
Productsยท 16
Conceptsยท 14
Companyยท 1
Locationsยท 2
Mediasยท 2
Eventยท 1