Zubnet AIसीखेंWiki › SwiGLU
मूल सिद्धांत

SwiGLU

Gated Linear Unit, GLU Variants
Modern Transformers की feedforward layers में use होने वाला एक gated activation function। SwiGLU SiLU/Swish activation को एक gating mechanism के साथ combine करता है: SwiGLU(x) = (x · W1 · SiLU) ⊗ (x · W3), जहाँ ⊗ element-wise multiplication है। ये network को सीखने देता है कि कौन सी information pass करनी है, standard ReLU या GELU feedforward layers को consistently outperform करते हुए।

यह क्यों matter करता है

SwiGLU LLaMA, Mistral, Qwen, Gemma, और अधिकांश modern LLMs द्वारा use की गई feedforward activation है। इसे समझना आपको model architectures read करने में help करता है और explain करता है कि modern FFN layers में दो के बजाय तीन weight matrices क्यों हैं। ये model quality पर outsized impact वाला एक small architectural choice है।

Deep Dive

Standard FFN: FFN(x) = W2 · GELU(W1 · x). Two weight matrices, one activation. SwiGLU FFN: SwiGLU(x) = W2 · (SiLU(W1 · x) ⊗ W3 · x). Three weight matrices, a gating mechanism. The gate (W3 · x) controls what passes through, letting the network selectively suppress or amplify different features. To keep parameter count constant, the intermediate dimension is typically reduced from 4×model_dim to (8/3)×model_dim.

Why Gating Helps

Gating gives the network a multiplicative interaction that standard activations lack. Standard activations apply a fixed non-linearity. Gating applies a learned, input-dependent non-linearity. This additional expressiveness helps the network learn more complex functions per layer, which means you need fewer layers (or smaller layers) for equivalent performance. Shazeer (2020) showed that GLU variants consistently outperform standard FFN across model sizes.

The GLU Family

SwiGLU is one of several GLU variants: GeGLU (uses GELU instead of SiLU), ReGLU (uses ReLU), and the original GLU (uses sigmoid). SwiGLU and GeGLU perform similarly and both outperform ReGLU. The choice between them is mostly empirical — SwiGLU has become the default through convention (LLaMA adopted it, others followed) rather than clear theoretical superiority over GeGLU.

संबंधित अवधारणाएँ

← सभी Terms
← Supervised सीखेंing Sycophancy →