beam search 和 greedy search
贪心搜索(greedy search):
贪心搜索最为简单,直接选择每个输出的最大概率,直到出现终结符或最大句子长度。

集束搜索(beam search):
集束搜索可以认为是维特比算法的贪心形式,在维特比所有中由于利用动态规划导致当字典较大时效率低,而集束搜索使用beam size参数来限制在每一步保留下来的可能性词的数量。集束搜索是在测试阶段为了获得更好准确性而采取的一种策略,在训练阶段无需使用。
假设字典为[a,b,c],beam size选择2,则如下图有:
1:在生成第1个词的时候,选择概率最大的2个词,那么当前序列就是a或b
2:生成第2个词的时候,我们将当前序列a或b,分别与字典中的所有词进行组合,得到新的6个序列aa ab ac ba bb bc,然后从其中选择2个概率最高的,作为当前序列,即ab或bb
3:不断重复这个过程,直到遇到结束符为止。最终输出2个概率最高的序列。

显然集束搜索属于贪心算法,不能保证一定能够找到全局最优解,因为考虑到搜索空间太大,而采用一个相对的较优解。而维特比算法在字典大小较小时能够快速找到全局最优解。
而贪心搜索由于每次考虑当下词的概率,而通常英文中有些常用结构,如“is going”,出现概率较大,会导致模型最终生成的句子过于冗余。如“is visiting”和“is going to be visiting”。贪心搜索可以认为beam size为1时的集束搜索特例。
beam search 和 greedy search的更多相关文章
- 集束搜索beam search和贪心搜索greedy search
贪心搜索(greedy search) 贪心搜索最为简单,直接选择每个输出的最大概率,直到出现终结符或最大句子长度. 集束搜索(beam search) 集束搜索可以认为是维特比算法的贪心形式,在维特 ...
- Comparing randomized search and grid search for hyperparameter estimation
Comparing randomized search and grid search for hyperparameter estimation Compare randomized search ...
- 【起航计划 032】2015 起航计划 Android APIDemo的魔鬼步伐 31 App->Search->Invoke Search 搜索功能 Search Dialog SearchView SearchRecentSuggestions
Search (搜索)是Android平台的一个核心功能之一,用户可以在手机搜索在线的或是本地的信息.Android平台为所有需要提供搜索或是查询功能的应用提 供了一个统一的Search Framew ...
- [Math] Beating the binary search algorithm – interpolation search, galloping search
From: http://blog.jobbole.com/73517/ 二分检索是查找有序数组最简单然而最有效的算法之一.现在的问题是,更复杂的算法能不能做的更好?我们先看一下其他方法. 有些情况下 ...
- LeetCode:Search Insert Position,Search for a Range (二分查找,lower_bound,upper_bound)
Search Insert Position Given a sorted array and a target value, return the index if the target is fo ...
- leetcode 704. Binary Search 、35. Search Insert Position 、278. First Bad Version
704. Binary Search 1.使用start+1 < end,这样保证最后剩两个数 2.mid = start + (end - start)/2,这样避免接近max-int导致的溢 ...
- Depth-first search and Breadth-first search 深度优先搜索和广度优先搜索
Depth-first search Depth-first search (DFS) is an algorithm for traversing or searching tree or grap ...
- [Algorithm] Beating the Binary Search algorithm – Interpolation Search, Galloping Search
From: http://blog.jobbole.com/73517/ 二分检索是查找有序数组最简单然而最有效的算法之一.现在的问题是,更复杂的算法能不能做的更好?我们先看一下其他方法. 有些情况下 ...
- AngularJS filter:search 是如何匹配的 ng-repeat filter:search ,filter:{$:search},只取repeat的item的value 不含label
1. filter可以接收参数,参数用 : 进行分割,如下: {{ expression | filter:argument1:argument2:... }} 2. filter参数是 对象 ...
随机推荐
- Codeforces Round #588 (Div. 2) E. Kamil and Making a Stream(DFS)
链接: https://codeforces.com/contest/1230/problem/E 题意: Kamil likes streaming the competitive programm ...
- [Debug] Debugger Statements
For example you have the following code; function reverse(str) { let reversed = ""; for (l ...
- 记一次antlr错误:ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.2ANTLR
场景:重构spark 2.1版本的sql语法.因此 需要使用antlr: 前期准备:idea安装了antlr插件(antlr的4.7.2版本) 因此在maven工程中添加了antlr的依赖: < ...
- KDC添加加密
零售KDC管理的域为TESTA.COM 华为集群管理的域为hadoop.com (目前测试了hdfs cli,下午在UAT集群测试下distcp) 一. 零售KDC升级支持AES ...
- mybatis 对string类型判断比较 group case when then 综合
[quote] 特别注意两点 一个是where 的用法group的用法 case when的用法 <if test='hasLoanApplicationFlag == "1" ...
- pl/sql Developer连接oracle远程数据库
1.下载地址:PLSQL Developer 12.1正式版64位(含中文语言包.注册码).rar https://download.csdn.net/download/bokewangyu/11 ...
- ARTS打卡计划第七周
Algorithms: https://leetcode-cn.com/problems/longest-common-prefix/ Review: https://link.medium.com/ ...
- Zookeeper系列(十三)Zookeeper的请求处理
作者:leesf 掌控之中,才会成功:掌控之外,注定失败. 出处:http://www.cnblogs.com/leesf456/p/6179118.html尊重原创,奇文共欣赏: 一.前言 在 ...
- python之json读写
#将字典转json并写入文件 import json i=3 j=5 a={'a':i,'b':j} js=json.dumps(a) print(js) with open("/Users ...
- Mybatis-Plus BaseMapper自动生成SQL及MapperProxy
目录 Spring+Mybatis + Mybatis-Plus 自定义无XML的sql生成及MapperProxy代理生成 问题产生背景 框架是如何使用 无Xml的SQL是如何生成生成及SQL长成什 ...