-
Notifications
You must be signed in to change notification settings - Fork 419
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
Add lm decode for the Python API. #353
Conversation
Shouldn't double lm_log_prob when merge same prefix path
@@ -17,11 +17,6 @@ void Hypotheses::Add(Hypothesis hyp) { | |||
hyps_dict_[key] = std::move(hyp); | |||
} else { | |||
it->second.log_prob = LogAdd<double>()(it->second.log_prob, hyp.log_prob); | |||
|
|||
if (it->second.lm_log_prob != 0 && hyp.lm_log_prob != 0) { |
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.
Is there a reason to remove it?
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.
here two decoding paths that have the same prefix and we need to merge them into one path,
we can refer the Python implementation at here :https://github.com/k2-fsa/icefall/blob/2b3c5d799f3a585dc22071a9148424ff77aefd47/egs/librispeech/ASR/pruned_transducer_stateless2/beam_search.py#L843
python implementation perform (path1_am_prob * path1_lm_prob ) + (path2_am_prob * path2_lm_prob )
Since paths with the same prefix must have the same language model probability, we can simplify the calculation to 【path1_lm_prob * ( path1_am_prob + path2_am_prob )】
If we don't remove it , we actually perform (path1_am_prob + path2_am_prob ) * ( path1_lm_prob + path2_lm_prob)
simplified to 【 2 * path1_lm_prob * ( path1_am_prob + path2_am_prob )】
I have tested two opensource test set and compared result :
双人对话 | 中英混句 | |
---|---|---|
lm-shallow_fusion_0.1 | 15.18% | 22.26% |
lm-shallow_fusion_0.1_bug_fix | 15.03% | 21.99% |
test set reference :
https://www.openslr.org/123/
https://magichub.com/cn/competition/code-switching-asr-challenge/
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.
Thanks for the detailed explanation!
Thanks for your contribution! |
No description provided.