Skip to content

vllm.entrypoints.generate.beam_search.offline

Classes:

BeamSearchOfflineMixin

Bases: OfflineInferenceMixin

Offline inference for beam search.

Methods:

  • beam_search –

    Generate sequences using beam search.

_beam_search_step(instances_batch, base_sampling_params, eos_token_ids, ignore_eos, beam_width, sort_beams_key, structured_output_backend, structured_output_key, structured_output_bitmask)

Run one token step of beam search across a batch of instances.

Returns True if all beams are exhausted and search should stop.

_build_beam_sampling_params(beams, base_params, backend, structured_output_key, bitmask)

Build per-beam SamplingParams and allowed token IDs from grammar.

Returns None for beams where the grammar has terminated.

_init_beam_search_structured_output(structured_outputs, tokenizer)

Initialize the structured output backend for beam search.

Generate sequences using beam search.

Parameters:

  • prompts

    (list[TokensPrompt | TextPrompt]) –

    A list of prompts. Each prompt can be a string or a list of token IDs.

  • params

    (BeamSearchParams) –

    The beam search parameters.

  • lora_request

    (list[LoRARequest] | LoRARequest | None, default: None ) –

    LoRA request to use for generation, if any.

  • use_tqdm

    (bool, default: False ) –

    Whether to use tqdm to display the progress bar.

  • concurrency_limit

    (int | None, default: None ) –

    The maximum number of concurrent requests. If None, the number of concurrent requests is unlimited.

  • priority

    (int | Sequence[int] | None, default: None ) –

    Scheduling priority, either shared or one per prompt. Lower values have higher priority. Defaults to 0.

_bitmask_to_token_ids(bitmask_row, vocab_size)

Convert a packed int32 bitmask row to a list of allowed token IDs.