Nodes/ymc-node-suite-comfyui/prompt - unweight
ComfyUI Node

prompt - unweight

Strip the weights off your prompt

By YMC-GitHub·Created 3 years ago·Updated about a year ago· 20
prompt - unweight
    • STRING
    text

    (masterpiece:1.2), (1girl:1.1), white hair - that's a perfectly good A1111-era prompt, and a liability in half the places you'd paste it. prompt - unweight strips the parentheses and the :weight suffixes so you're left with plain tags: masterpiece, 1girl, white hair.

    There are two solid reasons to want that. First, the KB's own survey of prompt-engineering notes that newer LLM-encoded models discard attention weights entirely - (word:1.3) is silently ignored. Second, weight-free text is the canonical form every other ymc text node (search, dedupe, std) wants to work against, because matching on weighted tags is flaky. Strip the weights once, upstream, and all the downstream string math gets reliable.

    How it works

    The transformation is literal: remove every ( and ) character, then cut off any :digits... suffix from the tag. So (white hair:1.2) becomes white hair, and (masterpiece:1.1) becomes masterpiece. Then the usual cleanup runs - trim, collapse interior spaces, drop empties - and the tags rejoin on commas.

    Note the two-step nature: the parentheses are removed unconditionally, and the :weight suffix is removed after. A tag like foo:bar that isn't a weight... well, :bar starts with a colon followed by non-digits, and the regex targets :\d.*, so only numeric weights get cut. Tags that were already plain pass through untouched. That makes this node safe to run on prompt text that's already clean - it's a no-op for unweighted tags.

    Inputs and outputs

    • text - the prompt to unweight
    • STRING output - the weight-free, comma-separated prompt

    Installing it

    Part of ymc-node-suite-comfyui:

    • ComfyUI Manager → search ymc-node-suite-comfyui → Install → restart, or
    cd ComfyUI/custom_nodes
    git clone https://github.com/YMC-GitHub/ymc-node-suite-comfyui
    

    restart, and pip install -r requirements.txt on a manual clone (four yors_* helper libs; the pack's auto-install is commented out). No models, no GPU.

    Search prompt / unweight on the canvas or use the right-click ymc suite menu.

    Common issues

    • "I need my weights!" Then don't use this node in that path. It's a transformation, not a toggle - if you want both weighted and unweighted forms, run two branches and pick per model. On models that do respect weights (SDXL-lineage at CFG above 1), stripping them is a real change, not a cleanup.
    • It doesn't strip BREAK or other syntax. Only parens and numeric weights are touched. And it won't fix mismatched parens - it removes them all, which is exactly what you want anyway.
    • Empty tags are dropped. ( ) or a bare : vanishes, so the output is always a clean list.
    • WAS Node Suite conflicts on the pack's io/save nodes can appear as warnings if you run both packs - unrelated to this node.

    Use it with prompt - std (whitespace) and prompt - dup (duplicates) and you have a complete "sanitize any pasted prompt" pipeline: unweight → std → dup, in that order, one wire into your encoder.

    Categoryymc suite/text

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING