Skip to content

Commit 53db0d4

Browse files
Fix stale Gemma-3 references and wrong chat_template in Gemma4 notebooks (#228)
* Fix stale Gemma-3 references and wrong chat_template in Gemma4 notebooks Several Gemma4 notebooks still contained leftover Gemma-3 wording that was never updated when the notebooks were forked from their Gemma-3 predecessors: - "According to the \`Gemma-3\` team, the recommended settings..." - "# Recommended Gemma-3 settings!" - "apply the chat template for \`Gemma-3\` onto the conversations" Fix all of these to reference Gemma-4. The list of supported chat template names (\`..., gemma3, gemma-4\`) is intentionally left alone since \`gemma3\` is a separate, still-supported template distinct from \`gemma-4\`. Also fix Gemma4_(26B_A4B)-Text which was using \`chat_template = "gemma-4-thinking"\`. Only the 31B notebooks should use the thinking template; the rest should use \`gemma-4\`. Total: 14 Gemma-3 -> Gemma-4 string fixes across 4 notebooks, plus 2 chat_template fixes in the 26B_A4B Text notebook. * Revert 26B_A4B-Text chat_template change; keep gemma-4-thinking The 26B_A4B model should also use the gemma-4-thinking chat template, not gemma-4. Only the E2B / E4B notebooks should use plain gemma-4.
1 parent 5e5b93f commit 53db0d4

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

nb/Gemma4_(26B_A4B)-Text.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@
376376
"id": "8Xs0LXio7rfd"
377377
},
378378
"source": [
379-
"We now have to apply the chat template for `Gemma-3` onto the conversations, and save it to `text`. We remove the `<bos>` token using removeprefix(`'<bos>'`) since we're finetuning. The Processor will add this token before training and the model expects only one."
379+
"We now have to apply the chat template for `Gemma-4` onto the conversations, and save it to `text`. We remove the `<bos>` token using removeprefix(`'<bos>'`) since we're finetuning. The Processor will add this token before training and the model expects only one."
380380
]
381381
},
382382
{
@@ -594,7 +594,7 @@
594594
"source": [
595595
"<a name=\"Inference\"></a>\n",
596596
"### Inference\n",
597-
"Let's run the model via Unsloth native inference! According to the `Gemma-3` team, the recommended settings for inference are `temperature = 1.0, top_p = 0.95, top_k = 64`"
597+
"Let's run the model via Unsloth native inference! According to the `Gemma-4` team, the recommended settings for inference are `temperature = 1.0, top_p = 0.95, top_k = 64`"
598598
]
599599
},
600600
{
@@ -628,7 +628,7 @@
628628
" **inputs,\n",
629629
" max_new_tokens = 64, # Increase for longer outputs!\n",
630630
" use_cache=True,\n",
631-
" # Recommended Gemma-3 settings!\n",
631+
" # Recommended Gemma-4 settings!\n",
632632
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
633633
")\n",
634634
"tokenizer.batch_decode(outputs)"
@@ -668,7 +668,7 @@
668668
" **inputs,\n",
669669
" max_new_tokens = 64, # Increase for longer outputs!\n",
670670
" use_cache=True,\n",
671-
" # Recommended Gemma-3 settings!\n",
671+
" # Recommended Gemma-4 settings!\n",
672672
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
673673
" streamer = TextStreamer(tokenizer, skip_prompt = True),\n",
674674
")"
@@ -742,7 +742,7 @@
742742
"_ = model.generate(\n",
743743
" **inputs,\n",
744744
" max_new_tokens = 128, # Increase for longer outputs!\n",
745-
" # Recommended Gemma-3 settings!\n",
745+
" # Recommended Gemma-4 settings!\n",
746746
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
747747
" streamer = TextStreamer(tokenizer, skip_prompt = True),\n",
748748
")"

nb/Gemma4_(31B)-Text.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@
376376
"id": "8Xs0LXio7rfd"
377377
},
378378
"source": [
379-
"We now have to apply the chat template for `Gemma-3` onto the conversations, and save it to `text`. We remove the `<bos>` token using removeprefix(`'<bos>'`) since we're finetuning. The Processor will add this token before training and the model expects only one."
379+
"We now have to apply the chat template for `Gemma-4` onto the conversations, and save it to `text`. We remove the `<bos>` token using removeprefix(`'<bos>'`) since we're finetuning. The Processor will add this token before training and the model expects only one."
380380
]
381381
},
382382
{
@@ -594,7 +594,7 @@
594594
"source": [
595595
"<a name=\"Inference\"></a>\n",
596596
"### Inference\n",
597-
"Let's run the model via Unsloth native inference! According to the `Gemma-3` team, the recommended settings for inference are `temperature = 1.0, top_p = 0.95, top_k = 64`"
597+
"Let's run the model via Unsloth native inference! According to the `Gemma-4` team, the recommended settings for inference are `temperature = 1.0, top_p = 0.95, top_k = 64`"
598598
]
599599
},
600600
{
@@ -628,7 +628,7 @@
628628
" **inputs,\n",
629629
" max_new_tokens = 64, # Increase for longer outputs!\n",
630630
" use_cache=True,\n",
631-
" # Recommended Gemma-3 settings!\n",
631+
" # Recommended Gemma-4 settings!\n",
632632
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
633633
")\n",
634634
"tokenizer.batch_decode(outputs)"
@@ -668,7 +668,7 @@
668668
" **inputs,\n",
669669
" max_new_tokens = 64, # Increase for longer outputs!\n",
670670
" use_cache=True,\n",
671-
" # Recommended Gemma-3 settings!\n",
671+
" # Recommended Gemma-4 settings!\n",
672672
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
673673
" streamer = TextStreamer(tokenizer, skip_prompt = True),\n",
674674
")"
@@ -743,7 +743,7 @@
743743
" **inputs,\n",
744744
" max_new_tokens = 128, # Increase for longer outputs!\n",
745745
" use_cache=True,\n",
746-
" # Recommended Gemma-3 settings!\n",
746+
" # Recommended Gemma-4 settings!\n",
747747
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
748748
" streamer = TextStreamer(tokenizer, skip_prompt = True),\n",
749749
")"

nb/Gemma4_(E2B)-Audio.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@
11171117
"source": [
11181118
"<a name=\"Inference\"></a>\n",
11191119
"### Inference\n",
1120-
"Let's run the model via Unsloth native inference! According to the `Gemma-3` team, the recommended settings for inference are `temperature = 1.0, top_p = 0.95, top_k = 64` but for this example we use `do_sample=False` for ASR."
1120+
"Let's run the model via Unsloth native inference! According to the `Gemma-4` team, the recommended settings for inference are `temperature = 1.0, top_p = 0.95, top_k = 64` but for this example we use `do_sample=False` for ASR."
11211121
]
11221122
},
11231123
{
@@ -1268,7 +1268,7 @@
12681268
"_ = model.generate(\n",
12691269
" **inputs,\n",
12701270
" max_new_tokens = 128, # Increase for longer outputs!\n",
1271-
" # Recommended Gemma-3 settings!\n",
1271+
" # Recommended Gemma-4 settings!\n",
12721272
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
12731273
" streamer = TextStreamer(processor, skip_prompt = True),\n",
12741274
")"

nb/Gemma4_(E4B)-Audio.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@
628628
"source": [
629629
"<a name=\"Inference\"></a>\n",
630630
"### Inference\n",
631-
"Let's run the model via Unsloth native inference! According to the `Gemma-3` team, the recommended settings for inference are `temperature = 1.0, top_p = 0.95, top_k = 64` but for this example we use `do_sample=False` for ASR."
631+
"Let's run the model via Unsloth native inference! According to the `Gemma-4` team, the recommended settings for inference are `temperature = 1.0, top_p = 0.95, top_k = 64` but for this example we use `do_sample=False` for ASR."
632632
]
633633
},
634634
{
@@ -760,7 +760,7 @@
760760
" **inputs,\n",
761761
" max_new_tokens = 128, # Increase for longer outputs!\n",
762762
" use_cache=True,\n",
763-
" # Recommended Gemma-3 settings!\n",
763+
" # Recommended Gemma-4 settings!\n",
764764
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
765765
" streamer = TextStreamer(processor, skip_prompt = True),\n",
766766
")"

0 commit comments

Comments
 (0)