Nodes/ComfyUI_EmbeddingToolkit/Save Weighted Embeddings
ComfyUI Node

Save Weighted Embeddings

1.3) weighting on Flux, Qwen and Mistral

By silveroxides·Created about a year ago·Updated 4 months ago· 11
Save Weighted Embeddings
  • clip
    text
    slice_bos_eosfalse
    filename_prefixweighted_embed

    Here's the problem this node exists to solve: on a 2026 text encoder - Flux's T5, Qwen3, Mistral - (word:1.3) attention weights are silently discarded. The tokenizer wrappers pass disable_weights=True, so your carefully-weighted prompt is read as flat text and the emphasis does nothing. That's not a bug in your workflow; it's a deliberate design choice in the encoder stack, and no amount of (((triple parentheses))) fixes it.

    Save Weighted Embeddings routes around that wall. It freezes a weighted prompt into an embedding file the same way its sibling Save Token Embeddings freezes an unweighted one - but it manually parses the weights and applies them before saving. You type a cinematic (sunset:1.4), (mist:0.6), run it through this node once, and get a small .safetensors in your embeddings folder. From then on, embedding:weighted_embed_00001 in a prompt reproduces that weighted conditioning - even on a model whose tokenizer would normally throw the weights away. It's the one node in this pack I'd genuinely call a workaround for a real ecosystem gap.

    How it works

    The clever part is the tokenizer. ComfyUI's standard path respects disable_weights=True and gives up; this pack implements its own tokenization loop (tokenize_preserving_weights) that parses weights segment-by-segment, handling embeddings inside the text, sub-encoder quirks like Mistral's left padding, and the different special-token setups across clip_l, t5xxl, qwen3_*, mistral3_*, gemma* and so on.

    Weights are then applied the ComfyUI way, which is different from the A1111 way (see the sibling node for that). Instead of scaling the vector directly, the node interpolates between the token's embedding and the segment's empty/pad embedding:

    (final) = (embedding − empty) × weight + empty
    

    So a weight of 1.0 leaves the token untouched, 1.4 pushes it further from the neutral baseline, and 0.6 pulls it closer to neutral. That's gentler than raw multiplication and is how ComfyUI itself thinks about emphasis - baked into a file you can reuse anywhere.

    Inputs and output

    Same shape as the pack's other save nodes, and only two you'll set:

    • clip - your loaded CLIP. The node discovers which sub-encoders are present and produces one tensor per part.
    • text - the weighted prompt to freeze. Multiline.
    • slice_bos_eos (default off) - on, strips BOS/EOS from clip_l/clip_g and EOS from T5 parts. Leave off for a file that behaves closest to the original prompt.
    • filename_prefix (default weighted_embed) - output is weighted_embed_00001.safetensors, auto-incremented, saved to ComfyUI/models/embeddings/.

    No output ports - it writes the file and reports the path. Reference it as embedding:weighted_embed_00001 in any text encoder.

    Installing

    Part of silveroxides/ComfyUI_EmbeddingToolkit, from the same author as the well-liked Chroma-GGUF quants. No dependencies, no model downloads - just ComfyUI's own torch and comfy modules. Install via Manager (search "ComfyUI_EmbeddingToolkit") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/silveroxides/ComfyUI_EmbeddingToolkit
    

    Restart and you're in.

    Gotchas

    The usual embedding rules apply with interest: the saved file is locked to the encoder it was made on, and ComfyUI silently ignores embeddings it can't apply. A weighted file made on SDXL CLIP won't bind to Qwen3, and one made on Flux's T5 is a Flux-file. The weight interpolation also depends on the model's empty-token path, so if the pack can't find a pad token for a given sub-encoder it will skip weighting that part with a console warning - check the log if a file comes out with a part missing. And per the pack's README: making embeddings to flip on CivitAI with Early Access is explicitly called deceptive - free uploads only.

    CategoryEmbeddingToolkit

    Inputs (4)

    NameTypeDefaultDescription
    clipCLIP
    textSTRING
    slice_bos_eosBOOLEANfalse
    filename_prefixSTRINGweighted_embed

    Outputs (0)

    No outputs