# Formal Algorithms for Transformers

**Authors:** Mary Phuong, Marcus Hutter  
**arXiv:** [2207.09238](https://arxiv.org/abs/2207.09238)  
**Date:** 2022-07-19  
**Summary page:** https://www.summarizepaper.com/en/paper/2207.09238v1/

## Key points

- "Formal Algorithms for Transformers" is a comprehensive document on transformer architectures and algorithms
- Authored by Mary Phuong and Marcus Hutter from DeepMind
- Assumes readers are familiar with basic machine learning terminology and simpler neural network architectures such as MLPs
- Covers fundamental concepts of transformers, including their training, usage, key architectural components, and prominent models
- Provides an introduction to transformers and their motivation before delving into typical tasks performed by them and explaining how text is represented through tokenization
- In-depth analysis of the architectural components of transformers provided including attention mechanisms, encoders, decoders, BERT (Bidirectional Encoder Representations from Transformers), GPT (Generative Pre-trained Transformer) and Gopher (Gradient-based Optimization for Phrase-based Hybrid ERror-reduction)
- Various transformer architectures explored in detail along with their strengths and limitations
- Transformer training and inference methods discussed while providing formal algorithms and pseudocode to aid understanding
- Practical considerations when working with transformers highlighted such as model selection criteria, hyperparameter tuning techniques, and optimization strategies for large-scale training datasets
- Serves as an essential resource for researchers interested in natural language processing or anyone looking to implement transformers in real-world scenarios.

## Summary

Formal Algorithms for Transformers is a comprehensive document that provides a mathematically precise overview of transformer architectures and algorithms. Authored by Mary Phuong and Marcus Hutter from DeepMind, the paper covers the fundamental concepts of transformers, including their training, usage, key architectural components and prominent models. The authors assume readers are familiar with basic machine learning terminology and simpler neural network architectures such as MLPs. The document begins with an introduction to transformers and their motivation before delving into typical tasks performed by them and explaining how text is represented through tokenization. An in-depth analysis of the architectural components of transformers is provided including attention mechanisms, encoders, decoders, BERT (Bidirectional Encoder Representations from Transformers), GPT (Generative Pre-trained Transformer) and Gopher (Gradient-based Optimization for Phrase-based Hybrid ERror-reduction). Various transformer architectures are explored in detail along with their strengths and limitations. Transformer training and inference methods are discussed while providing formal algorithms and pseudocode to aid understanding. Practical considerations when working with transformers such as model selection criteria, hyperparameter tuning techniques and optimization strategies for large-scale training datasets are also highlighted. In summary,"Formal Algorithms for Transformers" provides a rigorous understanding of transformer architectures and algorithms while offering insights into their practical applications. This paper serves as an essential resource for researchers interested in natural language processing or anyone looking to implement transformers in real-world scenarios.
