Views
No views yet
[!NOTE] To fix endless generations + instructions on how to run QwQ-32B, read our Tutorial here.
ollama run hf.co/unsloth/QwQ-32B-GGUF:Q4_K_M1import os
2os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
3from huggingface_hub import snapshot_download
4snapshot_download(
5 repo_id = "unsloth/QwQ-32B-GGUF",
6 local_dir = "unsloth-QwQ-32B-GGUF",
7 allow_patterns = ["*Q4_K_M*"], # For Q4_K_M
8)1./llama.cpp/llama-cli \
2 --model unsloth-QwQ-32B-GGUF/QwQ-32B-Q4_K_M.gguf \
3 --threads 32 \
4 --ctx-size 16384 \
5 --n-gpu-layers 99 \
6 --seed 3407 \
7 --prio 2 \
8 --temp 0.6 \
9 --repeat-penalty 1.1 \
10 --dry-multiplier 0.5 \
11 --min-p 0.01 \
12 --top-k 40 \
13 --top-p 0.95 \
14 -no-cnv \
15 --samplers "top_k;top_p;min_p;temperature;dry;typ_p;xtc" \
16 --prompt "<|im_start|>user\nCreate a Flappy Bird game in Python."[!NOTE] To stop infinite generations - add--samplers "top_k;top_p;min_p;temperature;dry;typ_p;xtc"
| Unsloth supports | Free Notebooks | Performance | Memory use |
|---|---|---|---|
| GRPO with Phi-4 | ▶️ Start on Colab | 2x faster | 80% less |
| Llama-3.2 (3B) | ▶️ Start on Colab | 2.4x faster | 58% less |
| Llama-3.2 (11B vision) | ▶️ Start on Colab | 2x faster | 60% less |
| Qwen2 VL (7B) | ▶️ Start on Colab | 1.8x faster | 60% less |
| Qwen2.5 (7B) | ▶️ Start on Colab | 2x faster | 60% less |
| Llama-3.1 (8B) | ▶️ Start on Colab | 2.4x faster | 58% less |
| Phi-4 (14B) | ▶️ Start on Colab | 2x faster | 50% less |
| Gemma 2 (9B) | ▶️ Start on Colab | 2.4x faster | 58% less |
| Mistral (7B) | ▶️ Start on Colab | 2.2x faster | 62% less |

transformers. We advise you to use the latest version of transformers.transformers<4.37.0, you will encounter the following error:KeyError: 'qwen2'apply_chat_template to show you how to load the tokenizer and model and how to generate contents.1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "Qwen/QwQ-32B"
4
5model = AutoModelForCausalLM.from_pretrained(
6 model_name,
7 torch_dtype="auto",
8 device_map="auto"
9)
10tokenizer = AutoTokenizer.from_pretrained(model_name)
11
12prompt = "How many r's are in the word \"strawberry\""
13messages = [
14 {"role": "user", "content": prompt}
15]
16text = tokenizer.apply_chat_template(
17 messages,
18 tokenize=False,
19 add_generation_prompt=True
20)
21
22model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
23
24generated_ids = model.generate(
25 **model_inputs,
26 max_new_tokens=32768
27)
28generated_ids = [
29 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
30]
31
32response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
33print(response)apply_chat_template and set add_generation_prompt=True, this is already automatically implemented, but it may cause the response to lack the <think> tag at the beginning. This is normal behavior.answer field with only the choice letter, e.g.,\"answer\": \"C\"." in the prompt.config.json to enable YaRN:1{
2 ...,
3 "rope_scaling": {
4 "factor": 4.0,
5 "original_max_position_embeddings": 32768,
6 "type": "yarn"
7 }
8}rope_scaling configuration only when processing long contexts is required.@misc{qwq32b,
title = {QwQ-32B: The Power of Scaling RL},
url = {https://qwenlm.github.io/blog/qwq-32b/},
author = {Qwen Team},
month = {March},
year = {2025}
}
@article{qwen2,
title={Qwen2 Technical Report},
author={An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhihao Fan},
journal={arXiv preprint arXiv:2407.10671},
year={2024}
}