Instructions to use Qwen/Qwen2.5-0.5B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen2.5-0.5B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct") model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct", 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Qwen/Qwen2.5-0.5B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/Qwen2.5-0.5B-Instruct" # 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/Qwen2.5-0.5B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Qwen/Qwen2.5-0.5B-Instruct
- SGLang
How to use Qwen/Qwen2.5-0.5B-Instruct 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/Qwen2.5-0.5B-Instruct" \ --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/Qwen2.5-0.5B-Instruct", "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/Qwen2.5-0.5B-Instruct" \ --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/Qwen2.5-0.5B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Qwen/Qwen2.5-0.5B-Instruct with Docker Model Runner:
docker model run hf.co/Qwen/Qwen2.5-0.5B-Instruct
Evaluation
Which tools were used for the evaluation? I’d like to replicate the results.
Thanks a lot.
We can't tell you what tooling produced this model's published evaluation, but here is a pinned replication of quality evaluation on this exact revision (7ae557604adf67be50417f59c2c2f167def9a775), run twice by two operators in fresh containers:
- Tooling:
llama-perplexityfrom the llama.cpp full image (ghcr.io/ggml-org/llama.cpp:full, build 10991 /930e2fa59), CPU only, 8 threads, seed 1051. - Perplexity: F16 15.3782, Q4_K_M 15.7842 (Wikitext-2 test, 128 x 512-token chunks).
- HellaSwag
acc_norm: 50.50% for both arms (200 tasks,--hellaswag). - Across the two runs: perplexity identical to four decimals, HellaSwag identical, both GGUF files byte-identical by SHA-256, peak RSS within 0.13%.
Exact commands, raw logs and the two-run diff: https://huggingface.co/datasets/CyberNative-AI/gguf-repro-harness
Two caveats so the numbers are not over-read: wall-clock load time and throughput did not reproduce within +/-2% on our shared CPU host (up to 61% and 34% spread), so we make no latency claims; and this is repeat execution of one harness, not an independent reproduction of the model card's published scores.