What is self-attention?medium

Type
conceptual
Topic
is-self-attention
Frequency
common
Tags
deep-learning, self-attention, context
Answer

Self-attention lets every token in a sequence compare itself against every other token in the same sequence to build a context-aware representation.

Explanation

For a word like “bank,” self-attention lets the model weigh nearby words like “river” or “deposited” to decide which meaning applies, updating each token's representation based on the tokens most relevant to it.

Follow-upHow does self-attention differ from the attention used in encoder-decoder models?