Skip to content

vllm.parser.minicpmv

MiniCPM-V family parser.

Wraps the Qwen3 grammar (<think> reasoning + XML tool calls) with two MiniCPM-V specifics:

  • <|im_end|> and the reserved marker tokens are passthrough terminals, so they never leak into content.
  • The tokenizer decodes a newline as the two characters \ and n (e.g. token id 1639) instead of \n, so the decoded text is recovered before it reaches the client. Code blocks, inline code and LaTeX are left alone, as are tool call arguments.

Classes:

Functions:

  • minicpmv_config –

    MiniCPM-V grammar: the qwen3 grammar plus MiniCPM-V markers.

EscapedNewlineNormalizer

Recover literal escape sequences written by the model as real text.

Scans character by character so that a backslash inside a code block, inline code, LaTeX span or a doubled escape is left untouched. A trailing half of an escape is held in _pending until the next chunk arrives, which keeps streaming output identical to the non-streaming result.

MiniCPMVOutputNormalizer

Apply EscapedNewlineNormalizer to a whole stream.

Reasoning and content are tracked separately so that a half-written escape at the end of a reasoning chunk does not swallow the first characters of the content that follows.

MiniCPMVParser

Bases: Qwen3Parser

Parse MiniCPM-V family output in thinking and non-thinking modes.

MiniCPMVUnifiedParser

Bases: DelegatingParser

MiniCPM-V serving parser: the adapters plus newline recovery.

Recovery cannot live in MiniCPMVParser: the serving stack drives the reasoning/tool adapters, never ParserEngine.parse / ParserEngine.parse_delta, so a rewrite applied there would only be visible to callers that construct the engine directly.

minicpmv_config(thinking) cached

MiniCPM-V grammar: the qwen3 grammar plus MiniCPM-V markers.

Both modes keep the qwen3 tool call terminals and transitions, so <tool_call> output is parsed whether or not thinking is enabled.