머신러닝을 삼킨 메커니즘
Attention은 model이 각 출력 만들 때 입력의 다른 부분에 선택적으로 집중하게 해. 전체 sequence를 단일 고정 크기 벡터로 압축 (vanilla seq2seq의 병목) 대신, attention은 decoder가 모든 encoder state 다시 보고 매 step 가장 관련 있는 거 결정하게 해.
Self-attention은 한 발 더 나가: sequence의 모든 위치가 동시에 모든 다른 위치에 attend. 이게 Transformer architecture의 핵심 혁신. Multi-Head Attention은 attention을 병렬로 여러 번 돌려, 각각 다른 종류 관계 학습 (구문, 의미, 위치).
TensorFlow는 tf.keras.layers.MultiHeadAttention을 first-class layer로 제공. 시그니처는 직관적: query, key, value 넘기기. Self-attention은 셋 다 같은 tensor; cross-attention (decoder가 encoder에 attend)은 query가 decoder, key/value가 encoder.