Skip to content

Commit

Permalink
[Doc] Add llama2 android documentation
Browse files Browse the repository at this point in the history
This patch adds llama2 android documentation.

Signed-off-by: Yelin Jeong <[email protected]>
  • Loading branch information
niley7464 committed Oct 7, 2024
1 parent ffcdce0 commit 158b757
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
5 changes: 5 additions & 0 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ This guide is suitable for normal application developers.

* __Android Platform Guide__: If you are going to build Android rootFS from scratch for NNStreamer, then refer to [this guide](https://github.com/nnstreamer/nnstreamer-example/tree/master/android/android_platform_guide.md).
This guide is _only_ suitable for Android platform developers or system guys.

Also, we provide a [single APK integration](https://github.com/nnstreamer/nnstreamer-android) of NNStreamer and ML API.
This application is a solution for on-device Machine Learning Operations (MLOps) and provides end-points to ML task.

* __Android App using MLOps Solution__: If you want to make an Android Application without dependencies such as `aar`, then refer to [this guide](/android/kotlin_app/README.md).
74 changes: 74 additions & 0 deletions android/kotlin_app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Android Application Examples using MLOps Solution

## Prerequisite

We assume that you already have experienced Android application developments with Android Studio.

* Host PC:
* OS: Ubuntu 20.04 / 22.04 x86_64 LTS
* Android Studio: Ubuntu version
* Target Device:
* CPU Architecture: ARM 64bit (aarch64)
* Android SDK: Min version 34
* [nnstreamer-android application](https://github.com/nnstreamer/nnstreamer-android/blob/main/documentation/getting_started.md#building-the-android-app-with-llama2) is installed.

## Build example

We provide Kotlin example which runs an LLM task.

#### Cloning the GitHub Repository

To build example application, you need to clone the repository.

```bash
$ git clone https://github.com/nnstreamer/nnstreamer-example

$ ls nnstreamer-example/android/kotlin_app/llama2/
app build.gradle.kts gradle gradle.properties gradlew gradlew.bat local.properties settings.gradle.kts
$ cd nnstreamer-example/android/kotlin_app/llama2
```

#### Building the Android App using Gradle

In the example application's directory, `Gradle Wrapper` files have already been generated. You can
build apk file as follows.

```bash
$ ./gradlew build

> Task :app:compileReleaseKotlin
...omitted...

$ find app -name "*.apk"
app/build/outputs/apk/debug/app-debug.apk
app/build/outputs/apk/release/app-release-unsigned.apk
```

##### Running the App on the Android Device

The Android device can use `adb` to install and run the app.

```bash
$ cd ${HOME}/Android/Sdk/platform-tools
$ ls adb
adb

$ ./adb devices
List of devices attached
R3CW90D8TNR device

$ ./adb install ${HOME}/nnstreamer-example/android/kotlin_app/llama2/app/build/outputs/apk/debug/app-debug.apk
Success

$ ./adb shell am start ai.nnstreamer.example.llama2/ai.nnstreamer.example.llama2.MainActivity
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=ai.nnstreamer.example.llama2/.MainActivity }
```
If you can see the same user interface as the following screenshot, the Android app has been
successfully installed and launched on the device.
![Android Device Ready](img/ready.jpeg)
If you enter the first part of the sentence in the input prompt and press the button, the llama2 model will complete the latter part.
![Android Device Run](img/run.jpeg)
Binary file added android/kotlin_app/img/ready.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/kotlin_app/img/run.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 158b757

Please sign in to comment.