Qwen is Alibaba’s family of open-weight models released under Apache 2.0, ranging from 0.8B to hundreds of billions of parameters and covering around 200 languages, which makes it popular for multilingual services. This guide goes from choosing among general, coding, vision and embedding models to running locally, thinking mode, multilingual embeddings and the API.
Qwen Practical Examples
Examples of running Qwen locally, tool calling, a coding agent and fine-tuning.
View practical examples →Qwen (通义千问) is Alibaba’s LLM family. Alongside general models it releases coding (Coder), vision (VL) and embedding models in the same family, so you can build RAG, agents and coding tools entirely from one vendor’s models.
| When | Key models | What changed |
|---|---|---|
| April 2025 | Qwen3 | 0.6B-32B dense + 30B-A3B and 235B-A22B MoE, 119 languages, thinking mode |
| 2025 | Qwen3-Coder, Qwen3-VL, Qwen3 Embedding | Dedicated coding, vision and embedding models |
| February 2026 | Qwen3.5 | Gated DeltaNet + sparse MoE architecture, image input, 201 languages and dialects, 256K context |
| April 2026 | Qwen3.6 | 27B dense and 35B-A3B MoE |
| August 2026 | Qwen3.8 | Open-weight 27B (Apache 2.0) and the commercial top model Qwen3.8-Max, stronger at agent tasks |
To build a RAG system that searches company documents and answers with citations using Qwen3 Embedding and Qwen3.5, see the company-docs RAG tutorial with Qwen.
| Model | Ollama tag (size) | Input | Best for |
|---|---|---|---|
| Qwen3.8 27B | qwen3.8:27b (about 18 GB) | Text, image, video | Latest general and agent work, 24 GB GPU |
| Qwen3.6 | qwen3.6:27b, qwen3.6:35b | Text, image | The generation before 3.8; a settled choice |
| Qwen3.5 small | qwen3.5:0.8b-qwen3.5:9b (1.0-6.6 GB) | Text, image | Laptops and edge, classification and extraction, RAG answers |
| Qwen3.5 large | qwen3.5:27b (17 GB), 35b (24 GB, MoE), 122b (81 GB, MoE) | Text, image | High-quality servers |
| Qwen3-Coder | qwen3-coder:30b, 480b | Code | Coding agents and code review |
| Qwen3-VL | qwen3-vl:2b-235b | Text, image | Vision work focused on documents and screens |
| Qwen3 Embedding | qwen3-embedding:0.6b, 4b, 8b | Text | Multilingual search and RAG embeddings |
35B-A3B in a name means an MoE with 35B total and 3B active per token. Speed follows active parameters; the memory you need follows total parameters. On Apple Silicon, MLX tags such as qwen3.5:9b-mlx are faster.
| Models | License | What it means |
|---|---|---|
| Open-weight Qwen (3.8 27B, 3.6, 3.5, Coder, VL, Embedding) | Apache 2.0 | Free commercial use, modification and redistribution; keep the license notice |
| Top models such as Qwen3.8-Max | Commercial (no public weights) | Paid use through the Alibaba Cloud Model Studio API |
Check the LICENSE file of each repository you download from Hugging Face or ModelScope. Even within one generation, availability can differ by size and purpose.
ollama pull qwen3.5:9b # laptop default (about 6.6 GB)
ollama pull qwen3.8:27b # 24 GB GPU (about 18 GB)
ollama pull qwen3-embedding:0.6b # embeddings
ollama pull qwen3-coder:30b # coding
ollama run qwen3.5:9b "Compare Kubernetes HPA and VPA in a table"Qwen3.5 and later support a 256K context, but Ollama runs with a default sized to your GPU memory (4K below 24 GiB). Raise num_ctx for long documents.
Qwen3 and later can switch thinking mode on and off, and Qwen3.8 has it on by default. In Ollama, control it per request with think; the reasoning arrives separately in message.thinking.
from ollama import chat
question = "With 100 million rows in the orders table, what index strategy makes a last-30-days revenue query fast?"
fast = chat(model="qwen3.8:27b", messages=[{"role": "user", "content": question}], think=False)
print("[fast answer]", fast.message.content[:300])
deep = chat(model="qwen3.8:27b", messages=[{"role": "user", "content": question}], think=True)
print("[reasoning]", (deep.message.thinking or "")[:300], "...")
print("[deep answer]", deep.message.content[:300])from ollama import chat
resp = chat(
model="qwen3.5:9b",
messages=[{
"role": "user",
"content": "Which metrics and times in this dashboard screenshot look anomalous?",
"images": ["./grafana.png"],
}],
think=False,
)
print(resp.message.content)from ollama import chat
def get_exchange_rate(base: str, target: str) -> dict:
"""Get the current exchange rate between two currencies.
Args:
base: Base currency code (e.g. USD)
target: Target currency code (e.g. EUR)
"""
return {"base": base, "target": target, "rate": 0.92}
messages = [{"role": "user", "content": "How much is 1,200 dollars in euros?"}]
resp = chat(model="qwen3.5:9b", messages=messages, tools=[get_exchange_rate], think=False)
messages.append(resp.message)
for call in resp.message.tool_calls or []:
result = get_exchange_rate(**call.function.arguments)
messages.append({"role": "tool", "tool_name": call.function.name, "content": str(result)})
print(chat(model="qwen3.5:9b", messages=messages, think=False).message.content)Qwen3 Embedding is a retrieval embedding model supporting over 100 languages. The 0.6B model supports up to 1024 dimensions (choose 32-1024) and 32K-token inputs. The rule is add an instruction to search queries, not to documents.
import math
from ollama import embed
TASK = "Given a web search query, retrieve relevant passages that answer the query"
def query_text(q: str) -> str:
return f"Instruct: {TASK}\nQuery:{q}" # instruction on queries only
docs = ["Employees get 15 days of paid leave after one year.", "Return your laptop to IT when you leave.", "Request VPN access in the company portal."]
doc_vecs = embed(model="qwen3-embedding:0.6b", input=docs).embeddings # documents as they are
q_vec = embed(model="qwen3-embedding:0.6b", input=[query_text("How many vacation days do I get?")]).embeddings[0]
def cosine(a, b):
return sum(x * y for x, y in zip(a, b)) / (math.sqrt(sum(x * x for x in a)) * math.sqrt(sum(y * y for y in b)))
for doc, vec in sorted(zip(docs, doc_vecs), key=lambda p: -cosine(q_vec, p[1])):
print(f"{cosine(q_vec, vec):.3f} {doc}")Models without public weights, such as Qwen3.8-Max, are used through Alibaba Cloud Model Studio’s OpenAI-compatible API. The endpoint depends on region and workspace, so use the value shown in the console.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DASHSCOPE_API_KEY"],
# e.g. the US (Virginia) region. Singapore, Tokyo and others use an address with your workspace ID
base_url="https://dashscope-us.aliyuncs.com/compatible-mode/v1",
)
resp = client.chat.completions.create(
model="qwen3.8-max",
messages=[{"role": "user", "content": "Make a checklist for adopting a service mesh"}],
)
print(resp.choices[0].message.content)How thinking mode is controlled and how API models are priced differ by model, so check the Model Studio documentation for the model you use.
| Symptom | Cause | Fix |
|---|---|---|
| Long reasoning before every answer | Thinking is on by default in Qwen3.8 | think=False |
| Irrelevant search results | No instruction on queries, or an instruction added to documents too | Apply Instruct: ...\nQuery: to queries only |
| Forgets the start of long documents | Ollama’s default context (4K, etc.) | Raise num_ctx or OLLAMA_CONTEXT_LENGTH |
| Answers drift into another language | Small model, no language set in the system prompt | State the answer language explicitly; use 9B or larger |
| Model Studio 401 / 404 | Region endpoint does not match the key or workspace | Match base_url to the console’s region |
Open-weight models such as Qwen3.8 27B, Qwen3.6, Qwen3.5, Qwen3-Coder and Qwen3 Embedding are Apache 2.0, so commercial use, modification and redistribution are free. Top models such as Qwen3.8-Max are commercial with no public weights and are only available through the Alibaba Cloud Model Studio API.
Qwen3.5 and later were trained on about 200 languages and dialects, and quality in major languages is solid for production use. Quality varies a lot with model size, so if non-English answer quality matters, start at 9B or larger and evaluate with real questions from your users.
Thinking mode is on by default in Qwen3.8. In Ollama, pass think=False to chat to turn it off per request. For simple Q&A or classification that needs no deep reasoning, turning it off makes responses faster.
Yes. Prefix search queries with an instruction in the form "Instruct: task description\nQuery:question", and leave documents without one. Embedding queries without the instruction still works, but retrieval accuracy can drop.
35B is an MoE model (35B-A3B) that computes only about 3B parameters per token, so it responds much faster than the 27B dense model. Memory still follows total parameters: about 24 GB for 35B and 17 GB for 27B in Ollama. Quality depends on the task, so evaluate both.