Trans-Encoder: Unsupervised sentence-pair modelling through self- and mutual-distillations

Fangyu Liu, Yunlong Jiao, Jordan Massiah, Emine Yilmaz, Serhii Havrylov
9/27/2021
cs.CLcs.AIcs.LG
distillation

Official code: amzn/trans-encoder (133 stars, Python, Apache-2.0, last commit 2026-07-02).

Abstract

In NLP, a large volume of tasks involve pairwise comparison between two sequences (e.g. sentence similarity and paraphrase identification). Predominantly, two formulations are used for sentence-pair tasks: bi-encoders and cross-encoders.

Show full abstract

Bi-encoders produce fixed-dimensional sentence representations and are computationally efficient, however, they usually underperform cross-encoders. Cross-encoders can leverage their attention heads to exploit inter-sentence interactions for better performance but they require task fine-tuning and are computationally more expensive. In this paper, we present a completely unsupervised sentence representation model termed as Trans-Encoder that combines the two learning paradigms into an iterative joint framework to simultaneously learn enhanced bi- and cross-encoders. Specifically, on top of a pre-trained Language Model (PLM), we start with converting it to an unsupervised bi-encoder, and then alternate between the bi- and cross-encoder task formulations. In each alternation, one task formulation will produce pseudo-labels which are used as learning signals for the other task formulation. We then propose an extension to conduct such self-distillation approach on multiple PLMs in parallel and use the average of their pseudo-labels for mutual-distillation. Trans-Encoder creates, to the best of our knowledge, the first completely unsupervised cross-encoder and also a state-of-the-art unsupervised bi-encoder for sentence similarity. Both the bi-encoder and cross-encoder formulations of Trans-Encoder outperform recently proposed state-of-the-art unsupervised sentence encoders such as Mirror-BERT and SimCSE by up to 5% on the sentence similarity benchmarks.

View on arXivView PDF

Code Implementations(1)

amzn/trans-encoderOfficial100%
Apache-2.0

Trans-Encoder: Unsupervised sentence-pair modelling through self- and mutual-distillations

13316Python, ShellNov 24, 20215 months agoApache-2.0

Similar Papers

Cite this paper

@article{liu2021transencoder,
  title  = {Trans-Encoder: Unsupervised sentence-pair modelling through self- and mutual-distillations},
  author = {Fangyu Liu and Yunlong Jiao and Jordan Massiah and Emine Yilmaz and Serhii Havrylov},
  year   = {2021},
  eprint = {2109.13059},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2109.13059}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2109.13059.svg)](https://codeofpaper.com/paper/2109.13059)

Discussion