Knowledge Guided Metric Learning for Few-Shot Text Classification

Dianbo Sui, Yubo Chen, Binjie Mao, Delai Qiu, Kang Liu, Jun Zhao

Abstract

Few-shot text classification aims to categorize text with minimal labeled examples. Traditional metric learning approaches often use a static distance function, which fails to capture task-specific nuances. This paper proposes a Knowledge Guided Relation Network that leverages external knowledge bases to dynamically generate task-specific metrics. By using a parameter generator network, the model adapts its classification logic based on retrieved domain knowledge. Experimental results on the Amazon Reviews Sentiment Classification (ARSC) dataset demonstrate that this approach significantly outperforms existing state-of-the-art models, achieving a mean accuracy of 87.93%.

Introduction

Few-shot learning (FSL) is the challenge of training a model to recognize new categories using only a handful of examples. In text classification, most current approaches use metric learning: they learn a distance function to determine if two pieces of text belong to the same category. However, a "one-size-fits-all" metric is fundamentally flawed for text because words that are highly informative for one task (e.g., "durable" in a kitchen appliance review) might be irrelevant for another (e.g., a book review). Humans solve this by using prior knowledge about the world to focus on what matters for a specific context. This paper aims to bridge that gap by injecting external knowledge into the metric-learning process.

Methodology

The authors propose the Knowledge Guided Relation Network, which consists of three main components:

  1. Sentence Embedding Network: A pre-trained BERT model converts sentences into vector representations.
  2. Dual-Path Relation Network: Instead of one metric, the model uses two:
  3. Task-Agnostic Relation Network: A standard network that learns a general similarity function applicable to all tasks.
  4. Task-Relevant Relation Network: This uses a Parameter Generator Network to create custom weights for the metric based on external knowledge retrieved for that specific task.
  5. Knowledge Retrieval and Embedding: The model uses NELL (Never-Ending Language Learning) as its external knowledge base. It performs entity linking via string matching to find relevant concepts, which are represented as distributed embeddings to ensure better generalization.
Architecture of the Knowledge Guided Relation Network, illustrating the dual-path similarity scoring and the integration of external knowledge via a parameter generator.

Experimental Setup

The model was evaluated on the ARSC (Amazon Reviews Sentiment Classification) dataset, which contains reviews for 23 different product domains. Each domain has three binary classification tasks, totaling 69 tasks. Following standard few-shot protocols, 12 tasks from four domains were held out for testing. The experiments focused on the 5-shot setting, where only 5 labeled examples per class are provided.

Results and Discussion

The proposed model achieved a mean accuracy of 87.93% on the ARSC dataset, setting a new state-of-the-art.

Comparison of the proposed model against various few-shot learning baselines, showing its superior performance on the ARSC dataset.

Key Insights

  • Task-Level Knowledge: Most knowledge-enhanced models inject knowledge directly into embeddings. This paper argues it is more effective to inject knowledge at the task level—using it to decide how to compare examples.
  • Dynamic Metric Generation: By using a parameter generator, the model reconfigures its own internal logic for every new task it encounters.
  • Ablation Study: Removing the task-relevant network dropped accuracy to 86.09%. Replacing it with a standard network of the same size resulted in 86.40% accuracy, confirming that the external knowledge was the primary driver of performance.

Conclusion

The Knowledge Guided Relation Network demonstrates that external knowledge can significantly enhance few-shot text classification by enabling dynamic, task-specific metrics. While the current system relies on exact string matching for retrieval, future work could explore more robust retrieval mechanisms and apply this parameter generation approach to other domains like image recognition.

Summary updated

BibTeX
@inproceedings{sui2021knowledge,
  author = {Dianbo Sui and Yubo Chen and Binjie Mao and Delai Qiu and Kang Liu and Jun Zhao},
  title = {{Knowledge Guided Metric Learning for Few-Shot Text Classification}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.naacl-main.261},
}
Figure