Part 1 (20 minutes): Naturally — What is Self Attention and how can it be explained intuitively?
Self Attention is a computation in Transformer models by which each word (or token) in the input text determines its relevance to all other words and then computes a weighted representation. Intuitively, you can imagine Self Attention like a discussion in a committee: each member (word A) asks the other members (words B, C, D ...) for their opinion on the current question. The answers are weighted and combined so that member A ends up not only knowing its own perspective but a contextualized view that contains relevant cues from the entire committee. This metaphor is used repeatedly in the technical literature, for example in introductory visualizations and explanations of the Transformer architecture (see Jay Alammar, "The Illustrated Transformer").
More concretely: for each word the model computes three vectors: Query (Q), Key (K) and Value (V). The Query of a word is compared with the Keys of all words; the strength of these comparisons determines, via a Softmax distribution, the weights with which the Values of the other words are averaged. Mathematically this can be summarized briefly as Attention(Q,K,V) = softmax(QK^T / sqrt(d_k)) V — this formula originates from the original Transformer description and is established in the scientific consensus on the architecture (Vaswani et al., "Attention Is All You Need").
An example: in the sentence "Die Katze, die der Hund verfolgte, sprang über den Zaun" (The cat that the dog chased jumped over the fence), the model at the word "sprang" (jumped) needs information about which entity performed the jumping. Self Attention allows the token for "sprang" to attend strongly to the token "Katze" (cat), even though several tokens lie between them. This direct connection is a central reason why Transformer-based models have made great progress in language tasks since 2017.
Important: Self Attention is not a symbolic rule but a learnable mechanism. The linear projections that produce Queries, Keys and Values are adjusted during training with gradient-based methods so that the attention weights shape themselves according to the target task (e.g., translation, masked language modeling in BERT, etc.; see Devlin et al., "BERT").
Part 2 (20 minutes): Deeper dive — Terms, mechanics, strengths and limits
Key terms and mechanics
The central technical terms are token, embedding, query, key, value, scaled dot-product attention, multi-head attention and positional encoding. A token is a basic unit (word, subword), an embedding is a vector representing the meaning of that token in the model's space. From embeddings, three vectors Q, K, V are formed via learnable matrices. The scalar Q·K (dot product) measures raw compatibility; dividing by sqrt(d_k) (scaling) improves numerical stability; the Softmax function normalizes compatibilities into probabilities that are applied to the Values.
Multi-Head Attention means the model carries out the same operation in parallel across several "heads", where each head can focus on different types of relations (e.g., syntactic relationships, semantic cores, local dependencies). The outputs of the heads are then combined and transformed. This mechanism allows modeling different aspects of context simultaneously rather than compressing all information into a single representation (Vaswani et al.).
Why attention is key to language understanding
Scientific consensus considers Self Attention crucial for how modern language models capture long-range and flexible dependencies. While recurrent networks passed information sequentially and therefore path lengths grew for long distances, Self Attention creates direct connections between arbitrary positions within a layer. This shortens the effective path length for information flow and facilitates modeling more distant relations (Vaswani et al.; summaries and reviews of Transformers confirm this advantage).
How does the model practically decide which words are important?
Two factors are decisive: the learned geometry of the representation space and the training objective. The linear projections shape Queries and Keys so that relevant pairs produce high dot products. Which pairs are relevant is defined by the training signal: in translation, for example, alignment of subject and verb matters; in question answering, the relation between the question word and the relevant sentence part matters. The model learns to recognize such patterns as gradients adjust the projection matrices so that downstream loss becomes worse or better (see Vaswani; Devlin et al.).
Important to emphasize and often misunderstood: high attention weights are not automatically complete proof that a token is "the cause" of a decision. Works in the literature show that attention weights can provide informative hints but do not always constitute a complete or unequivocal explanation (see Jain & Wallace, "Attention is not Explanation"). Therefore there is uncertainty about how far attention alone can be used for interpretation; this is an active research area.
Advantages and technical limits
Advantages of Self Attention include: (1) direct connections between arbitrary tokens, which model long-range dependencies more efficiently; (2) good parallelizability on modern hardware, because computations for all positions can be performed simultaneously; (3) ability to capture different kinds of relations via multi-heads; (4) transferability to many tasks (machine translation, question answering, text classification), as practical successes with BERT and similar models show (Devlin et al.).
At the same time there are technical limits: the standard implementation has quadratic time and memory complexity with respect to sequence length (O(n^2) for n tokens), which becomes a practical bottleneck for very long texts or large batch sizes. For this reason research is developing more efficient variants and approximations (overviews and surveys on efficient Transformers document this line of work; see Tay et al., "Efficient Transformers: A Survey").
Part 3 (10 minutes): Applications, limits and short thought exercises
Concrete applications: Self Attention is a core component of modern language models and enables excellent results in translation, text generation, question answering systems, text summarization and semantic search. Models like BERT use Self Attention in a bidirectional pretraining to create contextualized token representations that can be fine-tuned for many NLP tasks (Devlin et al.).
Limits and caution: Even though Self Attention provides strong contextual representations, problems remain such as data bias, lack of world knowledge modeling without explicit training, memory limitations for long inputs and questions of interpretability. In particular, the claim that a high attention weight is equivalent to "cause" or "explanation" is not universally confirmed scientifically; there are studies that question this relationship (Jain & Wallace).
Short thought exercises to take away:
1) Take the sentence "Anna gab Maria ihren Buchhalter." (Anna gave Maria her accountant.) Consider which tokens might be important for resolving "her" (ihren). How could Self Attention support the decision? (Hint: the model must resolve pronoun reference using context.)
2) Imagine a very long historical text (e.g., several thousand tokens). Why might a purely recurrent model be advantageous or disadvantageous compared to Self Attention? Formulate one precise advantage and one precise disadvantage each.
3) Think of a scenario where the highest attention weight falls on an irrelevant word that contradicts human intuition. What explanations could you give? (Possible answers: artifacts from training data, ambiguity in the embedding space, interaction with subsequent layers.)
These exercises are intended to connect the abstract description with concrete, intuitive considerations and to show where Self Attention is very strong — and where research is still needed.
Sources
The following sources were used directly for the facts presented in this talk. Each source has been taken into account in the presentation.
1) Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., & Polosukhin, I. (2017). "Attention Is All You Need". Conference: Advances in Neural Information Processing Systems. Available as preprint: https://arxiv.org/abs/1706.03762 (2017-06-12).
2) Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2018). "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding". Preprint: https://arxiv.org/abs/1810.04805 (2018-10-11).
3) Alammar, J. "The Illustrated Transformer". Blog post with visualizations and didactic explanations of the Transformer architecture. Available at: https://jalammar.github.io/illustrated-transformer/ (2018).
4) Rogers, A., Kovaleva, O., & Rumshisky, A. (2020). "A Primer in BERTology: What we know about how BERT works". Preprint: https://arxiv.org/abs/2002.12327 (2020-02-27). This review was used to contextualize findings on interpretability and behavior of Transformer-based models.
5) Jain, S. & Wallace, B. C. (2019). "Attention is not Explanation". Preprint/Conference paper: https://arxiv.org/abs/1902.10186 (2019-02-25). This work was used for a critical assessment of the explanatory power of attention weights.
6) Tay, Y., Dehghani, M., Bahri, D., & Metzler, D. (2020). "Efficient Transformers: A Survey". Preprint: https://arxiv.org/abs/2009.06732 (2020-09-14). This survey was cited to present limitations (quadratic complexity) and research approaches.
Note: The preprints and review articles cited here represent the state of the published scientific literature up to the creation of this lecture. For detailed mathematical derivations I refer to the original articles, in particular Vaswani et al. (2017).