Nodes/SP-Nodes/SP_KoboldCpp_BannedTokens
ComfyUI Node

SP_KoboldCpp_BannedTokens

Stop your local LLM from saying specific words

By bananasss00·Created 2 years ago·Updated 6 days ago· 20
SP_KoboldCpp_BannedTokens
    • BANNED_TOKENS
    delimiter\n
    tokensbanned_token banned phrase banned phrase\n with newline

    A small, single-purpose node: give it a list of words or phrases, and it produces a config you can wire into SP_KoboldCppWithContext (or the plain SP_KoboldCpp node) to make sure the LLM never outputs them. Useful for the usual reasons a local-LLM ban list exists - a model that keeps repeating a specific tic, a word you don't want showing up in generated prompts, or a phrase that keeps derailing the output in a direction you don't want.

    How it works

    tokens is a multiline text box, one banned entry per line - the default placeholder shows the pattern: banned_token, banned phrase, and even a phrase containing an escaped newline (banned phrase\n with newline), which tells you the field supports more than single words. delimiter (default \n) is what actually splits the list into individual entries, so if your banned phrases need to contain literal newlines themselves, that's the setting to look at rather than the tokens field.

    The node doesn't call KoboldCpp itself - it just packages your ban list into the BANNED_TOKENS type this pack's Kobold nodes expect, and does nothing on its own until wired in.

    Inputs and outputs that matter

    • tokens (multiline string) - one banned word or phrase per line, split on delimiter.
    • delimiter (default \n) - what separates entries in tokens.
    • Output: BANNED_TOKENS - feeds SP_KoboldCppWithContext's (or SP_KoboldCpp's) optional banned_tokens input.

    How to install it

    Comes bundled with the rest of SP-Nodes. Through ComfyUI Manager: search "SP-Nodes," install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bananasss00/ComfyUI-SP-Nodes
    

    Restart ComfyUI once cloned. This node itself needs nothing extra, but it's only useful alongside a running KoboldCpp server - the actual LLM inference engine these nodes talk to, which you install and run separately from ComfyUI entirely.

    Common issues & troubleshooting

    Banned words still show up in output. Bans on local LLMs generally work at the token level, not the word level - a phrase that tokenizes differently depending on capitalization, spacing, or surrounding punctuation can slip through even with the base word banned. Try adding a few obvious variants (different casing, with and without a leading space) rather than assuming one entry covers every occurrence.

    The list doesn't seem to be applied at all. Double-check BANNED_TOKENS is actually wired into the Kobold node's optional banned_tokens input - it's easy to build this config and forget the connection, since nothing errors if it's left unplugged.

    Legitimate output gets cut short or garbled near a banned phrase. That's the model working around the ban mid-generation rather than a bug in this node - if it's happening a lot, the ban list is probably too aggressive for how common that phrase is in normal output; trim it down to what you actually need blocked.

    CategorySP-Nodes

    Inputs (2)

    NameTypeDefaultDescription
    delimiterSTRING\n
    tokensSTRINGbanned_token banned phrase banned phrase\n with newline

    Outputs (1)

    NameTypeDescription
    BANNED_TOKENSBANNED_TOKENS