Qwen 3 Local Setup Guide: Run Alibaba's AI Model with Ollama
Want to go deeper than this article?
Free account unlocks the first chapter of all 20 courses — RAG, agents, MCP, voice AI, MLOps, real GitHub repos.
Ollama’s running. Here’s what to build with it. Go from “ollama run” to RAG apps, agents, and fine-tuned models — structured and hands-on. First chapter free.
To run Qwen3 locally, install Ollama, then run ollama pull qwen3:8b and ollama run qwen3:8b — that's the 8B dense model in about 6GB of VRAM, the recommended starting point for most people. Pick by hardware: qwen3:8b for an 8GB GPU, qwen3:14b for 16GB, and qwen3:32b or the qwen3:30b-a3b MoE for 24GB. All open-weight Qwen 3 models are Apache 2.0 (free commercial use), span 0.6B to 235B parameters across 119 languages, and support a toggleable thinking mode. The newer flagship Qwen3.7-Max (May 2026) is API-only with no open weights, so it cannot run locally.
Qwen 3 Quick Start
Choose Your Model:
Quick Install (3 commands):
curl -fsSL https://ollama.com/install.sh | sh
ollama pull qwen3:8b
ollama run qwen3:8b
What is Qwen 3?
Qwen 3 is Alibaba Cloud's flagship large language model series, released April 28-29, 2025. It represents a massive leap forward with 36 trillion training tokens across 119 languages—nearly double the 18 trillion tokens used for Qwen 2.5.
The release includes 8 models: 6 dense architectures ranging from 0.6B to 32B parameters, plus 2 Mixture-of-Experts (MoE) models with 30B and 235B total parameters. All models are released under the Apache 2.0 license, making them fully open source and commercially usable without restrictions.
What makes Qwen 3 exceptional:
- Performance scaling: Qwen3-32B matches Qwen2.5-72B capability—72B-class performance from a single RTX 4090
- 119 languages: The most multilingual open-source model available
- Dual-mode thinking: Switch between deep reasoning and fast responses
- MoE efficiency: 30B quality with 3B inference cost (30B-A3B variant)
- State-of-the-art benchmarks: Outperforms DeepSeek-R1 on 17/23 benchmarks
Reading articles is good. Building is better.
Free account = 20+ free chapters across 20 courses, with a per-chapter AI tutor. No card. Cancel anytime if you ever upgrade.
Qwen 3 Model Family: Complete Overview
Dense Models (All Parameters Active)
Dense models activate all parameters during inference. They're simpler to deploy and have predictable resource requirements.
| Model | Parameters | Layers | Attention Heads | KV Heads | Context | VRAM (Q4) |
|---|---|---|---|---|---|---|
| Qwen3-0.6B | 0.6B | 28 | 16 | 4 | 32K | ~1GB |
| Qwen3-1.7B | 1.7B | 28 | 16 | 4 | 32K | ~2GB |
| Qwen3-4B | 4B | 36 | 24 | 8 | 32K | ~3GB |
| Qwen3-8B | 8B | 36 | 32 | 8 | 128K | ~5-6GB |
| Qwen3-14B | 14B | 48 | 40 | 8 | 128K | ~10GB |
| Qwen3-32B | 32.8B | 64 | 64 | 8 | 128K | ~20GB |
Mixture-of-Experts (MoE) Models
MoE models contain many "expert" sub-networks but only activate a subset for each token. This gives better quality per compute dollar.
| Model | Total Params | Active Params | Experts | Active | Context | VRAM (Q4) |
|---|---|---|---|---|---|---|
| Qwen3-30B-A3B | 30B | 3B | 128 | 8 | 128K | ~19-24GB |
| Qwen3-235B-A22B | 235B | 22B | 128 | 8 | 1M* | 140GB+ |
| Qwen3-Next-80B-A3B | 80B | 3B | 512+1 | 10 | - | ~30GB |
| Qwen3-Coder-480B-A35B | 480B | 35B | - | - | 256K-1M | 250GB+ |
*Extended to 1M tokens with the Qwen3-2507 update.
Understanding MoE Efficiency
The Qwen3-30B-A3B model is particularly notable:
- 30B total parameters stored in memory
- Only 3B activated per token (8 of 128 experts)
- 30B-class quality with 8B-class speed
- Fits on RTX 4090 with INT4 quantization
This is why MoE is revolutionary for local AI: you get significantly better quality without proportionally more compute or memory.
Qwen 3 Release Timeline
| Date | Release | Key Features |
|---|---|---|
| April 28-29, 2025 | Qwen3 Initial | 8 models (6 dense + 2 MoE), Apache 2.0 |
| July-August 2025 | Qwen3-2507 | 1M token context, improved thinking |
| August 4, 2025 | Qwen-Image | Image generation model |
| September 5, 2025 | Qwen3-Max | Flagship API model |
| September 10, 2025 | Qwen3-Next | Hybrid MoE, multi-token prediction |
| October 4, 2025 | Qwen3-VL-30B-A3B | Vision-language MoE |
| January 23, 2026 | qwen3-max-2026-01-23 | Integrated thinking + tool use |
| May 20, 2026 | Qwen3.7-Max | 1M context, native extended-thinking, agentic — API-only, no open weights (not runnable locally) |
The Qwen team maintains rapid development with monthly updates and new model variants. Note that the latest flagship, Qwen3.7-Max (May 20, 2026), is a proprietary API-only model on Alibaba Cloud Model Studio with no open weights released, so it is not part of the local/Ollama lineup covered in this guide. For local use, the Apache 2.0 open-weight dense and MoE models below remain the relevant choices.
Should I run the original Qwen3 or the Qwen3-2507 update?
This is the single most common point of confusion when you go to pull a model in mid-2026, so it's worth getting right before you download 20GB. The original April 2025 Qwen3 release used a hybrid design: one set of weights that you toggled between reasoning and direct answers with /set think and /set nothink. In the July-August 2025 "2507" refresh, Alibaba split that into two dedicated, separately-trained checkpoints — and the newer 2507 weights generally score higher on reasoning and instruction-following than the original hybrids.
| Variant | Reasoning behavior | Best for | Ollama tag example |
|---|---|---|---|
| Original Qwen3 (Apr 2025) | Hybrid — toggle /set think / /set nothink | Mixed workloads, one model to manage | qwen3:8b, qwen3:32b |
| Qwen3-Instruct-2507 | Always direct (no visible chain-of-thought) | Fast chat, RAG, high-throughput, structured output | qwen3:30b-a3b-instruct-2507 |
| Qwen3-Thinking-2507 | Always reasons before answering | Hard math, multi-step coding, agents | qwen3:30b-a3b-thinking-2507 |
The 2507 split exists in 4B, 30B-A3B, and 235B-A22B sizes, with native context extended to 256K tokens. Recommended sampling settings differ between the two: for Instruct-2507 use temperature 0.7, top_p 0.8, top_k 20; for Thinking-2507 use temperature 0.6, top_p 0.95, top_k 20. Practical rule of thumb: if you want one model that does everything, pull the original hybrid qwen3:8b or qwen3:32b; if you have a clear job (a fast assistant or a deep reasoner), the matching 2507 checkpoint will usually beat the toggled hybrid at that one job.
# Direct, fast assistant (no chain-of-thought) — great for RAG and chat
ollama pull qwen3:30b-a3b-instruct-2507
# Deep reasoner — math, multi-step coding, agent loops
ollama pull qwen3:30b-a3b-thinking-2507
# Small but capable 2507 pair (fits ~4GB VRAM)
ollama pull qwen3:4b-instruct-2507
ollama pull qwen3:4b-thinking-2507
If you are choosing a local model purely for everyday assistant use, it's worth weighing Qwen3 against the rest of the field — our roundup of the best Ollama models for local use compares Qwen3, Llama, Gemma, and DeepSeek side by side so you can see where each one wins.
Reading articles is good. Building is better.
Free account = 20+ free chapters across 20 courses, with a per-chapter AI tutor. No card. Cancel anytime if you ever upgrade.
Benchmark Performance
Qwen3-235B-A22B vs Competitors
| Benchmark | Qwen3-235B | DeepSeek-R1 | GPT-4o | Claude 3.5 |
|---|---|---|---|---|
| MMLU Pro | 80.6% | 79.0% | 78.4% | 77.2% |
| LiveCodeBench | 70.7% | 65.9% | 33.4% | 38.9% |
| CodeForces ELO | 2,056 | 2,029 | 1,891 | 1,886 |
| ArenaHard | 95.6 | 92.3 | 90.2 | 89.5 |
| MATH-500 | 90.2% | 97.3% | 74.6% | 78.3% |
| GSM8K | 95.4% | 95.8% | 92.0% | 91.6% |
Key insight: Qwen3-235B-A22B outperforms DeepSeek-R1 on 17 of 23 benchmarks while using only:
- 35% of total parameters (235B vs 671B)
- 60% of active parameters (22B vs 37B)
Performance Scaling: Qwen 3 vs Qwen 2.5
Each Qwen 3 model matches a larger Qwen 2.5:
| Qwen 3 | Matches | Improvement |
|---|---|---|
| Qwen3-1.7B | Qwen2.5-3B | 1.8x smaller |
| Qwen3-4B | Qwen2.5-7B | 1.75x smaller |
| Qwen3-8B | Qwen2.5-14B | 1.75x smaller |
| Qwen3-14B | Qwen2.5-32B | 2.3x smaller |
| Qwen3-32B | Qwen2.5-72B | 2.2x smaller |
This means Qwen3-32B on a single RTX 4090 delivers performance that previously required multi-GPU setups with Qwen 2.5.
Qwen 3 vs Llama Comparison
| Strength | Qwen 3 | Llama |
|---|---|---|
| STEM Reasoning | Stronger | Good |
| Mathematics | Stronger (95.4% GSM8K) | Good |
| Coding | Stronger (2,056 ELO) | Strong |
| Multilingual | Stronger (119 langs) | Limited |
| Structured Output | Good | Stronger |
| Creative Writing | Good | Stronger |
| Multi-step Refactoring | Stronger | Good |
Recommendation: Use Qwen 3 for STEM, math, coding, and multilingual tasks. Use Llama for creative writing and when you need clean structured outputs.
Step-by-Step Local Setup with Ollama
Step 1: Install Ollama
macOS/Linux:
curl -fsSL https://ollama.com/install.sh | sh
Windows: Download from ollama.com/download and run the installer.
Verify installation:
ollama --version
# Should show: ollama version 0.5.x or higher
Step 2: Choose and Pull Your Model
Select based on your VRAM:
# 4GB VRAM - Basic, fast
ollama pull qwen3:0.6b
# 6GB VRAM - Good starter (default)
ollama pull qwen3:8b
# 10-12GB VRAM - Strong reasoning
ollama pull qwen3:14b
# 20-24GB VRAM - Best quality
ollama pull qwen3:32b
# 19-24GB VRAM - MoE efficiency (recommended for 24GB)
ollama pull qwen3:30b-a3b
Step 3: Run the Model
# Run default (8B)
ollama run qwen3
# Or specify size
ollama run qwen3:32b
Step 4: Configure Thinking Mode
Within the interactive session:
# Enable thinking mode (chain-of-thought reasoning)
/set think
# Disable thinking mode (fast direct responses)
/set nothink
# Adjust context length
/set parameter num_ctx 40960
# Adjust response length
/set parameter num_predict 32768
# Exit
/bye
Step 5: Create an Optimized Configuration
For best results, create a custom Modelfile:
cat > Modelfile << 'EOF'
FROM qwen3:32b
# Optimal for reasoning
PARAMETER temperature 0.7
PARAMETER top_p 0.8
PARAMETER num_ctx 32768
# System prompt for technical tasks
SYSTEM """You are Qwen 3, a highly capable AI assistant created by Alibaba Cloud.
For complex problems:
1. Analyze the problem systematically
2. Consider multiple approaches
3. Show your reasoning clearly
4. Verify your solution before finalizing
Be precise, thorough, and helpful."""
EOF
# Create custom model
ollama create qwen3-optimized -f Modelfile
# Run optimized version
ollama run qwen3-optimized
Why does Qwen3 forget the start of long prompts? (the num_ctx gotcha)
This is the bug that quietly ruins more local Qwen3 setups than any hardware issue. By default, Ollama caps the context window at a small value (historically 2,048, more recently 4,096 tokens) regardless of the 128K–256K the model itself supports. When your conversation, document, or agent loop exceeds that cap, Ollama silently truncates from the beginning — no error, no warning. The symptom is a model that "forgets" your instructions or the top of a pasted file, and people wrongly blame Qwen3's quality when the real culprit is the runtime default.
The fix is to set num_ctx explicitly. A one-off override inside a session or via the API gets reset when the model unloads, so the durable fix is to bake it into a Modelfile:
# Durable fix — bake a larger context into a custom model
cat > Modelfile << 'EOF'
FROM qwen3:8b
PARAMETER num_ctx 32768
EOF
ollama create qwen3-32k -f Modelfile
ollama run qwen3-32k
A few things worth knowing so you don't trip over the override order:
- Modelfile
PARAMETER num_ctxwins over theOLLAMA_CONTEXT_LENGTHenvironment variable, which in turn wins over the built-in default. - Bigger context costs VRAM. Going from 4K to 32K context on the 8B model adds roughly 1–2GB of KV-cache memory, so leave headroom or you'll spill into system RAM and crawl.
- You rarely need the full 128K/256K locally. For most chat, coding, and RAG work, 16K–32K is the sweet spot between recall and speed. Reserve the very long contexts for whole-repo or whole-document tasks.
If you're on a tight 8GB card, this trade-off between context size and quantization is exactly the balancing act covered in our guide to the best local AI models for 8GB RAM, which walks through how far you can push num_ctx before performance falls off a cliff.
Thinking Mode Deep Dive
Qwen 3 features a dual-mode architecture that lets you switch between deep reasoning and fast responses.
How Thinking Mode Works
When enabled, Qwen 3 generates internal reasoning before the final answer:
- Problem Analysis: Breaks down the question into components
- Approach Exploration: Considers multiple solution paths
- Reasoning Chain: Works through the logic step by step
- Verification: Checks the answer before responding
- Final Response: Delivers the clean answer
This is similar to DeepSeek R1's chain-of-thought but optimized for Qwen's architecture.
When to Use Each Mode
Use Thinking Mode (/set think) for:
- Complex mathematics
- Multi-step coding problems
- Logical reasoning puzzles
- Analysis that requires verification
- Educational explanations
Use Non-Thinking Mode (/set nothink) for:
- Simple factual questions
- Quick translations
- General conversation
- Time-sensitive responses
- High-throughput applications
Thinking Budget Control
Advanced users can allocate computational resources:
# Python API example with thinking budget
import ollama
response = ollama.chat(
model='qwen3:32b',
messages=[{
'role': 'user',
'content': 'Solve this step by step with careful reasoning...'
}],
options={
'temperature': 0.7,
'num_ctx': 32768,
'num_predict': 8192 # Allow space for thinking
}
)
VRAM Requirements: Complete Guide
Dense Models by Quantization
| Model | FP16 | Q8_0 | Q5_K_M | Q4_K_M | Minimum GPU |
|---|---|---|---|---|---|
| Qwen3-0.6B | 1.2GB | 0.8GB | 0.6GB | 0.5GB | Any 4GB |
| Qwen3-1.7B | 3.4GB | 2GB | 1.5GB | 1.2GB | GTX 1060 |
| Qwen3-4B | 8GB | 5GB | 3.5GB | 3GB | RTX 3060 6GB |
| Qwen3-8B | 16GB | 9GB | 7GB | 5-6GB | RTX 3060 12GB |
| Qwen3-14B | 28GB | 15GB | 11GB | 10GB | RTX 4070 16GB |
| Qwen3-32B | 64GB | 34GB | 24GB | 20GB | RTX 4090 24GB |
MoE Models
| Model | Total Params | Q4_K_M VRAM | Hardware Required |
|---|---|---|---|
| Qwen3-30B-A3B | 30B | 19-24GB | RTX 4090 or Mac 64GB |
| Qwen3-235B-A22B | 235B | 140GB+ | 2x H100 or 4x A100 |
Recommended Configurations
| Budget | Hardware | Best Model | Performance |
|---|---|---|---|
| $300 | RTX 3060 12GB | qwen3:8b Q4 | 30 tok/s |
| $500 | RTX 4060 Ti 16GB | qwen3:14b Q4 | 28 tok/s |
| $800 | RTX 4070 Ti Super 16GB | qwen3:14b Q5 | 32 tok/s |
| $1,600 | RTX 4090 24GB | qwen3:32b Q4 | 22 tok/s |
| $1,600 | RTX 4090 24GB | qwen3:30b-a3b | 25 tok/s |
Apple Silicon Performance
| Mac | Memory | Best Model | Performance |
|---|---|---|---|
| M1/M2 8GB | 8GB | qwen3:4b Q4 | 25 tok/s |
| M1/M2 16GB | 16GB | qwen3:8b Q4 | 18 tok/s |
| M2/M3 Pro 32GB | 32GB | qwen3:14b Q5 | 20 tok/s |
| M3 Max 64GB | 64GB | qwen3:32b Q4 | 18 tok/s |
| M3 Max 128GB | 128GB | qwen3:30b-a3b | 15 tok/s |
MoE Architecture Deep Dive
Understanding Mixture-of-Experts helps you choose between dense and MoE models.
How MoE Works
- Expert Network: Model contains 128 "expert" sub-networks
- Router: Each token goes through a routing mechanism
- Expert Selection: Router selects 8 of 128 experts for that token
- Computation: Only selected experts process the token
- Aggregation: Expert outputs are combined for final result
Qwen 3 MoE Specifications
| Component | Qwen3-30B-A3B | Qwen3-235B-A22B |
|---|---|---|
| Total Parameters | 30B | 235B |
| Active Parameters | 3B | 22B |
| Expert Count | 128 | 128 |
| Active Experts | 8 | 8 |
| Routing | Token-level | Token-level |
| Memory (Q4) | 19-24GB | 140GB+ |
Qwen3-Next Architecture (Preview)
The Qwen3-Next variant previews future architecture:
- 512 routed experts + 1 shared expert (vs 128 in standard)
- 10 active experts per token (vs 8)
- Multi-token prediction for faster inference
- Hybrid attention mechanism
This is where Qwen 3.5 is heading—more experts, better routing, faster generation.
When to Use MoE vs Dense
Choose MoE (30B-A3B) when:
- You have exactly 24GB VRAM
- You need 30B-class quality
- Throughput matters more than latency
- Running multiple concurrent requests
Choose Dense (32B) when:
- You want simpler deployment
- You need consistent latency
- You're fine-tuning the model
- Debugging model behavior
Integration Options
Python with Ollama API
import ollama
# Basic chat
response = ollama.chat(
model='qwen3:32b',
messages=[{
'role': 'user',
'content': 'Explain quantum computing in simple terms'
}]
)
print(response['message']['content'])
# Streaming
for chunk in ollama.chat(
model='qwen3:32b',
messages=[{'role': 'user', 'content': 'Write a Python quicksort'}],
stream=True
):
print(chunk['message']['content'], end='', flush=True)
OpenAI-Compatible API
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:11434/v1",
api_key="ollama"
)
response = client.chat.completions.create(
model="qwen3:32b",
messages=[{"role": "user", "content": "Hello!"}],
temperature=0.7
)
print(response.choices[0].message.content)
Open WebUI (ChatGPT-like Interface)
docker run -d -p 3000:8080 \
--add-host=host.docker.internal:host-gateway \
-v open-webui:/app/backend/data \
--name open-webui \
ghcr.io/open-webui/open-webui:main
Access at http://localhost:3000 and select qwen3:32b from the dropdown.
VS Code with Continue Extension
- Install Continue extension
- Configure Ollama provider:
{
"models": [
{
"title": "Qwen 3 32B",
"provider": "ollama",
"model": "qwen3:32b",
"contextLength": 32768
}
]
}
vLLM for Production
pip install vllm
python -m vllm.entrypoints.openai.api_server \
--model Qwen/Qwen3-32B-Instruct \
--max-model-len 32768
SGLang for High Throughput
pip install "sglang[all]"
python -m sglang.launch_server \
--model-path Qwen/Qwen3-32B-Instruct \
--port 30000
Best Use Cases for Qwen 3
1. Multilingual Applications
With 119 languages, Qwen 3 excels at:
- Translation services
- Multilingual chatbots
- Global content creation
- Cross-language analysis
2. STEM and Technical Work
Top benchmark scores make it ideal for:
- Mathematical problem solving
- Scientific analysis
- Technical documentation
- Research assistance
3. Code Generation
CodeForces ELO 2,056 and LiveCodeBench 70.7% mean excellent:
- Algorithm implementation
- Code review and debugging
- Refactoring suggestions
- Multi-file code generation
For serious coding work there's a dedicated model worth knowing about. The flagship Qwen3-Coder-480B-A35B needs 250GB+ of memory and is out of reach for a single workstation, but Alibaba also released Qwen3-Coder-30B-A3B-Instruct (sometimes called "Qwen3-Coder Flash") — a Mixture-of-Experts model with 30B total but only ~3.3B active parameters. That makes it genuinely runnable on a 24GB GPU (or a 32GB+ Mac) at Q4, while still delivering strong agentic-coding performance, native 256K context (extendable toward 1M with YaRN), and a tool-calling format built for assistants like Cline and Qwen Code:
# Locally-runnable coder MoE (~3.3B active) — fits a 24GB GPU at Q4
ollama pull qwen3-coder:30b
ollama run qwen3-coder:30b
If your machine tops out at 16GB, a dense 14B-class model is often the better coding pick than a heavier MoE — our breakdown of the best 14B coding models compares Qwen3-14B against the alternatives at that VRAM tier. For the full feature set, benchmarks, and agent-integration notes on the dedicated coder line, see our Qwen3-Coder model page.
4. Educational Content
Thinking mode enables:
- Step-by-step tutorials
- Concept explanations
- Practice problem generation
- Adaptive learning assistance
5. Business Analysis
Strong reasoning for:
- Market analysis
- Financial modeling
- Strategic planning
- Report generation
Troubleshooting Common Issues
Model Runs Out of Memory
# Use smaller quantization
ollama pull qwen3:32b-q4_0
# Reduce context
ollama run qwen3:32b --num-ctx 8192
# Try MoE variant (more efficient)
ollama run qwen3:30b-a3b
Slow Generation Speed
# Check GPU is being used
ollama ps
# Force GPU layers
OLLAMA_NUM_GPU=999 ollama run qwen3:32b
# Verify CUDA
nvidia-smi
Thinking Mode Not Working
# Make sure you're in interactive mode
ollama run qwen3:32b
# Then enable thinking
/set think
Poor Multilingual Output
# Increase context for better language handling
/set parameter num_ctx 16384
# Use system prompt to specify language
Key Takeaways
- Qwen 3-32B delivers 72B-class performance on a single RTX 4090
- 119 languages make it the best multilingual open model
- MoE 30B-A3B gives 30B quality with 3B inference cost
- Thinking mode enables deep reasoning like DeepSeek R1
- Apache 2.0 license means free commercial use
- Performance scaling means smaller models punch above their weight
- Easy setup with Ollama gets you running in under 5 minutes
Next Steps
- Compare with DeepSeek R1 for reasoning tasks
- Compare with Llama 4 for creative writing
- Learn about MoE architecture in depth
- Check VRAM requirements for your hardware
- Build AI agents with Qwen 3
- Set up RAG for document chat
Qwen 3 represents the cutting edge of open-source AI from Alibaba. Whether you need the efficiency of the 30B-A3B MoE model, the raw capability of the 32B dense model, or the lightweight speed of the 8B variant, Qwen 3 delivers state-of-the-art performance that runs entirely on your own hardware. The combination of 119 languages, thinking mode, and Apache 2.0 licensing makes it an exceptional choice for both personal and commercial applications.
Ollama’s running. Here’s what to build with it.
Go from “ollama run” to RAG apps, agents, and fine-tuned models — structured and hands-on. First chapter free.
Liked this? 20 full AI courses are waiting.
From fundamentals to RAG, agents, MCP servers, voice AI, and production deployment with real GitHub repos. First chapter free, every course.
Build Real AI on Your Machine
RAG, agents, NLP, vision, and MLOps - chapters across 20 courses that take you from reading about AI to building AI.
Want structured AI education?
20 courses, 495+ chapters, from $9. Understand AI, don't just use it.
Continue Your Local AI Journey
Comments (0)
No comments yet. Be the first to share your thoughts!