Qwen 3
- Vendor
- Alibaba
- Parameters
- 4B
- Size
- 7.5 GB
$ brew install mirai$ mirai --model Qwen/Qwen3-4BBenchmarks
Qwen 3
Apple M4 Max 128GB
0.78 s
lower is better ↓
Qwen 3
Apple M4 Max 128GB
56 t/s
higher is better ↑
Qwen 3
Apple M4 Max 128GB
8.42 GB
lower is better ↓
Benchmarked 7 Aug 2026
Integrate with SDK
https://github.com/trymirai/uzu-swift
| 1 | import Foundation |
| 2 | import Uzu |
| 3 | |
| 4 | public func runChat() async throws { |
| 5 | let engineConfig = EngineConfig.create() |
| 6 | let engine = try await Engine.create(config: engineConfig) |
| 7 | |
| 8 | guard let model = try await engine.model(identifier: "alibaba:qwen3.5:0.8b:mirai:mirai-m:4") else { |
| 9 | return |
| 10 | } |
| 11 | for try await update in try await engine.download(model: model).iterator() { |
| 12 | print(String(format: "\r\u{001B}[2KDownload progress: %.2f%%", update.progress() * 100), terminator: "") |
| 13 | fflush(stdout) |
| 14 | } |
| 15 | print() |
| 16 | |
| 17 | let messages = [ |
| 18 | ChatMessage.system().withText(text: "You are a helpful assistant"), |
| 19 | ChatMessage.user().withText(text: "Tell me a short, funny story about a robot") |
| 20 | ] |
| 21 | let session = try await engine.chat(model: model, config: .create()) |
| 22 | let stream = await session.replyWithStream(input: messages, config: .create()) |
| 23 | var message: ChatMessage? = nil |
| 24 | for try await update in stream.iterator() { |
| 25 | switch update { |
| 26 | case .replies(let replies): |
| 27 | let reply = replies.last |
| 28 | message = reply?.message |
| 29 | print("Generated tokens: \(reply?.stats.tokensCountOutput ?? 0)") |
| 30 | case .error(let error): |
| 31 | print("Error: \(error)") |
| 32 | } |
| 33 | } |
| 34 | print("Reasoning: \(message?.reasoning() ?? "empty")") |
| 35 | print("Text: \(message?.text() ?? "empty")") |
| 36 | } |
| 37 | |
Details
Qwen3-4B is a 4-billion-parameter dense causal language model from Alibaba's Qwen team, part of the third-generation Qwen series. Built on the Qwen3-4B-Base foundation, it has undergone both pretraining and post-training to deliver strong performance in a compact form factor.
Dual-Mode Reasoning
A standout feature of Qwen3-4B is its ability to seamlessly switch between thinking mode and non-thinking mode within a single model. In thinking mode, the model engages in explicit chain-of-thought reasoning — ideal for complex math, coding, and logic tasks — wrapping its internal deliberation in `<think>...</think>` blocks before producing a final answer. In non-thinking mode, it behaves like a traditional instruct model, offering fast, efficient responses for general-purpose dialogue. Users can toggle between modes via API parameters or inline `/think` and `/no_think` tags in conversation.
Architecture & Specifications
- Parameters: 4.0B total (3.6B non-embedding)
- Layers: 36, using Grouped Query Attention (32 Q heads, 8 KV heads)
- Context Length: 32,768 tokens natively; up to 131,072 tokens via YaRN RoPE scaling
Key Capabilities
- Reasoning: Surpasses prior Qwen2.5 instruct models in mathematics, code generation, and commonsense reasoning
- Human Preference Alignment: Strong performance in creative writing, role-playing, multi-turn dialogue, and instruction following
- Agent & Tool Use: Precise integration with external tools in both thinking and non-thinking modes, with first-class support via Qwen-Agent and MCP configurations
- Multilingual: Supports 100+ languages and dialects with robust multilingual instruction following and translation
Deployment
Qwen3-4B is compatible with Hugging Face Transformers (v4.51.0+), vLLM, SGLang, Ollama, LM Studio, llama.cpp, and other popular inference frameworks, making it straightforward to deploy as an OpenAI-compatible API endpoint or run locally on consumer hardware.
Licensed under Apache 2.0, Qwen3-4B offers an accessible entry point into the Qwen3 family for developers seeking capable reasoning in a lightweight package.