Density-Aware Prototypical Network for Few-Shot Relation Classification

Jianfeng Wu, Mengting Hu, Yike Wu, Bingzhe Wu, Yalan Xie, Mingming Liu, Renhong Cheng

Abstract

Few-shot relation classification (FSRC) often fails when query instances do not belong to any predefined categories, a scenario known as the "None-Of-The-Above" (NOTA) problem. Traditional methods attempt to model NOTA as an additional class, which fails to capture the diverse, outlier nature of such instances. This paper introduces D-Proto (Density-Aware Prototypical Network), a framework that treats NOTA detection as an outlier detection task. By shaping the embedding space to create dense clusters for known relations and utilizing a novel Prototype enhanced Local Outlier Factor (PLOF), D-Proto significantly improves performance and robustness in realistic, variable-rate NOTA environments.

Introduction

Relation Classification (RC) identifies semantic links between entities in text. In few-shot settings, models must generalize from minimal examples. However, real-world deployment often involves "None-Of-The-Above" (NOTA) instances—queries that do not match any provided support classes. Existing "N+1" class approaches struggle because NOTA instances are heterogeneous and do not form cohesive clusters. D-Proto addresses this by modeling known classes as dense regions and identifying NOTA instances as outliers in the "void" between these regions.

Methodology

D-Proto consists of a specialized training phase and a density-aware inference module designed to isolate known relations from outliers.

Overview of the D-Proto framework, illustrating the training objectives for known sample separation and NOTA isolation, followed by the NOTA detection module during testing.

Training Objectives

The model employs two primary losses to structure the embedding space:

  1. Known Sample Separation (NCA Loss): Uses Neighborhood Component Analysis to pull samples of the same relation together and push different relations apart, creating tight, distinct clusters.
  2. NOTA Sample Isolation Loss: Explicitly pushes NOTA instances away from known class clusters to prevent false positives.

NOTA Detection Module

During inference, a NOTA Score is calculated for each query based on two factors:

  • Prototype enhanced Local Outlier Factor (PLOF): To enhance density estimation, the model generates "degenerative prototypes" from subsets of support samples. It then applies a modified Local Outlier Factor algorithm to detect if a query sits in a low-density region relative to these prototypes.
  • Base Score: A ratio of the distance to the nearest prototype versus the farthest prototype. Known relations exhibit a small ratio, while NOTA instances yield larger values.

Experiments and Results

The model was evaluated on FewRel 1.0 and 2.0 benchmarks using both fixed and random NOTA sampling strategies. Random sampling is considered a more realistic simulation of real-world deployment.

Performance and Robustness

D-Proto outperformed state-of-the-art baselines like MCMN by +2.75% accuracy and +2.66% F1 score in realistic random sampling settings. Notably, while other models' performance degraded significantly as the NOTA rate increased (e.g., MCMN dropping over 13%), D-Proto remained stable with only a ~2.5% decrease.

t-SNE visualizations comparing D-Proto against O-Proto and MNAV at different NOTA rates. D-Proto demonstrates tighter, more separable clusters for known relations.

Comparison with LLMs

D-Proto was compared against GPT-3.5 (ChatGPT), which performed roughly 20% lower in accuracy on the NOTA task. This suggests that specialized, density-aware models are more effective for high-precision, few-shot RC than general-purpose large language models.

Conclusion

D-Proto shifts the paradigm of NOTA detection from classification to outlier detection. By focusing on the density of known classes and using degenerative prototypes, it achieves superior robustness. Future work includes automating threshold selection and extending density-aware techniques to other few-shot NLP tasks.

Summary updated

BibTeX
@inproceedings{wu2023density,
  author = {Jianfeng Wu and Mengting Hu and Yike Wu and Bingzhe Wu and Yalan Xie and Mingming Liu and Renhong Cheng},
  title = {{Density-Aware Prototypical Network for Few-Shot Relation Classification}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.162},
}
Figure