LLM.swift
A Swift library for running large language models locally on macOS, iOS, watchOS, tvOS and visionOS, built around llama.cpp with automatic chat-template handling from a model's GGUF metadata.
LLM.swift is a library for interacting with large language models locally from Swift, on macOS, iOS, watchOS, tvOS and visionOS. It can load a bundled GGUF model file directly or fetch one from Hugging Face, and by default renders conversations using the chat template embedded in the GGUF file itself through llama.cpp's Jinja engine, so a model works with its own template without extra configuration.
A Template can still be passed explicitly to override the embedded one, for example when a model's metadata is missing or broken, and thinking or reasoning output is separated automatically for models that support it. Conversation context is maintained incrementally between turns, and a maxTokenCount parameter controls the memory and computation trade-off, which matters most on mobile devices.