BFS H3 Token / Word Weight Editor (Experimental)
Getting prompt weighting back on a model that throws it away
- conditioning
- model
- clip
- positive
- model
- report
Why this exists at all
Here's the fact that makes this node make sense: on any LLM-encoded model, ComfyUI's prompt weighting is inert. Not weakened - discarded. Type (golden fur:1.3) into a Qwen-encoded prompt and the tokenizer reads your parentheses and colon as literal punctuation and feeds them to the encoder as text. That's worse than nothing, because now your prompt contains garbage characters.
MiniMax H3 encodes with a Qwen tokenizer, so it inherits that. The KB's take on prompt engineering is blunt about it: delete the syntax and say what you want in words.
BFS H3 Token / Word Weight Editor (Experimental) is an attempt to claw the capability back - not by parsing bracket syntax, but by reaching into the conditioning tensor after it's been encoded and changing the force on specific text tokens. It's the most technically interesting thing in this pack and also the one I'd trust least without checking every result.
Notice the author's honesty markers: "experimental" in the display name, "(experimental)" after both mode options, and a docs section headed "Validation boundaries." Believe them.
Mechanism: two completely different tricks
mode picks the method.
attention logits (experimental) leaves the conditioning tensor alone. For target-video queries, it adds log(force) to the attention logits of the selected text keys. Because those logits all share one softmax, this multiplies the unnormalized weight - it does not scale the final probability by that factor. It requires TARA upstream and requires both this node's model and positive outputs to be used together, so the policy is applied on the same pass. Up to 16 disjoint weighted ranges; contiguous tokens with the same force share one range.
embedding magnitude (experimental) is simpler and more predictable: it multiplies the selected text embedding vectors by their force after encoding, leaving every other row and all metadata untouched. No renormalization, no empty-prompt subtraction. This does not reproduce SD1.5 weighting, and the author doesn't claim it does.
Both modes are limited in the same way: contextual encoders mix meaning across tokens. Turn one token down and its meaning still lives in the neighbouring vectors. Strengthen one and you may drag other attributes with it.
conditioning has to be traced - coming out of the pack's Native Reference Set to Video encode, which stamps a token trace onto the conditioning. The fallback is clip + original_prompt: give it the H3 CLIP and the exact prompt that was encoded. Guessing is refused. So is a prompt that still contains (phrase:1.3) syntax - inline weights must be removed before encoding, and there's an explicit error saying so.
Inputs and outputs
model comes from TARA (or from a cast binding after it). Out comes positive (the edited conditioning - this goes to the guider), model (to the guider and the scheduler), and report, a string worth wiring to a preview while you're learning what the chips mean.
inspect_only is the workflow everyone should start with: on, it encodes, shows the token chips, and blocks sampling outright so you burn no GPU time guessing. Turn it off, queue again, it renders. Changes only apply to the next queue - editing chips mid-run does nothing.
weights_json is the panel's backing store (default {}); you don't type in it. weighted_phrases is the friendlier route from 1.115.30 - one exact phrase per line:
(golden fur:1.3)
(original background:1.2)
These are matched case-sensitively against the already-encoded prompt using real tokenizer offsets, need no extra CLIP pass, and weight every exact occurrence. Word edges don't match substrings (man won't hit woman), a missing phrase fails loudly instead of guessing, and forces must stay within 0.05–3.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/alisson-anjos/ComfyUI-BFSNodes.git
cd ComfyUI-BFSNodes
pip install -r requirements.txt
Restart ComfyUI and hard-refresh the browser - the token chip panel is web/js, so a stale cached frontend means no chips and a node that looks broken.
Common issues
"Embeddings alone cannot be decoded into original words." You connected a conditioning with no trace and no clip/original_prompt pair. There's no inverse function; supply the prompt.
"Token trace overlaps visual or invalid rows." A safety check, and a good one - it refuses to weight Qwen's visual rows or reference latents rather than corrupting them. Usually means the conditioning came from a different encoder path than the trace expects.
Old manual token indices stopped working in a shot loop. Expected. Nonneutral index overrides aren't remapped across different per-shot prompts; only weighted_phrases gets re-matched per shot.
"Token editor currently supports one H3 conditioning sequence, not scheduled conditioning." Exactly what it says. Feed it a scheduled or batched conditioning and it refuses rather than editing one slice and silently ignoring the rest.
Runs finish in ~0.1 s with no video. You're in inspect mode (or a cached inspection blocker). Check inspect_only before assuming the GPU broke.
Speed dropped. Attention mode goes through Flash Partitions, and every additional partition call costs time. Remove Model Sparse Attention while using nonneutral attention controls - sparse routing isn't supported here.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| conditioning | CONDITIONING | — | |
| model | MODEL | — | |
| mode | COMBO | 2 options: attention logits (experimental), embedding magnitude (experimental) | |
| inspect_only | BOOLEAN | false | On: show tokens and stop before sampling. Adjust tokens in the panel; switch off and queue again to render. |
| weights_json | STRING | {} | — |
| clipopt | CLIP | — | |
| original_promptopt | STRING | — | |
| weighted_phrasesopt | STRING | Exact phrases such as (golden fur:1.3), one per line. Applies to every exact occurrence in the encoded prompt. No extra CLIP pass. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| positive | CONDITIONING | — |
| model | MODEL | — |
| report | STRING | — |