Dynamic and Efficient Inference for Text Generation via BERT Family

Xiaobo Liang, Juntao Li, Lijun Wu, Ziqiang Cao, Min Zhang

Introduction

Large pre-trained language models like BART and T5 have set benchmarks in text generation but face significant deployment hurdles. Their reliance on autoregressive (AR) decoding—generating tokens sequentially—results in high latency and poor parallelization. Furthermore, deploying these models across diverse hardware (from cloud servers to mobile devices) typically requires maintaining multiple model versions. This paper introduces DEER (Dynamic and Efficient infERence), a method that transforms BERT-family models into flexible, non-autoregressive (NAR) generators capable of dynamic size adjustment.

Methodology: Adapting BERT for Generation

DEER repurposes encoder-only models (e.g., RoBERTa, XLM-R) for generation tasks through a two-stage process involving single-step generation and iterative refinement.

Non-Autoregressive Generation

Instead of token-by-token generation, DEER employs a single-step Connectionist Temporal Classification (CTC) generator to produce an initial draft. This draft is then refined by an iterative "Levenshtein Editor" that performs parallel insertions and deletions. To enable this, the authors designed specific input formats and self-attention masks that prevent the target text from attending to future tokens during training, effectively converting the bidirectional encoder into a generative model.

Overview of the DEER generation process, showing single-step CTC generation and iterative refinement with cached hidden states.

Dynamic Block Pruning

To handle varying hardware constraints, DEER uses movement pruning during training. Importance scores are assigned to parameter blocks in the attention and feed-forward layers. At inference, a global threshold allows the model to be pruned to specific sparsity levels (e.g., 75%, 45%, 25%) without additional fine-tuning for each sub-model.

Key Insights

The study reveals that BERT's bidirectional attention is naturally suited for NAR objectives, as it allows the model to consider the entire sequence context simultaneously. A critical finding involves the distribution of parameters across layers during pruning.

Parameter keep percentages across transformer layers for different pruning targets, highlighting that top layers are more frequently pruned.

As shown in the pruning analysis, the model tends to retain more parameters in the lower layers, while the top layers are more expendable. This suggests that foundational semantic features captured in early layers are more critical for generation than the specialized features in later layers when operating under tight parameter budgets. Additionally, the authors found that L1 norm regularization is mandatory to ensure that pruned sub-models maintain performance.

Results and Performance

DEER demonstrates significant improvements in both speed and quality across several benchmarks:

  • Inference Speed: On Neural Machine Translation (NMT) tasks, DEER achieves a 3x to 12x speedup over standard AR Transformers, depending on the number of refinement iterations.
  • Translation Quality: On the IWSLT’14 De→En dataset, DEER outperformed the AR baseline by over 2 BLEU points (37.46 vs 35.05) using four refinement steps on distilled data.
  • Monolingual Generation: On GLGE benchmarks like XSUM, DEER achieved performance comparable to BART-Base while being up to 9.3x faster.

Conclusion and Limitations

DEER provides a robust framework for efficient text generation by combining NAR decoding with dynamic pruning. However, it currently relies on the CTC assumption that the input sequence is longer than the target, which may limit its use in tasks where the output is significantly longer than the input. Future work aims to address length prediction challenges to broaden the framework's applicability.

Summary updated

BibTeX
@inproceedings{liang2023dynamic,
  author = {Xiaobo Liang and Juntao Li and Lijun Wu and Ziqiang Cao and Min Zhang},
  title = {{Dynamic and Efficient Inference for Text Generation via BERT Family}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.162},
}
Figure