Instructions to use KBlueLeaf/DanTagGen-alpha with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KBlueLeaf/DanTagGen-alpha with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="KBlueLeaf/DanTagGen-alpha")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("KBlueLeaf/DanTagGen-alpha") model = AutoModelForCausalLM.from_pretrained("KBlueLeaf/DanTagGen-alpha") - llama-cpp-python
How to use KBlueLeaf/DanTagGen-alpha with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="KBlueLeaf/DanTagGen-alpha", filename="ggml-model-Q6_K.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use KBlueLeaf/DanTagGen-alpha with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf KBlueLeaf/DanTagGen-alpha:Q6_K # Run inference directly in the terminal: llama-cli -hf KBlueLeaf/DanTagGen-alpha:Q6_K
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf KBlueLeaf/DanTagGen-alpha:Q6_K # Run inference directly in the terminal: llama-cli -hf KBlueLeaf/DanTagGen-alpha:Q6_K
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf KBlueLeaf/DanTagGen-alpha:Q6_K # Run inference directly in the terminal: ./llama-cli -hf KBlueLeaf/DanTagGen-alpha:Q6_K
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf KBlueLeaf/DanTagGen-alpha:Q6_K # Run inference directly in the terminal: ./build/bin/llama-cli -hf KBlueLeaf/DanTagGen-alpha:Q6_K
Use Docker
docker model run hf.co/KBlueLeaf/DanTagGen-alpha:Q6_K
- LM Studio
- Jan
- vLLM
How to use KBlueLeaf/DanTagGen-alpha with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "KBlueLeaf/DanTagGen-alpha" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KBlueLeaf/DanTagGen-alpha", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/KBlueLeaf/DanTagGen-alpha:Q6_K
- SGLang
How to use KBlueLeaf/DanTagGen-alpha with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "KBlueLeaf/DanTagGen-alpha" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KBlueLeaf/DanTagGen-alpha", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "KBlueLeaf/DanTagGen-alpha" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KBlueLeaf/DanTagGen-alpha", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use KBlueLeaf/DanTagGen-alpha with Ollama:
ollama run hf.co/KBlueLeaf/DanTagGen-alpha:Q6_K
- Unsloth Studio
How to use KBlueLeaf/DanTagGen-alpha with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for KBlueLeaf/DanTagGen-alpha to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for KBlueLeaf/DanTagGen-alpha to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for KBlueLeaf/DanTagGen-alpha to start chatting
- Docker Model Runner
How to use KBlueLeaf/DanTagGen-alpha with Docker Model Runner:
docker model run hf.co/KBlueLeaf/DanTagGen-alpha:Q6_K
- Lemonade
How to use KBlueLeaf/DanTagGen-alpha with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull KBlueLeaf/DanTagGen-alpha:Q6_K
Run and chat with the model
lemonade run user.DanTagGen-alpha-Q6_K
List all available models
lemonade list
DanTagGen - alpha
DanTagGen(Danbooru Tag Generator) is inspired from p1atdev's dart project. But with different arch, dataset, format and different training strategy.
Model arch
This version of DTG is trained from scratch with 400M param LLaMA arch.(In my personal preference I will call it NanoLLaMA) Since it is llama arch. Theoritically it should be able to be used in any LLaMA inference interface.
This repo also provided converted FP16 gguf model and quantized 8bit/6bit gguf models. Basically it is recommended to use llama.cpp or llama-cpp-python to run this model. Which will be very fast.
Format
prompt = f"""
rating: {rating or '<|empty|>'}
artist: {artist.strip() or '<|empty|>'}
characters: {characters.strip() or '<|empty|>'}
copyrights: {copyrights.strip() or '<|empty|>'}
aspect ratio: {f"{aspect_ratio:.1f}" or '<|empty|>'}
target: {'<|' + target + '|>' if target else '<|long|>'}
general: {", ".join(special_tags)}, {general.strip().strip(",")}<|input_end|>
"""
for example:
rating: safe
artist: <|empty|>
characters: <|empty|>
copyrights: <|empty|>
aspect ratio: 1.0
target: <|short|>
general: 1girl, solo, dragon girl, dragon horns, dragon tail<|input_end|>
And you may get something like:
rating: safe
artist: <|empty|>
characters: <|empty|>
copyrights: <|empty|>
aspect ratio: 1.0
target: <|short|>
general: 1girl, solo, dragon girl, dragon horns, dragon tail<|input_end|>open mouth, red eyes, long hair, pointy ears, tail, black hair, chinese clothes, simple background, dragon, hair between eyes, horns, china dress, dress, looking at viewer, breasts
Dataset and Training
I use the trainer I implemented in HakuPhi to run the training. (It should be HakuLLM now LoL) with 15epoch on 2M data and 5epoch on 5.3M data. This model have roughly 6~12B token seen.
The dataset is exported by HakuBooru with my danbooru sqlite database. Use the percentile of fav_count on each rating to filter the data. (2M = top 25%, 5.3M = top 75%)
Utilities
I'm implementing a gradio UI for this thing and other dev can utilize the API in it to make different app. I'm also planning to make sd-webui extension.
- Downloads last month
- 8,184