CLIP Directional Prompt Attention Encode
Stop color bleed by rewriting CLIP's attention mask (a 2023 experiment that died on the vine)
- clip
- CONDITIONING
- IMAGE
- IMAGE
You've seen the failure this node exists to fix. Prompt like "a girl had green eyes and red hair" and SD 1.5 sometimes paints her whole head green, because CLIP lets the word "green" pour attention onto tokens far away from "eyes". The usual fixes are prompt weighting and word order - (green eyes:1.2), put the color next to the noun. This node takes a totally different route: instead of adjusting weights, it rewrites the CLIP transformer's attention mask so "green" is physically only allowed to look at "eyes". Neat idea. It's also a 2023 experiment whose own author walked away from it, so set expectations before you reach for it.
What it is, honestly
CLIP Directional Prompt Attention Encode is one node from the small andersxa/comfyui-PromptAttention pack. It subclasses ComfyUI's SD 1.5 tokenizer and lets you write a directed relationship into your prompt using < and >. Take the green/red example and the README's syntax:
a (girl < had (green > eyes) and (red > hair))
That's "green applies to eyes, red applies to hair, both apply to the girl." The same problem is what Cutoff for ComfyUI (BlenderNeko) attacks with isolated prompt masking; this pack's approach is cheaper - it uses the causal attention mask that's already baked into the HuggingFace CLIP implementation every SD 1.5 model uses. A causal mask means tokens can't see the future, which is great for language modeling but bad for image generation where you want the whole prompt represented. This node swaps that mask for one built from your arrows.
Now the part nobody on the comfy.icu page will tell you: the author pinned a notice to the top of the README saying the extension no longer works after the SD XL update (the HF transformers patch stopped applying), that models were never finetuned for this forced attention view anyway, and that "the quality suffers." The reddit corpus backs the vanishing act - about four exact-phrase mentions ever. This is a historical curiosity and an SD 1.5-only tool, not something you should build a workflow around in 2026.
The inputs that matter
- text (multiline) - your prompt with
</>relationship syntax.>means "this side attends to that side";<means the reverse. Note the README's warning:<only works with a non-causal mask. - clip - wire in your SD 1.5 CLIP from a checkpoint loader.
- default_emphasis (default 1.1) - the multiplier applied to any
(parenthesized)group, same behavior as ComfyUI's built-in weighting. - causal - the mode selector. Quick map:
Yes- keep the default causal mask (so backward<arrows are silently ignored).No- full attention, both arrows work.No (fully)- a fully-connected bidirectional graph, every token attends to every token.No (mirrored)- a symmetric version of the causal mask.
Outputs: a CONDITIONING you wire into a KSampler, plus two IMAGE previews - a graph of how your prompt got parsed, and an adjacency-matrix heatmap with token labels showing exactly which tokens attend to which. Those debug images are genuinely the best part: you can see whether your arrows parsed the way you thought, instead of guessing from the render.
Install
Via ComfyUI Manager (search "PromptAttention" or "CLIP Directional Prompt Attention"), or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/andersxa/comfyui-PromptAttention
Then restart ComfyUI. There are no model files to download. The README says you need scikit-learn and matplotlib in your Python environment - but the source also imports networkx at the top of its module, so install all three or the node won't load at all:
pip install matplotlib scikit-learn networkx
Troubleshooting & verdict
If ComfyUI throws an import error on startup, one of those three packages is missing. If your < arrows appear to do nothing, you left causal on Yes. And if the whole thing errors or quietly produces weird results on anything but an old SD 1.5 install - that's not you, that's the patch hook (_build_causal_attention_mask on the HF transformers text model) not being there anymore. Modern ComfyUI runs its own CLIP implementation, not HuggingFace's, so this node is fighting the architecture it was written for.
Read it once, run it on a 1.5 checkpoint if you're curious about the adjacency-matrix preview, and learn the idea: attribute bleeding is an attention problem, and masking is a legitimate attack on it. Just don't expect a fix that survives contact with 2026 models - this is a museum piece with a good demo.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| clip | CLIP | — | |
| default_emphasis | FLOAT | 1.100–2 | — |
| causal | COMBO | 4 options: Yes, No, No (fully), No (mirrored) |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| CONDITIONING | CONDITIONING | — |
| IMAGE | IMAGE | — |
| IMAGE | IMAGE | — |