Nodes/ComfyUI-PromptUtilities/Sample Tags With Weight
ComfyUI Node

Sample Tags With Weight

Random tags, each with its own random emphasis

By nkchocoai·Created 3 years ago·Updated about a year ago· 26
Sample Tags With Weight
    • STRING
    tags
    tags_delimiter
    seed0
    max_k1
    min_k1
    max_w1.00
    min_w0.80
    step_w0.10

    Take Sample Tags - random k-of-n picks from a tag pool, no duplicates - and add one more layer: every tag that gets picked also gets wrapped in (tag:weight) syntax, with the weight itself randomized within a range you set. Instead of every batch run emphasizing the same tags identically, each pull gets its own slightly different push.

    How it works

    The sampling side works exactly like Sample Tags: tags split by tags_delimiter (newline or comma), min_kmax_k tags drawn without repeats, seed controlling the draw. On top of that, each sampled tag is assigned a random weight between min_w and max_w, snapped to increments of step_w, then wrapped as (tag:weight) in the output string. Defaults are conservative on purpose - min_w at 0.8, max_w at 1, step_w at 0.1 - so out of the box you're getting mild variation around neutral, not wild swings.

    Inputs and outputs that matter

    • tags / tags_delimiter / seed / min_k / max_k - same as Sample Tags: the pool, how it's split, the draw seed, and how many get pulled.
    • min_w / max_w - the weight range applied to each sampled tag. Defaults 0.8 / 1.
    • step_w - the increment weights are snapped to, default 0.1.

    Output is a single STRING - the sampled tags, each individually weighted, joined together.

    Installing it

    ComfyUI Manager → search ComfyUI-PromptUtilities → install → restart. Or:

    cd ComfyUI/custom_nodes && git clone https://github.com/nkchocoai/ComfyUI-PromptUtilities
    

    Pure Python, no models or heavy dependencies - same low-friction install as the rest of this pack. Look for it under the PromptUtilities category.

    Where it fits

    This is the batch-variety node when you specifically want each generation to lean into its randomly-chosen tags by a slightly different amount, rather than uniformly. Think dataset-style generation where you want organic-looking spread across a set - a batch of character portraits where "detailed eyes" isn't emphasized identically in every single image. Pair it with Round Prompt Weight downstream if the resulting long decimal weights bother you in logs or saved presets.

    Where people get burned

    The one that matters most: attention weighting is a CLIP-model thing. (tag:weight) syntax does nothing on Flux.2, Z-Image, Qwen-Image, or any other LLM-encoded model - the parentheses and colon just get read as literal characters by those encoders, which is actively worse than plain text. This node is built for SD1.5 and SDXL-family workflows; on anything newer, use plain Sample Tags instead and skip the weighting entirely.

    Second: don't be tempted to crank max_w way past its default range expecting proportionally stronger results. Attention weights compound fast - by the time you're pushing past roughly 1.3–1.4 you're usually well into fried, over-saturated territory rather than "more of the thing," and the wide -100 to 100 range on the sliders is generous headroom, not a recommendation to use it.

    CategoryPromptUtilities

    Inputs (8)

    NameTypeDefaultDescription
    tagsSTRING
    tags_delimiterCOMBO2 options: new line, ,
    seedINT00–18446744073709550000
    max_kINT11–18446744073709550000
    min_kINT10–18446744073709550000
    max_wFLOAT1.00-100–100
    min_wFLOAT0.80-100–100
    step_wFLOAT0.10-100–100

    Outputs (1)

    NameTypeDescription
    STRINGSTRING