Beam search: Difference between revisions

Content deleted Content added
Yoderj (talk | contribs)
Mention LLMs as state of art for translation where beam search is often applied.
OAbot (talk | contribs)
m Open access bot: url-access updated in citation with #oabot.
 
(12 intermediate revisions by 6 users not shown)
Line 1:
{{short description|Heuristic search algorithm}}
[[File:Beam search.gif|thumb|Beam search with width 3 (animation)]]
 
In [[computer science]], '''beam search''' is a [[heuristic (computer science)|heuristic]] [[search algorithm]] that explores a graph by expanding the most promising node in a limited set. Beam search is ana optimizationmodification of [[best-first search]] that reduces its memory requirements. Best-first search is a graph search which orders all partial solutions (states) according to a chosensome heuristic. But in beam search, only a predetermined number of best partial solutions are kept as candidates.<ref>{{Cite web |title=beam search |url=httphttps://foldoc.org/index.cgi?query=beam+search&action=Search|title=FOLDOC - Computing Dictionary|website=foldoc.org|access-date=20162024-0403-1127 |archive-datewebsite=2020[[Free On-01-25|archive-url=https://web.archive.org/web/20200125061837/http://foldoc.org/index.cgi?query=beam+search&action=Search|url-status=deadline Dictionary of Computing]]}}</ref> It is thus a [[greedy algorithm]]. Implemented with an unlimited set of candidates, beam search becomes a [[Backtracking|backtracking algorithm]].
 
The term "beam search" was coined by [[Raj Reddy]] of [[Carnegie Mellon University]] in 1977.<ref>{{Cite book |last=Defense Technical Information Center |url=http://archive.org/details/DTIC_ADA049288 |title=DTIC ADA049288: Speech Understanding Systems. Summary of Results of the Five-Year Research Effort at Carnegie-Mellon University |date=1977-08-01 |language=english}}</ref>
 
== Details ==
Beam search uses [[breadth-first search]] to build its [[Tree traversal|search tree]]. At each level of the tree, it generates all successors of the states at the current level, sorting them in increasing order of heuristic cost.<ref>{{Cite web|url=http://bradley.bradley.edu/~chris/searches.html|title=BRITISH MUSEUM SEARCH|website=bradley.bradley.edu|access-date=2016-04-11}}</ref> However, it only stores a predetermined number, <math>\beta</math>, of best states at each level (called the beam width). Only those states are expanded next. The greater the beam width, the fewer states are pruned. With an infinite beam width, no states are pruned and beam search is identical to [[breadthbest-first search]].<ref name=":0">{{Cite book |last=Norvig |first=Peter |url=https://books.google.com/books?id=QzGuHnDhvZIC&q=%22beam%20search%22 |title=Paradigms of Artificial Intelligence Programming: Case Studies in Common LISP |date=1992 |publisher=Morgan Kaufmann |isbn=9781558601918 |page=196}}</ref> Conversely, a beam width of 1 corresponds to a [[Hill climbing|hill-climbing]] algorithm.<ref name=":0" /> The beam width bounds the memory required to perform the search. Since a goal state could potentially be pruned, beam search sacrifices completeness (the guarantee that an algorithm will terminate with a solution, if one exists). Beam search is not optimal (that is, there is no guarantee that it will find the best solution).
<ref>{{Cite book|url=https://books.google.com/books?id=X4mhySvjqUAC|title=Paradigms of Artificial Intelligence Programming: Case Studies in Common LISP|last=Norvig|first=Peter|date=1992 |publisher=Morgan Kaufmann|isbn=9781558601918 }}</ref>
 
== Uses ==
A beam search is most often used to maintain tractability in large systems with insufficient amount of memory to store the entire search tree.<ref name="furcy"/> For example, it has been used in many [[machine translation]] systems.<ref>{{cite journal |last1=Tillmann |first1=C. |last2=Ney |first2=H. |title=Word reordering and a dynamic programming beam search algorithm for statistical machine translation |journal=Computational Linguistics |volume=29 |issue=1 |pages=97–133 |date=2003 |doi= 10.1162/089120103321337458|s2cid=7829066 |url=https://direct.mit.edu/coli/article-abstract/29/1/97/1794|doi-access=free }}</ref> (The state of the art now primarily uses [[neural machine translation]] based methods, especially [[large language models]].) To select the best translation, each part is processed, and many different ways of translating the words appear. The top best translations according to their sentence structures are kept, and the rest are discarded. The translator then evaluates the translations according to a given criterion, choosing the translation which best keeps the goals. The first use of a beam search was in the Harpy Speech Recognition System, CMU 1976.<ref>{{cite thesis |last

=Lowerre |first=Bruce T. |titleHistory=The Harpy Speech Recognition System |type=PhD |publisher=Carnegie Mellon University |date=1976 |url=https://cmu.primo.exlibrisgroup.com/permalink/01CMU_INST/1feg4j8/alma991010499929704436}}</ref>
 
The Harpy Speech Recognition System (introduced in a 1976 dissertation<ref>{{cite thesis |last=Lowerre |first=Bruce T. |title=The Harpy Speech Recognition System |type=PhD |publisher=Carnegie Mellon University |date=1976 |url=https://stacks.stanford.edu/file/druid:rq916rn6924/rq916rn6924.pdf}}</ref>) was the first use of what would become known as beam search.<ref>{{Cite journal |last1=Ow |first1=Peng Si |last2=Morton |first2=Thomas E. |date=1988 |title=Filtered beam search in scheduling† |url=http://www.tandfonline.com/doi/abs/10.1080/00207548808947840 |journal=International Journal of Production Research |language=en |volume=26 |issue=1 |pages=35–62 |doi=10.1080/00207548808947840 |issn=0020-7543|url-access=subscription }}</ref>
TheWhile termthe "beam search"procedure was coinedoriginally byreferred [[Rajto Reddy]]as the "locus model of [[Carnegiesearch", Mellonthe University]]term "beam search" was already in use by 1977.<ref>{{Cite book |last=Defense Technical Information Center |url=http://archive.org/details/DTIC_ADA049288 |title=DTIC ADA049288: Speech Understanding Systems. Summary of Results of the Five-Year Research Effort at Carnegie-Mellon University |date=1977-08-01 |page=6|language=english}}</ref>
== Variants ==
Beam search has been made [[Completeness (logic)|complete]] by combining it with [[depth-first search]], resulting in ''[[beam stack search]]''<ref>{{cite book |last1=Zhou |first1=Rong |last2=Hansen |first2=Eric |chapter=Beam-Stack Search: Integrating Backtracking with Beam Search |date=2005 |chapter-url=http://www.aaai.org/Library/ICAPS/2005/icaps05-010.php |title=ICAPS |pages=90–98 |access-date=2011-04-09 |archive-date=2021-04-20 |archive-url=https://web.archive.org/web/20210420205518/http://www.aaai.org/Library/ICAPS/2005/icaps05-010.php |url-status=dead }}</ref> and ''depth-first beam search'',<ref name="furcy" /> and with limited discrepancy search,<ref name=furcy>{{cite book |last1=Furcy |first1=D. |last2=Koenig |first2=S. |chapter=Limited discrepancy beam search |chapter-url=https://dl.acm.org/doi/abs/10.5555/1642293.1642313 |editor= |title=Proceedings of the 19th international joint conference on Artificial intelligence |publisher=Morgan Kaufmann |___location= |date=2005 |isbn= |pages=125–131 |url=}}</ref> resulting in ''beam search using limited discrepancy backtracking''<ref name="furcy" /> (BULB). The resulting search algorithms are [[anytime algorithm]]s that find good but likely sub-optimal solutions quickly, like beam search, then backtrack and continue to find improved solutions until convergence to an optimal solution.
 
In the context of a [[Local search (optimization)|local search]], we call ''local beam search'' a specific algorithm that begins selecting <math>\beta</math> randomly generated states and then, for each level of the search tree, it always considers <math>\beta</math> new states among all the possible successors of the current ones, until it reaches a goal.<ref>{{cite web|url=https://www.cs.unc.edu/~lazebnik/fall10/lec06_local_search.pdf|title=Local search algorithms|publisher=University of North Carolina at Chapel Hill, Department of Computer Science|page=15|author=Svetlana Lazebnik|author-link= Svetlana Lazebnik |archive-url=https://web.archive.org/web/20110705070334/http://www.cs.unc.edu/~lazebnik/fall10/lec06_local_search.pdf|archive-date=2011-07-05|url-status=live}}</ref><ref name="iitb">{{cite web|url=https://www.cse.iitb.ac.in/~cs344/2011/slides/cs344-beam-search-2feb11.pptx|title=Beam Search|publisher=Indian Institute of Technology Bombay, Department of Computer Science and Engineering (CSE)|pages=39–40|author=Pushpak Bhattacharyya|archive-url=https://web.archive.org/web/20181121123057/https://www.cse.iitb.ac.in/~cs344/2011/slides/cs344-beam-search-2feb11.pptx|archive-date=2018-11-21|url-status=live}}</ref>
 
Since local beam search often ends up on local maxima, a common solution is to choose the next <math>\beta</math> states in a random way, with a probability dependent from the heuristic evaluation of the states. This kind of search is called ''stochastic beam search''.<ref>{{cite web|url=http://www-users.cselabs.umn.edu/classes/Fall-2017/csci4511/slides/week4/9.28.17.pdf|title=Local Search|author=James Parker|page=17|publisher=University of Minnesota|date=2017-09-28|archive-url=https://web.archive.org/web/20171013150401/http://www-users.cselabs.umn.edu/classes/Fall-2017/csci4511/slides/week4/9.28.17.pdf|archive-date=2017-10-13|url-status=live|access-date=2018-11-21}}</ref>