Nodes/Encode Prompt with Attention Bias/CLIP Text Encode (w Attention Bias)
ComfyUI Node

CLIP Text Encode (w Attention Bias)

1.3) is dead on Flux. This node brings weighting back as an attention bias

By silveroxides·Created 11 months ago·Updated 10 months ago· 2
CLIP Text Encode (w Attention Bias)
  • clip
  • CONDITIONING
text

If you've tried to weight a word on Flux, Chroma, or any T5-era model, you already know the pain: (a huge dog:1.25) just feeds the parentheses and colon to the text encoder as literal characters. ComfyUI disables embedding weighting for those models, so the syntax you leaned on through the whole SD 1.5/SDXL era silently does nothing - or worse, pollutes the prompt. CLIP Text Encode (w Attention Bias) is a drop-in replacement for CLIP Text Encode that brings weighting back the one way it still works: as a bias on attention, not on the embedding.

It's a tiny, single-node pack (the whole repo is one file and a pyproject.toml) by Silveroxides, aimed squarely at the Flux-era problem. The pitch is in the name: instead of (word:1.3) you write <a huge dog=1.25>.

What it actually does

Swap it in where you'd use a normal CLIP Text Encode: wire a CLIP into clip, type your prompt into text, and the single CONDITIONING output feeds the sampler's positive or negative input exactly like always. The <...=strength> segments get parsed out, the words stay in the prompt, and each phrase gets its own attention strength. 1.0 is neutral, above boosts, below reduces.

The mechanism is the interesting part, because it's genuinely different from SD weighting. The node tokenizes the full prompt, works out which token span each biased phrase occupies, then builds a log-space attention mask where log(strength) gets added to every attention pair touching those tokens - both directions, tokens-to-world and world-to-tokens. That mask rides out of the node inside the conditioning's attention_mask channel. This isn't some private hack; it's the same channel ComfyUI core itself uses for StyleModelApply's attn_bias mode, and the Flux model path reads it in extra_conds and feeds it straight into cross-attention as a logit bias. Because it's added in log space, it reshapes the softmax - the phrase genuinely grabs a bigger share of attention without its embedding direction being distorted. That's why high weights here don't oversaturate the way (word:1.7) does at the embedding level; you're turning up a dial on attention, not stretching a vector.

The honest caveat

This only works where ComfyUI actually consumes attention_mask, which is the Flux/DiT model path. The classic SD 1.5/SDXL UNet ignores that conditioning channel entirely, so there the node degrades into a plain text encode (with your brackets stripped). A Flux-era tool, through and through.

Two things worth knowing in practice:

  • <cat=0> doesn't mean "almost nothing" - log(0) is -inf, which hard-blocks attention to those tokens. That's a usable erase move, and also the easiest way to confuse yourself later.
  • Negative prompt weighting is fair game; the bias applies wherever you put the node.

Installing it

Nothing to download, nothing to configure. The pack has zero dependencies and no model files - just the node code, published to the Comfy Registry.

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

Then restart ComfyUI. Or use ComfyUI Manager and search for ComfyUI_PromptAttention - it's registered, so it'll install and track updates.

Issues and expectations

Keep expectations honest: this is a young, two-star pack - created October 2025, one burst of dev in mid-November, then quiet since. No README, no open issues. It works as advertised on Flux-class models, but there's no community mileage behind it yet, so treat the output like you'd treat any untested weighting approach - eyeball it against a seed-matched run with a normal text encode before you build a workflow around it. If the clip input lands empty, you'll get a clear error telling you the checkpoint lacks a valid text encoder. The text field supports dynamic prompts, so your wildcard setup can feed it directly. It's the rare weighting tool that still has a job to do in the post-T5 world - just know which models it's actually for.

Categoryconditioning

Inputs (2)

NameTypeDefaultDescription
textSTRINGThe text to be encoded.
clipCLIPThe CLIP model used for encoding the text.

Outputs (1)

NameTypeDescription
CONDITIONINGCONDITIONING