当前位置: 首页 > wzjs >正文

手机网站类型英文服装商城网站建设

手机网站类型,英文服装商城网站建设,购物网上商城建设,帮助中心网站源码BLEU的完整介绍,请参考: 机器翻译指标:BLEU-CSDN博客https://blog.csdn.net/qq_54708219/article/details/148635887?spm1001.2014.3001.55021.计算机器译文中的n-gram: 第一步是将机器翻译生成的句子(Candidate Tr…

BLEU的完整介绍,请参考:

机器翻译指标:BLEU-CSDN博客https://blog.csdn.net/qq_54708219/article/details/148635887?spm=1001.2014.3001.55021.计算机器译文中的n-gram:

第一步是将机器翻译生成的句子(Candidate Translation)分解成连续的词序列片段,这些片段的长度就是 n

  • Unigram (1-gram):单个词。例如,句子 “the cat sat” 的 1-gram 是:["the"]["cat"]["sat"]

  • Bigram (2-gram):连续的两个词。例如:["the", "cat"]["cat", "sat"]

  • Trigram (3-gram):连续的三个词。例如:["the", "cat", "sat"]

  • 以此类推 (4-gram, 5-gram...)。

2.在参考译文中出现的比例

  • 对于机器译文中分解出来的 每一个 n-gram,检查它是否出现在 至少一个 人工提供的参考译文(Reference Translation)中。

  • 计算一个分数:匹配上的 n-gram 数量 / 机器译文中总的 n-gram 数量

  • 初步想法 (原始精确度 - Naive Precision): 直接数机器译文中每个 n-gram 出现的次数 (Count_candidate(ngram)),再数这个 n-gram 在参考译文中出现的次数 (Count_reference(ngram))。匹配数就是 min(Count_candidate(ngram), Count_reference(ngram))。对所有 n-gram 求和匹配数,除以机器译文中 n-gram 的总数。

  • 问题: 如果机器译文简单地大量重复参考译文中出现过的某个词(或短语),就能获得很高的分数,即使译文不通顺或信息不全。例如,机器译文只输出 “the the the the”,而参考译文中有 “the”,那么所有 1-gram “the” 都匹配上了,原始精确度=100%,但这显然不是好翻译。

3.修正 (Modified) 的关键:

为了解决上述问题,BLEU 对计数方式进行了修正,对于机器译文中的 某个特定 n-gram

  • 计算它在机器译文中出现的次数 (Count_candidate(ngram))。

  • 计算它在 所有参考译文 中出现的 最大次数 (Max_Ref_Count(ngram))

  • (1)如果有多个参考译文(通常推荐使用多个参考译文以提高评估可靠性),Max_Ref_Count(ngram) 是这个 n-gram 在 所有 参考译文中出现次数的最大值。

  • (2)如果只有一个参考译文,Max_Ref_Count(ngram) 就是它在该参考译文中出现的次数。

因此,这个 n-gram 的 有效匹配计数 被限制为:min(Count_candidate(ngram), Max_Ref_Count(ngram))

核心思想: 机器译文中的某个 n-gram,最多只能匹配它在 任意一个 参考译文里出现的次数。不能因为它在一个句子里重复出现多次,就获得超过参考译文最大支持次数的匹配数。

和原始精确度分析: 常见的原始精确度错误做法是:对于机器译文中出现的 每一种 n-gram 类型 (type),看它是否在参考译文中出现(出现则为1,否则为0),然后除以机器译文中 n-gram 类型 的总数。

  • 机器译文:the the the cat。Bigram 类型 只有两种:["the", "the"] 和 ["the", "cat"]

  • 参考译文中 ["the", "the"] 出现了 => 计 1, ["the", "cat"] 出现了 => 计 1。

  • 匹配的类型数 = 2, 机器中类型总数 = 2。

  • 原始 P₂ (错误类型法) = 2 / 2 = 100% (严重高估!它忽略了重复)

BLEU 修正 vs 原始类型法: BLEU 的修正方法既考虑了 n-gram 的 类型 是否匹配,更关键的是 考虑了 n-gram 词例 (token) 在句子中重复出现的次数是否超过了参考译文所能支持的最大次数。它惩罚了通过简单重复参考译文中存在的词汇来“刷分”的行为。


总结修正 n-gram 精确度的计算公式:

修正 n-gram 精确度 (Pₙ) = Σ (所有 n-gram 的有效匹配计数) / Σ (机器译文中所有 n-gram 的数量)

其中,对于 每个 n-gram:
有效匹配计数 = min(该 n-gram 在机器译文中出现的次数, 该 n-gram 在所有参考译文中出现的最大次数)


举例:

设参考译文 (reference):

[['the', 'cat', 'is', 'on', 'the', 'mat'],  # 参考1 (6个词)['there', 'is', 'a', 'cat', 'on', 'the', 'mat']]  # 参考2 (7个词)

和候选译文 (candidate):

['the', 'the', 'the', 'cat', 'on', 'the', 'mat']  # 7个词

任务:计算 (1-gram) (2-gram) (3-gram) 和(4-gram) 的修正精确度 

(1) 1-gram 精确度 (n=1)

候选次数参考1次数参考2次数最大参考次数有效计数
the4222min(4,2)=2
cat1111min(1,1)=1
on1111min(1,1)=1
mat1111min(1,1)=1
总和7---5

1-gram 精确度 = 5/7 ≈ 0.7143

(2) 2-gram 精确度 (n=2)

2-gram候选次数参考1出现?参考2出现?最大参考次数有效计数
(the, the)20min(2,0)=0
(the, the)20(已计入类型)
(the, cat)11min(1,1)=1
(cat, on)11min(1,1)=1
(on, the)11min(1,1)=1
(the, mat)11min(1,1)=1
总和6---4

2-gram 精确度 = 4/6 ≈ 0.6667

(3) 3-gram 精确度 (n=3)

3-gram候选次数参考1出现?参考2出现?最大参考次数有效计数
(the, the, the)100
(the, the, cat)100
(the, cat, on)100
(cat, on, the)111
(on, the, mat)111
总和5---2

3-gram 精确度 = 2/5 = 0.4

(4) 4-gram 精确度 (n=4)

4-gram候选次数参考1出现?参考2出现?最大参考次数有效计数
(the, the, the, cat)100
(the, the, cat, on)100
(the, cat, on, the)100
(cat, on, the, mat)111
总和4---1

4-gram 精确度 = 1/4 = 0.25

代码实现:

from nltk.translate.bleu_score import sentence_bleureference = [['the', 'cat', 'is', 'on', 'the', 'mat'], ['there', 'is', 'a', 'cat', 'on', 'the', 'mat']]
candidate = ['the', 'the', 'the', 'cat', 'on', 'the', 'mat']print('Individual 1-gram: %f' % sentence_bleu(reference, candidate, weights=(1, 0, 0, 0)))
print('Individual 2-gram: %f' % sentence_bleu(reference, candidate, weights=(0, 1, 0, 0)))
print('Individual 3-gram: %f' % sentence_bleu(reference, candidate, weights=(0, 0, 1, 0)))
print('Individual 4-gram: %f' % sentence_bleu(reference, candidate, weights=(0, 0, 0, 1)))# Individual 1-gram: 0.714286
# Individual 2-gram: 0.666667
# Individual 3-gram: 0.400000
# Individual 4-gram: 0.250000
http://www.dtcms.com/wzjs/784459.html

相关文章:

  • 石家庄做网站备案有哪些公司wordpress登录链接
  • 策划文案的网站门户网站ip地址段
  • 建站公司哪家好都选万维科技博客seo教程
  • 哪个网站可以免费设计房子ps网站首页怎么设计
  • 做教育的网站需要资质吗小程序开发源码
  • 同城的网站建设网络架构分层包括哪些
  • vps建设网站别人访问不了单页面网站模板
  • 广告模板在哪个网站好建设网站方法有哪些内容
  • 多个网站做计划制作音乐排行榜html5
  • 做网站 花时间php+mysql 2012也买酒商城网站源码
  • 新乡网站建设哪家优惠自己制作手机app软件
  • 新七建设集团有限公司网站手机开发者选项怎么打开
  • 站长推荐产品哪个网站可以做装修效果图
  • 做服装零售上什么网站网站首页的文字下拉怎么做
  • 青岛做网站的有哪些网站开发产品规划要求
  • 南昌网站忧化网站如何实现qq登录功能
  • 软件介绍网站源码移动网站建设价格
  • 备案 网站首页地址两学一做注册网站吗
  • 随州便宜做网站建教会网站的内容
  • 广州市住房建设部网站厦门同安建设局网站
  • 杭州做网站的公司也是网络品牌建设和推广的基础
  • 网站开发一般会使用框架吗html的制作网站的优点
  • 设计网站公司名称tk域名官方网站
  • 浙江公司网站建设推广网站怎么做地区屏蔽js
  • 深圳品牌网站设计公司价格做国学类网站合法吗
  • 国内十大网站建设网站建站报价单
  • 网站推广策划的策略优秀的个人网站
  • 手机网站建设事项浙江高端网站建设公司
  • 重庆公司网站seo建设网站预期效果怎么写
  • 腾讯云如何创建网站建设网站投资多少