Instructions to use Qwen/QwQ-32B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/QwQ-32B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Qwen/QwQ-32B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Qwen/QwQ-32B") model = AutoModelForCausalLM.from_pretrained("Qwen/QwQ-32B", 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
- AMD Developer Cloud
- Local Apps Settings
- vLLM
How to use Qwen/QwQ-32B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/QwQ-32B" # 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/QwQ-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Qwen/QwQ-32B
- SGLang
How to use Qwen/QwQ-32B 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/QwQ-32B" \ --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/QwQ-32B", "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/QwQ-32B" \ --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/QwQ-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Qwen/QwQ-32B with Docker Model Runner:
docker model run hf.co/Qwen/QwQ-32B
用vllm时应该是什么参数
需要加那个什么apply_chat_template不,我用的https://hf-mirror.com/lmstudio-community/QwQ-32B-GGUF 这里的gguf,好像没法抽出来tokenizer
prompt_final = [{"role": "user", "content": "xxx"}]
tensor_parallel_size=1
pipeline_parallel_size=1
ckpt_path="./QwQ-32B-Q4_K_M.gguf"
sampling_params = SamplingParams(temperature=0.6, max_tokens=1000)
batch_prompts = [prompt_final]
llm = LLM(model=ckpt_path, tensor_parallel_size=tensor_parallel_size, distributed_executor_backend="mp", pipeline_parallel_size=pipeline_parallel_size)#,
preds = llm.chat(batch_prompts, sampling_params)
for output in preds:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}\n")
请问解决用VLLM部署了吗
上面那个代码用vllm部署没有问题,现在主要问题是感觉qwq的cot特别长,相比r1来说
有的问题r1-distill-qwen-32b可能五百个token就回答完了(cot+response),而qwq可能cot要想1000多个token还没想完,很影响性能
vllm serve ~/.cache/models--Qwen--QwQ-32B/snapshots/f28e641280ed3228b25df45b02ce6526b472cbea/ --tokenizer ~/Downloads/QwQ-32B/ --host 0.0.0.0 --port 21434 --tensor-parallel-size 4 --max-model-len 34576 --served-model-name qwq-32b
魔塔社区的官方公众号,已经发了使用 vLLM 和sgLang 的方式 ,大家可以去看下
vllm serve /ModelPath/QwQ-32B --port 8000 --reasoning-parser deepseek_r1 --max_model_len 4096 --enable-auto-tool-choice --tool-call-parser hermes
python -m sglang.launch_server --model-path /ModelPath/QwQ-32B --port 3001 --host 0.0.0.0 --tool-call-parser qwen25
魔塔社区的官方公众号,已经发了使用 vLLM 和sgLang 的方式 ,大家可以去看下
vllm serve /ModelPath/QwQ-32B --port 8000 --reasoning-parser deepseek_r1 --max_model_len 4096 --enable-auto-tool-choice --tool-call-parser hermespython -m sglang.launch_server --model-path /ModelPath/QwQ-32B --port 3001 --host 0.0.0.0 --tool-call-parser qwen25
The vllm documentation mentions that there are currently incompatibilities with structured output and Tool-Calling if inferential parsing is used, and this is actually the case as described in the documentation.