Watch the Neighbors: A Unified K-Nearest Neighbor Contrastive Learning Framework for OOD Intent Discovery

Yutao Mou, Keqing He, Pei Wang, Yanan Wu, Jingang Wang, Wei Wu, Weiran Xu

Introduction

In task-oriented dialogue systems like Alexa or Siri, "intent discovery" is the process of grouping unknown user queries into new categories. For instance, if a system is trained on "Check Balance" but receives "I lost my credit card," it must recognize this as a new, distinct intent. Current methods face two primary hurdles: In-domain Overfitting, where known categories are made too compact, crushing natural data diversity; and the Clustering-Representation Gap, where traditional contrastive learning pushes similar unknown instances apart because their shared identity is not yet recognized.

The KCOD Framework

To address these challenges, the authors propose KCOD (K-nearest neighbor Contrastive learning framework for OOD intent discovery). This framework operates in a unified two-stage process: pre-training on known data and clustering on unknown data.

The KCOD framework overview, illustrating the two-stage process: IND pre-training with KCL and OOD clustering with KCC.

Stage 1: KCL for Pre-training

Standard Supervised Contrastive Learning (SCL) forces all samples in a known category to be nearly identical. KCOD replaces this with K-nearest neighbor Contrastive Learning (KCL). Instead of pulling a sample toward a class centroid, KCL only pulls it toward its $K$ nearest neighbors within that class.

Comparison between standard Supervised Contrastive Learning (SCL) and the proposed K-nearest neighbor Contrastive Learning (KCL). KCL preserves intra-class diversity, preventing overfitting to known categories.

This approach maintains "intra-class diversity," allowing the model to learn linguistic nuances that are crucial for generalizing to entirely new Out-of-Domain (OOD) categories later.

Stage 2: KCC for Discovery

During the OOD discovery phase, the model groups unlabeled data using K-nearest neighbor Contrastive Clustering (KCC). KCC employs two key mechanisms to bridge the clustering-representation gap:

  • False Negative Filtering: A similarity threshold prevents the model from accidentally pushing away samples that likely belong to the same cluster.
  • Hard Negative Mining: The model identifies the $K$ nearest samples outside the current cluster and focuses on pushing them away, sharpening cluster boundaries.

Experimental Evaluation

KCOD was evaluated on three major intent discovery benchmarks: Banking (13,083 queries), HWU64 (25,716 utterances), and CLINC (22,500 queries). In a semi-supervised setup, a portion of intents were treated as known (In-Domain or IND) and the rest as unknown (OOD) to be discovered.

Key Results

KCOD achieved state-of-the-art (SOTA) performance across all datasets, significantly outperforming previous methods like DKT and DeepAligned.

  • Accuracy Gains: On the Banking dataset, KCOD improved clustering accuracy by approximately 4.6% over the previous best method.
  • Robustness: The framework remained effective even with incorrect estimates for the number of clusters, demonstrating real-world viability where the true number of intents is often unknown.
  • Visual Clarity: T-SNE visualizations confirmed that KCOD produces tighter, more distinct clusters with fewer outliers compared to baselines.

Conclusion and Future Work

KCOD demonstrates that preserving diversity in known categories is a feature, not a bug, for OOD discovery. By focusing on local neighborhoods rather than global centroids, the framework successfully bridges the gap between representation learning and clustering. Future work may explore self-supervised neighbor discovery to remove the dependency on labeled IND data and test the framework on broader NLP tasks like long-form document discovery.

Presented at EMNLP 2022.

Summary updated

BibTeX
@inproceedings{mou2022watch,
  author = {Yutao Mou and Keqing He and Pei Wang and Yanan Wu and Jingang Wang and Wei Wu and Weiran Xu},
  title = {{Watch the Neighbors: A Unified K-Nearest Neighbor Contrastive Learning Framework for OOD Intent Discovery}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.emnlp-main.98},
}
Figure