---
title: "Exploring the Impact of Negative Samples of Contrastive"
description: "MoCoSE tests how the number and age of negative examples affect contrastive sentence embeddings and finds that longer queues can hurt."
canonical: "https://research.elamur.ai/free/en/papers/cao-2022-exploring-impact-negative-samples-contrastive/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/cao-2022-exploring-impact-negative-samples-contrastive/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2022](https://md.research.elamur.ai/free/en/papers/2022/) / Exploring the Impact of Negative Samples of Contrastive Learning: A Case Study of Sentence Embedding

# Exploring the Impact of Negative Samples of Contrastive Learning: A Case Study of Sentence Embedding

Paper · 2022 · Rui Cao, Yihao Wang, Yuxin Liang et al.

**Authors:** [Rui Cao](https://md.research.elamur.ai/free/en/authors/rui-cao/), [Yihao Wang](https://md.research.elamur.ai/free/en/authors/yihao-wang/), Yuxin Liang, Ling Gao, [Jie Zheng](https://md.research.elamur.ai/free/en/authors/jie-zheng/), [Jie Ren](https://md.research.elamur.ai/free/en/authors/jie-ren/) and [Zheng Wang](https://md.research.elamur.ai/free/en/authors/zheng-wang/) · **Year:** 2022 · **Venue:** Findings of the Association for Computational Linguistics: ACL 2022 · **Licence:** [CC BY 4.0 (ACL Anthology)](https://creativecommons.org/licenses/by/4.0/)

Findings of the Association for Computational Linguistics: ACL 2022 · [licence](https://creativecommons.org/licenses/by/4.0/)

- [Publisher's page](https://aclanthology.org/2022.findings-acl.248/)
- [PDF](https://aclanthology.org/2022.findings-acl.248.pdf)
- [DOI 10.18653/v1/2022.findings-acl.248](https://doi.org/10.18653/v1/2022.findings-acl.248)

## Summary

A sentence embedding turns a sentence into a vector so that its meaning can be compared with the meaning of another sentence. One way to learn these vectors from unlabeled text is to give a system two versions of the same sentence and ask it to identify the matching version among alternatives. The alternatives are called negatives. Cao and colleagues ask what happens when those negatives come from a queue of vectors produced during earlier training steps. A longer queue makes more alternatives available, but some of them come from a time when the system represented sentences differently. The paper tests how much of that history helps when the eventual goal is to judge [semantic similarity](https://md.research.elamur.ai/free/en/concepts/semantic-similarity/).

The authors build MoCoSE around two branches initialized from [BERT](https://md.research.elamur.ai/free/en/papers/devlin-2019-bert-pre-training-deep-bidirectional/). The online branch produces a query, and the target branch produces the matching key from another view of the same sentence. Dropout and a small gradient-based perturbation create variation between the views without rewriting the sentence. The learning objective rewards the query for matching its key more strongly than the keys already in the queue. It updates the online branch directly. The target branch follows through an exponential moving average and supplies keys for future comparisons. The authors find that a predictor on the online branch and the moving update help keep the training procedure from degenerating.

With BERT-base, MoCoSE reports an average Spearman correlation of 77.27% across the semantic textual similarity tasks, compared with 76.25% for unsupervised [SimCSE](https://md.research.elamur.ai/free/en/papers/gao-2021-simcse-simple-contrastive-learning-sentence/). MoCoSE with BERT-large reaches 79.13 on the same average, ahead of the large alternatives in the comparison. Individual tasks favor different systems, and the transfer-task scores give a mixed picture. The base MoCoSE variant is broadly comparable to SimCSE on transfer, while the advantage on sentence similarity is clearer.

The queue experiments explain why adding negatives is an incomplete description of the intervention. In a controlled comparison, the middle part of a queue gave a better result than an equally sized slice at either end. The authors combine queue capacity, batch size, and the rate at which the target follows the online branch into a measure they call maximum traceable distance. The strongest results occurred around 14.67 for BERT-base and around 22 for BERT-large in the respective history experiments. The different peaks matter. The findings support tuning the amount of history carried into a comparison, with the usable range depending on the training setup.

## Deep dive: Exploring the Impact of Negative Samples of Contrastive Learning: A Case Study of Sentence Embedding

MoCoSE tests how the number and age of negative examples affect contrastive sentence embeddings and finds that longer queues can hurt. · about 34 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### When a sentence vector becomes a measure of meaning

The experiments address a particular job for a sentence representation. Given pairs of sentences, the system should assign greater similarity to pairs that people judge more similar in meaning. A useful representation must support this comparison across sentences it encounters at evaluation time. Producing a vector for each sentence is only the starting point. The arrangement of those vectors determines which pairs appear close and whether their ordering agrees with the judgments used by the benchmark.

A pretrained BERT encoder gives a straightforward way to obtain a sentence vector. The paper draws attention to the special `[CLS]` position, whose output can serve as a representation of the input as a whole. Its availability makes it easy to extract such a vector, but the authors describe a problem with the resulting geometry. The vectors can be anisotropic, meaning they cluster preferentially along some directions in the representation space. Under those conditions, a similarity score has less room to distinguish the relationships that matter for the task. The concern is how the representations are distributed, a problem discussed in [Representation Degeneration](https://md.research.elamur.ai/free/en/papers/gao-2019-representation-degeneration-problem-training-natural/).

Earlier work approached that geometry in more than one way. BERT-Flow and BERT-whitening act on the representations produced by the encoder. The general approach is to change the distribution of those outputs so that their comparisons are more useful. Contrastive training puts the pressure on the encoder as it learns. It makes the relative placement of different examples part of the objective, so sentences are positioned through repeated comparisons during training. These are different points at which to intervene in the route from a pretrained encoder to usable sentence vectors. [BERT-Flow](https://md.research.elamur.ai/free/en/papers/li-2020-sentence-embeddings-pre-trained-language/)

#### Where the training comparisons come from

The defining comparison in this study has a query, a positive and a collection of negatives. The positive is a second view of the same source sentence. A negative is an alternative the objective asks the query to score below that positive. These roles are assigned by the training procedure. In particular, two different source sentences can express similar ideas, so a negative carries an instruction about the comparison without necessarily carrying a human judgment of unrelatedness.

Positive pairs give the encoder a reason to retain information that survives a small change in the input or its representation. If the only pressure were to make paired views agree, an encoder could meet that pressure by mapping every input to the same vector. The paper calls that outcome collapse. Negatives create pressure in the other direction because a representation shared by all sentences gives the query no way to distinguish the positive. The practical question is how to supply comparisons that encourage separation while leaving semantically related sentences close enough for a downstream similarity task.

In [SimCLR](https://md.research.elamur.ai/free/en/papers/chen-2020-simple-framework-contrastive-learning-visual/), as the authors describe it, different transformations of an image create the positive pair. Other images in the same training batch supply the alternatives. For a batch-based method, the number of comparisons available to a query depends on how many examples are processed together. Enlarging the batch can supply more negatives, and their vectors are produced during the current training step. This gives an experimenter a way to change the number of comparisons without introducing a bank of old representations.

The paper presents unsupervised SimCSE as the sentence counterpart most directly relevant to this setup. Its positive pair comes from passing the same sentence through the encoder under different dropout masks. Dropout randomly suppresses part of the computation, giving the two passes different vector representations even though the words have stayed the same. The other sentences in the batch supply the negatives. The paper motivates MoCoSE in part through the authors’ observation that simply increasing the batch size in their SimCSE experiments did not bring the improvement they were looking for.

#### What changes when negatives are kept in a queue

[Momentum Contrast](https://md.research.elamur.ai/free/en/papers/he-2019-momentum-contrast-unsupervised-visual-representation/) supplies a way to keep many alternatives available across training steps. Instead of computing every negative from the current batch, it stores keys generated in earlier steps. The newest keys are added at one end and the oldest make way at the other. This first-in, first-out order makes the queue a record of recent training. It lets the batch and the number of available comparisons be set separately.

A retained key can be used again without repeatedly encoding its source example. The tradeoff is that its position in the vector space was assigned by an earlier version of the target branch. An encoder changes as it trains, which means the relation between a stored vector and a newly generated query depends partly on when the stored vector was made. Using a queue introduces this issue even when every entry comes from the same corpus and is encoded by the same architecture. An entry belongs to a past state of the training procedure.

The moving target in Momentum Contrast is important for this reason. It changes gradually in response to the online branch, allowing successive batches of keys to come from a more slowly changing encoder. The choice introduces another source of history. Even the newest key is produced by a target whose parameters reflect earlier online parameters. An older key adds time spent in the queue to the history already present when it was encoded. This is the distinction MoCoSE eventually expresses through the two terms of its traceable-distance measure.

The authors also draw on [BYOL](https://md.research.elamur.ai/free/en/papers/grill-2020-bootstrap-your-own-latent-new/). In the account they give, BYOL learns from positive pairs with a predictor on one branch and a moving-average target on the other. MoCoSE adopts the asymmetry and retains explicit negatives. The predecessor therefore supplies an architectural choice for handling the relationship between the branches, while Momentum Contrast supplies a way to retain comparisons. The paper also mentions SimSiam as another investigation of asymmetry and describes other visual approaches that place constraints in the objective itself.

#### Why constructing views is different for sentences

The paper treats the choice of augmentation as part of the experimental question. An augmentation should change the view enough to give the encoder something to learn while preserving the relationship that makes the pair positive. In text, deleting a word, rearranging phrases, or replacing a word with another can change what the sentence says. Leaving the words in place and perturbing their numerical representations offers a way to control the size of the intervention at another level.

The prior approaches surveyed in the paper span both possibilities. CLEAR changes words or phrases through deletion, rearrangement, or substitution. CERT builds views by translating away from the source language and back. CLINE assigns different training roles to synonyms and antonyms, using the former to make positives and the latter to make negatives. These choices act on the text or change which texts are paired. [ConSERT](https://md.research.elamur.ai/free/en/papers/yan-2021-consert-contrastive-framework-self-supervised/) is the precedent the authors point to for several perturbations that can be applied around the encoder input, including shuffling, cutoff, dropout, and gradient-directed changes.

The issue the authors inherit from visual contrastive learning is therefore more specific than whether negatives are beneficial. They want to know whether the queue behaves similarly when it carries sentence representations generated during the adaptation of a pretrained encoder. A previous study they discuss had already raised the possibility that a longer queue could fail to help. MoCoSE turns that possibility into a series of comparisons over capacity, queue position, and the update relationship between the two branches.

### The method, step by step

#### Building one comparison

Training starts from a batch of unlabeled sentences. For each sentence, MoCoSE constructs two slightly different views at the embedding stage. The online branch transforms one view into a query. The target branch transforms the other into a key. The key is the query’s positive because it comes from the same sentence. The queue supplies other keys, each of which competes with the matching key in the loss. The same arrangement is used across the examples in the batch.

Both branches have an encoder, a pooler, and a projection component. The pooler helps obtain a sentence-level representation from the encoder output. The projection component transforms that representation for the training comparison. MoCoSE puts a further predictor after the projection on the online side. That predictor transforms the query representation, giving the two branches different jobs even though their corresponding encoder, pooler, and projection components have the same structure. The paper describes the pooler, projection, and predictor in terms of fully connected layers.

When the training loop finishes a batch, it uses the loss to update the online branch. The target parameters then move toward the online parameters through an exponential moving average. The keys produced by the target branch serve another purpose after their positive comparisons are complete. MoCoSE adds them to the queue so that they can act as negatives in subsequent steps. When the queue has reached its capacity, a new batch displaces the oldest entries.

How MoCoSE trains on a batch The steps in order.

#### Perturbing the views

MoCoSE uses dropout at 0.1 and pairs it with the Fast Gradient Sign Method, abbreviated FGSM. Dropout introduces randomness into the two passes. FGSM uses the direction of change in the contrastive loss to make a small, deliberately chosen change to the embedding input. The gradient measures which input coordinates can raise the loss locally and in which direction. Taking only the sign of each coordinate turns that information into a direction whose size is then set by the perturbation parameter. [Fast Gradient Sign Method](https://md.research.elamur.ai/free/en/papers/goodfellow-2014-explaining-harnessing-adversarial-examples/)

```
x′ = x + ε · sign(∇ₓ L(x, θ))
```

Here, x is the unperturbed input to the embedding layer and x′ is its perturbed version. The parameter ε controls the step size. The operator ∇ₓ takes the gradient with respect to x, the input being changed, and sign keeps the direction of each gradient component. L is the contrastive loss, θ denotes the online branch, and the dot before sign denotes multiplication by the scalar ε. The selected perturbation size is 5e-9.

The direction depends on the training comparison because the loss depends on the relationship between the query, its key, and the alternatives in the queue. This distinguishes the perturbation from a fixed edit or a randomly selected synonym. It can make the positive pairing a little harder for the current encoder while continuing to use the same source sentence. The paper tests textual edits and other embedding perturbations as alternatives, but the main configuration combines FGSM with dropout.

#### Scoring the positive against the queue

The paper uses the InfoNCE objective from [Contrastive Predictive Coding](https://md.research.elamur.ai/free/en/papers/oord-2018-representation-learning-contrastive-predictive-coding/). For a given query, it first scores the matched key and each stored alternative. The matched key appears both above and below the fraction in the loss. The denominator adds the scores of the negatives, so the fraction measures the positive’s share of the total. Taking the negative logarithm gives a larger penalty when the positive has a smaller share.

```
L = −log[exp((q · k)/τ) / (exp((q · k)/τ) + ∑ₗ exp((q · l)/τ))]
```

Here, L is the loss for the comparison. The vector q is the online query, k is the target key paired with it, and l is an individual key in the negative queue. The sum ∑ₗ ranges over all negative keys used for that comparison. The centered dot between vectors denotes their dot product. The parameter τ is the temperature, which scales the dot products before exp, the exponential function, is applied. The outer log is the logarithm. The minus sign turns a high positive share into a small loss.

The loss is relative to the alternatives available in that step. A query can have a substantial score for its own key and still receive a large penalty if the queued vectors score well too. Likewise, a negative with a high score contributes more to the denominator than a negative with a low score. As a result, adding keys can change the training signal in two ways. It gives the query more competitors, and it can change the kinds of comparison that account for much of the penalty. Slicing the queue later in the study keeps the same objective and alters the collection over which it sums.

The target key also plays two roles at different times. It is the correct match for the query generated from its own sentence in the current batch. After insertion, it can appear in the denominator as an alternative for a future query. Its vector is reused in the second role. It remains in the coordinates assigned when the target first generated it, whereas the query that compares against it was produced after further updates.

#### Updating the branches and filling the queue

The loss gradient is used to change the online branch. The target branch stops the gradient and is updated separately. In the appendix’s training algorithm, Adam takes the online step before the target update. This order lets the target incorporate some of the current online change while retaining some of its previous parameter values.

```
θₜ ← ηθₜ + (1 − η)θₒ
```

Here, θₜ denotes the target parameters, with the right-hand occurrence referring to the values before replacement. The symbol θₒ denotes the current online parameters. The coefficient η is the exponential moving-average decay. The arrow means that the right-hand expression becomes the new target value, and 1 − η is the weight assigned to the current online parameters.

A higher η preserves more of the previous target. A lower η makes the target respond faster to the latest online update. As these steps repeat, the target accumulates contributions from earlier states of the online branch. This helps neighboring batches of keys come from related target states. It also means that a queue with fast turnover can still hold vectors produced by a target with considerable memory.

The training procedure gives the queue a partial random initialization. It starts with a smaller set of random vectors and grows toward its intended capacity as genuine keys arrive. Once it is full, the size stays fixed by dropping the oldest entries. This separates the number of comparison vectors used at the start from the number available in the established queue. A long queue can therefore be tested with a modest random starting set, which matters when interpreting results that would otherwise conflate length with the influence of startup vectors.

The paper’s architecture and loss descriptions identify the stored vectors as outputs of the target branch. The appendix pseudocode has an inconsistent notation at the enqueue step, where it names the augmented target view after having used the encoded target output in the loss. The method description and the queue experiments give the role of the intended entry: a target key is stored in the same space used for the contrastive comparison.

#### Training and extracting the sentence representation

The authors train on a random sample of 1 million [English](https://md.research.elamur.ai/free/en/topics/english/) Wikipedia sentences. The data are preprocessed following SimCSE so they can be loaded in stored form during training. The starting weights come from pretrained BERT checkpoints, and the authors use the output at `[CLS]` as the sentence representation. This separates the unlabeled training procedure from the human judgments used to measure performance later. The queue is part of the fine-tuning procedure, which adjusts an existing encoder for sentence similarity. [Fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/)

For MoCoSE with BERT-base the learning rate is 3e-5, and for BERT-large it is 1e-5. The reported weight decay is 1e-6. The base configuration uses a batch size of 64, and the large configuration uses 32. Training runs for one epoch, with validation every 100 steps. The main settings give the queue a capacity of 512. The decay increases from 0.75 to 0.95 according to a cosine schedule. The fixed-decay comparisons in the ablations are separate runs designed to examine the effect of that parameter.

The paper reports training with an NVIDIA RTX3090 and using the [Transformers](https://md.research.elamur.ai/free/en/papers/wolf-2020-transformers-state-art-natural-language/) and Datasets packages. It uses SentEval for evaluation and nlpaug for several of the augmentation comparisons. The authors also make their source code available. For the additional analysis of representation geometry, they preprocess STS-B and compute alignment and uniformity on it. These measurements have a different role from the training loss and from the correlations reported across the full benchmark suite.

#### Measuring how far back the negatives reach

The authors introduce maximum traceable distance to compare queues under different combinations of capacity, batch size, and target decay. The measure gives each of the two sources of history a term. The first represents the lag introduced by the moving average. The second represents how many batches fit in the queue, and hence how far back the oldest stored keys reach through turnover. Both are expressed on the scale of training updates.

```
dₜᵣₐ꜀ₑ = 1/(1 − η) + queue_size/batch_size
```

Here, dₜᵣₐ꜀ₑ is maximum traceable distance. The quantity η is the target decay. The expression 1/(1 − η) denotes the average-history term used for the moving target under the paper’s counting convention. The quantity queue_size is the number of keys the queue can hold, and batch_size is the number supplied per update. Their quotient is the turnover term for a full queue.

The distinction between those terms makes the measure useful for understanding the batch experiments. At fixed capacity, a larger batch replaces more entries each time and reaches through fewer updates. At fixed batch size, a larger capacity holds keys through more updates. Changing η affects the target that originally made each key, even without changing how long any of the keys stays in the queue. Settings can therefore land at similar values of traceable distance through different combinations of target memory and stored batches.

The word *maximum* refers to the use of the oldest retained part of the queue in the turnover term. The moving-average contribution is a weighted age. That part summarizes how much the target depends on different points in the online branch’s history. It does not treat an exponential moving average as a history with a hard cutoff. This distinction also explains why the paper derives that term by looking at the weights of past updates.

#### Where the moving-average term comes from

The appendix considers a fixed decay and unfolds the target update over past steps. The newest contribution carries the weight assigned to the online branch in the update rule. Reaching back another step multiplies the weight by the decay again. Each contribution is multiplied by its age, with the paper counting the first contribution from one. The sum gives a weighted history over a finite number of terms.

```
Sₙ = ∑ᵢ₌₀ᵏ (1 − η) · ηⁱ · (i + 1)
```

Here, Sₙ is the paper’s notation for the finite weighted history, with n labeling the accumulated quantity. The index i counts how far back a contribution lies, starting at 0, and k is the last index included. The decay is η, and ηⁱ means η raised to the power i. The coefficient 1 − η is the weight of a new online contribution, i + 1 is the age assigned to that term, and the centered dots denote multiplication.

The appendix rewrites the sum so that the terms depending on the finite history can be studied in a limit. An equivalent arrangement of its closed form is the difference between a finite geometric sum and the correction associated with the end of that sum.

```
Sₙ = (1 − η^(k + 1))/(1 − η) − (k + 1) · η^(k + 1)
```

Here, Sₙ is again the weighted history, k is the last included index, and η is the fixed decay. The caret indicates exponentiation, and the centered dot indicates multiplication. The fraction contains the finite geometric contribution, while the subtracted expression accounts for ending the history at k.

The limit sends the end of the history outward. Under a fixed decay below 1 in the range considered by the update rule, the exponentially decaying power shrinks fast enough that multiplying it by the age still leaves a term that tends to zero.

```
lim(k → ∞) [−(k + 1) · η^(k + 1)] = 0
```

The notation lim(k → ∞) considers the expression as the last index k goes to infinity. The quantity η is the decay, the caret forms the power, and the dot multiplies that power by the age factor. The value 0 is the limiting contribution of the finite-history correction.

The numerator of the remaining fraction approaches 1 because it subtracts a power of the same fixed decay that tends to zero. The denominator is independent of how many terms are included.

```
lim(k → ∞) [(1 − η^(k + 1))/(1 − η)] = 1/(1 − η)
```

Here, lim(k → ∞) again takes the limit as the last index k grows without bound. The parameter η stays fixed, and the fraction on the right retains the denominator of the finite geometric sum. That result gives the scale of the moving-average history.

```
lim(k → ∞) Sₙ = 1/(1 − η)
```

Here, Sₙ is the weighted sum of ages as the included history extends to the last index k. The decay η sets how heavily the older ages count. The limit supplies the first term of maximum traceable distance. The separate queue term then extends the measure from the current target state to the oldest retained set of keys.

### Experiments and results

#### What the similarity benchmarks measure

The main evaluation uses seven tasks. The annual collections are reported as STS12, STS13, and STS14, followed by STS15 and STS16. Their common purpose is to compare the similarity scores produced from sentence representations with human assessments of the sentence pairs. The paper also evaluates on STSBenchmark, abbreviated STS-B in the results, and on SICK-Relatedness, abbreviated SICK-R. The score reported for each task is a Spearman correlation. [Evaluation and benchmarks](https://md.research.elamur.ai/free/en/topics/evaluation-benchmarks/)

Spearman correlation asks whether the scored pairs appear in an order similar to the order given by human judgments. A pair that humans judge more similar should tend to receive a higher similarity score than a pair they judge less similar. This measures the use of the representation for ranking pairs. A high correlation is about the agreement of these orderings and leaves open how well the numerical similarities themselves match any particular human scoring scale.

The benchmark names also identify experiments with separate evaluation collections. The early annual results include [STS12](https://md.research.elamur.ai/free/en/papers/agirre-2012-semeval-2012-task-6-pilot/), [STS13](https://md.research.elamur.ai/free/en/papers/agirre-2013-sem-2013-shared-task-semantic/), and [STS14](https://md.research.elamur.ai/free/en/papers/agirre-2014-semeval-2014-task-10-multilingual/). The succeeding annual results are those for [STS15](https://md.research.elamur.ai/free/en/papers/agirre-2015-semeval-2015-task-2-semantic/) and [STS16](https://md.research.elamur.ai/free/en/papers/agirre-2016-semeval-2016-task-1-semantic/). The paper reports a separate correlation for [STSBenchmark](https://md.research.elamur.ai/free/en/papers/cer-2017-semeval-2017-task-1-semantic/) alongside these annual collections and SICK-R, then summarizes the group with an average.

#### Comparisons with the base encoders

The base-scale comparison includes older ways of constructing sentence vectors along with more recent unsupervised training methods. Averaged [GloVe](https://md.research.elamur.ai/free/en/concepts/glove/) vectors provide a word-embedding baseline. The authors also include first-and-last-layer averages from BERT and RoBERTa. Two other rows, BERT-flow and BERT-whitening, show the results of methods that change the geometry of BERT’s representations. RoBERTa-whitening is included separately, allowing the table to show results for that intervention with a different pretrained encoder.

The table also includes systems trained to produce more useful representations. IS-BERT represents the mutual-information approach in the comparison. CT-BERT, DeCLUTR-RoBERT, and SimCSE provide further points of reference. Their averages span a range, with SimCSE the nearest base-scale baseline to MoCoSE. The comparison places the queue-based system alongside established alternatives, though it is the paper’s internal ablations that hold more of the architecture and training procedure fixed. [IS-BERT](https://md.research.elamur.ai/free/en/papers/zhang-2020-unsupervised-sentence-embedding-method-mutual/) · [DeCLUTR](https://md.research.elamur.ai/free/en/papers/giorgi-2021-declutr-deep-contrastive-learning-unsupervised/)

Base-scale methods on average Spearman correlation across the STS tasks MoCoSE has the highest average among the base-scale methods shown.

**The numbers**

| System or setting | Spearman correlation % |
| --- | --- |
| Averaged GloVe | 61.32 |
| BERT first and last layer average | 56.70 |
| BERT-flow | 66.55 |
| IS-BERT | 66.58 |
| DeCLUTR-RoBERT | 69.99 |
| CT-BERT | 72.05 |
| SimCSE | 76.25 |
| MoCoSE (this paper) | 77.27 |

The other base averages include 66.28 for BERT-whitening, 56.57 for the first-and-last-layer RoBERTa average, and 61.73 for RoBERTa-whitening. These results put several changes to the raw encoder outputs in perspective. Reshaping or training the representations can change the ranking performance considerably. The comparison nearest MoCoSE in the table is with SimCSE, which already uses a contrastive objective and creates positive views with dropout.

MoCoSE’s average advantage over SimCSE is spread unevenly over the tasks. On STS12, MoCoSE reports 71.48 and SimCSE 68.40. On STS15 the respective correlations are 83.45 and 80.91, while on STS-B they are 78.68 and 76.85. STS13 favors SimCSE, with 82.41 against MoCoSE’s 81.40. Thus the average summarizes results over different sentence-pair collections, some of which respond more favorably to the queue-based setup than others.

The remaining base-scale comparisons are close. For STS14 the reported correlations are 74.47 for MoCoSE and 74.38 for SimCSE. On STS16 they are 78.99 and 78.56, respectively, and on SICK-R they are 72.44 and 72.23. The detailed ordering is useful because a single average can conceal both a reversal on one benchmark and near ties on several others. The reported correlations are point estimates, so these close values are best read as the observed scores for the corresponding settings.

#### Comparisons with the large encoders

With BERT-large as the starting point, MoCoSE reports an average of 79.13. The comparison gives SimCSE-BERT 78.41 and SimCSE-RoBERTa 78.90. The BERT-to-BERT comparison keeps the choice of pretrained encoder family in view, while the RoBERTa row gives the strongest other large-scale average in the table. MoCoSE leads the average in both comparisons.

Large-scale methods on average Spearman correlation across the STS tasks MoCoSE has the highest average, with both SimCSE variants close behind.

**The numbers**

| System or setting | Spearman correlation % |
| --- | --- |
| SimCSE-BERT | 78.41 |
| SimCSE-RoBERTa | 78.90 |
| MoCoSE-BERT (this paper) | 79.13 |

At this scale, the gains relative to SimCSE-BERT are concentrated in the earlier annual collections and STS-B. On STS12, MoCoSE records 74.50 compared with 70.88. On STS13 it records 84.54 compared with 84.16, and on STS14 it records 77.32 compared with 76.43. The STS-B comparison is 80.53 against 79.26. SimCSE-RoBERTa records 81.98 on STS-B, which shows why the choice of baseline matters for a statement about leadership on a specific collection.

The larger MoCoSE setup has lower reported correlations than SimCSE-BERT on STS15, STS16, and SICK-R. On STS15 the entries are 84.11 and 84.50. On STS16 they are 79.67 and 79.76, while on SICK-R they are 73.26 and 73.88. The result for the large configuration is therefore consistent with the broad base-scale finding about the average, while individual benchmark outcomes change with the encoder.

#### Transfer beyond the similarity ranking

The authors also evaluate the representations through SentEval on seven transfer tasks. The paper labels them MR, CR, SUBJ, and MPQA, with SST, TREC, and MRPC making up the rest. This part of the evaluation asks how well the learned sentence vectors support other tasks, with task scores reported separately from the Spearman correlations for similarity. The distinction matters because ranking sentences by relatedness and supplying features for a downstream decision put different demands on the representation.

In the base comparison, the transfer average for MoCoSE-BERT is 85.46, while SimCSE-BERT records 85.81. SimCSE-RoBERTa records 84.84, and the average BERT embedding baseline records 84.94. There are also earlier baselines built from averaged word vectors, Skip-thought, and BERT’s `[CLS]` output. The paper characterizes MoCoSE as comparable to the base SimCSE system on transfer, a more limited finding than its lead on the average similarity score.

The base MoCoSE scores include 94.76 on SUBJ and 89.70 on MPQA, compared with 94.45 and 88.88 for SimCSE-BERT. On MRPC, MoCoSE reports 75.86 against 74.43. TREC goes the other way, with 84.06 for MoCoSE and 89.80 for SimCSE-BERT. The average includes gains as well as losses across tasks, so the near placement of the two averages does not imply that they behave identically on the individual evaluations.

The large transfer comparison pairs MoCoSE-BERT with SimCSE-RoBERTa. Their averages are 86.90 and 86.11, respectively. On TREC the respective scores are 84.92 and 92.00, while on MRPC they are 76.81 and 69.68. Those movements in opposite directions reinforce the distinction between a transfer average and the score a practitioner would see on a particular task. The paper’s claims about queue age draw on the similarity experiments, with the transfer results supplying a separate check on the scope of the learned representations.

### What the ablations show

#### The target update and the online predictor

The appendix looks directly at what happens when the branches are made symmetric. The authors remove the online predictor and set the target decay to 0. In this setup the target is copied from the online branch at the update, and the branch architectures match. The evaluation correlation is strongest at the beginning and moves toward 0 as training proceeds. The authors report seeing this behavior across several runs and call it collapse.

A second run restores the predictor while leaving the decay at 0. This still shows collapse and develops large oscillations late in training. In this particular setup, making the branches architecturally different was insufficient to maintain useful training when the target followed the online parameters immediately. Using the predictor together with a moving target gave the authors a working training procedure. The two tests specifically probe removal of the moving update and removal of both elements.

The authors also vary the fixed decay while holding the other hyper-parameters constant. A decay of 0.85 produces the best average in that comparison, 76.49. At 0.5 the average is 75.76, and at 0.8 it is 75.19. The higher settings in the sweep reach 76.05 at 0.9 and 76.08 at 0.95, with 75.12 at 0.99. In this controlled setting the best point lies inside the tested range. A faster target than at 0.99 helps, while the lowest tested decay also gives a weaker result than the peak.

The paper contrasts its fixed-decay finding with the use of values as large as 0.99 in the visual setting it discusses. The authors suggest that the pretrained text encoder changes enough during adaptation to benefit from a target that follows more quickly. That is an explanation for the observed sensitivity, based on the way a moving average works. The experiment measures performance under different decay settings. It does not directly measure the size of parameter changes in comparable image and text encoders.

#### Depth and dimension in the representation heads

The architecture tests vary the depth of the projection and prediction heads and train the alternatives under the same hyper-parameters. The strongest configuration in that comparison has a projection of 1 layer and a predictor of 2 layers, with a reported correlation of 76.89. Removing the projection lowers performance. The comparison supports keeping a projection before the online prediction and shows that greater depth alone did not systematically produce better correlations.

A separate set of runs varies the dimension to which the predictor maps the representation. With a dimension of 256, the average is 73.91. It rises to 76.07 at 512 and to 77.04 at 768. The reported averages at 1024 and 2048 are 77.02 and 77.03. The practical distinction in this sweep is between the weaker low-dimensional settings and a group of wider settings with almost the same result. The authors use a predictor dimension matching the encoder in their experiments.

The authors suggest that a small prediction space may discard semantic information if it is narrower than the intrinsic dimension of the representations. The scores establish sensitivity to the smaller mapping sizes under the tested settings. They leave the intrinsic dimension itself unmeasured. The appendix also discusses the need to keep the queue entries compatible with the chosen embedding dimension when changing the size of the vectors used in the comparison.

#### How much variation to put in the positive views

The augmentation study uses dropout alone as its reference condition. In the comparison of augmentation types, that setting scores 76.76 on the average similarity metric. Adding FGSM at 5e-9 gives 77.04. The gain is small on that scale, but FGSM is the only addition in that comparison that improves the reported average. This is the reason the authors combine it with dropout in the main setup.

The effects of other embedding-level changes vary considerably. Position shuffling yields 73.80. Token dropout at probability 0.1 yields 41.32. Feature dropout gives 76.33 at probability 0.01 and 71.62 at 0.1. The difference between the two feature settings indicates that the strength of a perturbation matters within an augmentation family. The authors suggest that dropping a complete token can remove information essential to the sentence’s meaning, making the assumption behind a positive pair harder to satisfy.

Textual changes also trail the dropout reference in the settings tested. Adding typos yields 22.32, contextual synonym replacement yields 28.70, and paraphrasing gives 60.45. Back translation through German yields 69.35. These comparisons use the specified augmentation implementations and their settings. They show that an operation intended to preserve broad meaning can still give these training branches a less useful positive pairing than dropout. They also show that the results differ substantially even among methods that all modify the surface text.

The appendix varies the strength of FGSM in another fixed-hyperparameter experiment. The setting without FGSM scores 76.26. The reported averages are 75.61 for 1e-9, 76.64 for 5e-9, 75.39 for 1e-8, and 76.62 for 5e-8. This sweep has a different dropout-only reference from the augmentation comparison. It supports the choice of 5e-9 in that setup and shows a nearby outcome for another tested magnitude. The results make the adopted perturbation a setting selected by the experiments, with its benefit depending on how it is applied.

#### Batch size, capacity, and initial entries

At fixed queue capacity, the batch-size comparison gives its best average at 64, where it reports 77.25. The batch size of 32 gives 73.86. The settings at 128 and 256 yield 76.78 and 76.62, respectively. Larger batches in this comparison continue to refresh the queue faster, but performance falls from the result at 64. This motivates looking at turnover in update steps, since an increase in batch size changes how long the stored vectors stay available.

The overall capacity experiment varies the number of random vectors used to start the queue as well as how many vectors it can hold when full. The best entry in this grid is 77.30 for capacity 512 with 128 initial entries. At the same capacity, the reported average is 75.38 without initialization, and it is 76.29 when the whole queue is initialized at the start. These comparisons show that two runs with the same eventual capacity can have different outcomes depending on their initial contents.

There is a more substantial deterioration at capacity 4096. The reported average without initialization is 50.17, while filling the whole queue at initialization yields 45.80. The comparison therefore shows poor results with a very long queue under more than one startup condition. The authors initially suspected that a large body of random entries could interfere with learning. Partial initialization addresses that concern, and the remaining difficulties with long queues motivate looking at the age of the keys gathered during training as well.

A capacity comparison changes both the number of terms in InfoNCE and the time represented in those terms. A startup comparison keeps the eventual capacity fixed and changes the entries used early on. The batch-size sweep changes the rate of replacement and the amount of data processed at each step. Reading the three comparisons together makes clear why the paper goes on to control the number of negatives more directly by selecting slices from the same queue.

#### Which entries help within a single queue

The slice experiment uses a queue of length 1024, an initial size of 128, and a batch size of 256. Each iteration adds 256 keys. The authors compare a slice at one end, a middle slice, and a slice at the other end. They also concatenate the outer portions to form a comparison that excludes the middle. The full queue supplies a reference that uses more entries.

Queue slices on average STS Spearman correlation The middle slice leads the other selections and also scores above the full queue.

**The numbers**

| System or setting | Spearman correlation % |
| --- | --- |
| Queue positions 0–512 | 76.10 |
| Queue positions 256–768 (this paper) | 77.02 |
| Queue positions 512–1024 | 75.71 |
| Outer portions without positions 256–768 | 76.18 |
| Full queue | 76.86 |

The slices offer a different comparison from changing total capacity. Each contiguous selection covers the same length, so the three contiguous runs expose the query to the same number of alternative vectors. Their positions shift which ages are included. The middle selection scores best, while the selection combining the outer portions also trails it. The evidence favors including examples from the middle of this queue under the specified batch and initialization conditions.

The full queue contains the middle entries and still scores below the middle-only setting. Conversely, using the full queue scores above either end slice. These observations show why both inclusion and the surrounding alternatives matter. In InfoNCE, extra negatives enter the same denominator. Adding entries around an effective slice changes which competitors shape the loss and how much they contribute. The table shows the outcome of those combined changes, without identifying the contribution of each individual negative.

#### Bringing the two sources of history together

The traceable-distance experiments vary the target decay, queue size, and batch size to span different values of maximum traceable distance. For BERT-base, the paper places the strongest result around 14.67. The best region appears at a finite distance in the plotted results. The batch comparisons also suggest that choosing an appropriate distance continues to matter when batch size changes. Increasing the batch while holding capacity fixed can move the distance away from the favorable region because it shortens the period covered by the queue.

The BERT-large experiments show a similar pattern with a peak around 22. The two sweeps support the same qualitative conclusion about the value of an intermediate amount of history in their respective settings. They give different numerical locations for the best region. This is consistent with the purpose of the measure. It describes the interaction of several choices in the learning procedure and offers a scale on which to plot outcomes for a given encoder and training setup.

The distance analysis also helps interpret the slice comparison. An explanation based only on queue capacity would assign the same role to negatives anywhere in an equally sized slice. The differing scores point to something associated with which entries are selected. First-in, first-out order makes age a plausible factor. The tuning curves extend that evidence by changing the age scale through more than one control, including how strongly the target carries earlier online parameters.

#### What changes in the embedding space

The geometry analysis examines alignment and uniformity on STS-B. Alignment concerns whether related representations are close. Uniformity concerns whether the vectors occupy the space broadly enough to retain distinctions across examples. A configuration can affect both properties. Pulling matching views together is useful when the resulting space still offers enough separation for comparisons with other sentences.

The authors plot how the alignment and uniformity measurements move as maximum traceable distance changes. They describe the best-performing region in terms of a favorable combination of the two. Moving away from it changes their joint behavior. The analysis provides an account of what changes in the learned vectors as the queue and target history change, alongside the benchmark correlations that show how well readers’ similarity judgments are ranked.

The appendix approaches the geometry from another direction by comparing singular values of sentence embedding matrices from STS-B. Singular values summarize how strongly the variation in a matrix is concentrated across directions. A rapid decline indicates that much of the variation is represented in relatively few directions. The authors report a smoother decline for MoCoSE than in their comparisons with BERT and SimCSE. They interpret that shape as evidence of a more isotropic representation. Together, the singular-value plot and the alignment and uniformity analysis characterize how training changes the space used for the similarity comparison.

### Limitations

#### Qualifications the authors give

The authors present their best traceable distances as approximate locations within favorable regions. They report one region for BERT-base and another for BERT-large. Their conclusion is that an appropriate range exists in the tested setups. The numbers are attached to particular sweeps, with their own choices of batch size, queue capacity, and target decay. The distinction matters when using the result to understand a new experiment with a different starting encoder or training procedure.

Their explanations for the range are also qualified. They suggest that earlier sentence vectors can become stale as the encoder changes and that language encoders may need a faster-moving target during adaptation. They further propose that word-frequency effects and anisotropy help explain why their text results differ from the visual Momentum Contrast results they discuss. The geometry measurements describe changes within MoCoSE as its history settings vary. The authors give the proposed cross-domain explanation as an interpretation of those changes.

The augmentation findings are tied to the interventions the authors actually try. Dropping a token may alter meaning substantially, and a small gradient-based change can make the learning comparison harder while keeping the sentence fixed. These are the authors’ explanations for the observed augmentation scores. The outcome of paraphrasing, translation, or lexical replacement depends on how each transformation is implemented and on the sentence it is applied to. The reported results characterize those selected configurations.

#### Limits of the experimental setup

The unlabeled corpus is a sample of English Wikipedia, and the sentence encoders start from BERT checkpoints. The main similarity evidence comes from the tasks collected in the STS evaluation, and the geometry measurements come from STS-B. This provides several tests of sentence-pair ranking within a shared training setup. Generalization to other corpus types, languages, or encoder families would require evidence from those conditions. The transfer evaluation broadens the set of tasks, but the learned representations still come from the same training corpus and procedure.

The comparison with SimCSE evaluates complete systems that differ in several respects. MoCoSE introduces a queue, a moving target, an online predictor, and the additional FGSM perturbation. The main average measures the result of using them together. The internal ablations strengthen some more specific conclusions, such as the dependence on a moving target in the tested architecture or the effect of selecting queue slices. Taken on its own, the difference between the main MoCoSE and SimCSE scores cannot isolate the effect of the queue.

The collapse evidence comes from the two zero-decay configurations and the behavior of the adopted asymmetric moving-target setup. The symmetric test changes both the architecture and the update. The predictor-only test restores one of these elements. A full factorial comparison would also help quantify how much the predictor contributes to stability with a moving target held in place. The head-depth ablations show that the choice of heads affects the final score, while the zero-decay runs chiefly describe the consequences of making the target follow the online branch immediately.

Queue slices separate position from the number of negatives more effectively than changing capacity does. Even so, positional selection determines which batches and sentences supply the comparisons. The paper observes the scores for those selections. It does not identify the degree of semantic overlap between the selected negatives and their queries, or independently hold that overlap fixed while moving stored vectors across ages. The evidence supports age as a factor in this queue without quantifying its contribution separately from the composition of the slices.

Maximum traceable distance combines a weighted look into parameter history with a turnover estimate for the oldest entries. The appendix derives the moving-average term for fixed decay and an indefinitely extended history. During a finite training run, the target begins from an initialization, the decay can follow a schedule, and the queue takes time to fill. Traceable distance is therefore a summary of the settings and their steady behavior. It does not give the exact age or representational drift of each key at each update.

The measure also leaves out the size and direction of the parameter changes between updates. Two settings may have the same distance even if a step moves their representations by different amounts. A long historical reach can matter more when the encoder is changing rapidly than when it is already relatively stable. The paper gives empirical evidence that the combined measure tracks outcomes in these sweeps. It does not establish that matching distances is sufficient to make different training recipes behave alike.

The correlations, transfer scores, and ablation averages are reported as point estimates. The paper reports having observed collapse in several runs and discusses instability in parts of the queue-length study. The main tables do not provide ranges of scores across independent repetitions. This limits comparisons between close entries in particular. The reported lead on an average or the highest point in a sweep identifies an observed ordering under those settings, with the variability of that ordering left open.

Finally, Spearman correlation evaluates the ordering of scored sentence pairs. The transfer results add evidence from downstream tasks, and the geometry analysis characterizes the arrangement of the learned vectors. None of these measurements directly tests whether the encoder has retained every aspect of meaning that can be important for a given pair of sentences. The paper’s strongest claims concern usable rankings on the reported benchmarks and how those rankings respond when the negatives come from different amounts of training history.

### What came after

[Facilitating Contrastive Learning of Discourse Relational Senses](https://md.research.elamur.ai/free/en/papers/long-2022-facilitating-contrastive-learning-discourse-relational/) cites MoCoSE in work that uses a hierarchy of discourse relations to facilitate contrastive learning. The subject is how to organize comparisons for the senses of relations in [discourse analysis](https://md.research.elamur.ai/free/en/concepts/discourse-analysis/). This puts another property of the comparisons in view. Where Cao and colleagues vary when a comparison vector was produced, the discourse work is concerned with structure among the senses being learned.

[A Benchmark Study of Contrastive Learning for Arabic Social Meaning](https://md.research.elamur.ai/free/en/papers/khondaker-2022-benchmark-study-contrastive-learning-arabic/) cites MoCoSE in an evaluation setting centered on Arabic and social meaning. Its stated focus extends the discussion of contrastive learning into a different language and evaluation problem from the English sentence similarity experiments. The citation connects the studies, while the title establishes the scope of the later benchmark.

The documented connection in each case is the citation and the later paper’s stated research focus. That evidence leaves open whether either study used MoCoSE’s queue, its moving-average target, or maximum traceable distance as part of its own method.

## Cite

Cite as Rui Cao, Yihao Wang, Yuxin Liang, Ling Gao, Jie Zheng, Jie Ren and Zheng Wang. 2022. Exploring the Impact of Negative Samples of Contrastive Learning: A Case Study of Sentence Embedding. Findings of the Association for Computational Linguistics: ACL 2022.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.18653/v1/2022.findings-acl.248](https://doi.org/10.18653/v1/2022.findings-acl.248)

```bibtex
@inproceedings{cao2022exploring,
  title = {{Exploring the Impact of Negative Samples of Contrastive Learning: A Case Study of Sentence Embedding}},
  author = {Rui Cao, Yihao Wang, Yuxin Liang, Ling Gao, Jie Zheng, Jie Ren and Zheng Wang},
  booktitle = {Findings of the Association for Computational Linguistics: ACL 2022},
  year = {2022},
  doi = {10.18653/v1/2022.findings-acl.248},
  url = {https://doi.org/10.18653/v1/2022.findings-acl.248}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
