npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

expo-foundation-models

v1.0.0

Published

Expo module for Apple's Foundation Models (on-device LLM) and CoreML

Readme

expo-foundation-models

Expo module for Apple's Foundation Models (on-device LLM with Apple Intelligence) and CoreML integration.

npm version License: MIT

Overview

expo-foundation-models provides React Native/Expo bindings for Apple's on-device language model, enabling private, fast AI text generation without sending data to external servers. It also includes CoreML support for running custom machine learning models.

Key Features

| Feature | Description | |---------|-------------| | On-device LLM | Private text generation using Apple Intelligence | | Structured Output | Generate JSON conforming to schemas | | Tool Calling | Let the model call your functions | | Streaming | Token-by-token response streaming | | Session Management | Conversation history, prewarm, resume | | Adapters | Load and use fine-tuned models | | CoreML | Run any CoreML model |

Platform Support

| Feature | iOS | Android | |---------|-----|---------| | Foundation Models | iOS 26.0+ | Not supported | | CoreML | iOS 16.0+ | Not supported |

Note: Foundation Models requires an Apple Silicon device with Apple Intelligence enabled in Settings.

iOS 26 Beta Notice: The Foundation Models framework is in beta with rapidly changing APIs. Some features use workarounds:

  • Structured Output: Uses prompt-based JSON generation instead of DynamicGenerationSchema. The schema is included in the prompt and the model's JSON response is parsed. Results may vary.
  • Tool Calling: Tool result submission API has changed and is stubbed.
  • Session Transcript: Some transcript features use workarounds for API compatibility.

See GitHub Issue #1 for details.

Installation

npx expo install expo-foundation-models

For bare React Native projects:

npm install expo-foundation-models
npx pod-install

Quick Start

import { FoundationModels } from 'expo-foundation-models';

// Check availability
if (FoundationModels.isAvailable()) {
  // Create a session
  const sessionId = await FoundationModels.createSession('You are a helpful assistant.');
  
  // Generate a response
  const response = await FoundationModels.respond(sessionId, 'Hello!');
  console.log(response);
  
  // Clean up
  await FoundationModels.closeSession(sessionId);
}

Documentation

| Guide | Description | |-------|-------------| | Getting Started | Installation, setup, and basic usage | | Foundation Models | Text generation, streaming, and options | | Structured Output | JSON Schema generation and choices | | Tool Calling | Function calling and tool execution | | Session Management | Transcripts, prewarm, and history | | Adapters | Training and loading fine-tuned models | | Feedback | Response quality logging | | CoreML | Custom ML model integration | | Error Handling | Error types and handling patterns |

Example

Check out the example app for a complete demo showcasing all features.

cd example
npx expo run:ios

Requirements

  • Expo SDK 54+
  • iOS 26.0+ for Foundation Models
  • iOS 16.0+ for CoreML only
  • Apple Intelligence enabled in device Settings
  • Device with Apple Silicon (A17+ for Foundation Models)

Adapter Training

Want to create custom adapters for specialized tasks? Apple provides a Python toolkit for training adapters using LoRA (Low-Rank Adaptation).

| Task | Tool | |------|------| | Train adapters | Apple's Python Toolkit | | Use adapters | This package |

Training Requirements

  • Mac with Apple Silicon + 32GB RAM, or Linux GPU
  • Python 3.11+
  • 100-5,000+ training samples (prompt/response pairs)

Quick Training Overview

# 1. Download toolkit from Apple Developer
# 2. Set up environment
conda create -n adapter-training python=3.11
pip install -r requirements.txt

# 3. Train adapter
python -m examples.train_adapter \
  --train-data train.jsonl \
  --eval-data valid.jsonl \
  --epochs 5

# 4. Export to .fmadapter
python -m export.export_fmadapter \
  --adapter-name my_adapter \
  --checkpoint checkpoints/adapter-final.pt \
  --output-dir exports/

Then load in your app:

const adapter = await FoundationModels.loadAdapterFromFile('/path/to/my_adapter.fmadapter');
const sessionId = await FoundationModels.createSession({
  adapterId: adapter.id,
  instructions: 'You are a specialized assistant.',
});

See Adapters Documentation for complete details.

License

MIT

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Links