beam search 和 greedy search

Search greedy (greedy search):

Greedy search for the most simple, direct select the maximum probability for each output until the terminator or a maximum sentence length.

 

 

 

Beam search (beam search):

Beam search can be considered greedy form of the Viterbi algorithm, the Viterbi all due to the dynamic programming leads to low efficiency when a large dictionary, while the number of beam search parameters to limit the use of beam size at each step retained the possibility of words . Beam search is a strategy in the testing phase in order to obtain better accuracy taken without the use of the training phase.

Suppose dictionary is [a, b, c], beam size selection 2, there is shown below:

1: In the first generation one word, select the most probable two words, then the current sequence is a or b

2: generating a second word, we will be the current sequence a or B, respectively, in combination with all the word dictionary, to obtain a new six sequences aa ab ac ba bb bc, and from which to select two highest probability , as the current sequence, i.e., ab or bb

3: repeat the process until the end of the character encountered so far. 2 sequence with the highest probability of the final output.

 

 

 

Obviously beam search belong to a greedy algorithm can not guarantee global optimal solution can be found, given the search space is too large, and the use of a relatively better solution. The Viterbi algorithm can quickly find the global optimum size is small in the dictionary.

The greedy search because the probability of each word of the moment to consider, usually in English some common structures, such as "is going", the larger the probability of occurrence will lead to the final sentence model generated too redundant. Such as "is visiting" and "is going to be visiting". Greedy search can be considered beam size is 1 cluster search exception.

Guess you like

Origin www.cnblogs.com/shona/p/11762873.html