Original: Batch-Softmax Contrastive Loss for Pairwise Sentence Scoring Tasks
Revised: Batch-Softmax Contrastive Loss for Pairwise Sentence Scoring Tasks

Original: Anonymous ACL submission

Original: Abstract
Revised: Abstract

Original: The use of contrastive loss for representationlearning has become prominent in computervision, and it is now getting attention in Natural Language Processing (NLP).
Revised: The use of contrastive loss for representation learning has become prominent in computer vision, and it is now getting attention in Natural Language Processing (NLP).

Original: Here, we explore the idea of using a batch-softmax contrastive loss when fine-tuning large-scale pretrained transformer models to learn better taskspecific sentence embeddings for pairwise sentence scoring tasks.
Revised: Here, we explore the idea of using a batch-softmax contrastive loss when fine-tuning large-scale pretrained transformer models to learn better taskspecific sentence embeddings for pairwise sentence scoring tasks.

Original: We introduce and study anumber of variations in the calculation of theloss as well as in the overall training procedure; in particular, we find that a special datashuffling can be quite important.
Revised: We introduce and study a number of variations in the calculation of the loss as well as in the overall training procedure; in particular, we find that a special data shuffling can be quite important.

Original: Our experimental results show sizable improvements on anumber of datasets and pairwise sentence scoring tasks including classification, ranking, andregression.
Revised: Our experimental results show sizable improvements on a number of datasets and pairwise sentence scoring tasks including classification, ranking, and regression.

Original: Finally, we offer detailed analysis and discussion, which should be useful forresearchers aiming to explore the utility of contrastive loss in NLP.
Revised: Finally, we offer detailed analysis and discussion, which should be useful for researchers aiming to explore the utility of contrastive loss in NLP.

Original:  Introduction
Revised:  Introduction

Original: Recent years have seen a revolution in Natural Language Processing (NLP) thanks to the advances inmachine learning.
Revised: Recent years have seen a revolution in Natural Language Processing (NLP) thanks to the advances in machine learning.

Original: A lot of attention has been paidto architectures, especially for deep learning, aswell as to loss functions.
Revised: A lot of attention has been paid to architectures, especially for deep learning, as well as to loss functions.

Original: Notably, loss functionsbased on similar ideas were proposed in unrelatedpapers in different machine learning fields underdifferent names.
Revised: Notably, loss functions based on similar ideas were proposed in unrelated papers in different machine learning fields under different names.

Original: This can cause difficulties whensolving new problems or when designing new experiments based on previous results.
Revised: This can cause difficulties when solving new problems or when designing new experiments based on previous results.

Original: To a greaterextent, this applies to “universal” loss functions,which can be applied in different machine learningareas and tasks such as Computer Vision (CV), Recommendation Systems, and NLP.
Revised: To a greater extent, this applies to “universal” loss functions, which can be applied in different machine learning areas and tasks such as Computer Vision (CV), Recommendation Systems, and NLP.

Original: An example ofsuch loss function is the batch-softmax contrastive(BSC) loss, which we will discuss below.
Revised: An example of such loss function is the batch-softmax contrastive (BSC) loss, which we will discuss below.

Original: For many NLP tasks, it is important to obtainrepresentations of sentences for semantic matching problems, since they can be used for furtheranalysis, e.g., for finding the best answer to a question.
Revised: For many NLP tasks, it is important to obtain representations of sentences for semantic matching problems, since they can be used for further analysis, e.g., for finding the best answer to a question.

Original: Sentence BERT is a recent popular approach for this (Reimers and Gurevych, 2019): it can be trained with different loss functions, and we show that the choice of a loss function is important.
Revised: Sentence BERT is a recent popular approach for this (Reimers and Gurevych, 2019): it can be trained with different loss functions, and we show that the choice of a loss function is important.

Original: Moreover, we show that it will not be optimal to take the “standard” batch-softmax contrastive loss, which is used for training SimCSE (Gao et al., 2021), a recent alternative to Sentence BERT, and we suggest ways to improve its efficiency.
Revised: Moreover, we show that it will not be optimal to take the “standard” batch-softmax contrastive loss, which is used for training SimCSE (Gao et al., 2021), a recent alternative to Sentence BERT, and we suggest ways to improve its efficiency.

Original: Our contributions can be summarized as follows:
Revised: Our contributions can be summarized as follows:

Original: • We study the use of a batch-softmax con- trastive loss for fine-tuning large-scale trans- formers to learn better task-specific embed- dings for pairwise sentence scoring tasks.
Revised: • We study the use of a batch-softmax contrastive loss for fine-tuning large-scale transformers to learn better task-specific embeddings for pairwise sentence scoring tasks.

Original: • We introduce and study a number of novel

Original: variations in the calculation of the loss

Original: such

Original:  as symmetrization, incorporating labeled neg- atives, aligning scores on the similarity ma- trix diagonal, normalizing over the batch axis, as well as in the overall training procedure, 
Revised: • We introduce and study a number of novel variations in the calculation of the loss such as symmetrization, incorporating labeled negatives, aligning scores on the similarity matrix diagonal, normalizing over the batch axis, as well as in the overall training procedure, e

Original: e g., shuffling, trainable temperature, and se- quential pre -training.
Revised: g., shuffling, trainable temperature, and sequential pre-training.

Original: • We demonstrate sizable improvements for a number of pairwise sentence scoring tasks such as classification, ranking, and regression.
Revised: • We demonstrate sizable improvements for a number of pairwise sentence scoring tasks such as classification, ranking, and regression.

Original: • We offer detailed analysis and discussion, which would be useful for future research.
Revised: • We offer detailed analysis and discussion, which would be useful for future research.

Original: • We release our code at http: //anonymous
Revised: • We release our code at https://github. com/aschern/BSC-loss

Original:  Related Work
Revised:  Related Work

Original: The contrastive loss was proposed by Hadsell et al.
Revised: The contrastive loss was proposed by Hadsell et al.

Original: (2006) as metric learning that contrasts Euclidean distances between embeddings of samples from one class and between samples from different classes.
Revised: (2006) as metric learning that contrasts Euclidean distances between embeddings of samples from one class and between samples from different classes.

Original: Weinberger et al.
Revised: Weinberger et al.

Original: (2006) suggested the triplet loss, which is based on a similar idea, but uses triplets ( anchor , positive , negative ), and aims for the difference between the distances for ( anchor , positive ) and for ( anchor , negative ) to be larger than a margin.
Revised: (2006) suggested the triplet loss, which is based on a similar idea, but uses triplets ( anchor , positive , negative ), and aims for the difference between the distances for ( anchor , positive ) and for ( anchor , negative ) to be larger than a margin.

Original: N -pair loss was presented asa generalization of the contrastive and the tripletlosses as a way to solve the problem of extensive construction of hard negative pairs and triplets(Sohn, 2016).
Revised: N -pair loss was presented as a generalization of the contrastive and the triplet losses as a way to solve the problem of extensive construction of hard negative pairs and triplets (Sohn, 2016).

Original: To this end, a batch of N pairs ofexamples from N different classes is sampled, andthe first element in each pair is considered to be ananchor .
Revised: To this end, a batch of N pairs of examples from N different classes is sampled, and the first element in each pair is considered to be an anchor .

Original: Thus, for each anchor , there are one positive and N ´ 1 negative pairs.
Revised: Thus, for each anchor , there are one positive and N ´ 1 negative pairs.

Original: The loss contrasts thedistances simultaneously using the softmax function over dot-product similarities.
Revised: The loss contrasts the distances simultaneously using the softmax function over dot-product similarities.

Original: The approachwas used successfully in CV tasks.
Revised: The approach was used successfully in CV tasks.

Original: The same method of Multiple Negative Ranking for training Dot-Product Scoring Models wasapplied to ranking natural language responses toemails (Henderson et al., 2017), where the lossuses labeled pairs.
Revised: The same method of Multiple Negative Ranking for training Dot-Product Scoring Models was applied to ranking natural language responses to emails (Henderson et al., 2017), where the loss uses labeled pairs.

Original: A similar idea, called Negative
Revised: A similar idea, called Negative

Original: Sharing , was used to reduce the computational costwhen training recommender systems (Chen et al.,2017).
Revised: Sharing , was used to reduce the computational cost when training recommender systems (Chen et al., 2017).

Original: Wu et al.
Revised: Wu et al.

Original: (2018) presented an approachwith N -pairs like logic, as a Non-Parametric Softmax Classifier, replacing the weights in the softmaxwith embeddings of samples from such classes.
Revised: (2018) presented an approach with N -pairs like logic, as a Non-Parametric Softmax Classifier, replacing the weights in the softmax with embeddings of samples from such classes.

Original: Itwas also proposed to use L2 normalization and temperature.
Revised: It was also proposed to use L2 normalization and temperature.

Original: Yang et al.
Revised: Yang et al.

Original: (2018) proposed to use Multiple Negative Ranking to train general sentencerepresentations on data from Reddit and SNLI.
Revised: (2018) proposed to use Multiple Negative Ranking to train general sentence representations on data from Reddit and SNLI.

Original: Logeswaran and Lee (2018) presented a QuickThoughts approach to learn sentence embeddings,which constructs batches of contiguous sets of sentences, and for each sentence, contrasts the nextsentence in the text and all other candidates.
Revised: Logeswaran and Lee (2018) presented a QuickThoughts approach to learn sentence embeddings, which constructs batches of contiguous sets of sentences, and for each sentence, contrasts the next sentence in the text and all other candidates.

Original: A lot of subsequent work has focused on maximizing Mutual Information (MI).
Revised: A lot of subsequent work has focused on maximizing Mutual Information (MI).

Original: Oord et al.(2018) presented a loss function based on NoiseContrastive Estimation, called InfoNCE.
Revised: Oord et al. (2018) presented a loss function based on NoiseContrastive Estimation, called InfoNCE.

Original: It modelsthe “similarity” function that estimates the MI between the target (future) and the context (present)signals, and maximizes the MI between temporallynearby signals.
Revised: It models the “similarity” function that estimates the MI between the target (future) and the context (present) signals, and maximizes the MI between temporally nearby signals.

Original: If this “similarity” function expresses the dot-product between embeddings, the
Revised: If this “similarity” function expresses the dot-product between embeddings, the

Original: InfoNCE loss is equivalent to the N -pair loss up tosome constants.
Revised: InfoNCE loss is equivalent to the N -pair loss up to some constants.

Original: It was also shown that InfoNCE isequivalent to the Mutual Information Neural Estimator (MINE) up to a constant (Belghazi et al.,2018), whose minimization maximizes a lowerbound on MI.
Revised: It was also shown that InfoNCE is equivalent to the Mutual Information Neural Estimator (MINE) up to a constant (Belghazi et al., 2018), whose minimization maximizes a lower bound on MI.

Original: Deep InfoMax (DIM) (Hjelm et al. ,2019) improves MINE, and can be modified to incorporate some autoregression as InfoNCE.
Revised: Deep InfoMax (DIM) (Hjelm et al., 2019) improves MINE, and can be modified to incorporate some autoregression as InfoNCE.

Original: However, Tschannen et al.
Revised: However, Tschannen et al.

Original: (2020) pointed out that theeffectiveness of loss functions such as DIM and
Revised: (2020) pointed out that the effectiveness of loss functions such as DIM and

Original: InfoNCE might be primarily connected not to deep metric learning but rather to MI.
Revised: InfoNCE might be primarily connected not to deep metric learning but rather to MI.

Original: The idea gained a lot of popularity in Computer
Revised: The idea gained a lot of popularity in Computer

Original: Vision with the advent of SimCLR (a Simple framework for Contrastive Learning of visual Representations), which introduced NT-Xent (normalized temperature-scaled cross-entropy loss) (Chen et al., 2020).
Revised: Vision with the advent of SimCLR (a Simple framework for Contrastive Learning of visual Representations), which introduced NT-Xent (normalized temperature-scaled cross-entropy loss) (Chen et al., 2020).

Original: It uses self-supervised learning, where augmentations of the same image are used as positive examples and augmentations of different images are used as negative examples.
Revised: It uses self-supervised learning, where augmentations of the same image are used as positive examples and augmentations of different images are used as negative examples.

Original: Thus, the task is as follows: for each example in a batch, find its paired positive augmentation.
Revised: Thus, the task is as follows: for each example in a batch, find its paired positive augmentation.

Original: Here, the N -pairs loss is modified with a temperature parameter and with an
Revised: Here, the N -pairs loss is modified with a temperature parameter and with an

Original: L2 normalization of embeddings to the unit hypersphere.
Revised: L2 normalization of embeddings to the unit hypersphere.

Original: The loss was further extended for supervised learning as SupCon loss (Khosla et al., 2020), which aggregates all positive examples (from the same class) in the softmax numerator.
Revised: The loss was further extended for supervised learning as SupCon loss (Khosla et al., 2020), which aggregates all positive examples (from the same class) in the softmax numerator.

Original: Subsequently, these losses were introduced to the field of Natural Language Processing (NLP).
Revised: Subsequently, these losses were introduced to the field of Natural Language Processing (NLP).

Original: Gunel et al.
Revised: Gunel et al.

Original: combined the SupCon loss with the cross-entropy loss and obtained state-of-theart results for several downstream NLP tasks using RoBERTa.
Revised: combined the SupCon loss with the cross-entropy loss and obtained state-of-theart results for several downstream NLP tasks using RoBERTa.

Original: Giorgi et al.
Revised: Giorgi et al.

Original: (2020), Fang and Xie (2020) and Meng et al.
Revised: (2021), Fang and Xie (2020) and Meng et al.

Original: (2021) used NT-Xent to pre-train Transformers, considering spans sampled from the same document, sentences augmented with back-translation as positive examples, and sequences corrupted with MLM.
Revised: (2021) used NT-Xent to pre-train Transformers, considering spans sampled from the same document, sentences augmented with back-translation as positive examples, and sequences corrupted with MLM.

Original: Luo et al.
Revised: Luo et al.

Original: (2020) proposed to use NT-Xent in a self-supervised setting to learn noise-invariant sequence representations, where sentences augmented with masking were considered as positive examples.
Revised: (2020) proposed to use NT-Xent in a self-supervised setting to learn noise-invariant sequence representations, where sentences augmented with masking were considered as positive examples.

Original: Finally,
Revised: Finally,

Original: Gao et al.
Revised: Gao et al.

Original: (2021) introduced the SimCLR loss to
Revised: (2021) introduced the SimCLR loss to

Original: NLP under the name SimCSE
Revised: NLP under the name SimCSE

Original: (Simple Contrastive
Revised: (Simple Contrastive

Original: Learning of Sentence Embeddings), where sentences processed by a neural network with dropout served as augmentations of the original sentences.
Revised: Learning of Sentence Embeddings), where sentences processed by a neural network with dropout served as augmentations of the original sentences.

Original: Here, we explore various ways to use a similar loss function for pairwise sentence scoring tasks.
Revised: Here, we explore various ways to use a similar loss function for pairwise sentence scoring tasks.

Original: While the above-described loss functions have different names, they are all based on similar ideas.
Revised: While the above-described loss functions have different names, they are all based on similar ideas.

Original: Below, we will use the name Batch-Softmax Contrastive (BSC) loss, which we believe reflects the main idea best.
Revised: Below, we will use the name Batch-Softmax Contrastive (BSC) loss, which we believe reflects the main idea best.

Original: In our experiments below, we will use the “modern” variant of the loss: with temperature, normalization, and symmetrization components (described in more detail in Section 3.1).
Revised: In our experiments below, we will use the “modern” variant of the loss: with temperature, normalization, and symmetrization components (described in more detail in Section 3.1).

Original: These components were not used for NLP in combination before.
Revised: These components were not used for NLP in combination before.

Original: We further introduce a number of
Revised: We further introduce a number of

Original: Softmax aaaa n qqq m qaaaa n aaaa n aaaa m qqq m qaa m aa
Revised: Softmax aaaa n qqq m qaaaa n aaaa n aaaa m qqq m qaa m aa

Original: T novel and important modifications in the definitionof the loss and in the training procedure, whichmake it more efficient, and we show that using theresulting loss yields better task-specific sentenceembeddings for pairwise sentence scoring tasks.
Revised: T novel and important modifications in the definition of the loss and in the training procedure, which make it more efficient, and we show that using the resulting loss yields better task-specific sentence embeddings for pairwise sentence scoring tasks.

Original:  Method 
Revised:  Method 3. Batch-Softmax Contrastive (BSC) Loss

Original: 3. Batch-Softmax Contrastive (BSC) Loss

Original: Pointwise approaches for training models for pairwise sentence scoring tasks, such as mean squarederror (MSE), are problematic as the loss does nottake the relative order into account.
Revised: Pointwise approaches for training models for pairwise sentence scoring tasks, such as mean squared error (MSE), are problematic as the loss does not take the relative order into account.

Original: For instance,for two pairs with correct target scores (0.4, 0.5),the loss function would equally penalize answerslike (0.3, 0.6) and (0.5, 0.4).
Revised: For instance, for two pairs with correct target scores (0.4, 0.5), the loss function would equally penalize answers like (0.3, 0.6) and (0.5, 0.4).

Original: However, the first pairis better, as it keeps the correct ranking, while thesecond one does not.
Revised: However, the first pair is better, as it keeps the correct ranking, while the second one does not.

Original: This is addressed in pairwiseapproaches, e.g., in triplet loss, where the modeldirectly learns an ordering.
Revised: This is addressed in pairwise approaches, e.g., in triplet loss, where the model directly learns an ordering.

Original: Yet, there is a problemfor constructing pairs or triplets in the training set,as it is hard to find non-trivial negatives examples.
Revised: Yet, there is a problem for constructing pairs or triplets in the training set, as it is hard to find non-trivial negatives examples.

Original: Unlike traditional pairwise loss functions, the
Revised: Unlike traditional pairwise loss functions, the

Original: BSC loss treats all other possible pairs of examplesin the batch as “negatives.”
Revised: BSC loss treats all other possible pairs of examples in the batch as “negatives.”

Original: That is, only positivepairs are needed for training.
Revised: That is, only positive pairs are needed for training.

Original: Consider a batch
Revised: Consider a batch

Original: X of pairs from a question-answering dataset.
Revised: X of pairs from a question-answering dataset.

Original: Ingeneral, let Q m ˆ n and A m ˆ n be the matrices ofembeddings produced by a query model and an answer model.
Revised: In general, let Q m ˆ n and A m ˆ n be the matrices of embeddings produced by a query model and an answer model.

Original: We define the loss function as follows:
Revised: We define the loss function as follows:

Original: [Equation]
Revised: [Equation]

Original: [Equation]

Original:  ´ mean ˆ
Revised: “ ´ mean ˆ

Original: [Equation]
Revised: [Equation]

Original: ˆ 
Revised: ˆ diag

Original: [Equation]
Revised: [Equation]

Original:  ˆ
Revised: ˙˙˙˙ ´ mean ˆ log ˆ diag ˆ softmax ˆ

Original: [Equation]
Revised: [Equation]

Original: ˆ
Revised: τ ˙˙˙˙ (

Original: [Equation]
Revised: [Equation]

Original: Here, softmax is applied by rows (Figure 1), andτ is the temperature.
Revised: Here, softmax is applied by rows (Figure 1), and τ is the temperature.

Original: Both components can be rewritten, e.g., L 

Revised: Both components can be rewritten, e.g., L

Original: p X q can be written as follows:
Revised: p X q can be written as follows:

Original: [Equation]
Revised: [Equation]

Original: ˆ
Revised: τ

Original: [Equation]

Original: Ti a j τ ˙

Original: [Equation]
Revised: [Equation]

Original: Mathematically, this loss function is similar to the one presented in (Chen et al., 2020).
Revised: Mathematically, this loss function is similar to the one presented in (Chen et al., 2020).

Original: The difference is that we do not use augmentations, and we do not compare q i to q j (or a i to a j ) due to their different nature: we want to compare a question to an answer, not a question to a question or an answer to an answer.
Revised: The difference is that we do not use augmentations, and we do not compare q i to q j (or a i to a j ) due to their different nature: we want to compare a question to an answer, not a question to a question or an answer to an answer.

Original: Thus, we apply the symmetrization in the formula.
Revised: Thus, we apply the symmetrization in the formula.

Original: So, the difference from SimCSE (Gao et al., 2021) is that we compare not only q i to all a j , but also a i to all q j in the batch.
Revised: So, the difference from SimCSE (Gao et al., 2021) is that we compare not only q i to all a j , but also a i to all q j in the batch.

Original: Note that, although a frequent short answer may fit multiple questions in a batch, such pairs are considered as “negative” examples in the loss.
Revised: Note that, although a frequent short answer may fit multiple questions in a batch, such pairs are considered as “negative” examples in the loss.

Original: However, the loss learns Mutual Information (Tschannen et al., 2020), that is p p q i , a i q{p p
Revised: However, the loss learns Mutual Information (Tschannen et al., 2020), that is p p q i , a i q{p p

Original: p q i q p p a i qq , and thus it is robust to this false negatives problem.
Revised: p q i q p p a i qq , and thus it is robust to this false negatives problem.

Original: Early research has already shown the importance of properly configuring and using some BSC loss settings.
Revised: Early research has already shown the importance of properly configuring and using some BSC loss settings.

Original: For example, low temperatures are equivalent to optimizing for hard positives/negatives (Khosla et al., 2020), while L2 normalization of vectors to the unit hypersphere along with temperature effectively weighs different examples (Chen et al., 2020).
Revised: For example, low temperatures are equivalent to optimizing for hard positives/negatives (Khosla et al., 2020), while L2 normalization of vectors to the unit hypersphere along with temperature effectively weighs different examples (Chen et al., 2020).

Original: We further propose a number of important modifications that can have a major impact on the performance for a number of tasks.
Revised: We further propose a number of important modifications that can have a major impact on the performance for a number of tasks.

Original: 3. Batch Construction
Revised: 3. Batch Construction

Original: In computer vision, it is common to use a batch size of 5,000, which in turn would naturally be very likely to contain some hard negative examples.
Revised: In computer vision, it is common to use a batch size of 5,000, which in turn would naturally be very likely to contain some hard negative examples.

Original: In
Revised: In

Original: NLP, fine-tuning Transformer-based models with large batch sizes requires very large amounts of memory.
Revised: NLP, fine-tuning Transformer-based models with large batch sizes requires very large amounts of memory.

Original: Thus, much smaller batches are used in practice, and as a result, it becomes important to make sure these batches do contain some hard negative examples.
Revised: Thus, much smaller batches are used in practice, and as a result, it becomes important to make sure these batches do contain some hard negative examples.

Original: We achieve this by fixing the content of the batches at each epoch of the training process.
Revised: We achieve this by fixing the content of the batches at each epoch of the training process.

Original: Note that this is much simpler than mining hard negatives, as we only need to increase the likelihood that there would be a hard negative example present in the batch, but we do not need to know which particular example in the batch would be hard.
Revised: Note that this is much simpler than mining hard negatives, as we only need to increase the likelihood that there would be a hard negative example present in the batch, but we do not need to know which particular example in the batch would be hard.

Original: Inside the batch, this would be controlled by the temperature parameter.
Revised: Inside the batch, this would be controlled by the temperature parameter.

Original: Example-based shuffling The key idea of thismethod is to batch several groups, so that withineach group all pairs are similar based on their firstor based on their second elements.
Revised: Example-based shuffling The key idea of this method is to batch several groups, so that within each group all pairs are similar based on their first or based on their second elements.

Original: In this way,each positive pair would be accompanied by hardnegatives from the same group and by simpler negatives from the remaining examples inside the batch(which come from other groups).
Revised: In this way, each positive pair would be accompanied by hard negatives from the same group and by simpler negatives from the remaining examples inside the batch (which come from other groups).

Original: We use the knearest neighbors for an input example to form agroup for it, and Faiss (Johnson et al., 2019) toquickly find these nearest neighbors in the embedding space.
Revised: We use the knearest neighbors for an input example to form a group for it, and Faiss (Johnson et al., 2019) to quickly find these nearest neighbors in the embedding space.

Original: Let the pairs be grouped by their firstelements
Revised: Let the pairs be grouped by their first elements

Original: q i .
Revised: q i .

Original: Algorithm 1 summarizes the proposedmethod.
Revised: Algorithm 1 summarizes the proposed method.

Original: Algorithm Input: sequence D , group size s initialize R Ð rs Ź sequence to store the result initialize U Ð ∅ Ź set of used examples randomly shuffle D for e in D do if e R U then find the n nearest neighbors of e from D choose the top s ´ 1 that are not in U add them and e to R and also to U return reversed R
Revised: Input: sequence D , group size s initialize R Ð rs Ź sequence to store the result initialize U Ð ∅ Ź set of used examples randomly shuffle D for e in D do if e R U then find the n nearest neighbors of e from D choose the top s ´ 1 that are not in U add them and e to R and also to U return reversed R

Original: Note that we use two stages in kNN to limit therange of possible candidates and thus to reducethe computational costs (both in terms of time andmemory).
Revised: Note that we use two stages in kNN to limit the range of possible candidates and thus to reduce the computational costs (both in terms of time and memory).

Original: We first extract the top- n neighbors (forsome large n , e.g., 500), and then we take the top- kfrom them, so that no duplicates appear in the finalsequence (for some small k “ 7 ).
Revised: We first extract the top- n neighbors (for some large n , e.g., 500), and then we take the top- k from them, so that no duplicates appear in the final sequence (for some small k “ 7 ).

Original: The time complexity of such a check is O(1).
Revised: The time complexity of such a check is O(1).

Original: If all such neighbors are already used, then only the considered example will be added to the resulting sequence.
Revised: If all such neighbors are already used, then only the considered example will be added to the resulting sequence.

Original: Thiscase will often arise for the last examples, and thusbatches will consist of simple 1-element groups.
Revised: This case will often arise for the last examples, and thus batches will consist of simple 1-element groups.

Original: Therefore, we reverse the sequence to start withthese simple batches, as in curriculum learning.
Revised: Therefore, we reverse the sequence to start with these simple batches, as in curriculum learning.

Original: By default, we assume that there should be onepositive example for each question/answer (on thediagonal of the matrix), and thus identical neighbors could be optionally filtered.
Revised: By default, we assume that there should be one positive example for each question/answer (on the diagonal of the matrix), and thus identical neighbors could be optionally filtered.

Original: Still, if thereare the same q i in the batch X , the loss definition(eq. 1) does not change.
Revised: Still, if there are the same q i in the batch X , the loss definition (eq. 1) does not change.

Original: Indeed, let P q “ t i |
Revised: Indeed, let P q “ t i |

Original: q i “q, p q i , a i q P X u , then @
Revised: q i “ q, p q i , a i q P X u , then @

Original: i, j P P q : p q i , a j q form apositive pair.
Revised: i, j P P q : p q i , a j q form a positive pair.

Original: According to Khosla et al.
Revised: According to Khosla et al.

Original: (2020),for each q , all ˜ q P P q should be placed in the softmax numerator and then averaging over all such ˜ qshould be performed outside the logarithm.
Revised: (2020), for each q , all ˜ q P P q should be placed in the softmax numerator and then averaging over all such ˜ q should be performed outside the logarithm.

Original: Thus,in L 0 p X q (eq. 2) only the first sum would change:304 ÿ i P P q q Ti a i ù ÿ i P P q | P q | ÿ j P P q q Ti a j “ ÿ j P P q | P q | ÿ i P P q q T a j “ ÿ j P P q q Tj a j (3)
Revised: Thus, in L 0 p X q (eq. 2) only the first sum would change: ÿ i P P q q Ti a i ù ÿ i P P q | P q | ÿ j P P q q Ti a j “ ÿ j P P q | P q | ÿ i P P q q T a j “ ÿ j P P q q Tj a j (3)

Original: In L 1 p X q :308 ÿ i P P q q Ti a i ù ÿ i P P q | P q | ÿ j P P q q Tj a i “ ÿ i P P q | P q | ÿ j P P q q T a i “ ÿ i P P
Revised: In L 1 p X q : ÿ i P P q q Ti a i ù ÿ i P P q | P q | ÿ j P P q q Tj a i “ ÿ i P P q | P q | ÿ j P P q q T a i “ ÿ i P P

Original: q q Ti a i (4)
Revised: q q Ti a i (4)

Original: To select the groups even better, we consider task-specific embeddings.
Revised: To select the groups even better, we consider task-specific embeddings.

Original: To this end, we apply the current model to encode all pairs at each epoch.
Revised: To this end, we apply the current model to encode all pairs at each epoch.

Original: Algorithm 
Revised: Algorithm 2 Shuffling by words

Original: Input: sequence D , group size k , shingle size t for e in D do e.shingle Ð random subset of t words of e (ignoring stop-words) sort D by e.shingle initialize gID Ð random uint Ź group ID initialize s ÐŹ current group size initialize prev Ð first element of D for e in D do if e.shingle ‰ prev.shingle then gID Ð random uint if s ě k then gID Ð random uint s Ðe.gID Ð gID s Ð s `prev Ð e sort D by e.gID return D
Revised: Input: sequence D , group size k , shingle size t for e in D do e.shingle Ð random subset of t words of e (ignoring stop-words) sort D by e.shingle initialize gID Ð random uint Ź group ID initialize s ÐŹ current group size initialize prev Ð first element of D for e in D do if e.shingle ‰ prev.shingle then gID Ð random uint if s ě k then gID Ð random uint s Ðe.gID Ð gID s Ð s `prev Ð e sort D by e.gID return D

Original: Fast shuffling For extremely large datasets, example-based shuffling is time-consuming even with Faiss; thus, we propose several effective options to perform a less-thorough shuffling.
Revised: Fast shuffling For extremely large datasets, example-based shuffling is time-consuming even with Faiss; thus, we propose several effective options to perform a less-thorough shuffling.

Original: We choose some attribute by which we will group the examples, that is, we guarantee some closeness of the examples.
Revised: We choose some attribute by which we will group the examples, that is, we guarantee some closeness of the examples.

Original: Thus, the examples are close if they share the same words, the same cluster number or the same nearest neighbors.
Revised: Thus, the examples are close if they share the same words, the same cluster number or the same nearest neighbors.

Original: First, consider the case of words and grouping by the first elements of the pairs (the case of the second elements is the same).
Revised: First, consider the case of words and grouping by the first elements of the pairs (the case of the second elements is the same).

Original: Algorithm 2 presents the shuffling process.
Revised: Algorithm 2 presents the shuffling process.

Revised: We choose a random word or phrase (shingle) in each element and sort the dataset by these shingles.

Revised: Since examples with the same shingles will be in sequence, we assign group

Revised: IDs sequentially.

Original:  To produce a shuffle by clusters, we apply the samealgorithm, where each sentence is replaced by itscluster number.
Revised: We split each group into several parts if its size is large. Then we shuffle (sort) the dataset by group IDs. The resulting algorithmic complexity is equal to the complexity of two sorts of the dataset. To produce a shuffle by clusters, we apply the same algorithm, where each sentence is replaced by its cluster number.

Original: Thus, each shingle has size t “ 1 .
Revised: Thus, each shingle has size t “ 1 .

Original: In order to make a shuffle by nearest neighbors, wecreate shingles by “sentences,” where the wordsare the positions of the top- k nearest neighborsin the input sequence (for some small k ).
Revised: In order to make a shuffle by nearest neighbors, we create shingles by “sentences,” where the words are the positions of the top- k nearest neighbors in the input sequence (for some small k ).

Original: All ofthese approaches, as well as k -means clustering,can be effectively implemented using MapReduceand parallel computations.
Revised: All of these approaches, as well as k -means clustering, can be effectively implemented using MapReduce and parallel computations.

Original: 3. Labeled Negatives
Revised: 3. Labeled Negatives

Original: Usually, when the data size is small, hard negative examples may be hard to obtain even withdata shuffling, e.g., when all examples are semantically distant.
Revised: Usually, when the data size is small, hard negative examples may be hard to obtain even with data shuffling, e.g., when all examples are semantically distant.

Original: Nonetheless, if the dataset containsa labeled negative pair with some anchor, then itselements are semantically close by traditional rulesof dataset construction.
Revised: Nonetheless, if the dataset contains a labeled negative pair with some anchor, then its elements are semantically close by traditional rules of dataset construction.

Original: Thus, using such a pairinside the batch, where this anchor is present, willadd the necessary hard negative example.
Revised: Thus, using such a pair inside the batch, where this anchor is present, will add the necessary hard negative example.

Original: The only change that is added in the loss functionis the masking of negative examples—we have noguarantees that the selected negative example iscloser to the anchor than the rest of the examplesinside the batch.
Revised: The only change that is added in the loss function is the masking of negative examples—we have no guarantees that the selected negative example is closer to the anchor than the rest of the examples inside the batch.

Original: Let y i be a binary label, wherey i “ 1 if the i -th pair is positive.
Revised: Let y i be a binary label, where y i [Equation] 1 if the i -th pair is positive.

Original: Then, we have
Revised: Then, we have

Original: [Equation]

Original: [Equation]
Revised: [Equation]

Original: 3. Combo Loss
Revised: 3. Combo Loss

Original: Theoretically, it is beneficial to use several lossfunctions for training if they are calculated on thesame batch (and thus do not require additional computations).
Revised: Theoretically, it is beneficial to use several loss functions for training if they are calculated on the same batch (and thus do not require additional computations).

Original: That is, joint training of BSC and MSElosses combines the advantages of pointwise andof pairwise approaches, thus ensuring that for positives examples, the values on the diagonal of thedot-product matrix are not only greater than the rest,but are also close to 1 or to some target similarity.
Revised: That is, joint training of BSC and MSE losses combines the advantages of pointwise and of pairwise approaches, thus ensuring that for positives examples, the values on the diagonal of the dot-product matrix are not only greater than the rest, but are also close to 1 or to some target similarity.

Original: Note that here L MSE p X q “ 1 m ř mi pp q Ti a
Revised: Note that here L MSE p X q “ 1 m ř mi pp q Ti a

Original: i q ´ y i q 2for target positive similarities y i , and thus we donot force all other similarities to zero.
Revised: i q ´ y i qfor target positive similarities y i , and thus we do not force all other similarities to zero.

Original: At the sametime, the BSC loss adds new examples (“negative”pairs) to the training set.
Revised: At the same time, the BSC loss adds new examples (“negative” pairs) to the training set.

Original: In order to use the BSC loss when training amodel in tasks with non-binary labels, we modifythe indicator function in the equation 5, as 1 r y i ą t s , where t is a configurable binarization threshold.
Revised: In order to use the BSC loss when training a model in tasks with non-binary labels, we modify the indicator function in the equation 5, as 1 r y i ą t s , where t is a configurable binarization threshold.

Original: Then, we use their convex combination with the configurable hyperparameter µ P p0 , 1 q [Equation] [Equation]
Revised: Then, we use their convex combination with the configurable hyperparameter µ P p

Original: [Equation]
Revised: [Equation]

Original:  Normalization
Revised: 3. Normalization

Original: L2 normalization of matrices A and B means that a Ti b j will be equivalent to cosine similarity.
Revised: L2 normalization of matrices A and B means that a Ti b j will be equivalent to cosine similarity.

Original: The embeddings can also be normalized by the batch dimension (by coordinates), which can bring additional regularization.
Revised: The embeddings can also be normalized by the batch dimension (by coordinates), which can bring additional regularization.

Original: In our experiments, we confirm the importance of this, e.g., new representations can be calculated with L2 normalization by coordinates or in a min-max scale.
Revised: In our experiments, we confirm the importance of this, e.g., new representations can be calculated with L2 normalization by coordinates or in a min-max scale.

Original:  Datasets
Revised:  Datasets

Original: NLP tasks that compare pairs of sentences can be divided into regression (predicting a similarity score), classification (e.g., similar vs. dissimilar), and ranking (search for the best matches).
Revised: NLP tasks that compare pairs of sentences can be divided into regression (predicting a similarity score), classification (e.g., similar vs. dissimilar), and ranking (search for the best matches).

Original: They differ only by the quality assessment functions, and thus they all can benefit from the above losses.
Revised: They differ only by the quality assessment functions, and thus they all can benefit from the above losses.

Original: Note that it is important to calculate sentence representations in ranking tasks, as when independently calculating the embeddings of the individual elements in the pairs, the inference time of the model becomes linear instead of quadratic.
Revised: Note that it is important to calculate sentence representations in ranking tasks, as when independently calculating the embeddings of the individual elements in the pairs, the inference time of the model becomes linear instead of quadratic.

Original: Therefore, we use Sentence-BERT (SBERT), which is trained as a Siamese BERT model, and offers a way to obtain state-of-the-art sentence embeddings, which have been proven useful for a number of tasks (Reimers and Gurevych, 2019; Thakur et al., 2020).
Revised: Therefore, we use Sentence-BERT (SBERT), which is trained as a Siamese BERT model, and offers a way to obtain state-of-the-art sentence embeddings, which have been proven useful for a number of tasks (Reimers and Gurevych, 2019; Thakur et al., 2020).

Original: At inference time, we first use SBERT to obtain independently a representation for each sentence in the pair, and then we calculate the cosine similarities between these embeddings.
Revised: At inference time, we first use SBERT to obtain independently a representation for each sentence in the pair, and then we calculate the cosine similarities between these embeddings.

Original: We use the following  English datasets and tasks for the evaluation.
Revised: We use the following public English datasets and tasks for the evaluation.

Original: Four ranking tasks (ranking answers to non-factoid questions, ranking questions by their similarity with respect to other questions, ranking comments by their similarity to a given question, ranking fact-checked claims by their relevance with respect to an input claim), two binary classification tasks (paraphrases identification, and duplicate question identification), and one regression task (semantic sentence similarity).
Revised: Four ranking tasks (ranking answers to non-factoid questions, ranking questions by their similarity with respect to other questions, ranking comments by their similarity to a given question, ranking fact-checked claims by their relevance with respect to an input claim), two binary classification tasks (paraphrases identification, and duplicate question identification), and one regression task (semantic sentence similarity).

Original: Antique
Revised: Antique

Original: The dataset contains 2,626 non-factoid questions with answer choices (Hashemi et al., 2019), asked by users on Yahoo!
Revised: The dataset contains 2,626 non-factoid questions with answer choices (Hashemi et al., 2019), asked by users on Yahoo!

Original: Answers .
Revised: Answers .

Original: There are a total of 34,011 question–answer pairs: 27, for training and 6,589 for validation.
Revised: There are a total of 34,011 question–answer pairs: 27, for training and 6,589 for validation.

Original: Each answeris annotated with a relevance score with respect tothe question on a scale from 1 to 4, and the task isto rank the answers by their relevance.
Revised: Each answer is annotated with a relevance score with respect to the question on a scale from 1 to 4, and the task is to rank the answers by their relevance.

Original: To modelrelevance as a cosine similarity, we normalize thescores to the r 0 , 1 s interval.
Revised: To model relevance as a cosine similarity, we normalize the scores to the r 0 , 1 s interval.

Original: We use Mean Reciprocal Rank (MRR) as the main evaluation measure.
Revised: We use Mean Reciprocal Rank (MRR) as the main evaluation measure.

Original: CQA-A
Revised: CQA-A

Original: This dataset was used in [-SemEval-
 Task-] 3 on Community Question Answering subtask A (Nakov et al., 2017).
Revised: This dataset was used in [-SemEval-
 Task-]SemEvalTask 3 on Community Question Answering subtask A (Nakov et al., 2017).

Original: The goal is to rankthe first ten answers in a question thread on Qatar
Revised: The goal is to rank the first ten answers in a question thread on Qatar

Original: Living, so that good answers are ranked higherthan bad ones.
Revised: Living, so that good answers are ranked higher than bad ones.

Original: We used the clean part of thedataset, which consists of 14,110 and 2,440 labeledquestion–comments pairs for training and development, respectively.
Revised: We used the clean part of the dataset, which consists of 14,110 and 2,440 labeled question–comments pairs for training and development, respectively.

Original: The evaluation measure is
Revised: The evaluation measure is

Original: Mean Average Precision (MAP).
Revised: Mean Average Precision (MAP).

Original: This dataset contains important metadata, e.g., the date and time ofthe comment, and sorting the comments by timeyields a strong baseline; yet, we only use the text.
Revised: This dataset contains important metadata, e.g., the date and time of the comment, and sorting the comments by time yields a strong baseline; yet, we only use the text.

Original: To train the model with the triplet loss, we groupthe pairs by the first element (anchor).
Revised: To train the model with the triplet loss, we group the pairs by the first element (anchor).

Original: CQA-B
Revised: CQA-B

Original: This dataset was developed for
Revised: This dataset was developed for

Original: SemEval-2017 Task 3, subtask B (Nakov et al.,2017), whose goal was to rank 10 potentially related questions by their similarity with respect toan input question.
Revised: SemEval-2017 Task 3, subtask B (Nakov et al., 2017), whose goal was to rank 10 potentially related questions by their similarity with respect to an input question.

Original: These questions are retrievedfrom the Qatar Living forum using Google and theinput question as a query.
Revised: These questions are retrieved from the Qatar Living forum using Google and the input question as a query.

Original: We use the clean partof the dataset, which consists of 19,990 trainingand 5,500 development labeled question-questionpairs.
Revised: We use the clean part of the dataset, which consists of 19,990 training and 5,500 development labeled question-question pairs.

Original: The main evaluation measure here is MAP.
Revised: The main evaluation measure here is MAP.

Original: There is additional information, e.g., the rank ofthe retrieved question in the Google search results,which we do not use.
Revised: There is additional information, e.g., the rank of the retrieved question in the Google search results, which we do not use.

Original: PFCC-S Shaar et al.
Revised: PFCC-S Shaar et al.

Original: (2020) presented a datasetfor detecting Previously Fact-Checked Claims on
Revised: (2020) presented a dataset for detecting Previously Fact-Checked Claims on

Original: Snopes (PFCC-S), aimed at facilitating the solutionof a fact-checking problem: given an input claim,it asks to rank claims that have been previouslyfact-checked, so that claims that can help verifythe input claim are ranked as high as possible.
Revised: Snopes (PFCC-S), aimed at facilitating the solution of a fact-checking problem: given an input claim, it asks to rank claims that have been previously fact-checked, so that claims that can help verify the input claim are ranked as high as possible.

Original: Thedataset has 800 positive input–verified claim pairsfor training and 200 such positive pairs for testing,and they are to be matched against a database of10,369 verified claims.
Revised: The dataset has 800 positive input–verified claim pairs for training and 200 such positive pairs for testing, and they are to be matched against a database of 10,369 verified claims.

Original: The evaluation is performedin terms of a HasPositive@k metric, which checkswhether there is a positive match among the first kresults in the ranked list.
Revised: The evaluation is performed in terms of a HasPositive@k metric, which checks whether there is a positive match among the first k results in the ranked list.

Revised: There are no negative examples in the dataset, but about eight million such pairs can be created.

Original: In order to train modelsusing MSE or triplet loss, we sampled negativesaccording to the following scheme.
Revised: Thus, in order to train models using MSE or triplet loss, we sampled negatives according to the following scheme.

Original: First, we encoded all sentences using SBERT, pretrained on
Revised: First, we encoded all sentences using SBERT, pretrained on

Original: STSb and NLI.
Revised: STSb and NLI.

Original: Then, we selected the first element in each positive pair as an anchor and we sorted all other examples by their similarity to this anchor.
Revised: Then, we selected the first element in each positive pair as an anchor and we sorted all other examples by their similarity to this anchor.

Original: The assumption is that positive examples will be concentrated in the beginning, e.g., among the top100.
Revised: The assumption is that positive examples will be concentrated in the beginning, e.g., among the top100.

Original: Thus, we selected negatives starting from on, logarithmically: on positions 100 ` 2 k , k P N .
Revised: Thus, we selected negatives starting fromon, logarithmically: on positions 100 ` 2 k , k P N .

Original: As a result, we obtain many hard negative examples and a small number of easy ones.
Revised: As a result, we obtain many hard negative examples and a small number of easy ones.

Original: Finally, we oversampled the positive pairs to correct the balance of positive and negative examples.
Revised: Finally, we oversampled the positive pairs to correct the balance of positive and negative examples.

Original:  Paraphrase Corpus (MRPC)
Revised: Microsoft Research Paraphrase Corpus (MRPC)

Original: Dolan et al.
Revised: Dolan et al.

Original: (2004) contains 5,800 pairs of sentences, extracted from online news sources.
Revised: (2004) contains 5,800 pairs of sentences, extracted from online news sources.

Original: Each pair was labeled with a tag indicating whether the sentences are paraphrases (semantically equivalent).
Revised: Each pair was labeled with a tag indicating whether the sentences are paraphrases (semantically equivalent).

Original: There are 3,668, 407, and 1,725 pairs in the training, development, and test subsets.
Revised: There are 3,668, 407, and 1,725 pairs in the training, development, and test subsets.

Original: As it is a binary classification task with class imbalance, it is evaluated in terms of F1.
Revised: As it is a binary classification task with class imbalance, it is evaluated in terms of F1.

Original: Quora Question Pairs (QQP)
Revised: Quora Question Pairs (QQP)

Original: Quora presented a dataset containing over 500,000 sentences with over 400,000 lines of potential duplicate questions.
Revised: Quora presented a dataset containing over 500,000 sentences with over 400,000 lines of potential duplicate questions.

Original: Each line has a binary label indicating whether the line truly contains a duplicate pair.
Revised: Each line has a binary label indicating whether the line truly contains a duplicate pair.

Original: Due to the sampling method, which returns mostly positive pairs, the authors supplemented the dataset with negative pairs composed of “related questions.”
Revised: Due to the sampling method, which returns mostly positive pairs, the authors supplemented the dataset with negative pairs composed of “related questions.”

Original: As in (Thakur et al., 2020), we sample randomly 10, examples for training, and we use the F1 score as the main evaluation measure.
Revised: As in (Thakur et al., 2020), we sample randomly 10, examples for training, and we use the F1 score as the main evaluation measure.

Original: Semantic Textual Similarity Benchmark
Revised: Semantic Textual Similarity Benchmark

Original: (STSb)
Revised: (STSb)

Original: The STS benchmark comprises a selection

Original:  of the English datasets used in the STS tasks orga- nized in the context of SemEval between 2012 and 2017 (Cer et al., 2017).
Revised: The STS benchmark comprises a selection of the English datasets used in the STS tasks organized in the context of SemEval between 2012 and 2017 (Cer et al., 2017).

Original: The benchmark comprises 628 sentence pairs.
Revised: The benchmark comprises 8,628 sentence pairs.

Original: The pairs were annotated with similarity scores 
Revised: The pairs were annotated with similarity scores on a scale from 0 to 5 (5 indicating complete equivalence).

Original: on a scale from
Revised: There are a total of

Original: 0 to indi- cating complete equivalence).
Revised: [Table]

Original: There are a total of 5,749, 1,500 and 1,379 pairs in the training, in the development, and in the testing split, respectively.
Revised: 5,749, 1,500 and 1,379 pairs in the training, in the development, and in the testing split, respectively.

Original: The main metric is Spearman’s rank correlation.
Revised: The main metric is Spearman’s rank correlation.

Original: As in the Antique dataset, we normalize the scores to the r 0 , 1 s interval
Revised: As in the Antique dataset, we normalize the scores to the r 0 , 1 s interval

Original: and then we binarized them based on a threshold of 0 . 6 .
Revised: and then we binarized them based on a threshold of 0 . 6 .

Original:  Experimental Setup
Revised:  Experimental Setup

Original: We used BERT-base uncased in all our experiments to be able to perform direct comparison for tasks such as MRPC, QQP and STS to previous work[Table] [Table] (Reimers and Gurevych, 2019; Thakur et al., 2020).
Revised: We used BERT-base uncased in all our experiments to be able to perform direct comparison for tasks such as MRPC, QQP and STS to previous work (Reimers and Gurevych, 2019; Thakur et al., 2020).

Original: We considered SimCSE ( sup-simcse-bert-baseuncased checkpoint)
Revised: We considered SimCSE ( sup-simcse-bert-baseuncased checkpoint)

Original: (Gao et al., 2021) as an unsupervised baseline as it uses the base version ofthe BSC loss, which we modified.
Revised: (Gao et al., 2021) as an unsupervised baseline as it uses the base version of the BSC loss, which we modified.

Original: Below, by BSCwe will denote using optimal settings in the tables,and variants like BSC - random shuffle would meanthat instead of these optimal settings, we appliedrandom shuffling.
Revised: Below, by BSC we will denote using optimal settings in the tables, and variants like BSC - random shuffle would mean that instead of these optimal settings, we applied random shuffling.

Original: The hyperparameter settings are described indetail in Appendix A.
Revised: The hyperparameter settings are described in detail in Appendix 8.

Original:  Results
Revised:  Results

Original: [Table]

Original: In this section, we compare the BSC loss to otherloss functions: MSE and triplet loss.
Revised: In this section, we compare the BSC loss to other loss functions: MSE and triplet loss.

Original: Additionally, we make an ablation study for the BSC lossmodifications we proposed.[Table]
Revised: Additionally, we make an ablation study for the BSC loss modifications we proposed.

Original: Antique
Revised: Antique

Original: The results are shown in Table 1.
Revised: The results are shown in Table 1.

Original: Ourbest approach of combo-training MSE and BSC[Table] losses outperforms all other variants and the approach proposed in (Hashemi et al., 2019), wherespecific negative sampling and a triplet loss wereused.
Revised: Our best approach of combo-training MSE and BSC losses outperforms all other variants and the approach proposed in (Hashemi et al., 2019), where specific negative sampling and a triplet loss were used.

Original: Besides, the best BSC configuration achieveshigher scores than MSE.
Revised: Besides, the best BSC configuration achieves higher scores than MSE.

Original: We can see the importance of using predefined hand-crafted negativeexamples, which brings additional difficult casesand increases MRR by 0.02.
Revised: We can see the importance of using predefined hand-crafted negative examples, which brings additional difficult cases and increases MRR by 0.02.

Original: CQA-A
Revised: CQA-A

Original: The results for CQA subtask A areshown in Table 2.
Revised: The results for CQA subtask A are shown in Table 2.

Original: A comparison with (Nakov et al.
Revised: A comparison with (Nakov et al.,

Original: ,2017) is not very fair, as we did not use the meta-

Original: [Table]
Revised: [Table]

Original: data, e.g., the comment position, which was cru-

Original: [Table]
Revised: [Table]

Original: cial for the best systems.
Revised: 2017) is not very fair, as we did not use the metadata, e.g., the comment position, which was crucial for the best systems.

Original: Besides, we use SBERT, which is inferior to a fine-tuned BERT.
Revised: Besides, we use SBERT, which is inferior to a fine-tuned BERT.

Original: Nevertheless, our best approach of combo training with
Revised: Nevertheless, our best approach of combo training with

Original: MSE and BSC losses yielded competitive results.
Revised: MSE and BSC losses yielded competitive results.

Original: We further compared different shuffling strategies.
Revised: We further compared different shuffling strategies.

Original: The data is ordered by questions, and keeping this order turns out to be best.
Revised: The data is ordered by questions, and keeping this order turns out to be best.

Original: That is, the model learns to distinguish positive answers for each question from manually selected negative ones and from answers to other questions.
Revised: That is, the model learns to distinguish positive answers for each question from manually selected negative ones and from answers to other questions.

Original: Also, note that random shuffling completely eliminates this structure, and
Revised: Also, note that random shuffling completely eliminates this structure, and

Original: MAP drops by 6% absolute.
Revised: MAP drops by 6% absolute.

Original: Fast shuffling by clusters, an advanced version of shuffling by words, improves these results.
Revised: Fast shuffling byclusters, an advanced version of shuffling by words, improves these results.

Original: Example-based shuffling finds a data order similar to the initial one, and the quality does not degrade much.
Revised: Example-based shuffling finds a data order similar to the initial one, and the quality does not degrade much.

Original: CQA-B
Revised: CQA-B

Original: The results for CQA-B are shown in Table 2.
Revised: The results for CQA-B are shown in Table 2.

Original: Again, we did not use the question position, which is a critically important feature for the best systems.
Revised: Again, we did not use the question position, which is a critically important feature for the best systems.

Original: We can see that the BSC loss achieved the best score, noticeably outperforming MSE and triplet losses.
Revised: We can see that the BSC loss achieved the best score, noticeably outperforming MSE and triplet losses.

Original: The experiments also demonstrate the importance of data order when training with the BSC loss.
Revised: The experiments also demonstrate the importance of data order when training with the BSC loss.

Original: Since the dataset is small, the model overfits when the original data order is fixed.
Revised: Since the dataset is small, the model overfits when the original data order is fixed.

Original: PFCC-S Table 3 shows the results for PFCCS ( HP@k stands for HasPositives@k ).
Revised: PFCC-S Table 3 shows the results for PFCC-S ( HP@k stands for HasPositives@k ).

Revised: Note that the

Original: Note that the scores from (Shaar et al., 2020) are for pretrained SBERT without task-specific fine-tuning.
Revised: [Table] [Table] scores from (Shaar et al., 2020) are for pre-trained SBERT without task-specific fine-tuning.

Original: We observed that even when using oversampling to improve the balance of positive examples,  MSE performed worse than their results.
Revised: We observed that even when using oversampling to improve the balance of positive examples, fine-tuning with MSE performed worse than their results.

Original: Here, we used only positives examples to train with BSC, and normalizing by the zero dimension was the best.
Revised: Here, we used only positives examples to train with BSC, and normalizing by the zero dimension was the best.

Original: Overall, the approaches using BSC and triplet losses were comparable.
Revised: Overall, the approaches using BSC and triplet losses were comparable.

Original: However, the dataset size for training with the BSC loss was much smaller, which is also true for MSE.
Revised: However, the dataset size for training with the BSC loss was much smaller, which is also true for MSE.

Original: As a result, the BSC loss is faster, and preferable for this task.
Revised: As a result, the BSC loss is faster, and preferable for this task.

Original: Approach / Metric

Original: [Table] [Table] MRPC Table 4 shows the results for MRPC.
Revised: MRPC Table 4 shows the results for MRPC.

Original: MSE outperformed the BSC loss, but comboachieved a slightly higher F1 score.
Revised: MSE outperformed the BSC loss, but combo achieved a slightly higher F1 score.

Original: QQP
Revised: QQP

Original: The results for QQP are presented in
Revised: The results for QQP are presented in

Original: Table 4.
Revised: Table 4.

Original: We also show results for SBERT andaugmented SBERT (in parentheses) from (Thakuret al., 2020).
Revised: We also show results for SBERT and augmented SBERT (in parentheses) from (Thakur et al., 2020).

Original: There score was obtained by training
Revised: There score was obtained by training

Original: SBERT with MSE using another random trainingsample, but nonetheless, the F1 score is close toours.
Revised: SBERT with MSE using another random training sample, but nonetheless, the F1 score is close to ours.

Original: The combo approach outperformed separatetraining with BSC or MSE.
Revised: The combo approach outperformed separate training with BSC or MSE.

Original: STSb Table 5 shows the results for STS.
Revised: STSb Table 5 shows the results for STS.

Original: It isthe only task where combo with the BSC loss wasworse than MSE.
Revised: It is the only task where combo with the BSC loss was worse than MSE.

Original: This could be due to hard negatives not appearing in the batch in any of the shuffling procedures.
Revised: This could be due to hard nega- tives not appearing in the batch in any of the shuffling procedures.

Original: Moreover, we observed onlymarginal improvement when fine-tuning with a BSC model initially trained with MSE. 
Revised: Moreover, we observed only marginal improvement when fine-tuning with a BSC model initially trained with MSE. However, if it was pretrained with BSC

Revised: up to

Original: However,if it was pretrained with BSC up to overfitting, finetuning it with MSE yielded sizable improvements.
Revised: overfitting , fine- tuning it with MSE yielded sizable improvements

Original:  Discussion
Revised:  Discussion

Original: We highlight the following observations:
Revised: We highlight the following observations:

Original: • Combo-training with BSC and MSE lossesgenerally yields the best results (the only exception is STS), and it outperforms the triplet loss with advanced negative sampling.
Revised: • Combo-training with BSC and MSE losses generally yields the best results (the only exception is STSb), and it outperforms the triplet loss with advanced negative sampling.

Original: • The order in which the data is presented for training can be critical, as we have seen in the cases of CQA-A and
Revised: • The order in which the data is presented for training can be critical, as we have seen in the cases of CQA-A and

Original: CQA-B. • The use of labeled negatives examples gener- ally improves the scores by 1-2% absolute.
Revised: CQA-B. • The use of labeled negatives examples generally improves the scores by 1-2% absolute (e.g., for Antique).

Original: • Embedding normalization during training is important.
Revised: • Embedding normalization during training is important.

Original: Moreover, it is useful to normalize to the zero dimension (e.g., for PFCC-S).
Revised: Moreover, it is useful to normalize to the zero dimension (e.g., for PFCC-S).

Original: • Temperature τ of order 0.1 should be used with the standard normalization, and τ of or- der 1-3 for coordinate normalization.
Revised: • Temperature τ of order 0.1 should be used with the standard normalization, and τ of order 1-3 for coordinate normalization.

Original: • An incorrect training setup may hurt the per- formance by more than 10%, as was demon- strated for ( i ) filtering out negative exam- ples for which no positives were given in 
Revised: • An incorrect training setup may hurt the performance by more than 10%, as was demonstrated for ( i ) filtering out negative examples for which no positives were given in the dataset (Table 1), ( ii ) using poorly formed batches (highest effect in Table 2), ( iii ) suboptimal normalization (Table 3), and ( iv ) wrong temperature value.

Original: the

Original: dataset (Table 1), ( ii ) using poorly formed

Original: batches (highest effect in Table 2), ( iii ) subop-

Original: timal normalization (Table 3), and ( iv ) wrong

Original: temperature value. • BSC is more suitable for ranking tasks, but it can help for other tasks  if applied as pre- training or in joint training with MSE.
Revised: • BSC is more suitable for ranking tasks (Antique, CQA, PFCC-S), but it can help for other tasks (classification and regression tasks, e.g., for MRPC, QQP, STSb) if applied as pretraining or in joint training with MSE.

Original: Selecting a loss function is important.
Revised: Selecting a loss function is important.

Original: For

Original: in-

Original: stance, if

Original: the

Original: model

Original: optimizes

Original:  Pearson correlation, it achieves a score of 85. on the STS task.
Revised: For instance, if the model optimizes Pearson correlation, it achieves a score of 85.57 on the STS task.

Original: Thus, it outperforms almost all considered approaches
Revised: Thus, it outperforms almost all considered approaches.

Original: Moreover, the combination of such a loss with BSC allows the model to achieve an F1 score of 89.
Revised: Moreover, the combination of such a loss with BSC allows the model to achieve an F score of 89.

Original: in the MRPC task (a classification task)
Revised: in the MRPC task (a classification task).

Original: Finally, we would like to draw a parallel between our work and Augmented SBERT (Thakur et al., 2020).
Revised: Finally, we would like to draw a parallel between our work and Augmented SBERT (Thakur et al., 2020).

Original: When using the BSC loss, some negatives are implicitly added to the dataset.
Revised: When using the BSC loss, some negatives are implicitly added to the dataset.

Original: Augmented
Revised: Augmented

Original: SBERT adds new examples too and retrieves them using BM25 or Semantic Search samplings.
Revised: SBERT adds new examples too and retrieves them using BM25 or Semantic Search samplings.

Original: These methods are comparable to our fast shuffling by words ( n -grams) and to example-based shuffling, respectively.
Revised: These methods are comparable to our fast shuffling by words ( n -grams) and to example-based shuffling, respectively.

Original: Moreover, the task-specific model is used to encode the data in both cases.
Revised: Moreover, the task-specific model is used to encode the data in both cases.

Original: However, we do not need to label such pairs with another model (cross-encoder) due to the BSC loss definition.
Revised: However, we do not need to label such pairs with another model (cross-encoder) due to the BSC loss definition.

Original:  Conclusion and Future Work
Revised:  Conclusion and Future Work

Original: We explored the idea of using a batch-softmax contrastive loss for fine-tuning large-scale pre-trained transformers to learn better task-specific sentence embeddings for pairwise sentence scoring tasks.
Revised: We explored the idea of using a batch-softmax contrastive loss for fine-tuning large-scale pre-trained transformers to learn better task-specific sentence embeddings for pairwise sentence scoring tasks.

Original: We introduced and studied a number of variations in the calculation of the loss as well as in the overall training procedure.
Revised: We introduced and studied a number of variations in the calculation of the loss as well as in the overall training procedure.

Original: Our experimental results have shown sizable improvements on a number of datasets and pairwise sentence scoring tasks including ranking, classification, and regression.
Revised: Our experimental results have shown sizable improvements on a number of datasets and pairwise sentence scoring tasks including ranking, classification, and regression.

Original: In future work, we want to explore new variations of the loss, and to gain better understanding of when to use which variation.
Revised: In future work, we want to explore new variations of the loss, and to gain better understanding of when to use which variation.

Original: We further plan experiments with a larger set of NLP tasks.
Revised: We further plan experiments with a larger set of NLP tasks.

Original: Ethics and Broader Impact
Revised: Ethics and Broader Impact

Original: We wouldalso like to warn that the use of largescale Transformers requires a lot of computationsand the use of GPUs/TPUs for training, which contributes to global warming (Strubell et al., 2019).
Revised: We would like to warn that the use of large-scale Transformers requires a lot of computations and the use of GPUs/TPUs for training, which contributes to global warming (Strubell et al., 2019).

Original: This is a bit less of an issue in our case, as wedo not train such models from scratch; rather, wefine-tune them on relatively small datasets.
Revised: This is a bit less of an issue in our case, as we do not train such models from scratch; rather, we fine-tune them on relatively small datasets.

Original: Moreover, running on a CPU for inference, once themodel is fine-tuned, is perfectly feasible, and CPUscontribute much less to global warming. 
Revised: Moreover, running on a CPU for inference, once the model is fine-tuned, is perfectly feasible, and CPUs contribute much less to global warming. Acknowledgments

Revised: The article was prepared within the framework of the HSE University Basic Research Program.

Original: AppendixA Hyperparameters Setting
Revised: Appendix A Hyperparameters Setting

Original: We set the number of warm-up steps to 10% ofthe total steps, and we limited the input sequencelength to 90 subtokens.
Revised: We set the number of warm-up steps to 10% of the total steps, and we limited the input sequence length to 90 subtokens.

Original: We used a batch size of30 in all tasks, except for Antique and QQP, wherewe used 50.
Revised: We used a batch size of 30 in all tasks, except for Antique and QQP, where we used 50.

Original: Note that an order of magnitude largerbatch sizes would probably yield better results, butthey would also require much more memory.
Revised: Note that an order of magnitude larger batch sizes would probably yield better results, but they would also require much more memory.

Original: Weexperimented with learning rates from {5e-6, 1e5, 2e-5, 3e-5}, and we selected (on dev) 3e-5 for
Revised: We experimented with learning rates from {5e-6, 1e5, 2e-5, 3e-5}, and we selected (on dev) 3e-5 for

Original: CQA-B and 2e-5 for all other experiments.
Revised: CQA-B and 2e-5 for all other experiments.

Original: Weused the AdamW optimizer with the bias correctionfor the CQA tasks, and without bias correction forthe rest.
Revised: We used the AdamW optimizer with the bias correction for the CQA tasks, and without bias correction for the rest.

Original: We trained the model for five epochsfor Antique, CQA-A and STSb, for six epochs for
Revised: We trained the model for five epochs for Antique, CQA-A and STSb, for six epochs for

Original: QQP, MRPC and PFCC-S, and for seven epochsfor CQA-B, saving a checkpoint after each one,and we selected the best checkpoint on dev.
Revised: QQP, MRPC and PFCC-S, and for seven epochs for CQA-B, saving a checkpoint after each one, and we selected the best checkpoint on dev.

Original: As recommended in (Thakur et al., 2020), due toinstability, we did seed optimization, running eachapproach five times and selecting the best result(on dev).
Revised: As recommended in (Thakur et al., 2020), due to instability, we did seed optimization, running each approach five times and selecting the best result (on dev).

Original: To train with the BSC loss, we used min-maxnormalization by coordinates with τ “ 1 . 2 for
Revised: To train with the BSC loss, we used min-max normalization by coordinates with τ “ 1 . 2 for

Original: PFCC-S and QQP, standard L2 normalization withτ “ 0 . 055 for CQA-A, τ “ 0 . 07 for CQA-B, andτ “ 0 .
Revised: PFCC-S and QQP, standard L2 normalization with τ “ 0 . 055 for CQA-A, τ “ 0 . 07 for CQA-B, and τ “ 0 .

Original: 1 for all other tasks (to find the optimal τ , wemade it trainable for one run).
Revised: 1 for all other tasks (to find the optimal τ , we made it trainable for one run).

Original: We applied examplebased shuffling to train with the BSC loss.
Revised: We applied examplebased shuffling to train with the BSC loss.

Original: We useda group size of four in MRPC, of five in CQA-B,and of eight in all other tasks.
Revised: We used a group size of four in MRPC, of five in CQA-B, and of eight in all other tasks.

Original: We iterated over µvalues from the set t 0 . 1 , 0 . 5 , 0 .
Revised: We iterated over µ values from the set t 0 . 1 , 0 . 5 , 0 .

Original: 9 u , and we choseµ “ 0 . 1 to train the combo approach for CQA-A,
Revised: 9 u , and we chose µ “ 0 . 1 to train the combo approach for CQA-A,

Original: MRPC, QQP and STSb tasks, and µ “ 0 . 9 for theother experiments.
Revised: MRPC, QQP and STSb tasks, and µ “ 0 . 9 for the other experiments.

Revised: Our experiments demonstrated that there is only a minor effect of changing these hyperparameters.

Revised: For example, the maximum quality drop from µ ( 0 . 1 vs. 0 . 5 ) is 0.4%, i.e., almost at the noise level, while we obtained gains of up to 10% when using our proposed modifications.

Original: We trained the triplet loss variant from (Reimersand Gurevych, 2019) with margin “ 0 . 6 for
Revised: We trained the triplet loss variant from (Reimers and Gurevych, 2019) with margin “ 0 . 6 for

Original: PFCC-S, and margin “ 0 .
Revised: PFCC-S, and margin “ 0 .

Original: 5 for all other tasks.
Revised: 5 for all other tasks.

Original: As we have no answers for the test set in MRPC,and no test sets in Antique and PFCC-S, we split thetraining set into 9:1 to tune the hyper-parameters.
Revised: As we have no answers for the test set in MRPC, and no test sets in Antique and PFCC-S, we split the training set into 9:1 to tune the hyper-parameters.

Original: The time for training SBERT with the BSC loss(or combo loss) was almost equal to the time fortraining with the standard MSE loss.
Revised: The time for training SBERT with the BSC loss (or combo loss) was almost equal to the time for training with the standard MSE loss.

Revised: The most complex example-based shuffling only adds 8% to the training time.

Revised: Note that it is several times faster than triplet loss, as only positive examples are used for training and thus the dataset becomes several times smaller.

Original: We ran all experiments on a GeForce GTX[-
-]
Revised: We ran all experiments on a GeForce GTX[-
-]

Original: GPU Ti.
Revised: GPU Ti.

Original: Base SBERT has 110M parameters.
Revised: Base SBERT has 110M parameters.

Original: Itstraining took up to 10 minutes per epoch dependingon the dataset size.
Revised: Its training took up to 10 minutes per epoch depending on the dataset size.