Nodes/NKD Klein Tools/😺NKD Klein Reference Weight
ComfyUI Node

😺NKD Klein Reference Weight

Turn one reference up or down without touching the others

By Nekodificador·Created 4 months ago·Updated 11 days ago· 80
😺NKD Klein Reference Weight
  • model
  • model
â—„reference_index1â–º
â—„weight1.00â–º
◄schedule—►

Multi-reference Klein is great until one reference hogs the image. You give the model three visual hints and the one you wanted as a subtle mood-setter is running the show. NKD Klein Reference Weight fixes exactly that: it lets you dial the attention weight of a single reference, independent of all the others. Turn a secondary reference up so it asserts itself, or turn an over-dominant one down to a whisper.

It's an optional node from the NKD Klein Tools pack - you only add it when you want the extra control, on the model line between Presampling and your sampler.

How it works

Klein doesn't process references like an inpainting model blends a mask. It concatenates each reference as extra tokens at the end of the attention sequence - [txt | canvas | ref_0 | ref_1 …] - and the model attends to them on every denoise step. This node hooks into that attention (set_model_attn1_patch) and scales the target reference's key/value tokens. Multiply k/v by less than 1 and the softmax attention toward that reference weakens; more than 1 and it strengthens. It's the same mechanism the neighboring Klein Enhancer pack's "Ref Latent Weight" uses, and because it lives at the token level it's independent of resolution and of how many references you've loaded.

The weight scale is simple: 1.0 leaves the reference exactly as usual, below 1 fades it out (0 = removed), above 1 reinforces it (up to 2).

Inputs that matter

  • reference_index - which reference this node controls. 0 is your main image (ref_0), 1 is ref_1, and so on, in the order you connected them.
  • weight - the strength dial above. A connected curve multiplies this per step; with no curve it applies flat across all steps.
  • schedule (optional) - a per-step curve in [0,1] that multiplies the weight across the generation. The pack author's own NKD Sigmas Curve node outputs exactly the FLOAT this expects. A curve that starts high and drops to zero lets a reference set the overall look early, then step aside so it doesn't take over the fine details.

Output is a single model you feed onward to your sampler. Want to control two references separately? Chain two of these nodes, one per reference - each adds its own independent patch. Untouched references keep their default influence.

Where it fits - and what it isn't

This node is not the same thing as Presampling's Reference Strength. That dial controls positional anchoring - how tightly the result's layout sticks to the reference. This one controls how much the reference shows up. You can keep a loose layout with a strong look, or the reverse; the README makes the distinction explicitly because people confuse them.

If you think you might want regional confinement later (one reference pinned to one zone of the canvas), consider NKD Klein Reference Control instead - it bundles this strength/weight control plus an optional per-step schedule and an optional region mask into a single node. If all you need is the strength dial, this leaner node is the one to grab.

Installing and using

Search NKD Klein Tools in ComfyUI Manager, or clone the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Nekodificador/ComfyUI-NKD-Klein-Tools

Restart ComfyUI. No extra Python dependencies - the pack's requirements.txt is empty; torch and the ComfyUI API come from ComfyUI itself. Then wire it on the model line:

NKD Klein Presampling → NKD Klein Reference Weight → [your sampler] → NKD Klein Postsampling

Set reference_index to the reference you want to adjust, drag the weight, and run. That's the whole node. It's deliberately tiny - and the kind of small, focused control that makes multi-reference work feel less like gambling.

Category😺NKD Nodes/Klein

Inputs (4)

NameTypeDefaultDescription
modelMODEL—
reference_indexINT10–7Which reference this node controls. 0 = the main reference (ref_0), 1 = ref_1, … in the order added.
weightFLOAT1.000–2Attention weight for this reference. 1.0 = no change, below 1 dilutes (0 = removed), above 1 reinforces (up to 2). A connected curve multiplies this per step; with no curve it applies flat across all steps.
scheduleoptFLOATOptional per-step curve in [0,1] for THIS reference that MULTIPLIES its weight (e.g. the FLOAT output of NKD Sigmas Curve). With weight 2.0, a 1→0.5 curve runs the effective weight from 2.0 to 1.0, a 1→0 curve from 2.0 to 0 (removed). Leave unconnected for flat weight.

Outputs (1)

NameTypeDescription
modelMODEL—