liveBook · Manning

Beam search

As explained in Deep Learning with Python, Third Edition

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

Beam search is a decoding method for text generation that heuristically explores several chains of predicted tokens instead of following only one. At each timestep, it keeps a fixed number of beams and expands those candidate paths. section 16.2.4

Use beam search when generation quality depends on exploring multiple likely continuations.

  • Keep a fixed number of candidate token chains active at every timestep. section 16.2.4
  • Treat it as an alternative decoding strategy alongside greedy search, random sampling, and top-K sampling. section 16.2.4

How Deep Learning with Python, Third Edition covers it

How deep it goes
Defines fixed-width, stepwise exploration but stops short of implementation details or a worked beam-search example.
What it assumes
Assumes familiarity with predicted tokens and text-generation decoding; does not develop beam search from code.
What you can do after
Evaluate beam search as a decoding alternative to single-path and sampling-based generation.
How it connects
Connects beam search with greedy search, top-K sampling, temperature sampling, random sampling, and text generation.

Also explained in

Compare how 5 books explain beam search →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.