Skip to content
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

Auto-detect wordpiece tokenizer when model.type is missing #1151

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xenova
Copy link
Collaborator

@xenova xenova commented Jan 16, 2025

Some old wordpiece tokenizers do not have model.type saved inside tokenizer.json. This PR adds logic to auto-detect when this is the case. Thanks to @pcuenca for finding this! 🤗

if (config.vocab) {
if (Array.isArray(config.vocab)) {
// config.vocab is of type `[string, number][]`
// @ts-ignore
return new Unigram(config, ...args);
} else if (typeof config.vocab === 'object' && config.continuing_subword_prefix && config.unk_token) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@pcuenca
Copy link
Member

pcuenca commented Jan 16, 2025

By the way, I'm @pcuenca here (but it's fine, @pcuenq is an alt account 😂)

@xenova
Copy link
Collaborator Author

xenova commented Jan 16, 2025

By the way, I'm @pcuenca here (but it's fine, @pcuenq is an alt account 😂)

lol whoops - I think I auto-completed your twitter username 😅

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