Gemma 4 Text Generation
Gemma 4 text generation without the vision — the local prompt engine
- RESPONSE
Sometimes you just want the language model to think, without a camera in the loop. That's this node: the text-only member of the ComfyUI-Gemma4 pack, wrapping Google's Gemma 4 12B instruct model and running it fully local. Give it a rough idea, get back a rewritten, structured prompt; give it a string, get back a paragraph. It's the "small and obedient" local writer that the LLM-in-the-graph pattern keeps reaching for - no API key, no Ollama server in the background, just the model sitting in ComfyUI.
The honest framing: a 12B chat model is not writing better English than a frontier API, and it's not a reasoning model either - you don't want it to be. Its job is the short, structured rewrite: turning "cyberpunk street in the rain" into something your encoder actually understands, or drafting the dialogue line a video's audio pass needs. It follows a format and stops, which is precisely what the diffusion side wants from a helper.
How it works
Same machinery as its siblings: it loads gemma-4-12b-it from ComfyUI/models/LLM/gemma-4-12b-it/ via the official ModelScope transformers implementation, so it avoids the llama.cpp/GGUF incompatibility that broke most ComfyUI loaders when Gemma 4 shipped. The difference from the multimodal nodes is that there's no vision encoder in the path at all - no image input, no vision_token_budget. That's actually the appeal: it's the cheapest node in the pack to run, the one most likely to leave room on the card for the sampler.
The node builds a chat with your optional prompt as the system message and text as the user message, then generates. If you've ever wondered why the output occasionally starts mid-thought, it's sampling, not a bug.
The inputs that matter
- text - your actual request. The user message. This is the one you're editing.
- prompt - optional system prompt. Worth using: the community verdict on Gemma 4 as a prompt writer is that the system prompt does half the work. Give it a role and an output format and it stops drifting.
- max_tokens - 1024 default, up to 8192. Crank it only if you're generating long text; for prompt rewriting, less is faster.
- temperature / top_p / top_k - the standard sampling trio. Defaults (1.0 / 0.95 / 64) are fine; drop temperature toward 0.7 if rewrites feel random.
- enable_thinking - turns on Gemma's reasoning pass, returned wrapped in
<think>...</think>. Tempting, but for prompt rewriting it mostly burns tokens and occasionally leaks scratch-work into your conditioning. Leave it off unless you want the deliberation. - keep_model_loaded - default
true. Keep it on if this node is a constant in your graph; turn it off so the model releases VRAM after each run when it's a once-in-a-while helper. - seed -
torch.manual_seedunder the hood. Same seed, same answer.
Output is one RESPONSE string, ready to wire into a CLIP text encoder, a text node, or a save-to-file.
Installing it
Same as the rest of the pack: ComfyUI Manager (search "Gemma 4 - Multimodal AI") or
cd ComfyUI/custom_nodes
git clone https://github.com/mailzwj/ComfyUI-Gemma4
cd ComfyUI-Gemma4
pip install -r requirements.txt # numpy, torch, Pillow, modelscope
then restart. The model comes from ModelScope, manually, into ComfyUI/models/LLM/gemma-4-12b-it/ - there's no auto-download, and the first run dies with a load error until the folder is complete.
Where people get burned
The recurring complaint in the community is that a full-precision Gemma 4 text generator eats VRAM and takes forever "even for the small model" - and that's the honest tradeoff here. This pack loads bf16 12B, roughly 24GB, because it doesn't do GGUF. On a 16GB card you'll feel it. If your use case is purely text, plenty of people end up happier with a 4-bit Ollama path at a fraction of the memory, or an even smaller abliterated 8B. This node is the right call when you specifically want official-implementation Gemma 4 and can feed it. It's a small, young pack from a low-profile author - the usual "read a fresh node before you run it" caution applies, but the code is short and open.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| text | STRING | — | |
| max_tokens | INT | 102464–8192 | — |
| temperature | FLOAT | 1.000–2 | — |
| top_p | FLOAT | 0.950–1 | — |
| top_k | INT | 641–256 | — |
| enable_thinking | BOOLEAN | false | — |
| keep_model_loaded | BOOLEAN | true | — |
| seed | INT | 420–4294967295 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| RESPONSE | STRING | — |