What Is Beam Search in AI?

Beam Search Explainer

Beam search is a decoding method that keeps several promising partial sequences while a model generates an output. At each step, it expands the current candidates with possible next tokens, scores the results, and retains only a fixed number called the beam width.

A beam width of one is equivalent to greedy decoding. Wider beams explore more alternatives and can find a sequence with a better model score, but they require more computation and memory. Scores are often adjusted for length so short sequences are not favored automatically.

Beam search has been widely used in translation, speech recognition, captioning, and other sequence tasks. It is an approximate search because the number of possible sequences grows too quickly to examine exhaustively.

A higher model probability does not always mean a better human-facing answer. Wide beams can produce generic or repetitive text, and open-ended generation may benefit more from sampling. The decoding rule should be selected and evaluated for the task.

Beam search keeps several promising partial sequences at each generation step instead of committing to only one next token.

Key terms include decoding, partial sequence, beam width, candidate, sequence score, length penalty, greedy decoding, search and generation.

Each step expands the surviving sequences and prunes the combined set back to the configured beam width.

The process continues until candidates end or a limit is reached, after which the highest adjusted score is selected.

Larger beams cost more and may favor safe, generic outputs rather than diverse or engaging language.

Teams compare task metrics and human judgments across decoding settings instead of assuming maximum model probability is the true objective.

Explore more "Explainers"

Discover additional explainers across politics, science, business, technology, and other fields. Each explainer breaks down a complex idea into clear, everyday language—helping you better understand how major concepts, systems, and debates shape the world around us.