Skip to content

Add support for shallow biasing of Whisper #1889

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
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

anthonyrathe
Copy link

@anthonyrathe anthonyrathe commented May 2, 2025

Attempting to fix #1789 by @zwycl

Adds an optional contextual biasing parameter to the Whisper model to enable shallow contextual biasing toward given sequences by modifying logits. This is a flexible and fairly simple method useful for transcribing out-of-vocabulary entities in ASR or mitigating harmful mistranscriptions toward unwanted token sequences. Similar parameter is implemented in the HuggingFace package: https://huggingface.co/docs/transformers/en/internal/generation_utils#transformers.SequenceBiasLogitsProcessor

@MrigankRaman
Copy link

Attempting to merge #1789

Do you have the python wheels for this branch? I would like to use it

@anthonyrathe anthonyrathe changed the title Add biasing Add support for shallow biasing of Whisper May 18, 2025
@anthonyrathe
Copy link
Author

Attempting to merge #1789

Do you have the python wheels for this branch? I would like to use it

Yes, you can find the links to the wheels via the checks below.

@anthonyrathe
Copy link
Author

@minhthuc2502 would you mind taking a look at this PR? Would love to get this released!

@MrigankRaman
Copy link

Attempting to merge #1789

Do you have the python wheels for this branch? I would like to use it

Yes, you can find the links to the wheels via the checks below.

There might be a bug in this PR. When I use sequence bias with a model compiled in int8_float16 I get this error

ValueError: expected storage to be of type float16, but is of type float32

which I dont get when I use sequence_bias as None. The exact same input

@MrigankRaman
Copy link

Attempting to merge #1789

Do you have the python wheels for this branch? I would like to use it

Yes, you can find the links to the wheels via the checks below.

There might be a bug in this PR. When I use sequence bias with a model compiled in int8_float16 I get this error

ValueError: expected storage to be of type float16, but is of type float32

which I dont get when I use sequence_bias as None. The exact same input

Sorry I resolved. Does this increase latency?

@anthonyrathe
Copy link
Author

Sorry I resolved. Does this increase latency?

It does, unfortunately. Especially if the number of sequences to bias is large.

@MrigankRaman
Copy link

Sorry I resolved. Does this increase latency?

It does, unfortunately. Especially if the number of sequences to bias is large.

Where does this latency increase come from?

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