Qwen3-4B-Diversity is a fine-tuned language model based on
Qwen/Qwen3-4B that has been trained on a diverse collection of high-quality reasoning datasets. This model combines knowledge distilled from various state-of-the-art AI systems to provide enhanced reasoning capabilities across multiple domains including mathematics, coding, general problem-solving, and multi-turn conversations.
The model was trained using supervised fine-tuning techniques with parameter-efficient methods to optimize performance while maintaining computational efficiency. Key training parameters include:
-
Advanced Reasoning: The model can break down complex problems into steps and provide detailed reasoning processes.
-
Mathematical Problem Solving: Enhanced capabilities for mathematical reasoning and problem-solving through dedicated math-focused datasets.
-
Code Generation and Understanding: Improved coding abilities from multiple code-reasoning datasets including DeepSeek and GPT-5 Codex data.
-
Multi-Turn Conversations: Better handling of extended dialogues and context-aware responses.
-
Domain Versatility: Exposure to reasoning patterns from various AI systems provides flexibility across different domains and task types.
If you are looking for a quick demo that is completely free and without any cost, you can use
Google Colab.
1# https://ollama.com/hadad/qwen3-4bd
2
3# hadad/qwen3-4bd:Q8_0 | 4.3GB
4# hadad/qwen3-4bd:BF16 | 8.1GB
5
6# ollama pull hadad/qwen3-4bd:Q8_0
7
8ollama run hadad/qwen3-4bd:Q8_0
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "hadadxyz/Qwen3-4B-Diversity"
4
5# load the tokenizer and the model
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype="auto",
10 device_map="auto"
11)
12
13# prepare the model input
14prompt = "Give me a short introduction to large language model."
15messages = [
16 {"role": "user", "content": prompt}
17]
18text = tokenizer.apply_chat_template(
19 messages,
20 tokenize=False,
21 add_generation_prompt=True,
22 enable_thinking=True # Switches between thinking and non-thinking modes. Default is True.
23)
24model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
25
26# conduct text completion
27generated_ids = model.generate(
28 **model_inputs,
29 max_new_tokens=32768
30)
31output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
32
33# parsing thinking content
34try:
35 # rindex finding 151668 (</think>)
36 index = len(output_ids) - output_ids[::-1].index(151668)
37except ValueError:
38 index = 0
39
40thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
41content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
42
43print("thinking content:", thinking_content)
44print("content:", content)
If you use this model in your research or applications, please cite both this model and the base model:
1@misc{qwen3-4b-diversity,
2 author = {hadadxyz},
3 title = {Qwen3-4B-Diversity},
4 year = {2026},
5 url = {https://huggingface.co/hadadxyz/Qwen3-4B-Diversity}
6}
This model was made possible through the combination of multiple high-quality datasets from the community. We acknowledge and thank all dataset creators and the Qwen team for providing the excellent base model.