CASE -- Condition-Aware Sentence Embeddings for Conditional Semantic Textual Similarity Measurement
Gaifan Zhang, Yi Zhou, Danushka Bollegala
TL;DR
CASE addresses the challenge of context-sensitive semantic textual similarity by pairing LLM-based conditioning with a lightweight, supervised projection. It encodes the condition given a sentence with $f(c; I(s))$, subtracts the unconditional condition embedding $f(c; I( emptyset))$, and learns a small FFN to produce low-dimensional CASE embeddings, optimizing cosine similarity to human C-STS ratings. Empirically, CASE improves over prior C-STS methods, with LLM embeddings outperforming MLMs, and achieves similar performance to fine-tuned encoders while reducing dimensionality to $512$ and requiring far less training compute. The approach yields higher isotropy in the embedding space and demonstrates practical gains for large-scale retrieval and QA tasks where context-aware similarity matters.
Abstract
The meaning conveyed by a sentence often depends on the context in which it appears. Despite the progress of sentence embedding methods, it remains unclear how to best modify a sentence embedding conditioned on its context. To address this problem, we propose Condition-Aware Sentence Embeddings (CASE), an efficient and accurate method to create an embedding for a sentence under a given condition. First, CASE creates an embedding for the condition using a Large Language Model (LLM), where the sentence influences the attention scores computed for the tokens in the condition during pooling. Next, a supervised nonlinear projection is learned to reduce the dimensionality of the LLM-based text embeddings. We show that CASE significantly outperforms previously proposed Conditional Semantic Textual Similarity (C-STS) methods on an existing standard benchmark dataset. We find that subtracting the condition embedding consistently improves the C-STS performance of LLM-based text embeddings. Moreover, we propose a supervised dimensionality reduction method that not only reduces the dimensionality of LLM-based embeddings but also significantly improves their performance.
