-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Fix infinite loop caused by incorrect timestamp tokens prediction #914
Fix infinite loop caused by incorrect timestamp tokens prediction #914
Conversation
Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The infinite loop can still happen, so I suggest to go further with this bugfix
timestamps = sampled_tokens[sampled_tokens.ge(self.tokenizer.timestamp_begin)] | ||
if timestamps.numel() > 0: | ||
# timestamps shouldn't decrease; forbid timestamp tokens smaller than the last | ||
logits[k, self.tokenizer.timestamp_begin : timestamps[-1]] = -np.inf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not enough to prevent the infinite loop (see discussion #924) because it is not preventing the model to always output <|0.00|>
Suggestion:
timestamp_last = max(timestamps[-1], self.tokenizer.timestamp_begin + 1) # Avoid to emit <|0.00|> again
logits[k, self.tokenizer.timestamp_begin : timestamp_last] = -np.inf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better suggestion is:
if last_was_timestamp and not penultimate_was_timestamp:
timestamp_last = timestamps[-1]
else:
timestamp_last = timestamps[-1] + 1
logits[k, self.tokenizer.timestamp_begin : timestamp_last] = -np.inf
to force that timestamps are strictly increasing after a speech segment / increasing between the end of a speech segment and the start of the next one.
Is anyone looking at this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great solution @Jeronymous! I checked it and it works.
With your permission, Im gonna create a new PR to speed up this change. Im gonna mention your suggestion.
Changes from openai/whisper#914
Following the suggestions of @Jeronymous in openai#914 and openai#924, it solves the problem of endless loop.
New fix for endless loop problem. I also created a PR for official Whisper: openai/whisper#1155 It is explained in openai/whisper#914 and openai/whisper#924
* Update decoding.py Following the suggestions of @Jeronymous in #914 and #924, it solves the problem of endless loop. * Removed blank line and whitespaces in empty lines. * Suggested changes according to the linter --------- Co-authored-by: Jong Wook Kim <jongwook@openai.com>
…enai#914) * Fix infinite loop caused by incorrect timestamp tokens prediction openai#810 * Update decoding.py --------- Co-authored-by: Jong Wook Kim <jongwook@openai.com>
* Update decoding.py Following the suggestions of @Jeronymous in openai#914 and openai#924, it solves the problem of endless loop. * Removed blank line and whitespaces in empty lines. * Suggested changes according to the linter --------- Co-authored-by: Jong Wook Kim <jongwook@openai.com>
…enai#914) * Fix infinite loop caused by incorrect timestamp tokens prediction openai#810 * Update decoding.py --------- Co-authored-by: Jong Wook Kim <jongwook@openai.com>
* Update decoding.py Following the suggestions of @Jeronymous in openai#914 and openai#924, it solves the problem of endless loop. * Removed blank line and whitespaces in empty lines. * Suggested changes according to the linter --------- Co-authored-by: Jong Wook Kim <jongwook@openai.com>
…enai#914) * Fix infinite loop caused by incorrect timestamp tokens prediction openai#810 * Update decoding.py --------- Co-authored-by: Jong Wook Kim <jongwook@openai.com>
* Update decoding.py Following the suggestions of @Jeronymous in openai#914 and openai#924, it solves the problem of endless loop. * Removed blank line and whitespaces in empty lines. * Suggested changes according to the linter --------- Co-authored-by: Jong Wook Kim <jongwook@openai.com>
* Update decoding.py Following the suggestions of @Jeronymous in openai/whisper#914 and https://github.com/openai/whisper/discussions/924, it solves the problem of endless loop. * Removed blank line and whitespaces in empty lines. * Suggested changes according to the linter --------- Co-authored-by: Jong Wook Kim <jongwook@openai.com>
* Update decoding.py Following the suggestions of @Jeronymous in openai/whisper#914 and openai/whisper#924, it solves the problem of endless loop. * Removed blank line and whitespaces in empty lines. * Suggested changes according to the linter --------- Co-authored-by: Jong Wook Kim <jongwook@openai.com>
#810