Papers › DiffCSE: Difference-based Contrastive Learning for Sentence Embeddings

DiffCSE: Difference-based Contrastive Learning for Sentence Embeddings

21 Apr 2022NAACL 2022 7arXiv:2204.10298archive 2025-07-28

Yung-Sung Chuang, Rumen Dangovski, Hongyin Luo, Yang Zhang, Shiyu Chang, Marin Soljačić, Shang-Wen Li, Wen-tau Yih, Yoon Kim, James Glass

We propose DiffCSE, an unsupervised contrastive learning framework for learning sentence embeddings. DiffCSE learns sentence embeddings that are sensitive to the difference between the original sentence and an edited sentence, where the edited sentence is obtained by stochastically masking out the original sentence and then sampling from a masked language model. We show that DiffSCE is an instance of equivariant contrastive learning (Dangovski et al., 2021), which generalizes contrastive learning and learns representations that are insensitive to certain types of augmentations and sensitive to other "harmful" types of augmentations. Our experiments show that DiffCSE achieves state-of-the-art results among unsupervised sentence representation learning methods, outperforming unsupervised SimCSE by 2.3 absolute points on semantic textual similarity tasks.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2204.10298")

Code

Syntology Ran 2 of 4 code samples harvested from 1 repository linked to this paper; 2 have no recorded run. Of those that ran: 2 ran · our draft was wrong.

By repository: official repository: 4 samples from 1 repository, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

voidism/diffcse officialmentioned in papermentioned on GitHubjaxMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

4 samples harvested; 2 ran; 0 honoured the contract we drafted; 2 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · our draft was wrong
2unverified

Licence: 0 of the 4 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from voidism/diffcse. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

create_position_ids_from_input_ids voidism/diffcse/modeling_roberta.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · d4903874fdec3763 · report
sentemb_forward voidism/diffcse/diffcse/models.py official repository ran · our draft was wrong MIT (permissive) · cb67cd5ac977480d · report
cl_forward voidism/diffcse/diffcse/models.py official repository unverified MIT (permissive) · c4cccc3c604c8c75 · report
load_tf_weights_in_bert voidism/diffcse/modeling_bert.py official repository unverified MIT (permissive) · 26be70dca3249c0b · report

Tasks

Contrastive LearningLanguage ModelingLanguage ModellingRepresentation LearningSemantic Textual SimilaritySentenceSentence Embeddings

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Semantic Textual Similarity STS12 DiffCSE-BERT-base Spearman Correlation 0.7228 #13 of 20 Archive leaderboard report
Semantic Textual Similarity STS12 DiffCSE-RoBERTa-base Spearman Correlation 0.7005 #16 of 20 Archive leaderboard report
Semantic Textual Similarity STS13 DiffCSE-BERT-base Spearman Correlation 0.8443 #13 of 22 Archive leaderboard report
Semantic Textual Similarity STS13 DiffCSE-RoBERTa-base Spearman Correlation 0.8343 #14 of 22 Archive leaderboard report
Semantic Textual Similarity STS14 DiffCSE-BERT-base Spearman Correlation 0.7647 #14 of 21 Archive leaderboard report
Semantic Textual Similarity STS14 DiffCSE-RoBERTa-base Spearman Correlation 0.7549 #15 of 21 Archive leaderboard report
Semantic Textual Similarity STS15 DiffCSE-BERT-base Spearman Correlation 0.8390 #13 of 20 Archive leaderboard report
Semantic Textual Similarity STS15 DiffCSE-RoBERTa-base Spearman Correlation 0.8281 #14 of 20 Archive leaderboard report
Semantic Textual Similarity STS16 DiffCSE-RoBERTa-base Spearman Correlation 0.8212 #13 of 20 Archive leaderboard report
Semantic Textual Similarity STS16 DiffCSE-BERT-base Spearman Correlation 0.8054 #14 of 20 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

Contrastive LearningSimCSE

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections