Python class
ReasoningParser
ReasoningParser
class max.interfaces.ReasoningParser
Bases: ABC
Parser for identifying reasoning spans in model output.
from_tokenizer()
abstract async classmethod from_tokenizer(tokenizer)
Constructs a reasoning parser from a tokenizer.
-
Parameters:
-
tokenizer (PipelineTokenizer[Any, Any, Any]) – The
PipelineTokenizerto use for resolving reasoning delimiter token IDs. -
Returns:
-
A new
ReasoningParserinstance. -
Return type:
stream()
abstract stream(delta_token_ids)
Identifies a reasoning span within a streaming delta chunk.
-
Parameters:
-
delta_token_ids (Sequence[int]) – The token IDs of the incremental streaming chunk.
-
Returns:
-
A tuple of
(ReasoningSpan, is_still_reasoning)whereis_still_reasoningindicates whether the reasoning section has ended. TheReasoningSpanidentifies the reasoning portion of the chunk. If there is no reasoning in the chunk, the span is zero-width so thatReasoningSpan.extract_content()behaves as identity andReasoningSpan.extract_reasoning()returns an empty list. -
Return type:
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!