vllm.reasoning.basic_parsers
¶
Classes:
-
BaseThinkingReasoningParser–Base class for reasoning parsers that use thinking tokens.
BaseThinkingReasoningParser
¶
Bases: ReasoningParser
Base class for reasoning parsers that use thinking tokens.
This class provides common functionality for parsers that use start and end
tokens to delimit reasoning content (
e.g.,
Subclasses must implement the start and end tokens via abstract properties.
Methods:
-
count_reasoning_tokens–Count tokens that fall within start/end thinking markers.
-
extract_content_ids–Extract the content after the end tokens.
-
extract_reasoning–Extract reasoning content from the model output.
-
extract_reasoning_streaming–Extract reasoning content from a delta message.
Attributes:
-
end_token(str) –The token that ends reasoning content.
-
start_token(str) –The token that starts reasoning content.
end_token
abstractmethod
property
¶
The token that ends reasoning content.
start_token
abstractmethod
property
¶
The token that starts reasoning content.
count_reasoning_tokens(token_ids)
¶
Count tokens that fall within start/end thinking markers.
Uses a depth counter so nested spans are handled safely and stray end tokens do not drive the counter negative.
extract_content_ids(input_ids)
¶
Extract the content after the end tokens.
extract_reasoning(model_output, request)
¶
Extract reasoning content from the model output.
This is the base implementation that works for most models. Subclasses can override this method for specific behavior.
extract_reasoning_streaming(previous_text, current_text, delta_text, previous_token_ids, current_token_ids, delta_token_ids)
¶
Extract reasoning content from a delta message. Handles streaming output where previous + delta = current. Uses token IDs for faster processing.