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 intocontent.- The tokenizer decodes a newline as the two characters
\andn(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:
-
EscapedNewlineNormalizer–Recover literal escape sequences written by the model as real text.
-
MiniCPMVOutputNormalizer–Apply :class:
EscapedNewlineNormalizerto a whole stream. -
MiniCPMVParser–Parse MiniCPM-V family output in thinking and non-thinking modes.
-
MiniCPMVUnifiedParser–MiniCPM-V serving parser: the adapters plus newline recovery.
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.
Source code in vllm/parser/minicpmv.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
MiniCPMVOutputNormalizer
¶
Apply :class: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.
Source code in vllm/parser/minicpmv.py
MiniCPMVParser
¶
Bases: Qwen3Parser
Parse MiniCPM-V family output in thinking and non-thinking modes.
Source code in vllm/parser/minicpmv.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
MiniCPMVUnifiedParser
¶
Bases: DelegatingParser
MiniCPM-V serving parser: the adapters plus newline recovery.
Recovery cannot live in :class: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.
Source code in vllm/parser/minicpmv.py
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.