Text Generation
Transformers
Safetensors
English
qwen2
llama-factory
unsloth
conversational
text-generation-inference
Instructions to use trollek/Qwen2-0.5B-DiffusionPrompter-v0.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trollek/Qwen2-0.5B-DiffusionPrompter-v0.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="trollek/Qwen2-0.5B-DiffusionPrompter-v0.1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("trollek/Qwen2-0.5B-DiffusionPrompter-v0.1") model = AutoModelForCausalLM.from_pretrained("trollek/Qwen2-0.5B-DiffusionPrompter-v0.1", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use trollek/Qwen2-0.5B-DiffusionPrompter-v0.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trollek/Qwen2-0.5B-DiffusionPrompter-v0.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trollek/Qwen2-0.5B-DiffusionPrompter-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/trollek/Qwen2-0.5B-DiffusionPrompter-v0.1
- SGLang
How to use trollek/Qwen2-0.5B-DiffusionPrompter-v0.1 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 "trollek/Qwen2-0.5B-DiffusionPrompter-v0.1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trollek/Qwen2-0.5B-DiffusionPrompter-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "trollek/Qwen2-0.5B-DiffusionPrompter-v0.1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trollek/Qwen2-0.5B-DiffusionPrompter-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use trollek/Qwen2-0.5B-DiffusionPrompter-v0.1 with Docker Model Runner:
docker model run hf.co/trollek/Qwen2-0.5B-DiffusionPrompter-v0.1
Can you teach me how to organize the dataset?你能教我怎么组织数据集吗?
#1
by sherlockbt - opened
你能指导我一下怎么把你提及的数据集转换成训练的数据格式的,我想复现你的训练结果
Can you guide me how to convert the dataset you mentioned into the training data format? I want to reproduce your training results.
I can! I did it in a few stages. Fumbling in darkness at the time. Here are the config files chronologically:
### model
model_name_or_path: Qwen/Qwen2-0.5B
### method
stage: sft
do_train: true
finetuning_type: lora
lora_target: all
loraplus_lr_ratio: 16.0
lora_rank: 8
lora_alpha: 16
use_unsloth: true
seed: 3141
### dataset
dataset: ninja_diffusion
template: hermes_chatml (ChatML without system)
cutoff_len: 1024
overwrite_cache: false
preprocessing_num_workers: 12
### output
output_dir: qwen2/0.5B/sd-prompter
logging_steps: 1
save_steps: 1
save_strategy: epoch
plot_loss: true
overwrite_output_dir: false
### train
per_device_train_batch_size: 8
gradient_accumulation_steps: 4
learning_rate: 0.0001
num_train_epochs: 4.0
lr_scheduler_type: cosine
warmup_ratio: 0.01
bf16: true
flash_attn: fa2
### eval
val_size: 0.02
per_device_eval_batch_size: 1
eval_strategy: steps
eval_steps: 200
### model
model_name_or_path: qwen2/0.5B/sd-prompter
### method
stage: pt
do_train: true
finetuning_type: full
use_badam: true
badam_switch_mode: ascending
badam_switch_interval: 50
badam_verbose: 1
badam_start_block: 10
seed: 31415
### dataset
dataset: stable_diffusion_pt (Gustavosta/Stable-Diffusion-Prompts)
cutoff_len: 1024
overwrite_cache: false
preprocessing_num_workers: 12
### output
output_dir: qwen2/0.5B/SD-base
logging_steps: 5
save_steps: 1
save_strategy: epoch
plot_loss: true
overwrite_output_dir: false
### train
per_device_train_batch_size: 1
gradient_accumulation_steps: 2
learning_rate: 0.00001
num_train_epochs: 2
lr_scheduler_type: cosine
warmup_ratio: 0.01
pure_bf16: true
flash_attn: fa2
### eval
val_size: 0.01
per_device_eval_batch_size: 1
eval_strategy: steps
eval_steps: 1000
### model
model_name_or_path: qwen2/0.5B/SD-base
### method
stage: sft
do_train: true
finetuning_type: lora
lora_target: all
use_dora: true
lora_rank: 16
lora_alpha: 16
use_unsloth: true
seed: 3141
additional_target: lm_head,embed_tokens
### dataset
dataset: ninja_diffusion,sd_concepts (the sd-concepts dataset is a json file in this repo)
template: hermes_chatml
cutoff_len: 1024
overwrite_cache: false
preprocessing_num_workers: 12
### output
output_dir: qwen2/0.5B/Qwen2-DiffusionPrompter-v0.1
logging_steps: 1
save_steps: 1
save_strategy: epoch
plot_loss: true
overwrite_output_dir: false
### train
per_device_train_batch_size: 4
gradient_accumulation_steps: 8
learning_rate: 0.00005
num_train_epochs: 2
lr_scheduler_type: constant_with_warmup
warmup_ratio: 0.01
bf16: true
flash_attn: fa2
### eval
val_size: 0.05
per_device_eval_batch_size: 1
eval_strategy: steps
eval_steps: 100