Swift Transformers 1.0 release notes / what's new
Hugging Face has released Swift Transformers 1.0, a stable version of its library designed to reduce friction for developers integrating local Large Language Models (LLMs) on Apple Silicon platforms, including iPhones. This release signals the transition of the library to a stable state, providing essential infrastructure for tokenization, model downloading, and inference that complements Core ML and MLX.
Core Components of Swift Transformers
Swift Transformers provides three primary modules that fill gaps in the Apple Silicon ML ecosystem:
- Tokenizers: A performant Swift implementation of tokenization that handles input preparation, chat templates, and agentic use cases, mirroring the ergonomics of Hugging Face's Python and Rust libraries.
- Hub: A Swift interface to the Hugging Face Hub that enables downloading and local caching of open models. It supports offline mode and background resumable downloads, though it does not currently support uploads.
- Models and Generation: Wrappers for LLMs converted to Core ML format, simplifying the process of running inference once the conversion is complete.
Key Updates in Version 1.0
Version 1.0 introduces several architectural improvements and stability updates to support production app development:
Modular Architecture and Dependency Reduction
Tokenizers and Hub are now first-class, top-level modules, allowing developers to import only the specific components they need rather than the entire package. To reduce overhead and prevent version conflicts, the library has removed example CLI targets and the swift-argument-parser dependency.
Performance and API Enhancements
- Swift Jinja Integration: In collaboration with John Mai, the library now uses a new version of
swift-jinja, which is reported to be several orders of magnitude faster for handling complex chat templates. - Modern Core ML APIs: Through contributions from Apple, the library now supports stateful models (facilitating easier KV-caching) and expressive
MLTensorAPIs, eliminating thousands of lines of custom tensor math code. - Swift 6 Support: The library is now fully compatible with Swift 6.
- API Refinement: The public API surface has been reduced to lower cognitive load, and documentation comments have been added to all public APIs.
Community Adoption and Integration
Swift Transformers is currently utilized by several high-profile Apple Silicon projects:
- mlx-swift-examples (Apple): Uses the library to run LLMs and VLMs (vision-language models) via MLX.
- WhisperKit (argmax): An optimized open-source speech recognition framework that relies on the
HubandTokenizersmodules. - FastVLM (Apple): A vision-language model demo, along with Hugging Face's own SmolVLM2 native app.
Future Roadmap
Hugging Face intends to focus future development on two primary areas:
- MLX Integration: Improving the seamlessness of the MLX experience, specifically through better integration with
mlx-swift-examplesfor LLMs and VLMs via frequent pre- and post-processing operations. - Agentic Workflows: Exploring agentic use cases and the Model Context Protocol (MCP) to enable the exposure of system resources to local workflows.