A FLAN-T5 Base model fine-tuned to predict Danbooru tag implications. Given a tag, the model outputs all tags that it implies according to Danbooru's tag implication system.
Model Description
This model learns the structured relationships between Danbooru tags, specifically the "implication" relationships where one tag automatically implies another. For example:
bikini implies swimsuit
cat_ears implies animal_ears
striped_panties implies both panties and striped_clothes
Base Model:google/flan-t5-base (248M parameters)
Training Data: 32,331 tag implication pairs from Danbooru
1defexpand_tags(tags_string):2"""Expand all tags in a comma-separated string"""3 tags =[t.strip()for t in tags_string.split(',')]4 expanded =set(tags)56for tag in tags:7 implications = get_implications(tag)8if implications:9 expanded.update([t.strip()for t in implications.split(',')])1011return', '.join(sorted(expanded))1213# Example14input_tags ="1girl, bikini, cat_ears"15expanded_tags = expand_tags(input_tags)16print(expanded_tags)17# Output: 1girl, animal_ears, bikini, cat_ears, swimsuit
Important: Guard Against Unknown Tags
The model was trained on specific Danbooru tags. For production use, you should only query tags that exist in the training data to avoid hallucinations:
python
1import json
23# Load the training dataset to get valid tags4tags_with_implications =set()5withopen('tag_implications_dataset.jsonl','r')as f:6for line in f:7 data = json.loads(line)8 tag = data['input'].replace('implications: ','')9 tags_with_implications.add(tag)1011defget_implications_safe(tag):12if tag notin tags_with_implications:13return""# Tag has no known implications14return get_implications(tag)
Examples
Clothing Tags
Input
Output
bikini
swimsuit
school_swimsuit
swimsuit
sleeveless_dress
dress, sleeveless
striped_panties
panties, striped_clothes
Animal Features
Input
Output
cat_ears
animal_ears
dog_ears
animal_ears
fox_tail
tail
Complex Implications
Input
Output
striped_bikini
bikini, striped_clothes, swimsuit
black_dress
dress
Limitations
Only works with Danbooru tags - The model is trained on specific Danbooru tag names (underscore-separated)
No natural language - Input must be exact tag names, not descriptions
May hallucinate on unknown tags - Always use the guard mechanism for production
Generic tags only - Series-specific tags (with parentheses) were filtered from generic tag implications
English-centric - Primarily English tag names
Training Data Filtering
To prevent generic tags from suggesting series-specific tags, we applied this rule:
If an input tag has no parentheses output tags with parentheses are filtered out