ArticleslgStudy

computer science

Beam search

Beam search is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Beam search rather than just read about it. In short: In computer science, beam search is a heuristic search algorithm that explores a graph by expanding the most promising node in a limited set. Beam search is a modification of best-first search that reduces its memory requirements.

Beam search — main illustration
Beam search — illustration

Key takeaways

  • Beam search belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Beam search to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Beam search from memory before moving on to harder problems.

Reference excerpt

In computer science, beam search is a heuristic search algorithm that explores a graph by expanding the most promising node in a limited set. Beam search is a modification of best-first search that reduces its memory requirements. Best-first search is a graph search that orders all partial solutions (states) according to some heuristic. But in beam search, only a predetermined number of best partial solutions are kept as candidates. It is thus a greedy algorithm.

Details Beam search uses breadth-first search to build its 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. However, it only stores a predetermined number, β, 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 best-first search. Conversely, a beam width of 1 corresponds to a hill-climbing algorithm. 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).

Uses A beam search is most often used to maintain tractability in large systems with insufficient memory to store the entire search tree. For example, it has been used in many machine translation systems. (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 that best meets the goals.

History The Harpy Speech Recognition System (introduced in a 1976 dissertation) was the first use of what would become known as beam search. While the procedure was originally referred to as the "locus model of search", the term "beam search" became adopted by 1977.

Variants Beam search has been made complete by combining it with depth-first search, resulting in beam stack search and depth-first beam search, and with limited discrepancy search, resulting in beam search using limited discrepancy backtracking (BULB). The resulting search algorithms are anytime algorithms 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, we call local beam search a specific algorithm that begins selecting β randomly generated states and then, for each level of the search tree, it always considers β new states among all the possible successors of the current ones, until it reaches a goal. Since local beam search often ends up on local maxima, a common solution is to choose the next β 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. Other variants are flexible beam search and recovery beam search.

References

Illustrations

Beam search illustration

Worked examples

Example 1 — a first encounter with Beam search

Start with the simplest possible case. Write down what Beam search claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Beam search before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Beam search ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Beam search

In research
Beam search appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Beam search in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Beam search is common in secondary-school and first-year university syllabi. It links to neighbouring topics Search algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Beam search outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Beam search” →

How to study Beam search in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Beam search means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Beam search out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Beam search in simple terms?

In computer science, beam search is a heuristic search algorithm that explores a graph by expanding the most promising node in a limited set. Beam search is a modification of best-first search that reduces its memory requirements.

Why does Beam search matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Beam search?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Beam search.

Tags

  • Search algorithms

Keep exploring