picoLLM Inference Engine
Android Quick Start
Platforms
- Android (5.0+, API 21+)
Requirements
- Picovoice Account and AccessKey
- Android Studio
- Android device with USB debugging enabled or Android simulator
Picovoice Account & AccessKey
Signup or Login to Picovoice Console to get your AccessKey
.
Make sure to keep your AccessKey
secret.
Quick Start
Setup
Install Android Studio.
Include
mavenCentral()
repository in the top-levelbuild.gradle
. Then add the following to the app'sbuild.gradle
:
- Add the following to the app's
AndroidManifest.xml
file to enableAccessKey
validation:
Model File Deployment
picoLLM Inference Engine supports a variety of open-weight models The models are available for download on the Picovoice Console.
Android APKs have a size limit which does not allow for the direct inclusion of a picoLLM
model file (.pllm
) as a resource. To deploy a model file as part of an Android app, there are a few alternative options:
Include in App Bundle:
- Utilize Google Play's Dynamic Delivery feature to include the model file in your app bundle.
- Model file will be hosted on Google Play's servers and downloaded on-demand.
APK Expansion File (OBB File):
- Store the model file as an expansion file (OBB file) and upload it alongside your APK.
- Google Play will handle downloading the expansion file along with the APK.
Host Externally:
- Host the model file on a server or cloud storage service.
- Download the file from within the app.
ADB Push (for testing or manual installation):
- Use the Android Debug Bridge (ADB) command
adb push
to transfer the model file directly to a connected device. - Access the file programmatically within your app.
- Use the Android Debug Bridge (ADB) command
Usage
- Create an instance of the inference engine:
NOTE: Android 11+ cannot directly open files from external storage. To load model files from external storage, copy the model file to the application's directory and load it from there. For an example, take a look at Android Completion Demo.
- Generate a prompt completion:
- To interrupt completion generation before it has finished:
- When done, be sure to release the resources explicitly:
Demo
For the picoLLM Android SDK, we offer demo applications that demonstrate how to use it to generate text from a prompt or in a chat-based environment.
Setup
- Clone the picoLLM repository from GitHub using HTTPS:
- Connect an Android device via USB or launch an Android device simulator.
Usage
Open the Android Completion demo using Android Studio.
Copy your
AccessKey
from Picovoice Console into theACCESS_KEY
variable in MainActivity.java.Upload the picoLLM model file (
.pllm
) to your device using Android Studio's Device Explorer or usingadb push
:
- Build and run the app.
For more information on our picoLLM demo for Android or to see a chat-based demo, head over to our GitHub repository.