CONNECT WITH US
AI & Deeptech

AI & Deeptech

Introducing swift-huggingface: The Complete Swift Client for Hugging Face

Hugging Face logo

Published on

Add as a preferred source on Google
Introducing swift-huggingface: The Complete Swift Client for Hugging Face

You can start using it today as a standalone package, and it will soon integrate into swift-transformers as a replacement for its current HubApi implementation.

When we released swift-transformers 1.0 earlier this year, we heard loud and clear from the community:

swift-huggingface is a ground-up rewrite focused on reliability and developer experience. It provides:

One of the biggest improvements is how authentication works. The TokenProvider pattern makes it explicit where credentials come from:

This means if you've already logged in with hf auth login, swift-huggingface will automatically find and use that token.

Building an app where users sign in with their Hugging Face account? swift-huggingface includes a complete OAuth 2.0 implementation:

The OAuth manager handles token storage in Keychain, automatic refresh, and secure sign-out. No more manual token management.

Downloading large models is now straightforward with proper progress tracking and resume support:

The snapshot function tracks metadata for each file, so subsequent calls only download files that have changed.

Remember the second problem we mentioned? "No shared cache with the Python ecosystem." That's now solved.

swift-huggingface implements a Python-compatible cache structure that allows seamless sharing between Swift and Python clients:

To prevent race conditions when multiple processes access the same cache, swift-huggingface uses file locking (flock(2)).

Here's what downloading a model snapshot looked like with the old HubApi:

The API is similar, but the implementation is completely different — built on URLSession download tasks with proper delegate handling, resume data support, and metadata tracking.


Source link

Disclaimer

We strive to uphold the highest ethical standards in all of our reporting and coverage. We TheMorningPulse.fyi want to be transparent with our readers about any potential conflicts of interest that may arise in our work. It's possible that some of the investors we feature may have connections to other businesses, including competitors or companies we write about. However, we want to assure our readers that this will not have any impact on the integrity or impartiality of our reporting. We are committed to delivering accurate, unbiased news and information to our audience, and we will continue to uphold our ethics and principles in all of our work. Thank you for your trust and support.