Instructions to use google/gemma-4-E4B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/gemma-4-E4B-it with Transformers:
# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("google/gemma-4-E4B-it") model = AutoModelForMultimodalLM.from_pretrained("google/gemma-4-E4B-it", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- AMD Developer Cloud
fix: chat_template, keep tool-call reasoning across later user turns
Summary
An assistant turn that called a tool loses its reasoning_content as soon as a later user message exists. On an agent loop that is every turn after the first tool call, and it invalidates ~27% of the previously cached prefix.
Patched chat_template.jinja attached. One-line change.
Hub main |
this PR | |
|---|---|---|
| ChatLint errors | 3 | 2 |
think_then_tool history_rewrite |
fail (27.5% prefix lost) | pass |
The remaining 2 are the preamble-hoist issue (assistant text after <tool_response|>), unchanged.
Fix
- {%- set thinking_gate = (loop.index0 > ns_turn.last_user_idx) or (preserve_thinking and message.get('tool_calls')) -%}
+ {%- set thinking_gate = (loop.index0 > ns_turn.last_user_idx) or message.get('tool_calls') or preserve_thinking -%}
Keep reasoning whenever the message itself made tool calls. preserve_thinking still opts into keeping plain (non-tool) reasoning across the whole history.
The Jul 15 commit was titled "reasoning preservation"; this is the remaining hole. Identical one-liner applies to gemma-4-31B-it / 12B / 26B-A4B-it (separate PRs, same patch files under the contribution).
Reproduce
pip install chatlint
chatlint check chat_template.jinja
Ask
A ChatLint CI workflow on template changes would have flagged this. Happy to open that as a follow-up.