huggingface/swift-transformers
Swift Package to implement a transformers-like API in Swift
What it solves
It provides a set of utilities to help developers integrate language models into Swift applications, bringing a familiar API similar to the Python transformers library to the Swift ecosystem.
How it works
The library offers several specialized modules:
- Tokenizers: Handles text tokenization and chat templating, including native support for tool calling formats.
- Hub: Enables fast and reliable downloads of models and configuration files directly from the Hugging Face Hub with progress reporting and connection handling.
- Models & Generation: Provides utilities for working with language models specifically within CoreML for on-device execution.
Who it’s for
Swift developers who want to implement on-device machine learning and language model capabilities in their apps without needing to rewrite the core logic of the Hugging Face ecosystem in Swift.
Highlights
- Idiomatic Swift API: Designed to feel familiar to users of the Python
transformerslibrary. - Smarter Downloads: Includes a
Hubmodule for reliable model fetching and an optionalXettrait for parallel downloads. - CoreML Integration: Built-in support for loading compiled CoreML models and offline tokenizers to avoid network requests.
- Tool Calling Support: Native formatting for complex model interactions involving external tools.
Related
- Dispatch
- Dispatch
- Dispatch
- Project
- Project