lm - 为什么 Kenlm lm 模型不断为不同的单词返回相同的分数?
问题描述
为什么 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']
解决方案
我自己想出来的。
输出中的 True/False 告诉您一个单词是否 OOV(超出词汇表)。KenLM 模型为这些词分配一个固定的概率。在问题的示例中,所有最后的单词都是 OOV。
推荐阅读
- python - 如何更新 matplotlib 条形图动画的标题和数据?
- sql - 如何理解前 2 行和当前行之间的行的结果?
- android - Flutter - 选项卡上的动态高度
- javascript - 姜戈。如何完全隐藏表单中的字段?
- html - 带有自定义断点的 Bootstrap 4 navbar-expand-* 不起作用
- iis - 为什么我会收到“与 SQL Server 建立连接时发生与网络相关或特定于实例的错误。”?
- c++ - 当我基本上复制代码时,为什么会得到不同的输出?(删除节点并用最深的节点替换)
- c# - 使用基于 ReactiveUI C# 的绑定绑定到 DataGridColumn
- typescript - 为网站管理多个打字稿文件的正确方法
- c# - 窗口焦点在最小化/恢复 chrome 浏览器窗口和 chrome 扩展时丢失