Skip to content
LearnAI

5.4Qwen (Alibaba): Qwen2.5, Qwen3 and beyond

The family with a model for every size and modality, from 0.6B on a phone to 2.4T in a data center, and how hybrid thinking and hybrid attention came to define it.

⏱ 13 minIntermediate

A model for every machine

Most labs release one or two flagship sizes. Qwen releases a whole spectrum: tiny models that run on a phone, mid-size models for a single GPU, giant MoEs for clusters, and specialized variants for code, math, vision, audio and speech. Nearly all are under Apache 2.0. That breadth is why, when researchers need a base model to fine-tune or distill into, they so often pick Qwen. DeepSeek’s R1-Distill models, for example, are mostly Qwen2.5 checkpoints underneath.

Breadth matters for a practical reason. If you fine-tune a 7B model for a product and later need more quality, you can move to the 14B or 32B sibling with the same tokenizer, chat template and behavior, and reuse your data and evaluation code unchanged. Researchers benefit too: a sweep of sizes trained on the same data is a ready-made scaling experiment, which is why so many papers on fine-tuning, quantization and reasoning report results “on Qwen” at several sizes.

The family’s history is also a compact tour of every big idea in this part of the course: dense scaling, MoE, hybrid reasoning modes, multimodality and linear attention.

ANALOGY· One factory, many trim levels

Think of Qwen as a car maker that ships every model in many trim levels. The engine design (the Transformer architecture and training recipe) is shared, so improvements show up everywhere at once. The trim level is the size: a 0.6B city car, a 32B family sedan, a 235B truck.

Dense models are like engines where every cylinder fires on every stroke. MoE models are like big engines with cylinder deactivation: a huge block (the total parameters) of which only a few cylinders fire at a time (the active parameters). Hybrid thinking is a sport/eco switch on the dashboard: the same car can sprint through a hard problem or cruise through small talk.

Qwen2.5: the workhorse

Qwen2.5 (September 2024) was a family of dense models from 0.5B to 72B, trained on 18T tokens, up from 7T for Qwen2. It used standard modern ingredients: grouped-query attentionGrouped-query attention (GQA)Attention in which groups of query heads share one key/value head, shrinking the KV cache. MQA is the extreme case of one shared KV head., RoPERotary position embedding (RoPE)Encodes position by rotating query and key vectors by angles proportional to their position, so attention depends on relative distance., SwiGLU and RMSNorm. The technical report emphasizes data more than architecture: more and cleaner data, more math and code, and a large post-training stage of supervised fine-tuning plus multi-stage RL. Specialized siblings (Qwen2.5-Coder, Qwen2.5-Math, Qwen2.5-VL) followed, and Qwen2.5-Omni (March 2025) introduced the Thinker–TalkerThinker–Talker architectureAn omni-model design (Qwen2.5-Omni, Qwen3-Omni) where a Thinker Transformer understands all inputs and writes text, and a Talker reads its hidden states to stream speech tokens. design for speech, covered below.

Qwen3: hybrid thinking at every size

Qwen3 (29 April 2025) is where the family took its modern shape:

  • Six dense models: 0.6B, 1.7B, 4B, 8B, 14B and 32B (32K context for the three smallest, 128K for the rest).
  • Two MoE models: Qwen3-30B-A3B (48 layers, 128 experts, 8 active) and Qwen3-235B-A22B (94 layers, 128 experts, 8 active). The “A” number is the active parameter count.
  • About 36T pretraining tokens in 119 languages and dialects, double Qwen2.5’s data and up from 29 languages.
  • Apache 2.0 for all of them.

The headline feature was hybrid thinkingHybrid thinking modeOne model that can either reason step by step before answering (thinking) or answer directly (non-thinking), switched per request, e.g. Qwen3's /think and /no_think.. One set of weights can either think step by step inside a <think> block before answering, or answer immediately. You flip it per request with enable_thinking, or turn by turn by adding /think or /no_think to a message. The Qwen3 report also describes a thinking budget: because the model learned both modes, you can cap how many tokens it may spend thinking and it still produces a coherent answer, trading accuracy for latency smoothly.

How do you train one model to do both? Per the Qwen3 report, the flagship models went through four post-training stages: a long chain-of-thought cold start, reasoning RL (see reasoning models), a “thinking mode fusion” stage that mixes thinking and non-thinking data with the /think and /no_think flags, and a general RL stage. The small models learned from the big ones by strong-to-weak distillation instead of running the full pipeline.

Qwen3-Coder-480B-A35B (July 2025) applied the recipe to agentic coding: 160 experts with 8 active, 256K native context, extendable to 1M. It is a good example of how Qwen reuses one architecture for specialist models: same building blocks, a different data mix and post-training focus.

Explore the family

INTERACTIVEThe Qwen family, from tiny to huge
Modality
Type
1B10B100B1TQwen2.5-0.5BQwen2.5-1.5BQwen2.5-3BQwen2.5-7BQwen2.5-14BQwen2.5-32BQwen2.5-72BQwen2.5-Omni-7BQwen3-0.6BQwen3-1.7BQwen3-4BQwen3-8BQwen3-14BQwen3-32BQwen3-30B-A3BQwen3-235B-A22BQwen3-Coder-480B-A35BQwen3-Next-80B-A3BQwen3-VL-8BQwen3-VL-235B-A22BQwen3-Omni-30B-A3BQwen3.5-397B-A17BQwen3.6-35B-A3BQwen3.8-27BQwen3.8-Flash-NextQwen3.8-2.4T-A95B

Filled dot = total parameters. Hollow dot = active per token (MoE only); the bar between them is the part of the model that sits idle for any given token. Colors: ■ text, ■ vision-language, ■ omni, ■ coder. Click a row for details.

Qwen3-235B-A22B

MoEText
total / active
235B / 22B
released
2025-04
native context
128K
license
Apache 2.0

94 layers, 128 experts with 8 active, GQA 64Q/4KV. The July 2025 “2507” refresh split it into separate Instruct and Thinking checkpoints with 256K native context.

Source: huggingface.co/Qwen/Qwen3-235B-A22B-Instruct-2507
Every row is an open-weight Qwen model on a log scale. Filled dot = total parameters, hollow dot = active per token, so long bars are very sparse MoEs. Filter by modality or type, and click a row for its details and source.

Things to try:

  1. Filter Type → MoE. Compare Qwen3-30B-A3B with Qwen3-Next-80B-A3B: same 3B active, but Next stores almost 3× more parameters.
  2. Look at the Qwen3.8-2.4T-A95B row. Its active slice (95B) alone is larger than Qwen2.5’s biggest dense model.
  3. Filter Omni and VL to see which sizes got multimodal versions.

Qwen3-Next: the architecture pivot

Qwen3-Next-80B-A3B (September 2025) was an experiment that became the template for everything after it. Two changes stand out.

Hybrid attention. Its 48 layers are arranged as 12 blocks of three Gated DeltaNet layers followed by one Gated Attention layer, a 3:1 ratio of linear attentionLinear attentionAttention variants (e.g. Gated DeltaNet, Kimi Delta Attention, lightning attention) that keep a fixed-size recurrent state instead of a growing KV cache, so cost grows linearly with sequence length. Usually mixed with a few full-attention layers. to full attention. Gated DeltaNet is a linear-attention layer: instead of caching a key and value for every past token, it maintains a fixed-size state matrix that it updates with each new token (a “delta rule” with a learned forgetting gate). Memory and per-token compute stay constant as the context grows. The occasional full-attention layer keeps the ability to look up exact earlier tokens. The result: 262,144 tokens native context, extendable to about 1M.

Ultra-sparse MoE. 512 experts, of which 10 routed plus 1 shared are active: about 3B active out of 80B. It was trained on 15T tokens and uses multi-token prediction.

Multimodal Qwen: VL and Omni

Qwen3-VL (autumn 2025) added vision to the Qwen3 backbones in dense (2B, 4B, 8B, 32B) and MoE (30B-A3B, 235B-A22B) sizes, with 256K native context for long videos and documents. (See vision-language models.)

Qwen3-Omni-30B-A3B (September 2025) handles text, images, audio and video as input and produces both text and streaming speech. It uses the Thinker–Talker split introduced in Qwen2.5-Omni: the Thinker is a language model that understands all the inputs and writes text; the Talker is a separate model that reads the Thinker’s internal representations and generates speech tokens in real time. Because the Talker conditions on the Thinker’s hidden states rather than just its words, the speech can follow the meaning, and both can stream at once. It covers 119 text languages, 19 for speech input and 10 for speech output. (See omni models.)

Qwen3.5 to Qwen3.8, and Qwen4

From 2026, the Qwen3-Next layout went mainstream and every new release was natively multimodal unless stated otherwise:

  • Qwen3.5-397B-A17B (about February 2026): 60 layers in the same 3:1 DeltaNet/attention pattern, 512 experts (10 + 1 active), a native vision-language model, and 201 languages and dialects.
  • Qwen3.6-35B-A3B (April 2026): a small agentic-coding MoE with 256 experts (8 + 1 active), image and video input. A dense Qwen3.6-27B followed; the larger “Plus” models stayed closed.
  • Qwen3.8 (August 2026): the first open-weight Qwen at “Max” scale, Qwen3.8-2.4T-A95B: 92 layers, 512 experts (10 + 1 active), 262K native context extendable to about 1M, text-only, and released under a custom qwen3.8-max license rather than Apache 2.0. Alongside it came Qwen3.8-27B, a dense, Apache-licensed vision-language model that Alibaba claims matches its closed Qwen3.7-Plus.
  • Qwen3.8-Flash-Next (late August 2026): an experimental preview of the Qwen4 architecture, with 125B MoE parameters (6B active), a 51B “n-gram embedding” table and a 4B MTP module. It replaces the full-attention layers with “Qwen Sparse Attention” and uses a new qwen-community-1.0 license.

Qwen4-Max launched in November 2026 as an API model. As of early December 2026, press reports say Alibaba has promised open weights for smaller Qwen4 models but has not published any or given a date; treat any claims to the contrary as unverified until they appear on Hugging Face.

MATH CORNER · optionalWhy hybrid attention saves so much memory

KV cache of a full-attention model. Qwen3-235B-A22B has L=94L = 94 layers, nkv=4n_{kv} = 4 KV heads and head dimension dh=128d_h = 128. Per token it caches a key and a value per KV head per layer:

KV per token=L×2×nkv×dh=94×2×4×128=96,256 numbers\text{KV per token} = L \times 2 \times n_{kv} \times d_h = 94 \times 2 \times 4 \times 128 = 96{,}256 \text{ numbers}

In BF16 that is about 192 KB per token, so a single 128K-token conversation needs about 192 KB×131,072≈25192\text{ KB} \times 131{,}072 \approx 25 GB of cache. GQA already helped here: with 64 separate KV heads (one per query head) it would be 16× more.

Hybrid 3:1 layout. Now keep the same per-layer numbers but make only 1 layer in 4 full attention, with the other 3 using linear attention whose state has a fixed size ss regardless of context length TT:

cache(T)≈14⋅(full-attention cache at T)+34L⋅s\text{cache}(T) \approx \tfrac{1}{4} \cdot (\text{full-attention cache at } T) + \tfrac{3}{4} L \cdot s
context TTall full attention3:1 hybrid (KV part)
32K≈ 6.3 GB≈ 1.6 GB
128K≈ 25 GB≈ 6.3 GB
1M≈ 202 GB≈ 50 GB

The linear layers add a constant (their state) that doesn’t grow with TT, so at long context the saving approaches 4×. Compute per token behaves similarly: full attention’s cost grows with TT, linear attention’s does not. This is a hypothetical illustration on Qwen3-235B’s dimensions; real hybrid models (Qwen3-Next, Qwen3.5) have their own head counts.

In code

Switching Qwen3’s thinking mode with Hugging Face Transformers:

from transformers import AutoTokenizer, AutoModelForCausalLM

name = "Qwen/Qwen3-8B"
tok = AutoTokenizer.from_pretrained(name)
model = AutoModelForCausalLM.from_pretrained(name, torch_dtype="auto", device_map="auto")

msgs = [{"role": "user", "content": "Is 391 prime? /no_think"}]   # soft switch per turn
text = tok.apply_chat_template(
    msgs, tokenize=False, add_generation_prompt=True,
    enable_thinking=True,          # hard switch: False disables thinking entirely
)
ids = tok(text, return_tensors="pt").to(model.device)
out = model.generate(**ids, max_new_tokens=512,
                     do_sample=True, temperature=0.7, top_p=0.8, top_k=20)
print(tok.decode(out[0][ids.input_ids.shape[1]:], skip_special_tokens=True))

The model card recommends temperature 0.6 and top-p 0.95 in thinking mode, 0.7 and 0.8 without thinking, and warns against greedy decoding.

COMMON MISCONCEPTIONS
  • “Qwen3-30B-A3B is a 3B model.” It computes like a 3B model per token but stores 30B parameters, so it needs the memory of a 30B model and knows more than a 3B one.
  • “/no_think makes the model dumber in general.” It skips the visible reasoning, which mainly hurts multi-step math and code. For chat, extraction and short answers it is faster and often just as good.
  • “Every Qwen model is Apache 2.0.” Most are, but Qwen2.5-72B and -3B used Qwen licenses, the Qwen3.8 flagship uses a custom license, and Qwen3.8-Flash-Next uses qwen-community-1.0. Qwen4-Max is not open at all so far.
  • “Linear attention replaced attention.” In Qwen3-Next and its successors, one layer in four is still full (or sparse) attention. Pure linear-attention models tend to struggle with exact recall over long contexts.

Check your understanding

0/4 answered
  1. Q1.What does the "A22B" in Qwen3-235B-A22B mean?

  2. Q2.Qwen3 lets you switch thinking with enable_thinking and with /think and /no_think. How do they relate?

  3. Q3.Qwen3-Next uses 3 Gated DeltaNet layers per 1 Gated Attention layer. What is the main benefit?

  4. Q4.In Qwen's Thinker–Talker design, what does the Talker do?

Further reading

Progress is saved in this browser only.
Type to search across all lessons and glossary terms.