Gaussian Error Linear Units
GELU replaces hard ReLU gating with a smooth probability-weighted activation, becoming a default nonlinearity in BERT-style and many later Transformer feed-forward blocks.
Metadata
| Field | Value |
|---|---|
| Paper | Gaussian Error Linear Units (GELUs) |
| Authors | Dan Hendrycks, Kevin Gimpel |
| Year | 2016 |
| Venue | arXiv preprint |
| arXiv | 1606.08415 |
| Code | hendrycks/GELUs |
| Status | seed note started |
One-Line Takeaway
GELU is the activation:
where is the standard Gaussian CDF, giving a smooth input-dependent gate rather than a hard threshold at zero.
Question
ReLU applies a hard gate:
This is cheap and effective, but the gate is discontinuous in derivative at zero and fully suppresses all negative inputs.
GELU asks:
Can an activation weight an input by how likely it is to be positive under a Gaussian uncertainty model?
Formula
The GELU activation is:
where:
So:
A common approximation is:
Architecture Contract
| Component | Role |
|---|---|
| input | pre-activation value from linear layer |
| smooth probability-like gate | |
| product | gates value by input magnitude and sign |
| approximation | faster implementation option |
| feed-forward placement | activation inside MLP/FFN block |
In a Transformer feed-forward block:
GELU sets:
This is why GELU matters as an architecture component: it changes the nonlinearity in the token-wise channel mixer.
ReLU vs GELU
| Axis | ReLU | GELU |
|---|---|---|
| Formula | ||
| Gate | hard sign gate | smooth probability-weighted gate |
| Negative values | all zeroed | small negatives can pass |
| Derivative | kink at zero | smooth |
| Common use | CNNs and many MLPs | BERT-style Transformers and modern FFNs |
GELU is not a new macro-architecture. It is a small block-level choice that became durable because activation behavior compounds over many layers.
Derivative
Let be the standard Gaussian density:
Then:
This derivative is smooth. For large positive :
For large negative :
Near zero, GELU behaves like a soft gate instead of an abrupt switch.
Why It Matters
GELU became important because many Transformer blocks are built from:
The FFN is often where much of the parameter count lives:
So the activation inside the FFN is not cosmetic. It affects channel mixing, gradient flow, sparsity, saturation, and training stability.
What To Watch
- GELU is usually an activation choice, not a standalone architecture claim.
- Exact and approximate GELU can differ slightly; implementations should be recorded.
- Performance gains are recipe-dependent and can interact with normalization, initialization, optimizer, and depth.
- In modern LLMs, GELU is often replaced by gated activations such as SwiGLU; compare with GLU Variants Improve Transformer.
- If a paper claims an architecture improvement, isolate whether the gain came from activation, width, normalization, or training recipe.