Residual connection (Transformer)
Appearance
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).
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]
- ↑ Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., & Polosukhin, I. (2017). Attention Is All You Need. 5998–6008. https://doi.org/10.48550/arXiv.1706.03762He, K., Zhang, X., Ren, S., & Sun, J. (2016). Deep Residual Learning for Image Recognition. 770–778. https://doi.org/10.1109/CVPR.2016.90
- ↑ He, K., Zhang, X., Ren, S., & Sun, J. (2016). Deep Residual Learning for Image Recognition. 770–778. https://doi.org/10.1109/CVPR.2016.90