Jump to content

Residual connection (Transformer)

From Wikibase

Languages: English · français · Esperanto

In a Transformer, residual connection is the process of enriching a input token sequence with additional information derived from calculation (e.g., from self-attention).

[1]

Definition

Let $\mathbf{X}\in\mathbb{R}^{T\times d}$ be the input of a sub-layer, and let $\operatorname{SL}\in\mathbb{R}^{T\times d}$ be the residual computed by the sub-layer.

Then the residual connection

$$ \operatorname{Res}(\mathbf{X})=\mathbf{X}+\operatorname{SL}(\mathbf{X}). $$

Identity

With $\operatorname{SL}\equiv\mathbf{0}$,

$$ \operatorname{Res}(\mathbf{X})=\mathbf{X} $$

Therefore, additional residual connection steps in a model architecture, even possibly inefficient, should not hinder model quality.[2]