Nodes/ComfyUI-UtilsCollection/Attention Bias Encode (Legacy)
ComfyUI Node

Attention Bias Encode (Legacy)

Weight individual phrases by biasing their attention, not their tokens

By silveroxides·Created 3 months ago·Updated a day ago· 36
Attention Bias Encode (Legacy)
  • clip
  • conditioning
text

You know the problem: on the LLM-encoded models - the Krea2/Qwen/Ideogram-4-style text encoders that power most of what people run in 2026 - the old (word:1.3) attention syntax is silently discarded. Prompt engineering doc after prompt engineering doc tells you weighting doesn't survive the encoder. Attention Bias Encode (Legacy) is the workaround: instead of weighting tokens, it biases the attention between the tokens and the conditioning, which does survive.

The mechanism is the interesting part, and it's worth getting roughly right. This is a CLIP-text-encode node - you feed it a clip and text, you get conditioning out - with one extra syntax. Write <word=2.5> inside your prompt and it sets up an attention-bias mask on the encoder's self-attention: the "key-column" for that span of tokens is scaled up or down, so those tokens get attended-to more (or less) during conditioning. No token weighting is applied - the encoder sees the raw text - but the resulting conditioning carries the bias in its attention mask. It's a different lever than old-style weighting, and it's the one that actually works on these models.

The inputs that matter

  • clip - the text encoder. Any CLIP works; this shines on the modern LLM-style encoders where (word:1.3) is dead.
  • text - your prompt, with <word=strength> inline. Values above 1 emphasize, below 1 de-emphasize, 0..1 is fine, negatives are rejected.

The output

conditioning, wired into your sampler exactly like any other text-encode output. If your text contains no <...=...> patterns at all, it's a straight passthrough to normal clip.encode_from_tokens_scheduled - so this node is also just a working plain text encoder if you don't use the syntax.

Installing it

Part of silveroxides/ComfyUI-UtilsCollection. ComfyUI Manager → search ComfyUI-UtilsCollection → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection

Restart after. Dependencies are opencv-python and typing-extensions; everything this node needs lives in the model's own encoder. No downloads. "(Legacy)" marks the compat alias for the pack's canonical UC_AttentionBiasTextEncode.

Where people get burned

The syntax is picky: <word=1.5> requires no spaces and a valid number - <my red car = 1.5> won't parse and the node will either ignore it or fall back to plain encoding. Also, this biases attention, not the token embeddings, so the effect is subtler than old-style weighting and interacts with the rest of the prompt - a "2.5" on one phrase doesn't mean that phrase dominates, it means the encoder attends to it harder. Start with small strengths around 1.2–2 and judge by eye; going straight to 5 usually just makes the conditioning weird rather than more emphatic.

Categoryadvanced/conditioning

Inputs (2)

NameTypeDefaultDescription
clipCLIP
textSTRING

Outputs (1)

NameTypeDescription
conditioningCONDITIONING