Nodes/ComfyUI-BerniniR Wrapper/Bernini-R Apply NAG
ComfyUI Node

Bernini-R Apply NAG

The free detail boost that only works if you remember to connect the negative

By xiaolibai-sys·Created 2 months ago·Updated 2 months ago· 9
Bernini-R Apply NAG
  • positive
  • negative
  • positive
  • negative
nag_scale11.0
nag_tau2.5
nag_alpha0.25
inplacetrue

Normalized Attention Guidance, or NAG, is a training-free trick from the Wan community for squeezing extra detail out of a diffusion model by steering its attention away from what the negative prompt represents. It started in WanVideoWrapper, and BerniniR_ApplyNAG brings it to this pack. The node itself is deceptively simple - it's a conditioning-to-conditioning pass-through - but the mechanism it unlocks is why people who use it describe it as a free upgrade.

How it works

The node takes your positive conditioning, extracts the negative prompt's text embedding, and injects it into the positive conditioning as nag_prompt_embeds along with a set of hyperparameters. The sampler spots those keys and enables cross-attention NAG hooks during denoising: at each attention layer, the model steers attention away from the negative prompt's content while keeping detail. It's a pass on top of normal CFG, which is why the negative output is passed through separately - you connect both to the sampler and get NAG and plain CFG in one run.

The crucial behavior, straight from the node's own description: if you don't connect the negative input, both outputs pass through unchanged and NAG is disabled. No error, no warning, just quietly off. This is the #1 way people think they're using NAG and aren't.

The inputs that matter

  • positive - your positive conditioning, from BerniniR_PromptEmbedding (or BerniniR_SegmentSchedule).
  • negative - the same negative conditioning you're already feeding the sampler for CFG. This is the guidance signal.
  • nag_scale - guidance strength, default 11. Higher = stronger attention steering. This is the one you tune.
  • nag_tau - the norm-clamp threshold, default 2.5. It controls how aggressively outlier attention is suppressed. Leave it alone until you know what you're doing.
  • nag_alpha - blend factor between the original and NAG-steered attention, default 0.25. A mild blend, which is the right starting point.
  • inplace - reuses tensors in place to save VRAM. Default on; there's little reason to turn it off.

Outputs and wiring

Two: positive (now carrying NAG data) and negative (untouched pass-through). Wire both into the sampler's positive and negative inputs. That's it.

Where people get burned

Besides the forgotten-negative silent disable, the other gotcha is cranking nag_scale too high and getting oversharpened, twitchy video - start at the default and move in small steps. It also plays fine with the pack's fancier guidance modes and the GuidanceStrengthSchedule, since NAG operates inside the attention layers while those modes shape the combine step. If your output looks unchanged after adding this node, check the negative wire first, then the scale. And know that NAG is a detail enhancer, not a quality fixer - if your base generation has anatomy or motion problems, no amount of attention steering will fix those.

CategoryBernini-R/Conditioning

Inputs (6)

NameTypeDefaultDescription
positiveCONDITIONINGPositive text conditioning
nag_scaleFLOAT11.00–100NAG guidance strength. Higher = stronger attention steering
nag_tauFLOAT2.50–10Norm-clamp threshold. Controls how aggressively outlier attention is suppressed
nag_alphaFLOAT0.250–1Blend factor between original and NAG-steered attention
negativeoptCONDITIONINGNegative text conditioning (used for both CFG and NAG guidance)
inplaceoptBOOLEANtrueReuse tensors in-place to save VRAM

Outputs (2)

NameTypeDescription
positiveCONDITIONING
negativeCONDITIONING