1. encoder-decoder multi head attention decoder의 2번째 attention layer는 특별하게 encoder decoder multi head attention으로 불린다. decoder의 masked self attention 이후 나온 결과는 Query로 들어오고 encoder의 최종 결과로 나오는 hidden vector는 적절하게 변형?되어 key,value로 들어온다 decoder의 query는 encoder가 이해한 맥락정보로부터 받아온 key value중 어떠한 정보에 더 집중할지 attention 연산을 수행하게 된다. 그 후 residual connection, layer normalization을 거치고 나온 결과에 encoder가 그랬던 것처럼 ..
decoder는 특이하게 masked multi head attention을 먼저 수행한다. 이것은 decoder 내부에서 이루어지는 self attention 과정으로 decoder의 input sequence끼리만 이루어진다. 언어모형을 학습시킬때 이미 정답을 아는 상태에서 학습을 시킨다. i go home을 번역하라고 할때 decoder에는 ' 나는 집에 간다'를 넣고 '나는 집에 간다 '를 순차적으로 뱉게 학습을 시킨다는 것이다. decoder에 input으로 ''를 넣어주면 output이 '나는'이 나오길 바라고 '나는'을 input으로 넣어주면 '집에'가 나오길 바란다. 그런식으로 학습을 시킨다. 하지만 이런 학습이 inference에는 어울리지 않는다는 점이다. test과정에서는 정답을 모른..
decoder의 기본 구조는 이렇다. The decoder is also composed of a stack of N = 6 identical layers. In addition to the two sub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head attention over the output of the encoder stack. Similar to the encoder, we employ residual connections around each of the sub-layers, followed by layer normalization. We also modify the se..
1. warm up learning rate scheduler 최적화 알고리즘인 optimizer의 learning rate는 중요한 hyperparameter인데 보통 하나의 값을 선택하고 전 과정동안 그 값으로 학습을 진행함. 그러나 조금 더 빠르게하면서 모델 성능은 높이고 싶다면 학습 중 변경하는 방법도 생각해볼 수 있음 이런 기법을 learning rate scheduling라고 부른다. 학습 중 적절한 방식으로 learning rate를 변경하면서 학습한다. 모델의 성능을 높이고 학습도 빠르게 할 수 있는 여러 기법들이 있다. warm up learning rate scheduler은 transformer에서 사용한다면 학습이 경험적으로 잘 된다고 많은 경우 알려져있다. 2. 직관적으로 warm..
1. block based model encoding의 마지막 단계로 residual connection, layer normalization 결과를 feed forward network라는 신경망에 넣어 다시 한번 변환을 거친다. 근데 특별히 왜 했다는 이유는 없는듯?? feed forward network후에도 residual connection을 수행하고 layer normalization을 수행하여 최종적인 encoder의 output인 hidden vector를 얻는다. 2. positional encoding 지금까지 연산의 결과는 사실 sequence의 순서 정보를 전혀 고려하지않았다. 직관적으로 당연하다. x1,x2,x3의 q,k,v를 한번에 만들어서 이것으로 attention을 수행하면서..
1. residual connection self attention 구조하에 당시 좋은 성능 향상 기법인 residual add connection, layer normalization을 채택했다. input $X_{t}$의 encoding 결과로 $h_{t}$라는 hidden vector를 얻고 싶은데 multi head attention이 학습하는 결과는$h_{t}-X_{t}$라고 하는 것이며 이 결과에 input $X_{t}$를 그대로 더하여 $h_{t}$라는 목표하는 hidden vector를 얻는다. input의 (1,4)의 multi head attention 결과로 얻은 (2,3)에 단순히 더하여 (3,7)이라는 벡터를 얻는 과정이 residual connection이다. 입력 input과 ..