Text Generation
PEFT
Safetensors
Transformers
qwen
kto
lora
trl
chinese-poetry
style-transfer
conversational
Instructions to use shikunpunk/Qwen3.8-27B-GuCheng-KTO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use shikunpunk/Qwen3.8-27B-GuCheng-KTO with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.8-27B") model = PeftModel.from_pretrained(base_model, "shikunpunk/Qwen3.8-27B-GuCheng-KTO") - Transformers
How to use shikunpunk/Qwen3.8-27B-GuCheng-KTO with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="shikunpunk/Qwen3.8-27B-GuCheng-KTO") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("shikunpunk/Qwen3.8-27B-GuCheng-KTO", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use shikunpunk/Qwen3.8-27B-GuCheng-KTO with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "shikunpunk/Qwen3.8-27B-GuCheng-KTO" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shikunpunk/Qwen3.8-27B-GuCheng-KTO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/shikunpunk/Qwen3.8-27B-GuCheng-KTO
- SGLang
How to use shikunpunk/Qwen3.8-27B-GuCheng-KTO 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 "shikunpunk/Qwen3.8-27B-GuCheng-KTO" \ --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": "shikunpunk/Qwen3.8-27B-GuCheng-KTO", "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 "shikunpunk/Qwen3.8-27B-GuCheng-KTO" \ --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": "shikunpunk/Qwen3.8-27B-GuCheng-KTO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use shikunpunk/Qwen3.8-27B-GuCheng-KTO with Docker Model Runner:
docker model run hf.co/shikunpunk/Qwen3.8-27B-GuCheng-KTO
Qwen3.8-27B GuCheng KTO LoRA Adapter(顾城风格 KTO 后训练)
基于 Qwen/Qwen3.8-27B + 顾城 SFT LoRA adapter 的 KTO 后训练 adapter。
模型说明
- 基座模型:Qwen/Qwen3.8-27B
- 训练方法:KTO(单模型,替代标准 DPO 双模型以解决 27B + 40GB 显存 OOM)
- 训练数据:标注一致偏好数据(desirable=真实诗人诗歌,undesirable=非诗文本),113 条(226 样本)
- LoRA 配置:r=16, alpha=32, dropout=0.05
- 训练 3 epochs:train_loss 0.317 → 0.070(final 0.185),KTO rewards/margins=18.88
使用方法
from transformers import AutoModelForCausalLM, AutoProcessor, BitsAndBytesConfig
from peft import PeftModel
import torch
base = "Qwen/Qwen3.8-27B"
adapter = "shikunpunk/Qwen3.8-27B-GuCheng-KTO"
quant = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True)
model = AutoModelForCausalLM.from_pretrained(base, trust_remote_code=True,
torch_dtype=torch.bfloat16, device_map="auto",
quantization_config=quant)
model = PeftModel.from_pretrained(model, adapter, is_trainable=False)
processor = AutoProcessor.from_pretrained(base, trust_remote_code=True)
model.eval()
说明
- 该 adapter 是风格保真 KTO 后训练产物,配合 SFT 风格 adapter 使用(SFT 先学风格,KTO 强化偏好对齐)。
- 相关代码与数据见项目 GitHub 仓库。
- Downloads last month
- 15
Model tree for shikunpunk/Qwen3.8-27B-GuCheng-KTO
Base model
Qwen/Qwen3.8-27B