AI Dictionary › Modelli AI
Self-attention is the mechanism by which each element of a sequence (for example, each token of a text) computes its own representation by comparing itself with every other element in the same sequence, including itself. Unlike attention that relates two different sequences, here the input and the reference coincide: the model learns which words in the same sentence are relevant to interpreting a given word.
Self-attention is the mechanism by which each element of a sequence (for example, each token of a text) computes its own representation by comparing itself with every other element in the same sequence, including itself. Unlike attention that relates two different sequences, here the input and the reference coincide: the model learns which words in the same sentence are relevant to interpreting a given word.
Technically, each token is projected into three vectors called query, key and value. The query of the current token is compared against the keys of every token in the sequence to produce relevance scores, which are normalized and used to compute a weighted sum of the values. The result is a new representation of the token that incorporates contextual information from across the whole sequence, regardless of the distance between words.
It is the central building block of architectures that process text, code and other sequences in parallel rather than strictly step by step: it captures long-range dependencies, such as the link between a pronoun and the noun it refers to several sentences earlier, without having to traverse the sequence step by step as recurrent models did.
The term spread from the second half of the 2010s within research on sequence-to-sequence architectures based exclusively on attention mechanisms, in contrast to the recurrent and convolutional models that had dominated natural language processing until then.
Il self-attention è il meccanismo con cui ogni elemento di una sequenza (per esempio ogni token di un testo) calcola la propria rappresentazione confrontandosi con tutti gli altri elementi della stessa sequenza, inclusi se stesso. A differenza di un'attenzione che mette in relazione due sequenze diverse, qui input e riferimento coincidono: il modello impara quali parole della stessa frase sono rilevanti per interpretare una determinata parola.
Tecnicamente, ogni token viene proiettato in tre vettori chiamati query, key e value. La query del token corrente viene confrontata con le key di tutti i token della sequenza per produrre punteggi di rilevanza, che vengono normalizzati e usati per calcolare una somma pesata dei value. Il risultato è una nuova rappresentazione del token che incorpora informazioni contestuali provenienti da tutta la sequenza, indipendentemente dalla distanza tra le parole.
È il componente centrale delle architetture che elaborano testo, codice e altre sequenze in parallelo anziché in modo strettamente sequenziale: permette di catturare dipendenze a lungo raggio, come il legame tra un pronome e il sostantivo a cui si riferisce diverse frasi prima, senza dover attraversare passo dopo passo tutta la sequenza come avveniva nei modelli ricorrenti.
Il termine si è diffuso a partire dalla seconda metà degli anni 2010 nell'ambito della ricerca su architetture sequence-to-sequence basate esclusivamente su meccanismi di attenzione, in contrapposizione ai modelli ricorrenti e convoluzionali che dominavano fino ad allora il trattamento del linguaggio naturale.
From our network
AGORÀ Intelligence — Enterprise AI Governance Platform
Govern AI at scale: policies, adoption and measurable results on your data. Built for boards and C-suite.
Visit agora-intelligence.com →From the Agora Intelligence blog
📱 Download the Android app (beta) iOS coming soon
Say what you mean. Get what you need.
Grace Certified — the AI coach that trains and certifies your prompt engineering — by Agora Intelligence.