Text Generation
Safetensors
GGUF
English
Chinese
qwen3_5_text
anime
text-to-image
prompt-expansion
danbooru
qwen3_5
non-commercial
conversational
Instructions to use hvgfgh/PromptGacha with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use hvgfgh/PromptGacha with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf hvgfgh/PromptGacha:Q5_K_M # Run inference directly in the terminal: llama cli -hf hvgfgh/PromptGacha:Q5_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf hvgfgh/PromptGacha:Q5_K_M # Run inference directly in the terminal: llama cli -hf hvgfgh/PromptGacha:Q5_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf hvgfgh/PromptGacha:Q5_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf hvgfgh/PromptGacha:Q5_K_M
Use Docker
docker model run hf.co/hvgfgh/PromptGacha:Q5_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use hvgfgh/PromptGacha with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hvgfgh/PromptGacha" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hvgfgh/PromptGacha", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/hvgfgh/PromptGacha:Q5_K_M
- Ollama
How to use hvgfgh/PromptGacha with Ollama:
ollama run hf.co/hvgfgh/PromptGacha:Q5_K_M
- Unsloth Desktop
- Docker Model Runner
How to use hvgfgh/PromptGacha with Docker Model Runner:
docker model run hf.co/hvgfgh/PromptGacha:Q5_K_M
- Lemonade
How to use hvgfgh/PromptGacha with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull hvgfgh/PromptGacha:Q5_K_M
Run and chat with the model
lemonade run user.PromptGacha-Q5_K_M
List all available models
lemonade list
- Atomic Chat
Add English model card (v0.1)
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190---language:- en- zhlicense: apache-2.0base_model: Qwen/Qwen3.5-4B-Basepipeline_tag: text-generationtags:- anime- text-to-image- prompt-expansion- danbooru- qwen3_5---
# PromptGacha
**English** | [中文](README_zh.md)
> A general-purpose anime image-generation prompt **translation & expansion** model fine-tuned from [Qwen3.5-4B-Base](https://huggingface.co/Qwen/Qwen3.5-4B-Base) (text-only, vision tower stripped). Supports flexible multi-format inputs and strict prose / structured JSON dual-mode outputs.
## Overview
Rather than a rigid 1-to-1 tag-to-sentence translator, this model is designed as a **Prompt Gacha LLM** with intentional **bidirectional input–output asymmetry**:
- **Sparse input → Creative expansion (Gacha mode)**: The shorter your input (even just `1girl` or a single action like `hug`), the more freely the model invents vivid composition, lighting, outfits, and scenery. Unlike general-purpose cloud LLMs that tend to collapse into repetitive templates, this model is trained to preserve high diversity across draws.- **Detailed input → Faithful translation + automatic out-of-frame clipping**: You can paste a full head-to-toe character sheet directly into the input. Whenever framing or occlusion hides certain traits (e.g., shoes/socks in an `upper body` shot, facial features in `from behind`, or eye color under `closed eyes`), the model automatically omits those invisible details so downstream image generators don't zoom out awkwardly or break anatomy.
## Model Card
| Field | Details || --- | --- || **Base Model** | [Qwen/Qwen3.5-4B-Base](https://huggingface.co/Qwen/Qwen3.5-4B-Base) (vision tower stripped into pure-text `Qwen3_5ForCausalLM`) || **Parameters** | 4.21B (pure-text BF16; exports cleanly to GGUF without `mmproj`) || **Training Method** | Full-parameter BF16 SFT (`v0.1` selected at 1.0 epoch checkpoint, `eval_loss = 1.640`) || **Dataset Scale** | 9,533 train + 212 eval samples (Mode A 78.7% / Mode B-1 9.4% / Mode B-2 12.0%; covers `g/s/q/e` ratings) || **Supported Inputs** | Flat Danbooru tags / Multi-line text blocks / Lightweight YAML / Structured JSON / Natural-language + tags hybrid || **Output Modes** | Mode A (default, pure English prose) / Mode B-1 (single-prompt JSON) / Mode B-2 (per-subject split JSON) || **Target Generators** | [Anima](https://huggingface.co/circlestone-labs/Anima), [NovelAI (NAI)](https://novelai.net/), Moss, FLUX, Qwen-Image, and other natural-language or regional-prompting anime models |
## Input & Output Specification
The model follows a **wide-in, strict-out** contract: inputs accept multiple casual or structured formats with optional controls, while outputs strictly conform to clean English prose or valid JSON.
### Optional Control Fields (All Optional)
| Field | Values / Examples | Default | Description || --- | --- | --- | --- || `rating` | `general` / `sensitive` / `questionable` / `explicit` | Inferred from input | Content rating control || `length` | `concise` / `standard` / `detailed` / `elaborate` | Free | Target output length tier (calibrated with Qwen3.5 tokenizer: `≤180` / `181–320` / `321–550` / `>550` tokens) || `aspect_ratio` | `2:3`, `3:4`, `1:1`, `3:2`, `16:9`, etc. | Free | Strictly honored when provided; auto-recommended in JSON modes when omitted || `style` | `"off"` / `"on"` / custom style phrase (e.g., `"soft watercolor"`) | `"off"` (style-neutral) | **Off by default** to avoid injecting conflicting medium/technique keywords over your artist tags or LoRAs || `output_format` | `"json"` | Omitted (Mode A) | Outputs pure English prose by default; set `"json"` to switch to Mode B || `split_characters` | `true` / `false` | `false` | Active only with `output_format: "json"`: `false` returns `{"aspect_ratio", "prompt"}`; `true` splits independent foreground subjects (characters, animals, mecha, key props) |
### Supported Input Formats
1. **Flat Danbooru Tags** (supports both underscores and spaces, including ultra-sparse gacha inputs): ```text 1girl, 1boy, hetero, hakurei reimu, black hair, red hair ribbon, school uniform, kissing cheek, classroom, sunset lighting ``` Optional key-value control headers can be prepended: ```text rating: sensitive length: standard aspect_ratio: 2:3 1girl, silver hair, rooftop, sunset ```
2. **Multi-line Text Blocks (Per-Character Anchoring)**: ```text 1girl, 1boy, hetero, girl, hakurei_reimu, black_hair, red_hair_ribbon, school_uniform, leaning_down, kissing_other's_cheek, boy, short_brown_hair, school_uniform, blushing, surprised_expression, classroom, sunset_lighting, upper_body ```
3. **Lightweight YAML**: ```yaml rating: sensitive aspect_ratio: 2:3 scene: classroom, sunset lighting, upper body characters: - hakurei_reimu [female] | black hair, red hair ribbon, school uniform, leaning down, kissing other's cheek - [male] | short brown hair, school uniform, blushing, surprised expression ```
4. **Structured JSON**: ```json { "rating": "sensitive", "length": "standard", "aspect_ratio": "2:3", "style": "soft watercolor, delicate linework", "output_format": "json", "split_characters": true, "scene": ["classroom", "sunset lighting", "warm glow", "upper body", "window"], "characters": [ { "name": "hakurei_reimu", "gender": "female", "tags": ["black hair", "red hair ribbon", "school uniform", "white thighhighs", "black loafers", "leaning down", "kissing other's cheek", "gentle smile"] }, { "name": null, "gender": "male", "tags": ["short brown hair", "school uniform", "blushing", "surprised expression", "receiving kiss on cheek"] } ] } ``` > Even though the character card includes `white thighhighs` and `black loafers`, the `upper body` framing cues the model to omit those out-of-frame items automatically.
### Output Modes
- **Mode A (Default — omit `output_format`): Pure English Prose** No Markdown wrappers, no VLM phrasing (*"The image depicts..."*), no aspect-ratio text noise—ready to paste straight into your image generator: ```text Warm late-afternoon sunlight streams through the tall windows of a quiet classroom, framing the scene from the waist up. Hakurei Reimu, her long black hair tied with a red ribbon and dressed in a neat school uniform, leans down with a gentle smile to press a soft kiss against a young man's cheek. The boy, with short brown hair and a matching school uniform, freezes in surprise with a deep blush spreading across his face. ```
- **Mode B-1 (`output_format: "json"`, `split_characters: false` or omitted): Single-Prompt JSON** ```json { "aspect_ratio": "2:3", "prompt": "Warm late-afternoon sunlight streams through the tall windows of a quiet classroom, framing the scene from the waist up. Hakurei Reimu, her long black hair tied with a red ribbon and dressed in a neat school uniform, leans down with a gentle smile to press a soft kiss against a young man's cheek. The boy, with short brown hair and a matching school uniform, freezes in surprise with a deep blush spreading across his face." } ```
- **Mode B-2 (`output_format: "json"` + `split_characters: true`): Per-Subject Split JSON** Returns `aspect_ratio`, overall `scene` prose, and an array of foreground subjects (`characters[]`, preserving Danbooru underscore tags in `name` for programmatic lookup or LoRA routing; `null` for unnamed subjects; `[]` for pure landscapes): ```json { "aspect_ratio": "2:3", "scene": "A quiet classroom bathed in warm late-afternoon sunset light streaming through tall windows, framed from the waist up with soft golden highlights across the desks.", "characters": [ { "name": "hakurei_reimu", "prompt": "hakurei reimu, long black hair, red hair ribbon, school uniform; she leans down with a gentle smile to press a soft kiss onto the boy's cheek." }, { "name": null, "prompt": "short brown hair, school uniform, blushing; the boy freezes in surprise as he receives the kiss." } ] } ```
## Recommended Inference Settings
- **Chat Template**: Standard ChatML (non-thinking), stop token `eos_token = "<|im_end|>"`.- **Sampling**: `temperature = 0.7–0.85`, `top_p = 0.90–0.92` (use `0.85–0.90` for higher gacha variance).- **Default System Prompt** (matches training verbatim): ```text You convert anime image tags or structured scene and character inputs into vivid, natural English image-generation prompts. Follow all explicit visible details, character counts, genders, named characters, rating, and optional length, aspect ratio, or style controls. When framing or occlusion hides parts of a character (such as close-up, upper body, from behind, or closed eyes), omit out-of-frame or occluded features from your output. Output pure English prose by default; when output_format is json, return a single valid JSON object with aspect_ratio and prompt (or scene and characters when split_characters is true). ```
## Performance & Benchmarks
There is no formal benchmark yet, though for anime prompt gacha specifically, it's arguably #1 in its niche (and if not, I'll just add a few more qualifiers).
## Training Notes
This is my first LLM fine-tuning project—having previously trained image-model LoRAs, adapting an LLM turned out to be a very different beast. Early prototyping was done on [Google Colab](https://colab.research.google.com/), and the `v0.1` release was trained via full-parameter BF16 SFT on an RTX PRO 6000 (with the vision tower stripped prior to training).
For a well-scoped task like this, **dataset design is everything**. The dataset went through multiple schema iterations and multi-round LLM auditing to balance three priorities:
1. **Consistency**: Accurate character traits, strict headcount/gender adherence, coherent multi-character interactions, and automatic clipping of out-of-frame or occluded features.2. **Structure**: Seamless switching between pure prose and structured JSON (including aspect-ratio recommendation, per-subject splitting for NAI/Moss/regional prompting, and 4-tier length control).3. **Diversity**: The core of a "gacha" model—without diversity, there's no gacha. Mixing heterogeneous multi-teacher sources and stopping at 1.0 epoch (`eval_loss = 1.640`) preserves the base model's creative variance without collapsing into repetitive phrasing.
## Limitations & Notes
- Built specifically for English anime/illustration image-generation prompts; not intended as a general-purpose chat assistant.- `style` defaults to `"off"` (style-neutral). Keep it off if your downstream workflow relies on artist tags or style LoRAs.- **Known `v0.1` limitation**: Out-of-frame and closed-eyes clipping works cleanly in Mode A, whereas in Mode B-2 JSON with full head-to-toe character sheets, the trait prefix before `;` may occasionally retain out-of-frame footwear. This will be addressed in the next release.
## Roadmap
1. **More human-like inputs**: Rewrite a portion of rule-assembled inputs via LLM into natural, messy, real-world user prompts.2. **One-to-many (multi-output) distillation**: Pair identical sparse inputs with multiple distinct high-quality outputs to push sampling diversity directly at the gradient level.3. **Dynamic multi-epoch re-rendering + curated annealing**: Prevent repetition overfitting across epochs while strengthening Mode B-2 out-of-frame clipping and custom instruction following.
## Acknowledgements
1. [ZAKO-V0.1 (`Johnny-Z/zako-pe`)](https://huggingface.co/Johnny-Z/zako-pe) — inspiration and initial visual prose distillation.2. [danbooru-tags-2016-2023 (`isek-ai/danbooru-tags-2016-2023`)](https://huggingface.co/datasets/isek-ai/danbooru-tags-2016-2023) — Danbooru tag foundation for stratified sampling.3. [Qwen (`Qwen3.5-4B-Base`)](https://huggingface.co/Qwen/Qwen3.5-4B-Base) — open-weights base model.4. [Google](https://www.google.com/) & [Google Colab](https://colab.research.google.com/) — early prototyping compute.5. [Gemini](https://deepmind.google/models/gemini/) — indispensable coding, auditing, and training co-pilot throughout the project.README.mdAdded+190