LiteRT-LM ist ein produktionsreifes Open-Source-Inferenz-Framework, das für leistungsstarke, plattformübergreifende LLM-Bereitstellungen auf Edge-Geräten entwickelt wurde.
- Plattformübergreifende Unterstützung:Ausführung auf Android, iOS, Web, Desktop und IoT (z.B. Raspberry Pi).
- Hardwarebeschleunigung:Durch die Nutzung von GPU- und NPU-Beschleunigern auf verschiedenen Hardwaretypen können Sie maximale Leistung und Systemstabilität erzielen.
- Multimodale Funktionen:Nutzen Sie LLMs, die Bild- und Audioeingaben unterstützen.
- Tool-Nutzung:Unterstützung von Funktionsaufrufen für agentische Workflows mit eingeschränkter Dekodierung für eine höhere Genauigkeit.
- Breite Modellunterstützung:Führen Sie Gemma, Llama, Phi-4, Qwen und weitere Modelle aus.
Generative KI auf dem Gerät – Showcase
Die Google AI Edge-Galerie ist eine experimentelle App, die entwickelt wurde, um generative KI-Funktionen auf dem Gerät zu demonstrieren, die vollständig offline mit LiteRT-LM ausgeführt werden.
- Google Play: LLMs lokal auf unterstützten Android-Geräten verwenden
- App Store: On-Device-KI auf Ihrem iOS-Gerät nutzen
- GitHub-Quelle: Hier können Sie sich den Quellcode für die Galerie-App ansehen, um zu erfahren, wie Sie LiteRT-LM in Ihre eigenen Projekte einbinden.
Vorgestelltes Modell: Gemma-4-E2B
- Modellgröße: 2,58 GB
Weitere technische Details finden Sie auf der HuggingFace-Modellkarte.
Plattform (Gerät) Backend Vorausfüllen (tk/s) Decodieren (tk/s) Zeit bis zum ersten Token (Sekunden) Spitzenwert des CPU-Arbeitsspeichers (MB) Android (S26 Ultra) CPU 557 47 1.8 1733 GPU 3808 52 0,3 676 iOS (iPhone 17 Pro) CPU 532 25 1.9 607 GPU 2878 56 0,3 1.450 Linux (Arm 2,3 und 2,8 GHz, NVIDIA GeForce RTX 4090) CPU 260 35 4 1628 GPU 11234 143 0,1 913 macOS (MacBook Pro M4) CPU 901 42 1.1 736 GPU 7835 160 0,1 1623 IoT (Raspberry Pi 5 16 GB) CPU 133 8 7.8 1546
Ihre erste eigene App
Die folgenden Snippets zeigen, wie Sie mit der LiteRT-LM-Befehlszeile sowie den Python-, Kotlin- und C++-APIs beginnen.
Befehlszeile
litert-lm run model.litertlm --prompt="What is the capital of France?"
Python
engine = litert_lm.Engine("model.litertlm")
with engine.create_conversation() as conversation:
response = conversation.send_message("What is the capital of France?")
print(f"Response: {response['content'][0]['text']}")
Kotlin
val engineConfig = EngineConfig(
modelPath = "/path/to/your/model.litertlm",
backend = Backend.CPU(),
)
val engine = Engine(engineConfig)
engine.initialize()
val conversation = engine.createConversation()
print(conversation.sendMessage("What is the capital of France?"))
C++
auto model_assets = ModelAssets::Create(model_path);
CHECK_OK(model_assets);
auto engine_settings = EngineSettings::CreateDefault(
model_assets,
/*backend=*/litert::lm::Backend::CPU);
absl::StatusOr<std::unique_ptr<Engine>> engine = Engine::CreateEngine(engine_settings);
CHECK_OK(engine);
auto conversation_config = ConversationConfig::CreateDefault(**engine);
CHECK_OK(conversation_config);
absl::StatusOr<std::unique_ptr<Conversation>> conversation = Conversation::Create(**engine, *conversation_config);
CHECK_OK(conversation);
absl::StatusOr<Message> model_message = (*conversation)->SendMessage(
JsonMessage{
{"role", "user"},
{"content", "What is the capital of France?"}
});
CHECK_OK(model_message);
std::cout << *model_message << std::endl;
| Sprache | Status | Optimal für… | Dokumentation |
|---|---|---|---|
| CLI | 🚀 Frühe Vorabversion |
Erste Schritte mit LiteRT-LM in weniger als einer Minute | CLI-Leitfaden |
| Python | ✅ Stabil |
Rapid Prototyping, Entwicklung auf Desktop-PCs und Raspberry Pi. | Python-Leitfaden |
| Kotlin | ✅ Stabil |
Native Android-Apps und JVM-basierte Desktop-Tools. Für Coroutinen optimiert. | Anleitung für Android (Kotlin) |
| C++ | ✅ Stabil |
Plattformübergreifende Kernlogik und eingebettete Systeme mit hoher Leistung. | C++-Leitfaden |
| Swift | 🚀 In der Entwicklung |
Native iOS- und macOS-Integration mit spezieller Metal-Unterstützung. | Demnächst verfügbar |
Unterstützte Back-Ends und Plattformen
| Beschleunigung | Android | iOS | macOS | Windows | Linux | IoT |
|---|---|---|---|---|---|---|
| CPU | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| GPU | ✅ | ✅ | ✅ | ✅ | ✅ | - |
| NPU | ✅ | - | - | - | - | - |
Unterstützte Modelle
In der folgenden Tabelle sind die von LiteRT-LM unterstützten Modelle aufgeführt. Detailliertere Leistungszahlen und Modellkarten finden Sie in der LiteRT-Community auf Hugging Face.
| Modell | Typ | Größe (MB) | Details | Gerät | CPU-Prefill (tk/s) | CPU-Decodierung (tk/s) | GPU-Prefill (tk/s) | GPU-Decodierung (tk/s) |
|---|---|---|---|---|---|---|---|---|
| Gemma4-E2B | Chat | 2583 | Modellkarte | Samsung S26 Ultra | 557 | 47 | 3808 | 52 |
| iPhone 17 Pro | 532 | 25 | 2878 | 57 | ||||
| MacBook Pro M4 | 901 | 42 | 7835 | 160 | ||||
| Gemma4-E4B | Chat | 3654 | Modellkarte | Samsung S26 Ultra | 195 | 18 | 1293 | 22 |
| iPhone 17 Pro | 159 | 10 | 1189 | 25 | ||||
| MacBook Pro M4 | 277 | 27 | 2.560 | 101 | ||||
| Gemma-3n-E2B | Chat | 2965 | Modellkarte | MacBook Pro M3 | 233 | 28 | - | - |
| Samsung S24 Ultra | 111 | 16 | 816 | 16 | ||||
| Gemma-3n-E4B | Chat | 4235 | Modellkarte | MacBook Pro M3 | 170 | 20 | - | - |
| Samsung S24 Ultra | 74 | 9 | 548 | 9 | ||||
| Gemma3-1B | Chat | 1005 | Modellkarte | Samsung S24 Ultra | 177 | 33 | 1191 | 24 |
| FunctionGemma | Basis | 289 | Modellkarte | Samsung S25 Ultra | 2238 | 154 | - | - |
| phi-4-mini | Chat | 3906 | Modellkarte | Samsung S24 Ultra | 67 | 7 | 314 | 10 |
| Qwen2.5-1.5B | Chat | 1598 | Modellkarte | Samsung S25 Ultra | 298 | 34 | 1668 | 31 |
| Qwen3-0.6B | Chat | 586 | Modellkarte | Vivo X300 Pro | 165 | 9 | 580 | 21 |
| Qwen2.5-0.5B | Chat | 521 | Modellkarte | Samsung S24 Ultra | 251 | 30 | - | - |
Probleme bei der Berichterstellung
Wenn Sie auf einen Fehler stoßen oder einen Feature Request haben, melden Sie ihn unter LiteRT-LM GitHub Issues.