In this article
The Kolors text interface uses both token-level and pooled features; an arbitrary mean of the same hidden tensor is not the documented replacement.
Identify the selected text encoder
The Kolors pipeline documentation identifies ChatGLM as its frozen text encoder. A generic image-generation integration must not assume the encoder follows every convention of a CLIP-based pipeline. The model consumes particular text representations learned together with its generator interface. Preserving tokenizer identity and supported sequence handling is necessary, but it is not sufficient if a custom implementation selects a different hidden layer or constructs a different pooled condition.
Trace token-level features
The pipeline implementation selects the penultimate hidden-state output for token-level conditioning. That output initially uses sequence, batch, hidden axes and is permuted into batch, sequence, hidden order. A reshape is not a semantic substitute for an axis permutation: it can retain storage values while associating them with the wrong examples or token positions. Keep the actual axis transformation explicit when porting the encoder or exporting its outputs.
Preserve the distinct pooled selection
The same implementation constructs pooled features from the final position of the final hidden-state output. This differs from averaging the penultimate token features. The pooled and sequence conditions therefore have separate provenance even though both originate in one text encoder. Cache and validate them together without synthesizing one from the other through an undocumented reduction. Matching the expected pooled shape only proves dimensional compatibility, not that the generator received the representation it was trained to interpret.
Use a batch that reveals alignment errors
Imagine a custom worker tested only with a single short prompt. A mistaken sequence/batch conversion may be harder to notice there than with several clearly different prompts and lengths. Compare each example’s token features and pooled vector with the native path before evaluating full images. The official Kolors repository provides model and usage context, including bilingual input support, but that support does not repair a wrapper that swaps examples or changes the hidden-state selection.
Keep conditioning provenance complete
Record text-encoder and tokenizer revisions, hidden-state selections, axis transformations, masks or position inputs where used, and paired negative conditions. Validate both feature types before optimizing text caching. Existing guides on tensor axes and strides versus transpose provide background. Kolors’ distinctive boundary is a specific ChatGLM feature extraction contract; correct shapes and fluent input text alone cannot prove that custom conditioning preserved it.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.