Nodes/ComfyUI-DataSet/DataSet_ConceptManager
ComfyUI Node

DataSet_ConceptManager

Add Your Trigger Token to Every Caption, at the Position You Want

By daxcay·Created 2 years ago·Updated about a year ago· 58
DataSet_ConceptManager
    • TextFileContents
    • Words List 1
    • Words List 2
    ◄TextFileContents—►
    ◄Mode▾►
    â—„Conceptsconceptâ–º

    If you've ever trained a LoRA, you know the ritual: your images are captioned, but every single caption needs your rare trigger token slapped on the front. Doing that by hand across a few hundred files is misery. DataSet_ConceptManager is the batch version of that chore - it adds or removes tokens in every caption file at once, and it lets you choose where in the caption each token lands.

    This is the node from the pack that most directly implements good training practice. The KB's training lore is consistent here: trigger words should be rare alphanumeric tokens (ch9ractername, styl3name) that don't collide with real vocabulary, and captioning rules say describe what should stay changeable, leave what should be permanent undescribed. ConceptManager is the tool for injecting or stripping those tokens across a whole folder in one queue run.

    How the Concepts input works

    This is the fiddly part, so read it twice. Concepts takes comma-separated text + position pairs:

    ohwx 0, portrait, 2
    
    • For add mode, the number is the position to insert at: 0 puts the token at the very front (the classic trigger-word spot), 2 inserts it after the second comma-separated tag. Use # instead of a number for a random position.
    • For remove mode, the position is mostly ignored - it removes the token from the caption, and # means remove every instance.

    Multi-word tokens are fine because the position is always the last whitespace-separated part of each entry.

    Inputs and outputs

    • TextFileContents - the caption list, wired in from a loader (it's forceInput, so a widget won't take).
    • Mode - add or remove.
    • Concepts - the tokens and positions described above.

    Outputs: TextFileContents (the edited list, ready to feed DataSet_TextFilesSave), plus two convenience strings - Words List 1 and Words List 2 - which are your concepts joined by newlines and commas respectively. They're mostly for previewing or logging; the real output is the edited caption list.

    The workflow that makes sense

    The canonical run looks like this: DataSet_TextFilesLoad pulls every caption in your training folder, DataSet_ConceptManager prepends your trigger token to each one (Mode: add, Concepts: ohwx 0), and DataSet_TextFilesSave writes them back. Run it once and every caption in the folder carries the token - which is precisely the setup the training guidance wants before you fire up ai-toolkit or Kohya.

    Installing and caveats

    It's part of the ComfyUI-DataSet pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-DataSet.git
    cd ComfyUI-DataSet && pip install -r requirements.txt
    

    Restart after. No extra models, no downloads - this node is pure string manipulation and works offline.

    Two things to watch. First, the position is a comma-separated index, not a word index - if your captions aren't comma-separated tags, the arithmetic gets confusing fast. Second, test on one file before running the whole folder; add mode with a bad position can silently misplace tokens, and the node returns an edited list rather than telling you it went wrong. That dry-run habit will save you from a folder of mangled captions.

    Category🔶DATASET🔶

    Inputs (3)

    NameTypeDefaultDescription
    TextFileContentsSTRING—
    ModeCOMBO2 options: add, remove
    ConceptsSTRINGconcept—

    Outputs (3)

    NameTypeDescription
    TextFileContentsSTRING—
    Words List 1STRING—
    Words List 2STRING—