Leuconoe/LiteRT-LM-Unity

Unity integration for running LiteRT-LM locally, including Windows Editor tests, Android GPU/OpenCL acceleration, function-calling benchmarks, and a patch-based custom AAR build workflow.

6

stars

1

commits

C#

primary language

Jul 29, 2026

updated

README

LiteRT-LM-Unity

Unity integration for on-device AI on Android. Runs LLM chat, speech recognition (ASR), image understanding and function calling entirely on the device, with no network.

  • LiteRT-LM v0.14.0 (.litertlm 1.5.0); customizations live in Tools/UnityAar/litert-lm-unity-aar.patch
  • Device-verified on Snapdragon 865 / 7.5 GB RAM / Android 12 — all four capabilities PASS across 6 PDCA cycles, 80+ runs, zero crashes (ledger)
  • Published models: whisper-acft · whisper-acft-ko · litert-lm-unity-quantized

Capabilities (measured on device)

CapabilitySpeedHit rateModel
LLM chat35.5 tok/sQwen2.5-0.5B i4
Speech recognition0.7–0.8 s4/5whisper-base-acft-ko 5s
Image understanding7.6 s (GPU)accurategemma-4-E2B QAT
Function calling15.5 s E2E (voice → tool)19/20gemma-4-E2B / Qwen3-0.6B

Requirements

Unity 2022.3 or newer (developed and device-verified on 6000.4.6f1) + Android Build Support · Android device (adb, Snapdragon 865 class or better, 4 GB+ RAM) · Windows PowerShell (build scripts) · Docker (only to rebuild the AAR)

Install

The runtime ships as a UPM package, com.leuconoe.litert-lm-unity. In Package Manager choose Add package from git URL… and paste:

https://github.com/Leuconoe/LiteRT-LM-Unity.git?path=/Packages/com.leuconoe.litert-lm-unity

Or add the line yourself to Packages/manifest.json:

{
  "dependencies": {
    "com.leuconoe.litert-lm-unity": "https://github.com/Leuconoe/LiteRT-LM-Unity.git?path=/Packages/com.leuconoe.litert-lm-unity"
  }
}

Pin a release by appending a tag: …litert-lm-unity#v0.14.0a-unity. Git URL installs need git on PATH; the package carries a 31 MB Android AAR, so the first resolve takes a moment.

Samples — in Package Manager select LiteRT-LM for UnitySamples:

SampleContents
Test ScenesSeven hand-driven scenes (quick start, chat, ASR, multimodal, voice FC, multimodal FC, translate), the Android build menu and the scene generator
Automated TestsThree unattended scenes (Android smoke, conversation, FC benchmark) that run on load and write their results to Builds/Logs/

Import Test Scenes first; Automated Tests is only needed for regression runs.

Working in this repository instead of consuming the package? The samples live in Samples~/, which Unity does not compile. Import them once with:

.\Tools\Windows\Restore-LiteRtLmSamples.ps1

Quick Start

  1. Install the package and import the Test Scenes sample (above)
  2. Place models — pick from the tables below and put them under Assets/StreamingAssets/ (model files are not in the repository)
  3. Build the APK — Unity menu LiteRT-LM/Android/... or Tools/Windows/Tests/Build-LiteRtLmAndroid*.ps1
  4. Smoke testRun-LiteRtLmAndroidAsrSmokeTest.ps1 -DeviceSerial <serial>; results land in Builds/Logs/AndroidDeviceRuns/

Package layout

PathContents
Packages/com.leuconoe.litert-lm-unity/Runtime/LiteRtLmUnityClient (Android bridge), LiteRtLmMicVadCapture, LiteRtLmStatusHudOverlay, LiteRtLmWindowsCliClient, and the native AAR
Packages/com.leuconoe.litert-lm-unity/Samples~/TestScenes/Scene runners, the seven hand-driven scenes, the APK build menu and the scene generator
Packages/com.leuconoe.litert-lm-unity/Samples~/AutomatedTests/Smoke, conversation and function-calling benchmark scenes
Assets/StreamingAssets/Where you place models (not in the repository)
Tools/Windows/Build and workflow scripts · Bin/ prebuilt runtime · Tests/ device and smoke runners
Tools/Research/Conversion and benchmark drivers behind the numbers in docs/
docs/Benchmarks and handoffs

LLM — pick by device RAM

Device RAMModelSizeMeasured on deviceDownload
4–6 GBLLM/qwen2.5-0.5b/…_wi4b64_ekv1280.litertlm265 MB35.5 tok/s — chat only (not usable as an FC router)project int4 (upstream f32)
6–8 GBLLM/qwen3-0.6b/qwen3_0_6b_mixed_int4.litertlm475 MB20.9 tok/s, FC 18/20litert-community/Qwen3-0.6B
8 GB+Multimodal/gemma-4-e2b/gemma-4-E2B-it.litertlm2.6 GBFC 19/20, image 7.6 s, audio 4.1 s; image turns peak at 3.6 GB PSSlitert-community/gemma-4-E2B-it-litert-lm

LFM2.5-1.2B int4 (702 MB, 16.8 tok/s, FC 17/20) is also available as a mid-size FC router. Use CPU for chat (decode) and GPU for long prompts and images. LLM details →

ASR — pick by utterance length (one model is usually enough)

Utterance lengthModelSizeMeasured on deviceDownload
≤5 s (commands, short sentences)ASR/whisper-base-acft-ko/acft_base_5s_drq.tflite101 MB0.7–0.8 s, 4/5 exactleuconoe/whisper-acft-ko
5–30 s (dictation)ASR/whisper-base/whisper_base_30s_i8.tflite77 MB2.7 s, sentence CER 0.000project i8 (upstream f32)
>30 s (batch)ASR/qwen3-asr-0.6b/qwen3_asr_0.6b_5s_i8.tflite794 MBchunk loop, RTF ≈2.6Qwen/Qwen3-ASR-0.6B

All 10 tiers, selection rationale, ACFT training background →

Test scenes

Shipped as the package's Test Scenes sample; after import they land under Assets/Samples/LiteRT-LM for Unity/<version>/Test Scenes/Scenes/. Regenerate them with the menu LiteRT-LM/Test Scenes/Generate All — scene paths resolve from the import location, so no path editing is needed.

Every scene shows a ◀ Prev / Next ▶ bar so the set can be walked through on a device. Each switch releases the loaded model first — engines hold native memory the GC does not track, so the outgoing one is disposed before the next loads rather than both being resident.

ScenePurpose
LiteRtLmSampleSceneQuick start — model path, one prompt, one response
LiteRtLmLlmChatTestSceneMulti-turn chat, think/no_think toggle
LiteRtLmAsrTestSceneASR — file / microphone / always-listening (Continuous)
LiteRtLmMultimodalTestSceneImage + audio input, with a file picker on Windows
LiteRtLmAsrFunctionCallingTestSceneVoice → tool call (15.5 s), editable prompt and tool list
LiteRtLmMultimodalFunctionCallingTestSceneImage + utterance → tool call (40.7 s)
LiteRtLmTranslateTestSceneTranslation — Whisper Direct / ASR+LLM

The Automated Tests sample adds LiteRtLmAndroidSmokeTestScene, LiteRtLmConversationTestScene and LiteRtLmFunctionCallingBenchmarkScene. These start on load and report through an on-screen overlay, so a device run needs no interaction.

Windows runs the same scenes through the bundled CLI binaries, so ASR, translation, multimodal and function calling can all be exercised in the editor before an APK build.

Rebuilding the AAR (after native changes)

Tools/Windows/Build-LiteRtLmUnityAarFromPatch.ps1 -SourceRoot <pristine v0.14.0> applies the patch, builds in Docker and deploys to Packages/com.leuconoe.litert-lm-unity/Runtime/Plugins/Android/.

⚠️ -SkipImageBuild builds the sources baked into the Docker image, so the image must be rebuilt after any patch change.

Docs

DocumentContents
docs/llm-details.mdLLM tiers, backend choice, device measurements
docs/asr-details.mdEvery ASR tier, VAD, ACFT-KO training background
docs/README.mdFull benchmark and handoff index

The Windows editor path exists only to validate logic before deploying to a device. Its performance profile is the opposite of Android's (GPU wins there), so never use desktop numbers to make device decisions.

Contributors

Leuconoe

1 commits

Leuconoe/LiteRT-LM-Unity

Unity integration for running LiteRT-LM locally, including Windows Editor tests, Android GPU/OpenCL acceleration, function-calling benchmarks, and a patch-based custom AAR build workflow.

6

stars

1

commits

C#

primary language

Jul 29, 2026

updated

README

LiteRT-LM-Unity

Unity integration for on-device AI on Android. Runs LLM chat, speech recognition (ASR), image understanding and function calling entirely on the device, with no network.

  • LiteRT-LM v0.14.0 (.litertlm 1.5.0); customizations live in Tools/UnityAar/litert-lm-unity-aar.patch
  • Device-verified on Snapdragon 865 / 7.5 GB RAM / Android 12 — all four capabilities PASS across 6 PDCA cycles, 80+ runs, zero crashes (ledger)
  • Published models: whisper-acft · whisper-acft-ko · litert-lm-unity-quantized

Capabilities (measured on device)

CapabilitySpeedHit rateModel
LLM chat35.5 tok/sQwen2.5-0.5B i4
Speech recognition0.7–0.8 s4/5whisper-base-acft-ko 5s
Image understanding7.6 s (GPU)accurategemma-4-E2B QAT
Function calling15.5 s E2E (voice → tool)19/20gemma-4-E2B / Qwen3-0.6B

Requirements

Unity 2022.3 or newer (developed and device-verified on 6000.4.6f1) + Android Build Support · Android device (adb, Snapdragon 865 class or better, 4 GB+ RAM) · Windows PowerShell (build scripts) · Docker (only to rebuild the AAR)

Install

The runtime ships as a UPM package, com.leuconoe.litert-lm-unity. In Package Manager choose Add package from git URL… and paste:

https://github.com/Leuconoe/LiteRT-LM-Unity.git?path=/Packages/com.leuconoe.litert-lm-unity

Or add the line yourself to Packages/manifest.json:

{
  "dependencies": {
    "com.leuconoe.litert-lm-unity": "https://github.com/Leuconoe/LiteRT-LM-Unity.git?path=/Packages/com.leuconoe.litert-lm-unity"
  }
}

Pin a release by appending a tag: …litert-lm-unity#v0.14.0a-unity. Git URL installs need git on PATH; the package carries a 31 MB Android AAR, so the first resolve takes a moment.

Samples — in Package Manager select LiteRT-LM for UnitySamples:

SampleContents
Test ScenesSeven hand-driven scenes (quick start, chat, ASR, multimodal, voice FC, multimodal FC, translate), the Android build menu and the scene generator
Automated TestsThree unattended scenes (Android smoke, conversation, FC benchmark) that run on load and write their results to Builds/Logs/

Import Test Scenes first; Automated Tests is only needed for regression runs.

Working in this repository instead of consuming the package? The samples live in Samples~/, which Unity does not compile. Import them once with:

.\Tools\Windows\Restore-LiteRtLmSamples.ps1

Quick Start

  1. Install the package and import the Test Scenes sample (above)
  2. Place models — pick from the tables below and put them under Assets/StreamingAssets/ (model files are not in the repository)
  3. Build the APK — Unity menu LiteRT-LM/Android/... or Tools/Windows/Tests/Build-LiteRtLmAndroid*.ps1
  4. Smoke testRun-LiteRtLmAndroidAsrSmokeTest.ps1 -DeviceSerial <serial>; results land in Builds/Logs/AndroidDeviceRuns/

Package layout

PathContents
Packages/com.leuconoe.litert-lm-unity/Runtime/LiteRtLmUnityClient (Android bridge), LiteRtLmMicVadCapture, LiteRtLmStatusHudOverlay, LiteRtLmWindowsCliClient, and the native AAR
Packages/com.leuconoe.litert-lm-unity/Samples~/TestScenes/Scene runners, the seven hand-driven scenes, the APK build menu and the scene generator
Packages/com.leuconoe.litert-lm-unity/Samples~/AutomatedTests/Smoke, conversation and function-calling benchmark scenes
Assets/StreamingAssets/Where you place models (not in the repository)
Tools/Windows/Build and workflow scripts · Bin/ prebuilt runtime · Tests/ device and smoke runners
Tools/Research/Conversion and benchmark drivers behind the numbers in docs/
docs/Benchmarks and handoffs

LLM — pick by device RAM

Device RAMModelSizeMeasured on deviceDownload
4–6 GBLLM/qwen2.5-0.5b/…_wi4b64_ekv1280.litertlm265 MB35.5 tok/s — chat only (not usable as an FC router)project int4 (upstream f32)
6–8 GBLLM/qwen3-0.6b/qwen3_0_6b_mixed_int4.litertlm475 MB20.9 tok/s, FC 18/20litert-community/Qwen3-0.6B
8 GB+Multimodal/gemma-4-e2b/gemma-4-E2B-it.litertlm2.6 GBFC 19/20, image 7.6 s, audio 4.1 s; image turns peak at 3.6 GB PSSlitert-community/gemma-4-E2B-it-litert-lm

LFM2.5-1.2B int4 (702 MB, 16.8 tok/s, FC 17/20) is also available as a mid-size FC router. Use CPU for chat (decode) and GPU for long prompts and images. LLM details →

ASR — pick by utterance length (one model is usually enough)

Utterance lengthModelSizeMeasured on deviceDownload
≤5 s (commands, short sentences)ASR/whisper-base-acft-ko/acft_base_5s_drq.tflite101 MB0.7–0.8 s, 4/5 exactleuconoe/whisper-acft-ko
5–30 s (dictation)ASR/whisper-base/whisper_base_30s_i8.tflite77 MB2.7 s, sentence CER 0.000project i8 (upstream f32)
>30 s (batch)ASR/qwen3-asr-0.6b/qwen3_asr_0.6b_5s_i8.tflite794 MBchunk loop, RTF ≈2.6Qwen/Qwen3-ASR-0.6B

All 10 tiers, selection rationale, ACFT training background →

Test scenes

Shipped as the package's Test Scenes sample; after import they land under Assets/Samples/LiteRT-LM for Unity/<version>/Test Scenes/Scenes/. Regenerate them with the menu LiteRT-LM/Test Scenes/Generate All — scene paths resolve from the import location, so no path editing is needed.

Every scene shows a ◀ Prev / Next ▶ bar so the set can be walked through on a device. Each switch releases the loaded model first — engines hold native memory the GC does not track, so the outgoing one is disposed before the next loads rather than both being resident.

ScenePurpose
LiteRtLmSampleSceneQuick start — model path, one prompt, one response
LiteRtLmLlmChatTestSceneMulti-turn chat, think/no_think toggle
LiteRtLmAsrTestSceneASR — file / microphone / always-listening (Continuous)
LiteRtLmMultimodalTestSceneImage + audio input, with a file picker on Windows
LiteRtLmAsrFunctionCallingTestSceneVoice → tool call (15.5 s), editable prompt and tool list
LiteRtLmMultimodalFunctionCallingTestSceneImage + utterance → tool call (40.7 s)
LiteRtLmTranslateTestSceneTranslation — Whisper Direct / ASR+LLM

The Automated Tests sample adds LiteRtLmAndroidSmokeTestScene, LiteRtLmConversationTestScene and LiteRtLmFunctionCallingBenchmarkScene. These start on load and report through an on-screen overlay, so a device run needs no interaction.

Windows runs the same scenes through the bundled CLI binaries, so ASR, translation, multimodal and function calling can all be exercised in the editor before an APK build.

Rebuilding the AAR (after native changes)

Tools/Windows/Build-LiteRtLmUnityAarFromPatch.ps1 -SourceRoot <pristine v0.14.0> applies the patch, builds in Docker and deploys to Packages/com.leuconoe.litert-lm-unity/Runtime/Plugins/Android/.

⚠️ -SkipImageBuild builds the sources baked into the Docker image, so the image must be rebuilt after any patch change.

Docs

DocumentContents
docs/llm-details.mdLLM tiers, backend choice, device measurements
docs/asr-details.mdEvery ASR tier, VAD, ACFT-KO training background
docs/README.mdFull benchmark and handoff index

The Windows editor path exists only to validate logic before deploying to a device. Its performance profile is the opposite of Android's (GPU wins there), so never use desktop numbers to make device decisions.

Contributors

Leuconoe

1 commits

Languages

C#

72.3%

PowerShell

16.7%

Python

11.0%