Skip to content

vllm.reasoning.minimax_m2_reasoning_parser

Classes:

MiniMaxM2AppendThinkReasoningParser

Bases: ReasoningParser

Reasoning parser for MiniMax M2 model.

Source code in vllm/reasoning/minimax_m2_reasoning_parser.py
class MiniMaxM2AppendThinkReasoningParser(ReasoningParser):
    """Reasoning parser for MiniMax M2 model."""

    def __init__(self, tokenizer: TokenizerLike, *args, **kwargs):
        super().__init__(tokenizer, *args, **kwargs)
        self.end_token_id = self.vocab.get("</think>")
        self.start_token_id = self.vocab.get("<think>")

    def is_reasoning_end(self, input_ids: Sequence[int]) -> bool:
        i = rfind_tokens(input_ids, (self.end_token_id, self.start_token_id))
        return i >= 0 and input_ids[i] == self.end_token_id

    def extract_content_ids(self, input_ids: list[int]) -> list[int]:
        return input_ids

    def extract_reasoning_streaming(
        self,
        previous_text: str,
        current_text: str,
        delta_text: str,
        previous_token_ids: Sequence[int],
        current_token_ids: Sequence[int],
        delta_token_ids: Sequence[int],
    ) -> DeltaMessage | None:
        if len(previous_token_ids) == 0:
            delta_text = "<think>" + delta_text
        return DeltaMessage(content=delta_text)

    def extract_reasoning(
        self, model_output: str, request: "ChatCompletionRequest | ResponsesRequest"
    ) -> tuple[str | None, str | None]:
        return None, "<think>" + model_output

MiniMaxM2ReasoningParser

Bases: MinimaxM2ParserReasoningAdapter

Reasoning parser for MiniMax M2 model.

MiniMax M2 models don't generate start token, only end token. All content before is reasoning, content after is the actual response.

Source code in vllm/reasoning/minimax_m2_reasoning_parser.py
class MiniMaxM2ReasoningParser(MinimaxM2ParserReasoningAdapter):  # type: ignore[valid-type, misc]
    """Reasoning parser for MiniMax M2 model.

    MiniMax M2 models don't generate <think> start token, only </think> end
    token. All content before </think> is reasoning, content after is the
    actual response.
    """