Klcse: Kullback–Leibler divergence contrastive sentence embedding
摘要
Cosine similarity in contrastive sentence embeddings (CSE) cannot measure the asymmetric relationships of inference direction. By following SimCSE and GaussCSE, we propose a supervised approach, which combines cosine similarity with Kullback–Leibler (KL) divergence for contrastive learning of sentence embeddings (KLCSE) to represent inference distance. Firstly, the sentence [CLS] vectors are obtained from pre-trained language models with multilayer perceptron (MLP). Then, softmax embedding is applied to the [CLS] vectors as the sentence probability distribution. In addition, the KL divergence is calculated between probability distributions of sentence pairs as an asymmetric measure. Finally, a loss function is constructed by combining the cosine similarity of sentence pairs to obtain a sentence representation with a uniform embedding space. We evaluated the method on standard semantic textual similarity (STS) tasks and massive text embedding benchmark (MTEB). Our models, using BERT