models icon indicating copy to clipboard operation
models copied to clipboard

DeepSpeech2 implementation detail not consistent with paper

Open lispc opened this issue 9 years ago • 4 comments

https://github.com/PaddlePaddle/models/blob/develop/deep_speech_2/decoders/scorer_deprecated.py#L67

score = self._alpha * np.log(lm) + self._beta * np.log(word_cnt)

While in the original paper, there is no log with word_cnt.

lispc avatar Nov 08 '17 05:11 lispc

@lispc Please note the if...else... condition outside this line. Users can set the flag log to choose whether return the score in log scale or in the original format. When in log scale, there should be a log operation with the word insertion term.

kuke avatar Nov 08 '17 07:11 kuke

@kuke no. the original formula is image so, maybe the correct code is

if log == False:
    score = np.power(lm, self._alpha) * np.power(10, word_cnt * self._beta) # in exp format
else:
    score = self._alpha * np.log(lm) + self._beta * word_cnt # as is original paper

?

lispc avatar Nov 08 '17 08:11 lispc

@lispc I see.

Actually the deprecated Python decoder is based on the prefix beam search paper, which we have declared in the comments. For the right code of the formula above, you should refer to the corresponding line in the C++ decoder that we are using.

They two have difference in the word insertion term.

kuke avatar Nov 08 '17 11:11 kuke

ok. got. Thanks~

lispc avatar Nov 08 '17 11:11 lispc