Beam search is a decoding algorithm in which a language model keeps a fixed number of high-probability candidate token sequences (the beam width) at each generation step and finally selects the sequence with the highest overall probability. Compared with greedy decoding, which picks only the single most likely token at each step, it can find outputs whose probability as a whole is higher, but tracking multiple candidate states costs more time and memory.
It has long been used in tasks such as machine translation and speech recognition, where there is a relatively well-defined correct output. In conversational LLM services, sampling-based decoding with temperature, top-k, and top-p is more common because of cost and the need for diversity.