Skip to content
Query Feedz
  • News
  • Business
    • Digital Marketing
      • Marketing & Sales
      • SEO
      • Content Marketing
      • AEO and GEO
    • Startups
      • Founder Stories
      • Funding & VC
      • Product & Growth
    • Money
      • Investing
      • Markets & Economy
      • Saving & Budgeting
  • AI & Technology
    • Technology
      • Consumer Tech
      • CRM
      • Cyber Security
      • Software Engineering
      • WordPress
      • Hardware
    • Artificial IntelligenceAI Glossary
      • LLMs
      • Machine Learning
      • AI Fundamentals
      • Generative AI
      • Deep Learning
    • AI Use Cases
      • Automation
      • Content
      • Customer Support
      • Finance
      • Marketing
      • View All
  • Tools & Software
  • Account
    • Submit Guest Post
    • Submit a tool
    • My listing
  • Contact
QueryFeedz
  • News
  • Business
    • Digital Marketing
      • Marketing & Sales
      • SEO
      • Content Marketing
      • AEO and GEO
    • Startups
      • Founder Stories
      • Funding & VC
      • Product & Growth
    • Money
      • Investing
      • Markets & Economy
      • Saving & Budgeting
  • AI & Technology
    • Technology
      • Consumer Tech
      • CRM
      • Cyber Security
      • Software Engineering
      • WordPress
      • Hardware
    • Artificial IntelligenceAI Glossary
      • LLMs
      • Machine Learning
      • AI Fundamentals
      • Generative AI
      • Deep Learning
    • AI Use Cases
      • Automation
      • Content
      • Customer Support
      • Finance
      • Marketing
      • View All
  • Tools & Software
  • Account
    • Submit Guest Post
    • Submit a tool
    • My listing
  • Contact
QueryFeedz
  1. Home /
  2. AI Glossaries /
  3. LLMs /
  4. What is Beam Search?
LLMs

What is Beam Search?

Updated September 26, 2026 Read 2 min

Beam search is a decoding method that keeps several candidate sequences alive at once and expands them step by step, choosing the sequence with the best overall probability rather than the best next token.

Contents 11
  1. 01Key takeaways
  2. 02Beam search explained in simple terms
  3. 03How it works
  4. 04A worked example with beam width 2
  5. 05Why a length penalty is needed
  6. 06Where beam search works well
  7. 07The beam search curse
  8. 08Limitations
  9. 09Common Use Cases
  10. 10Frequently Asked Questions
  11. 11Related Terms

Beam search is a decoding method that keeps several candidate sequences, called beams, alive at once and expands them step by step, finally selecting the sequence with the best overall score. Unlike greedy decoding, which commits to the best token at each step, beam search explores a few promising paths before deciding. It is a strong choice for translation and summarisation, and a weak one for open-ended writing.

Key takeaways

  • Beam width (k) controls how many candidate sequences are kept.
  • It approximates finding the highest-probability full sequence.
  • A length penalty is needed, or short outputs win unfairly.
  • It produces fluent but often bland, repetitive text in open-ended tasks.
  • Cost and memory scale roughly with beam width.

Beam search explained in simple terms

Planning a route, greedy decoding takes the best-looking turn at each junction. Beam search keeps the three most promising routes on the map, extends each one at every junction, discards the worst and continues. At the end, it compares the surviving routes and chooses the best complete journey.

How it works

  1. Start with the prompt and generate the top k tokens as k beams.
  2. For each beam, compute probabilities for the next token.
  3. Score every beam-and-token combination by cumulative log probability.
  4. Keep the best k overall; discard the rest.
  5. Repeat until beams finish or reach the length limit.
  6. Apply a length penalty and return the highest-scoring sequence.

A worked example with beam width 2

Prompt: “The meeting was”.

StepBeams keptCumulative score
1“postponed” (0.40), “cancelled” (0.35)log 0.40, log 0.35
2“postponed to” (0.40 × 0.60), “cancelled due” (0.35 × 0.70)0.24, 0.245

Notice that “cancelled due” overtakes “postponed to” at step 2, even though “postponed” was more likely at step 1. Greedy decoding could never recover this, because it discarded “cancelled” immediately.

Why a length penalty is needed

Each extra token multiplies in another probability below 1, so longer sequences always score lower. Without correction, beam search favours very short outputs. Implementations divide the score by the length raised to a tunable power, often around 0.6 to 1.0.

Where beam search works well

TaskSuitabilityReason
Machine translationStrongOne correct meaning, measurable quality
SummarisationGoodFaithfulness matters more than variety
Speech recognitionStrongA single correct transcript exists
Code completionSometimesPrecision matters
Chat and creative writingPoorProduces generic, repetitive text

The beam search curse

Research on open-ended generation found that increasing beam width can make text worse, not better: it converges on high-probability but dull, repetitive phrasing, because real human text is not the most probable text. This finding helped motivate sampling methods such as top-p for creative tasks.

Limitations

  • Slower and more memory-hungry than greedy decoding.
  • Needs tuning of beam width and length penalty.
  • Produces low-diversity output.
  • Rarely used in modern chat APIs, which favour sampling.

Common Use Cases

01

Machine translation

Find the best overall translation rather than best next word.

02

Summarisation

Generate faithful summaries with a strong overall score.

03

Speech recognition

Select the most likely complete transcript.

04

Grammar correction

Choose the best full corrected sentence.

05

Constrained generation

Explore multiple candidates that satisfy constraints.

06

Candidate generation

Return several high-scoring alternatives for reranking.

Frequently Asked Questions

A decoding method that keeps several candidate sequences and selects the one with the best overall score.

The number of candidate sequences kept at each step, often 3 to 10.

Longer sequences accumulate lower probability, so without a penalty the method favours very short outputs.

Usually for translation and summarisation. For open-ended chat, sampling methods are generally better.

It converges on high-probability, generic phrasing, which reads as bland and repetitive.

Related Terms

  • Greedy Decoding
  • Top-p Sampling
  • Top-k Sampling
  • Autoregressive Generation
  • Encoder-Decoder Model
  • LLM Inference

Related AI Terms

What is Multi-Head Attention?Multi-head attention runs several attention operations in parallel, each with its own learned projections, so a model can…What is Prefix Tuning?Prefix tuning is a parameter-efficient fine-tuning method that learns trainable vectors inserted into the attention keys and values…What is an Encoder-Decoder Model?An encoder-decoder model, also called a sequence-to-sequence model, uses one component to read and understand the input and…What is an Attention Mechanism?An attention mechanism is a technique that lets a neural network focus on the most relevant parts of…What is Self-Attention?Self-attention is a mechanism where each position in a sequence attends to every other position in the same…What is Positional Encoding?Positional encoding is the method transformers use to represent the order of tokens in a sequence, because the…

Contents

  1. 01Key takeaways
  2. 02Beam search explained in simple terms
  3. 03How it works
  4. 04A worked example with beam width 2
  5. 05Why a length penalty is needed
  6. 06Where beam search works well
  7. 07The beam search curse
  8. 08Limitations
  9. 09Common Use Cases
  10. 10Frequently Asked Questions
  11. 11Related Terms

AI Topic

  • LLMs

Related Terms

  • What is Multi-Head Attention?
  • What is Prefix Tuning?
  • What is an Encoder-Decoder Model?
  • What is an Attention Mechanism?
  • What is Self-Attention?
  • What is Positional Encoding?

Quick Navigation

  • Common Use Cases
  • Frequently Asked Questions
  • Related Terms
  • Back to top

Details

Updated
September 26, 2026
Read
2 min
  • Forum
  • Submit a tool
  • Submit Guest Post
  • List Your Startup
  • Privacy Policy
  • Editorial Policy
  • Account
  • Contact
  • AI Productivity
  • AI Video
  • AI Coding
  • AI Chatbots
  • Sales
  • AI Business
  • View All Tools

Subscribe our Newsletter

Get weekly exclusive content - No spam.

Copyright © 2026 -  Query Feedz

Manage Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
View preferences
  • {title}
  • {title}
  • {title}