On-Device LLMs (Gemma/Phi-3) in Flutter-Apps mit MediaPipe LLM Inference API ausführen

On-Device KI ermöglicht die Ausführung von LLMs direkt auf dem Smartphone ohne Cloud-API-Aufrufe.
Googles MediaPipe LLM Inference API erlaubt die Ausführung von Gemma-2B und Phi-3-Mini in Flutter-Apps mit voller Offline-Funktionalität und 0 € Serverkosten.
Wichtige Punkte
- Vorteile: 100% offline, 0 € Serverkosten, maximale Privatsphäre, minimale Latenz.
- 4-Bit Quantisierung (int4): Reduziert den Speicherbedarf auf unter 1,5 GB RAM.
- Flutter-Integration: Anbindung von Native-Streams an
StreamBuilder.
1. Code-Beispiel in Flutter
class OnDeviceLlmService {
static const MethodChannel _channel = MethodChannel('dev.effidev.mediapipe_llm');
Future<void> initializeModel(String modelPath) async {
await _channel.invokeMethod('initModel', {'modelPath': modelPath});
}
}