Zubnet AIApprendreWiki › Feedforward Network
Fondamentaux

Feedforward Network

FFN, MLP Block
Le composant dans chaque couche Transformer qui traite chaque token indépendamment à travers deux transformations linéaires avec une fonction d'activation entre. Pendant que l'attention mélange l'info à travers les tokens (quels tokens sont reliés à quels), le feedforward network traite la représentation de chaque token individuellement, appliquant des transformations non linéaires qui encodent la connaissance et effectuent le calcul.

Pourquoi c'est important

Le feedforward network est où la plupart de la connaissance d'un Transformer est stockée. L'attention reçoit toute la gloire, mais les couches FFN contiennent la majorité des paramètres du modèle (typiquement 2/3 du total) et sont où les associations factuelles, les patterns de langage et les calculs appris résident principalement. Comprendre ça aide à expliquer des phénomènes comme le knowledge editing et le model pruning.

Deep Dive

The standard FFN: FFN(x) = W2 · activation(W1 · x + b1) + b2, where W1 projects from the model dimension to a larger intermediate dimension (typically 4x), the activation function introduces non-linearity, and W2 projects back to the model dimension. Each position (token) passes through this independently — the FFN doesn't see other tokens, only the attention layer does.

SwiGLU and Gated Variants

Modern LLMs (LLaMA, Mistral, etc.) use SwiGLU instead of the standard FFN: SwiGLU(x) = (W1 · x · SiLU) ⊗ (W3 · x). This adds a third weight matrix (W3) and a gating mechanism that lets the network control what information passes through. Despite the extra parameters, it performs better at equivalent compute, so the intermediate dimension is adjusted down to compensate. This is a case where a slightly more complex component improves the whole system.

Knowledge Storage

Research suggests that FFN layers function like key-value memories: the first linear layer (W1) detects patterns in the input (keys), and the second linear layer (W2) maps those patterns to output updates (values). "The Eiffel Tower is in" activates specific neurons in W1, which through W2 promote the token "Paris." This key-value interpretation explains why FFN layers store factual knowledge and why knowledge editing techniques can modify specific facts by updating specific FFN weights.

Concepts liés

← Tous les termes
← Federated Apprendreing Few-Shot Apprendreing →