# Beam Search

- **Canonical URL:** https://getaimath.com/dictionary/beam-search/
- **Topics:** [LLM Inference: Prefill & Decode](https://getaimath.com/dictionary/category/llm-inference-prefill-and-decode/)
- **Last updated:** 2026-11-25

## What is Beam Search?

**In one sentence:** Beam search keeps several possible sentences going at once and picks the one with the best overall score at the end.

Instead of choosing one word at a time like greedy decoding, it keeps the top few "beams," or partial answers, and extends each. This finds better overall sequences for tasks like translation.

![How an AI Replies: 1. Read Your Question → 2. Type the Answer — Simple two-step cartoon: Step 1 (Prefill) shows the AI scanning your entire question in one flash (causing the brief pause before it starts talking); Step 2 (Decode) shows it typing out the reply one word at a time.](https://getaimath.com/diagrams/llm-inference-prefill-and-decode.png)
*Napkin Diagram (LLM Inference: Prefill & Decode): Every AI reply has two halves: gulping down your whole prompt at once, then speaking the answer one word at a time.*

## What is an example of Beam Search?

With a beam width of 3, the model tracks the 3 most promising translations at each step.

## Why does Beam Search matter?

It is common in translation and speech recognition, though chatbots usually use sampling.

## Related Concepts

- [Greedy Decoding](https://getaimath.com/dictionary/greedy-decoding/): Greedy decoding always picks the single most likely next token at every step.
- [Sampling](https://getaimath.com/dictionary/sampling/): Sampling is how a model picks the next token from its list of possible options, using their probabilities.
- [Target Model](https://getaimath.com/dictionary/target-model/): The target model is the large, high-quality model that checks and accepts the draft model's guesses in speculative decoding.
- [Throughput](https://getaimath.com/dictionary/throughput/): Throughput is the total amount of work a system completes over time, like the number of tokens or requests per second across all users.
- [Draft Model](https://getaimath.com/dictionary/draft-model/): A draft model is the small, fast model that proposes tokens in speculative decoding.
- [Latency](https://getaimath.com/dictionary/latency/): Latency is the delay between asking for something and getting a response.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/beam-search/)
