1212
1313---
1414
15- LocalLLM is a React Native application that brings large language models, vision AI, and image generation directly to mobile devices. All inference runs entirely on-device using llama.cpp, whisper.cpp, and local-dream—no internet required after initial model download, no data transmission, complete privacy guaranteed.
15+ LocalLLM is a React Native application that brings large language models, vision AI, and image generation directly to ** Android and iOS** devices. All inference runs entirely on-device using llama.cpp, whisper.cpp, local-dream (Android), and Apple's Core ML (iOS)—no internet required after initial model download, no data transmission, complete privacy guaranteed.
16+
17+ ### Platform Support
18+
19+ | Feature | Android | iOS |
20+ | ---------| ---------| -----|
21+ | Text Generation (GGUF) | llama.cpp (CPU + OpenCL GPU) | llama.cpp (CPU + Metal) |
22+ | Vision AI | llama.rn multimodal | llama.rn multimodal |
23+ | Image Generation | local-dream (MNN/QNN) | Core ML (ANE + CPU) |
24+ | Voice Transcription | whisper.cpp | whisper.cpp |
25+ | Background Downloads | Native DownloadManager | RNFS / URLSession |
1626
1727---
1828
@@ -79,27 +89,39 @@ Multimodal understanding via vision-language models (VLMs) with automatic mmproj
7989
8090### Image Generation
8191
82- On-device Stable Diffusion using local-dream with MNN (CPU) and QNN (NPU) backends :
92+ On-device Stable Diffusion with platform-native acceleration :
8393
94+ ** Android:**
8495- ** MNN backend** - Alibaba's MNN framework, works on all ARM64 devices (CPU-only)
8596- ** QNN backend** - Qualcomm AI Engine (NPU acceleration) for Snapdragon 8 Gen 1+
8697- ** Automatic backend detection** - Runtime NPU detection with MNN fallback
98+ - Models from xororz's HuggingFace repos (pre-converted MNN/QNN formats)
99+
100+ ** iOS:**
101+ - ** Core ML backend** - Apple's ml-stable-diffusion pipeline with Neural Engine (ANE) acceleration
102+ - ** DPM-Solver scheduler** - Faster convergence, better quality at fewer steps
103+ - ** Safety checker disabled** - Reduced latency (no NSFW classification overhead)
104+ - ** Palettized models** - 6-bit quantized (~ 1GB) for memory-constrained devices
105+ - ** Full precision models** - fp16 (~ 4GB) for maximum speed on ANE
106+ - Models from Apple's official HuggingFace repos (compiled Core ML format)
107+
108+ ** Common:**
87109- ** Real-time preview** - Progressive image display every N steps
88110- ** Background generation** - Lifecycle-independent service continues when screens unmount
89111- ** AI prompt enhancement** - Optional LLM-based prompt expansion using loaded text model
90112
91113** Technical Pipeline:**
92114```
93115Text Prompt → CLIP Tokenizer → Text Encoder (embeddings)
94- → Scheduler (Euler) ↔ UNet (denoising, iterative)
116+ → Scheduler (DPM-Solver/ Euler) ↔ UNet (denoising, iterative)
95117 → VAE Decoder → 512×512 Image
96118```
97119
98120** Implementation:**
99- - ` localDreamGeneratorService ` (` src/services/localDreamGenerator.ts ` ) bridges to native
121+ - ` localDreamGeneratorService ` (` src/services/localDreamGenerator.ts ` ) bridges to native via ` Platform.select() `
100122- ` imageGenerationService ` (` src/services/imageGenerationService.ts ` ) provides orchestration
101- - Native module ( ` android/app/src/main/java/com/localllm/localdream/ ` ) wraps local-dream C++ lib
102- - Models fetched from xororz 's HuggingFace repos (pre-converted MNN/QNN formats )
123+ - Android: ` LocalDreamModule ` wraps local-dream C++ lib (MNN/QNN)
124+ - iOS: ` CoreMLDiffusionModule ` wraps Apple 's ` StableDiffusionPipeline ` (ANE/CPU )
103125- Progress callbacks, preview callbacks, and completion callbacks flow through singleton service
104126- Gallery persistence via AsyncStorage with automatic cleanup on conversation deletion
105127
@@ -120,14 +142,22 @@ When enabled, uses the currently loaded text model to expand simple prompts into
120142
121143Implementation uses separate message array with enhancement-specific system prompt, calls ` llmService.generateResponse() ` , then explicitly resets LLM state (` stopGeneration() ` only, no KV cache clear to preserve vision inference performance).
122144
123- ** Image Models:**
145+ ** Image Models (Android) :**
124146- CPU (MNN): 5 models (~ 1.2GB each) - Anything V5, Absolute Reality, QteaMix, ChilloutMix, CuteYukiMix
125147- NPU (QNN): 20 models (~ 1.0GB each) - all CPU models plus DreamShaper, Realistic Vision, MajicmixRealistic, etc.
126148- QNN variants: ` min ` (non-flagship), ` 8gen1 ` , ` 8gen2 ` (8 Gen 2/3/4/5)
127149
150+ ** Image Models (iOS - Core ML):**
151+ - SD 1.5 Palettized (~ 1GB) - 6-bit quantized, 512×512
152+ - SD 2.1 Palettized (~ 1GB) - 6-bit quantized, 512×512
153+ - SDXL iOS (~ 2GB) - 4-bit mixed-bit palettized, 768×768, ANE-optimized
154+ - SD 1.5 Full (~ 4GB) - fp16, 512×512, fastest on ANE
155+ - SD 2.1 Base Full (~ 4GB) - fp16, 512×512, fastest on ANE
156+
128157** Generation Performance:**
129- - CPU: ~ 15s for 512×512 @ 20 steps (Snapdragon 8 Gen 3)
130- - NPU: ~ 5-10s for 512×512 @ 20 steps (chipset-dependent)
158+ - Android CPU (MNN): ~ 15s for 512×512 @ 20 steps (Snapdragon 8 Gen 3)
159+ - Android NPU (QNN): ~ 5-10s for 512×512 @ 20 steps (chipset-dependent)
160+ - iOS ANE (Core ML): ~ 8-15s for 512×512 @ 20 steps (A17 Pro/M-series), palettized models ~ 2x slower due to dequantization
131161
132162### Voice Transcription
133163
@@ -297,19 +327,31 @@ device safe limit of 4.8GB. Unload current model or choose smaller."
297327│ │(singleton, mem mgmt)│ │(download, storage) │ │
298328│ └────────────────────┘ └────────────────────┘ │
299329├──────────────────────────────────────────────────────────────────┤
300- │ Native Module Bridge (JNI) │
330+ │ Native Module Bridge (JNI / ObjC) │
301331├──────────────────────────────────────────────────────────────────┤
302332│ Native Implementations: │
303- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌───────────────┐ │
304- │ │ llama.rn │ │whisper.rn│ │local-dream│ │DownloadManager│ │
305- │ │(C++ JNI) │ │(C++ JNI) │ │(C++/MNN) │ │ (Kotlin) │ │
306- │ └──────────┘ └──────────┘ └──────────┘ └───────────────┘ │
333+ │ │
334+ │ Cross-platform: │
335+ │ ┌──────────────┐ ┌──────────────┐ │
336+ │ │ llama.rn │ │ whisper.rn │ │
337+ │ │ (C++ native) │ │ (C++ native) │ │
338+ │ └──────────────┘ └──────────────┘ │
339+ │ │
340+ │ Android: iOS: │
341+ │ ┌──────────┐ ┌───────────────┐ ┌──────────────────────┐ │
342+ │ │local-dream│ │DownloadManager│ │CoreMLDiffusionModule │ │
343+ │ │(C++/MNN) │ │ (Kotlin) │ │(StableDiffusionPipe) │ │
344+ │ └──────────┘ └───────────────┘ └──────────────────────┘ │
307345├──────────────────────────────────────────────────────────────────┤
308346│ Hardware Acceleration: │
309- │ ┌──────────────────┐ ┌──────────────────┐ │
310- │ │OpenCL (Adreno GPU)│ │ QNN (NPU) │ │
311- │ │ Text LLMs only │ │ Image gen only │ │
312- │ └──────────────────┘ └──────────────────┘ │
347+ │ Android: iOS: │
348+ │ ┌──────────────────┐ ┌──────────────────┐ │
349+ │ │OpenCL (Adreno GPU)│ │ ANE (Neural Engine)│ │
350+ │ │ Text LLMs only │ │ Image gen + LLMs │ │
351+ │ ├──────────────────┤ ├──────────────────┤ │
352+ │ │ QNN (NPU) │ │ Metal (GPU) │ │
353+ │ │ Image gen only │ │ LLM inference │ │
354+ │ └──────────────────┘ └──────────────────┘ │
313355└──────────────────────────────────────────────────────────────────┘
314356```
315357
@@ -806,31 +848,39 @@ Prevents OOM crashes by blocking loads that would exceed safe RAM limits.
806848- **TypeScript 5.x** - Type safety and developer experience
807849- **llama.rn** - Native bindings for llama.cpp GGUF inference
808850- **whisper.rn** - Native bindings for whisper.cpp speech recognition
809- - **local-dream** - MNN/QNN Stable Diffusion implementation
851+ - **local-dream** - MNN/QNN Stable Diffusion implementation (Android)
852+ - **ml-stable-diffusion** - Apple' s Core ML Stable Diffusion pipeline (iOS)
810853- **Zustand 4.x** - Lightweight state management
811854- **AsyncStorage** - Persistent local storage
812855- **React Navigation 6.x** - Native navigation
813856
814857### Native Modules
815858
816- **llama.rn:**
817- - Compiles llama .cpp for ARM64 Android
818- - JNI bindings expose inference APIs to JavaScript
819- - Supports OpenCL GPU offloading on Adreno GPUs
859+ **llama.rn (Android + iOS) :**
860+ - Compiles llama .cpp for ARM64
861+ - Android : JNI bindings , OpenCL GPU offloading on Adreno GPUs
862+ - iOS: Metal GPU acceleration
820863- Handles multimodal (vision ) via mmproj
821864
822- ** whisper .rn :**
823- - Compiles whisper .cpp for ARM64 Android
865+ ** whisper .rn ( Android + iOS ) :**
866+ - Compiles whisper .cpp for ARM64
824867- Real - time audio recording and transcription
825868- Multiple model sizes (Tiny , Base , Small , Medium )
826869
827- ** local - dream :**
870+ ** local - dream ( Android only ) :**
828871- C ++ implementation of Stable Diffusion
829872- MNN backend (CPU , all ARM64 devices )
830873- QNN backend (NPU , Snapdragon 8 Gen 1 + )
831874- Automatic backend detection and fallback
832875
833- ** DownloadManager :**
876+ ** CoreMLDiffusionModule (iOS only ):**
877+ - Swift bridge to Apple ' s `ml-stable-diffusion` StableDiffusionPipeline
878+ - Neural Engine (ANE ) acceleration via ` .cpuAndNeuralEngine ` compute units
879+ - DPM - Solver multistep scheduler for faster convergence
880+ - Safety checker disabled for reduced latency
881+ - Supports palettized (6 - bit ) and full - precision (fp16 ) Core ML models
882+
883+ ** DownloadManager (Android only ):**
834884- Native Android DownloadManager wrapper
835885- Background download support
836886- Progress polling and event emission to React Native
@@ -861,10 +911,17 @@ For developers who want to build from source or contribute:
861911### Prerequisites
862912
863913- Node .js 18 +
914+ - React Native CLI
915+
916+ ** Android :**
864917- JDK 17
865918- Android SDK (API 34 )
866919- Android NDK r26
867- - React Native CLI
920+
921+ ** iOS :**
922+ - Xcode 15 + with iOS 17 SDK
923+ - CocoaPods
924+ - Apple Developer account (for device deployment )
868925
869926### Setup
870927
@@ -877,11 +934,10 @@ cd LocalLLM
877934npm install
878935
879936# Android setup
880- cd android
881- ./gradlew clean
937+ cd android && ./gradlew clean && cd ..
882938
883- # Return to root
884- cd ..
939+ # iOS setup
940+ cd ios && pod install && cd ..
885941` ` `
886942
887943### Development Build
@@ -890,22 +946,27 @@ cd ..
890946# Start Metro bundler
891947npm start
892948
893- # In separate terminal, deploy to device
949+ # Android ( separate terminal)
894950npm run android
895951
896- # Or use Android Studio
897- # Open android/ folder in Android Studio
898- # Build → Make Project
899- # Run → Run 'app'
952+ # iOS (separate terminal)
953+ npm run ios
954+
955+ # Or use Xcode
956+ # Open ios/LocalLLM.xcworkspace
957+ # Select target device → Build & Run
900958` ` `
901959
902960### Release Build
903961
904962` ` ` bash
963+ # Android
905964cd android
906965./gradlew assembleRelease
907-
908966# Output: android/app/build/outputs/apk/release/app-release.apk
967+
968+ # iOS
969+ # Open Xcode → Product → Archive → Distribute
909970` ` `
910971
911972### Signing Configuration
@@ -990,6 +1051,15 @@ LocalLLM/
9901051│ ├── localdream/ # local-dream native module
9911052│ │ └── LocalDreamModule.kt
9921053│ └── ...
1054+ ├── ios/ # iOS native code
1055+ │ └── LocalLLM/
1056+ │ ├── CoreMLDiffusion/ # Core ML image generation
1057+ │ │ ├── CoreMLDiffusionModule.swift
1058+ │ │ └── CoreMLDiffusionModule.m
1059+ │ ├── Download/ # iOS download manager
1060+ │ │ ├── DownloadManagerModule.swift
1061+ │ │ └── DownloadManagerModule.m
1062+ │ └── ...
9931063├── docs/ # Documentation
9941064│ ├── CODEBASE_GUIDE.md # Comprehensive architecture guide
9951065│ ├── DESIGN_PHILOSOPHY_SYSTEM.md # Design system reference
@@ -1133,7 +1203,8 @@ MIT License - See LICENSE file for details.
11331203
11341204- [llama .cpp ](https :// github.com/ggerganov/llama.cpp) by Georgi Gerganov - LLM inference engine
11351205- [whisper .cpp ](https :// github.com/ggerganov/whisper.cpp) by Georgi Gerganov - Speech recognition engine
1136- - [local - dream ](https :// github.com/nicenemo/local-dream) - On-device Stable Diffusion
1206+ - [local - dream ](https :// github.com/nicenemo/local-dream) - On-device Stable Diffusion (Android)
1207+ - [ml - stable - diffusion ](https :// github.com/apple/ml-stable-diffusion) by Apple - Core ML Stable Diffusion pipeline (iOS)
11371208- [MNN ](https :// github.com/alibaba/MNN) by Alibaba - Mobile neural network inference framework
11381209- [llama .rn ](https :// github.com/mybigday/llama.rn) by mybigday - React Native bindings for llama.cpp
11391210- [whisper .rn ](https :// github.com/mybigday/whisper.rn) by mybigday - React Native bindings for whisper.cpp
0 commit comments