Skip to main content
QUICK REVIEW

[Paper Review] DeFormer: Decomposing Pre-trained Transformers for Faster Question Answering

Qingqing Cao, Harsh Trivedi|arXiv (Cornell University)|May 2, 2020
Topic ModelingComputer Science28 references9 citations
TL;DR

DeFormer accelerates question answering by decomposing pre-trained Transformers to process questions and passages independently in lower layers, enabling offline caching of passage representations and reducing runtime compute by up to 4.3x with only a 1% accuracy drop via distillation. It preserves model performance by initializing from pre-trained weights and fine-tuning directly on downstream tasks.

ABSTRACT

Transformer-based QA models use input-wide self-attention -- i.e. across both the question and the input passage -- at all layers, causing them to be slow and memory-intensive. It turns out that we can get by without input-wide self-attention at all layers, especially in the lower layers. We introduce DeFormer, a decomposed transformer, which substitutes the full self-attention with question-wide and passage-wide self-attentions in the lower layers. This allows for question-independent processing of the input text representations, which in turn enables pre-computing passage representations reducing runtime compute drastically. Furthermore, because DeFormer is largely similar to the original model, we can initialize DeFormer with the pre-training weights of a standard transformer, and directly fine-tune on the target QA dataset. We show DeFormer versions of BERT and XLNet can be used to speed up QA by over 4.3x and with simple distillation-based losses they incur only a 1% drop in accuracy. We open source the code at https://github.com/StonyBrookNLP/deformer.

Motivation & Objective

  • To reduce inference latency and memory usage in pre-trained Transformer-based question answering models without retraining from scratch.
  • To explore whether input-wide self-attention can be replaced with question- and passage-wide self-attention in lower layers without significant performance degradation.
  • To enable faster inference by pre-computing and caching passage representations independently of the question.
  • To maintain high accuracy in the decomposed model by using distillation-based loss to align outputs with the original model.
  • To provide a plug-and-play method to accelerate existing pre-trained models like BERT and XLNet for real-world deployment.

Proposed method

  • DeFormer replaces full input-wide self-attention in the first k layers with separate question-wide and passage-wide self-attention mechanisms.
  • Passage representations are computed offline and cached after the k-th layer, allowing reuse across multiple questions.
  • During inference, the question is processed through the first k layers, and the cached passage representation is loaded to merge inputs at the (k+1)-th layer.
  • The model is initialized using pre-trained weights from standard BERT or XLNet and fine-tuned directly on downstream QA datasets.
  • Two distillation losses are introduced: one to minimize output-level divergence and another to minimize layer-level representation divergence between DeFormer and the original model.
  • The distillation process ensures that the upper layers of DeFormer learn to produce representations similar to those of the original model, minimizing accuracy drop.

Experimental results

Research questions

  • RQ1Can replacing input-wide self-attention with question- and passage-wide self-attention in lower layers of a Transformer reduce inference latency without significant accuracy loss?
  • RQ2To what extent can passage representations be pre-computed and cached to reduce runtime computation in QA systems?
  • RQ3How effective is distillation in aligning the outputs and intermediate representations of a decomposed model with those of the original model?
  • RQ4Can DeFormer achieve faster inference than smaller baseline models while maintaining higher accuracy?
  • RQ5What is the trade-off between speedup, memory reduction, and accuracy loss across different QA tasks and model architectures?

Key findings

  • DeFormer achieves a 2.7x to 4.3x speedup in inference time across multiple QA datasets when applied to BERT and XLNet.
  • Memory usage is reduced by 65.8% to 72.9% due to the elimination of intermediate passage representations during inference.
  • With distillation, DeFormer incurs only a 0.6% to 1.8% drop in F1 score compared to the original model, with a maximum 1% accuracy drop on some benchmarks.
  • The DeFormer version of BERT-large runs faster than the original BERT-base while maintaining higher accuracy, demonstrating superior efficiency-accuracy trade-offs.
  • Ablation studies confirm that distillation losses significantly improve performance, especially in maintaining representation alignment with the original model.
  • The method is effective across different tasks, including reading comprehension and sentence-pair matching, and can be applied to any model relying on input-wide self-attention.

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.