Skip to content

Conversation

@pcuenca
Copy link
Member

@pcuenca pcuenca commented Sep 24, 2025

This is a rebase of the preview branch on the current main.

What we gain:

  • Modern MLTensor API
  • Stateful models for easier KV caching
  • Lots of tensor operation lines removed (no more MLShapedArray, MLMultiArray 🥳)
  • A Mistral 7B conversion example

What we lose:

Some cleanup still needed.

Should we move forward with this? @mattt @FL33TW00D @Vaibhavs10 @ZachNagengast

pcuenca and others added 6 commits September 24, 2025 08:46
* Added error for JSON serialization errors

* Fix merge commit

---------

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
SPM dependencies are always compiled for the standard architectures, but
Float16 is not available for `x86_64`.

Thanks @joshnewnham for the workaround 🙌
Package.swift Outdated
let package = Package(
name: "swift-transformers",
platforms: [.iOS(.v16), .macOS(.v13)],
platforms: [.iOS("18.0"), .macOS("15.0")],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.v18 and .v15 not supported for manifests < Swift 6

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could revert and conditionally exclude the Generation target instead

@FL33TW00D
Copy link
Contributor

This is great! Cuts out a lot of cruft we don't need any more and we can repost about the Mistral 7B example (I still use it as a reference and even I struggle to find it!!)

@pcuenca
Copy link
Member Author

pcuenca commented Sep 24, 2025

If we go forward, we can:

@pcuenca pcuenca mentioned this pull request Sep 25, 2025
name: "transformers-cli",
platforms: [.iOS(.v18), .macOS(.v15)],
dependencies: [
.package(url: "https://github.com/huggingface/swift-transformers", branch: "main"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.package(url: "https://github.com/huggingface/swift-transformers", branch: "main"),
.package(url: "https://github.com/huggingface/swift-transformers", from: "1.0.0"),

to update

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use a relative import here

Suggested change
.package(url: "https://github.com/huggingface/swift-transformers", branch: "main"),
.package(path: "../../"),

@pcuenca pcuenca merged commit c130706 into main Sep 25, 2025
2 checks passed
@pcuenca pcuenca deleted the preview-2025 branch September 25, 2025 14:53
pcuenca added a commit that referenced this pull request Sep 26, 2025
Co-authored-by: Joshua Newman <joshnewnham@users.noreply.github.com>
Co-authored-by: Yuduo Wu <6426433+1duo@users.noreply.github.com>
Co-authored-by: Alejandro Isaza <alejandro-isaza@users.noreply.github.com>
Co-authored-by: Aseem Wadhwa <aseemw@users.noreply.github.com>

Reference: #257
pcuenca added a commit that referenced this pull request Sep 26, 2025
* feat: tokenizers and hub are the big sellers!

* Update README.md

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>

* Update README.md

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>

* fix: add Mistral 7B example

* Update README.md

Co-authored-by: vb <vaibhavs10@gmail.com>

* Update README.md

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>

* Link to Core ML PR

Co-authored-by: Joshua Newman <joshnewnham@users.noreply.github.com>
Co-authored-by: Yuduo Wu <6426433+1duo@users.noreply.github.com>
Co-authored-by: Alejandro Isaza <alejandro-isaza@users.noreply.github.com>
Co-authored-by: Aseem Wadhwa <aseemw@users.noreply.github.com>

Reference: #257

---------

Co-authored-by: FL33TW00D <FL33TW00D@users.noreply.github.com>
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
Co-authored-by: vb <vaibhavs10@gmail.com>
Co-authored-by: Joshua Newman <joshnewnham@users.noreply.github.com>
Co-authored-by: Yuduo Wu <6426433+1duo@users.noreply.github.com>
Co-authored-by: Alejandro Isaza <alejandro-isaza@users.noreply.github.com>
Co-authored-by: Aseem Wadhwa <aseemw@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants