Beam Search is a heuristic search algorithm used in artificial intelligence and machine learning to explore large decision spaces efficiently. Instead of evaluating every possible solution, beam search maintains a fixed number of the most promising partial solutions — known as the beam width — at each step, expanding them iteratively until an optimal or near-optimal result is found.
This approach balances the thoroughness of exhaustive search with the speed of greedy methods, making it suitable for tasks where exploring every possible path is computationally infeasible.
Beam Width:
Determines how many partial solutions are kept active at each step. A wider beam allows more exploration but requires more computation.
Scoring Function:
Evaluates candidates based on probability, likelihood, or another objective metric, ranking them to retain the best ones.
Pruning Strategy:
Removes less promising candidates from consideration, ensuring that only top-scoring solutions remain in the active set.
Expansion Rules:
Define how new candidates are generated from the current set of solutions. This process continues until a stopping condition is reached (e.g., maximum depth, completed output sequence).
By combining these elements, beam search avoids local optima that may trap a purely greedy search while remaining computationally efficient compared to exhaustive enumeration.
The effectiveness of beam search depends on selecting an appropriate beam width:
Choosing the right width is crucial: too narrow may discard good solutions too early, while too wide can waste resources without significant quality gains.
Beam search is widely used in domains where sequential decision-making is required:
Advantages:
Challenges:
Beam Search is a powerful heuristic method for structured prediction tasks. By maintaining a fixed set of the most promising candidates, it navigates large decision spaces efficiently, producing high-quality solutions without the prohibitive cost of exhaustive search. Its success depends on carefully tuning the beam width, scoring functions, and pruning strategies to balance performance, accuracy, and computational efficiency.