|
1 | 1 | # MLX Swift LM |
2 | 2 |
|
| 3 | +> [!IMPORTANT] |
| 4 | +> The `main` branch is a _new_ major version number: 3.x. In order |
| 5 | +> to decouple from tokenizer and downloader packages some breaking |
| 6 | +> changes were introduced. See [Breaking Changes](#breaking-changes) for more information. |
| 7 | +
|
3 | 8 | MLX Swift LM is a Swift package to build tools and applications with large language models (LLMs) and vision language models (VLMs) in [MLX Swift](https://github.com/ml-explore/mlx-swift). |
4 | 9 |
|
5 | 10 | Some key features include: |
@@ -257,3 +262,37 @@ Developers can use these examples in their own programs -- just import the swift |
257 | 262 | - [MLXLLM](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxllm): Large language model example implementations |
258 | 263 | - [MLXVLM](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxvlm): Vision language model example implementations |
259 | 264 | - [MLXEmbedders](https://swiftpackageindex.com/ml-explore/mlx-swift-lm/main/documentation/mlxembedders): Popular encoders and embedding models example implementations |
| 265 | + |
| 266 | +## Breaking Changes |
| 267 | + |
| 268 | +### Loading API |
| 269 | + |
| 270 | +The `hub` parameter (previously `HubApi`) has been replaced with `from` (any `Downloader` or `URL` for a local directory). Functions that previously defaulted to `defaultHubApi` no longer have a default – callers must either pass a `Downloader` explicitly or use the convenience methods in `MLXLMHuggingFace` / `MLXEmbeddersHuggingFace`, which default to `HubClient.default`. |
| 271 | + |
| 272 | +For most users who were using the default Hub client, adding `import MLXLMHuggingFace` or `import MLXEmbeddersHuggingFace` and using the convenience overloads is sufficient. |
| 273 | + |
| 274 | +Users who were passing a custom `HubApi` instance should create a `HubClient` instead and pass it as the `from` parameter. `HubClient` conforms to `Downloader` via `MLXLMHuggingFace`. |
| 275 | + |
| 276 | +### `ModelConfiguration` |
| 277 | + |
| 278 | +- `tokenizerId` and `overrideTokenizer` have been replaced by `tokenizerSource: TokenizerSource?`, which supports `.id(String)` for remote sources and `.directory(URL)` for local paths. |
| 279 | +- `preparePrompt` has been removed. This shouldn't be used anyway, since support for chat templates is available. |
| 280 | +- `modelDirectory(hub:)` has been removed. For local directories, pass the `URL` directly to the loading functions. For remote models, the `Downloader` protocol handles resolution. |
| 281 | + |
| 282 | +### Tokenizer loading |
| 283 | + |
| 284 | +`loadTokenizer(configuration:hub:)` has been removed. Tokenizer loading now uses `AutoTokenizer.from(directory:)` from Swift Tokenizers directly. |
| 285 | + |
| 286 | +`replacementTokenizers` (the `TokenizerReplacementRegistry`) has been removed. Use `AutoTokenizer.register(_:for:)` from Swift Tokenizers instead. |
| 287 | + |
| 288 | +### `defaultHubApi` |
| 289 | + |
| 290 | +The `defaultHubApi` global has been removed. Hugging Face Hub access is now provided by `HubClient.default` from the `HuggingFace` module. |
| 291 | + |
| 292 | +### Low-level APIs |
| 293 | + |
| 294 | +- `downloadModel(hub:configuration:progressHandler:)` → `Downloader.download(id:revision:matching:useLatest:progressHandler:)` |
| 295 | +- `loadTokenizerConfig(configuration:hub:)` → `AutoTokenizer.from(directory:)` |
| 296 | +- `ModelFactory._load(hub:configuration:progressHandler:)` → `_load(configuration: ResolvedModelConfiguration)` |
| 297 | +- `ModelFactory._loadContainer`: removed (base `loadContainer` now builds the container from `_load`) |
| 298 | + |
0 commit comments