Skip to content

Optional Tokenizer Dependency to Improve Embedded Compatibility #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ykhrustalev opened this issue Apr 16, 2025 · 0 comments
Open

Optional Tokenizer Dependency to Improve Embedded Compatibility #209

ykhrustalev opened this issue Apr 16, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@ykhrustalev
Copy link
Contributor

ykhrustalev commented Apr 16, 2025

What behavior of the library made you think about the improvement?

The library currently depends on TLS libraries indirectly through the tokenizers crate, which in turn pulls in hf-hub. However, this dependency is not strictly necessary in all environments.

In many cases, the application using this library already has an instance of a tokenizer and can pass in the vocabulary as a constraint. Requiring hf-hub (and thus the TLS stack) creates issues in embedded environments like iOS or Mac Catalyst due to the heavy dependency graph.

Proposal
Make the hf-hub dependency optional by introducing a default feature flag. This allows stripping the dependency in environments where it's not needed.

Benefits
This change enables building in embedded targets such as:

aarch64-apple-ios
aarch64-apple-ios-macabi

with the following commands:

cargo build --release --target aarch64-apple-ios --no-default-features
cargo build --release --target aarch64-apple-ios-macabi --no-default-features

Related change to show how it could work (worked for our case)
#200

How would you like it to behave?

A feature flag that would make the hf hub an optional dependency and in turn will not pull the tls

@ykhrustalev ykhrustalev added the enhancement New feature or request label Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant