Mechanizm self-attention (zapytania, klucze, wartości)

Self-attention (queries, keys, values) · id selfattention · aliases: self-attention, attention mechanism, mechanizm uwagi, scaled dot-product attention, QKV, multi-head attention, uwaga wielogłowicowa, causal attention

Serce transformera: każdy token tworzy zapytanie (Q), klucz (K) i wartość (V), a wynik to średnia wartości ważona podobieństwem zapytania do kluczy wszystkich tokenów. Dzięki temu model łączy informacje z całej sekwencji naraz; koszt rośnie kwadratowo z długością tekstu. W modelach generujących tekst stosuje się maskę przyczynową (token widzi tylko poprzednie).

The heart of the transformer: each token produces a query (Q), key (K) and value (V), and the output is a weighted average of values, weighted by query–key similarity across all tokens. This lets the model mix information from the whole sequence at once; cost grows quadratically with length. Text-generating models use a causal mask (a token sees only earlier ones).

In one sentence

To sposób, w jaki każdy fragment danych dobiera informacje z innych fragmentów tego samego wejścia.

This lets each data element draw information from other elements of the same input.

Problem it solves

Samo słowo nie wystarcza, żeby ustalić, do czego odnosi się w całym zdaniu.

A word alone is not enough to determine what it refers to in a sentence.

What it does

Fragmenty tworzą zapytania i opisy, porównują je, a potem mieszają informacje według dopasowania i dozwolonego zakresu widzenia.

Elements create queries and descriptors, compare them, then mix information according to their match and the permitted viewing range.

Everyday example

W zdaniu o oddaniu klucza sąsiadowi model zestawia zaimek z wcześniejszą wzmianką, żeby przygotować odpowiedź o odbiorcy.

In a sentence about giving a neighbour a key, a model connects a pronoun with an earlier reference to answer about the recipient.

This concerns you if you…

Examples

Related topics

Sources