Kolors Text Encode
Where your prompt becomes 4096-wide vectors
- chatglm3_model
- kolors_embeds
Kolors Text Encode is the node that takes your prompt, shoves it through the ChatGLM3 language model, and spits out the embeddings Kolors' sampler needs. It's the middle of the chain and the one with actual brains: this is where Kolors' unusually good language understanding happens, and also where a chunk of your VRAM briefly disappears.
Kolors, remember, is Kuaishou's mid-2024 model that swapped the usual CLIP or T5 encoder for a full ChatGLM3 LLM. That's why it parses Chinese and long natural-language prompts so well, and why the encode step is heavy. This node is where all of that lives.
How it works
It tokenizes your prompt at up to 256 tokens (truncating past that), runs it through the ChatGLM3 encoder, and pulls two things out of the hidden states: the sequence embeddings (77 tokens × 4096 dims per image) and a pooled "text projection" vector. It does the identical pass for the negative prompt, because classifier-free guidance needs both. Everything gets wrapped up as a KOLORS_EMBEDS object with prompt, negative, pooled, and negative-pooled components - exactly what Kolors Sampler asks for.
Two genuinely handy features hide in here:
- Random bracket syntax. Put
{red|blue|green}in your prompt and it randomly picks one each run - a poor man's dynamic prompt for exploring variations. Works in both prompt and negative. - Batched prompts. Separate several prompts with
|and it encodes them as a list, replicating the negative prompt to match. Pair that withnum_images_per_promptand you can fan a single negative across a whole batch.
The inputs
- chatglm3_model - from either ChatGLM3 loader (the auto-downloader or the local safetensors one).
- prompt and negative_prompt - plain multiline text. Keep prompts under 256 tokens; the encoder truncates, so novels get their ending chopped.
- num_images_per_prompt - default 1, up to 128. It duplicates the embeddings per image, which multiplies the sampler's workload, not the encode itself.
Output is a single kolors_embeds, wired into the kolors_embeds input of Kolors Sampler.
Installing it
Same pack as the rest of the chain:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KwaiKolorsWrapper
cd ComfyUI-KwaiKolorsWrapper
pip install -r requirements.txt
Restart ComfyUI, or install via ComfyUI Manager by searching "KwaiKolorsWrapper". The heavy lifting here - transformers and the ChatGLM bits - is all in requirements.txt (mind the README's note that transformers 4.38.0+ is required).
Where people get burned
- The first encode is slow and VRAM-heavy. The encoder gets moved onto the GPU for the pass, then offloaded and cached cleared - that's by design, but on an 8 GB card it can spike hard. Prefer a quantized ChatGLM3 loader (quant8/quant4) if your card flinches here.
- This node doesn't understand SD syntax. No
(word:1.2)weighting, no embeddings or LoRA-style prompt tricks - it's an LLM, so write in plain sentences. The{a|b}and|syntaxes above are the only prompt "magic" it knows. - It needs a real prompt. Feed it an empty string and you'll get the unconditional/empty encode, which is technically valid but not a plan.
- If the pack won't import at all, it's the known diffusers/transformers version clash again - the community fallback is the MinusZoneAI/Kolors-MZ wrapper, which implements the same encode natively.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| chatglm3_model | CHATGLM3MODEL | — | |
| prompt | STRING | — | |
| negative_prompt | STRING | — | |
| num_images_per_prompt | INT | 11–128 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| kolors_embeds | KOLORS_EMBEDS | — |