{'fraction_non_alphanumeric': 0.023521932612841703, 'fraction_numerical': 0.0025429116338207248, 'mean_word_length': 5.296, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Task-Aware Feature Composition for Few-Shot Relation Classification

Relation classification tends to struggle when training data are limited or when it needs to adapt to unseen categories. In such challenging scenarios, recent approaches employ the metric-learning framework to measure similarities between query and support examples and to determine relation labels of the query sentences based on the similarities. However, these approaches treat each support class independently from one another, never looking at the entire task as a whole. Because of this, they are constrained to using a shared set of features for all meta-tasks, which hinders the ability to compose discriminative features for the task at hand. For example, if two similar relation types occur in a meta-task, the model needs to construct more detailed, task-related features instead of common features shared by all tasks. In this paper, we propose a novel task-aware relation classification model to tackle this issue. We first build a task embedding component to capture task-specific information, after which two mechanisms, such as task-specific gate and gated feature combination methods, are proposed to utilize the task-specific information to guide feature composition dynamically for each meta-task. Experiment results show that our model improves performance considerably over high performing baseline systems on both FewRel 1.0 and FewRel 2.0 benchmarks. Moreover, our proposed methods can be incorporated into metric-learning-based methods and significantly improve their performance.