Skip to main content
QUICK REVIEW

[Paper Review] Accelerating Transformer Decoding via a Hybrid of Self-attention and Recurrent Neural Network

Chengyi Wang, Shuangzhi Wu|arXiv (Cornell University)|Sep 5, 2019
Natural Language Processing TechniquesComputer Science13 references5 citations
TL;DR

This paper proposes a hybrid Transformer architecture that replaces the autoregressive decoder with a single-layer RNN while retaining the self-attention encoder, achieving up to 4.1x faster decoding than the original Transformer. With knowledge distillation from a full Transformer teacher model, the hybrid model maintains competitive translation quality, matching or exceeding baseline performance on NIST and WMT2017 benchmarks.

ABSTRACT

Due to the highly parallelizable architecture, Transformer is faster to train than RNN-based models and popularly used in machine translation tasks. However, at inference time, each output word requires all the hidden states of the previously generated words, which limits the parallelization capability, and makes it much slower than RNN-based ones. In this paper, we systematically analyze the time cost of different components of both the Transformer and RNN-based model. Based on it, we propose a hybrid network of self-attention and RNN structures, in which, the highly parallelizable self-attention is utilized as the encoder, and the simpler RNN structure is used as the decoder. Our hybrid network can decode 4-times faster than the Transformer. In addition, with the help of knowledge distillation, our hybrid network achieves comparable translation quality to the original Transformer.

Motivation & Objective

  • To address the slow inference speed of Transformer models, which stems from autoregressive decoding and high computational cost of multi-head attention.
  • To explore whether combining the parallelizable strength of self-attention with the fast inference of RNNs can yield a more efficient decoding system.
  • To maintain high translation quality in the hybrid model despite replacing the full Transformer decoder with a simpler RNN structure.
  • To evaluate the effectiveness of knowledge distillation in improving the performance of the lightweight hybrid model.
  • To demonstrate that the hybrid model can achieve significant speedups without sacrificing translation quality on standard benchmarks.

Proposed method

  • The model uses a standard self-attention-based encoder from the original Transformer, preserving its ability to capture long-range dependencies through multi-head attention and residual connections.
  • The decoder is replaced with a single-layer GRU-based RNN, which enables faster autoregressive generation by eliminating the need for full sequence attention computation at each step.
  • The hybrid model is first pre-trained using maximum likelihood estimation (MLE) on the target sequence.
  • Sequence-level knowledge distillation is applied, where the full Transformer acts as a teacher to guide the student hybrid model during fine-tuning, improving translation quality.
  • Pre-computation of key-value pairs and weight fusion are used in both baseline models and the hybrid model to ensure fair speed comparison.
  • Experiments are conducted on NIST and WMT2017 Chinese-English translation tasks using beam search with beam size 12 and length penalty 1.0.

Experimental results

Research questions

  • RQ1Can replacing the Transformer decoder with a lightweight RNN significantly accelerate inference without sacrificing translation quality?
  • RQ2How does the decoding speed of the hybrid model compare to both standard RNN-based models and full Transformer models under identical conditions?
  • RQ3To what extent can knowledge distillation improve the performance of a lightweight hybrid model to match that of a full Transformer?
  • RQ4What is the contribution of each component (self-attention, RNN, knowledge distillation) to the overall speed and accuracy trade-off?
  • RQ5Does the hybrid architecture maintain strong performance across different model depths and dataset types?

Key findings

  • The 6-layer hybrid model achieves a 4.1x speedup over the 6-layer Transformer baseline on the NIST dataset, with decoding time reduced from 420s to 107s.
  • On the WMT2017 Chinese-English task, the hybrid model achieves a 3.9x speedup over the 6-layer Transformer, reducing decoding time from 420s to 114s.
  • With knowledge distillation, the hybrid model achieves BLEU scores of 22.50 on WMT2017, closely matching the 23.08 score of the full Transformer teacher model.
  • Even without knowledge distillation, the hybrid model outperforms the standard RNMT baseline, and with KD, it surpasses RNMT by over 1 BLEU point.
  • The hybrid model with a single-layer RNN decoder achieves comparable BLEU scores to deeper RNN variants (2, 4, 6 layers) after knowledge distillation, indicating that depth is less critical when distillation is applied.
  • The time cost of the RNN decoder is significantly lower than that of the Transformer decoder—138.0s vs. 434.1s on NIST—confirming the efficiency gain from replacing attention-heavy decoding with RNN.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.