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

Faster whisper loads the wrong tokenizer for whisper-large-v3 derivatives #835

Open
AmgadHasan opened this issue May 13, 2024 · 2 comments

Comments

@AmgadHasan
Copy link

Hi
If the tokenizer.json isn't available in the model directory, the faster-whisper loaded automatically downloads the tokenizer from huggingface which is a good thing. However, it always downloads the openai/whisper-tiny tokenizer. This can cause problems if the model used is or derived from whisper-large-v3 as it has a different tokenizer; the task token_ids are offset by 1 since it has introduced a new language id.

Can we modify the code so that

tokenizer_file = os.path.join(model_path, "tokenizer.json")
        if tokenizer_bytes:
            self.hf_tokenizer = tokenizers.Tokenizer.from_buffer(tokenizer_bytes)
        elif os.path.isfile(tokenizer_file):
            self.hf_tokenizer = tokenizers.Tokenizer.from_file(tokenizer_file)
        else:
            self.hf_tokenizer = tokenizers.Tokenizer.from_pretrained(
                "openai/whisper-tiny" + ("" if self.model.is_multilingual else ".en")
            )
@AmgadHasan
Copy link
Author

I created a PR to fix this issue
#834

@AmgadHasan
Copy link
Author

Can you please check this issue and related PR?
@trungkienbkhn

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

No branches or pull requests

1 participant