본문으로 건너뛰기
Skillpedia
모바일 앱10k · #11911

litert-lm

하는 일

이 스킬은 CPU나 GPU를 이용해 휴대폰에서 직접 텍스트 언어 모델을 실행하는 Android 앱을 만드는 방법을 안내합니다. 기기 안에서 바로 작동하는 채팅, 요약 또는 추출 기능을 추가하려는 Android 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓휴대폰에서 직접 실행되는 채팅이나 요약 기능을 Android 앱에 넣고 싶을 때.
  • ✓Hugging Face의 Gemma, Qwen, Llama 또는 Phi 같은 .litertlm 모델을 사용할 계획일 때.
  • ✓기기 내 언어 모델을 위해 Gradle 설정과 GPU 설정이 필요할 때.

스킬 링크

https://github.com/android/skills/blob/main/device-ai/litert/litert-lm/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/android/skills/blob/main/device-ai/litert/litert-lm/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“Gemma 모델을 사용해 내 Android 앱에 기기 내 채팅 기능을 추가해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 LiteRT-LM 라이브러리를 추가하고, 매니페스트에 GPU 항목을 설정하고, 기기 저장소의 모델 파일을 불러오는 과정을 안내합니다. 이후 앱에서 모델을 실행하는 방법을 보여 줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

This skill provides step-by-step guidance for building an Android app that runs an open text LLM through the LiteRT-LM Kotlin API (com.google.ai.edge.litertlm) on the CPU or the GPU. The model is one .litertlm file. Images, audio, tool calling, and NPU backends aren't covered. For vision and audio models with .tflite files, suggest the litert-runtime skill.

When a LiteRT-LM class or method that this skill uses doesn't compile, you must read the LiteRT-LM Android guide and the LiteRT-LM README before changing the code.

Prerequisites

  • A Kotlin Android project (the Android Studio Empty Activity template is enough). The litertlm-android 0.18.0 AAR declares minSdk 24.
  • The dependency in the app-level build.gradle.kts file from Google Maven: implementation("com.google.ai.edge.litertlm:litertlm-android:0.18.0"). Google Maven lists the later releases.
  • For the GPU backend, two uses-native-library entries inside <application> in AndroidManifest.xml. Add the INTERNET permission if the app downloads the model.
  • The model file lives on the device's file system (hundreds of MB to a few GB), never in assets/ or in the APK.

Critical mandates

  • Dependency first : Before writing code that imports com.google.ai.edge.litertlm, add the litertlm-android dependency from Step 1 if the project lacks it. Verify with ./gradlew assembleDebug.
  • Background initialization : Engine(config).initialize() loads the weights and blocks for seconds. Call it on a background thread, never on the main thread.
  • Single owner : One single-thread executor owns the Engine and the Conversation. Creation, streaming, cancellation, and closing run on it.
  • Close once : Engine and Conversation are AutoCloseable. A second close on either throws IllegalStateException. So does close on an engine whose initialize threw. Store the engine only after initialize returns.
  • Model outside the APK : Pass an absolute path to EngineConfig. Never bundle a .litertlm file in assets/.

Detailed steps

Step 1: Configure Gradle and the manifest

Search the project for libs.versions.toml, app/build.gradle.kts, and AndroidManifest.xml before editing build files. Configure minSdk and add the LiteRT-LM dependency in app/build.gradle.kts:

<br />
android {
    defaultConfig {
        minSdk = 24
    }
}

dependencies {
    implementation("com.google.ai.edge.litertlm:litertlm-android:0.18.0")
}

If the project uses Hilt, check the Dagger version first. litertlm-android 0.18.0 carries Kotlin 2.4 metadata, which Hilt 2.59.2 can't read. The build then fails in hiltJavaCompileDebug with Provided Metadata instance has version 2.4.0, while maximum supported version is 2.3.0. Pick one fix:

  • Path A : Upgrade the Hilt version (com.google.dagger) to 2.60.1 or later. Ask the user before editing gradle/libs.versions.toml.
  • Path B : Keep the Hilt version and add a later version of the metadata reader to the annotation processor path in app/build.gradle.kts:
<br />
dependencies {
    ksp("org.jetbrains.kotlin:kotlin-metadata-jvm:2.4.21")
}

For the GPU backend, add both lines inside <application> in AndroidManifest.xml. Add the INTERNET permission outside <application> when the app downloads the model:

<br />
<uses-permission android:name="android.permission.INTERNET"/>

<application>
    <uses-native-library
        android:name="libvndksupport.so"
        android:required="false"/>
    <uses-native-library
        android:name="libOpenCL.so"
        android:required="false"/>
</application>

Step 2: Pick a model from litert-community

Choose a .litertlm file from litert-community on Hugging Face. Start with litert-community/gemma-4-E2B-it-litert-lm (the file gemma-4-E2B-it.litertlm, 2.6 GB). For a 0.6 GB model, start with litert-community/Qwen3-0.6B (the file Qwen3-0.6B.litertlm). Both files run on the CPU and the GPU. A SoC suffix such as _Google_Tensor_G5 or .mediatek.mt6993 marks an NPU build, which this skill doesn't cover. The model card names the tested backends and the size.

You must read get a model before you choose a model file other than these two, before you writ

자주 묻는 질문

모델 파일을 앱 안에 넣을 수 있나요?

아니요. 모델 파일은 앱의 assets나 패키지가 아니라 기기 저장소에 있어야 합니다.

이미지나 오디오도 지원하나요?

아니요. 텍스트 모델만 다룹니다. 비전 모델과 오디오 모델은 다른 스킬에서 다룹니다.

어떤 모델과 함께 작동하나요?

.litertlm 형식의 공개 텍스트 모델, 예를 들어 Gemma, Qwen, Llama, Phi를 대상으로 합니다.

상세 정보

작성자의 원본 설명

Builds an Android app that runs an open text LLM on the device, on the CPU or the GPU, with the LiteRT-LM Kotlin API (com.google.ai.edge.litertlm:litertlm-android). Use this skill when creating a chat, summarization, or extraction feature with a .litertlm model from Hugging Face litert-community (Gemma, Qwen, Llama, Phi), including the Gradle dependency, the GPU manifest entries, getting the model file onto the device, Engine initialization off the main thread, a streamed multi-turn Conversation with sendMessageAsync, and the AndroidViewModel and Compose screen. Don't use for running .tflite v

repo: android/skills

인기도

GitHub 스타
10k
순위
#11911
라이선스
Apache-2.0
업데이트
2026. 10. 29.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬