DataSet_TriggerWords
Hunt Down the Trigger Words Hiding in Your Captions
- Words
Here's a weird thing about training datasets: trigger words are designed to look like gibberish. A good trigger is a rare alphanumeric token that doesn't collide with real words - ch9ractername, styl3name, ohwx - so it stands out in a caption like a sore thumb. DataSet_TriggerWords exploits exactly that: it scans your captions and extracts every token that contains both letters and numbers, on the theory that those are your trigger words.
That heuristic is the whole node. It doesn't know anything about your actual trigger - it just finds every word with a digit mixed in. If you've been consistent about your trigger naming, it works beautifully. If your captions contain "a 2nd photo" or a year, you'll get false positives and need to eyeball the results.
Inputs and output
- TextFileContents - the caption list, wired in from a loader (
forceInput). - search - two modes:
trigger_word_only- returns just the matching words themselves.trigger_word_phrase- returns the entire comma-delimited phrase that contains a trigger word. Useful when the trigger is part of a multi-word concept and you want the full tag.
Output is Words, a list of the extracted triggers (or phrases).
How it works
It splits each caption on commas, splits each comma-part into words, and keeps any word that has at least one digit. In trigger_word_only mode you get the bare word; in trigger_word_phrase mode you get the whole comma-separated tag that contained it, which is usually what you actually care about when your trigger is my styl3 - a two-word tag.
The digit-mix heuristic is tuned for the alphanumeric-trigger convention the community settled on, and that convention has survived every architecture change in training. It's genuinely useful for an audit pass: load your captions, run this, and see whether the trigger actually made it into every file or got dropped from a few.
Installing
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 ComfyUI. Pure text processing, no models, no dependencies.
Common issues
The false-positive thing is real: captions that mention "50mm", "4k", "v2", or any year will surface those as "triggers." It's a heuristic, not magic. And there's a subtlety in phrase mode - a phrase is "contained within two commas," so if your trigger sits at the very start or end of a caption with no comma on one side, the boundary detection can clip it. Both issues are easy to live with if you treat the output as a list to skim rather than gospel. For a quick consistency check on trigger coverage before a training run, it's a handy ten-second audit.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| TextFileContents | STRING | — | |
| search | COMBO | 2 options: trigger_word_only, trigger_word_phrase |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Words | STRING | — |