react-native-executorch

software-mansion活跃维护

把 ExecuTorch 推理运行时封装进 React Native,让手机端直接跑 LLM、视觉、语音等模型,数据不出设备。

High-performance, privacy-first on-device AI inference library for React Native, powered by PyTorch's ExecuTorch runtime

v0.11.0发布于 2026-10-27 14:59 UTC1,788star102fork同步于 2026-11-10 11:46 UTC

怎么上手

由 README 提炼,执行前请确认
npm install react-native-executorch react-native-worklets react-native-blob-util
硬件要求按 README 说明

README 未给出具体显存或内存要求;支持 iOS 17.0+ 与 Android 8.0+(minSdkVersion >= 26),加速后端覆盖 CPU(XNNPACK)、Apple Silicon(Core ML、MLX)和 Android GPU(Vulkan)。

支持 Apple Silicon
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

在 React Native 里本地跑 AI 模型的推理库,基于 ExecuTorch,无需联网、数据不出设备

把 ExecuTorch 推理运行时封装进 React Native,让手机端直接跑 LLM、视觉、语音等模型,数据不出设备。

核心能力

  • 用 XNNPACK、Core ML、MLX、Vulkan 等后端做原生硬件加速
  • 提供 use<Task> 任务 Hook,覆盖 LLM、视觉、语音、嵌入并自动缓存
  • 支持加载自带 .pte 模型,用底层张量算子自建 TypeScript 流水线
  • 内置预导出模型目录,可从 Hugging Face 集合直接取用
  • 推理全程离线,模型下载后零网络依赖、零云端成本

容易踩的坑

必须启用 New Architecture,且需 React Native 0.83+ 或 Expo SDK 55+ 的 Development Builds,Expo Go 不支持;react-native-worklets 需 >=0.10.0 <0.14.0,并把 react-native-worklets/plugin 放在 Babel plugins 最后一项;预导出模型需联网下载,且默认会上报匿名下载事件,可用 setTelemetryEnabled(false) 关闭。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.11.0
  1. v0.11.1-libspre-release2026-11-04 · 2026-11-04 09:39 UTC
    查看更新说明

    Built from software-mansion-labs/executorch @ @ms/separate-backends-1.4.1 (0a087190). xnnpack-*, coreml-ios, opencv-android-* and qnn-android-arm64-v8a are the v0.11.0-libs files byte for byte.

    • Upstream ExecuTorch fixes synced to their merged or latest reviewed revisions (software-mansion-labs/executorch#30, #31).
    • Vulkan: Style Transfer output fixed on Mali.
    • Core: portable remainder and quantized dequantize_per_channel fixes.
    • MLX: lazy-graph eval threshold defaults to 512 MB.
    • headers regenerated.
  2. v0.11.0最新正式版2026-10-27 · 2026-10-27 14:59 UTC

    React Native ExecuTorch v0.11.0 🚀

    What's New?

    🧠 LLMs

    • LLM generation now runs on modular TypeScript runners (text, multimodal, Gemma) with a fully featured sampler based on the field-tested llama.cpp one, with support for constrained decoding and fine-grained control over generation. (#1508).
    • Re-exported LLMs with context windows up to 16k tokens (#1508).
    • enable_thinking chat template option and new MiniCPM5-2B (#1571). 👉 LLM Chat & Generation

    👁️ Computer vision

    • Depth estimation: Depth Anything V2 / V3 and ZipDepth (#1552). 👉 Docs
    • Image inpainting: MI-GAN (#1573). 👉 Docs
    • MediaPipe Face Mesh keypoints (#1469).
    • Core ML segmentation models may return an index map (#1463).

    🔎 Retrieval

    • createVectorStore: in-memory vector store with top-k cosine/dot queries and metadata filters (#1520).
    • ColBERT late-interaction embeddings with LFM2.5-ColBERT-350M and a maxSim helper (#1521). 👉 Docs

    🗣️ Speech

    • Kokoro: Chinese (#1557) and word timestamps (#1495).

    ⚡ Faster, smaller models

    • Vulkan is the Android default for style transfer, YOLO26 (detection / seg / pose), RF-DETR, FastSAM, BlazeFace and SDXS (#1479).
    • XNNPACK int8 for Whisper, YOLO26, RF-DETR, FastSAM, MiniLM, mpnet, CLIP, Supertonic and SDXS (#1522, #1530, #1537, #1539, #1542); Core ML text embedders served as int8 (#1465).

    📊 Benchmarks

    Per-device latency and memory for every registry variant. 👉 Benchmarks

    ⚠️ Breaking changes

    • The @experimental LLM runner API changed (#1508). The chat and generation APIs are unchanged.
    • The 15 unquantized (bf16/fp16) XNNPACK LLM variants were removed (#1519).
    • 66 unquantized XNNPACK variants with a faster quantized twin are deprecated and will be removed in v1.0.0 (#1519).

    🐛 Fixes

    All fixes shipped in v0.10.1 – v0.10.7 are included.

    Full Changelog: https://github.com/software-mansion/react-native-executorch/compare/v0.10.0...v0.11.0

  3. v0.11.0-libspre-release2026-10-27 · 2026-10-27 14:14 UTC
    查看更新说明

    Identical to v0.10.7-libs, republished under the v0.11.0 version.

  4. v0.10.7-libspre-release2026-10-22 · 2026-10-22 18:20 UTC
    查看更新说明

    Built from software-mansion-labs/executorch @ @ms/separate-backends-1.4.1 (f7bd4261). coreml-ios and opencv-android-* are the v0.10.6-libs files byte for byte.

    • software-mansion-labs/executorch#24: streamed tokenizer decode keeps word breaks (EuroLLM).
    • XNNPACK weights-cache, depthwise conv transpose, upsample and pad-fusion fixes from the fork PRs.
    • Vulkan conv2d_dw fix; QNN delegate argument bounds check; MLX backend updates.
    • headers regenerated from the build tree (v0.10.6-libs headers predated some Vulkan APIs).
  5. v0.10.72026-10-21 · 2026-10-21 12:26 UTC
    查看更新说明

    Patch release bumping phonemis to v0.3.1, so text-to-speech reads long numbers (e.g. phone numbers) digit by digit instead of dropping them.

    What's Changed

    Full Changelog: https://github.com/software-mansion/react-native-executorch/compare/v0.10.6...v0.10.7

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    React Native ExecuTorch is an on-device AI inference library for React Native, powered by ExecuTorch — Meta's on-device inference runtime. It lets you run machine learning models directly on the user's phone with zero network calls, full offline capability, and guaranteed privacy. No data ever leaves the device.

    The library ships with a curated set of pre-exported models covering computer vision, language models, text-to-speech, transcription, and more — all available in our Hugging Face collection and ready to use out of the box. You can also bring your own .pte models and plug them into existing pipelines or build entirely custom ones from scratch.

    To export your own PyTorch models to .pte, use ExecuTorch Export Recipes, our export harness with model recipes and agent skills.

    To explore all on-device capabilities in an interactive showcase app, check out the React Native ExecuTorch Gallery.

    npm version npm nightly CI

    Table of Contents

    Key Features

    • Native Hardware Acceleration: Optimized execution delegates across backends: XNNPACK (CPU), Core ML & MLX (Apple Silicon), and Vulkan (Android GPU).
    • 100% Offline & Private: Zero cloud inference costs and zero network dependency after model download. No user data ever leaves the device.
    • Two-Layer Architecture:
      • Ready-to-use Task Hooks (use<Task>): Out-of-the-box support for LLMs, computer vision, speech, and embeddings with automatic caching and lifecycle management.
      • Lower-level Runtime & Custom Orchestration: Build custom pipelines entirely in TypeScript using low-level tensor operations, fast native operators, schema validation, and worklet threading.
    • Pre-Exported Model Catalog: Access verified models directly via the models registry and the Software Mansion Hugging Face Collections.

    Quickstart

    [!TIP] Using an AI coding agent? The consumer skill helps your agent choose ready-made models and task hooks, integrate a custom .pte, or build a custom TypeScript pipeline.

    Install the consumer skill from the Software Mansion skills repository:

    npx skills add software-mansion-labs/skills -s react-native-executorch
    

    See AI Tools for model-selection guidance and an example prompt.

    1. Installation

    Install react-native-executorch alongside its required peer dependencies:

    npm install react-native-executorch react-native-worklets react-native-blob-util
    # or
    yarn add react-native-executorch react-native-worklets react-native-blob-util
    # or
    pnpm add react-native-executorch react-native-worklets react-native-blob-util
    

    [!IMPORTANT] React Native ExecuTorch requires:

    • New Architecture enabled
    • React Native 0.83+ or Expo SDK 55+ with Development Builds (Expo Go is not supported due to custom C++ native libraries)
    • react-native-worklets 0.10 or newer (>=0.10.0 <0.14.0)
    • iOS 17.0+ / Android 8.0+ (minSdkVersion >= 26)
    • react-native-worklets/plugin as the last entry in your Babel plugins

    Downloads of our pre-exported models send an anonymous download event; call setTelemetryEnabled(false) to opt out.

    See the Getting Started Guide and Compatibility table for more details.

    2. Run the Model

    import { Button, View } from 'react-native';
    import { models, useLLMChatSession } from 'react-native-executorch';
    
    export function App() {
      const session = useLLMChatSession(models.llm.LFM2_5_1_2B.DEFAULT);
    
      const handleGenerate = async () => {
        if (!session.isReady || !session.sendMessage) return;
    
        const turn = await session.sendMessage(
          'Explain on-device AI in one sentence.',
          (token) => console.log(token)
        );
    
        console.log('Result messages:', turn.messages);
      };
    
      return (
        <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
          <Button
            title={session.isReady ? 'Generate' : `Loading (${session.downloadProgress.toFixed(0)}%)`}
            onPress={handleGenerate}
            disabled={!session.isReady}
          />
        </View>
      );
    }
    

    Documentation

    Building with an AI coding agent? See AI Tools for model-selection guidance and an example prompt. Choose a pre-exported model with a task hook, or bring your own .pte and build a custom TypeScript pipeline.

    Full documentation, guides, architecture deep dives, and API references are available at: docs.swmansion.com/react-native-executorch

    Powered by React Native ExecuTorch

    React Native ExecuTorch powers Private Mind, a privacy-first mobile AI application available on App Store and Google Play.

    It also powers these libraries:

    • React Native RAG: private, on-device retrieval-augmented generation for your own documents.
    • React Native OCR: on-device document OCR with page layout, tables, dewarping and vertical text.

    Created by Software Mansion

    Since 2012, Software Mansion has been building mobile and web apps, contributing to open-source software, and dealing with all kinds of React Native challenges. We are Core React Native Contributors. We can help you build your next AI product – Hire us.

    swm