-
Notifications
You must be signed in to change notification settings - Fork 23
ByteNet : Neural Machine Translation in Linear Time
paper : https://arxiv.org/abs/1610.10099
ByteNet은 Encoder 위에 Decoder를 쌓고 Dynamic unfolding을 이용해 서로 다른 길이의 인풋과 아웃풋 시퀀스 길이를 고려하는 새로운 모델 아키텍쳐이다. 이로써 모델 실행 시간이 linear time으로 줄어 들고, 인풋 길이에 따라 source representation이 길어지는 resolution preserving 특징을 지니게 되었다. Machine Translation과 Language Modeling 문제에서 state-of-the-art 성능을 내었다.
Machine Translation 모델을 디자인할 때 고려해야 할 특성들은 다음과 같다.
- 실행 시간이 짧아야 한다. 인풋 시퀀스와 아웃풋 시퀀스의 길이에 따라서 linear하게 실행시간이 늘어나면 좋다. 특히 입력 시퀀스의 앞과 뒤가 병렬적으로 실행될 수 있으면 아주 좋다.
- RNN은 병렬 실행이 어렵다. 뒷부분의 hidden state를 계산하기 위해서는 반드시 앞부분의 hidden state가 필요하기 때문이다. CNN은 병렬 처리가 가능하다.
- 인풋 시퀀스가 길어지면 이 정보를 담고 있는 source representation도 길어져야 한다. 담고 있는 정보가 더 많아지기 때문이다. 이를 resolution preserving이라고 한다.
- 인풋과 아웃풋 사이의 forward, backward propagation 경로 길이가 짧아야 한다. 관련 있는 두 단어(또는 token) 사이의 거리가 멀더라도 네트워크 안에서 path 길이가 짧으면 학습에 좋다.
이 예시에서 Encoder와 Decoder는 1D CNN으로 가정하지만, ByteNet의 아이디어가 반드시 CNN을 취해야 하는 것은 아니다. 아래에서 살펴보겠지만 RNN도 가능하다.
source sequence를 fixed size representation으로 나타내지 않아도 된다. Encoder의 결과가 즉각 Decoder에 반영된다.
memorization 부담을 덜 수 있다.
source sequence의 길이와 target sequence의 길이가 다르면 어떻게 하나?
그래서 Dynamic Unfolding이라는 기법을 고안했다.
먼저 source sequence에 길이에 linear한 t-hat만큼의 representation을 encoder가 만든다. 그리고 decoder는 거기에서부터 decoding한다. representation이 끝다고 decoder는 EOS가 나올 때까지 계속 decoding할 수 있다.
ByteNet의 Decoder 역시 autoregressive한 모델이다. 즉 이전 단계에서 generate한 token을 다음 단계의 input으로 받는다.
token을 input으로 넣을 때 Input Embedding Tensor라는 lookup table을 통과시켜서 벡터화한다.
Decoding을 하는 CNN에서 미래의 정보는 가리기 위해 masking을 한다. masking은 weights들을 0으로 만들거나 input map을 padding함으로써 구현할 수 있다.
Dilation이란 CNN을 input sequence에 일정 간격으로 건너 뛰면서 적용하는 기술이다. receptive field를 exponentially 증가시키는 효과가 있다. dilation rate이 맨 아래 CNN은 1이지만, 그 위는 2, 그 위는 4, ... 최대 16까지 적용했다.
각각의 레이어마다 Residual Block을 적용했다. Machine translation 문제에는 ReLU를 쓰고 language modeling 문제에는 Multiplicative Units을 썼다. activation function 전에는 layer normalization을 했다.
ByteNet이라는 아이디어는 CNN만 쓸 수 있는 건 아니고 RNN도 쓸 수 있다.
각각의 모델들을 1. 실행 시간 과 2. Resolution Preserving이라는 관점에서 비교해 볼 수 있다.
- Language Modeling
- only Decoder
- Character-level
- Hutter Prize version of the Wikipedia dataset
- learning rate of 0.0003
- Negative log-likelihood
- score of 1.31
- Machine Translation
- 30 residual blocks in the encoder and 30 residual blocks in the decoder.
- kernel size : 3
- learning rate of 0.0003
- WMT English to German translation task
- wins GNMT
ByteNet generalizes the RNN Enc-Dec architecture and achieves state-of-the-art results.