GLM · 2024-06 · 稠密

GLM-4 9B

GLM-4 9B 是 GLM 于 2024-06 发布的 分组查询注意力(GQA) Transformer,共 40 层,隐藏维度 4096,上下文窗口 8,192 个 token。

层堆栈

注意力 ×40 · 层数 40

关键参数

实验室GLM
发布时间2024-06
总参数9.4 B
上下文8,192 tokens
注意力GQA (32:2)
层数40
隐藏维度4,096
注意力头32
词表
位置编码
归一化
激活函数
训练精度bf16
架构类名ChatGLMModel

架构概览

t₁ t₂ t₃ t₄ 输入 token Embedding · 词表 — → 隐藏维度 4,096 Q1 Q2 Q3 Qn KV1 KV2 注意力头 32 KV 头 2 head dim 128 · FFN · FFN 维度 13,696 × 40 Transformer 块 注意力 前馈 / MoE pre-norm 最终归一化 · LM head → 词表 — p p p → 下一 token 位置编码 训练精度 BF16 上下文 8K tok
依据随权重发布的 config.json 绘制 · 40 层 / 宽 4,096 / 上下文 8,192。本图为本站原创示意图。

注意力

分组查询注意力(GQA) — 32 q-heads / 2 kv-heads.

前馈 / MoE

它是稠密模型:全部 9.4B 参数都参与每个 token 的计算。

字段级对比

对比对象为同实验室的上一代模型;无前代时取结构最相似的模型。倍数列 = 本模型数值 ÷ 对比模型数值。

与前代 ChatGLM3 6B 的全字段对比
模型GLM-4 9BChatGLM3 6B倍数
model_typechatglmchatglm
architecturesChatGLMModelChatGLMModel
hidden_size40964096≈1
num_attention_heads3232≈1
torch_dtypebfloat16float16
_name_or_pathTHUDM/glm-4-9bTHUDM/chatglm3-6b
add_bias_linearfalsefalse
add_qkv_biastruetrue
apply_query_key_layer_scalingtruetrue
apply_residual_connection_post_layernormfalsefalse
attention_dropout00
attention_softmax_in_fp32truetrue
attn_implementationsdpa
bias_dropout_fusiontruetrue
ffn_hidden_size1369613696≈1
fp32_residual_connectionfalsefalse
hidden_dropout00
kv_channels128128≈1
layernorm_epsilon1.5625e-70.00001×0.016
multi_query_attentiontruetrue
multi_query_group_num22≈1
num_layers4028×1.43
original_ropetruetrue
padded_vocab_size15155265024×2.33
post_layer_normtruetrue
rmsnormtruetrue

结构最相似的模型

相似度取值范围 0(无共同类别特征)到 1(结构画像完全一致)。

原始 config 字段

32 个字段
_name_or_pathTHUDM/glm-4-9b
model_typechatglm
architecturesChatGLMModel
add_bias_linearfalse
add_qkv_biastrue
apply_query_key_layer_scalingtrue
apply_residual_connection_post_layernormfalse
attention_dropout0
attention_softmax_in_fp32true
attn_implementationsdpa
bias_dropout_fusiontrue
ffn_hidden_size13696
fp32_residual_connectionfalse
hidden_dropout0
hidden_size4096
kv_channels128
layernorm_epsilon1.5625e-7
multi_query_attentiontrue
multi_query_group_num2
num_attention_heads32
num_layers40
original_ropetrue
padded_vocab_size151552
post_layer_normtrue
rmsnormtrue
seq_length8192
use_cachetrue
torch_dtypebfloat16
transformers_version4.44.0
tie_word_embeddingsfalse
eos_token_id151329×1 + 151336×1 + 151338×1
pad_token_id151329