vllm.reasoning.muse_glimmer_reasoning_parser ¶
Reasoning-content parser for MuseGlimmer. Port of the reasoning_content rule from the HuggingFace MuseGlimmer MUSE_GLIMMER_RESPONSE_SCHEMA (synced with internal master). MuseGlimmer emits chain-of-thought in to=self channels delimited by <|message|> ... <|eom|>: to=self<|message|>...reasoning...<|eom|> A turn may contain several to=self blocks interleaved with tool calls, and a tool call or final answer follows in its own channel. Because MuseGlimmer's framing markers (<|message|>, <|eom|>) are not guaranteed to be single vocab tokens across every checkpoint's tokenizer, this parser works on the decoded text with regexes rather than the single start/end-token base class. Usage: --reasoning-parser muse_glimmer
Classes:
MuseGlimmerReasoningParser ¶
Bases: ReasoningParser
Methods:
-
adjust_request–Preserve MuseGlimmer's ATEM framing tokens in the decoded output.
-
extract_reasoning_streaming–Channel-aware streaming split of reasoning vs content.
-
get_streaming_fallback_content–Promote un-surfaced content when the stream ends mid-reasoning.
-
is_reasoning_end–Whether the model has left reasoning and opened a TOOL channel.
Source code in vllm/reasoning/muse_glimmer_reasoning_parser.py
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 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 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 | |
_classify_bodies(text) staticmethod ¶
Split text into (reasoning_body, content_body), channel-aware. Framing markers and tool channels contribute nothing -- the tool parser owns those. A body ends at <|eom|> / <|eot|>, at the next channel header, or at end-of-text (an OPEN body, which is held back).
Source code in vllm/reasoning/muse_glimmer_reasoning_parser.py
_scoped_turn(text) classmethod ¶
Current assistant turn with reasoning spans removed.
Source code in vllm/reasoning/muse_glimmer_reasoning_parser.py
_tool_channel_remainder(text) classmethod ¶
Text from the first tool-channel header onward, framing INCLUDED. DelegatingParser.parse_delta rebuilds current_text from whatever this parser returns as .content on the transition delta and commits it; anything not returned is destroyed. It must start AT the to=<name><|message|> header -- handing over the text after the header loses the recipient, and the tool parser then sees a bare <|message|>, classifies it as the content channel, and leaks the ATEM markup.
Source code in vllm/reasoning/muse_glimmer_reasoning_parser.py
adjust_request(request) ¶
Preserve MuseGlimmer's ATEM framing tokens in the decoded output. vLLM's serving default is skip_special_tokens=True, which strips <|start|> / <|message|> / <|eom|> / <|eot|> before the parsers run, collapsing reasoning into content and breaking channel scoping. Unlike the base tool-parser hook we do NOT touch structured_outputs -- MuseGlimmer emits native ATEM, not JSON.
Source code in vllm/reasoning/muse_glimmer_reasoning_parser.py
extract_reasoning_streaming(previous_text, current_text, delta_text, previous_token_ids, current_token_ids, delta_token_ids) ¶
Channel-aware streaming split of reasoning vs content. Classifies the full current_text and emits only what has not been emitted yet, so no framing token is ever surfaced and a delta straddling a channel boundary only contributes the portion inside a real body.
Source code in vllm/reasoning/muse_glimmer_reasoning_parser.py
get_streaming_fallback_content(previous_text, request) ¶
Promote un-surfaced content when the stream ends mid-reasoning. DelegatingParser.finalize_generation calls this when reasoning_ended is still False. Returns only the channel-classified to=user body, and only the portion not already streamed.
Source code in vllm/reasoning/muse_glimmer_reasoning_parser.py
is_reasoning_end(input_ids) ¶
Whether the model has left reasoning and opened a TOOL channel. A to=user answer is NOT a reason to leave the reasoning phase -- this parser surfaces that content itself. Only a real tool channel switches the DelegatingParser phase machine over to the tool parser. Both closed and unterminated reasoning spans are stripped before the check, so an <atem:invoke> the model merely echoes inside its CoT never flips the phase.
Source code in vllm/reasoning/muse_glimmer_reasoning_parser.py
_current_assistant_turn(text) ¶
Return only the text generated in the current assistant turn. is_reasoning_end is evaluated on the PROMPT token-ids at stream start, and an MuseGlimmer prompt legitimately contains ATEM markers (render_tool_defs writes a literal <atem:function_calls> example into the system message, and prior assistant turns may carry real tool calls). Anchoring on the last channel-open keeps prompt text from deciding the phase.
Source code in vllm/reasoning/muse_glimmer_reasoning_parser.py
_trim_open_body(body) ¶
Hold back any tail of a still-growing body that could still be framing. Iterated to a fixpoint because the two cases compose: " to=skill<" needs the partial-marker trim (<) before the partial-header trim can see " to=skill". Trimming only once leaks the recipient name as reasoning.