【问题标题】:Why does Kenlm lm model keep returning the same score for different words?为什么 Kenlm lm 模型不断为不同的单词返回相同的分数?
【发布时间】:2021-09-08 19:42:29
【问题描述】:

为什么 kenlm 模型返回相同的值?我也尝试过使用 4-gram arpa 文件。同样的问题。

import kenlm
model = kenlm.mode('lm/test.arpa') # unigram model. 

print( [f'{x[0]:.2f}, {x[1]}, {x[2]}' for x in model.full_scores('this is a sentence', bos=False, eos=False)])
print( [f'{x[0]:.2f}, {x[1]}, {x[2]}' for x in model.full_scores('this is a sentence1', bos=False, eos=False)])
print( [f'{x[0]:.2f}, {x[1]}, {x[2]}' for x in model.full_scores('this is a devil', bos=False, eos=False)])

结果:

['-2.00, 1, True', '-21.69, 1, False', '-1.59, 1, False', '-2.69, 1, True']

['-2.00, 1, True', '-21.69, 1, False', '-1.59, 1, False', '-2.69, 1, True']

['-2.00, 1, True', '-21.69, 1, False', '-1.59, 1, False', '-2.69, 1, True']

【问题讨论】:

    标签: lm kenlm


    【解决方案1】:

    我自己想出来的。

    输出中的 True/False 告诉您一个单词是否 OOV(超出词汇表)。 KenLM 模型为这些词分配一个固定的概率。在问题的示例中,所有最后的单词都是OOV。

    【讨论】:

      猜你喜欢
      • 2019-12-18
      • 2019-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-27
      • 1970-01-01
      • 2017-04-01
      • 1970-01-01
      相关资源
      最近更新 更多