Abstract
Sentence embeddings are critical for various natural language processing tasks, yet obtaining high-quality representations from conversational data remains challenging. We present DialogueCSE, a novel contrastive learning framework designed to leverage multi-turn dialogue context. By introducing a Matching-Guided Embedding (MGE) mechanism, DialogueCSE aligns a sentence's standalone representation with a context-aware version distilled through its conversational history. Our approach significantly outperforms traditional siamese-network baselines across multiple benchmarks, demonstrating superior accuracy and robustness even in low-data regimes.
Introduction
The development of high-quality sentence embeddings is a cornerstone of modern NLP, facilitating tasks such as semantic search and dialogue system management. While supervised methods like SBERT achieve strong performance, they are limited by the availability of human-labeled data. Self-supervised learning from dialogue corpora offers a scalable alternative, as conversations naturally encode semantic relationships between turns.
However, existing dialogue-based models often suffer from two primary issues: the training-evaluation gap and contextual noise. Many models are trained as classifiers to predict response-context fit but are evaluated using simple distance metrics like cosine similarity. Furthermore, naive concatenation of dialogue history often introduces irrelevant information that degrades embedding quality. DialogueCSE addresses these challenges by moving toward a contrastive learning objective and employing a fine-grained matching mechanism.
Methodology: Matching-Guided Embedding (MGE)
The core of DialogueCSE is the Matching-Guided Embedding (MGE) mechanism, which transitions from simple classification to a contrastive learning paradigm. The architecture is designed to bake conversational relevance directly into the embedding space.
The process involves four key stages:
- Sentence Encoding: Individual turns in the dialogue context ($u$) and the target response ($r$) are encoded using a shared BERT encoder.
- Token-Level Matching: MGE performs a token-level dot-product between the response and each context turn, generating a matching matrix that identifies relevant segments of the response.
- Refinement: This matrix filters the response embedding to produce a context-aware representation ($\tilde{R}$), effectively viewing the response through the lens of the preceding conversation.
- Contrastive Objective: The model is trained to minimize the distance between the context-free embedding (the response alone) and its context-aware counterpart, while maximizing the distance from unrelated dialogue samples.
This approach eliminates the need for an additional multi-layer perceptron (MLP) at inference time, ensuring that the learned embeddings are optimized for direct similarity comparisons.
Experimental Setup
We evaluated DialogueCSE on three diverse multi-turn dialogue datasets: the task-oriented Microsoft Dialogue Corpus (MDC), the large-scale Chinese Jing Dong Dialogue Corpus (JDDC), and the E-commerce Dialogue Corpus (ECD) from Taobao. To accurately measure performance in conversational contexts, we established two new evaluation benchmarks: Semantic Retrieval (SR) and Dialogue-based Semantic Textual Similarity (D-STS), comprising over 22,000 annotated samples.
Results and Discussion
DialogueCSE achieves state-of-the-art results across all tested datasets. On the MDC dataset, the model improved Mean Average Precision (MAP) from 76.26% (SiameseBERT) to 91.40%. Significant gains were also observed in Spearman’s correlation, with an improvement of up to 8.49 points on the ECD dataset.
Key Insights
- Context Utility and Noise: As shown in the figure above, performance typically peaks when using approximately three turns of dialogue context. Beyond this point, additional turns tend to introduce more noise than useful signal, leading to a slight decline in metrics.
- MGE as a Denoising Filter: The MGE mechanism effectively acts as a filter at both token and turn levels, allowing the model to focus on relevant conversational cues while ignoring irrelevant information.
- Few-Shot Robustness: DialogueCSE demonstrates remarkable efficiency; when trained on only a small fraction of available data, it frequently outperforms baseline siamese networks trained on full datasets.
Conclusion
DialogueCSE provides a robust framework for learning conversational sentence embeddings by aligning context-free and context-aware representations. While the model shows diminishing returns with very long dialogue histories, its ability to filter noise and operate effectively in low-data scenarios marks a significant advancement. Future work will explore integrating this contrastive objective into the initial pre-training phases of large language models and incorporating more complex speaker interaction dynamics.
Summary updated