-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Update decoding.py #1155
Update decoding.py #1155
Conversation
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
Hi, looks like I can't add commits to your branch. Could you delete whitespaces in the two empty lines and also remove the line 17? |
Done! |
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 linter is being very picky here 😅
whisper/decoding.py
Outdated
timestamp_last = timestamps[-1] | ||
else: | ||
timestamp_last = timestamps[-1] + 1 | ||
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.
logits[k, self.tokenizer.timestamp_begin: timestamp_last] = -np.inf | |
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.
Done!
whisper/decoding.py
Outdated
@@ -14,7 +14,6 @@ | |||
if TYPE_CHECKING: | |||
from .model import Whisper | |||
|
|||
|
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.
Please restore this deleted line
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.
Done!
@@ -471,6 +471,13 @@ def apply(self, logits: Tensor, tokens: Tensor): | |||
# 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.
Forgot to mention that this line is no longer needed but I'll fix it in a subsequent PR
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
Following the suggestions of @Jeronymous in #914 and #924, it solves the problem of endless loop.