Qwen/Qwen3.8-27B:原生视觉语言 27B 密集模型发布
英文标题:🤗 Qwen/Qwen3.8-27B
Qwen 发布 Qwen3.8-27B,这是基于 Qwen3.5 架构构建的 270 亿参数原生视觉语言密集模型,面向编程、专业工作、科研及长程 Agent 任务。该模型原生支持图像和视频理解,提供可开关的思考模式、`reasoning_effort` 推理深度控制及 `preserve_thinking` 历史推理保留能力,并支持最高扩展至 100 万 token 的上下文。基准测试显示,它在 SWE-bench Pro、DeepSWE 1.1、QwenSWEBench、CoWorkBench、OSWorld-Verified 和 WebArena-Verified 等多项 Agent 与软件工程任务中取得表中最佳成绩。对开发者而言,模型可通过 OpenAI 兼容的 Chat Completions API 以及 Transformers、vLLM、SGLang、TokenSpeed 等框架接入,官方托管版 Qwen Cloud 服务即将推出。
2.8 KB
403.0 KB
中文
Qwen3.8-27B
此仓库包含以后训练模型的权重及配置文件,格式为 Hugging Face Transformers。
这些文件兼容 Hugging Face Transformers、vLLM、SGLang、TokenSpeed 等。
对于希望获得免基础设施维护的托管式、可扩展推理服务的用户,官方 Qwen API 服务由 Qwen Cloud 提供。其中,Qwen3.8-27B 将以托管版本形式提供更多生产级功能,例如默认 100 万上下文长度、官方内置工具。更多信息请参阅 Qwen3.8-27B 概览。该服务即将推出,敬请关注后续更新。
继 Qwen3.5 和 Qwen3.6 系列在社区中获得广泛采用后,我们很高兴推出 Qwen3.8——迄今为止 Qwen 开放模型家族能力最强的一代。
Qwen3.8 建立在 Qwen3.5 的架构基础上,在编程、专业工作、科研和长程 Agent 任务方面实现了显著提升。Qwen3.8-27B 将这些进步带入一款紧凑、易部署的密集模型:这是一款原生视觉语言模型,能够理解图像和视频,支持灵活的思考控制,旨在以更高可靠性完成复杂的多步骤任务。
Qwen3.8 核心亮点
Qwen3.8-27B 具备以下增强:
- 核心能力:在编程、专业工作、科研和长程 Agent 任务等方面实现全面提升。
- Agent 执行:具备更强的自主规划能力,并能更好地处理环境反馈,从而更可靠地端到端完成任务。
- 下游兼容性:更广泛支持常用 harness 和开发工具,更易集成至现有技术栈。
- 灵活的思考控制:默认启用思考模式,且可按请求禁用;可通过
reasoning_effort调整推理深度,并通过preserve_thinking保留历史消息中的推理上下文。 - 视觉语言理解:原生支持图像和视频理解,覆盖 STEM 图表、文档以及小时级视频。
模型概览
- 类型:带视觉编码器的因果语言模型
- 训练阶段:预训练与后训练
- 语言模型
- 参数量:27B
- 隐藏层维度:5120
- Token 嵌入:248,320(填充后)
- 层数:64
- 隐藏层布局:16 ×(3 ×(Gated DeltaNet → FFN)→ 1 ×(Gated Attention → FFN))
- Gated DeltaNet:
- 线性注意力头数量:V 为 48,QK 为 16
- 头维度:128
- Gated Attention:
- 注意力头数量:Q 为 24,KV 为 4
- 头维度:256
- 旋转位置嵌入维度:64
- 前馈网络:
- 中间层维度:17,408
- LM 输出:248,320(填充后)
- MTP(多 Token 预测):采用多步训练
- 上下文长度:原生支持 262,144 token,并可扩展至 1,000,000 token。
基准测试结果
文本性能
| Qwen3.8-27B | Qwen3.6-27B | Qwen3.7-Plus | Muse Glimmer-30B | Opus4.6 Max | |---|---|---|---|---|---| | 编程 | | | | | | | Agent 终端编程 Terminal Bench 2.1 (Terminus) | 73.0 | 63.4 | 64.0 | 51.7 | 78.2 | | Agent 编程 SWE-bench Pro | 61.7 | 53.5 | 57.6 | 51.2 | 53.4 | | 仓库级代码生成 NL2Repo-Bench | 42.3 | 36.2 | 41.1 | -- | 47.6 | | Agent 编程 DeepSWE 1.1 | 42.2 | 13.3 | 14.2 | -- | -- | | 软件工程 QwenSWEBench | 79.0 | 49.3 | 59.2 | -- | 63.8 | | Agent | | | | | | | 长程办公室工作 CoWorkBench | 70.7 | 61.0 | 65.1 | -- | 68.2 | | 专业工作任务 JobBench | 33.4 | 21.8 | 27.6 | -- | -- | | 前沿 Agent 任务 Agents' Last Exam | | | | -- | -- | | 通用 | | | | | | | 指令遵循 IFBench | 79.5 | 69.1 | 79.1 | 77.0 | 62.5 | | 科学推理 GPQA Diamond | 89.2 | 87.8 | 90.3 | 83.5 | 91.3 | | 多学科推理 HLE | 30.8 | 24.0 | 34.7 | 22.0 | 40.0 | | 竞赛编程 LiveCodeBench v6 | 90.3 | 83.9 | 89.6 | -- | 88.8 |
- SWE-bench Pro:除采用官方公布分数的 Opus4.6 Max 外,所有模型均使用 Claude Code harness 评估,参数为 temp=1.0、top_p=0.95 和 256K 上下文窗口。研究人员修正了存在问题的任务,并在改进后的基准上重新评估了所有基线模型。
- NL2Repo-Bench:使用 Claude Code harness 评估。为防止奖励黑客行为,禁用了尝试访问特定仓库的 Bash 命令,例如 pip download、pip install 和 git clone。
- DeepSWE 1.1:使用 Claude Code harness 评估,参数为 temp=1.0、top_p=0.95 和 256K 上下文窗口。
- QwenSWEBench:用于评估模型软件工程能力的内部编程基准。使用 Claude Code harness 评估。在 8 小时超时条件下报告 avg@3,max_tokens=32,768、temperature=1.0,以及 256K 上下文窗口。
- CoWorkBench:用于评估计算机科学、金融、法律、医疗及其他生产力领域长程任务的内部协作基准。
- HLE:由 GPT-4o 判定。
- 每行最佳结果以粗体显示。
- 空单元格(--)表示结果尚不可用或不适用。
VL 性能
| Qwen3.8-27B | Qwen3.6-27B | Qwen3.7-Plus | Muse Glimmer-30B | Opus4.6 Max | |---|---|---|---|---|---| | Agent 多模态智能 | | | | | | | 计算机使用 OSWorld-Verified | 84.3 | 63.9 | 73.3 | 65.9 | 72.7 | | 浏览器使用 WebArena-Verified | 64.8 | 48.8 | 55.3 | -- | -- | | 移动端使用 AndroidWorld | 81.9 | 70.3 | 81.0 | -- | 62.0 | | 应用复现 RecreationBench | 47.1 | 29.8 | 30.2 | -- | -- | | 多模态工具使用 ClawEval-MM | | | | -- | | | 多模态软件工程 SWE-MM | 38.6 | 25.7 | 30.0 | -- | 27.1 | | 视觉 Web 开发 Vision2Web | 62.9 | 45.0 | 42.1 | -- | -- | | 通用多模态智能 | | | | | | | 视觉数学问题求解 MathVision | | | | -- | | | 通用视觉推理 BabyVision | | | | -- | | | 科学图表分析 CharXiv (RQ) | | | | 78.8 | | | 文档智能 OmniDocBench 1.5 | 91.1 | 89.4 | 91.4 | 75.8 | 86.6 | | 现实世界感知 RealWorldQA | 85.9 | 84.1 | 86.9 | -- | 73.9 | | 具身智能 ERQA | 65.5 | 62.5 | 69.8 | -- | 40.8 |
- MathVision、BabyVision 和 CharXiv (RQ):在两种设置均可用时,单元格会分别报告“Without CI”和“With CI”;否则仅展示可用设置。经过人工核验后,修正了 MathVision 和 CharXiv (RQ) 中少量错误的真实标签标注,所有在这些基准上报告的分数均使用修正后的标注计算。
- MathVision:Qwen3.8-27B 使用固定提示词评估:“Please reason step by step, and put your final answer within
\boxed{}.” 对于其余模型,报告包含和不包含\boxed{}格式要求的两种提示词变体中的较高分数。 - WebArena-Verified:分数使用 OSWorld scaffold 下官方 WebArena-Verified 评分器计算。
- RecreationBench:内部长期应用复现基准,旨在评估混合 Agent 在五个平台上的能力:桌面端(Ubuntu、macOS 和 Windows)、移动端(Android)及 Web。
- ClawEval-MM:分数以“Pass@3 / 平均分”报告。Pass@3 指一个任务在三次试验中至少有一次通过的比例;平均分指三次试验的基准分数均值。
- Vision2Web:分数在前端、网页和网站类别中取平均。评估使用 Claude Code harness,并由
gpt-5.4-2026-03-05判定。 - SWE-MM:使用 Claude Code harness,在 SWE-bench Multimodal 的公开开发集上进行评估,并采用 Claude Opus 4.7 system card 附录 8.3 所述的修改。
- 空单元格(--)表示结果尚不可用或不适用。
快速开始
为实现更简洁的集成,我们建议通过 API 使用 Qwen3.8。
部署 Qwen3.8
不同框架的推理效率与吞吐量差异显著。建议使用最新版本的框架,以确保最佳性能与兼容性。对于生产负载或高吞吐场景,建议使用 SGLang、vLLM 或 TokenSpeed 等专用服务引擎。
Qwen3.8 可通过常见推理框架部署,例如:
API 使用
Qwen3.8 模型默认以思考模式运行,在生成最终回复前,会先生成以
<think>\n...</think>\n\n标识的思考内容。如需禁用思考内容并获得直接回复,请参阅此处示例。
建议在生成时使用以下采样参数组合:
- 思考模式:
temperature=1.0、top_p=0.95、top_k=20、min_p=0.0、presence_penalty=0.0、repetition_penalty=1.0- Instruct(或非思考)模式:
temperature=0.7、top_p=0.80、top_k=20、min_p=0.0、presence_penalty=1.5、repetition_penalty=1.0
请注意,不同推理框架对采样参数的支持情况不同。
Qwen3.8 官方支持 reasoning_effort,可用于调整推理深度并控制成本:
xhigh(默认):适用于需要充分分析的复杂任务medium:平衡准确性与速度low:以速度和成本为优先的高效推理
此外,所有工作负载默认启用 preserve_thinking,以提供开箱即用的最佳体验。如需禁用推理保留,请参阅此处示例。
在多轮 Agent 任务中,较低的推理强度不一定会缩短整体任务完成时间。尽管它可能带来更快的单轮响应,但也可能导致分析不足、失败增多和重复重试,从而增加总延迟与 token 消耗。
Chat Completions API
Chat Completions API 可与大多数推理框架及 Qwen Cloud 一起使用。开始前,请确保已安装 OpenAI Python SDK,并已配置 API 密钥和 API 基础 URL,例如:
pip install -U openai
# Set the following accordingly
export OPENAI_BASE_URL='your-base-url'
export OPENAI_API_KEY='your-api-key'
纯文本输入
from openai import OpenAI
client = OpenAI()
messages = [{"role": "user", "content": "Write a Python function to merge two sorted linked lists."}]
completion = client.chat.completions.create(
model="Qwen/Qwen3.8-27B",
messages=messages,
extra_body={
"chat_template_kwargs": {
"enable_thinking": True,
"preserve_thinking": True,
},
},
reasoning_effort="xhigh",
stream=True,
stream_options={"include_usage": True},
)
reasoning_content = ""
answer_content = ""
is_answering = False
print("\n" + "=" * 20 + "Reasoning" + "=" * 20 + "\n")
for chunk in completion:
if not chunk.choices:
print("\nUsage:")
print(chunk.usage)
continue
delta = chunk.choices[0].delta
if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
if not is_answering:
print(delta.reasoning_content, end="", flush=True)
reasoning_content += delta.reasoning_content
elif hasattr(delta, "reasoning") and delta.reasoning is not None:
if not is_answering:
print(delta.reasoning, end="", flush=True)
reasoning_content += delta.reasoning
if hasattr(delta, "content") and delta.content:
if not is_answering:
print("\n" + "=" * 20 + "Answer" + "=" * 20 + "\n")
is_answering = True
print(delta.content, end="", flush=True)
answer_content += delta.content
messages.append({
"role": "assistant",
"content": answer_content,
"reasoning_content": reasoning_content,
"reasoning": reasoning_content,
})
图像输入
from openai import OpenAI
client = OpenAI()
messages = [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/CI_Demo/mathv-1327.jpg"
}
},
{
"type": "text",
"text": "The centres of the four illustrated circles are in the corners of the square. The two big circles touch each other and also the two little circles. With which factor do you have to multiply the radii of the little circles to obtain the radius of the big circles?\nChoices:\n(A) $\\frac{2}{9}$\n(B) $\\sqrt{5}$\n(C) $0.8 \\cdot \\pi$\n(D) 2.5\n(E) $1+\\sqrt{2}$"
}
]
}
]
chat_response = client.chat.completions.create(
model="Qwen/Qwen3.8-27B",
messages=messages,
)
print("Chat response:", chat_response)
视频输入
from openai import OpenAI
client = OpenAI()
messages = [
{
"role": "user",
"content": [
{
"type": "video_url",
"video_url": {
"url": "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/video/N1cdUjctpG8.mp4"
}
},
{
"type": "text",
"text": "How many porcelain jars were discovered
English / 原文
Qwen3.8-27B
This repository contains model weights and configuration files for the post-trained model in the Hugging Face Transformers format.
These artifacts are compatible with Hugging Face Transformers, vLLM, SGLang, TokenSpeed, etc.
For users seeking managed, scalable inference without infrastructure maintenance, the official Qwen API service is provided by Qwen Cloud. In particular, Qwen3.8-27B will be available as a hosted version with more production features, e.g., 1M context length by default, official built-in tools. For more information, please refer to the Qwen3.8-27B Overview. The service is coming soon. Stay tuned for updates.
Following the widespread community adoption of the Qwen3.5 and Qwen3.6 series, we are pleased to introduce Qwen3.8, the most capable generation in the Qwen open-model family to date.
Built on the architectural foundation of Qwen3.5, Qwen3.8 delivers substantial gains across coding, professional work, research, and long-horizon agentic tasks. Qwen3.8-27B brings these advances to a compact, deployment-friendly dense model: a native vision-language model that understands images and videos, with flexible thinking control, designed to carry complex, multi-step tasks through to completion with greater reliability.
Qwen3.8 Highlights
Qwen3.8-27B features the following enhancements:
- Core Capabilities : Comprehensive improvements across coding, professional work, research, and long-horizon agentic tasks.
- Agent Execution : Stronger autonomous planning and better handling of environment feedback, leading to more reliable end-to-end task completion.
- Downstream Compatibility : Broader support for popular harnesses and development tools, making it easier to integrate into your existing stack.
- Flexible Thinking Control : Thinking mode is on by default and can be disabled per request; reasoning depth can be tuned with
reasoning_effort, and reasoning context from historical messages is retained viapreserve_thinking. - Vision-Language Understanding : Native support for image and video understanding, from STEM diagrams and documents to hour-scale videos.
Model Overview
- Type: Causal Language Model with Vision Encoder
- Training Stage: Pre-training & Post-training
- Language Model
- Number of Parameters: 27B
- Hidden Dimension: 5120
- Token Embedding: 248,320 (Padded)
- Number of Layers: 64
- Hidden Layout: 16 × (3 × (Gated DeltaNet → FFN) → 1 × (Gated Attention → FFN))
- Gated DeltaNet:
- Number of Linear Attention Heads: 48 for V and 16 for QK
- Head Dimension: 128
- Gated Attention:
- Number of Attention Heads: 24 for Q and 4 for KV
- Head Dimension: 256
- Rotary Position Embedding Dimension: 64
- Feed Forward Network:
- Intermediate Dimension: 17,408
- LM Output: 248,320 (Padded)
- MTP (Multi-Token Prediction): trained with multiple steps
- Context Length: 262,144 natively and extensible up to 1,000,000 tokens.
Benchmark Results
Text Performance
| Qwen3.8-27B| Qwen3.6-27B| Qwen3.7-Plus| Muse Glimmer-30B| Opus4.6 Max
---|---|---|---|---|---
Coding
Agentic terminal codingTerminal Bench 2.1 (Terminus) | 73.0 | 63.4 | 64.0 | 51.7 | 78.2
Agentic codingSWE-bench Pro | 61.7 | 53.5 | 57.6 | 51.2 | 53.4
Repo-level code generationNL2Repo-Bench | 42.3 | 36.2 | 41.1 | -- | 47.6
Agentic codingDeepSWE 1.1 | 42.2 | 13.3 | 14.2 | -- | --
Software engineeringQwenSWEBench | 79.0 | 49.3 | 59.2 | -- | 63.8
Agent
Long-horizon office workCoWorkBench | 70.7 | 61.0 | 65.1 | -- | 68.2
Professional job tasksJobBench | 33.4 | 21.8 | 27.6 | -- | --
Frontier agentic tasksAgents' Last Exam | | | | -- | --
General
Instruction followingIFBench | 79.5 | 69.1 | 79.1 | 77.0 | 62.5
Scientific reasoningGPQA Diamond | 89.2 | 87.8 | 90.3 | 83.5 | 91.3
Multidisciplinary reasoningHLE | 30.8 | 24.0 | 34.7 | 22.0 | 40.0
Competitive codingLiveCodeBench v6 | 90.3 | 83.9 | 89.6 | -- | 88.8
- SWE-bench Pro: Except for Opus4.6 Max, which uses the officially reported score, all models are evaluated with the Claude Code harness at temp=1.0, top_p=0.95, and a 256K context window. Problematic tasks were corrected, and all baseline models were re-evaluated on the refined benchmark.
- NL2Repo-Bench: Evaluated with the Claude Code harness. To prevent reward hacking, we disable Bash commands that attempt to access the specific repository, such as pip download, pip install, and git clone.
- DeepSWE 1.1: Evaluated with the Claude Code harness at temp=1.0, top_p=0.95, and a 256K context window.
- QwenSWEBench: In-house coding benchmark for evaluating models' software engineering capabilities. Evaluated with the Claude Code harness. Reporting avg@3 with an 8-hour timeout, max_tokens=32,768, temperature=1.0, and a 256K context window.
- CoWorkBench: In-house cowork benchmark for evaluating long-horizon tasks across computer science, finance, law, medical, and other productivity domains.
- HLE: Judged by GPT-4o.
- The best result in each row is shown in bold.
- Empty cells (--) indicate that results are not yet available or not applicable.
VL Performance
| Qwen3.8-27B| Qwen3.6-27B| Qwen3.7-Plus| Muse Glimmer-30B| Opus4.6 Max
---|---|---|---|---|---
Agentic Multimodal Intelligence
Computer useOSWorld-Verified| 84.3| 63.9| 73.3| 65.9| 72.7
Browser useWebArena-Verified| 64.8| 48.8| 55.3| --| --
Mobile useAndroidWorld| 81.9| 70.3| 81.0| --| 62.0
Application recreationRecreationBench| 47.1| 29.8| 30.2| --| --
Multimodal tool useClawEval-MM| | | | --|
Multimodal software engineeringSWE-MM| 38.6| 25.7| 30.0| --| 27.1
Visual web developmentVision2Web| 62.9| 45.0| 42.1| --| --
General Multimodal Intelligence
Visual math problem solvingMathVision| | | | --|
General visual reasoningBabyVision| | | | --|
Scientific chart analysisCharXiv (RQ)| | | | 78.8|
Document intelligenceOmniDocBench 1.5| 91.1| 89.4| 91.4| 75.8| 86.6
Real-world perceptionRealWorldQA| 85.9| 84.1| 86.9| --| 73.9
Embodied intelligenceERQA| 65.5| 62.5| 69.8| --| 40.8
- MathVision, BabyVision, and CharXiv (RQ): Where both settings are available, cells report “Without CI” and “With CI” separately; otherwise, only the available setting is shown. A small number of incorrect ground-truth annotations in MathVision and CharXiv (RQ) were corrected following manual verification, and all reported scores on those benchmarks were computed using the corrected annotations.
- MathVision: Qwen3.8-27B is evaluated using the fixed prompt: “Please reason step by step, and put your final answer within
\boxed{}.” For the remaining models, we report the higher score from two prompt variants—one with and one without the\boxed{}formatting requirement. - WebArena-Verified: Scores are computed with the official WebArena-Verified grader under the OSWorld scaffold.
- RecreationBench: An in-house, long-horizon application-recreation benchmark designed to evaluate hybrid-agent capabilities across five platforms: desktop (Ubuntu, macOS, and Windows), mobile (Android), and the web.
- ClawEval-MM: Scores are reported as “Pass@3 / average score.” Pass@3 is the percentage of tasks passed in at least one of three trials; the average score is the mean benchmark score across the three trials.
- Vision2Web: Scores are averaged across the frontend, webpage, and website categories. Evaluations use the Claude Code harness and are judged by
gpt-5.4-2026-03-05. - SWE-MM: Scores are evaluated on the Claude Code harness using the public dev split of SWE-bench Multimodal, with the modifications described in Appendix 8.3 of the Claude Opus 4.7 system card.
- Empty cells (--) indicate that results are not yet available or not applicable.
Quickstart
For streamlined integration, we recommend using Qwen3.8 via APIs.
Serving Qwen3.8
Inference efficiency and throughput vary significantly across frameworks. We recommend using the latest framework versions to ensure optimal performance and compatibility. For production workloads or high-throughput scenarios, dedicated serving engines such as SGLang, vLLM, or TokenSpeed are recommended.
Qwen3.8 can be deployed with popular inference frameworks, e.g.:
API Usage
Qwen3.8 models operate in thinking mode by default, generating thinking content signified by
<think>\n...</think>\n\nbefore producing the final response. To disable thinking content and obtain a direct response, refer to the examples here.
We recommend using the following sets of sampling parameters for generation:
- Thinking Mode:
temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,presence_penalty=0.0,repetition_penalty=1.0- Instruct (or non-thinking) mode:
temperature=0.7,top_p=0.80,top_k=20,min_p=0.0,presence_penalty=1.5,repetition_penalty=1.0
Please note that the support for sampling parameters varies according to inference frameworks.
Qwen3.8 comes with official support for reasoning_effort, which can be used to adjust reasoning depth and control cost:
xhigh(default): for complex tasks demanding thorough analysismedium: balancing accuracy and speedlow: efficient reasoning optimizing for speed and cost
In addition, preserve_thinking is enabled by default for all workloads for the best out-of-the-box experience. To disable preserved thinking, refer to the examples here.
In multi-turn agentic tasks, lower reasoning effort does not always reduce overall task completion time. Although it may produce faster per-turn responses, it can also lead to insufficient analysis, more failures, and repeated retries, which may increase total latency and token consumption.
Chat Completions API
The Chat Completions API can be used with most inference frameworks, as well as Qwen Cloud. Before starting, make sure the OpenAI Python SDK is installed and the API key and the API base URL are configured, e.g.:
pip install -U openai
# Set the following accordingly
export OPENAI_BASE_URL='your-base-url'
export OPENAI_API_KEY='your-api-key'
Text-Only Input
from openai import OpenAI
client = OpenAI()
messages = [{"role": "user", "content": "Write a Python function to merge two sorted linked lists."}]
completion = client.chat.completions.create(
model="Qwen/Qwen3.8-27B",
messages=messages,
extra_body={
"chat_template_kwargs": {
"enable_thinking": True,
"preserve_thinking": True,
},
},
reasoning_effort="xhigh",
stream=True,
stream_options={"include_usage": True},
)
reasoning_content = ""
answer_content = ""
is_answering = False
print("\n" + "=" * 20 + "Reasoning" + "=" * 20 + "\n")
for chunk in completion:
if not chunk.choices:
print("\nUsage:")
print(chunk.usage)
continue
delta = chunk.choices[0].delta
if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
if not is_answering:
print(delta.reasoning_content, end="", flush=True)
reasoning_content += delta.reasoning_content
elif hasattr(delta, "reasoning") and delta.reasoning is not None:
if not is_answering:
print(delta.reasoning, end="", flush=True)
reasoning_content += delta.reasoning
if hasattr(delta, "content") and delta.content:
if not is_answering:
print("\n" + "=" * 20 + "Answer" + "=" * 20 + "\n")
is_answering = True
print(delta.content, end="", flush=True)
answer_content += delta.content
messages.append({
"role": "assistant",
"content": answer_content,
"reasoning_content": reasoning_content,
"reasoning": reasoning_content,
})
Image Input
from openai import OpenAI
client = OpenAI()
messages = [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/CI_Demo/mathv-1327.jpg"
}
},
{
"type": "text",
"text": "The centres of the four illustrated circles are in the corners of the square. The two big circles touch each other and also the two little circles. With which factor do you have to multiply the radii of the little circles to obtain the radius of the big circles?\nChoices:\n(A) $\\frac{2}{9}$\n(B) $\\sqrt{5}$\n(C) $0.8 \\cdot \\pi$\n(D) 2.5\n(E) $1+\\sqrt{2}$"
}
]
}
]
chat_response = client.chat.completions.create(
model="Qwen/Qwen3.8-27B",
messages=messages,
)
print("Chat response:", chat_response)
Video Input
from openai import OpenAI
client = OpenAI()
messages = [
{
"role": "user",
"content": [
{
"type": "video_url",
"video_url": {
"url": "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/video/N1cdUjctpG8.mp4"
}
},
{
"type": "text",
"text": "How many porcelain jars were discovered in the niches located in the primary chamber of the tomb?"
}
]
}
]
chat_response = client.chat.completions.create(
model="Qwen/Qwen3.8-27B",
messages=messages,
)
print("Chat response:", chat_response)
Instruct (or Non-Thinking) Mode
Qwen3.8-27B will think by default before responding. You can obtain a direct response from the model without thinking by configuring the API parameters. For example,
from openai import OpenAI
client = OpenAI()
messages = [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/RealWorld/RealWorld-04.png"
}
},
{
"type": "text",
"text": "Where is this?"
}
]
}
]
chat_response = client.chat.completions.create(
model="Qwen/Qwen3.8-27B",
messages=messages,
temperature=0.7,
top_p=0.8,
presence_penalty=1.5,
extra_body={
"top_k": 20,
"chat_template_kwargs": {"enable_thinking": False},
},
)
print("Chat response:", chat_response)
If you are using APIs from Qwen Cloud, in addition to changing
model, please use"enable_thinking": Falseinstead of"chat_template_kwargs": {"enable_thinking": False}.
Disable Preserved Thinking
By default, Qwen3.8 retains thinking blocks from all historical messages, maintaining a complete reasoning trace across the conversation. This behavior, known as preserved thinking, ensures full context continuity and is especially beneficial for agent scenarios where decision consistency and reduced redundant reasoning are critical. It also improves KV cache utilization, optimizing inference efficiency in both thinking and non-thinking modes.
If you prefer to retain only the thinking blocks from the latest user message, you can disable this behavior by setting preserve_thinking to False:
from openai import OpenAI
client = OpenAI()
messages = [...]
chat_response = client.chat.completions.create(
model="Qwen/Qwen3.8-27B",
messages=messages,
extra_body={
"chat_template_kwargs": {"preserve_thinking": False},
},
)
print("Chat response:", chat_response)
If you are using APIs from Qwen Cloud, in addition to changing
model, please use"preserve_thinking": Falsedirectly instead of wrapping it inchat_template_kwargs.
Best Practices
To achieve optimal performance, we recommend the following settings:
-
Sampling Parameters : We suggest using the following sets of sampling parameters:
- Thinking Mode:
temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,presence_penalty=0.0,repetition_penalty=1.0 - Instruct (or non-thinking) mode:
temperature=0.7,top_p=0.80,top_k=20,min_p=0.0,presence_penalty=1.5,repetition_penalty=1.0
- Thinking Mode:
For supported frameworks, you can adjust the presence_penalty parameter between 0 and 2 to reduce endless repetition. However, using a higher value may occasionally result in language mixing and a slight decrease in model performance.
-
Adequate Output Length : To optimize performance on agentic tasks, we recommend allocating sufficient output length to allow the model to generate detailed and comprehensive responses. For frameworks that support separate token limits for internal reasoning and final outputs, we suggest the following configuration within the 1M context length:
- Reasoning Content: Set the maximum output length to 262,144 tokens.
- Final Response: Set the maximum output length to 131,072 tokens.
These settings provide the necessary capacity for complex reasoning while ensuring ample space for high-quality final deliverables.
- Processing Ultra-Long Texts : Qwen3.8-27B natively supports context lengths of up to 262,144 tokens. For long-horizon tasks where the total length (including both input and output) exceeds this limit, we recommend using RoPE scaling techniques to handle long texts effectively, e.g., YaRN.
YaRN is currently supported by several inference frameworks, e.g., vLLM, SGLang, and TokenSpeed. In general, there are two approaches to enabling YaRN for supported frameworks:
* Modifying the model configuration file:
In the config.json file, change the rope_parameters fields in text_config to:
{
"mrope_interleaved": true,
"mrope_section": [
11,
11,
10
],
"rope_type": "yarn",
"rope_theta": 10000000,
"partial_rotary_factor": 0.25,
"factor": 4.0,
"original_max_position_embeddings": 262144,
}
* Passing command line arguments:
For vLLM, you can use
VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 vllm serve ... --hf-overrides '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}' --max-model-len 1000000
For SGLang, you can use
SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1 python -m sglang.launch_server ... --json-model-override-args '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}' --context-length 1000000
For TokenSpeed, you can use
TOKENSPEED_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1 tokenspeed serve ... --hf-overrides '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}' --max-model-len 1000000
All the notable open-source frameworks implement static YaRN, which means the scaling factor remains constant regardless of input length, potentially impacting performance on shorter texts. We advise modifying the
rope_parametersconfiguration only when processing long contexts is required. It is also recommended to modify thefactoras needed. For example, if the typical context length for your application is 524,288 tokens, it would be better to setfactoras 2.0.
-
Long Video Understanding : To optimize inference efficiency for plain text and images, the
sizeparameter in the releasedvideo_preprocessor_config.jsonis conservatively configured. It is recommended to set thelongest_edgeparameter in the video_preprocessor_config file to 469,762,048 (corresponding to 224k video tokens) to enable higher frame-rate sampling for hour-scale videos and thereby achieve superior performance. For example,{"longest_edge": 469762048, "shortest_edge": 4096}
Alternatively, override the default values via engine startup parameters. For implementation details, refer to: vLLM / SGLang.
Citation
If you find our work helpful, feel free to give us a cite.
@misc{qwen38,
title = {{Qwen3.8-Max}: A New Bar for Coding and Cowork},
url = {https://qwen.ai/blog?id=qwen3.8},
author = {{Qwen Team}},
month = {August},
year = {2026}
}