Nodes/ComfyUI-DanbooruSearcher/Danbooru Related Tags
ComfyUI Node

Danbooru Related Tags

The RAG expander that keeps your LLM honest

By SuzumiyaAkizuki·Created 7 months ago·Updated 3 months ago· 70
Danbooru Related Tags
  • search_result
  • related_tags
  • combined_tags
  • debug_info
limit50
show_nsfwtrue

The one reason this node exists

The sister node in this pack, Danbooru Smart Search, finds the tags you meant. This one finds the tags you didn't know existed - and it's built for a single, very specific job: feeding an LLM without letting it lie to you.

Here's the problem it solves. Anime models (Illustrious, NoobAI, Pony) were trained on Danbooru's exact vocabulary, so a correct tag controls an image far better than a sentence ever will. But LLMs are terrible at knowing which tags actually exist. Ask one to translate "sailor suit" and it happily emits sailor suit - which isn't the tag - instead of the real serafuku. The pack's whole design is retrieval-augmented generation: use search to build a candidate pool of real tags, then let the LLM pick from that pool instead of generating names from nothing. Danbooru Related Tags is the expansion half of that pool.

How it works

You feed it the search_result output from Danbooru Smart Search - a structured DANBOORU_RESULT object, not a tag string. The node doesn't take all of those results as seeds; it picks the single highest-scoring tag per source segment. So a description like "a girl running in the rain" seeds one tag for the girl concept, one for running, one for rain - the most confident hit per idea, on purpose, because mediocre seeds drag down co-occurrence quality.

Those seeds get looked up in a co-occurrence table (cooccurrence_clean.parquet, shipped inside the pack) that records how often tag pairs appear on the same image. Neighbors are scored with normalized PMI - a measure of "these tags appear together more than random chance would predict" - and the node excludes anything already in your search results so it's pure expansion. The debug_info output shows you the whole ranking with npmi scores, co-occurrence counts, and post counts, which is a genuinely nice window into why a recommendation landed.

The inputs and outputs that matter

Inputs are refreshingly few:

  • search_result - required, must come live from the Smart Search node. You can't paste a tag string in here.
  • limit - max co-occurrence recommendations, default 50 (range 10–200). Keep it modest; this output is meant to be a candidate pool, not a dump.
  • show_nsfw - whether NSFW tags are allowed through, default on.

Outputs:

  • related_tags - just the co-occurrence recommendations, comma-separated. Alone it's a weird prompt (you'd be prompting with orphan tags whose seeds aren't there).
  • combined_tags - search results plus related tags, deduplicated. This is the one you want. It's the designed handoff to an LLM.
  • debug_info - the seed list and NPMI table, for when a recommendation makes no sense.

The intended pipeline, straight from the README: Danbooru Smart Search → search_result → Danbooru Related Tags → combined_tags → LLM. The author pairs it with their own ComfyUI-NewBie-LLM-Formatter node.

Install and gotchas

Same install as the rest of the pack: git clone https://github.com/SuzumiyaAkizuki/ComfyUI-DanbooruSearcher into ComfyUI/custom_nodes, pip install -r requirements.txt, restart - or just search ComfyUI-DanbooruSearcher in ComfyUI Manager. This node doesn't add its own model dependency; it reuses the same engine singleton as Smart Search, so the BGE-M3 model download and first-run cache build (1–3 minutes, ~50k tags) all happen upstream on the search node.

Two things trip people up. First, this node is downstream-only: with no LLM in your workflow it's mostly optional - the search node's tags_string works fine alone. Second, because it inherits the pack's tag set, recommendations only cover tags with Danbooru frequency ≥ 100 in the General, Character, and Copyright categories. No artist tags, no rare niche tags, and that's by design - those are exactly the ones the LLM shouldn't be inventing anyway.

Categoryutils/prompt

Inputs (3)

NameTypeDefaultDescription
search_resultDANBOORU_RESULT
limitINT5010–200Maximum number of co-occurrence recommendations
show_nsfwBOOLEANtrue

Outputs (3)

NameTypeDescription
related_tagsSTRING
combined_tagsSTRING
debug_infoSTRING