Instructions to use Qwen/Qwen3-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen3-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Qwen/Qwen3-8B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-8B") model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-8B") 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]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Qwen/Qwen3-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/Qwen3-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qwen/Qwen3-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Qwen/Qwen3-8B
- SGLang
How to use Qwen/Qwen3-8B 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 "Qwen/Qwen3-8B" \ --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": "Qwen/Qwen3-8B", "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 "Qwen/Qwen3-8B" \ --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": "Qwen/Qwen3-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Qwen/Qwen3-8B with Docker Model Runner:
docker model run hf.co/Qwen/Qwen3-8B
DoRA personal-voice adapter on Qwen3-8B β 100% blind A/B vs stock, $1.50 GPU cost (writeup + adapter)
Hi Qwen team and community,
Sharing a small experiment we ran on Qwen3-8B that might be of interest to folks doing personalization work.
We trained a DoRA adapter on 6128 personal Telegram message pairs (single person's chat history, with consent). Single RTX 3090 on Vast.ai, 3.5h, ~$1.50 total.
Setup
- Base:
Qwen/Qwen3-8B - Method: DoRA via peft (
use_dora=True), rank 16, alpha 32, target q/k/v/o - Loss mask only on assistant tokens (critical for voice work)
- bf16 + flash-attn-2 + gradient checkpointing, peaks at 22/24 GB
Eval (blind 3-way A/B on 30 hold-out prompts)
| Comparison | Result |
|---|---|
| DoRA vs stock (head-to-head) | DoRA 100% |
| Full 3-way (real human / DoRA / stock) | Real 71% / DoRA 29% / Stock 0% |
| Catastrophic forgetting on 50 baseline tasks | 0 pp |
Critical gotcha β enable_thinking=False
This bit us hard. Qwen3 emits <think> reasoning traces by default, but chat-style training data has none. During inference the base prior fights the adapter and output ends up as long reasoning prefix + short colloquial reply. The fix:
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
enable_thinking=False, # MANDATORY for chat-style adapters
return_tensors='pt',
)
Worth a prominent note in the Qwen3 README/usage docs IMO β this is non-obvious for anyone training chat adapters and silently breaks output quality.
transformers version
Qwen3 lands in 4.51, but 4.55+ wants torch β₯2.5. We pinned to transformers==4.53.0 for Vast 3090 compatibility.
Adapter on HF (CC BY-NC 4.0, gated for ethical reasons since training data is one specific person):
https://huggingface.co/aiconiccompany/yuka-dora-v1
Full write-up with methodology, configs, the one prompt where DoRA beat the real human at sounding like themselves, and what we'd change in v2:
https://aiconic.company/en/journal/dora-personal-voice
Happy to share configs/eval scripts or discuss with anyone planning similar work on Qwen3.
Thanks to the Qwen team for shipping such a clean open-weights model β the personal-AI thesis only works because of releases like this.