OpenAI · 2019-02 · Dense

GPT-2

GPT-2 is a multi-head attention (MHA) transformer released by OpenAI in 2019-02, with 12 layers, hidden size 768 and a context window of 1,024 tokens.

Layer stack

Attention ×12 · Layers 12

Key facts

FamilyOpenAI
Released2019-02
Params1.24 B
Context1,024 tokens
AttentionMHA (12:12)
Layers12
Hidden768
Heads12
Vocab50,257
Positionlearned-absolute
NormLayerNorm
Activation
Dtypebf16
Architecture classGPT2LMHeadModel

Architecture overview

t₁ t₂ t₃ t₄ input tokens Embedding · Vocab 50,257 → Hidden 768 Q1 Q2 Q3 Qn KV1 KV2 KV3 KVn Heads 12 KV heads 12 head dim 64 · learned-absolute FFN · FFN dim — × 12 transformer block Attention Feed-forward / MoE LayerNorm pre-norm Final norm · LayerNorm LM head → Vocab 50,257 p p p → next token Position learned-absolute Dtype BF16 Context 1K tok
Drawn from the shipped config.json · 12 layers / width 768 / context 1,024. Original diagram by this atlas.

Attention

multi-head attention (MHA) — 12 q-heads / 12 kv-heads.

Feed-forward / MoE

It is a dense model: all 1.24B 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 most-similar GPT-3 175B (paper)
ModelGPT-2GPT-3 175B (paper)Ratio
model_typegpt2gpt3-paper
architecturesGPT2LMHeadModel
hidden_size12288
num_attention_heads96
max_position_embeddings2048
layer_norm_epsilon0.00001
vocab_size5025750257≈1
activation_functiongelu_new
attn_pdrop0.1
bos_token_id50256
embd_pdrop0.1
eos_token_id50256
initializer_range0.02
n_ctx1024
n_embd768
n_head12
n_layer12
n_positions1024
resid_pdrop0.1
summary_first_dropout0.1
summary_proj_to_labelstrue
summary_typecls_index
summary_use_projtrue

Most similar architectures

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

Raw config fields

20 fields
activation_functiongelu_new
architecturesGPT2LMHeadModel
attn_pdrop0.1
bos_token_id50256
embd_pdrop0.1
eos_token_id50256
initializer_range0.02
layer_norm_epsilon0.00001
model_typegpt2
n_ctx1024
n_embd768
n_head12
n_layer12
n_positions1024
resid_pdrop0.1
summary_first_dropout0.1
summary_proj_to_labelstrue
summary_typecls_index
summary_use_projtrue
vocab_size50257