Previous architectures
- LSTM
- Gated RNNs
Self attention - Relates different positions of a single sequence in order to compute a representation of the sequence
Input - Encoding - Output -
Transduction models have encoder/decoder structure
- encoder maps inputs to representation
- decoder generates given
Autoregresssive - consumes the previously generated symbol as additional input
Transformer architecture

- Decoder uses masked self-attention to prevent positions from attending to subsequent positions.
- Ensures prediction for position can only depend on known outputs at positions less than
Scaled dot-product attention
- Queries and keys of dimension , values of dimension
Multi-head attention
- Instead of dimensional keys for queries, values and keys, split them times, perform attention parallely and then concatenated and projected
- This allows the model to attend information from different representations at different positions
where
- , … and
Attention uses in Transformers
- Encoder-decoder attention layers - queries come from previous decoder and keys, values comes form the output of encoder
- Allows each position in decoder to attend over all positions of input
- Encoder’s self attention - each position in encoder can attend to all positions in previous layer of encoder
- Decoder self attention - uses masked attention so that each position can only attend to positions up to and including that position
Feed forward networks
Softmax
- Use a learnt linear transformation and softmax to turn the decoder output to predicted next-token probabilities.
Positional encoding
- Injects information about the position of the tokens in the sequence