ComfyUI Node

Jina CLIP v2 Loader

Jina CLIP v2 Loader — the front door to replacing SDXL's text encoder

By lRemixl·Created 5 months ago·Updated 3 months ago· 0
Jina CLIP v2 Loader
    • jina_model
    • info
    model_name
    deviceauto
    force_reloadfalse
    dtypeauto

    The Jina CLIP v2 Loader is where a Jina-driven SDXL workflow starts. It's the node that replaces your CLIP loader: instead of loading the small OpenCLIP-G text encoder that SDXL was born with, it loads Jina CLIP v2, a 0.9B multilingual embedding model that actually understands what you wrote. The name isn't clickbait - it genuinely changes how the model reads prompts, and it's the least fiddly node in this whole pack, because there's exactly one thing you must get right: the model file in the right folder.

    Why swap text encoders at all? SDXL's stock CLIP truncates at 77 tokens, trips over non-English words, and treats a comma-separated tag list about as well as a child's first word list. Jina CLIP v2 (561M-parameter text tower over a multilingual RoBERTa base, plus a 304M vision tower you don't even need) understands 89 languages and long-form descriptions, and its pooled embedding performs on par with jina-embeddings-v3 - the best sub-1B multilingual embedding model on MTEB. Text encoders are the part of the pipeline that decides how much of your intent actually reaches the UNet ([kg/entities/text-encoder.json]), and this swap is exactly the 2026-style move: keep the SDXL checkpoint, retire the weak encoder.

    How it works

    Under the hood the loader builds a JinaStates object: it loads the tokenizer and AutoModel.from_pretrained(model_id, trust_remote_code=True), attaches a forward hook to the text-encoder module to capture per-token hidden states, and then deletes the vision tower to free VRAM - you only need the text half, and the pack knows it. It also runs a flash-attention bypass: Jina's import can crash ComfyUI if a broken flash-attn build is sitting in your Python path, so the pack surgically removes it from sys.modules before loading. That bit is automatic; you don't touch it.

    The output is a JINA_MODEL object that the encoder nodes consume, not a tensor you wire into a sampler directly.

    The inputs that matter

    • model_name - picks from whatever's in ComfyUI/models/llm/. The base model is jinaai/jina-clip-v2: put the whole repo folder (it needs config.json plus the safetensors, ~1.7GB) at models/llm/jina-clip-v2. Note the license is CC-BY-NC-4.0 - free for personal tinkering, not for commercial products.
    • dtype (auto default) - auto resolves to bf16, with fp16/fp32 as fallbacks. bf16 is the sensible default; drop to fp32 only if you're chasing numerical issues.
    • device (auto default) - auto, cuda:0/1, or cpu. Leave it.
    • force_reload - reloads from disk and rebuilds the object even if one is already cached. Useful after you update the model files.

    Outputs: jina_model (feed it into Jina Text Encode (SDXL)) and info (a STRING describing the model path and device - handy for confirming which file actually loaded).

    How to install

    From ComfyUI Manager, search "ComfyUI_JinaCLIP_SDXL_Adapter" and install, or:

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

    Then restart. There's no requirements.txt, and the pack only needs transformers, safetensors, and einops, which standard ComfyUI installs already carry. The real install is the model: download jina-clip-v2 into models/llm/. First load pulls from HuggingFace (local_files_only=False in the code), so give it a few minutes and a stable connection the first time. The rest of the chain - Jina Adapter LoaderJina Text Encode (SDXL) → your KSampler - will refuse to do anything until this node has loaded, which is the point: it's the foundation.

    One honest note: this is the node people use, then quietly realize the quality win comes mostly from the adapter and the encoder choices downstream. The loader just needs to not be the thing that breaks. Get the folder right and it won't be.

    Categoryllm_sdxl/jina

    Inputs (4)

    NameTypeDefaultDescription
    model_nameCOMBO0 options:
    deviceoptCOMBOauto4 options: auto, cuda:0, cuda:1, cpu
    force_reloadoptBOOLEANfalse
    dtypeoptCOMBOauto4 options: auto, bf16, fp16, fp32

    Outputs (2)

    NameTypeDescription
    jina_modelJINA_MODEL
    infoSTRING