能力标签
llama-rn AI技能包
🛠
AI工具

llama-rn AI技能包

基于 C++ · 开源免费,本地部署,数据完全自主可控
英文名:llama-rn
⭐ 947 Stars 🍴 101 Forks 💻 C++ 📄 MIT 🏷 AI 8.2分
8.2AI 综合评分
React NativeLLM推理跨平台C++绑定移动AI
✦ AI Skill Hub 推荐

经 AI Skill Hub 精选评估,llama-rn AI技能包 获评「强烈推荐」。这款AI工具在功能完整性、社区活跃度和易用性方面表现出色,AI 评分 8.2 分,适合有一定技术背景的用户使用。

📚 深度解析

llama-rn AI技能包 是一款基于 C++ 的开源工具,在 GitHub 上收获 1k+ Star,是React Native、LLM推理、跨平台、C++绑定领域中的优质开源项目。开源工具的最大优势在于代码完全透明,你可以审计每一行代码的安全性,也可以根据自身需求进行二次开发和定制。

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

**安装与环境准备**
llama-rn AI技能包 依赖 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 将持续追踪 llama-rn AI技能包 的版本更新,及时通知重要功能变化。

📋 工具概览

为React Native提供llama.cpp的原生绑定库,支持iOS和Android平台集成大型语言模型。开发者可在移动应用中部署本地LLM推理,实现离线AI功能,适合需要隐私保护和边缘计算的移动应用开发者。

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

GitHub Stars
⭐ 947
开发语言
C++
支持平台
Windows / macOS / Linux
维护状态
正常维护,社区驱动
开源协议
MIT
AI 综合评分
8.2 分
工具类型
AI工具
Forks
101

📖 中文文档

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

为React Native提供llama.cpp的原生绑定库,支持iOS和Android平台集成大型语言模型。开发者可在移动应用中部署本地LLM推理,实现离线AI功能,适合需要隐私保护和边缘计算的移动应用开发者。

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

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

# 查看安装说明
cat README.md

# 按 README 完成环境依赖安装后即可使用
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 查看帮助
llama.rn --help

# 基本运行
llama.rn [options] <input>

# 详细使用说明请查阅文档
# https://github.com/mybigday/llama.rn
以下配置示例基于典型使用场景生成,具体参数请参照官方文档调整。
配置示例
# llama.rn 配置说明
# 查看配置选项
llama.rn --config-example > config.yml

# 常见配置项
# output_dir: ./output
# log_level: info
# workers: 4

# 环境变量(覆盖配置文件)
export LLAMA.RN_CONFIG="/path/to/config.yml"
📑 README 深度解析 真实文档 完整度 56/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

llama.rn

Actions Status License: MIT npm

React Native binding of llama.cpp - LLM inference in C/C++

Key Features:

  • GPU/NPU Acceleration: Metal (iOS), Hexagon NPU (Android, Experimental) for on-device inference
  • Multimodal Support: Support vision/audio understanding models through mmproj projector integration
  • Parallel Decoding: Slot-based concurrent request processing with automatic queue management
  • Tool Calling: Universal function calling support via Jinja templates
  • Grammar Sampling: GBNF and JSON schema support for structured, constrained output generation
[!IMPORTANT] Starting with v0.10, llama.rn requires React Native's New Architecture. For Old Architecture support or documentation for v0.9.x, please refer to the v0.9 branch.

Installation

npm install llama.rn

llama.rn downloads the pre-built ios/rnllama.xcframework and android/src/main/jniLibs from the matching GitHub release during postinstall. Existing downloads are reused, and each archive is verified with SHA-256 before extraction.

Bun

Bun does not run dependency lifecycle scripts unless the package is trusted. If you install llama.rn with Bun and want the native downloads to run automatically, add it to trustedDependencies and re-run bun install:

{
  "trustedDependencies": ["llama.rn"]
}

If you prefer not to trust dependency lifecycle scripts, run the downloader manually before npx pod-install or your Android build:

node ./node_modules/llama.rn/install/download-native-artifacts.js

iOS

Please re-run npx pod-install again.

By default, llama.rn will use pre-built rnllama.xcframework for iOS. If you want to build from source, please set RNLLAMA_BUILD_FROM_SOURCE to 1 in your Podfile.

Android

Add proguard rule if it's enabled in project (android/app/proguard-rules.pro):

```proguard

Setup

First, you need a multimodal model and its corresponding multimodal projector (mmproj) file, see how to obtain mmproj for more details.

Usage

💡 You can find complete examples in the example project.

Load model info only:

import { loadLlamaModelInfo } from 'llama.rn'

const modelPath = 'file://<path to gguf model>'
console.log('Model Info:', await loadLlamaModelInfo(modelPath))

Initialize a Llama context & do completion:

import { initLlama } from 'llama.rn'

// Initial a Llama context with the model (may take a while)
const context = await initLlama({
  model: modelPath,
  use_mlock: true,
  n_ctx: 2048,
  n_gpu_layers: 99, // number of layers to store in GPU memory (Metal/OpenCL)
  // embedding: true, // use embedding
})

const stopWords = ['</s>', '<|end|>', '<|eot_id|>', '<|end_of_text|>', '<|im_end|>', '<|EOT|>', '<|END_OF_TURN_TOKEN|>', '<|end_of_turn|>', '<|endoftext|>']

// Do chat completion
const msgResult = await context.completion(
  {
    messages: [
      {
        role: 'system',
        content: 'This is a conversation between user and assistant, a friendly chatbot.',
      },
      {
        role: 'user',
        content: 'Hello!',
      },
    ],
    n_predict: 100,
    stop: stopWords,
    // ...other params
  },
  (data) => {
    // This is a partial completion callback
    const { token } = data
  },
)
console.log('Result:', msgResult.text)
console.log('Timings:', msgResult.timings)

// Or do text completion
const textResult = await context.completion(
  {
    prompt: 'This is a conversation between user and llama, a friendly chatbot. respond in simple markdown.\n\nUser: Hello!\nLlama:',
    n_predict: 100,
    stop: [...stopWords, 'Llama:', 'User:'],
    // ...other params
  },
  (data) => {
    // This is a partial completion callback
    const { token } = data
  },
)
console.log('Result:', textResult.text)
console.log('Timings:', textResult.timings)

The binding's deisgn inspired by server.cpp example in llama.cpp:

  • /completion and /chat/completions: context.completion(params, partialCompletionCallback)
  • /tokenize: context.tokenize(content)
  • /detokenize: context.detokenize(tokens)
  • /embedding: context.embedding(content)
  • /rerank: context.rerank(query, documents, params)
  • ... Other methods

Please visit the Documentation for more details.

You can also visit the example to see how to use it.

Usage Examples

Vision (Image Processing)

const result = await context.completion({
  messages: [
    {
      role: 'user',
      content: [
        {
          type: 'text',
          text: 'What do you see in this image?',
        },
        {
          type: 'image_url',
          image_url: {
            url: 'file:///path/to/image.jpg',
            // or base64: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD...'
          },
        },
      ],
    },
  ],
  n_predict: 100,
  temperature: 0.1,
})

console.log('AI Response:', result.text)

Audio Processing

// Method 1: Using structured message content (Recommended)
const result = await context.completion({
  messages: [
    {
      role: 'user',
      content: [
        {
          type: 'text',
          text: 'Transcribe or describe this audio:',
        },
        {
          type: 'input_audio',
          input_audio: {
            data: 'data:audio/wav;base64,UklGRiQAAABXQVZFZm10...',
            // or url: 'file:///path/to/audio.wav',
            format: 'wav', // or 'mp3'
          },
        },
      ],
    },
  ],
  n_predict: 200,
})

console.log('Transcription:', result.text)

Usage

import { initLlama } from 'llama.rn'

const context = await initLlama({
  model: modelPath,
  n_ctx: 8192,
  n_gpu_layers: 99,
  n_parallel: 4, // Max number of parallel slots supported
})

// Enable parallel mode with 4 slots
await context.parallel.enable({
  n_parallel: 4, // new_n_ctx (2048) = n_ctx / n_parallel
  n_batch: 512,
})

// Queue multiple completion requests
const request1 = await context.parallel.completion(
  {
    messages: [{ role: 'user', content: 'What is AI?' }],
    n_predict: 100,
  },
  (requestId, data) => {
    console.log(`Request ${requestId}:`, data.token)
  }
)

const request2 = await context.parallel.completion(
  {
    messages: [{ role: 'user', content: 'Explain quantum computing' }],
    n_predict: 100,
  },
  (requestId, data) => {
    console.log(`Request ${requestId}:`, data.token)
  }
)

// Cancel a request if needed
await request1.stop()

// Wait for completion
const result = await request2.promise
console.log('Result:', result.text)

// Disable parallel mode when done
await context.parallel.disable()

Optional space: by convention, applied in this grammar after literal chars when allowed

ws ::= | " " | "\n" [ \t]{0,20}

js import { initLlama } from 'llama.rn'

const gbnf = '...'

const context = await initLlama({ // ...params grammar: gbnf, })

const { text } = await context.completion({ // ...params messages: [ { role: 'system', content: 'You are a helpful assistant that can answer questions and help with tasks.', }, { role: 'user', content: 'Test', }, ], }) console.log('Result:', text) ```

Also, this is how json_schema works in response_format during completion, it converts the json_schema to gbnf grammar.

API

context.parallel.enable(config?): - config.n_parallel (number): Number of concurrent slots (default: 2) - config.n_batch (number): Batch size for processing (default: 512) - Returns: Promise<boolean>

context.parallel.disable(): - Disables parallel mode - Returns: Promise<boolean>

context.parallel.configure(config): - Reconfigures parallel mode (enables if not already enabled) - config.n_parallel (number): Number of concurrent slots - config.n_batch (number): Batch size for processing - Returns: Promise<boolean>

context.parallel.completion(params, onToken?): - params: Same completion parameters as completion() - onToken: Optional callback (requestId, data) => void for token streaming - requestId: Unique request identifier - data: Token data with token, content, reasoning_content, tool_calls, accumulated_text - Returns: Promise<{ requestId, promise, stop }> - requestId: Unique request identifier - promise: Resolves to NativeCompletionResult when complete - stop: Function to cancel this request

context.parallel.embedding(text, params?): - text: Text content to get embedding for - params: Optional embedding parameters - Returns: Promise<{ requestId, promise }> - requestId: Unique request identifier - promise: Resolves to embedding result when complete

context.parallel.rerank(query, documents, params?): - query: Query string for ranking - documents: Array of document strings to rank - params: Optional rerank parameters (e.g., normalize) - Returns: Promise<{ requestId, promise }> - requestId: Unique request identifier - promise: Resolves to rerank results when complete

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

高质���React Native-LLM集成方案,活跃维护,技术选型合理,填补移动平台本地推理空白。

📚 实用指南(长尾问题)
适合谁
  • 构建企业知识库 / RAG 检索应用的团队
  • 做语音类 AI 产品的开发者
最佳实践
  • 本地部署优先选 GGUF 量化模型,节省显存并保持响应速度
  • 分块大小建议 256-512 tokens,向量库优选 pgvector 或 Qdrant
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • embedding 模型与查询模型不一致导致检索失效
  • 显存不足直接 OOM — 优先降低 context 或换更小的量化模型
部署方案
  • 本地部署:CPU 8GB 起,GPU 推荐 16GB+ 显存
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
llama-rn 中文教程llama-rn 安装报错怎么办llama-rn 与同类工具对比llama-rn 最佳实践llama-rn 适合谁用

⚡ 核心功能

👥 适合谁
  • 构建企业知识库 / RAG 检索应用的团队
  • 做语音类 AI 产品的开发者
⭐ 最佳实践
  • 本地部署优先选 GGUF 量化模型,节省显存并保持响应速度
  • 分块大小建议 256-512 tokens,向量库优选 pgvector 或 Qdrant
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • embedding 模型与查询模型不一致导致检索失效
  • 显存不足直接 OOM — 优先降低 context 或换更小的量化模型

👥 适合人群

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

🎯 使用场景

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

⚖️ 优点与不足

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

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

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

📄 License 说明

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

🔗 相关工具推荐

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

❓ 常见问题 FAQ

支持iOS和Android两个主要移动平台。
💡 AI Skill Hub 点评

AI Skill Hub 点评:llama-rn AI技能包 的核心功能完整,质量优秀。对于AI 技术爱好者来说,这是一个值得纳入个人工具库的选择。建议先在非生产环境试用,再逐步推广。

📚 深入学习 llama-rn AI技能包
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 llama-rn
原始描述 开源AI工具:React Native binding of llama.cpp。⭐947 · C++
Topics React NativeLLM推理跨平台C++绑定移动AI
GitHub https://github.com/mybigday/llama.rn
License MIT
语言 C++
🔗 原始来源
🐙 GitHub 仓库  https://github.com/mybigday/llama.rn

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

📺 订阅 AI Skill Hub Daily Telegram 频道
每天 8 条精选 AI Skill、MCP、Agent 与自动化工具推送
加入频道 →