Abstract
Pre-trained Transformer language models (LM) have become go-to text representation encoders. Prior research fine-tunes deep LMs to encode text sequences such as sentences and passages into single dense vector representations for efficient text comparison and retrieval. However, dense encoders require a lot of data and sophisticated techniques to effectively train and suffer in low data situations. This paper finds a key reason is that standard LMs' internal attention structure is not ready-to-use for dense encoders, which needs to aggregate text information into the dense representation. We propose to pre-train towards dense encoder with a novel Transformer architecture, Condenser, where LM prediction CONditions on DENSE Representation. Our experiments show Condenser improves over standard LM by large margins on various text retrieval and similarity tasks.
Introduction
In Information Retrieval (IR), dense retrieval (bi-encoders) has emerged as a gold standard for efficiency, enabling fast comparison of query and document vectors via simple inner products. However, standard Language Models (LMs) like BERT are not inherently optimized for this task. Analysis reveals that the [CLS] token—typically used for the final dense representation—remains largely "dormant" throughout most layers in a standard BERT model, only broadening its attention to the entire sequence in the final layers.
Consequently, when fine-tuning these models for retrieval, significant "learning effort" is spent restructuring internal attention patterns to aggregate information rather than learning the task itself. This structural unreadiness makes bi-encoders difficult to train, often necessitating massive datasets and complex techniques like hard negative mining.
The Condenser Architecture
To address this, we introduce Condenser, a modified Transformer architecture designed to be "structurally ready" for dense retrieval. The core innovation lies in forcing the model to aggregate information into the [CLS] token during the pre-training phase.
The architecture consists of:
- Backbone Split: The Transformer is divided into "early" and "late" layers.
- Condenser Head: A specialized head used only during pre-training. It takes token representations from early layers and the
[CLS]token from the late layers as inputs. - Information Bottleneck: To predict masked tokens, the head is forced to use the late-layer
[CLS]token. Since early-layer tokens lack deep context, the model must "condense" missing information into the[CLS]vector to succeed at the Masked Language Modeling (MLM) task.
Post-pre-training, the Condenser head is discarded, leaving a backbone identical in architecture to standard BERT, serving as a drop-in replacement.
Experimental Evaluation
Condenser was pre-trained on English Wikipedia and BookCorpus and evaluated across several benchmarks, including:
- Sentence Similarity: STS-benchmark and Wikipedia Section Distinction.
- Open Domain QA: Natural Questions (NQ) and TriviaQA.
- Web Search: MS-MARCO and TREC DL2019.
Key Results
Condenser demonstrates significant improvements, particularly in low-data regimes. For instance, with only 1,000 training examples for Natural Questions, Condenser achieved 72.7% Top-20 accuracy, significantly outperforming BERT's 66.6%. On the MS-MARCO passage ranking task, Condenser achieved an MRR@10 of 0.366, surpassing complex systems like ANCE (0.330) without requiring expensive denoising or data augmentation.
Structural Readiness and Attention Patterns
The concept of "structural readiness" is validated through an analysis of attention entropy. While standard BERT undergoes a drastic structural shift during fine-tuning, Condenser maintains a more consistent internal structure.
By turning the [CLS] token from a passive placeholder into an active information aggregator, Condenser ensures the model is prepared for the global aggregation required by bi-encoders. Furthermore, Condenser is more robust to noise in training data and does not require the massive batch sizes or specialized hardware often associated with previous methods like the Inverse Cloze Task (ICT).
Conclusion
Condenser provides a simple yet effective way to pre-train LMs for dense retrieval. By making the architecture "structurally ready," it simplifies the fine-tuning process and improves performance across various tasks. Future work may explore optimizing the layer split and combining Condenser with advanced contrastive learning strategies to further push the boundaries of dense representation learning.
Summary updated