Skip to content

Add support for using the tokenizer without loading onnx and tripping warnings - #1773

Open
koush wants to merge 2 commits into
huggingface:mainfrom
koush:main
Open

koush wants to merge 2 commits into
huggingface:mainfrom
koush:main

Conversation

@koush

@koush koush commented Sep 20, 2026

Copy link
Copy Markdown

adds TokenizersBackend: PreTrainedTokenizer to the registry, so tokenizer configs declaring tokenizer_class: "TokenizersBackend" (the generic HF tokenizers Rust backend alias) resolve cleanly to the base class instead of tripping the unknown-class warning.

Add tokenizer-only package entry point so it can be used without loading onnx.

@xenova

xenova commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Hi there 馃憢 if you would like to use the tokenizers.js backend by itself, you can use it via https://www.npmjs.com/package/@huggingface/tokenizers, which is what Transformers.js uses as a dependency.
Repo: https://github.com/huggingface/tokenizers.js

@xenova xenova closed this Sep 20, 2026
@xenova xenova reopened this Sep 20, 2026
@xenova

xenova commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

(sorry, accidentally closed when I posted that comment)

Perhaps there is a particular use-case that you are trying to achieve? If so, and the above usage of tokenizers.js directly is insufficient, do let us know and we'd be happy to help :)

@koush

koush commented Sep 21, 2026

Copy link
Copy Markdown
Author

my use case is a custom cuda inference engine that just needs the tokenizer stuff. from_pretrained and apply_chat_template specifically. which the raw @huggingface/tokenizers package doesn't have, it's in the transformers.js wrapper layer. the tokenizer-only entry point in this PR gives me that without onnxruntime getting pulled in via the main entry point.

@koush

koush commented Oct 16, 2026

Copy link
Copy Markdown
Author

@xenova hi, any other way to address my use case?

This branch has not been deployed

No deployments
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.

2 participants