Overview
The VLM (Vision Language Model) module enables on-device multimodal inference — feed an image and a text prompt to get descriptions, answers, or analysis. VLM runs entirely on the device using llama.cpp with no data leaving the phone.Package Imports
Basic Usage
processImageStream returns a Flow<String> where each emission is a single token, enabling real-time streaming display.
Model Setup
Register a VLM Model
VLM models require two files: the main model GGUF and a multimodal projector (mmproj) GGUF. Register them using registerMultiFileModel:
Load and Unload
API Reference
VLMImage
VLMImage.fromFilePath() requires a file system path, not a content URI. If you’re using
Android’s photo picker or ACTION_OPEN_DOCUMENT, you must first copy the image to a temporary
file. See the image picker example below.VLMGenerationOptions
processImageStream
Flow<String> that emits one token at a time. Collect the flow to build up the full response incrementally.
cancelVLMGeneration
Model State
Model Registration
Examples
Jetpack Compose with Image Picker
A complete example showing image selection, VLM processing, and streaming token display:Batch Image Description
Error Handling
Supported Models
Performance Tips
Related
LLM Generation
Text-only generation
LLM Streaming
Streaming text generation
Tool Calling
Function calling with LLMs
Best Practices
Performance optimization