Gaussian Error Linear Unit

A smooth activation function that keeps small negative values and is common in transformer feed-forward blocks.

The Gaussian Error Linear Unit, usually shortened to GELU, scales each input by how likely it is to be useful under a Gaussian-shaped gate. That gives transformer feed-forward blocks a smoother transition than rectified linear unit (ReLU), keeps some small negative values, and avoids the hard cutoff that classic ReLU uses.

At a glance

Released

June 2016

Authors

Dan Hendrycks, Kevin Gimpel

Optimizes

  • Smooth Gating

What It Is

The Gaussian Error Linear Unit, usually shortened to GELU, is an activation function that keeps an input value x, shrinks it, or nearly removes it depending on where x falls on a smooth Gaussian-shaped curve. Large positive values pass through strongly, values near 0 are only partly kept, and small negative values can still survive instead of being cut off at exactly 0.

Why It Exists

GELU exists because a hard on-or-off gate is not always the best filter for deep hidden states. ReLU keeps every positive value and drops every negative value. GELU instead treats the gate as smooth and probabilistic, so values near 0 are not forced into a sharp decision boundary.

How It Works

GELU works one value at a time. It multiplies x by a Gaussian cumulative score Phi(x). Large positive values get a score near 1, so they mostly pass through. Large negative values get a score near 0, so they mostly disappear. Values near 0 are only partly passed, which makes the curve look like a softened version of ReLU. In transformer feed-forward blocks, that smoother gate is often used after the first wide projection and before projecting back to the model width.
Activation Curves
f(x)
x
  • GELU
  • ReLU
  • SiLU

Math Or Compute Schema

The formula below shows the exact GELU rule. The important idea is that x is scaled by the Gaussian cumulative distribution Phi(x), which creates a smooth gate instead of a hard sign check.
Gaussian Error Linear Unit activation
GELU(x)=x Φ(x)\mathrm{GELU}(x) = x\,\Phi(x)
xx
One input value before the activation rule is applied.
GELU\mathrm{GELU}
Gaussian Error Linear Unit activation.
Φ\Phi
Cumulative distribution function of the standard normal distribution.

Compared To Nearby Modules

Compared with ReLU, GELU keeps the same broad idea of favoring positive values but replaces the hard cutoff with a smooth curve. Compared with SiLU, GELU is another smooth self-scaling activation, but the gate comes from the Gaussian cumulative distribution rather than sigmoid. That smoother shape is one reason transformer feed-forward blocks often prefer GELU over plain ReLU.
Comparison dimensionGELUReLUSiLU
Negative branchKeeps some small negative values with smooth shrinkageDrops every negative value to 0Shrinks negative values smoothly with x sigma(x)
Transition shapeSmooth ReLU-like curve with no hard cornerPiecewise-linear with a hard corner at 0Smooth self-gated curve through 0
Common useCommon dense activation in transformer feed-forward blocksClassic cheap baseline for dense hidden layersSmooth activation and gate inside SwiGLU-style feed-forward variants

Example Architectures

GELU appears in transformer feed-forward blocks where authors want a smooth dense activation instead of a hard ReLU cutoff. The original GELU paper introduced the function, and BERT helped make GELU a familiar default inside transformer encoder feed-forward layers.

Limitations And Tradeoffs

GELU is smoother than ReLU, but that smoothness also makes it a little less simple to explain and implement. It is still a dense activation, so every token still runs through the full feed-forward path. When a model wants even stronger feature selection, authors may move from one-branch activations such as GELU to gated designs such as SwiGLU.

Why It Still Matters

GELU still matters because it marks the shift from older saturating curves and hard piecewise cutoffs toward smoother transformer-friendly activations. Once a reader understands GELU, it becomes easier to read modern feed-forward papers that compare smooth dense baselines against gated or expert variants.

Tags

References

  1. Hendrycks, Dan, and Kevin Gimpel. "Gaussian Error Linear Units (GELUs)." arXiv, 2016, https://arxiv.org/abs/1606.08415.
  2. Devlin, Jacob, et al. "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding." arXiv, 2018, https://arxiv.org/abs/1810.04805.