CoreML-LLM

A Swift package for running converted large language models on the Apple Neural Engine with Core ML, including Gemma 4, Qwen and other bundles, with text, image, video and audio paths.

View on GitHub ↗
Stars
★ 210
Last commit
19 Nov 2026
Maintenance
Active
Licence
MIT
Category
On-device AI SDKs
GitHub
john-rocky/CoreML-LLM

Overview

CoreML-LLM is a Swift package by john-rocky for running on-device language models through Core ML, with the Neural Engine as the preferred compute path so the GPU can stay free for the rest of the app. The README contrasts this with MLX Swift, which it describes as the better choice when maximum GPU throughput is the aim.

The package can download a registered model or a Hugging Face path, cache it on the device, and then generate, stream or chat, including image, video and audio inputs on supported Gemma 4 bundles. Specialist APIs cover FunctionGemma (function calling) and EmbeddingGemma (sentence embeddings). Conversion scripts are included for building new Core ML bundles.

This is a different repo from the author's listed coreml-models collection and from coreai-kit, which targets Apple's Core AI path on OS 27. CoreML-LLM sticks with Core ML, with a documented minimum of iOS 18 and macOS 15.

The code is licensed under the MIT licence. Model weights keep their original terms, including Google's Gemma Terms of Use, Apache-2.0 for Qwen, and Liquid AI's LFM Open Licence v1.0 for LFM2.5 350M, which the README says has a US $10 million annual revenue threshold for commercial use.

Decode speeds in the README (for example 34.2 tok/s for Gemma 4 E2B and about 48 tok/s for Qwen3.5 0.8B on an iPhone 17 Pro) are the author's measurements and have not been independently verified.

Features

  • One-line load and generate, plus streaming and multi-turn chat.
  • Multimodal generate APIs for image, audio and video on supported models.
  • A catalogue that includes Gemma 4 E2B and E4B, Qwen3.5, stateful Qwen3-VL, LFM2.5 350M, FunctionGemma-270M and EmbeddingGemma-300M, downloaded on first use.
  • Background downloads through ModelDownloader, with pause and resume.
  • Conversion tooling in conversion/ for building Core ML bundles.
  • Sample apps, including Examples/CoreMLLLMChat, and a pre-built App Store demo, Models Zoo.
  • A documented default compute setting, cpuAndNeuralEngine, that puts the Neural Engine first.

Requirements

  • Inference: iOS 18 or later, or macOS 15 or later.
  • Sample apps: Xcode 16 or later.
  • Conversion, if building bundles: Python 3.10 to 3.12, coremltools 8 or later, and PyTorch 2.2 or later.
  • Enough free disk and memory for the chosen bundle (Gemma 4 E2B is listed at 5.4 GB multimodal, or 4.4 GB text-only).

Install

  1. In a Package.swift, add .package(url: "https://github.com/john-rocky/CoreML-LLM", from: "1.9.0") and depend on the CoreMLLLM product.

  2. In Xcode, use File, Add Package Dependencies, and the same repository URL, from version 1.9.0.

  3. To try the sample: open Examples/CoreMLLLMChat/CoreMLLLMChat.xcodeproj, set a development team, and run on an iOS 18 device. The README also points to Models Zoo on the App Store.

Example

Add the package, then load a catalogue id such as lfm2.5-350m or gemma4e2b with CoreMLLLM.load and call generate or stream. For a multimodal Gemma 4 model, pass an image, audio samples or a video URL into generate.

Works with

Not stated by the source

Listed in

Read the code before you install anything. SwiftAgents doesn't review or endorse the tools listed here. Active: a commit in the last 90 days. Slowing: last commit within the past year. Stale: older than a year, or archived.

Report a correction

More in this category