Encoder-Decoder Today
Encoder-decoder는 source와 target의 역할이 분명한 Translation·Speech 작업에서 계속 사용된다. Encoder는 source를 읽어 memory를 만들고, Decoder는 그 memory를 참고하면서 target을 생성한다. 여기서는 Self-Attention을 다시 정의하기보다 Decoder의 Query가 Encoder의 Key/Value를 읽는다는 Cross-Attention의 연결을 따라가면 된다.
The First Decoder Query
첫 token을 만들 때에는 아직 생성한 target prefix가 없다. Decoder는 BOS로 시작하고, 그 position의 state에서 Query를 만든다. BOS라는 입력 token 자체에 source의 내용이 들어 있는 것은 아니지만, Cross-Attention을 거치면 Encoder에서 넘어온 정보를 받아들일 수 있다.
Encoder outputs 에 K/V projection을 적용하고, BOS 쪽 Query로 Attention weights를 계산한다. 강의 예시에서 weights가 이면 context vector는
가 된다. 첫 source token의 Value를 상대적으로 많이 읽은 것이다. 이런 source-conditioned 정보가 Decoder state에 반영되어 첫 output token 의 prediction으로 이어진다. 따라서 “첫 BOS 앞에는 아무 target도 없는데 어떻게 source에 맞는 token을 만드는가”에 대한 답은 Cross-Attention에 있다. 이 계산은 여러 Decoder layers를 거치며 반복된다.
NLLB and Whisper
NLLB-200은 200개 언어와 약 40,000 translation directions를 다룬다. 강의는 54.5B sparse MoE, 3.3B/1.3B dense 모델과 FLORES-200 평가를 소개한다. Target-language token인 kor_Hang은 output을 한국어로 만들라는 조건이다. 같은 source라도 어떤 target language를 지정하는지에 따라 이어질 output이 달라진다.
Whisper는 audio/log-Mel input을 읽는 Encoder와 text Decoder를 사용한다. Log-Mel 표현은 시간과 frequency의 정보를 담으며, text 대신 음성에서 얻은 Encoder memory를 읽는다는 점을 제외하면 conditional generation의 연결은 같다. 학습 자료는 680,000 hours의 weak supervision이며, 강의는 별도 task fine-tuning 없이 평가하는 zero-shot ASR·Speech Translation을 소개한다.
Whisper의 <|transcribe|>와 <|translate|>는 각각 Transcription과 Translation처럼 수행할 일을 지정한다. NLLB의 target-language token과 마찬가지로 generation 조건에 참여하지만, 어느 언어로 만들지와 어떤 일을 할지는 다른 조건이다.
From Decoder Weights to T5Gemma
T5Gemma는 이미 학습된 Gemma 2 Decoder weights를 Encoder와 Decoder의 출발점으로 활용한다. Encoder 쪽은 causal visibility를 bidirectional로 바꾸고, Decoder에는 source를 읽을 Cross-Attention을 추가한다. 복사한 weights를 갖고 있어도 새 연결의 동작은 별도로 학습해야 한다.
그 다음 PrefixLM+distillation 또는 UL2로 continued training한다. 강의의 Encoder–Decoder pairs는 2B–2B, 9B–2B, 9B–9B이며, Gemma 2 up to 9B와 최대 2T adaptation tokens의 범위다. Balanced models는 수십 B adaptation tokens 뒤 Decoder baseline에 가까워지고, instruction tuning 뒤에는 비슷한 inference cost에서 뚜렷한 개선이 보고된다.
이 결과는 “Decoder 두 개를 붙이면 학습 없이 Encoder-decoder가 된다”는 뜻이 아니다. Initialize → Rewire → Continue training의 세 단계를 구분해야 한다. Encoder-decoder도 KV Cache를 사용하므로, source/target 역할 분리와 추가 학습의 효과를 cache의 유무와 혼동하지 않는다.
Check
Encoder-decoder의 첫 BOS token에는 어떻게 source 정보가 들어오는가?
Answer
BOS에서 생긴 Decoder Query가 Encoder의 /를 Cross-Attention으로 읽어 source 정보를 받는다.
T5Gemma를 Decoder weights 두 개를 복사하면 바로 완성된다고 하면 무엇을 생략하는가?
Answer
Bidirectional Encoder로 rewire,Cross-Attention 추가,continued training/adaptation 단계를 생략한다.
Decoder BOS가 첫 source-conditioned output을 만드는 흐름을 말하라.
Answer
Encoder source hidden states에서 / → Decoder BOS에서 → scores/scaling/Softmax → weighted source → Decoder representation → 첫 output token.