MITLM 工具包安装及使用

由于项目需求,SRILM 工具无法支持某些功能(如使用LBFG等算法进行优化),查阅相关资料发现MITLM工具包可以完成。本文主要针对LINUX Ubuntu环境进行安装。
安装步骤如下:
1. 从google code站点(https://code.google.com/p/mitlm/) 或 github站点(https://github.com/mit-nlp/mitlm)下载工具包
2. 解压工具包后,进入mitlm目录
3. 由于工具包中有fortran模块,需要提前安装,执行 sudo apt-get install gfortran或sudo apt-get install ifort
4. 执行chmod +x ./autogen.sh命令,将目录下的autogen.sh脚本变成可执行文件
5. 运行./autogen.sh,若生成过程无报错,执行./configure
6. 上述步骤顺利执行后, 输入make -j,若无错误信息,则已通过编译安装

使用介绍:
MITLM工具包主要使用estimate-ngram命令来训练语言模型,除了支持常规的KN平滑外,-eval-perp 和 -opt-alg选项可控制是否需要计算perplexity和采用的优化算法,几命令如下:
1> ./estimate-ngram -t test.txt -wl test.opt.lm -eval-perp eva.txt (结果为12.813)
2> ./estimate-ngram -t test.txt -wl test.opt.lm -op dev.txt -eval-perp eva.txt (结果为 10.670)
3> ./estimate-ngram -t test.txt -wl test.opt.lm -op dev.txt -opt-alg LBFGS -eval-perp eva.txt (结果为10.671)
4> ./estimate-ngram -t test.txt -wl test.opt.lm -op dev.txt -opt-alg LBFGSB -eval-perp eva.txt (结果为10.672)

MITLM另外一大特色是在多模型融合时候除了常规的线性融合外支持优化算法,不过前提是需要通过计算一些额外的统计量。
1> 线性融合:
./estimate-ngram -t 1.txt -wl 1.lm -eval-perp eva.txt (结果为319.578)
./estimate-ngram -t 2.txt -wl 2.lm -eval-perp eva.txt (结果为12.480)
./interpolate-ngram -l “1.lm, 2.lm” -i LI -wl 1+2.li.lm -eval-perp eva.txt (结果为20.214)
./interpolate-ngram -t “1.txt, 2.txt” -i LI -wl 1+2.li.lm -eval-perp eva.txt (结果为20.214)

./interpolate-ngram -t “1.txt, 22.txt” -i LI -wl 1+2.li.opt.lm -op dev.txt -eval-perp eva.txt (结果为10.541)
./interpolate-ngram -l “1.lm, 2.lm” -i LI -wl 1+2.li.opt.lm -op dev.txt -eval-perp eva.txt (结果为10.481)
./interpolate-ngram -l “1.lm, 2.lm” -i LI -wl 1+2.li.opt.lm -op dev.txt -opt-alg LBFGS -eval-perp eva.txt (结果为10.481)
./interpolate-ngram -l “1.lm, 2.lm” -i LI -wl 1+2.li.opt.lm -op dev.txt -opt-alg LBFGSB -eval-perp eva.txt (结果为10.480)

2> 其他融合:
./estimate-ngram -t 1.txt -wc 1.counts -wec 1.effcounts -wlc 1.lcounts -wrc 1.rcounts
./estimate-ngram -t 2.txt -wc 2.counts -wec 2.effcounts -wlc 2.lcounts -wrc 2.rcounts
./interpolate-ngram -l “1.lm, 2.lm” -i CM -interpolation-features “log:sumhist:%s.effcounts” -wl 1+2.cm.op.lm -op dev.txt -eval-perp eva.txt (结果为12.480)
./interpolate-ngram -l “1.lm, 2.lm” -i GLI -wl 1+2.gil.op.lm -if “log:sumhist:%s.effcounts” -op dev.txt -eval-perp eva.txt (结果为12.480)
./interpolate-ngram -l “1.lm, 2.lm” -i GLI -wl 1+2.gil.op.lm -if “log:sumhist:%s.effcounts,pow2:log1p:sumhist:%s.counts” -op dev.txt -eval-perp eva.txt (结果为12.480)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值