BLEU的计算

摘录部分学习记录~

1. 简介

BLEU(Bilingual Evaluation Understudy),相信大家对这个评价指标的概念已经很熟悉,随便百度谷歌就有相关介绍。原论文为BLEU: a Method for Automatic Evaluation of Machine Translation,IBM出品。

本文通过一个例子详细介绍BLEU是如何计算以及NLTKnltk.align.bleu_score模块的源码。

首先祭出公式:

注意这里的BLEU值是针对一条翻译(一个样本)来说的。

NLTKnltk.align.bleu_score模块实现了这里的公式,主要包括三个函数,两个私有函数分别计算P和BP,一个函数整合计算BLEU值。

例子:

候选译文(Predicted): 
It is a guide to action which ensures that the military always obeys the commands of the party

参考译文(Gold Standard) 
1:It is a guide to action that ensures that the military will forever heed Party commands 
2:It is the guiding principle which guarantees the military forces always being under the command of the Party 
3:It is the practical guide for the army always to heed the directions of the party

2. Modified n-gram Precision计算(也即是Pn)

我们这里n取值为4,也就是从1-gram计算到4-gram。

Modified 1-gram precision:

首先统计候选译文里每个词出现的次数,然后统计每个词在参考译文中出现的次数,Max表示3个参考译文中的最大值,Min表示候选译文和Max两个的最小值。

然后将每个词的Min值相加,将候选译文每个词出现的次数相加,然后两值相除即得

P1=(3+0+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)/(3+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1)=0.95

类似可得:

Modified 2-gram precision:

P2=10/17=0.588235294   P2=10/17=0.588235294

Modified 3-gram precision:

下面计算BP(Brevity Penalty),翻译过来就是“过短惩罚”。由BP的公式可知取值范围是(0,1],候选句子越短,越接近0。

候选翻译句子长度为18,参考翻译分别为:16,18,16。 
所以c=18,r=18(参考翻译中选取长度最接近候选翻译的作为rr)

所以


4. 整合

最终

BLEU的取值范围是[0,1],0最差,1最好。

通过计算过程,我们可以看到,BLEU值其实也就是“改进版的n-gram”加上“过短惩罚因子”。

这里只是部分解释,原作者还有实现...棒!机器翻译之BLEU值_心有猛虎 细嗅蔷薇-CSDN博客_bleu1. 简介BLEU(Bilingual Evaluation Understudy),相信大家对这个评价指标的概念已经很熟悉,随便百度谷歌就有相关介绍。原论文为BLEU: a Method for Automatic Evaluation of Machine Translation,IBM出品。本文通过一个例子详细介绍BLEU是如何计算以及NLTKnltk.align.bleu_scor...https://blog.csdn.net/qq_36652619/article/details/87544918

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值