Skip to content

[WIP] Gemma4 reasoning parser#4191

Open
dkalinowski wants to merge 1 commit intomainfrom
gemma-thinking
Open

[WIP] Gemma4 reasoning parser#4191
dkalinowski wants to merge 1 commit intomainfrom
gemma-thinking

Conversation

@dkalinowski
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings May 7, 2026 14:42
@dkalinowski dkalinowski added the WIP Do not merge until resolved label May 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends OVMS LLM output parsing to support extracting “reasoning” segments from Gemma4 model outputs by reusing and parameterizing the existing Qwen3 reasoning parser.

Changes:

  • Refactors Qwen3ReasoningParser to allow configurable start/end tags and to expose whether streaming requires special tokens.
  • Adds Gemma4ReasoningParser and wires it into OutputParser selection via --reasoning_parser=gemma4.
  • Updates Bazel build and user documentation to include the new parser option.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/llm/io_processing/qwen3/reasoning_parser.hpp Makes Qwen3 reasoning tag handling configurable and adds a special-tokens requirement flag for streaming.
src/llm/io_processing/output_parser.cpp Registers gemma4 as a supported reasoning parser option.
src/llm/io_processing/gemma4/reasoning_parser.hpp Introduces Gemma4 reasoning parser as a thin specialization of Qwen3 reasoning parser.
src/llm/BUILD Adds the Gemma4 reasoning parser header to the output_parsers library.
docs/parameters.md Documents gemma4 as a supported --reasoning_parser value.

Comment thread docs/parameters.md
Comment on lines +141 to 142
| `--reasoning_parser` | `string` | Type of parser to use for reasoning content extraction from model output. Currently supported: [qwen3, gemma4] |
| `--tool_parser` | `string` | Type of parser to use for tool calls extraction from model output. Currently supported: [llama3, hermes3, phi4] |
Comment on lines 179 to 183
if (reasoningParserName == "qwen3") {
reasoningParser = std::make_unique<Qwen3ReasoningParser>(tokenizer);
} else if (reasoningParserName == "gemma4") {
reasoningParser = std::make_unique<Gemma4ReasoningParser>(tokenizer);
} else if (reasoningParserName == "gptoss") {
@dtrawins dtrawins requested a review from przepeck May 7, 2026 14:59
@dkalinowski
Copy link
Copy Markdown
Collaborator Author

To be done: add mapping document which tool parsers are for which models

@dtrawins dtrawins added this to the 2026.2_rc milestone May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WIP Do not merge until resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants