Module think_tags

Module think_tags 

Source
Expand description

Parser for <think>...</think> tags in model output.

Models like DeepSeek R1, QwQ, and SmolLM3 use <think> tags to wrap chain-of-thought reasoning content. This module provides incremental parsing to extract reasoning content separately from final response content.

§Format

<think>This is reasoning content</think>This is final content

§Behavior

  • Content before <think> goes to content
  • Content inside <think>...</think> goes to reasoning_content
  • Content after </think> goes to content
  • Multiple <think> blocks are concatenated
  • At EOS, treat unclosed <think> content as reasoning

Structs§

ThinkTagContext
Context for tracking <think>...</think> tag parsing state within a sequence.

Functions§

is_think_tag_template
Check if a chat template uses <think>...</think> tags.