Gated Linear Units › Gated Linear Units

Michael BrenndoerferUpdated June 14, 20252 min read
Language AI HandbookAll chapters
Part 15 of 67Transformer Blocks
Chapter 109Gated Linear Units › Gated Linear Units
Reading section 1 of 16 · Gated Linear Units · 2 minSection 1 of 16 · 2 min

Book contents

Section 1 of 16 · 2 min read

Gated Linear Units › Gated Linear UnitsOne section · Sections in this chapter1 / 16 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

The standard feed-forward network in transformers applies a simple formula: expand the dimension, apply an activation function, contract back. This works, but researchers discovered something better. By adding a gating mechanism, where one pathway controls how much of another pathway passes through, the FFN becomes significantly more expressive. This insight, borrowed from recurrent neural networks, has become the default choice in modern large language models.

Gated Linear Units (GLUs) replace the single nonlinearity in the FFN with a product of two linear projections, one of which passes through an activation function to produce "gate" values between 0 and 1. These gates control information flow: they can fully pass, partially attenuate, or completely block the signal from the other pathway. This multiplicative interaction creates richer representations than a simple pointwise nonlinearity.

The change is visible in current model designs. Current architectures commonly use GLU variants, with LLaMA and Mistral among the examples. SwiGLU has become particularly common in state-of-the-art LLMs. This gives improved training dynamics and better later performance at comparable parameter counts. This chapter explains why gating works, how to implement it, and the trade-offs that come with this more sophisticated architecture.