---
title: "Releasing Swift Transformers: Run On-Device LLMs in Apple Devices"
description: "Hugging Face released swift-transformers, an alpha Swift package with a transformers-like API for on-device text generation, along with the swift-chat demo app, updated exporters and transformers-to-coreml conversion tools, and pre-converted Llama 2 7B and Falcon 7B Core ML models."
url: "https://swe.quest/articles/releasing-swift-transformers-run-on-device-llms-in-apple-devices-ee6106831bf892fd"
canonical: "https://huggingface.co/blog/swift-coreml-llm"
source: "Hugging Face"
published: "2023-08-08"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 15
tags: ["swift","inference","llms","mobile"]
---

# Releasing Swift Transformers: Run On-Device LLMs in Apple Devices

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2023-08-08, 15 min read, Announcement. Original: [https://huggingface.co/blog/swift-coreml-llm](https://huggingface.co/blog/swift-coreml-llm)

## Summary

Hugging Face released swift-transformers, an alpha Swift package with a transformers-like API for on-device text generation, along with the swift-chat demo app, updated exporters and transformers-to-coreml conversion tools, and pre-converted Llama 2 7B and Falcon 7B Core ML models. The post walks through converting Llama 2 to Core ML via three routes: the no-code Space, exporters, or raw coremltools. Lessons from those conversions include using coremltools 7.0b1, dropping softmax from outputs, and using fixed sequence lengths, because flexible shapes only run on the CPU. Planned optimizations are KV caching, discrete input shapes and palettization or mixed-bit quantization, and the library already supports Hub-configured BPE tokenizers plus greedy and top-k generation.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Swift](https://swe.quest/tags/swift.md) (Languages)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)

## Prerequisites

- Swift basics ([easy posts on Swift](https://swe.quest/tags/swift.md?difficulty=easy))
- transformer language models
- Core ML basics ([easy posts on Machine learning](https://swe.quest/tags/machine-learning.md?difficulty=easy))

## Keywords

swift-transformers, Core ML, coremltools, Llama 2, Falcon, exporters, Hugging Face Hub, BPE

## Related posts

- [Swift Transformers Reaches 1.0 – and Looks to the Future](https://swe.quest/articles/swift-transformers-reaches-1-0-and-looks-to-the-future-a8395154e2037c4e.md): Hugging Face · 2025-09-26 · Easy · 5 min read · Swift, Inference & serving, LLMs, Mobile
  swift-transformers, Hugging Face's Swift library for running local models on Apple Silicon, reaches 1.0.
- [WWDC 24: Running Mistral 7B with Core ML](https://swe.quest/articles/wwdc-24-running-mistral-7b-with-core-ml-8ff5ba3b889a9bf2.md): Hugging Face · 2024-07-22 · Medium · 13 min read · Inference & serving, LLMs, Swift, Mobile
  Mistral 7B Instruct can run on a Mac with Core ML using features new in iOS 18 and macOS Sequoia: the MLTensor Swift type for tensor pre- and post-processing, stateful buffers that keep the kv-cache on the GPU instead of passing it in and out on every call, and block-wise 4-bit quantization.
- [AnyLanguageModel 1.0: One Year of Local Models on Apple Platforms](https://swe.quest/articles/anylanguagemodel-1-0-one-year-of-local-models-on-apple-platforms-2fd58a39aa0b428c.md): Hugging Face · 2026-10-20 · Medium · 4 min read · Swift, LLMs, Inference & serving, Mobile, API design
  AnyLanguageModel 1.0 is a Swift package that acts as a drop-in replacement for Apple's Foundation Models framework, letting apps swap the model and provider by changing a single import.
- [Introducing AnyLanguageModel: One API for Local and Remote LLMs on Apple Platforms](https://swe.quest/articles/introducing-anylanguagemodel-one-api-for-local-and-remote-llms-on-apple-049ac2052cff4c11.md): Hugging Face · 2025-11-20 · Medium · 6 min read · Swift, LLMs, API design, Inference & serving, Mobile
  AnyLanguageModel is a Swift package that mirrors Apple's Foundation Models API, so a single \`import\` swap lets apps target Apple's system model, Core ML, MLX, llama.cpp, Ollama, or cloud providers (OpenAI, Anthropic, Gemini, Hugging Face Inference Providers) through the same session-based interface.
- [Using Stable Diffusion with Core ML on Apple Silicon](https://swe.quest/articles/using-stable-diffusion-with-core-ml-on-apple-silicon-ec28c0373922e17b.md): Hugging Face · 2022-12-01 · Medium · 6 min read · Inference & serving, Computer vision, Swift, Python
  Stable Diffusion can run on Apple Silicon via Core ML using Apple's ml-stable-diffusion repo, with pre-converted checkpoints for v1.4, v1.5, v2 base and v2.1 base hosted on the Hugging Face Hub.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
