Contrastive Learning with Prompt-derived Virtual Semantic Prototypes for Unsupervised Sentence Embedding

Jiali Zeng, Yongjing Yin, Yufan Jiang, Shuangzhi Wu, Yunbo Cao

Introduction

High-quality sentence embeddings—vector representations of textual meaning—are fundamental to modern Natural Language Processing (NLP) tasks such as semantic search, clustering, and information retrieval. While unsupervised contrastive learning methods like SimCSE have set strong benchmarks, they often struggle with capturing global semantic structures and are sensitive to noise introduced during data augmentation. This paper introduces ConPVP (Contrastive learning with Prompt-derived Virtual semantic Prototypes), a novel framework that leverages the latent knowledge within pre-trained language models (PLMs) to anchor sentence embeddings to broader semantic concepts.

The Limitations of Instance-wise Contrastive Learning

Standard unsupervised contrastive learning typically relies on "instance-wise" objectives. A model is trained to minimize the distance between a sentence and its augmented version (e.g., via dropout) while maximizing the distance from other sentences in the batch. However, this approach has two primary drawbacks:

  1. Local Smoothness vs. Global Structure: By focusing only on individual pairs, the model fails to learn the underlying semantic categories of the language.
  2. Semantic Drift: Simple augmentations can inadvertently alter the meaning of a sentence, leading the model to learn incorrect associations.

The ConPVP Framework: Mining Latent Prototypes

ConPVP addresses these issues by introducing "virtual semantic prototypes" derived directly from the PLM using prompt learning. Instead of clustering the dataset to find centroids, the method uses natural language templates to query the model's internal knowledge.

Prototype Extraction via Prompts

For any given sentence $<S>$, ConPVP wraps it in a template like "<S> is a [MASK] one". The hidden state of the [MASK] token serves as a positive prototype, representing the general semantic category of the sentence. To provide a more robust training signal, the authors also employ Semantically Opposite Templates (e.g., "<S> is not a [MASK] one") to generate negative prototypes.

Figure 1: Illustration of basic and semantically opposite templates used to derive virtual prototypes from the MLM head.

Prototypical Contrastive Learning

The training objective is a modified prototypical contrastive loss. As shown in the architecture, the model learns to pull a sentence embedding closer to its corresponding positive prototype while pushing it away from its negative prototype and the prototypes of other sentences in the batch. This ensures that the embedding space is not only locally smooth but also globally structured.

Figure 3: The ConPVP architecture showing the contrastive learning process between sentence anchors and prompt-derived prototypes.

Experimental Evaluation

The researchers evaluated ConPVP across several benchmarks, including Semantic Textual Similarity (STS), short text clustering, and transfer tasks.

  • STS Performance: ConPVP achieved significant gains over SimCSE, with an average improvement of 2.60 points on BERT-base and 1.28 points on RoBERTa-large.
  • Clustering Accuracy: The prototype-based approach improved short text clustering accuracy by up to 2.18 points, demonstrating its ability to group semantically related topics effectively.
  • Few-Shot Stability: In low-resource settings (16 samples per class), ConPVP showed greater robustness and higher accuracy than previous state-of-the-art models.

Conclusion

ConPVP demonstrates that the [MASK] token in a prompt-wrapped sentence can effectively capture a "summary" of its semantic role. By aligning sentences with these virtual prototypes, the model creates a more discriminative and semantically meaningful embedding space without the need for labeled data. This approach paves the way for more sophisticated uses of prompt learning in unsupervised representation learning.

Reference: Zeng, J., Yin, Y., Jiang, Y., Wu, S., & Cao, Y. (2022). Contrastive Learning with Prompt-derived Virtual Semantic Prototypes for Unsupervised Sentence Embedding. Findings of EMNLP 2022.

Summary updated

BibTeX
@inproceedings{zeng2022contrastive,
  author = {Jiali Zeng and Yongjing Yin and Yufan Jiang and Shuangzhi Wu and Yunbo Cao},
  title = {{Contrastive Learning with Prompt-derived Virtual Semantic Prototypes for Unsupervised Sentence Embedding}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.findings-emnlp.522},
}
Figure