Skip to content
StackDecode
LLM Library
Dense decoderOpen weightsArchitecture animation

Gemma 2

Small open models that alternate local and global attention layers.

At a glance

Made by
Google
Released
2024
Type
Dense decoder
Access
Open weights
Parameters
2B, 9B, 27B
Context window
8,192 tokens
Attention
Alternating local sliding-window and global attention, GQA

How it works

Gemma 2 alternates layers that look only at a 4,096-token window with layers that look at everything, and uses logit soft-capping and extra normalisation. Smaller models were trained by distillation from a larger one.

Architecture, step by step

A token travels from text in to prediction out. The boxed layers repeat many times.

× N layersText inTokenizerEmbedding + positionNormCausal self-attentionAdd (residual)NormFeed-forward (MLP)Add (residual)Final normLM head (vocabulary scores)Softmax, then sample next token

Raw text enters the system, for example "The cat sat on the".

stage:
1/12
part:
Text in
1/12

The green dot is one token travelling through the model. The boxed section repeats for every layer.

What stands out

  • Local-global attention
  • Logit soft-capping
  • Knowledge distillation

Keep in mind

Short context compared with later releases.

Related models