Functions and operators

SiLU⁡(x)=x σ(x)\operatorname{SiLU}(x) = x \, \sigma(x) SiLU / Swish (and SwiGLU)

SiLU(x) = x·σ(x), a smooth ReLU; SwiGLU is the gated feed-forward layer built from it.

In ML papers

SiLU⁡(x)=x σ(x)\operatorname{SiLU}(x) = x \, \sigma(x) multiplies the input by its own sigmoid. Like ReLU it is near 0 for very negative inputs and near xx for large ones, but it is smooth and dips slightly below zero. It was proposed in the GELU paper (Hendrycks & Gimpel 2016) and later popularized as Swish (Ramachandran et al. 2017), whose version x σ(βx)x \, \sigma(\beta x) has a scale β\beta; with β=1\beta = 1 they are the same.

SwiGLU (Shazeer 2020, "GLU Variants Improve Transformer") is a feed-forward layer, not a single function: SwiGLU⁡(x)=(SiLU⁡(xW)⊙xV)W2\operatorname{SwiGLU}(\mathbf{x}) = \big(\operatorname{SiLU}(\mathbf{x} W) \odot \mathbf{x} V\big) W_2. One projection is passed through SiLU and gates the other elementwise. LLaMA and many later language models use it in place of the ReLU Feed-forward network (FFN, MLP).

How to type it

LaTeXShows
\operatorname{SiLU}(x)SiLU⁡(x)\operatorname{SiLU}(x)
\operatorname{Swish}(x)Swish⁡(x)\operatorname{Swish}(x)
\operatorname{SwiGLU}(\mathbf{x})SwiGLU⁡(x)\operatorname{SwiGLU}(\mathbf{x})

A worked example

SiLU⁡(1)=1×0.731=0.731,SiLU⁡(−1)=−0.269\operatorname{SiLU}(1) = 1 \times 0.731 = 0.731, \quad \operatorname{SiLU}(-1) = -0.269

Its minimum is about −0.278-0.278, near x=−1.28x = -1.28.

Common confusions

Related

σ(z)\sigma(z)Sigma (lowercase)ReLU⁡(x)=max⁡(0,x)\operatorname{ReLU}(x) = \max(0, x)ReLUFFN⁡(x)=max⁡(0,xW1+b1)W2+b2\operatorname{FFN}(\mathbf{x}) = \max(0, \mathbf{x} W_1 + \mathbf{b}_1) W_2 + \mathbf{b}_2Feed-forward network (FFN, MLP)a⊙b\mathbf{a} \odot \mathbf{b}Hadamard (elementwise) product

Decode this example →