Nodes/ComfyUI_JinaCLIP_SDXL_Adapter/Jina Text Encode (SDXL)
ComfyUI Node

Jina Text Encode (SDXL)

Jina Text Encode (SDXL) — the drop-in replacement for your CLIP Text Encode

By lRemixl·Created 5 months ago·Updated 3 months ago· 0
Jina Text Encode (SDXL)
  • jina_model
  • jina_adapter
  • CONDITIONING
  • info
textmasterpiece, (best quality:1.2)
Padding_ModeNearest-77
cross_attention_masktrue

This is the node you came for. In a normal SDXL workflow you have a CLIP Text Encode (Prompt) sitting in front of your KSampler. This node is the same shape with a different brain: give it the Jina model and adapter, type your prompt, and it spits out a CONDITIONING you wire into exactly the same positive/negative slots. Same socket, better prompt understanding, no 77-token ceiling, no API, no key. That's the whole pitch, and it mostly holds.

What you're buying is a text encoder that reads like a language model instead of a keyword scanner. SDXL's stock encoders choke on long sentences, foreign languages, and anything past token 77 (older workflows just silently chunked). Jina CLIP v2 is a 0.9B multilingual embedding model trained on 89 languages, and its embedding quality sits on par with the best sub-1B multilingual encoders around. The adapter on top (see Jina Adapter Loader) translates Jina's 1024-dim features into SDXL's 2048-dim sequence plus a 1280-dim pooled vector, so the UNet cross-attends to your words exactly like it always did - just better words.

How it works

The encode path is: tokenize your text → run it through the loaded Jina model to capture per-token hidden states → push those through the adapter's four attention blocks and two projection heads → build an SDXL-style conditioning. Three details matter in practice:

  • Weights still work. The node parses (word:1.2) and (word) A1111-style syntax into per-token weights, then applies them Comfy-style: it encodes the empty prompt, computes prompt_embeds = empty + (diff * weight), which is exactly the scaling trick ComfyUI uses. Old muscle memory survives the swap.
  • Padding is handled for you. Padding_Mode rounds the token count to a multiple of 77 (SDXL's native stride), or to a fixed 539/1078 to match the advanced adapter loader. Unused tokens are zero-padded and masked off so they don't leak meaning into the image.
  • The mask is real, not a gimmick. With cross_attention_mask on, the node appends a +1D attention mask to the conditioning, and the pack patches ComfyUI's attention blocks at import time so padding tokens are truly ignored during cross-attention. You don't have to install anything extra - the patch is automatic.

The inputs that matter

  • jina_model / jina_adapter - the outputs of Jina CLIP v2 Loader and Jina Adapter Loader. Both required; the chain is strict.
  • text - your prompt, multiline. Multiline is welcome: one concept per line reads better than a wall of commas.
  • Padding_Mode (Nearest-77 default) - keep it in step with the loader's max_seq_length. If you load the adapter at 539, padding to 539 is the honest setting.
  • cross_attention_mask (true default) - leave on unless you're debugging.

Outputs: CONDITIONING (into the KSampler's positive/negative) and info (token counts and embed shapes - worth wiring to a text node while you're tuning, because it shows you how many tokens you actually used).

Gotchas

Negative prompts still go through the same chain - you need a second Jina Text Encode (SDXL) (and often a second adapter instance) for the negative side, exactly like CLIP. And if your adapter is the initial release, load it with the Advanced adapter loader (positional embeddings: true, max_seq_length: 539, attn_pooling: true) - the basic loader's hardcoded settings can silently mismatch it. Flash-attn crashes during load are auto-bypassed by the pack, so if you see a "function object is not iterable" error, that's the known failure and the bypass should already have kicked in.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/lRemixl/ComfyUI_JinaCLIP_SDXL_Adapter

Then restart, and make sure the base model is in models/llm/ and the adapter in models/llm_adapters/. Manager finds it as "ComfyUI_JinaCLIP_SDXL_Adapter" if you prefer buttons. First run downloads the base model from HuggingFace, so budget a few minutes and a couple of GB. After that it's a local, keyless swap - the same habit change as when people first retired CLIP for T5 on Flux, just one node instead of a whole new checkpoint.

Categoryllm_sdxl/jina

Inputs (5)

NameTypeDefaultDescription
jina_modelJINA_MODEL
jina_adapterJINA_ADAPTER
textSTRINGmasterpiece, (best quality:1.2)
Padding_ModeCOMBONearest-774 options: none, Nearest-77, 539, 1078
cross_attention_maskBOOLEANtrue

Outputs (2)

NameTypeDescription
CONDITIONINGCONDITIONING
infoSTRING