Fine-tune Qwen 3 on a custom dataset
Qwen 3 is one of the strongest open-weight models for reasoning and multilingual tasks. This guide shows how to fine-tune Qwen 3 8B on your own dataset with Soup CLI.
1. Install
pip install "soup-cli[train,fast]"Since v0.71.0 the base
soup-clipackage is a light, PyTorch-free CLI.[train]adds the training stack;[fast]adds Unsloth on top. Installing[fast]alone cannot train.
2. Dataset (ShareGPT format)
Qwen 3 handles multi-turn conversations well. Use the ShareGPT format:
[
{
"conversations": [
{"from": "user", "value": "Explain gradient descent in one paragraph."},
{"from": "assistant", "value": "Gradient descent is..."}
]
}
]3. Config
base: Qwen/Qwen3-8B
task: sft
backend: unsloth # root-level, NOT under training
data:
train: conversations.json
format: sharegpt
max_length: 4096 # sequence length lives under data
training:
epochs: 2
lr: 1.5e-4 # the key is lr, not learning_rate
batch_size: 4
gradient_accumulation_steps: 4
lora:
r: 32 # LoRA turns on when r > 0; there is no enabled flag
alpha: 64
target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]Why target all projections? Qwen 3 benefits from training LoRA on both attention and MLP projections for instruction-following tasks.
4. Train
soup train --config qwen3.yaml5. Serve with vLLM
pip install "soup-cli[serve-fast]"
soup serve --model Qwen/Qwen3-8B --adapters qwen3=./runs/qwen3/latest --backend vllm --port 8000The model is now available at http://localhost:8000/v1/chat/completions with OpenAI-compatible API.
Tips
- Qwen 3 uses a 151k vocab — stick to
data.max_length: 4096or higher for best results. - Use
training.neftune_alpha: 5to inject noise into embeddings — improves generalization on small datasets. - For reasoning tasks, try
training.packing: truefor efficient long-context training.
Related
Soup is free and Apache-2.0. If it saved you a training run, starring the repo costs nothing and helps most. You can also fund the GPU time behind the work a 4 GB laptop cannot reach.