recurrent_gemma_tiny
A DeepMind language model mixing gated linear recurrences with local attention, captured as tiny RecurrentGemma.
Language · 226 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Language
- Parameters
- 71.7K
- Operations
- 226
- Framework
- PyTorch
- Recurrent
- No
- Published
- 2024
- Cited by
- 369 (as of 24 November 2026)
- Authors
- Soham De, Samuel L. Smith, Anushan Fernando and others
- Source
- transformers 5.18.0
- License
- Apache-2.0
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m8684
- Graph hash
- 562763078f4053a14eff63ae91d51be4959c182632da1f91c470991b50e44781
- Skeleton hash
- 031b67305f2c51c7d633a53391ec9d3d62af0e22b4439b7638f9f50d96063f25
- Architecture hash
- e3f81bd74722525a26f696692e03fbc045a8fc2b6a49926fa678a439dd14780f
- Diagram SHA-256
- 80744c50229c61e8214dbe09da2e00dbd51dd14b1ee9e61cc28d26f956803cb5
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
How this diagram was made
transformers.RecurrentGemmaForCausalLM()
What it is
Griffin is a hybrid language model architecture that mixes gated linear recurrences with local attention, developed alongside Hawk, a pure RNN built from the same recurrent block. The motivation is that Transformers are difficult to scale efficiently to long sequences due to the quadratic complexity of global attention, and the linear growth of the KV cache with sequence length makes them slow during inference.
All of the models share a residual block, an MLP block and a temporal-mixing block, with three candidate temporal-mixing blocks: global multi-query attention, local sliding-window attention and the proposed recurrent block. The recurrent block splits its input into two branches with parallel linear layers, and the first branch applies a small separable Conv1D layer with a temporal filter dimension of 4. That Conv1D feeds the RG-LRU layer, while the second branch applies a GeLU nonlinearity before the two are merged by element-wise multiplication. The Real-Gated Linear Recurrent Unit, RG-LRU, has a simple recurrence inspired by the Linear Recurrent Unit but adds a gating mechanism motivated by LSTMs and GRUs. Griffin alternates two residual blocks with a recurrent block followed by one residual block using local attention, with the local attention window fixed to 1024 tokens. The authors found this combination extremely effective, since local attention accurately models the recent past while the recurrent layers can transmit information across long sequences.
Griffin achieves lower validation loss than the Transformer baseline across all FLOPs budgets despite not using any global attention layers. Griffin-7B and Griffin-14B achieve performance competitive with Llama-2 despite being trained on nearly 7 times fewer tokens. During inference both Hawk and Griffin achieve significantly higher throughput than MQA Transformers and lower latency when sampling long sequences. The captured member is a tiny configuration of RecurrentGemma, a family of open language models which uses Griffin. RecurrentGemma makes only a single modification to Griffin, multiplying the input embeddings by a constant equal to the square root of model width. It ships in 2B and 9B sizes, with pre-trained and instruction tuned variants for both, and achieves comparable performance to similarly-sized Gemma baselines despite being trained on fewer tokens.
Key idea. Griffin replaces global attention with a mixture of the RG-LRU gated linear recurrent block and local attention, keeping a fixed-size state so that it matches Transformer hardware efficiency in training while gaining lower latency and higher throughput at inference.
- griffin
- hawk
- recurrentgemma
- rg-lru
- real-gated linear recurrent unit
- gated linear recurrences
- local attention
- sliding window attention
- recurrent language model
- efficient inference
- fixed-size state
- google deepmind
- recurrent_gemma
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{de2024griffinmixinggatedlinear,
title={Griffin: Mixing Gated Linear Recurrences with Local Attention for Efficient Language Models},
author={Soham De and Samuel L. Smith and Anushan Fernando and Aleksandar Botev and George Cristian-Muraru and Albert Gu and Ruba Haroun and Leonard Berrada and Yutian Chen and Srivatsan Srinivasan and Guillaume Desjardins and Arnaud Doucet and David Budden and Yee Whye Teh and Razvan Pascanu and Nando De Freitas and Caglar Gulcehre},
year={2024},
eprint={2402.19427},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2402.19427},
}