Introduction
Sentence embeddings are fundamental to modern Natural Language Processing (NLP), enabling tasks such as semantic search, document clustering, and information retrieval. While encoder-only architectures like BERT have long served as the standard for generating these embeddings, the "Text-to-Text Transfer Transformer" (T5) has demonstrated superior performance across a wide range of other NLP benchmarks. Sentence-T5 (ST5) represents the first comprehensive effort to adapt the T5 encoder-decoder framework into a high-performance sentence encoder, scaling the architecture up to 11 billion parameters.
Adapting the T5 Architecture
Transitioning T5 from a generative model to an embedding model requires addressing how to extract a single representative vector from its complex architecture. The researchers explored three primary configurations:
- ST5-Enc (first): Utilizing the representation of the first token from the encoder.
- ST5-Enc (mean): Averaging all token representations from the encoder.
- ST5-EncDec (first): Passing encoder outputs through the decoder and extracting the first decoded token's representation.
A key finding was that mean pooling significantly outperforms first-token pooling for T5 encoders. Unlike BERT, which includes a dedicated [CLS] token for classification, T5’s first token is simply the first word of the input. Consequently, averaging the hidden states of all tokens provides a more holistic representation of the sentence's semantics.
Two-Stage Contrastive Learning
Raw embeddings from pre-trained models often suffer from "anisotropy," where vectors are clustered in a narrow cone, limiting their discriminative power. To resolve this, ST5 employs a two-stage contrastive learning recipe:
- Stage 1: Conversational Pre-training. The model is trained on 2 billion web-mined conversational and question-answer (CQA) pairs to learn general semantic relatedness.
- Stage 2: NLI Fine-tuning. The model is further refined using Natural Language Inference (NLI) datasets, teaching it to distinguish between entailment and contradiction.
Scaling and Performance
A central question of the study was whether the massive scale of generative models translates into better embeddings. The results confirm that performance on both transfer tasks and Semantic Textual Similarity (STS) improves consistently as the model scales from 110 million (Base) to 11 billion parameters.
The ST5-EncDec (11B) variant achieved a new state-of-the-art Spearman correlation of 84.94 on STS tasks. Interestingly, the decoder-based approach proved particularly effective for similarity tasks, acting as a sophisticated attention pooling layer. For transfer tasks, the ST5-Enc (11B) model reached a peak accuracy of 91.63%.
Benchmarking with SentGLUE
To further validate these representations, the authors introduced SentGLUE. This benchmark adapts nine tasks from the GLUE suite but imposes a "sentence embedding" constraint: models must produce a fixed-size vector for each sentence, which is then processed by a simple linear classifier. This prevents models from relying on cross-attention between sentence pairs, providing a truer measure of individual sentence representation quality.
Conclusion
Sentence-T5 demonstrates that scaling is a viable path toward more powerful sentence encoders. By combining the T5 architecture with a robust contrastive learning pipeline, the researchers have pushed the boundaries of semantic representation. Future work may explore increasing embedding dimensions to match model capacity and distilling decoder-based performance into more efficient encoder-only models.
Summary updated