能力标签
React Native LiteRT-LM
🛠
AI工具

React Native LiteRT-LM

基于 C++ · 开源免费,本地部署,数据完全自主可控
英文名:react-native-litert-lm
⭐ 31 Stars 🍴 10 Forks 💻 C++ 📄 MIT 🏷 AI 7.5分
7.5AI 综合评分
androidexpoios
✦ AI Skill Hub 推荐

AI Skill Hub 推荐使用:React Native LiteRT-LM 是一款优质的AI工具。AI 综合评分 7.5 分,在同类工具中表现稳健。如果你正在寻找可靠的AI工具解决方案,这是一个值得深入了解的选择。

📚 深度解析

React Native LiteRT-LM 是一款基于 C++ 的开源工具,在 GitHub 上收获 0k+ Star,是android、expo、ios领域中的优质开源项目。开源工具的最大优势在于代码完全透明,你可以审计每一行代码的安全性,也可以根据自身需求进行二次开发和定制。

**为什么要使用开源工具而非商业 SaaS?**
对于个人开发者和有隐私需求的用户,本地部署的开源工具意味着数据不离本机,不受第三方服务商的数据政策约束。同时,开源工具通常没有使用次数限制和月度费用,一次安装即可长期使用,对于高频使用场景的总拥有成本(TCO)远低于订阅制商业工具。

**安装与环境准备**
React Native LiteRT-LM 依赖 C++ 运行环境。建议通过 pyenv(Python)或 nvm(Node.js)管理 C++ 版本,避免全局环境污染。对于新手用户,推荐先创建虚拟环境(python -m venv venv && source venv/bin/activate),再安装依赖,这样即使出现问题也可以随时删除虚拟环境重新开始,不影响系统稳定性。

**社区与维护**
GitHub Issue 和 Discussion 是获取帮助的最快渠道。在提问前建议先检查 Closed Issues(已关闭的问题),大多数常见问题都已有解答。遇到 Bug 时,提供 pip list 的输出、完整错误堆栈和最小可复现示例,能显著提高开发者响应速度。AI Skill Hub 将持续追踪 React Native LiteRT-LM 的版本更新,及时通知重要功能变化。

📋 工具概览

高性能的React Native设备内LLM推理工具,使用LiteRT-LM技术。提供快速、轻量级的AI推理解决方案,适用于移动应用开发。

React Native LiteRT-LM 是一款基于 C++ 开发的开源工具,专注于 android、expo、ios 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

GitHub Stars
⭐ 31
开发语言
C++
支持平台
Windows / macOS / Linux
维护状态
轻量级项目,按需更新
开源协议
MIT
AI 综合评分
7.5 分
工具类型
AI工具
Forks
10

📖 中文文档

以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

高性能的React Native设备内LLM推理工具,使用LiteRT-LM技术。提供快速、轻量级的AI推理解决方案,适用于移动应用开发。

React Native LiteRT-LM 是一款基于 C++ 开发的开源工具,专注于 android、expo、ios 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

📌 核心特色
  • 开源免费,支持本地部署,数据完全自主可控
  • 活跃的 GitHub 开源社区,持续迭代更新
  • 提供详细文档和使用示例,新手友好
  • 支持自定义配置,灵活适配不同使用环境
  • 可作为基础组件集成进现有技术栈或进行二次开发
🎯 主要使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 克隆仓库
git clone https://github.com/hung-yueh/react-native-litert-lm
cd react-native-litert-lm

# 查看安装说明
cat README.md

# 按 README 完成环境依赖安装后即可使用
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 查看帮助
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"
📑 README 深度解析 真实文档 完整度 87/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

react-native-litert-lm

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.

Features

  • 🚀 Native Swift Bridge (iOS) — Bypasses Swift actor deadlocks (User Rule #1) via direct C FFI dispatched on a serial dev.litert.engine background queue.
  • 🤖 Stateless Kotlin Bridge (Android) — Fully conforms to HybridLiteRTLMSpec using direct JSI memory access.
  • Zero-Copy Multimodal API — Native-owned ArrayBuffer mapping straight to FFI inputs for image/audio data without copy overhead (complying with User Rule #2).
  • 🧠 Speculative Decoding — Active multi-token prediction support with pre-flight model capability validation.
  • 🛠️ Function / Tool Calling — Native JSON-encoded schema specification support for structured outputs.
  • 🏎️ GPU Acceleration — Metal (iOS), OpenCL GPU delegate (Android, Pixel devices).
  • 🔄 Streaming Support — Non-blocking token-by-token callbacks.
  • 📊 Real Memory Tracking — OS-level memory metrics (RSS, native heap, available memory) via native APIs (complying with User Rule #3).
  • 📥 Automatic Model Download — Downloads models from URL with progress tracking and local caching.

iOS Feature Matrix

FeatureStatusNotes
Text inference (blocking)Direct FFI using dev.litert.engine background queue
Text inference (streaming)Token-by-token callbacks
CPU inferenceSafe fallback default
GPU inference (Metal/MPS)Supported via backend: 'gpu'
Model download with progressURLSession-based, cached in Caches/
Memory trackingReal-time Resident Set Size (RSS) tracking
Multi-turn conversationContext retained across turns
Multimodal (image/audio)Zero-copy ArrayBuffer mapping to FFI input buffers
Speculative DecodingDynamic capabilities check during model pre-load
Function / Tool CallingSupported via JSON-encoded schema specification

Requirements

DependencyVersion
React Native0.76+
react-native-nitro-modules0.35.0+
Android API26+ (ARM64)
iOS15.0+ (ARM64)
LiteRT-LM Engine0.12.0

Installation

npm install react-native-litert-lm react-native-nitro-modules

Example App

The example/ directory contains a fully functional test app with a dark-themed diagnostic UI that demonstrates:

  • Model downloading with progress tracking
  • Text inference (blocking and streaming)
  • Multi-turn conversation with context retention
  • Performance benchmarking (tokens/sec, latency)
  • Real-time memory tracking
  • Speculative decoding & tool calling settings toggles
  • Zero-copy multimodal inference loading images/audio directly into ArrayBuffers

Running the Example

  1. Build the library (compiles TypeScript to lib/):
   npm run build
   
  1. Install example dependencies:
   cd example
   npm install
   
  1. Create a development build and run:
   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.

Usage

Manual Usage

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();

`getMemoryUsage(): MemoryUsage`

Returns real OS-level memory usage.

Demo

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>

`createLLM(options?): LiteRTLM`

Creates a new LLM inference engine instance.

  • options.enableMemoryTracking — enable automatic memory snapshot recording
  • options.maxMemorySnapshots — max number of snapshots to retain (default: 256)

`loadModel(path, config?): Promise<void>`

Loads a model from a local path or HTTPS URL.

ParameterTypeDefaultDescription
pathstringAbsolute path to .litertlm or HTTPS URL
config.backendstring'cpu''cpu', 'gpu', or 'npu'
config.systemPromptstringSystem prompt for the model
config.temperaturenumber0.7Sampling temperature
config.topKnumber40Top-K sampling
config.topPnumber0.95Top-P (nucleus) sampling
config.maxTokensnumber1024Maximum generation length

Backend Options

BackendEngineSpeedNotes
'cpu'CPU inferenceSlowestAlways available on all devices
'gpu'Metal (iOS) / OpenCL (Android)FastiOS: always available. Android: requires OpenCL (Pixel only, not Samsung/Qualcomm)
'npu'NPU / Neural EngineFastestRequires 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. Use checkBackendSupport('gpu') to check before loading. The engine will throw a clear error if GPU is unsupported.

API Reference

Supported Models

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.

ConstantModelSizeMin RAMSource
GEMMA_4_E2B_ITGemma 4 E2B (Multimodal, IT)2.58 GB4 GB+HuggingFace
GEMMA_4_E4B_ITGemma 4 E4B (Higher Quality)3.65 GB6 GB+HuggingFace
GEMMA_3N_E2B_IT_INT4Gemma 3n E2B (Int4, Multimodal)~1.3 GB4 GB+litert.dev
Recommended: Use GEMMA_4_E2B_IT for most use cases — multimodal (text + vision + audio) and the best quality-to-size ratio. iOS Note: Models larger than ~2 GB require the com.apple.developer.kernel.extended-virtual-addressing entitlement. See iOS Entitlements below. Gemma 3n E2B (~1.3 GB) works without it.

Other compatible models (download .litertlm files manually from HuggingFace):

ModelSizeMin RAMNotes
Gemma 3 1B~1 GB4 GB+Smallest, fastest
Phi-4 Mini~2 GB4 GB+Microsoft's small LLM
Qwen 2.5 1.5B~1.5 GB4 GB+Multilingual

iOS FFI Architecture & Integration

The library uses a highly optimized Swift Direct-FFI bridge that links directly with the pre-compiled C library CLiteRTLM.xcframework.

🇨🇳 中文文档镜像 AI 翻译 2026-05-30
英文原文章节由系统翻译为中文摘要,便于快速理解。完整原文见上方 "📑 README 深度解析"。
📌 简介

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。

🛠 安装步骤(Docker/pip/源码)

可以通过 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 的配置切换。

⚙️ 配置说明(含 MCP / env)

通过 `createLLM(options?)` 函数创建推理引擎实例。支持 `options.enableMemoryTracking` 参数来开启自动内存快照记录,并可通过 `maxMemorySnapshots` 设置保留的最大快照数量(默认 256)。在 `loadModel` 时,可以通过 `config.backend` 指定运行后端,可选值为 'cpu'、'gpu' 或 'npu'。

🔌 API 说明

核心 API 包含 `createLLM` 用于初始化引擎,以及 `loadModel(path, config?)` 用于从本地路径或 HTTPS URL 加载模型。该 API 支持通过配置指定后端硬件加速,并能处理模型文件的自动下载与缓存。

🔄 工作流/模块

本项目支持多种模型加载工作流。所有导出的模型 URL 均为公开资源,无需身份验证。开发者可以直接将 URL 传递给 `useModel()` 或 `loadModel()`,系统会自动完成下载、进度追踪及本地缓存管理。iOS 端采用高度优化的 Swift Direct-FFI 架构,直接链接至预编译的 `CLiteRTLM.xcframework`。

🎯 aiskill88 AI 点评 A 级 2026-05-30

该项目提供了高性能的LLM推理解决方案,适用于React Native应用开发,但需要进一步优化和测试。

📚 实用指南(长尾问题)
适合谁
  • 需要 react-native-litert-lm 解决具体问题的开发者与运营人员
最佳实践
  • 先在测试环境跑通最小用例,再接入生产数据
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
部署方案
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
react-native-litert-lm 中文教程react-native-litert-lm 安装报错怎么办react-native-litert-lm 与同类工具对比react-native-litert-lm 最佳实践react-native-litert-lm 适合谁用

⚡ 核心功能

👥 适合谁
  • 需要 react-native-litert-lm 解决具体问题的开发者与运营人员
⭐ 最佳实践
  • 先在测试环境跑通最小用例,再接入生产数据
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)

👥 适合人群

AI 技术爱好者研究人员和学生开发者和工程师技术创业者

🎯 使用场景

  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发

⚖️ 优点与不足

✅ 优点
  • +MIT 协议,可免费商用
  • +完全开源免费,无授权费用
  • +本地部署,数据完全自主可控
  • +开发者社区支持,遇问题可查可问
⚠️ 不足
  • 安装和初始配置可能需要一定技术基础
  • 功能完整性通常不如成熟商业产品
  • 技术支持主要依赖开源社区,响应速度不稳定
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。

🔗 相关工具推荐

📰 相关 AI 新闻
🗺️ 相关解决方案
🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合

❓ 常见问题 FAQ

react-native-litert-lm 是一款C++开发的AI辅助工具。开源AI工具:High-performance on-device LLM inference for React Native, powered by LiteRT-LM 。⭐31 · C++ 主要应用场景包括:在React Native应用中使用LiteRT-LM进行高性能的LLM推理,适用于移动应用开发。。
💡 AI Skill Hub 点评

总体来看,React Native LiteRT-LM 是一款质量良好的AI工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。

📚 深入学习 React Native LiteRT-LM
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 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++
🔗 原始来源
🐙 GitHub 仓库  https://github.com/hung-yueh/react-native-litert-lm

收录时间:2026-05-30 · 更新时间:2026-05-30 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。