Skip to content

vllm.reasoning.olmo3_reasoning_parser

Classes:

Functions:

  • string_overlap –

    Find the longest overlap where the end of string a matches the start

Olmo3ReasoningParser

Bases: ReasoningParser

Reasoning parser for Olmo 3 model.

Olmo3ReasoningParser

This class implements a reasoning parser specifically designed for the Olmo 3 family of models. Olmo 3 models do not use special tokens to indicate reasoning; rather, reasoning trace is wrapped in <think> and </think>, which are tokenized using standard vocabulary entries. Because of this, the parser operates in string space, accumulating the characters in a buffer until it sees <think> or </think>. tokens to switch modes.

Key Features
  • For non-stream output, Recognizes and extracts reasoning (text bracketed by <think> and </think>) and content (everything after the first </think>).
  • For stream process, it uses a buffer to accumulate delta text, and output progressive delta messages as soon as thinking starts or ends.
  • For reliability, some Olmo 3 models may hardcode the first <think> token is the input text (similar to Deepseek R1, or reasoning-only Qwen models). To support such variants, the parser can optionally work in cases where the first <think> token is missing from generation.

Methods:

extract_reasoning(model_output, request)

Extract the reasoning content & content sections, respectively. If the sequence doesn't match what we expect, i.e., the model generates something else, all content is considered non-reasoning content.

Parameters:

Returns:

  • str | None –

    tuple[Optional[str], Optional[str]]: Tuple pair containing the

  • str | None –

    reasoning content and non-reasoning content.

extract_reasoning_streaming(previous_text, current_text, delta_text, previous_token_ids, current_token_ids, delta_token_ids)

Extract content using token ID sequence state machine.

string_overlap(a, b)

Find the longest overlap where the end of string a matches the start of string b.

Parameters:

  • a

    (str) –

    First string

  • b

    (str) –

    Second string

Returns:

  • Indices | None –

    Tuple of IndicesTuples representing the overlapping portions in each

  • Indices | None –

    string, or a tuple of None if no overlap exists