Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the beam size represent in the beam search algorithm?

I have a question about the beam search algorithm.

Let's say that n = 2 (the number of nodes we are going to expand from every node). So, at the beginning, we only have the root, with 2 nodes that we expand from it. Now, from those two nodes, we expand two more. So, at the moment, we have 4 leafs. We will continue like this till we find the answer.

Is this how beam search works? Does it expand only n = 2 of every node, or it keeps 2 leaf nodes at all the times?

I used to think that n = 2 means that we should have 2 active nodes at most from each node, not two for the whole tree.

like image 252
Dimitar Spasovski Avatar asked Mar 08 '14 18:03

Dimitar Spasovski


1 Answers

In the "standard" beam search algorithm, at every step, the total number of the nodes you currently "know about" is limited - and NOT the number of nodes you will follow from each node.

Concretely, if n = 2, it means that the "beam" will be of size at most 2, at all times. So, initially, you start from one node, then you discover all nodes that are reachable from it, but discard all of them but two, and finish step 1 with 2 nodes. At step 2, you have two nodes, and you will expand both, and discard all nodes again, except exactly 2 nodes (total, not from each!). In the next steps, similarly, you will keep 2 nodes after each step.

Choosing which node to keep is usually done by some heuristic function that evaluates which node is closest to the target.

Note that the beam search algorithm is not complete (i.e., it may not find a solution if one exists) nor optimal (i.e. it may not find the best solution). The best way to see this is witnessing that when n = 1, it basically reduces to best-first-search.

like image 184
amit Avatar answered Nov 06 '22 12:11

amit