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参数是 对象 ...
随机推荐
- am335x system upgarde ddr3 capacity configuration base on TI DDR3 Software Leveling Tool (二十)
follow test is use ti DDR Software Leveling op log. AM335x DDR3 Software Leveling -- Version: Beta ...
- 自己总结:汇编CALL和RET指令
ret指令,相当于 pop IP:修改IP的内容,从而实现近转移 retf指令,相当于 pop IP pop CS:修改CS和IP的内容,从而实现远转移 -------------- CPU执行cal ...
- 期望与概率dp
概率与期望dp 定义: 概率:事件A发生的可能性,计作P(A) 期望:事件A结果的平均大小,记住E(x) E(x)=每种结果的大小与其概率的乘积的和 注意计算概率时需要考虑是否要用容斥原理 期望d ...
- python 绘制五角星
code import turtle n = eval(input("请输入五角星的长度")) turtle.begin_fill() #开始填充颜色 i = : turtle.f ...
- epoll反应堆
/* * epoll基于非阻塞I/O事件驱动 */ #include <stdio.h> #include <sys/socket.h> #include <sys/ep ...
- input输入框只能输入数字和英文逗号
<input type="text" onkeyup="this.value=this.value.replace(/[^\d\,]/g,'')"> ...
- linux下编译利用CMakeLists.txt 编译C++写的opencv程序
https://hihozhou.com/blog/2017/05/11/linux-compile-opencv-c++-file.html cmake . make -j8
- 【Docker】docker 的常用命令&操作
一.在linux虚拟机上安装docker XShell1:检查内核版本,必须是3.10及以上 uname -r2:安装docker yum install docker3:输入y确认安装4:启动doc ...
- openwrt系统源码地址
https://dev.openwrt.org/wiki/GetSource http://www.openwrtdl.com/wordpress/openwrt-full-tutorial
- Nginx-HTTP之静态网页访问流程分析二
11. HTTP 阶段执行 下面会依次执行以下阶段: NGX_HTTP_SERVER_REWRITE_PHASE: 在将请求的 URI 与 location 表达式匹配前,修改请求的 URI (所谓重 ...