[PR #15490] [MERGED] gemma4: update renderer to match new jinja template #15173

Closed
opened 2026-04-13 01:11:53 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15490
Author: @drifkin
Created: 4/10/2026
Status: Merged
Merged: 4/10/2026
Merged by: @drifkin

Base: mainHead: drifkin/gemma4-updated-template


📝 Commits (5)

  • d3315cf gemma4: update renderer to match new jinja template
  • f334c86 gemma4: special case simple AnyOfs
  • 275a786 fix lint
  • 7e34c8e gemma4: prefer empty instead of None
  • 99bed13 gemma4: be more careful for tool results with missing IDs

📊 Changes

5 files changed (+1448 additions, -302 deletions)

View changed files

📝 model/parsers/gemma4.go (+22 -8)
📝 model/parsers/gemma4_test.go (+71 -0)
📝 model/renderers/gemma4.go (+531 -96)
📝 model/renderers/gemma4_reference_test.go (+700 -158)
📝 model/renderers/testdata/gemma4_chat_template.jinja2 (+124 -40)

📄 Description

Google has updated their jinja template for gemma4, and so this change gives us parity with the new template. The parsing also slightly changed upstream, so we make a small change to our parser as well.

I've also corrected a few probably existing edge cases, especially around type unions. The upstream output format is weird (a stringified array), but in practice the models seem to understand it well.


🔄 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/15490 **Author:** [@drifkin](https://github.com/drifkin) **Created:** 4/10/2026 **Status:** ✅ Merged **Merged:** 4/10/2026 **Merged by:** [@drifkin](https://github.com/drifkin) **Base:** `main` ← **Head:** `drifkin/gemma4-updated-template` --- ### 📝 Commits (5) - [`d3315cf`](https://github.com/ollama/ollama/commit/d3315cffdaede2a3b2234407f819c594c245b85e) gemma4: update renderer to match new jinja template - [`f334c86`](https://github.com/ollama/ollama/commit/f334c863288fad517bd29a2f88a9cf002c9d4806) gemma4: special case simple `AnyOf`s - [`275a786`](https://github.com/ollama/ollama/commit/275a786e556fece61f86bccf3eb4b5091db195e0) fix lint - [`7e34c8e`](https://github.com/ollama/ollama/commit/7e34c8e94646ed7f93c86a70bfd7905a1cc35965) gemma4: prefer empty instead of `None` - [`99bed13`](https://github.com/ollama/ollama/commit/99bed13d2dd84b66be46a047cb00c23abc07834c) gemma4: be more careful for tool results with missing IDs ### 📊 Changes **5 files changed** (+1448 additions, -302 deletions) <details> <summary>View changed files</summary> 📝 `model/parsers/gemma4.go` (+22 -8) 📝 `model/parsers/gemma4_test.go` (+71 -0) 📝 `model/renderers/gemma4.go` (+531 -96) 📝 `model/renderers/gemma4_reference_test.go` (+700 -158) 📝 `model/renderers/testdata/gemma4_chat_template.jinja2` (+124 -40) </details> ### 📄 Description Google has updated their jinja template for gemma4, and so this change gives us parity with the new template. The parsing also slightly changed upstream, so we make a small change to our parser as well. I've also corrected a few probably existing edge cases, especially around type unions. The upstream output format is weird (a stringified array), but in practice the models seem to understand it well. --- <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-04-13 01:11:53 -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#15173