WanVideoNAG
This node is implemented based on ChenDarYen's Normalized-Attention-Guidance project and works by modifying the cross-attention layers during the model's diffusion process.
Wan Video NAG
The WanVideoNAG node is implemented based on ChenDarYen's Normalized-Attention-Guidance project. It works by modifying the cross-attention layers during the model's diffusion process.
WanVideoNAG is an experimental node designed to apply "Normalized Attention Guidance" (NAG) to video generation models. Its core function is to enhance or control the alignment between the generated video content and given conditions (such as text prompts) by adjusting the model's internal attention mechanism. This can potentially improve video coherence or thematic consistency.
Node Functionality
This node is implemented based on ChenDarYen's Normalized-Attention-Guidance project. It works by modifying the cross-attention layers during the model's diffusion process. It takes a base model and conditioning input, and finely controls the guidance strength, mixing ratio, and clipping threshold for attention bias using the three parameters nag_scale, nag_alpha, and nag_tau. It also offers optional settings for input type and in-place model modification. Ultimately, it outputs a modified new model that incorporates the NAG mechanism.
Node Parameter Description - WanVideoNAG
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
model | MODEL | Yes | - | - | Outputs a new model with the normalized attention guidance mechanism applied. |
conditioning | CONDITIONING | Yes | - | - | Input the text conditioning embeddings used to guide the generation process. Typically comes from a CLIP Text Encode node. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
nag_scale | FLOAT | Yes | 11.0 | 0.0 - 100.0 (Step: 0.001) | Strength of negative guidance effect |
nag_alpha | FLOAT | Yes | 0.25 | 0.0 - 1.0 (Step: 0.001) | Mixing coefficient that controls the balance between the normalized guided representation and the original positive representation. |
nag_tau | FLOAT | Yes | 2.5 | 0.0 - 10.0 (Step: 0.001) | Clipping threshold that controls how much the guided attention can deviate from the positive attention. |
input_type | COMBO | No | default | "default", "batch" | Determines how the conditioning is applied. "default" processes conditioning as a single input; "batch" expects batched conditioning. |
inplace | BOOLEAN | No | False | True/False | If enabled, modifies the model in-place instead of returning a copy. Use with caution to avoid unintended side effects. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| model | MODEL | Outputs a new model with the normalized attention guidance mechanism applied. |
Usage Scenarios
In a video generation workflow, you can place this node after loading the base model and before the sampler. For example, first load a video model using Checkpoint Loader, then generate conditioning using the CLIP Text Encode node. Next, input the model and conditioning into the WanVideoNAG node for adjustment. Finally, connect the output model to a sampler node for video generation.
Notes
This node is located under the KJNodes/wan category and is based on research code from the Normalized-Attention-Guidance project. While its functionality can be powerful, it may still behave unpredictably in certain workflows. It is recommended to test with a range of parameters and understand the underlying mechanism before relying on it for production use.
WanVideoNAG Node Source Code Link
The WanVideoNAG node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.