liveBook · Manning

SwiGLU

As explained in LLMs in Production

SWIGLU is a gated activation function that uses the Swish function to modulate one linear projection with another.

SwiGLU is a gated activation that uses Swish to modulate one linear projection with another. In a Llama-style network, it replaces ReLU, supports negative values, and helps address exploding or vanishing gradients. section 9.2

SwiGLU in a Llama block

A SimpleLlama feed-forward path projects from d_model to hidden_dim, applies SwiGLU, then projects back to d_model. The same activation appears in the model’s final feed-forward network instead of ReLU.

How LLMs in Production covers it

How deep it goes
Explains its activation role and placement, but defers the internal implementation to a notebook.
Examples
Demonstrates SwiGLU inside LlamaBlock and the final SimpleLlama feed-forward network.
What you can do after
Apply it in a Llama-style PyTorch feed-forward network in place of ReLU.
How it connects
Connects SwiGLU with Swish, ReLU, feed-forward networks, RMSNormalization, and Llama 3.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of LLMs in Production. The section links point to the parts of the book it draws on.