VIRT: Improving Representation-based Text Matching via Virtual Interaction

Dan Li, Yang Yang, Hongyin Tang, Jiahao Liu, Qifan Wang, Jingang Wang, Tong Xu, Wei Wu, Enhong Chen

Introduction

Text matching is a fundamental task in Natural Language Processing (NLP), critical for applications ranging from search engines to question-answering systems. Traditionally, models have been divided into two paradigms: interaction-based models (cross-encoders) and representation-based models (dual-encoders). While cross-encoders achieve high accuracy by allowing all-to-all word interactions, they are computationally prohibitive for large-scale retrieval. Conversely, dual-encoders offer high efficiency through pre-computable embeddings but suffer from lower accuracy due to the lack of cross-sequence interaction.

The Challenge of Text Matching

The performance gap between these two paradigms stems from the "missing interaction" in dual-encoders. In a cross-encoder, every token in one sequence can attend to every token in another. In a dual-encoder, sequences are processed in isolation, preventing the model from capturing fine-grained semantic relationships between the two inputs.

Comparison of (a) Interaction-based, (b) Representation-based, and (c) VIRT models.

The VIRT Framework

VIRT (Virtual InteRacTion) is a novel training framework designed to bridge this gap. It enables dual-encoders to "mimic" the rich interactions of cross-encoders during training without sacrificing inference speed.

Knowledge Distillation of Attention Maps

The core of VIRT is the distillation of internal attention maps. In a cross-encoder, the attention matrix includes cross-attention quadrants where tokens from Sequence A attend to Sequence B. Dual-encoders naturally lack these quadrants. VIRT forces the dual-encoder (the student) to generate "virtual" versions of these missing quadrants, penalizing deviations from the cross-encoder (the teacher) via a specific distillation loss.

The VIRT architecture illustrating the knowledge transfer process from a cross-encoder teacher to a dual-encoder student.

VIRT-Adapted Interaction Layer

To utilize these virtual interactions, VIRT introduces a lightweight fusion module at the top of the model. This module combines the final representations of both sequences using the learned virtual attention before producing a final relevance score. Crucially, this heavy distillation process only happens during training; at inference time, the model remains a dual-encoder, allowing for offline computation of embeddings.

Experimental Results

VIRT was evaluated across six benchmarks, including MNLI, RTE, QQP, and BoolQ.

  • Superior Accuracy: On the MNLI dataset, VIRT achieved 78.6% accuracy, a significant improvement over the 60.2% achieved by standard Siamese BERT.
  • Efficiency: Despite the accuracy boost, VIRT maintains the inference advantages of dual-encoders, offering a 5x speedup over BERT-base cross-encoders (66.5ms vs 332.6ms latency).
  • Versatility: The framework proved effective when applied to various student architectures, including Poly-encoders and Sentence-T5, consistently boosting their performance.

Conclusion

VIRT successfully addresses the accuracy-efficiency trade-off in text matching. By distilling cross-sequence interactions into a "virtual" space, it allows representation-based models to achieve performance closer to cross-encoders while retaining the high throughput necessary for real-world production environments.

Summary updated

BibTeX
@inproceedings{li2022virt,
  author = {Dan Li and Yang Yang and Hongyin Tang and Jiahao Liu and Qifan Wang and Jingang Wang and Tong Xu and Wei Wu and Enhong Chen},
  title = {{VIRT: Improving Representation-based Text Matching via Virtual Interaction}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.emnlp-main.59},
}
Figure