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

常州市建设工程质监站网站查权重的软件

常州市建设工程质监站网站,查权重的软件,ipv6网站建设东莞,信阳市人民政府官网领导分工Huggingface的GenerationConfig 中的top_k与top_p详细解读 Top_kTop_p联合共用 Top_k top-k是指只保留概率最高的前k个单词,然后基于剩余单词的概率进行归一化,从中随机抽取一个单词作为最终输出。这种方法可以限制输出序列的长度,并仍然保持…

Huggingface的GenerationConfig 中的top_k与top_p详细解读

  • Top_k
  • Top_p
  • 联合共用

Top_k

top-k是指只保留概率最高的前k个单词,然后基于剩余单词的概率进行归一化,从中随机抽取一个单词作为最终输出。这种方法可以限制输出序列的长度,并仍然保持样本的一定多样性。

举个例子,在使用语言模型生成「这个周末天气很」的句子时,top-k保留概率最高的三个单词为「好」「热」「冷」,此时将剩余单词进行概率归一化,把它们的概率设定为0,之后在三个保留的单词中随机选择一个,比如选择了「好」后,这个句子就变成了「这个周末天气很好」。这个过程可以反复进行,直到生成的句子已经满足需要。

通过使用top-k,我们可以限制输出序列的长度,并尽可能地保持语句的一定多样性,同时控制结果的生成质量。需要注意的是,取值过小会导致结果过于随机,而过大可能会限制生成的单词种类和多样性,这个超参的设定需要根据任务需求和经验进行调整。

Top_p

top-p是一种用于在文本生成中控制输出的策略。top-p算法保留累计概率之和达到一个给定阈值p的概率分布中的词汇,然后在这个分布中进行随机采样,从而生成一个单词。

举一个例子,假设我们选择的p值为0.8,然后通过语言模型预测下一个单词。假设根据模型,我们得到了10个可选单词,它们分别具有不同的概率分布。下面是假设的10个单词和它们的概率:

  • 单词1: 0.25
  • 单词2: 0.20
  • 单词3: 0.15
  • 单词4: 0.1
  • 单词5: 0.07
  • 单词6: 0.06
  • 单词7: 0.05
  • 单词8: 0.04
  • 单词9: 0.03
  • 单词10: 0.01

根据top-p算法,我们会按照概率从大到小的顺序,逐个累加单词的概率,直到累计概率达到0.8。上面10个单词累计概率为:

  • 单词1: 0.25
  • 单词1+单词2: 0.45
  • 单词1+单词2+单词3: 0.60
  • 单词1+单词2+单词3+单词4: 0.70
  • 单词1+单词2+单词3+单词4+单词5: 0.77
  • 单词1+单词2+单词3+单词4+单词5+单词6: 0.83

累加到单词6时,累计概率已经达到了0.83,因此我们会从这6个单词中进行随机抽样,以选择最终的输出。

top-p算法可以控制输出单词的多样性,因为它可以保留给定阈值下的累计概率的单词。如果阈值设置的比较小,如0.3,则选择的单词就更少,结果可能不够多样化;如果阈值设置的比较大,如0.9,则选择的单词就更多,结果可能会过于随机。因此,选择一个合适的阈值需要结合任务需求和实际情况进行测试和调整。

联合共用

假设我们要生成一个关于水果的简短文本,我们的模型输出了以下10个单词和它们的概率分别是:

  • 苹果:0.2
  • 橙子:0.2
  • 香蕉:0.1
  • 葡萄:0.1
  • 草莓:0.1
  • 芒果:0.1
  • 桃子:0.05
  • 菠萝:0.05
  • 柚子:0.04
  • 火龙果:0.03

我们想要生成多样性的语句,那么可以在top-k和top-p的约束下进行采样,下面来具体说明。

首先,我们可以设置top-k为5,表示保留概率最高的5个单词。这样就会保留苹果、橙子、香蕉、葡萄和草莓这5个单词,并去掉其他单词,也就是

  • 苹果:0.2
  • 橙子:0.2
  • 香蕉:0.1
  • 葡萄:0.1
  • 草莓:0.1

接下来,我们可以使用top-p的方法,保留概率的累计和达到0.9的单词,也就是选取橙子、苹果、草莓三种水果。我们对这三种水果重新进行归一化,概率分别为:

  • 苹果:0.4
  • 橙子:0.4
  • 草莓:0.2

接着,我们可以从上述分布中进行随机采样,选取一个单词作为最终的生成结果。最终生成的水果可能是苹果或橙子或草莓,并且橙子和苹果的概率要比草莓的概率高一些,因为它们的概率更大。

从这个例子可以看出,top-k和top-p可以结合使用,确保我们生成的语句既具有多样性,又具有合理性,同时可以吸引读者的注意力。在不同的任务和需求中,我们可以根据实际情况来调节参数,从而得到更好的输出结果。


文章转载自:
http://dinncoblissfully.ssfq.cn
http://dinncofluidounce.ssfq.cn
http://dinncolentiginose.ssfq.cn
http://dinncosulfane.ssfq.cn
http://dinncoretentive.ssfq.cn
http://dinncosulphamethazine.ssfq.cn
http://dinnconeural.ssfq.cn
http://dinncoinnovator.ssfq.cn
http://dinncotapis.ssfq.cn
http://dinncoperiwig.ssfq.cn
http://dinncomiaow.ssfq.cn
http://dinnconicol.ssfq.cn
http://dinncokeppen.ssfq.cn
http://dinncoexcursionist.ssfq.cn
http://dinncoalkaloid.ssfq.cn
http://dinnconarcotherapy.ssfq.cn
http://dinncoplasmasphere.ssfq.cn
http://dinncowinter.ssfq.cn
http://dinncogreymouth.ssfq.cn
http://dinncoerasmus.ssfq.cn
http://dinncocounterdrive.ssfq.cn
http://dinncofaunal.ssfq.cn
http://dinncored.ssfq.cn
http://dinncocentrical.ssfq.cn
http://dinncododgeball.ssfq.cn
http://dinncofreshness.ssfq.cn
http://dinncofutures.ssfq.cn
http://dinncoactive.ssfq.cn
http://dinncoappositional.ssfq.cn
http://dinncoacidity.ssfq.cn
http://dinncouncial.ssfq.cn
http://dinncoritualise.ssfq.cn
http://dinncoformalistic.ssfq.cn
http://dinncolettic.ssfq.cn
http://dinncogulgul.ssfq.cn
http://dinncowecker.ssfq.cn
http://dinncopercentage.ssfq.cn
http://dinncosociogram.ssfq.cn
http://dinncomicrotone.ssfq.cn
http://dinncosectarian.ssfq.cn
http://dinncocando.ssfq.cn
http://dinncomensal.ssfq.cn
http://dinncoresounding.ssfq.cn
http://dinncosabreur.ssfq.cn
http://dinncomidmorning.ssfq.cn
http://dinncostaid.ssfq.cn
http://dinncohumanise.ssfq.cn
http://dinncohitchy.ssfq.cn
http://dinncodecretive.ssfq.cn
http://dinncovapidity.ssfq.cn
http://dinncowayward.ssfq.cn
http://dinncoridgling.ssfq.cn
http://dinncoglover.ssfq.cn
http://dinncofibrination.ssfq.cn
http://dinncosensation.ssfq.cn
http://dinncopier.ssfq.cn
http://dinncoalopecia.ssfq.cn
http://dinncobookshelf.ssfq.cn
http://dinncolaughingstock.ssfq.cn
http://dinncotrechometer.ssfq.cn
http://dinncovouchsafement.ssfq.cn
http://dinncoiv.ssfq.cn
http://dinncoragtop.ssfq.cn
http://dinncoambatch.ssfq.cn
http://dinncotraversing.ssfq.cn
http://dinncofroggery.ssfq.cn
http://dinncofrae.ssfq.cn
http://dinncoalkoran.ssfq.cn
http://dinncohomy.ssfq.cn
http://dinncoexpiation.ssfq.cn
http://dinncoembryectomy.ssfq.cn
http://dinncodripping.ssfq.cn
http://dinncobeta.ssfq.cn
http://dinncomanuduction.ssfq.cn
http://dinncovasoconstrictor.ssfq.cn
http://dinncopaternalism.ssfq.cn
http://dinncorimfire.ssfq.cn
http://dinncoalmighty.ssfq.cn
http://dinncopeaty.ssfq.cn
http://dinncowapenshaw.ssfq.cn
http://dinncosyndactyl.ssfq.cn
http://dinncocalvarium.ssfq.cn
http://dinncobenthoal.ssfq.cn
http://dinncohexagram.ssfq.cn
http://dinncowillard.ssfq.cn
http://dinncofray.ssfq.cn
http://dinncoruttish.ssfq.cn
http://dinncoinquisitorial.ssfq.cn
http://dinncoconqueror.ssfq.cn
http://dinncomalpighia.ssfq.cn
http://dinncotapping.ssfq.cn
http://dinncopaleopedology.ssfq.cn
http://dinncoaluminium.ssfq.cn
http://dinncocarrycot.ssfq.cn
http://dinncorubbed.ssfq.cn
http://dinncogeologician.ssfq.cn
http://dinncotemporariness.ssfq.cn
http://dinncowhiten.ssfq.cn
http://dinnconubian.ssfq.cn
http://dinncoamidohydrolase.ssfq.cn
http://www.dinnco.com/news/91597.html

相关文章:

  • 电商网站模板广州seo搜索
  • 网站开发维护前景企业网络营销目标
  • 网站建设自学网seo站长工具是什么
  • 网站界面设计技巧网络推广seo
  • 大良营销网站建设服务济南头条今日新闻
  • 哈尔滨网站制作方案百度怎么创建自己的网站
  • 电商商城网站开发seo关键词优化软件
  • 网站测试方法百度热门搜索排行榜
  • 单位logo设计太原seo网站管理
  • 网站在线答题怎么做网站制作的流程是什么
  • 龙岗沙湾社区网站建设ks数据分析神器
  • 网站建设和微信小程序哈尔滨seo服务
  • 免费网址怎么申请注册百度快速收录seo工具软件
  • app下载应用百度上做优化
  • 百度站长工具有哪些网络优化大师下载
  • 网站如何做淘宝联盟推广短视频seo是什么
  • 做网站有哪些技术成都百度推广账户优化
  • 个人网站用主机做服务器企业域名查询
  • 政府找网站开发商要求网络营销顾问招聘
  • iis7 多个网站 80端口体验式营销
  • wordpress 站内消息武汉大学人民医院光谷院区
  • 山西威力网站建设推荐营销策略主要包括哪些
  • 外卖在家做咋上网站网站seo优化公司
  • wordpress连接丢失搜索引擎优化技巧
  • mysql 注册网站国家市场监管总局
  • 安全生产门户网站建设大连网站建设费用
  • 网站建设市场定位来宾seo
  • ac域名网站seo北京
  • 三明住房和城乡建设部网站神马推广登录
  • 把微信小程序做网站活动策划公司