Skip to content

vllm.parser.minimax_m2_parser

MiniMax M2 Parser - A unified parser for MiniMax M2 models.

This parser combines the existing MiniMaxM2ReasoningParser and MinimaxM2ToolParser into a single unified interface by delegating to those implementations.

logger module-attribute

logger = init_logger(__name__)

MiniMaxM2Parser

Bases: DelegatingParser

Unified parser for MiniMax M2 models that handles both reasoning extraction and tool call parsing.

This parser delegates to the existing implementations: - MiniMaxM2ReasoningParser for reasoning extraction - MinimaxM2ToolParser for tool call parsing

MiniMax M2 models have two special behaviors: 1. Reasoning: They don't generate start token, only end token. All content before is reasoning, content after is the actual response. 2. Tool Calls: They use ... tags with ... and ... syntax.

Source code in vllm/parser/minimax_m2_parser.py
class MiniMaxM2Parser(DelegatingParser):
    """
    Unified parser for MiniMax M2 models that handles both reasoning
    extraction and tool call parsing.

    This parser delegates to the existing implementations:
    - MiniMaxM2ReasoningParser for reasoning extraction
    - MinimaxM2ToolParser for tool call parsing

    MiniMax M2 models have two special behaviors:
    1. Reasoning: They don't generate <think> start token, only </think> end
       token. All content before </think> is reasoning, content after is the
       actual response.
    2. Tool Calls: They use <minimax:tool_call>...</minimax:tool_call> tags
       with <invoke name="...">...</invoke> and <parameter name="...">...</parameter>
       syntax.
    """

    # Class-level parser classes for compatibility
    reasoning_parser_cls = MiniMaxM2ReasoningParser
    tool_parser_cls = MinimaxM2ToolParser

    def __init__(self, tokenizer: TokenizerLike):
        super().__init__(tokenizer)

        # Initialize the underlying parsers
        self._reasoning_parser = MiniMaxM2ReasoningParser(tokenizer)
        self._tool_parser = MinimaxM2ToolParser(tokenizer)

        logger.debug(
            "vLLM Successfully initialized parser %s!", self.__class__.__name__
        )

_reasoning_parser instance-attribute

_reasoning_parser = MiniMaxM2ReasoningParser(tokenizer)

_tool_parser instance-attribute

_tool_parser = MinimaxM2ToolParser(tokenizer)

reasoning_parser_cls class-attribute instance-attribute

reasoning_parser_cls = MiniMaxM2ReasoningParser

tool_parser_cls class-attribute instance-attribute

tool_parser_cls = MinimaxM2ToolParser

__init__

__init__(tokenizer: TokenizerLike)
Source code in vllm/parser/minimax_m2_parser.py
def __init__(self, tokenizer: TokenizerLike):
    super().__init__(tokenizer)

    # Initialize the underlying parsers
    self._reasoning_parser = MiniMaxM2ReasoningParser(tokenizer)
    self._tool_parser = MinimaxM2ToolParser(tokenizer)

    logger.debug(
        "vLLM Successfully initialized parser %s!", self.__class__.__name__
    )