Fix infinite loop caused by incorrect timestamp tokens prediction#914
Conversation
|
Thank you! |
Jeronymous
left a comment
There was a problem hiding this comment.
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.
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.
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.
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 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>
Changes from openai/whisper#914
Changes from openai/whisper#914
* 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>
…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#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 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