core.tokenizers.text.parsers.deepseek_r1_reasoning_parser#

Module Contents#

Classes#

DeepSeekR1ReasoningParser

Parser for DeepSeek R1 style reasoning output.

API#

class core.tokenizers.text.parsers.deepseek_r1_reasoning_parser.DeepSeekR1ReasoningParser#

Bases: megatron.core.tokenizers.text.parsers.base_parser.BaseParser

Parser for DeepSeek R1 style reasoning output.

static parse(text: str, **kwargs) tuple[str, dict[str, str]]#

Extracts the reasoning content from the text using tags. Only extracts the first set of think tags. If an initial tag is not present but a tag is, it will infer a tag at the beginning of the text.

Parameters:

text (str) – The text to parse.

Returns:

A tuple containing the unprocessed text and a dictionary with the extracted reasoning content.

Return type:

tuple[str, dict[str, str]]