BLEU指标的计算示例

ThisarticledetailsthecalculationofBLEU-4foramachinetranslationexample,usingn-gramstatisticsandprovidingaformulatodeterminethemetricbetweenanartificialandmachine-generatedtranslation.
摘要由CSDN通过智能技术生成

题目如下:

根据下图例子,计算下面机器翻译译文的BLEU-4值 (列出1-4元文法的统计数)
在这里插入图片描述
在这里插入图片描述

解:由题意得

1 − 4 元的统计数如下表所示: 1-4 元的统计数如下表所示: 14元的统计数如下表所示:
1-gram count ref count-clip it 1 0 0 is 1 1 1 a 1 1 1 nice 1 1 1 day 1 1 1 today 1 1 1 \begin{array}{|c|c|c|c|} \hline \text{1-gram} & \text{count} & \text{ref} & \text{count-clip} \\ \hline \text{it} & 1 & 0 & 0 \\ \hline \text{is} & 1 & 1 & 1 \\ \hline \text{a} & 1 & 1 & 1 \\ \hline \text{nice} & 1 & 1 & 1 \\ \hline \text{day} & 1 & 1 & 1 \\ \hline \text{today} & 1 & 1 & 1 \\ \hline \end{array} 1-gramitisanicedaytodaycount111111ref011111count-clip011111

2-gram count ref count-clip it is 1 0 0 is a 1 1 1 a nice 1 1 1 nice day 1 1 1 day today 1 0 0 \begin{array}{|c|c|c|c|} \hline \text{2-gram} & \text{count} & \text{ref} & \text{count-clip} \\ \hline \text{it is} & 1 & 0 & 0 \\ \hline \text{is a} & 1 & 1 & 1 \\ \hline \text{a nice} & 1 & 1 & 1 \\ \hline \text{nice day} & 1 & 1 & 1 \\ \hline \text{day today} & 1 & 0 & 0 \\ \hline \end{array} 2-gramit isis aa nicenice dayday todaycount11111ref01110count-clip01110

3-gram count ref count-clip it is a 1 0 0 is a nice 1 1 1 a nice day 1 1 1 nice day today 1 0 0 \begin{array}{|c|c|c|c|} \hline \text{3-gram} & \text{count} & \text{ref} & \text{count-clip} \\ \hline \text{it is a} & 1 & 0 & 0 \\ \hline \text{is a nice} & 1 & 1 & 1 \\ \hline \text{a nice day} & 1 & 1 & 1 \\ \hline \text{nice day today} & 1 & 0 & 0 \\ \hline \end{array} 3-gramit is ais a nicea nice daynice day todaycount1111ref0110count-clip0110

4-gram count ref count-clip it is a nice 1 0 0 is a nice day 1 1 1 a nice day today 1 0 0 \begin{array}{|c|c|c|c|} \hline \text{4-gram} & \text{count} & \text{ref} & \text{count-clip} \\ \hline \text{it is a nice} & 1 & 0 & 0 \\ \hline \text{is a nice day} & 1 & 1 & 1 \\ \hline \text{a nice day today} & 1 & 0 & 0 \\ \hline \end{array} 4-gramit is a niceis a nice daya nice day todaycount111ref010count-clip010

由表可得
p 1 = 5 6 , p 2 = 3 5 , p 3 = 2 4 , p 4 = 1 3 p_1 = \frac56 , p_2 = \frac35 , p_3 = \frac24 , p_4 = \frac13 p1=65p2=53p3=42p4=31
易知
c = 6 , r = 5 c = 6,r = 5 c=6,r=5

c > r c > r c>r

B P = 1 BP = 1 BP=1
画表如下:
Translation p 1 p 2 p 3 p 4 BP 人工译文: Today is a nice day 机器译文: It is a nice day today 5 6 3 5 2 4 1 3 1 ‾ \overline{\begin{array}{lllllll} &\text{Translation}&p_1&p_2&p_3&p_4&\text{BP}\\ \hline\text{人工译文:}&\text{Today is a nice day}&&&&&\\ \text{机器译文:}&\text{It is a nice day today}&\frac56&\frac35&\frac24&\frac13&1 \end{array}} 人工译文:机器译文:TranslationToday is a nice dayIt is a nice day todayp165p253p342p431BP1
因为 N = 4 N = 4 N=4 ,故 w n = 1 4 w_n = \frac14 wn=41

所以
BLEU-4 = B P ∗ exp ⁡ ( ∑ n = 1 N w n l o g P n ) = 1 × exp ⁡ ( 1 4 × ( log ⁡ ( p 1 ) + log ⁡ ( p 2 ) + log ⁡ ( p 3 ) + l o g ( p 4 ) ) ) = exp ⁡ ( 1 4 × log ⁡ ( p 1 p 2 p 3 p 4 ) ) = exp ⁡ ( 1 4 × l o g ( 5 6 × 3 5 × 2 4 × 1 3 ) ) = exp ⁡ ( 1 4 × l o g ( 1 12 ) ) ≈ 0.537 \begin{aligned} \text{BLEU-4}&=\mathrm{BP}*\exp(\sum_{n=1}^Nw_n\mathrm{log}P_n) \\ &= 1 \times \exp(\frac14 \times (\log(p_1) + \log(p_2) + \log(p_3) + log(p_4))) \\ &= \exp(\frac14 \times \log(p_1p_2p_3p_4)) \\ &= \exp(\frac14 \times log(\frac56 \times \frac35 \times \frac24 \times \frac13)) \\ &= \exp(\frac14 \times log(\frac{1}{12})) \\ &\approx 0.537 \end{aligned} BLEU-4=BPexp(n=1NwnlogPn)=1×exp(41×(log(p1)+log(p2)+log(p3)+log(p4)))=exp(41×log(p1p2p3p4))=exp(41×log(65×53×42×31))=exp(41×log(121))0.537

倘若大佬发现什么错误,敬请斧正,感谢感谢!

  • 17
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_a_yang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值