← all repositories
eastriverlee/LLM.swift

Local LLMs on every Apple OS, plus a macro for types

It wraps llama.cpp in Swift so you can run local LLMs on iPhones, Watches, and Macs without touching C++.

LLM.swift
Collecting fresh signals — velocity needs a few days of history.
collecting data…
star history

What it does

LLM.swift is a Swift abstraction over llama.cpp that loads and runs GGUF models locally on macOS, iOS, watchOS, tvOS, and visionOS. You can bundle a model with your app or pull one directly from Hugging Face at runtime. The library handles chat templating, history rotation, and streaming responses through an open Swift class meant to be subclassed.

The interesting bit

The standout feature is @Generatable, a Swift macro that turns structs and enums into JSON schemas to constrain the model’s output into valid, type-safe objects. The project is essentially well-crafted glue code over a battle-tested C++ engine, but the macro pushes it beyond a thin wrapper into something that actually feels native to Swift’s type system.

Key highlights

  • Runs inference entirely offline on any Apple platform using standard GGUF models.
  • Downloads compatible models directly from Hugging Face with progress callbacks.
  • @Generatable macro produces structured output for structs, enums, arrays, and nested types.
  • Built-in chat templates (ChatML, Gemma, etc.) and conversation history with preprocess, postprocess, and update hooks.
  • The core LLM class is open for subclassing when you need fine-grained control over the generation loop.

Caveats

  • Mobile memory is tight; the README explicitly warns that a poorly chosen maxTokenCount can silently truncate conversation context.

Verdict

Swift developers building Apple-native apps that need private, offline LLM inference should look here; if you need cross-platform support or already have a llama.cpp pipeline, it adds little.

Frequently asked

What is eastriverlee/LLM.swift?
It wraps llama.cpp in Swift so you can run local LLMs on iPhones, Watches, and Macs without touching C++.
Is LLM.swift open source?
Yes — eastriverlee/LLM.swift is open source, released under the MIT license.
What language is LLM.swift written in?
eastriverlee/LLM.swift is primarily written in C++.
How popular is LLM.swift?
eastriverlee/LLM.swift has 865 stars on GitHub.
Where can I find LLM.swift?
eastriverlee/LLM.swift is on GitHub at https://github.com/eastriverlee/LLM.swift.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.