# Task-Aware Feature Composition for Few-Shot Relation Classification
###### Abstract  
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. relation classification; few-shot learning; task embedding +
Footnote †: journal:  
Many methods have been proposed to approach this problem, among which, the prototypical network [9] is a simple and effective method. It iteratively samples some classes and their corresponding labeled support sentences from the whole training set to construct meta-tasks. If a meta-task contains N classes, and there are K labeled support sentences in each corresponding class, the task is called N-way-K-shot. After constructing meta-tasks, it first utilizes a context encoder to map query sentences and supporting sentences into distributed feature representations, then the feature representations of supporting sentences from each class are averaged and treated as prototype representations of these classes. Finally, the labels of query sentences are determined by computing distances or matching degrees to prototype representations. Since the method is simple and effective, lots of similar methods [10; 11; 12] have been proposed. Despite the great success of these approaches, all of them treat each class in each meta-task separately, not as a whole, and do not take into account the specific characteristics of each meta-task, which results in two limitations of these approaches. First, since very few labeled data are available for each meta-task, it is imperative to make the best use of all of the information available from the full set of examples. Neglecting the information from the whole view will cause information loss. Second, the class set of each meta-task is not overlapped with each other. If models treat all meta-tasks equally without considering their specific characteristics, the models will compose a shared feature set for all tasks, which is unreasonable [13]. Take the two meta-tasks in Figure 1 as an example. In meta-task1, as the support sentence S1, S2 of class A \"father\" and class B \"mother\" share similar lexical and syntax clues, models need to pay much attention to pronouns such as \"She\" of S1 and \"He\" of S2 to make a correct prediction. However, in meta-task2, since class A \"sport\" and class B \"military_rank\" have distinct lexical and syntax clues, the models can predict correctly without considering pronouns. Using the same feature set learned from meta-task1, which always focuses on pronouns, we could reduce the weights of discriminative features, leaving potential hazards for other meta-tasks.