[PR #15886] [MERGED] renderers: update gemma4 renderer #77637

Closed
opened 2026-05-05 10:18:39 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15886
Author: @ParthSareen
Created: 4/30/2026
Status: Merged
Merged: 4/30/2026
Merged by: @ParthSareen

Base: mainHead: parth-update-gemma4-renderer


📝 Commits (2)

  • e507626 renderers: match updated gemma4 templates
  • 1ee4070 renderers: add gemma4 parity stress cases

📊 Changes

4 files changed (+86 additions, -23 deletions)

View changed files

📝 model/renderers/gemma4.go (+5 -2)
📝 model/renderers/gemma4_reference_test.go (+47 -1)
📝 model/renderers/testdata/gemma4_31b_chat_template.jinja2 (+17 -10)
📝 model/renderers/testdata/gemma4_e2b_chat_template.jinja2 (+17 -10)

📄 Description

New templates are available at:

The main renderer change was around when we decide an assistant message has content.

Before, we checked messageHasContent before stripping Gemma thinking blocks. So an assistant message like:

<|channel>I should use bash<channel|>

counted as “has content,” even though the template strips it to empty. That made us emit an extra turn boundary after a tool response.

Now we strip thinking first, trim, then decide whether content exists. So tool-response continuation matches upstream:

<|tool_response>...<tool_response|>Here are the files.<turn|>

instead of:

<|tool_response>...<tool_response|><turn|>
Here are the files.<turn|>

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15886 **Author:** [@ParthSareen](https://github.com/ParthSareen) **Created:** 4/30/2026 **Status:** ✅ Merged **Merged:** 4/30/2026 **Merged by:** [@ParthSareen](https://github.com/ParthSareen) **Base:** `main` ← **Head:** `parth-update-gemma4-renderer` --- ### 📝 Commits (2) - [`e507626`](https://github.com/ollama/ollama/commit/e507626006d979993c2d43417aaea815a1f044bb) renderers: match updated gemma4 templates - [`1ee4070`](https://github.com/ollama/ollama/commit/1ee4070f3cb044667b71707247bff2d20a0c5b1b) renderers: add gemma4 parity stress cases ### 📊 Changes **4 files changed** (+86 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `model/renderers/gemma4.go` (+5 -2) 📝 `model/renderers/gemma4_reference_test.go` (+47 -1) 📝 `model/renderers/testdata/gemma4_31b_chat_template.jinja2` (+17 -10) 📝 `model/renderers/testdata/gemma4_e2b_chat_template.jinja2` (+17 -10) </details> ### 📄 Description New templates are available at: - https://huggingface.co/google/gemma-4-E2B-it - https://huggingface.co/google/gemma-4-26B-A4B-it - https://huggingface.co/google/gemma-4-31B-it The main renderer change was around **when we decide an assistant message has content**. Before, we checked `messageHasContent` before stripping Gemma thinking blocks. So an assistant message like: ```text <|channel>I should use bash<channel|> ``` counted as “has content,” even though the template strips it to empty. That made us emit an extra turn boundary after a tool response. Now we strip thinking first, trim, then decide whether content exists. So tool-response continuation matches upstream: ```text <|tool_response>...<tool_response|>Here are the files.<turn|> ``` instead of: ```text <|tool_response>...<tool_response|><turn|> Here are the files.<turn|> ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 10:18:39 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#77637