GLM · 2024-06 · Dense

GLM-4 9B

GLM-4 9B is a grouped-query attention (GQA) transformer released by GLM in 2024-06, with 40 layers, hidden size 4096 and a context window of 8,192 tokens.

Layer stack

Attention ×40 · Layers 40

Key facts

FamilyGLM
Released2024-06
Params9.4 B
Context8,192 tokens
AttentionGQA (32:2)
Layers40
Hidden4,096
Heads32
Vocab
Position
Norm
Activation
Dtypebf16
Architecture classChatGLMModel

Architecture overview

t₁ t₂ t₃ t₄ input tokens Embedding · Vocab — → Hidden 4,096 Q1 Q2 Q3 Qn KV1 KV2 Heads 32 KV heads 2 head dim 128 · FFN · FFN dim 13,696 × 40 transformer block Attention Feed-forward / MoE pre-norm Final norm · LM head → Vocab — p p p → next token Position Dtype BF16 Context 8K tok
Drawn from the shipped config.json · 40 layers / width 4,096 / context 8,192. Original diagram by this atlas.

Attention

grouped-query attention (GQA) — 32 q-heads / 2 kv-heads.

Feed-forward / MoE

It is a dense model: all 9.4B parameters participate in computing every token.

Field-level comparison

Compared against the previous model of the same lab; where none exists, against the structurally closest model. The ratio column is this model divided by the comparison model.

Full-field comparison vs predecessor ChatGLM3 6B
ModelGLM-4 9BChatGLM3 6BRatio
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

Most similar architectures

Similarity values range from 0 (no shared categorical features) to 1 (identical profiles).

Raw config fields

32 fields
_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