Tag Generator
Let Danbooru's real co-occurrence statistics finish your prompt
- processed_text
- generated_tags
You prompt in Danbooru tags - 1girl, night, city, rain - because that's the language Illustrious, NoobAI and Pony actually speak. TagGenerator extends a prompt like night, city, rain with the tags that show up alongside those tags across 9.23 million Danbooru posts: cityscape, building, night sky, scenery, road. It's prompt autocomplete built from the board's own statistics, running fully offline and reproducible from a seed.
How it works
It's an LM-style sampler, one tag per step. Each step's distribution is a naive Bayes over Danbooru solo-post co-occurrence: log P(tag) plus the sum of log lift against every tag already in the context. Each pick joins the context and re-conditions the next step. Tags whose co-occurrence lift sits far below 1 - the pair avoids each other on the board - get vetoed, so the output can't contradict itself. temperature 0.0 is a deterministic argmax; above that you get the usual top_k / top_p / min_p filters applied in that order, and seed makes the whole draw reproducible.
The statistics come from a co-occurrence table the author rebuilt from a 2026 snapshot: 20,811 tags over 9.23M posts. It ships as a 72MB numpy file (suggest_v1.0.npz) that downloads from the pack's GitHub release on first use and is verified by sha256. If it can't download, the node logs suggest artifact not found and passes your text through unchanged - nothing breaks, you just get nothing extra.
The inputs that matter
- rating - check this first. The default is
explicit, and the node is honest about what that means: the co-occurrence tables are built per cumulative rating tier (general < sensitive < questionable < explicit), and any tag whose own rating exceeds your request is masked. Want mild content? Setgeneralorsensitive- this isn't a filter bolted on after the fact, it changes which statistics the sampler is even allowed to see.randomrolls one of the four from the seed. - categories - restrict which axes can contribute, optionally with counts:
"pose:2, clothes:3"admits only pose and clothes tags and caps each. Withnat 0, those caps become the target length - the way to get a balanced prompt instead of whatever the stats happen to favour. - n - how many tags. 0 means auto length, drawn from the corpus length distribution, and generation stops early when no candidate is at least twice as likely as chance given the context. The data has nothing left to say.
- blacklist - a regex matched against each candidate tag (
"hair|eyes"drops every hair and eye tag). It filters candidates rather than results, so you still getntags back. An unparseable pattern is logged and ignored. - text, seed, temperature, top_k, top_p, min_p, min_count -
min_countdrops rare tags; at its default of 100 it's effectively no filtering, because rare tags are already held back three other ways. Raise it if a prompt keeps surfacing tags too obscure for your model to have learned.
Outputs and where it sits
processed_text is your prompt with the generated tags appended - wire it into a CLIP Text Encode. generated_tags is just the new tags, handy for inspecting what the sampler added. It's the offline, seedable sibling of the pack's Danbooru Related Tags Retriever, which queries the live API for the same job. Good uses: bulking out a sparse prompt, or discovering the actual board vocabulary for a scene instead of guessing what people tag a beach with. If you're on a natural-language model (Flux, Z-Image), skip it - tag autocomplete only helps models trained on tags.
Install
ComfyUI Manager: search for ComfyUI-Alchemine-Pack, install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/alchemine/comfyui-alchemine-pack
pip install -r requirements.txt
then restart. The pack's only Python dependency is python-dotenv; no model, no API key. Budget for the first-run 72MB download.
Troubleshooting
Empty generated_tags with processed_text equal to your input on the first run almost always means the 72MB artifact is still downloading or failed - watch the console for the [TagSuggest] downloading ... line and let it finish once. Beyond that there's little to break; the node needs no model and nothing at load time.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| n | INT | 100–100 | — |
| rating | COMBO | explicit | 5 options: general, sensitive, questionable, explicit, random |
| temperature | FLOAT | 1.000–5 | — |
| top_k | INT | 500–500 | — |
| top_p | FLOAT | 0.950–1 | — |
| min_p | FLOAT | 0.000–1 | — |
| seed | INT | 00–18446744073709550000 | — |
| min_count | INT | 100100–1000000 | — |
| categoriesopt | STRING | — | |
| blacklistopt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| processed_text | STRING | — |
| generated_tags | STRING | — |