GLM-4.5: Agentic, Reasoning, and Coding (ARC) Foundation Models
Paper: arXiv:2508.06471 Code: zai-org/GLM-4.5, zai-org/glm-simple-evals, plus official implementation pointers to Transformers glm4_moe, vLLM glm4_moe_mtp, and SGLang glm4_moe Code reference:
zai-org/GLM-4.5 main@170f20b2(2026-02-01);zai-org/glm-simple-evals main@b67cb0bf(2025-10-17); upstream model implementations inspected attransformers main@0b25f8c4,vLLM main@ef54a4d6,SGLang main@5073c82a(2026-05-19)
1. 这篇论文在解决什么问题?
这篇技术报告的目标不是提出一个单点算法,而是给出 GLM-4.5 系列如何把 Agentic、Reasoning、Coding 三类能力统一到同一个开源 MoE 基座和同一套后训练流程里。论文把这三类能力合称为 ARC:Agentic 指外部工具、浏览器、代码仓库、终端等环境交互;Reasoning 指数学、科学、长链推理和可验证问题;Coding 指真实软件工程任务、repo 级代码理解和 agentic coding。作者认为下一代通用模型不应只在某一个维度极强,而应在这三类相互依赖的能力之间保持均衡:复杂 agent 往往需要推理规划,真实 coding 又需要长上下文、工具调用和测试反馈,推理 RL 的可验证奖励也能迁移到多步 agent 决策。
GLM-4.5 的核心定位是一个 开源、参数效率较高、具备混合思考模式的 MoE foundation model。主模型 GLM-4.5 有 355B 总参数、32B 激活参数;轻量版本 GLM-4.5-Air 有 106B 总参数、12B 激活参数。两者都支持 thinking mode 与 non-thinking mode:前者用于复杂推理、agentic task 和长链问题,后者用于闲聊、摘要、翻译等低延迟即时回答。这个设计不是简单地在推理时开关 CoT,而是在 SFT 阶段同时蒸馏带长思考过程和不显式思考的数据,让模型学会按任务类型选择“反思式”或“立即式”的输出风格。
论文的主张可以概括为:通过较深的 MoE 架构、23T token 多阶段预训练、面向代码/数学/agent 的 mid-training、专家模型迭代式 SFT/RL,以及异步长轨迹 RL 基础设施,GLM-4.5 能在开放模型规模内逼近或超过若干闭源模型的 ARC 综合能力。报告中的 headline 数字包括:TAU-Bench 70.1%、BFCL v3 77.8%、BrowseComp 26.4%、AIME 24 91.0%、GPQA 79.1%、LiveCodeBench 72.9%、HLE 14.4%、SWE-bench Verified 64.2%、Terminal-Bench 37.5%。在作者的 12 项 ARC 综合评估里,GLM-4.5 总排名第 3,GLM-4.5-Air 第 6;在 agentic 维度,GLM-4.5 排第 2,仅次于 OpenAI o3。
Figure 1 解读:这张图把 agentic、reasoning、coding 三类 benchmark 合成 ARC 视角,强调 GLM-4.5 不是只在数学或代码单点领先,而是在三条能力线上都进入第一梯队。对读者最有用的信息是排序背后的权衡:GLM-4.5 不是最大模型,但在 agentic 与 coding 上的综合位置非常靠前;GLM-4.5-Air 则证明同一训练路线在 100B 级别也保留了较强能力。
Figure 2 解读:SWE-bench Verified 与参数量的图主要服务于“参数效率”论点。GLM-4.5 以 355B 总参数、32B 激活参数进入 Pareto frontier,GLM-4.5-Air 则在更小规模上给出强 coding-agent 性能。论文把这点作为深而窄 MoE、repo-level mid-training、agentic RL 共同生效的证据。
2. 核心思想与贡献
最核心的新意是 “ARC generalist by expert iteration”:先把 reasoning、agent、general chat 三类能力分别做成专家,再通过统一 SFT 与 self-distillation 把专家能力合到一个 hybrid reasoning generalist 里,然后用多类 RL 对数学、代码、科学、工具调用、Web search、通用指令、安全等维度继续强化。与只做 base pretraining 后加一个通用 instruction tuning 的路线不同,GLM-4.5 的 post-training 被设计成“专家产生高质量行为、generalist 学会在任务间切换、RL 再对可验证或可评分目标做提升”的循环。
架构层面的贡献不是提出全新 Transformer,而是围绕 深 MoE + 高 attention head 数 + QK-Norm + MTP + loss-free balance routing 做工程组合。作者明确说他们相对 DeepSeek-V3 和 Kimi K2 减少宽度、增加深度,因为实验中更深模型表现出更强 reasoning capacity。GLM-4.5 有 3 个 dense layer、89 个 MoE layer、1 个 MTP layer、hidden size 5120、96 个 attention heads、8 个 KV heads、160 个 routed experts、每 token 激活 8 个 expert、1 个 shared expert,并使用 QK-Norm;Air 版本有 1 个 dense layer、45 个 MoE layer、hidden size 4096、128 个 routed experts、每 token 也激活 8 个 expert。
数据与训练路线的贡献在于把普通预训练、代码/数学/科学增强、repo-level 长上下文、synthetic agent trajectories 放进一个阶段化 curriculum。预训练主体覆盖网页、社交媒体、书籍、论文和代码仓库,先以 4K context 在 15T token 通用语料上训练,再在后续阶段上采样代码、数学、科学与高质量网页;mid-training 进一步加入 500B repo-level code、500B continual reasoning data、100B agent data,并把上下文从 32K 延到 128K。这里的设计直觉是:普通网页学习语言和知识,repo-level 代码学习跨文件依赖,reasoning data 学习长 CoT,agent trajectories 学习工具和环境交互,长上下文训练则保证这些序列不会被截断。
后训练贡献主要体现在四类 RL 的组合。Reasoning RL 基于 GRPO 但去掉 KL loss,针对数学、代码、科学分别处理 reward variance、loss 计算和数据质量;Agentic RL 使用 web search 与 SWE 这类可验证环境,用结果监督加格式惩罚,并通过 self-distillation 迭代提升 cold-start 模型;General RL 融合规则、人类偏好和 AI feedback,覆盖 holistic、instruction following、creative writing、multi-turn function calling 和 safety;Infrastructure 则使用 Slime,把 Megatron training、SGLang/Router rollout、Data Buffer 解耦,支持同步/异步、多任务、长轨迹和 Docker 隔离的 agent rollout。
Figure 3 解读:这张图是整篇 paper 的训练路线索引。它把 4K 的通用预训练、32K 的 repo-level code / reasoning、128K 的 long-context & agent training 串起来,说明 GLM-4.5 的 ARC 能力不是只靠 post-training 注入,而是在 base/mid-training 阶段已经让模型接触了长 repo、数学科学推理过程和 agent 轨迹。
3. 方法详解
3.1 架构:深而窄的 MoE generalist
GLM-4.5 采用 MoE 架构来降低训练和推理计算量。每个 token 只激活一部分 routed experts,同时保留 shared expert。论文采用 loss-free balance routing 与 sigmoid gates,目标是在不引入强辅助负载均衡损失干扰主任务的前提下,让 expert 使用保持相对均衡。公开 Hugging Face config 与 Transformers 实现也能对应到这一点:Glm4MoeTopkRouter.route_tokens_to_experts 先对 router logits 做 sigmoid,然后加上 e_score_correction_bias,按 group 选择候选 expert,再取 top-k expert,最后对 top-k weights 做归一化并乘 routed_scaling_factor。这与论文中“sigmoid gates + loss-free balance routing”的描述一致。
注意力部分采用 Grouped-Query Attention 与 partial RoPE,并且使用 96 个 attention heads。作者提到一个反直觉经验:更多 attention heads 未必改善 training loss,但能稳定提升 MMLU、BBH 等 reasoning benchmark。GLM-4.5 还使用 QK-Norm 稳定 attention logits;HF config 中 use_qk_norm: true 与论文 Table 1 对齐。RoPE base 在 32K 长度扩展时从 10,000 调整到 1,000,000,HF config 的 rope_theta: 1000000、max_position_embeddings: 131072 也对应 128K 上下文。
MTP(Multi-Token Prediction)以一个 MoE layer 形式加入,用于 speculative decoding 支持。论文报告 GLM-4.5 和 GLM-4.5-Air 都有 1 个 MTP layer;HF config 中 num_nextn_predict_layers: 1 与这一点一致。这里 MTP 的重点不是提高训练语义能力,而是让推理部署时可以更好地配合 speculative decoding 或 serving 框架,提升生成吞吐。
3.2 预训练与 mid-training:从通用知识到 ARC 数据
预训练语料包括网页、社交媒体、书籍、论文、代码仓库。网页数据用质量分桶策略,上采样高分桶,最高质量桶在预训练中超过 3.2 epochs;同时用 MinHash 与 SemDedup 处理模板化相似网页。多语言语料来自自爬网页和 FineWeb-2。代码数据来自 GitHub 与网页,作者先用文件级代码预训练让模型获得基本 programming capability,再在 mid-training 阶段做 repo-level 训练,把同一仓库的文件拼接起来学习跨文件依赖,并把 issue、PR、commit 组织成 diff-like 格式以提升软件工程理解。
推理数据的核心是数学、科学、代码竞赛等任务。论文说他们从网页和书籍收集问题答案,并用 reasoning model 合成推理过程。这个设计的关键在于:GLM-4.5 不只是学 final answer,而是学会在长上下文里维护中间思路。agent 数据则在 long-context & agent training 阶段大规模加入 synthetic agent trajectories,使模型在基座阶段就见过多轮工具调用、浏览、环境状态变化和任务完成轨迹。因为 repo-level code 与 reasoning process 都很容易被普通 packing 截断,作者在 mid-training 中使用 best-fit packing,而预训练文档仍采用 random truncation 作为数据增强。
训练超参数方面,论文给出若干关键数值:Muon optimizer 用于除 word embedding、bias、RMSNorm weights 之外的参数;Newton-Schulz iteration steps 为 5,momentum 为 0.95,Muon update RMS 缩放到 0.2;学习率采用 cosine decay 而不是 WSD,从 0 warm up 到 2.5e-4,再衰减到 2.5e-5;batch size 在前 500B token 从 16M token 逐步升到 64M token;weight decay 0.1,不用 dropout;loss-free balance routing 的 bias update rate 在前 15T token 为 0.001,之后为 0;sequence-level balance loss weight 为 0.0001;MTP loss weight 前 15T token 为 0.3,之后为 0.1。这些数值来自论文而不是 public training config,因为官方 GitHub 仓库没有发布训练 launch script。
3.3 SFT:专家模型迭代与 hybrid reasoning
后训练被分成两个阶段。Stage 1 是 Expert Training,分别构建 Reasoning、Agent、General chat 三类专家模型;Stage 2 是 Unified Training,用 self-distillation 把多个专家的能力整合回一个 generalist。SFT 在两个阶段开头都执行:在专家阶段,它负责提供 cold start,让后续 expert RL 有较好起点;在 unified 阶段,它负责把不同专家的输出蒸馏到同一基座,得到能根据任务类型选择长思考或即时回答的 hybrid model。
Overall SFT 收集了数百万样本,覆盖 reasoning(math、code、science 等)、general chat(writing、translation、summarization、chit chat 等)、agentic 和 long-context understanding。一个重要细节是数据混合:对于需要长思考的任务,使用带 extended CoT 的专家输出;对于闲聊、翻译等快速任务,则平衡没有显式 thought process 的数据。这解释了为什么 GLM-4.5 可以同时提供 thinking mode 和 non-thinking mode,而不是所有任务都强制输出长链思考。
函数调用模板也被单独优化。论文指出,现代函数调用参数常以 JSON 表示,当参数里包含代码段时会出现大量转义字符,增加模型学习负担。GLM-4.5 提出一种函数调用模板,把函数调用内容封装到更适合模型生成的格式里,减少代码字符串转义,尤其面向 agentic foundation model,因为函数调用不是边缘功能,而是模型完成真实任务的核心能力。官方 README 和 inference/api_request.py 也显示,GLM-4.5 系列服务端支持 OpenAI-style tool description,且可以通过 extra_body={"chat_template_kwargs": {"enable_thinking": False}} 控制是否关闭 thinking。
3.4 Reasoning RL:可验证任务上的 curriculum 与 loss 设计
Reasoning RL 覆盖数学、代码生成和科学推理。它的共同特点是 reward 相对精确:数学可以验证答案,代码可以运行测试,科学选择题或结构化问题也能用较高置信的 checker 判断。论文的 RL algorithm 基于 GRPO,但排除了 KL loss term。作者没有把所有训练曲线都放在最终 GLM-4.5 上,而是说明对比曲线来自 smaller experimental model;因此笔记里的曲线解读应视为方法消融而不是最终模型训练日志。
难度 curriculum 是 Reasoning RL 的关键。若训练数据过简单,后期 rollout 全部 reward=1,没有梯度信号;若数据过难,早期 rollout 全部 reward=0,也无法学习。GLM-4.5 的做法是两阶段难度切换:第一阶段用 moderate-difficulty problems,第二阶段切到 extremely difficult problems,具体定义是 pass@8=0 但 pass@512>0。AIME’24 曲线显示这种策略在第二阶段仍持续提升,而 baseline 继续使用中等难度题后趋于平台。
Figure 5 解读:这张图说明 RL 数据难度必须随模型能力变化。若一个 batch 内 reward 方差消失,GRPO 无论有多少样本都缺少有用排序信号;pass@8=0、pass@512>0 的题既难到不是轻松全对,又存在被采样解出的可能,因此适合后期继续提供学习信号。
长上下文 RL 的发现也很实用。作者比较了 single-stage 64K 与逐步增加 context length 的 multi-stage RL,结果 single-stage 64K 更好;multi-stage 早期出现不可逆 performance drop,限制最终表现。这说明“逐步加长上下文”并不总是安全 curriculum,尤其当早期长度或数据分布让策略偏离后,后续阶段可能难以恢复。
Figure 6 解读:这张图对长上下文 RL 很有启发。多阶段训练看似更平滑,但如果早期 context 设置导致模型学到不适合 64K 的策略,后续即使增加长度也会被早期退化拖累。实践上,长上下文 RL 需要先确认中间阶段不会造成不可逆的策略偏移。
代码和科学 RL 的消融说明两个经验。对 code RL,token-weighted mean loss 比 sequence-mean loss 收敛更快,因为它提供更细粒度、更稳定的梯度,并缓解 sequence-level reward 带来的长度偏差,减少过度简单或重复的 base-case 样本。对 science RL,数据质量和类型比数据量更关键;在 GPQA-Diamond 上,只用 expert-verified multiple-choice questions 明显优于 mixed-quality 或 unverified data。换言之,对可验证 RL 来说,“可执行/可判定”只是起点,数据池中 challenge level 与 label quality 才决定训练信号是否有效。
Figure 7 解读:左图对应 code RL 的 loss aggregation,右图对应 science RL 的数据来源。它们共同指向同一条经验:RL 不是只要 reward function 正确就会自动提升,batch 内信号粒度、长度偏差、数据质量都会决定优化效率。
3.5 Agentic RL 与 General RL:从工具格式到长轨迹环境
Agentic RL 关注 web-search agent 和 code-generation agent。它利用这些任务的内置可验证性:web search 以最终答案准确性作为整个 agent trace 的 reward;coding agent 主要使用 SWE 数据和可验证 test cases。为了让工具调用可用,GLM-4.5 还加入 process format penalty;如果模型在生成 agent trace 时没有产生正确工具调用格式,流程会停止并得到 zero reward。这个细节很重要,因为 agent 模型的错误常不是“答案不够聪明”,而是 JSON、function name、参数字段、调用顺序等格式错误导致环境无法执行。
Agentic RL 采用 iterative distillation。由于 agent RL 成本高、rollout 长,作者先在 cold-start model 上进行 RL,达到某个 step 或 plateau 后,用 RL-trained model 的响应替换原始 cold-start 数据,形成更强的 SFT model,再继续 RL 并逐步增加训练难度。这是一种 SFT/RL 交替的 bootstrapping:RL 找到更好轨迹,SFT 把轨迹压回稳定起点,下一轮 RL 在更强策略上探索更难任务。
Figure 8 解读:BrowseComp 的 interaction-turn scaling 强调 test-time compute 对 agentic search 的作用。agentic task 的性能不只取决于单次生成质量,也取决于模型能否在多轮搜索、观察、修正里有效使用额外交互预算。
General RL 的目标是整体提升和修补潜在问题。它融合 rule-based feedback、human feedback(RLHF)和 model-based feedback(RLAIF)。Holistic RL 使用约 5,000 个 prompts,覆盖 7 个一级、33 个二级、139 个三级类别;human feedback 训练 reward model,AI feedback 则根据是否有 objective ground-truth 设计不同 scoring rubrics。Instruction Following RL 建立细粒度 taxonomy 和挑战指令集,反馈系统包括确定性验证规则、reward model 和 evaluator。论文报告 SysBench-ISR 随 reward 上升,在约 1,000 training steps 内没有观察到明显 reward hacking。
Figure 9 解读:这张曲线展示 instruction following RL 中 reward 与 SysBench-ISR 的同步提升。它不能证明永远没有 reward hacking,但说明在报告的训练区间内,reward 还保持了与外部 instruction-following 指标一致的方向。
3.6 Slime RL 基础设施
GLM-4.5 的 RL infrastructure 基于 Slime。Slime 有三个核心模块:Training(Megatron)负责主训练、读取 Data Buffer、同步参数;Rollout(SGLang + Router)负责生成新数据、reward 和 verifier outputs,并写入 Data Buffer;Data Buffer 负责 prompt 初始化、自定义数据和 rollout 生成策略。这个设计把训练和数据生成从一个同步循环里拆开,使不同 RL 任务可以共享框架但采用不同调度策略。
对一般 RL 或需要稳定同步更新的任务,colocated synchronous mode 可能足够;对长 horizon agent task,异步解耦更重要。agent rollout 的时长高度不均,若同步等待最慢轨迹,会导致 GPU 利用率很差。论文的做法是把 GPU 分成 rollout engines 和 training engines,rollout engine 持续生成轨迹,training engine 更新权重并周期性同步回 rollout engine。再加上高并发 Docker runtime 为每个任务提供隔离环境,可以降低长轨迹环境交互的 overhead,并支持不同 agent frameworks。
Figure 10 解读:Slime 图的重点是 Data Buffer 和异步解耦。对长 agent RL,rollout 不再是训练 step 内的阻塞子过程,而是独立生产数据的系统组件;这让 slow trajectory 不会拖住整个训练循环,也让不同 task 的 prompt、reward、verifier 可以更容易接入。
3.7 方法流程伪代码(基于论文流程与公开实现)
# High-level training recipe reconstructed from the paper.
base = initialize_glm4_moe(
total_params="355B", activated_params="32B",
layers={"dense": 3, "moe": 89, "mtp": 1},
router="sigmoid_topk_loss_free_balance",
attention="GQA + partial RoPE + QK-Norm",
)
base = pretrain(
base,
corpus=["web", "social", "books", "papers", "code"],
tokens="15T general + staged upsampling",
seq_len=4096,
optimizer="Muon",
)
base = midtrain(
base,
stages=[
("repo-level code", "500B", 32768),
("continual reasoning", "500B", 32768),
("long-context + agent trajectories", "100B agent data", 131072),
],
packing="best-fit for repo/reasoning to avoid truncating trajectories",
)
experts = {}
for domain in ["reasoning", "agent", "general_chat"]:
experts[domain] = sft_cold_start(base, domain_data=domain)
experts[domain] = domain_rl(experts[domain], reward=domain_specific_verifier)
generalist = sft_distill(
base,
teacher_outputs=experts,
mix=["long-CoT thinking data", "non-thinking quick-response data"],
max_context=131072,
)
generalist = reasoning_rl(generalist, algorithm="GRPO_without_KL", curriculum="difficulty_adaptive")
generalist = agentic_rl(generalist, reward=["web final answer", "SWE tests", "tool format penalty"])
generalist = general_rl(generalist, feedback=["rules", "human preference RM", "AI rubrics"])# Public Transformers routing path inspected in modeling_glm4_moe.py.
def route_tokens_to_experts(hidden_states, gate, config):
router_logits = linear(hidden_states, gate.weight).float()
scores = sigmoid(router_logits)
corrected = scores + gate.e_score_correction_bias
group_scores = top2_sum_per_group(corrected, n_group=config.n_group)
chosen_groups = topk(group_scores, k=config.topk_group)
masked_scores = mask_unselected_groups(corrected, chosen_groups)
expert_ids = topk(masked_scores, k=config.num_experts_per_tok)
expert_weights = gather(scores, expert_ids)
if config.norm_topk_prob:
expert_weights = expert_weights / (sum(expert_weights) + 1e-20)
return expert_ids, expert_weights * config.routed_scaling_factor4. 实验结果与证据
4.1 Base model 与架构对比
Table 1 显示 GLM-4.5 的架构比 DeepSeek-V3、Kimi K2 更深、更窄。GLM-4.5:355B total、32B activated、3 dense layers、89 MoE layers、1 MTP layer、hidden dim 5120、dense FFN intermediate 12288、MoE intermediate 1536、96 attention heads、8 KV heads、160 total experts、每 token 8 active experts、1 shared expert、QK-Norm yes。
GLM-4.5-Air:106B total、12B activated、1 dense layer、45 MoE layers、hidden dim 4096、MoE intermediate 1408、128 total experts、每 token 8 active experts、QK-Norm no。Table 2 的 base model 对比显示,GLM-4.5-Base 在 EvalPlus pass@1 为 78.1、LiveCodeBench-Base pass@1 为 28.1,在代码 base 评估上强于 DeepSeek-V3 Base 的 65.6/24.6;
但在 MATH 61.0 和 GSM8K 79.4 上不如 Qwen3-235B-A22B Base 的 71.8/94.4,说明 base 阶段不是所有数学指标都领先,后续 reasoning RL 和 SFT 对最终模型很关键。
4.2 Agentic 能力
Agentic 表格包括 TAU-Retail、TAU-Airline、BFCL V3、BrowseComp。GLM-4.5 在 TAU-Retail 为 79.7、TAU-Airline 为 60.4,两项平均约 70.1;BFCL V3 为 77.8,是表中最佳;BrowseComp 为 26.4,弱于 o3 的 49.7,但接近 o4-mini 的 28.3,并明显强于 Claude Opus 4 的 18.8。论文强调 TAU-bench 使用了优化 user simulator,BFCL 衡量 function calling,BrowseComp 衡量复杂浏览查找正确答案。结论是:GLM-4.5 在 function calling 上非常强,在 web browsing 上进入第二梯队,但与 o3 仍有明显差距。
4.3 Reasoning 能力
Reasoning benchmark 包括 MMLU-Pro、AIME 24、MATH 500、SciCode、GPQA、HLE、LiveCodeBench。GLM-4.5 的关键数值是:MMLU-Pro 84.6、AIME 24 91.0、MATH 500 98.2、SciCode 41.7、GPQA 79.1、HLE 14.4、LCB 72.9,AA-Index estimated 67.7。它在 AIME 24 高于 o3 的 90.3、Claude Opus 4 的 75.7、Gemini 2.5 Pro 的 88.7、DeepSeek-R1-0528 的 89.3,但低于 Qwen3-235B-2507 的 94.1 和 Grok 4 的 94.3。在 GPQA 和 HLE 上,GLM-4.5 仍落后于 Grok 4、Gemini 2.5 Pro、o3 等最强模型。这个结果更像“开放模型进入 closed-model reasoning 第一梯队附近”,而不是全面 SOTA。
4.4 Coding 能力
Coding 表格使用 SWE-bench Verified 和 Terminal-Bench。GLM-4.5 在 SWE-bench Verified 为 64.2,GLM-4.5-Air 为 57.6;Claude Sonnet 4 为 70.4,o3 为 69.1,Kimi K2 为 65.4,GPT-4.1 为 48.6,Gemini 2.5 Pro 为 49.0。Terminal-Bench 上 GLM-4.5 为 37.5,高于 Claude Sonnet 4 的 35.5、o3 的 30.2、GPT-4.1 的 30.3、Kimi K2 的 25.0,但低于 Claude Opus 4 的 43.2。作者使用 OpenHands v0.34.0 评估 SWE-bench,运行限制 100 iterations,并做 history truncation 避免超过 128K context;Terminal-Bench 使用 Terminus framework 和标准 function calling,而不是 direct prompting。
4.5 安全、人工评测与 CC-Bench
SafetyBench 上 GLM-4.5 平均 89.9,接近 Gemini 2.5 Pro 90.5、Kimi K2 90.5、GPT-4.1 89.7;其中 Physical Health 96.7、Privacy & Property 92.0、Illegal Activities 91.0,但 Unfairness & Bias 77.4,是相对弱项。人工评测中,GLM-4.5 在英文 prompts overall 8.66,中文 prompts overall 8.37,多语言 prompts overall 8.49;作者报告其在英文和中文 prompt set 上平均得分领先对比模型。
CC-Bench 是作者构建的 agentic coding benchmark,基于 Claude Code,包含 52 个编程任务。GLM-4.5 对 Claude Sonnet 4 的 head-to-head 是 40.4% win、9.6% tie、50.0% loss;对 Kimi K2 是 53.9% win、17.3% tie、28.8% loss;对 Qwen3-Coder 是 80.8% win、7.7% tie、11.5% loss。Figure 13 显示 GLM-4.5 的 tool calling success rate 为 90.6%,高于 Claude Sonnet 4 的 89.5%、Kimi-K2 的 86.2%、Qwen3-Coder 的 77.1%。这支持论文关于 function-calling template、agentic RL 和格式奖励的重要性。
Figure 12 解读:CC-Bench 胜率显示 GLM-4.5 还没有超过 Claude Sonnet 4,但已经超过 Kimi K2 和 Qwen3-Coder。对开发者而言,这比单纯 SWE-bench 更接近日常 agentic coding 使用,因为它包含多步工具调用、代码修改和轨迹评估。
Figure 13 解读:这张图把成功率和 token usage 放在一起看。GLM-4.5 的优势不只是最终代码得分,也包括工具调用可靠性;agent 系统里格式错误会直接导致环境失败,所以 90.6% 的 tool calling success rate 是实际可用性的重要证据。
5. 代码实现、复现路径与局限
5.1 代码搜索结论
代码搜索找到了官方主仓库 zai-org/GLM-4.5、官方评测仓库 zai-org/glm-simple-evals,以及主仓库 README 指向的 Transformers、vLLM、SGLang GLM4-MoE 实现。需要明确的是:官方主仓库主要提供模型下载链接、部署说明、tool calling 示例、Claude Code 配置示例和推理脚本;没有发现完整预训练、SFT、RL 训练 launch script 或训练数据 pipeline 源码。因此,本文中的训练超参数、stage token 数、RL curriculum 和数据组成只能追溯到 paper;公开代码可以验证模型配置、router/attention/MoE 实现、推理接口、tool calling 示例和评测工具,而不能完全复现实验训练。
5.2 Code mapping table
| Paper Concept | Source File | Key Class/Function |
|---|---|---|
| 官方模型发布、部署、thinking 开关、tool calling 说明 | zai-org/GLM-4.5/README.md | SGLang/vLLM/Transformers sections; extra_body={"chat_template_kwargs": {"enable_thinking": False}} guidance |
| OpenAI-style tool calling 示例 | zai-org/GLM-4.5/inference/api_request.py | OpenAI(...), client.chat.completions.create(...), tools, second-round tool response |
| Transformers 本地推理 | zai-org/GLM-4.5/inference/trans_infer_cli.py | AutoTokenizer.apply_chat_template, AutoModelForCausalLM.from_pretrained, model.generate |
| Claude Code / agentic coding router 示例 | zai-org/GLM-4.5/example/claude_code/config.example.json | Providers, Router.default/background/think/longContext/webSearch |
| GLM4-MoE 配置字段 | transformers/src/transformers/models/glm4_moe/configuration_glm4_moe.py; HF config.json | Glm4MoeConfig, num_hidden_layers, n_routed_experts, num_experts_per_tok, use_qk_norm |
| MoE routing 与 shared/routed experts | transformers/src/transformers/models/glm4_moe/modeling_glm4_moe.py | Glm4MoeTopkRouter, route_tokens_to_experts, Glm4MoeSparseMoeBlock |
| GQA、QK-Norm、RoPE attention | transformers/src/transformers/models/glm4_moe/modeling_glm4_moe.py | Glm4MoeAttention, q_proj/k_proj/v_proj/o_proj, q_norm/k_norm |
| Causal LM wrapper | transformers/src/transformers/models/glm4_moe/modeling_glm4_moe.py | Glm4MoeModel, Glm4MoeForCausalLM |
| Serving-side MTP / GLM4-MoE implementation | vllm/model_executor/models/glm4_moe_mtp.py | vLLM GLM4-MoE MTP model path |
| SGLang rollout/serving implementation | sglang/python/sglang/srt/models/glm4_moe.py | SGLang GLM4-MoE serving model |
| ARC benchmark reproduction toolkit | zai-org/glm-simple-evals/evaluate.py | task registry for AimeEval, GPQAEval, MathEval, SciCodeEval, MMLUProEval, HLEEval |
| AIME repeated sampling | zai-org/glm-simple-evals/evals/aime_eval.py | AimeEval, n_repeats=32 for AIME 2024/2025 in non-debug mode |
| Evaluation aggregation | zai-org/glm-simple-evals/evals/common.py | aggregate_results, EvalResult, score mean/std aggregation |
5.3 公开实现伪代码
# Inference with the official example pattern.
client = OpenAI(api_key="EMPTY", base_url="http://127.0.0.1:8000/v1")
completion = client.chat.completions.create(
model="zai-org/GLM-4.5",
messages=[{"role": "user", "content": "call the tool if needed"}],
tools=[openai_style_function_schema],
max_tokens=4096,
temperature=0.0,
# Disable thinking for quick-response mode:
# extra_body={"chat_template_kwargs": {"enable_thinking": False}},
)
if completion.choices[0].message.tool_calls:
tool_args = json.loads(completion.choices[0].message.tool_calls[0].function.arguments)
tool_result = run_tool(tool_args)
messages.extend([completion.choices[0].message, tool_result])
final = client.chat.completions.create(model="zai-org/GLM-4.5", messages=messages, tools=tools)# Transformers local generation path.
tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-4.5")
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
return_tensors="pt",
)
model = AutoModelForCausalLM.from_pretrained(
"zai-org/GLM-4.5",
torch_dtype=torch.bfloat16,
device_map="auto",
)
generated_ids = model.generate(**inputs.to(model.device), max_new_tokens=128, do_sample=False)5.4 复现注意事项
第一,训练不可完全复现。论文给出大量训练策略和关键超参,但没有公开完整数据、训练脚本、SFT/RL 配置或 Slime 训练 job 配置。读者能复现的是模型推理、部署、部分 benchmark evaluation,而不是从头训练 GLM-4.5。第二,主仓库在 2026-05-19 已经同时覆盖 GLM-4.7、GLM-4.6、GLM-4.5,示例代码默认值可能写成 zai-org/GLM-4.7;做 GLM-4.5 笔记时应把它理解为同系列接口示例,而不是 paper 训练代码。第三,evaluation code 主要覆盖 reasoning 类 benchmark,SWE-bench、Terminal-Bench、CC-Bench 的完整环境复现还依赖 OpenHands、Terminus、Claude Code 风格工具环境和外部数据集。
5.5 局限与读者应保留的疑问
论文是技术报告,包含大量系统与训练经验,但许多关键细节仍是高层描述。比如 pretraining 数据过滤阈值、具体数据比例、expert model 的参数与训练 step、RL reward model 训练细节、agentic RL 的任务采样分布、self-distillation 的触发条件和 plateau 判定,都没有完全展开。由于没有训练源码,读者无法判断某些提升来自架构、数据、SFT、RL、评测 prompt、工具环境还是 ensemble-like expert iteration。
第二,很多评估是强工程环境下的综合能力测试。SWE-bench 使用 OpenHands、Terminal-Bench 使用 Terminus,CC-Bench 基于 Claude Code,并且工具调用格式、历史截断、temperature、top_p、最大交互轮次都会影响结果。GLM-4.5 在 Terminal-Bench 高于 Claude Sonnet 4,但在 CC-Bench head-to-head 仍输给 Sonnet 4;这说明 coding-agent 能力不能由单个 benchmark 判定。
第三,安全与偏见还有明显待改进点。SafetyBench 平均分接近 GPT-4.1 与 Kimi K2,但 Unfairness & Bias 只有 77.4,低于其他安全类别。对实际部署来说,agentic 模型能调用工具和执行代码,安全约束应覆盖工具权限、数据泄露、prompt injection、网页浏览攻击、代码执行沙箱等更复杂场景,而 SafetyBench 的 multiple-choice 形式只能部分反映风险。
最后,GLM-4.5 的一个真正价值在于公开权重和部署生态。即使训练无法复现,研究者仍可以基于 HF/vLLM/SGLang 跑大规模推理、做工具调用实验、复现 reasoning evaluation,并分析 MoE routing、thinking/non-thinking 模板和 agentic serving 行为。对于想做 ARC foundation model 的团队,这篇报告最值得借鉴的不是某一个公式,而是“base/mid-training 数据先铺底,专家 SFT/RL 产生能力,再统一蒸馏,最后用异步 infra 支撑长 agent RL”的系统路线。