FlashKeepers

Machine Learning · College · College and University

Deep Learning IV: Transformers and Attention

Self-attention, multi-head attention, positional encoding, encoder and decoder stacks, BERT versus GPT and scaling laws.

About this set

40 basic cards for College Machine Learning. Set 4 of 4 in Deep Learning. It opens with "Self-attention mechanism" and "Q, K, V in self-attention". Study it alongside the other College sets below.

40 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

Self-attention mechanism
Show answerEach element attends to all elements and itself to compute representations
Q, K, V in self-attention
Show answerQuery, Key, and Value matrices computed from the input
Attention weight formula
Show answersoftmax(Q * K^T / sqrt(d_k)) * V
Why divide by sqrt(d_k) in attention
Show answerPrevents dot products from growing too large and causing vanishing gradients
Self-attention output
Show answerWeighted sum of value vectors, weighted by softmax attention scores
Multi-head attention
Show answerMultiple parallel self-attention operations, each learning different representation aspects
Purpose of multiple attention heads
Show answerDifferent heads attend to different positions and representation subspaces
Typical number of attention heads
Show answer8, 12, or 16 heads
How attention heads are combined
Show answerConcatenate outputs and project through a linear layer
Positional encoding
Show answerInformation added to embeddings to represent position of each element in sequence
Why positional encoding is needed
Show answerSelf-attention is permutation-invariant, cannot distinguish word order without it
Original Transformer positional encoding type
Show answerSinusoidal functions using sin and cos at different frequencies
Learned vs fixed positional encoding
Show answerOriginal Transformer uses fixed sinusoidal values, not learned parameters
Two main Transformer components
Show answerEncoder stack and decoder stack
Encoder stack function
Show answerProcesses input sequence through self-attention and feed-forward networks

25 more cards in the app

Study this set free