From c3c6d4c3c40e97030f2aa1f3c9e4c1d37c0a1d88 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Mon, 10 Apr 2023 12:13:36 +0800 Subject: [PATCH] Support combining two LMs --- icefall/shared/combine_lm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icefall/shared/combine_lm.py b/icefall/shared/combine_lm.py index b6b7c8e95..d443db921 100755 --- a/icefall/shared/combine_lm.py +++ b/icefall/shared/combine_lm.py @@ -7,11 +7,11 @@ Given two LMs "A" and "B", this script modifies probabilities in A such that -P_{A_{new}}(w_n|w0,w1,...,w_{n-1}) = P_{A_{original}}(w_n|w0,w1,...,w_{n-1}) / P_{B}(w_n|w0,w1,...,w_{n-1}) +P_{A_{new}}(w_n|w_0,w_1,...,w_{n-1}) = P_{A_{original}}(w_n|w_0,w_1,...,w_{n-1}) / P_{B}(w_n|w_0,w_1,...,w_{n-1}) When it is formulated in log-space, it becomes -\log P_{A_{new}}(w_n|w0,w1,...,w_{n-1}) = \log P_{A_{original}}(w_n|w0,w1,...,w_{n-1}) - \log P_{B}(w_n|w0,w1,...,w_{n-1}) +\log P_{A_{new}}(w_n|w_0,w_1,...,w_{n-1}) = \log P_{A_{original}}(w_n|w_0,w_1,...,w_{n-1}) - \log P_{B}(w_n|w_0,w_1,...,w_{n-1}) Optionally, you can pass a scale for the LM "B", such that