AI Skill Hub 推荐使用:React Native LiteRT-LM 是一款优质的AI工具。AI 综合评分 7.5 分,在同类工具中表现稳健。如果你正在寻找可靠的AI工具解决方案,这是一个值得深入了解的选择。
高性能的React Native设备内LLM推理工具,使用LiteRT-LM技术。提供快速、轻量级的AI推理解决方案,适用于移动应用开发。
React Native LiteRT-LM 是一款基于 C++ 开发的开源工具,专注于 android、expo、ios 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
高性能的React Native设备内LLM推理工具,使用LiteRT-LM技术。提供快速、轻量级的AI推理解决方案,适用于移动应用开发。
React Native LiteRT-LM 是一款基于 C++ 开发的开源工具,专注于 android、expo、ios 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 克隆仓库 git clone https://github.com/hung-yueh/react-native-litert-lm cd react-native-litert-lm # 查看安装说明 cat README.md # 按 README 完成环境依赖安装后即可使用
# 查看帮助 react-native-litert-lm --help # 基本运行 react-native-litert-lm [options] <input> # 详细使用说明请查阅文档 # https://github.com/hung-yueh/react-native-litert-lm
# react-native-litert-lm 配置说明 # 查看配置选项 react-native-litert-lm --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export REACT_NATIVE_LITERT_LM_CONFIG="/path/to/config.yml"
High-performance on-device LLM inference for React Native, powered by LiteRT-LM and Nitro Modules. Optimized for Gemma 4 and other on-device language models.
dev.litert.engine background queue.HybridLiteRTLMSpec using direct JSI memory access.ArrayBuffer mapping straight to FFI inputs for image/audio data without copy overhead (complying with User Rule #2).| Feature | Status | Notes |
|---|---|---|
| Text inference (blocking) | ✅ | Direct FFI using dev.litert.engine background queue |
| Text inference (streaming) | ✅ | Token-by-token callbacks |
| CPU inference | ✅ | Safe fallback default |
| GPU inference (Metal/MPS) | ✅ | Supported via backend: 'gpu' |
| Model download with progress | ✅ | URLSession-based, cached in Caches/ |
| Memory tracking | ✅ | Real-time Resident Set Size (RSS) tracking |
| Multi-turn conversation | ✅ | Context retained across turns |
| Multimodal (image/audio) | ✅ | Zero-copy ArrayBuffer mapping to FFI input buffers |
| Speculative Decoding | ✅ | Dynamic capabilities check during model pre-load |
| Function / Tool Calling | ✅ | Supported via JSON-encoded schema specification |
| Dependency | Version |
|---|---|
| React Native | 0.76+ |
| react-native-nitro-modules | 0.35.0+ |
| Android API | 26+ (ARM64) |
| iOS | 15.0+ (ARM64) |
| LiteRT-LM Engine | 0.12.0 |
npm install react-native-litert-lm react-native-nitro-modules
The example/ directory contains a fully functional test app with a dark-themed diagnostic UI that demonstrates:
lib/): npm run build
cd example
npm install
npx expo prebuild --clean
npx expo run:android # Android
npx expo run:ios # iOS (pre-linked with CLiteRTLM.xcframework)
Note: If you change native code (Swift/Kotlin), you must run npx expo prebuild --clean again before rebuilding.
import { createLLM } from "react-native-litert-lm";
const llm = createLLM();
// Load a model from URL (auto-downloads) or local path
await llm.loadModel("https://example.com/model.litertlm", {
backend: "gpu",
systemPrompt: "You are a helpful assistant.",
});
// Generate a response
const response = await llm.sendMessage("What is the capital of France?");
console.log(response);
// Clean up
llm.close();
Returns real OS-level memory usage.
Gemma 4 E2B running on-device on a Samsung Galaxy S22 (Snapdragon 8 Gen 1, 4 GB RAM) — CPU backend, streaming inference.
<video src="https://github.com/user-attachments/assets/1da527ce-0432-4f8b-8899-474f81b2feea" width="300" controls></video>
Creates a new LLM inference engine instance.
options.enableMemoryTracking — enable automatic memory snapshot recordingoptions.maxMemorySnapshots — max number of snapshots to retain (default: 256)Loads a model from a local path or HTTPS URL.
| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Absolute path to .litertlm or HTTPS URL |
config.backend | string | 'cpu' | 'cpu', 'gpu', or 'npu' |
config.systemPrompt | string | — | System prompt for the model |
config.temperature | number | 0.7 | Sampling temperature |
config.topK | number | 40 | Top-K sampling |
config.topP | number | 0.95 | Top-P (nucleus) sampling |
config.maxTokens | number | 1024 | Maximum generation length |
| Backend | Engine | Speed | Notes |
|---|---|---|---|
'cpu' | CPU inference | Slowest | Always available on all devices |
'gpu' | Metal (iOS) / OpenCL (Android) | Fast | iOS: always available. Android: requires OpenCL (Pixel only, not Samsung/Qualcomm) |
'npu' | NPU / Neural Engine | Fastest | Requires supported hardware; experimental |
iOS: Both'cpu'and'gpu'(Metal) are supported. The engine automatically tries fallback backend combinations if the primary one fails. Android GPU: The GPU backend requires OpenCL, which is not available on most Samsung and Qualcomm devices. UsecheckBackendSupport('gpu')to check before loading. The engine will throw a clear error if GPU is unsupported.
All exported model URLs are public — no authentication required. Pass them directly to useModel() or loadModel() for automatic downloading with progress tracking and local caching.
| Constant | Model | Size | Min RAM | Source |
|---|---|---|---|---|
GEMMA_4_E2B_IT | Gemma 4 E2B (Multimodal, IT) | 2.58 GB | 4 GB+ | HuggingFace |
GEMMA_4_E4B_IT | Gemma 4 E4B (Higher Quality) | 3.65 GB | 6 GB+ | HuggingFace |
GEMMA_3N_E2B_IT_INT4 | Gemma 3n E2B (Int4, Multimodal) | ~1.3 GB | 4 GB+ | litert.dev |
Recommended: UseGEMMA_4_E2B_ITfor most use cases — multimodal (text + vision + audio) and the best quality-to-size ratio. iOS Note: Models larger than ~2 GB require thecom.apple.developer.kernel.extended-virtual-addressingentitlement. See iOS Entitlements below. Gemma 3n E2B (~1.3 GB) works without it.
Other compatible models (download .litertlm files manually from HuggingFace):
| Model | Size | Min RAM | Notes |
|---|---|---|---|
| Gemma 3 1B | ~1 GB | 4 GB+ | Smallest, fastest |
| Phi-4 Mini | ~2 GB | 4 GB+ | Microsoft's small LLM |
| Qwen 2.5 1.5B | ~1.5 GB | 4 GB+ | Multilingual |
The library uses a highly optimized Swift Direct-FFI bridge that links directly with the pre-compiled C library CLiteRTLM.xcframework.
react-native-litert-lm 是一个专为 React Native 设计的高性能端侧 LLM 推理库。它基于 LiteRT-LM 和 Nitro Modules 构建,针对 Gemma 4 及其他端侧语言模型进行了深度优化,旨在为移动端开发者提供流畅的本地 AI 推理体验。
本项目具备卓越的性能表现:在 iOS 端通过 Native Swift Bridge 实现直接 C FFI 调用,有效避免了 Swift actor 死锁;Android 端采用无状态 Kotlin Bridge 并通过 JSI 实现直接内存访问。此外,它支持 Zero-Copy Multimodal API,能够将图像或音频数据通过 ArrayBuffer 直接映射至 FFI 输入,实现零拷贝的多模态数据处理。
使用本项目需满足以下环境要求:React Native 版本需在 0.76+;必须安装 react-native-nitro-modules 0.35.0+;Android 端需 API 26+ (ARM64);iOS 端需 15.0+ (ARM64);底层 LiteRT-LM Engine 版本需为 0.12.0。
可以通过 npm 进行快速安装。首先在项目根目录执行 `npm install react-native-litert-lm react-native-nitro-modules`。如果是开发库本身,请先运行 `npm run build` 将 TypeScript 编译至 lib 目录。
项目提供了完整的 example 示例应用,包含一个深色主题的诊断 UI。开发者可以通过该示例演示模型下载(带进度追踪)、文本推理(支持阻塞与 Streaming 模式)、多轮对话上下文保留、性能基准测试(tokens/sec、延迟)、实时内存追踪以及 Speculative decoding 和 Tool calling 的配置切换。
通过 `createLLM(options?)` 函数创建推理引擎实例。支持 `options.enableMemoryTracking` 参数来开启自动内存快照记录,并可通过 `maxMemorySnapshots` 设置保留的最大快照数量(默认 256)。在 `loadModel` 时,可以通过 `config.backend` 指定运行后端,可选值为 'cpu'、'gpu' 或 'npu'。
核心 API 包含 `createLLM` 用于初始化引擎,以及 `loadModel(path, config?)` 用于从本地路径或 HTTPS URL 加载模型。该 API 支持通过配置指定后端硬件加速,并能处理模型文件的自动下载与缓存。
本项目支持多种模型加载工作流。所有导出的模型 URL 均为公开资源,无需身份验证。开发者可以直接将 URL 传递给 `useModel()` 或 `loadModel()`,系统会自动完成下载、进度追踪及本地缓存管理。iOS 端采用高度优化的 Swift Direct-FFI 架构,直接链接至预编译的 `CLiteRTLM.xcframework`。
该项目提供了高性能的LLM推理解决方案,适用于React Native应用开发,但需要进一步优化和测试。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
总体来看,React Native LiteRT-LM 是一款质量良好的AI工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。
| 原始名称 | react-native-litert-lm |
| 原始描述 | 开源AI工具:High-performance on-device LLM inference for React Native, powered by LiteRT-LM 。⭐31 · C++ |
| Topics | androidexpoios |
| GitHub | https://github.com/hung-yueh/react-native-litert-lm |
| License | MIT |
| 语言 | C++ |
收录时间:2026-05-30 · 更新时间:2026-05-30 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。