T5Gemma Text Encoder
The T5Gemma branch's text front end
- llm_model
- llm_tokenizer
- hidden_states
- attention_mask
- info
T5GEMMATextEncoder is the T5Gemma branch's version of LLMTextEncoder - the node that turns your prompt into the hidden states the adapter chain consumes. Same spirit, different mechanics. Where the Gemma encoder wraps your text in a chat template and relies on a system prompt, this one takes the plain T5-style approach: tokenize, pad to a fixed length, run through the encoder, hand back the token-level states and the attention mask.
It's the middle link in a chain that looks like T5GEMMALoader → T5GEMMATextEncoder → t5gemmaApplyLLMToSDXLAdapter. Because the apply node on this branch needs an attention mask (more on that there), this encoder is the only one in the pack that outputs one - hidden_states alone won't get you through the T5Gemma apply node.
What it does
The encode path is simple and legible: it appends <eos> to your text, tokenizes with padding="max_length" and truncation to max_length, runs the model, and returns the last_hidden_state cast to float32. No chat template, no token skipping - it's a straight encoder pass.
The inputs that matter:
llm_model/llm_tokenizer- fromT5GEMMALoader.text- your prompt, same natural-language-friendly behavior as the Gemma branch.max_length(default 512, up to 4096) - the fixed sequence length everything pads to. This has to line up with what the adapter expects; leave it at 512 unless you know better.device(cpuorcuda, defaultcuda) anddtype(float32orbfloat16, defaultbfloat16) - your precision/VRAM trade-off, right on the node.
Outputs: hidden_states (LLM_HIDDEN_STATES), attention_mask (LLM_ATTENTION_MASK), and info (STRING with the shape).
Honest notes
This is the least "finished-feeling" corner of the pack - the README documents the Gemma adapter, not a T5Gemma one, so you're on your own for weights that match the 2304-dim t5gemma preset. If that's what you're doing, this node is the reference implementation of how to feed the encoder. If you just want sentences working in SDXL, the Gemma branch (LLMModelLoader → LLMTextEncoder) is the smoother path.
Install
Ships with the ComfyUI LLM SDXL Adapter pack - ComfyUI Manager, search "ComfyUI LLM SDXL Adapter", or clone https://github.com/NeuroSenko/ComfyUI_LLM_SDXL_Adapter.git into ComfyUI/custom_nodes/ and restart. Dependencies: transformers>=4.53.1, einops, safetensors, torch.
Troubleshooting
- Attention mask goes in, error comes out - you tried to use this with the wrong apply node. The Gemma
ApplyLLMToSDXLAdapterhas no mask input; uset5gemmaApplyLLMToSDXLAdapter. - Wrong shapes vs. the adapter - check
max_lengthagainst your adapter'starget_seq_lenexpectation; a mismatch shows up as a linear-layer error on the other side. - Slow encoding on
float32/cpu- expected. Thedtype/deviceinputs exist precisely so you can drop to bf16 on GPU.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| llm_model | LLM_MODEL | — | |
| llm_tokenizer | LLM_TOKENIZER | — | |
| text | STRING | masterpiece, best quality, 1girl, anime style | — |
| max_length | INT | 5128–4096 | — |
| device | COMBO | cuda | 2 options: cpu, cuda |
| dtype | COMBO | bfloat16 | 2 options: float32, bfloat16 |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| hidden_states | LLM_HIDDEN_STATES | — |
| attention_mask | LLM_ATTENTION_MASK | — |
| info | STRING | — |