Skip to content

Implement from_bytes and read_bytes Methods in WordPiece Tokenizer for WebAssembly Compatibility#1758

Merged
ArthurZucker merged 3 commits intohuggingface:mainfrom
sondalex:add_wordpiece_methods
Jul 29, 2025
Merged

Implement from_bytes and read_bytes Methods in WordPiece Tokenizer for WebAssembly Compatibility#1758
ArthurZucker merged 3 commits intohuggingface:mainfrom
sondalex:add_wordpiece_methods

Conversation

@sondalex
Copy link
Copy Markdown
Contributor

Description:

This Pull Request introduces the implementation of from_bytes and read_bytes methods within the WordPiece tokenizer. These methods were added to improve integration with WebAssembly (Wasm). As model downloading is managed on the JavaScript side in a Wasm target environment, methods compatible with u8 types facilitates the transfer of a Uint8Array from JavaScript to Rust.

Copy link
Copy Markdown
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Yeah sure! 🤗

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@ArthurZucker ArthurZucker merged commit ed2cda5 into huggingface:main Jul 29, 2025
29 checks passed
vocab.insert(line.trim_end().to_owned(), index as u32);
}

Ok(vocab)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this currently breaks on main! We switch to using AHashmap, I suspect the branch was not up to date

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

will fix

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.

3 participants