llama.rn  by mybigday

React Native binding for llama.cpp

created 2 years ago
596 stars

Top 55.4% on sourcepulse

GitHubView on GitHub
Project Summary

This library provides React Native bindings for llama.cpp, enabling on-device large language model inference within mobile applications. It targets React Native developers seeking to integrate powerful AI capabilities directly into their iOS and Android apps without relying on external APIs.

How It Works

The library wraps the C++ llama.cpp inference engine, exposing its functionality through a JavaScript interface. It leverages pre-built binaries for iOS and Android, with options to build from source. The design mirrors llama.cpp's server examples, mapping API endpoints to methods like completion, tokenize, and embedding on a LlamaContext object. It supports advanced features like tool calling via Jinja templating and grammar-based sampling using GBNF.

Quick Start & Requirements

  • Install: npm install llama.rn
  • iOS: Run npx pod-install. Set RNLLAMA_BUILD_FROM_SOURCE=1 in Podfile to build from source. Extended Virtual Addressing recommended. Metal support requires Apple7 GPU or higher; iOS simulator is not supported.
  • Android: Add proguard rule if enabled. Set rnllamaBuildFromSource=true in gradle.properties to build from source. Currently supports arm64-v8a/x86_64; 64-bit platforms recommended. No integrated GPU backend.
  • Models: Download GGUF format models from HuggingFace.

Highlighted Details

  • Supports chat and text completion with partial result callbacks.
  • Implements universal tool calling via Jinja templating and chat.cpp.
  • Enables output control with GBNF grammar, including JSON schema conversion.
  • Provides session loading/saving and completion stopping.
  • Includes a Jest mock for testing.

Maintenance & Community

  • Built and maintained by BRICKS.
  • Apps using llama.rn: BRICKS, ChatterUI, PocketPal AI.
  • Related project: llama.node (Node.js binding with similar API).

Licensing & Compatibility

  • License: MIT.
  • Compatible with commercial and closed-source applications.

Limitations & Caveats

iOS Metal support has minimum GPU requirements and is not available on the simulator. Android is limited to specific architectures and lacks GPU acceleration.

Health Check
Last commit

20 hours ago

Responsiveness

1 day

Pull Requests (30d)
12
Issues (30d)
7
Star History
102 stars in the last 90 days

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Nat Friedman Nat Friedman(Former CEO of GitHub), and
32 more.

llama.cpp by ggml-org

0.4%
84k
C/C++ library for local LLM inference
created 2 years ago
updated 14 hours ago
Feedback? Help us improve.