Loading...
2022. 5. 18. 20:03

transformer의 마지막 encoder-decoder multi head attention

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가 그랬던 것처럼 ..

2022. 5. 18. 02:09

transformer decoder에 사용된 masked self attention에 대해 알아보고 구현하기

decoder는 특이하게 masked multi head attention을 먼저 수행한다. 이것은 decoder 내부에서 이루어지는 self attention 과정으로 decoder의 input sequence끼리만 이루어진다. 언어모형을 학습시킬때 이미 정답을 아는 상태에서 학습을 시킨다. i go home을 번역하라고 할때 decoder에는 ' 나는 집에 간다'를 넣고 '나는 집에 간다 '를 순차적으로 뱉게 학습을 시킨다는 것이다. decoder에 input으로 ''를 넣어주면 output이 '나는'이 나오길 바라고 '나는'을 input으로 넣어주면 '집에'가 나오길 바란다. 그런식으로 학습을 시킨다. 하지만 이런 학습이 inference에는 어울리지 않는다는 점이다. test과정에서는 정답을 모른..

2022. 5. 16. 20:24

transformer의 decoder 구조 알아보기

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..