Skip to main content

Python class

ReasoningParser

ReasoningParser

class max.interfaces.ReasoningParser

source

Bases: ABC

Parser for identifying reasoning spans in model output.

from_tokenizer()

abstract async classmethod from_tokenizer(tokenizer)

source

Constructs a reasoning parser from a tokenizer.

Parameters:

tokenizer (PipelineTokenizer[Any, Any, Any]) – The PipelineTokenizer to use for resolving reasoning delimiter token IDs.

Returns:

A new ReasoningParser instance.

Return type:

ReasoningParser

stream()

abstract stream(delta_token_ids)

source

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) where is_still_reasoning indicates whether the reasoning section has ended. The ReasoningSpan identifies the reasoning portion of the chunk. If there is no reasoning in the chunk, the span is zero-width so that ReasoningSpan.extract_content() behaves as identity and ReasoningSpan.extract_reasoning() returns an empty list.

Return type:

tuple[ReasoningSpan, bool]