Attention에서 Query, Key, Value가 동일한 경우
한 문장에서 각 단어가 다른 단어와 어떤 관계를 갖고 있는지 수치화하는 행위
The animal didn’t cross the street because it was to tired.
위와 같은 문장에서, 우리는 it이 The animal이라는 것을 안다.
모든 시점의 은닉 상태(Query)에 대해, 모든 시점의 은닉 상태(Key)와의 유사도(Value)를 구한다.
정리하면 수식은 다음과 같다.
$$ \tt Attention(Q,K,V) = \blue{softmax(\frac{QK^T}{\sqrt{d_k}})}V $$
이 때, Value Vector의 차원은 Query Vector나 Key Vector와 달라도 된다.