Skip to content

vllm.renderers.params

Classes:

  • ChatParams –

    Configuration to control how to parse chat messages.

  • TokenizeParams –

    Configuration to control how prompts are tokenized.

Functions:

ChatParams dataclass

Configuration to control how to parse chat messages.

Methods:

Attributes:

chat_template = None class-attribute instance-attribute

The chat template to apply.

chat_template_content_format = 'auto' class-attribute instance-attribute

The format of the chat template.

chat_template_kwargs = field(default_factory=dict) class-attribute instance-attribute

The kwargs to pass to the chat template.

media_io_kwargs = None class-attribute instance-attribute

Per-modality kwargs for media I/O (loading/decoding images, videos, etc.).

mm_processor_kwargs = None class-attribute instance-attribute

The kwargs to pass to the multi-modal processor.

parallel_tool_calls = True class-attribute instance-attribute

Request-level parallel_tool_calls for renderers that need API metadata.

response_format = None class-attribute instance-attribute

Request-level response format for renderers that need API metadata.

tool_choice = None class-attribute instance-attribute

Request-level tool choice for renderers that need API metadata.

get_apply_chat_template_kwargs()

The arguments to pass to tokenizer.apply_chat_template.

TokenizeParams dataclass

Configuration to control how prompts are tokenized.

Methods:

Attributes:

add_special_tokens = True class-attribute instance-attribute

Whether to add special tokens.

do_lower_case = False class-attribute instance-attribute

Whether to normalize text to lower case before tokenization.

max_input_tokens property

Maximum allowed number of input tokens.

max_output_tokens is not subtracted here: the value represents the actual model context length, not a reservation of output space. Downstream clamping of the sampling max_tokens is handled by get_max_tokens() in the entrypoint layer.

max_output_tokens = 0 class-attribute instance-attribute

Maximum requested output tokens; None means no explicit limit.

Zero indicates a request that does not need generated tokens, such as pooling.

max_output_tokens_param = 'max_output_tokens' class-attribute instance-attribute

Override this to edit the message for validation errors.

max_total_tokens instance-attribute

Maximum allowed number of input + output tokens.

Usually, this refers to the model's context length.

max_total_tokens_param = 'max_total_tokens' class-attribute instance-attribute

Override this to edit the message for validation errors.

max_truncation_tokens property

Maximum prompt length that truncation may reduce a prompt to.

For generative requests this is max_input_tokens less one, holding a token of context back for output. Truncating to the full max_total_tokens would leave get_max_tokens() clamping the sampling budget to 0, turning an over-long prompt into a silent zero-token generation.

Pooling requests set max_output_tokens = 0 and emit an embedding rather than generated tokens, so they keep the full input budget.

needs_detokenization = False class-attribute instance-attribute

Whether the tokenized prompt needs to contain the original text.

Not to be confused with SamplingParams.detokenize which deals with the output generated by the model.

pad_prompt_tokens = None class-attribute instance-attribute

Number of tokens to pad to: - None means no padding. - -1 maps to max_input_tokens.

return_token_offsets = False class-attribute instance-attribute

If true, request char-level (start, end) offsets per token. Honored only for Fast (Rust-backed) tokenizers with text input and no multimodal data; otherwise silently ignored.

truncate_prompt_tokens = None class-attribute instance-attribute

Number of tokens to keep: - None means no truncation. - -1 maps to max_input_tokens.

truncate_prompt_tokens_param = 'truncate_prompt_tokens' class-attribute instance-attribute

Override this to edit the message for validation errors.

truncation_side = None class-attribute instance-attribute

Which side to truncate from when truncate_prompt_tokens is active: - "right" keeps the first N tokens (truncate from the end). - "left" keeps the last N tokens (truncate from the start). - None falls back to the tokenizer default.

_get_text_truncation_offset(tokenizer, text)

Return the number of source characters removed from the left.

_text_len_check pre-truncates long text before tokenization when an explicit truncation side is requested. Fast-tokenizer offsets are then relative to that shortened string, so callers need this prefix length to map them back to the original prompt.

_text_len_check(tokenizer, text)

Apply length checks to prompt text if necessary.

_text_lowercase(tokenizer, text)

Apply lowercase to prompt text if necessary.

_token_len_check(tokenizer, tokens)

Apply length checks to prompt tokens if necessary.

_token_padding(tokenizer, tokens)

Apply padding to prompt tokens if necessary.

_token_truncation(tokenizer, tokens)

Apply truncation to prompt tokens if necessary.

_tokenizer_truncation_probe(num_tokens)

Params to re-encode a text prompt with one more token of room.

Without an explicit truncation_side the tokenizer truncates by itself, so a prompt cut to max_length tokens looks like one that fits exactly. None unless num_tokens == max_length.

_truncation_slice(tokenizer, length)

The slice truncation applies to a sequence of length tokens.

None means no truncation. Anything parallel to the prompt tokens must be reduced with this same slice to stay aligned with them; list such keys in _PARALLEL_TO_PROMPT_TOKENS.

_validate_text(tokenizer, text)

Apply all validators to prompt text.

_validate_tokens(tokenizer, tokens)

Apply all validators to a token sequence.

apply_post_tokenization(tokenizer, prompt)

apply_post_tokenization(
    tokenizer: TokenizerLike | None, prompt: TokensPrompt
) -> TokensPrompt
apply_post_tokenization(
    tokenizer: TokenizerLike | None, prompt: EmbedsPrompt
) -> EmbedsPrompt

Ensure that the prompt meets the requirements set out by this config. If that is not possible, raise a VLLMValidationError.

This method is run after tokenization occurs.

apply_pre_tokenization(tokenizer, prompt)

Ensure that the prompt meets the requirements set out by this config. If that is not possible, raise a VLLMValidationError.

This method is run before tokenization occurs.

get_encode_kwargs()

The arguments to pass to tokenizer.encode.

apply_max_tokenize_tokens(tok_params, max_tokenize_tokens)

Validate and apply the server's max_tokenize_tokens limit to TokenizeParams.

map_reasoning_effort(effort, effort_map)

Rewrite a requested effort to the one the chat template supports.