Paper commentary
ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Tools
GLM-4 family matches GPT-4 on several benchmarks while adding tool use
- Problem Keeping a chat model family competitive across generations means changing pre-training, architecture and alignment together. Each comparison with GPT-4 depends on its own test conditions, so results are hard to read side by side.
- Method GLM-4 keeps the transformer family but swaps LayerNorm and ReLU for RMSNorm and SwiGLU. It adopts Group Query Attention, trains on about ten trillion tokens, then aligns with supervised fine-tuning and RLHF.
- Results GLM-4 (0520) scores 83.3 on MMLU and 93.3 on GSM8K, against 86.4 and 92.0 for GPT-4 (0314).
What the report covers
The report covers the ChatGLM family, and its main focus is the GLM-4 language models, namely GLM-4, GLM-4-Air and GLM-4-9B. The authors present these models as the most capable outcome of three earlier ChatGLM generations, so the lessons from ChatGLM-6B, ChatGLM2-6B and ChatGLM3-6B feed directly into them.
Different versions carry different roles. GLM-4 (0116) has been served through the GLM-4 API since January 2024, GLM-4 All Tools is reachable through a website and mobile applications, and GLM-4 (0520) and GLM-4-Air (0605) are the latest checkpoints.
How context length and capability changed across generations
ChatGLM2-6B was pre-trained and aligned on higher-quality data and adopted FlashAttention, which extended its context to 32K, while Multi-Query Attention added a 42% increase in inference speed.
The report lists gains over the predecessor of 23% on MMLU, 571% on GSM8K and 60% on BBH for ChatGLM2-6B. The context window then grew to 32K for ChatGLM2 and ChatGLM3, and to 128K and 1M for GLM-4, with the 1M version labelled experimental.
Table 1 tracks the same progression on a shared set of benchmarks, moving from ChatGLM-6B's 1.5 on GSM8K and 25.2 on MMLU to 84.0 and 74.7 for GLM-4-9B. The table compares the earlier models with a base version of ChatGLM3-6B, so it measures generation-to-generation change rather than a single fixed setup.
Architecture changes in GLM-4
GLM-130B used DeepNorm for layer normalisation, Rotary Positional Encoding, and a Gated Linear Unit with GeLU in its feed-forward networks. GLM-4 keeps the transformer family but drops every bias term except the biases of the query, key and value projections in attention, which the authors chose to speed up training and which they found to slightly help length extrapolation.
GLM-4 replaces LayerNorm with RMSNorm and ReLU with SwiGLU, and the authors state that both changes improved model performance. The report gives no separate number for either change, so the claim rests on the authors' statement.
The rotary positional embedding is extended to a two-dimensional form so that it can carry the 2D positional encoding that GLM uses. Group Query Attention replaces Multi-Head Attention to shrink the key-value cache at inference. Because it has fewer parameters, the feed-forward width d_ffn is set to 10/3 of the hidden size, which keeps the overall model size the same.
Pre-training data and tokenizer
The corpus is multilingual, mostly English and Chinese, and drawn from webpages, Wikipedia, books, code and research papers. Processing runs in three stages: deduplication, which removes exact and near-duplicate documents, filtering, which removes noisy web text such as offensive language, placeholder text and source code, and tokenization.
Byte-level byte pair encoding learns Chinese and multilingual tokens separately, and these are merged with the cl100k_base tokens from tiktoken into one vocabulary of 150,000 tokens. The authors note that the token count directly affects training speed, which is why the tokenizer design matters for cost.
Sources are re-weighted so that high-quality, educational material such as books and Wikipedia carries more weight, and the training set reaches around ten trillion tokens. The authors say data quality and diversity matter, but they have not found a principle that governs collection, cleaning and selection.
Alignment with SFT and RLHF
Alignment is mostly done with supervised fine-tuning followed by reinforcement learning from human feedback. The authors found that real human prompts and interactions gave better alignment quality than template-based or model-generated responses.
The first generation's prompt-response pairs were annotated mostly by the model developers, while later models combine in-house annotation with third-party proprietary data under quality control. Annotators score responses on safety, factuality, relevance, helpfulness and human preference.
RLHF is credited with reducing response rejection, unsafe answers, mixing of bilingual tokens and loss of coherence across turns.
Base capability on academic benchmarks
Six benchmarks are used: MMLU, GSM8K, MATH, BBH, GPQA and HumanEval, with chain-of-thought prompting applied to GSM8K, MATH and BBH. The comparison baseline in the results table is GPT-4 (0314).
Against GPT-4 (0314), GLM-4 (0520) scores 83.3 on MMLU, 93.3 on GSM8K, 61.3 on MATH, 84.7 on BBH, 39.9 on GPQA and 78.5 on HumanEval, while GPT-4 (0314) scores 86.4, 92.0, 52.9, 83.1, 35.7 and 67.0. On MMLU the report puts GLM-4 at 96.3% of GPT-4's accuracy.
GLM-4 (0520) is below GPT-4 Turbo (2024-04-09) on MMLU, 83.3 against 86.7, but the table shows it above GPT-4 (0314) on the other five columns. GLM-4-Air (0605) and GLM-4-9B-Chat are separate models with lower scores, such as 81.9 and 72.4 on MMLU, so their numbers should not be read as GLM-4 results.
Instruction following and Chinese alignment
IFEval contains 541 prompts built from 25 instruction types that can be checked by explicit rules, and it is scored at prompt level and instruction level in strict and loose modes. For Chinese, the prompts were translated, instructions that do not apply in Chinese were dropped, and the scoring scripts were adjusted.
On English prompts, GLM-4 (0520) reaches 83.7 loose prompt-level and 85.0 strict instruction-level accuracy, against 84.5 and 85.9 for GPT-4 Turbo (2024-04-09). Expressed as shares of GPT-4 Turbo (2024-04-09), the strict instruction-level result is 99.0% in English and 98.6% in Chinese.
AlignBench v1.1 has 683 queries in 8 categories, scored by a GPT-4 based judge against references. GLM-4 (0520) has an overall score of 8.00, equal to GPT-4 Turbo (2024-04-09), and above GPT-4 Turbo (1106) at 7.90, Claude 3 Opus at 7.53 and Gemini 1.5 Pro at 7.47.
The authors identify mathematics as the main gap to GPT-4 Turbo (2024-04-09), with GLM-4 (0520) at 7.89 against 8.32 on Math. Chinese Logic and Language Understanding are where the authors report GLM-4 clearly leading the other models.
Long context and coding on realistic prompts
LongBench-Chat covers context lengths from 10k to 100k and includes document Q&A, summarization and coding, and results are split into English and Chinese. Scores come from GPT-4 judging outputs with a few-shot strategy, and the reported values are averages over repeated runs.
On English LongBench-Chat, GLM-4 (0520) scores 87.3, against 87.2 for GPT-4 Turbo (1106) and 87.7 for Claude 3 Opus. On Chinese it scores 84.0, above Claude 3 Opus at 82.7 and GPT-4 Turbo (2024-04-09) at 82.1.
NaturalCodeBench uses real user prompts in Python and Java, in English and Chinese, and the authors present it because HumanEval problems are mostly introductory and may be contaminated in training data.
Function calling, agents and All Tools
GLM-4 (0520) has an overall score of 81.76, close to GPT-4 Turbo (2024-04-09) at 81.24 and GLM-4-9B-Chat at 81.00, while Llama-3-8B-Instruct scores 58.88.
AgentBench is run on 7 of its 8 environments, with the Digital Card Game left out because it is too time-consuming to interact with, and overall scores use the per-dataset weights of AgentBench. GLM-4 (0520) reaches an overall score of 3.79, above GPT-4 Turbo (1106) at 3.77, GPT-4 (0613) at 3.69 and Claude 3 Opus at 3.62.
The authors identify Database, House Holding and Web Shopping as strengths, and Operating System, Knowledge Graph and Lateral Thinking Puzzles as gaps against GPT-4 models. For All Tools, GLM-4 All Tools (Web, 0116) scores 91.59 on GSM8K, 63.60 on MATH and 88.50 on Math23K, against 92.72, 65.00 and 88.40 for GPT-4 (Web, 0110), and 78.08 against 67.12 on browser information seeking.
Safety evaluation and risk mitigation
Pre-training data was cleaned by removing sensitive keywords and blacklisted web pages, and every alignment sample was checked for safety before training. A red team challenges the model with tricky questions, and the harmful question-answer pairs it finds are improved with human annotation.
SafetyBench is scored on 7 dimensions using its Chinese subset, from which highly sensitive, censored questions were removed. GLM-4 (0520) has an overall score of 87.2, close to Claude 3 Opus at 87.5 and below GPT-4 (0613) at 89.7.
On Physical Health GLM-4 (0520) scores 92.3, below GPT-4 (0613) at 96.7, and the authors name this dimension as the one that needs stronger common-sense knowledge about the physical world.
Limitations
The overall AlignBench result is a tie with GPT-4 Turbo (2024-04-09) at 8.00, not a lead.
On NaturalCodeBench GLM-4 (0520) stays below GPT-4 models, and the authors say their remaining work is to improve it through training strategies and data curation. On AgentBench the gap to GPT-4 series remains on Operating System, Knowledge Graph and Lateral Thinking Puzzles.
The All Tools comparison pits GLM-4 All Tools (Web, 0116) against GPT-4 (Web, 0110) and is described as a first-hand test, so it is not a controlled benchmark. Long-context scores are judged by GPT-4 on a few-shot setup, and GLM-4 (0520) trails Claude 3 Opus on English at 87.3 against 87.7.
The architecture changes come without separate ablation numbers, and the report gives no latency or inference-cost measurements for GLM-4-Air.
Paper info
- Authors
- Team GLM, :, Aohan Zeng, Bin Xu, Bowen Wang, Chenhui Zhang, Da Yin, Dan Zhang, Diego Rojas, Guanyu Feng, Hanlin Zhao, Hanyu Lai, Hao Yu, Hongning Wang, Jiadai Sun, Jiajie Zhang, Jiale Cheng, Jiayi Gui, Jie Tang, Jing Zhang, Jingyu Sun, Juanzi Li, Lei Zhao, Lindong Wu, Lucen Zhong, Mingdao Liu, Minlie Huang, Peng Zhang, Qinkai Zheng, Rui Lu, Shuaiqi Duan, Shudan Zhang, Shulin Cao, Shuxun Yang, Weng Lam Tam, Wenyi Zhao, Xiao Liu, Xiao Xia, Xiaohan Zhang, Xiaotao Gu, Xin Lv, Xinghan Liu, Xinyi Liu, Xinyue Yang, Xixuan Song, Xunkai Zhang, Yifan An, Yifan Xu, Yilin Niu, Yuantao Yang, Yueyan Li, Yushi Bai, Yuxiao Dong, Zehan Qi, Zhaoyu Wang, Zhen Yang, Zhengxiao Du, Zhenyu Hou, Zihan Wang
- Venue
- arXiv · Preprint
- First published
- 2024-6-18
- Added
- 2026-11-12
- Updated
- 2024-7-30
- Version
- v2
- arXiv
- 2406.12793
- Category
- cs.CL
- Original paper terms
- CC BY 4.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Team GLM, :, Aohan Zeng, Bin Xu, Bowen Wang, Chenhui Zhang, Da Yin, Dan Zhang, Diego Rojas, Guanyu Feng, Hanlin Zhao, Hanyu Lai, Hao Yu, Hongning Wang, Jiadai Sun, Jiajie Zhang, Jiale Cheng, Jiayi Gui, Jie Tang, Jing Zhang et al. (2024). ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Tools. arXiv:2406.12793v2. https://arxiv.org/abs/2406.12793v2
BibTeX
@misc{glm2024chatglm,
title = {{ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Tools}},
author = {Team GLM and : and Aohan Zeng and Bin Xu and Bowen Wang and Chenhui Zhang and Da Yin and Dan Zhang and Diego Rojas and Guanyu Feng and Hanlin Zhao and Hanyu Lai and Hao Yu and Hongning Wang and Jiadai Sun and Jiajie Zhang and Jiale Cheng and Jiayi Gui and Jie Tang and Jing Zhang and Jingyu Sun and Juanzi Li and Lei Zhao and Lindong Wu and Lucen Zhong and Mingdao Liu and Minlie Huang and Peng Zhang and Qinkai Zheng and Rui Lu and Shuaiqi Duan and Shudan Zhang and Shulin Cao and Shuxun Yang and Weng Lam Tam and Wenyi Zhao and Xiao Liu and Xiao Xia and Xiaohan Zhang and Xiaotao Gu and Xin Lv and Xinghan Liu and Xinyi Liu and Xinyue Yang and Xixuan Song and Xunkai Zhang and Yifan An and Yifan Xu and Yilin Niu and Yuantao Yang and Yueyan Li and Yushi Bai and Yuxiao Dong and Zehan Qi and Zhaoyu Wang and Zhen Yang and Zhengxiao Du and Zhenyu Hou and Zihan Wang},
year = {2024},
eprint = {2406.12793},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2406.12793v2}
}