liveBook · Manning

Beam search

Beam search is a heuristic search and decoding technique that iteratively expands a limited set of the highest-scoring partial candidates.

How 5 Manning books explain it

Natural Language Processing in Action, Second Edition

Beam search generates sequences by retaining a limited set of high-scoring partial paths and expanding them over multiple decoding steps.

How it is used
Guides generative language-model decoding toward high-scoring sequences without exploring every possible path.
How deep it goes
Explains retained paths, cumulative probability, breadth, depth, and recursive expansion, but does not provide beam-search implementation code.
Examples
Uses a road-trip analogy and a decision-tree figure showing two possible beams.
What you can do after
Apply beam search to bound generative decoding while retaining multiple candidate token sequences.

Read how Natural Language Processing in Action, Second Edition explains beam search →

Transformers in Action

Beam search is a decoding algorithm that maintains a fixed number of highest-probability partial token sequences and expands each sequence at every step.

How it is used
Guides text generation by retaining several likely token sequences rather than committing to each greedy choice.
How deep it goes
Explains expansion and pruning through breadth-first-search intuition and a generation call, without specifying scoring refinements.
Examples
Illustrates two beams extending “LLMs” and configures five beams to return three sequences.
What you can do after
Apply it via `model.generate` using `num_beams`, `num_return_sequences`, `early_stopping`, and `do_sample=False`.

Read how Transformers in Action explains beam search →

Optimization Algorithms: AI techniques for design, planning, and control problems

An informed search technique that retains only a limited number of the most promising partial solutions at each step.

How it is used
Finds short paths in graphs or trees when limiting memory and search breadth matters.
How deep it goes
Explains state retention, expansion, ranking, complexity, thresholds, and failure modes, stopping short of optimality guarantees.
Examples
Demonstrates S-to-G routing with w = 2 and larger routing experiments using k = 10 and n = 20.
What you can do after
Apply it via Python graph code by tuning beam width, generated children, costs, and route-expansion parameters.

Read how Optimization Algorithms: AI techniques for design, planning, and control problems explains beam search →

Deep Learning with Python, Third Edition

A decoding method that keeps a fixed number of candidate generation paths and expands them step by step.

How it is used
Uses multiple candidate token chains to guide text-generation decoding.
How deep it goes
Defines fixed-width, stepwise exploration but stops short of implementation details or a worked beam-search example.
What you can do after
Evaluate beam search as a decoding alternative to single-path and sampling-based generation.

Read how Deep Learning with Python, Third Edition explains beam search →

Sutskever's List

Beam search is a sequence-decoding algorithm that retains a fixed-size set of high-scoring partial candidates at each expansion step.

How it is used
Turns probabilistic speech-model scores into a transcript while avoiding exhaustive sequence search.
How deep it goes
Explains candidate expansion, acoustic and language-model scoring, and pruning, without giving formal scoring equations.
Examples
Uses Deep Speech 2’s English and Mandarin beam sizes and Mandarin’s shared-sound search challenge.
What you can do after
Understand how retaining and pruning alternatives trades decoding cost against transcript quality.

Read how Sutskever's List explains beam search →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.