Skip to content

Conversation

@sanchit-gandhi
Copy link
Contributor

@sanchit-gandhi sanchit-gandhi commented Dec 5, 2022

What does this PR do?

The previous PR #20589 incorrectly returned a list of forced decoder ids:

from transformers import WhisperProcessor

processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en")
print(processor.get_decoder_prompt_ids(task="transcribe"))

Print Output:

[50257, 50358, 50362]

The correct format is a nested list of decoder ids, where the first element of each list specifies the position of the forced token and the second the token id:

print(processor.get_decoder_prompt_ids(task="transcribe"))

Print Output:

[(1, 50257), (2, 50358), (3, 50362)]

(at position 1 we force token 50257, at 2 we force 50358, at 3 we force 50362)

The PR also implements a test, thus making sure that no such error can be made again 😅

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Dec 5, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

Copy link
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.

Thanks for the quick fix

Comment on lines +586 to +588
self.set_prefix_tokens(task=task, language=language, predict_timestamps=not no_timestamps)
forced_decoder_ids = [(rank + 1, token) for rank, token in enumerate(self.prefix_tokens)]
return forced_decoder_ids
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch! I should have realized when reviewing!

msg="`processor` and `feature_extractor` model input names do not match",
)

def test_get_decoder_prompt_ids(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice!

@sanchit-gandhi sanchit-gandhi merged commit 74fb524 into huggingface:main Dec 5, 2022
mpierrau pushed a commit to mpierrau/transformers that referenced this pull request Dec 15, 2022
* [Whisper] Fix decoder ids methods

* enum property
@sanchit-gandhi sanchit-gandhi deleted the whisper-tok-fix branch June 25, 2023 09:53
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.

4 participants