Skip to content

Commit

Permalink
fix LM logprob
Browse files Browse the repository at this point in the history
  • Loading branch information
HKAB committed Oct 12, 2022
1 parent 3b543fc commit 7c413f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion whisper/decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def update(self, tokens: Tensor, logits: Tensor, sum_logprobs: Tensor) -> Tuple[
lm_score = self.lm.score(curr_prefix_str, bos = True, eos = False)
# Formula: https://pytorch.org/blog/fast-beam-search-decoding-in-pytorch-with-torchaudio-and-flashlight-text/
# convert lm_score log 10 to log e
logprob = logprob + self.lm_alpha*lm_score*2.303 + self.lm_beta*len(reverse_curr_prefix_str.split())
logprob = logprob - self.lm_alpha*lm_score*2.303 + self.lm_beta*len(reverse_curr_prefix_str.split())
new_logprob = (sum_logprobs[idx] + logprob).item()
# print(f"[Audio {i}, beam {j}]lm_score of {reverse_curr_prefix_str}: {lm_score}, new_logprob: {(sum_logprobs[idx] + logprob).item()}")
sequence = tuple(prefix + [token.item()])
Expand Down

0 comments on commit 7c413f0

Please sign in to comment.