Nodes/ComfyUI-LaVi-Bridge-Wrapper/LaVi-Bridge T5 Encoder
ComfyUI Node

LaVi-Bridge T5 Encoder

Let T5-large read your prompt instead of CLIP

By kijai·Created 2 years ago·Updated 2 years ago· 21
LaVi-Bridge T5 Encoder
    • lavi_embeds
    promptOppenheimer sits on the beach on a chair, watching a nuclear exposition with a huge mushroom cloud, 120mm
    max_length77

    This is the node you'll actually use in a LaVi-Bridge workflow, because it's the half that works. The whole premise of LaVi-Bridge is that CLIP's stilted, 77-token word-list understanding is the bottleneck - so it swaps in a full language model to read your prompt, and a small adapter translates what the LLM "understood" into embeddings your SD1.5 UNet can condition on. The T5 Encoder is the version where that promise mostly pays off. The Llama-2 sibling in the same pack? Even the author admitted he "couldn't get anything useful" out of it.

    How it works

    Under the hood it's a three-part chain. Your prompt gets tokenized and pushed through a T5EncoderModel (the encoder-only T5-large, bf16, autodownloaded from Kijai's own Hugging Face repo). The last hidden states come out and get passed through the LaVi-Bridge TextAdapter - a small projection that maps T5's embedding space into the one Stable Diffusion expects. Meanwhile a text LoRA (lora_text.pt, rank 32) is monkeypatched into T5's attention layers so the encoder speaks "image prompt." It also encodes an empty string for the unconditional side and concatenates the two, so the sampler downstream can do classifier-free guidance without any extra work.

    The result is natural-language prompting that actually behaves. The default prompt in the node - an Oppenheimer-on-the-beach scene written as a whole sentence, with "120mm" for lens vibe - is exactly the kind of thing CLIP would butcher into fragments. That's the pitch: describe it like you'd tell a human.

    Inputs and output

    Only two inputs, and neither is scary:

    • prompt (STRING, multiline) - write normally. This is a T5, so long-form sentences, camera terms, composition language all have a fair shot at landing.
    • max_length (INT, default 77, up to 512) - 77 is SD1.5's old token budget, and the sane default. T5 handles more, so if you're writing big detailed prompts you can push this to 128 or 256. Don't set it higher than you actually use; you're paying for the padding.

    It returns one output, lavi_embeds (type LAVIEMBEDS), which plugs into the LaVi-Bridge Sampler - the only thing that consumes it. Match the lora_type dropdown in the LaVi-Bridge Model Loader to t5_unet, or none of this connects.

    Installing and the first-run downloads

    Install the pack (Manager search "ComfyUI-LaVi-Bridge-Wrapper", or git clone https://github.com/kijai/ComfyUI-LaVi-Bridge-Wrapper into custom_nodes) and pip install -r requirements.txt. The requirements file lists diffusers>=0.26.0, sentencepiece, and peft>=0.8.2; if ComfyUI complains about transformers or omegaconf, those get imported but aren't listed, so pip install them yourself.

    First encode autodownloads Kijai/t5-large-encoder-only-bf16 into ComfyUI/models/t5_model/ and the bridge adapters into ComfyUI/models/lavibridge/. T5-large is a few gigabytes, not a Llama - it loads fast and runs comfortably on a mid-range card, which is the whole reason this is the usable encoder.

    Where it lands

    Honest take: this is a 2024 experiment that the community mostly forgot by mid-2024 (there's literally a Reddit thread titled "I'm surprised LaviBridge has been forgotten about"). It's neat, it's historically interesting, and it's a great illustration of the "text encoder became a language model" direction everything went - but it's SD1.5-only, has no ControlNet support, and nobody's iterating on it. Reach for it if you want to see the pre-Flux version of LLM prompting in a working ComfyUI graph. Otherwise, treat it as a museum piece that happens to render.

    CategoryLaVI-BridgeWrapper

    Inputs (2)

    NameTypeDefaultDescription
    promptSTRINGOppenheimer sits on the beach on a chair, watching a nuclear exposition with a huge mushroom cloud, 120mm
    max_lengthINT771–512

    Outputs (1)

    NameTypeDescription
    lavi_embedsLAVIEMBEDS