Qwen/Qwen3-4B

Run locally on Apple devices with Mirai

Type
local
From
Alibaba
Quantization
No
Parameters
4B
Size
7.5 GB
Source
Hugging Face

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.

Explore all local models
1
Choose framework
2
Run the following command to install Mirai SDK
spm https://github.com/trymirai/uzu.git
3
Apply code
1import Uzu23public func runChat() async throws {4    let engineConfig = EngineConfig.create()5    let engine = try await Engine.create(config: engineConfig)67    guard let model = try await engine.model(identifier: "Qwen/Qwen3-4B") else {8        return9    }10    for try await update in try await engine.download(model: model).iterator() {11        print("Download progress: \(update.progress())")12    }1314    let messages = [15        ChatMessage.system().withText(text: "You are a helpful assistant"),16        ChatMessage.user().withText(text: "Tell me a short, funny story about a robot")17    ]18    let session = try await engine.chat(model: model, config: .create())19    let stream = await session.replyWithStream(input: messages, config: .create())20    var message: ChatMessage? = nil21    for try await update in stream.iterator() {22        switch update {23        case .replies(let replies):24            message = replies.last?.message25        case .error(let error):26            print("Error: \(error)")27        }28    }29    print("Text: \(message?.text() ?? "empty")")30}

Other local models from Alibaba