From 35e87c216e5e574992695bfdd4f8340712943216 Mon Sep 17 00:00:00 2001 From: FL33TW00D Date: Wed, 24 Sep 2025 11:22:50 +0100 Subject: [PATCH 1/3] fix: modernize readme --- README.md | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 1e42f480..627b85c4 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,7 @@ `swift-transformers` is a collection of utilities to help adopt language models in Swift apps. -It tries to follow the Python `transformers` API and abstractions whenever possible, but it also aims to provide an idiomatic Swift interface and does not assume prior familiarity with [`transformers`](https://github.com/huggingface/transformers) or [`tokenizers`](https://github.com/huggingface/tokenizers). - +Those familiar with the [`transformers`](https://github.com/huggingface/transformers) python library will find a familiar but idiomatic Swift API. ## Rationale & Overview @@ -23,7 +22,9 @@ Check out [our announcement post](https://huggingface.co/blog/swift-coreml-llm). ## Modules -- `Tokenizers`: Utilities to convert text to tokens and back, with support for Chat Templates and Tools. Follows the abstractions in [`tokenizers`](https://github.com/huggingface/tokenizers). Usage example: +- `Tokenizers`: Utilities to convert text to tokens and back, with support for Chat Templates and Tools. Follows the abstractions in [`tokenizers`](https://github.com/huggingface/tokenizers). + +Usage example: ```swift import Tokenizers func testTokenizer() async throws { @@ -33,16 +34,15 @@ func testTokenizer() async throws { let decoded = tokenizer.decode(tokens: encoded) } ``` - - `Hub`: Utilities for interacting with the Hugging Face Hub! Download models, tokenizers and other config files. Usage example: + ```swift import Hub func testHub() async throws { let repo = Hub.Repo(id: "mlx-community/Qwen2.5-0.5B-Instruct-2bit-mlx") - let filesToDownload = ["config.json", "*.safetensors"] let modelDirectory: URL = try await Hub.snapshot( from: repo, - matching: filesToDownload, + matching: ["config.json", "*.safetensors"], progressHandler: { progress in print("Download progress: \(progress.fractionCompleted * 100)%") } @@ -51,10 +51,9 @@ func testHub() async throws { } ``` -- `Generation`: Algorithms for text generation. Handles tokenization internally. Currently supported ones are: greedy search, top-k sampling, and top-p sampling. +- `Generation`: Utilities for text generation, handling tokenization for you. Currently supported sampling methods: greedy search, top-k sampling, and top-p sampling. - `Models`: Language model abstraction over a Core ML package. - ## Usage via SwiftPM To use `swift-transformers` with SwiftPM, you can add this to your `Package.swift`: @@ -85,25 +84,10 @@ targets: [ Using `swift-transformers` in your project? Let us know and we'll add you to the list! -## Supported Models - -You can run inference on Core ML models with `swift-transformers`. Note that Core ML is not required to use the `Tokenizers` or `Hub` modules. - -This package has been tested with autoregressive language models such as: - -- GPT, GPT-Neox, GPT-J. -- SantaCoder. -- StarCoder. -- Falcon. -- Llama 2. - -Encoder-decoder models such as T5 and Flan are currently _not supported_. - ## Other Tools - [`swift-chat`](https://github.com/huggingface/swift-chat), a simple app demonstrating how to use this package. - [`exporters`](https://github.com/huggingface/exporters), a Core ML conversion package for transformers models, based on Apple's [`coremltools`](https://github.com/apple/coremltools). -- [`transformers-to-coreml`](https://huggingface.co/spaces/coreml-projects/transformers-to-coreml), a no-code Core ML conversion tool built on `exporters`. ## Contributing From 02af6becb7080b38b436ca74c8975df47d416388 Mon Sep 17 00:00:00 2001 From: Christopher Fleetwood <45471420+FL33TW00D@users.noreply.github.com> Date: Thu, 25 Sep 2025 09:37:43 +0100 Subject: [PATCH 2/3] Update README.md Co-authored-by: Mattt --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 627b85c4..63299858 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,9 @@ func testTokenizer() async throws { let decoded = tokenizer.decode(tokens: encoded) } ``` -- `Hub`: Utilities for interacting with the Hugging Face Hub! Download models, tokenizers and other config files. Usage example: +- `Hub`: Utilities for interacting with the Hugging Face Hub. Download models, tokenizers and other config files. + +Usage example: ```swift import Hub From 591271945cbe726b8e466fc49baf627215fb40e5 Mon Sep 17 00:00:00 2001 From: Christopher Fleetwood <45471420+FL33TW00D@users.noreply.github.com> Date: Thu, 25 Sep 2025 09:37:49 +0100 Subject: [PATCH 3/3] Update README.md Co-authored-by: Mattt --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 63299858..dcc57110 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ `swift-transformers` is a collection of utilities to help adopt language models in Swift apps. -Those familiar with the [`transformers`](https://github.com/huggingface/transformers) python library will find a familiar but idiomatic Swift API. +Those familiar with the [`transformers`](https://github.com/huggingface/transformers) Python library will find a familiar yet idiomatic Swift API. ## Rationale & Overview