llmedge is a powerful Android library designed for seamless on-device AI inference. It supports GGUF language models and integrates various AI features including speech-to-text, text-to-speech, image generation, and more, all while optimized for mobile performance.
llmedge is a lightweight and efficient Android library designed for running GGUF language models directly on-device, leveraging the power of llama.cpp. This library enables various AI functionalities including language inference, speech transcription, text-to-speech synthesis, and image generation, all while ensuring enhanced performance and memory management suitable for mobile devices.
The library can be utilized through the LLMEdgeManager singleton, which manages model loading, threading, and caching operations. Here’s how to generate text using a pre-trained model:
CoroutineScope(Dispatchers.IO).launch {
val reply = LLMEdgeManager.generateText(
context = context,
params = LLMEdgeManager.TextGenerationParams(
prompt = "Summarize on-device LLMs in one sentence."
)
)
withContext(Dispatchers.Main) {
outputView.text = reply
}
}
val text = LLMEdgeManager.transcribeAudioToText(
context = context,
audioSamples = audioSamples
)
val audio = LLMEdgeManager.synthesizeSpeech(
context = context,
params = LLMEdgeManager.SpeechSynthesisParams(
text = "Hello, world!"
)
)
val description = LLMEdgeManager.analyzeImage(
context = context,
params = LLMEdgeManager.VisionAnalysisParams(
image = bitmap,
prompt = "Describe this image in detail."
)
)
val frames = LLMEdgeManager.generateVideo(
context = context,
params = VideoGenerationParams(
prompt = "a cat walking in a garden, high quality",
videoFrames = 8
)
)
While powerful, llmedge is currently in the early stages of development and features may evolve significantly. For further insights and examples, refer to the examples repository where sample usages and implementation details are showcased.
No comments yet.
Sign in to be the first to comment.