Discriminative Nearest Neighbor Few-Shot Intent Detection by Transferring Natural Language Inference

Jianguo Zhang, Kazuma Hashimoto, Wenhao Liu, Chien-Sheng Wu, Yao Wan, Philip S. Yu, Richard Socher, Caiming Xiong

Introduction

Intent detection is a cornerstone of goal-oriented dialogue systems. However, real-world deployment faces two significant challenges: data scarcity in few-shot scenarios and the need to robustly identify out-of-scope (OOS) queries. Traditional multi-class classifiers often fail here, as they tend to overconfidently map OOS inputs to known categories, leading to poor user experiences when the system encounters requests it wasn't trained to handle.

Methodology

The authors introduce Discriminative Nearest Neighbor Classification (DNNC), which reframes intent detection as a pairwise matching task. Unlike standard models that learn global intent representations, DNNC utilizes a BERT-style architecture to perform deep self-attention across a pair of sentences—the user input and a labeled training example—to determine if they share the same intent.

To enhance the model's semantic understanding, it is pre-trained on Natural Language Inference (NLI) datasets. By learning to identify entailment, the model gains a powerful proxy for recognizing intent similarity. During inference, the system compares user input against the training set; if the highest similarity score falls below a specific threshold, the input is classified as OOS. To maintain real-time performance, a DNNC-joint variant uses a fast bi-encoder (like SBERT) to retrieve the top-$k$ candidates before applying the more computationally intensive DNNC model.

Key Insights: The "Gap" Problem

DNNC's primary advantage is its focus on local relationships between utterances rather than global class boundaries. This fine-grained comparison allows the model to detect subtle semantic differences that distinguish in-domain requests from OOS ones.

t-SNE visualizations showing the separation of in-domain intent classes and out-of-scope intents across different models.

As illustrated in the t-SNE visualizations above, standard classifiers often cluster OOS points closely with in-domain data. In contrast, DNNC creates a distinct separation, effectively treating OOS detection as a "gap" problem where unknown intents fall into the empty spaces between well-defined clusters, making threshold-based rejection far more reliable.

Key Results

Empirical evaluations on the CLINC150 benchmark demonstrate DNNC's superiority in both few-shot accuracy and OOS detection:

  • Few-Shot Performance: In a 10-shot banking domain setting, DNNC achieved 91.2% in-domain accuracy, rivaling a 50-shot traditional classifier (90.0%).
  • OOS Mastery: At 5-shot, DNNC's OOS precision reached 64.7%, nearly doubling the 36.8% achieved by a standard RoBERTa classifier.
  • Efficiency: The DNNC-joint optimization reduced inference latency from 697ms to just 37ms per example with negligible impact on accuracy, proving its viability for production environments.
Performance metrics (In-domain accuracy, OOS recall, and OOS precision) as a function of the confidence threshold T.

The performance curves highlight that DNNC maintains high in-domain accuracy while significantly improving OOS recall and precision compared to baseline classifiers across various thresholds.

Conclusion

By transferring knowledge from NLI and adopting a discriminative nearest neighbor approach, DNNC provides a robust solution for few-shot intent detection. It excels where traditional models struggle, particularly in the critical task of identifying out-of-scope user queries. Future research may explore extending this framework to cross-lingual settings and further optimizing retrieval for massive intent taxonomies.

Summary updated

BibTeX
@inproceedings{zhang2020discriminative,
  author = {Jianguo Zhang and Kazuma Hashimoto and Wenhao Liu and Chien-Sheng Wu and Yao Wan and Philip S. Yu and Richard Socher and Caiming Xiong},
  title = {{Discriminative Nearest Neighbor Few-Shot Intent Detection by Transferring Natural Language Inference}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2020},
  doi = {10.18653/v1/2020.emnlp-main.411},
}
Figure