Incremental Few-shot Text Classification with Multi-round New Classes: Formulation, Dataset and System (2021)

Abstract: Text classification is usually studied by labeling natural language texts with relevant categories from a predefined set. In the real world, new classes might keep challenging the existing system with limited labeled data. The system should be intelligent enough to recognize upcoming new classes with a few examples. In this work, we define a new task in the NLP domain, incremental few-shot text classification, where the system incrementally handles multiple rounds of new classes. For each round, there is a batch of new classes with a few labeled examples per class. Two major challenges exist in this new task: (i) For the learning process, the system should incrementally learn new classes round by round without re-training on the examples of preceding classes; (ii) For the performance, the system should perform well on new classes without much loss on preceding classes. In addition to formulating the new task, we also release two benchmark datasets in the incremental few-shot setting: intent classification and relation classification. Moreover, we propose two entailment approaches, ENTAILMENT and HYBRID, which show promise for solving this novel problem.

## introduction text classification has achieved great success in the past decades with the development of deep learning techniques @xcite . however, decent performance highly relies on the availability of large-scale task-specific training data. recently, few-shot text classification @xcite @xcite has attracted increasing attention from the nlp community since it is unlikely to have large-scale labeled data for new classes in the real world. typically, few-shot text classification is formulated like this: the system first sees a set of base classes c b that have a large number of labeled examples, then a group of new classes c n is provided with k examples per class. for a testing instance, the system is required to search for its label in the space of c b ∪ c n or merely c n . however, this setting might not suitable for real scenarios. first, base classes with rich annotations might not be available at the beginning. it happens whenever you want to build a system from scratch. second, take the bank's customer service system as an example, queries with new intents are continuously appearing (e.g., by a sequence of rounds) without enough labeled data. the system should be able to keep learning and recognizing new intents round by round. for each query, the system needs to pick up the most appropriate intent in the incrementally increasing label space or return "none of them". in this work, we propose a more realistic and challenging task in the low resource scenarios: incremental few-shot text classification. in this new task, the system is provided with m rounds of new classes (i.e., c 1 n , c 2 n , • • • , c m n ) without any base classes that have enough annotations. for each round, there are a group of new classes, c i n (@xmath0, • • • , m), and each class has k labeled examples (k is in the range of @xcite and varies for different classes). during testing, the system is required to either select the best class from c 1 n ∪c 1 n • • •∪c m n or output "none of them" which means no existing class applies to the input. as far as we know, this is the first work that studies incremental few-shot learning without base classes. all previous fewshot learning models @xcite @xcite @xcite fail to solve this problem since they relied on the large-scale labeled data of base classes to train a robust system. to provide a complete vision about incremental few-shot text classification, we also conduct experiments with additional base classes to compare with these baselines. to evaluate the performance for different models, we build two benchmark datasets for this new problem. one is intent detection that aims at understanding the intents under user queries @xcite . this benchmark simulates a task like a bank's customer service as we mentioned. the other is relation classification which needs to determine the correct relation between two entities in a given sentence @xcite . in reality, the relation types might be unlimited. for example, there are fine-grained relations or implicit relations that need entailment. in opendomain or open-form relation tasks, there always exists the problem of lack of annotations. another important feature of our benchmark datasets is that we do not provide dev sets. existing systems are commonly evaluated on the dev set to choose the best training model. we claim that in real-world (incremental) few-shot applications, we cannot expect extra labeled data other than the k examples. this is in line with the observation in @xcite . if a system has to rely on the dev set to find the best parameters, it is not suitable for the incremental few-shot setting. furthermore, we propose a novel approach, en-tailment, to solve this new problem. entail-ment models the text classification problem in a textual entailment @xcite framework. to figure out if an input x belongs to a class y, entailment tries to infer the truth value of y (i.e., a hypothesis), given the x (i.e, the premise). the main benefit of this formulation is that the system learns this task not only from label-specific examples, but more importantly, from the largescale entailment datasets. in other words, we make use of indirect supervision from textual entailment datasets to address the target few-shot task. in summary, our contribution lies in three aspects. 1) we propose a new task named incremental few shot text classification with multi-round new classes. this task is more challenging and realistic for low resource scenarios. 2) we create and release two benchmark datasets to evaluate the performance of this new task. 3) we propose two novel models, entailment and hybrid, to solve this novel problem. extensive experiments on these two datasets show the effectiveness of our proposed models. in @xcite , the base representations w b are learned through supervised pre-training. the representation of the i th novel class (w n,i ) comes from two origins: (i) the prototypical averaging, w avg ; (ii) attention-weighted sum over base representations: w att . namely, w n,@xmath1, where φ avg and φ att are learnable weight vectors. in the fewshot training stage, the original base classes c b are split into "new base classes" and "fake novel classes" for each episode. in testing, the representations of novel classes, w n , are constructed based on the k examples and w b . in @xcite , both w b and w n are learned through supervised training: w b are classifier parameters pre-trained on base classes, w n are classifier parameters learned in new classes. during the training, the support set and the query set are constructed differently for new classes. the support set consists of examples only from new classes; the query set contains examples from both new classes and base classes (because the training goal is to maximize the performance of all classes). the training in this literature has two phases. the first phase is few-shot episode training which learns w n , the second phase (called meta-learning training) optimizes the performance on the query set and regularizes the representations for new classes. to summarize, compared with snell et al. (2017) and @xcite , both @xcite and @xcite build connections between the representations of base classes and the new classes. however, these methods cannot be directly applied to our problem for the following reasons. (i) despite the claims in some literature that they are dealing with incremental or dynamic few-shot problems, they only considered a single round of new classes @xcite @xcite . it is unclear if the system can keep the performance when multiround new classes are considered. (ii) during the training for the new classes, they often rely on extra labeled data other than the k examples, such as the query set in @xcite . (iii) different from their setting, we have an extra label "none-of-them" in incremental few-shot text classification. it's not guaranteed that the input, such as the customer's utterance, always falls into the range of seen labels. using textual entailment for text classification. @xcite is a state-of-the-art paper for few-shot text classification. they propose a clustering-based classifier named discriminative nearest neighbor classification (dnnc). dnnc compares whether two examples are in the same class or not. a matching model s(x i , x j ) is trained as a binary classifier, such that s(x i , x j ) is close to 1.0 if x i and x j belong to the same class, otherwise close to 0.0. thus, their model can be pre-trained with a large-scale textual entailment dataset. given a test query x, they compare the test query with all the previous examples. the final prediction is made by searching the nearest neighbor which has the highest matching score s(x, x i ) with the query example. their computation cost is high due to the comparision between all the utterance pairs. moreover, comparing whether two examples are in the same class is different from textual entailment. in textual entailment, a person reads a premise to infer that the hypothesis is true or not. the fact that two examples are in the same class does not mean they can entail each other. thus, they cannot fully utilize the pre-trained entailment model. instead, our proposed model, entail-ment, entails the label with a given utterance, which is much more efficient and maximizes the utilization of the pre-trained entailment model. @xcite is another work that utilizes textual entailment for zero-shot text classification. they convert the zero-shot text classification as a problem of filling a label for a hypothesis. for example, they combine "emotion" labels with the question "this text expresses ?", and ask the model if this hypothesis is true, given the text. this work more focuses on zero-shot learning and they need to propose different questions for different labels. ## problem formulation in this section, we give a formal description of the problem "incremental few-shot text classification" without base classes. furthermore, we extend the problem with additional base classes. training data. in the incremental few-shot text classification setting, the system is provided with m rounds of new classes sequentially: @xcite ). the value of k is not fixed and varies for different new classes in the same round, i.e., k c i n,@xmath2,t , where s, @xmath3, ..., h]. for the setting with additional base classes, the system can access a set of base classes c @xmath4,1 , c b,2 , • • • , c b,g }. all the base classes c b have enough labeled examples for training. we create the multi-round setting to mimic the real-world scenario where there is a sequence of new classes coming to the system. since we can only collect a handful of examples for the upcoming classes and the number of examples cannot be guaranteed, we set @xmath5, 5] and allow the flexibility that k c i n,@xmath6,t in each round. development data. in the incremental few-shot setting, there are only k examples available for each new class. thus, our formulation does not provide any development set to help select the best model. it is recommended to select hyperparameters based on experience or related tasks. in the experiments, we choose hyper-parameters like batch size based on the suggestions by huggingface foot_0 and other papers like @xcite and @xcite . testing data. to evaluate the system, the test data consists of examples across all the classes. for the setting without base classes, the potential label space is c o is an extra out-of-distribution (ood) class that consists of examples falling outside of all the seen classes. it gives us a chance to check the system's ability to detect instances that reject all the known classes. this is crucial for an open-set problem like incremental learning since there are always examples from upcoming classes that do not belong to any existing class. requirements. (i) for the training of i th round c i n , the system can only access the newly added few-shot examples and label names in this round. the system is not allowed to re-train on the (full or partial) examples of preceding classes. (ii) for the evaluation, we care about the performance in different types of classes, including base classes, different rounds of new classes, and ood classes in c o . we expect a system that can continuously recognize new classes with few-shot examples. in the meantime, the performance of preceding classes should be maintained. a system showing severer catastrophic forgetting is less preferred. ## our model: entailment our approach entailment casts the text classification problem into textual entailment: the input text acts as a premise, the class name, such as "open a bank account" in intent detection , acts as a hypothesis. then the question that if the input belongs to a class is equivalent to ask if the hypothesis is true given the premise. there are two benefits of transforming the text classification problem to entailment. first, we can make use of indirect supervision from a large-scale entailment dataset @xcite to benefit the fewshot settings. second, this enables us to utilize the few-shot examples as well as the information of the class names. typical text classification approaches treat classes as indices. in fact, class names usually contain informative signals. entailment pairs. to transfer the text classification problem into textual entailment, we construct positive and negative entailment pairs for the training. positive entailment pairs (x i , y i ) are constructed with utterance x i and its gold label name y i , where y @xmath7. negative entailment pairs consist of (x i , y j ), where y j is an incorrect label in the current round. for base classes, y @xmath8; for new classes, y @xmath9. for each entailment pair (x, y) whether it is positive or negative, we concatenate its utterance x with the label y and fed it into the roberta @xcite encoder. given an utterance @xmath10, x 2 , ..., x t 2 ) with t 1 words and a label @xmath11, y 2 , ..., y t 2 ) with t 2 words, we add a special start-of-sequence ([cls]) token at the beginning of the input and a special end-of-sequence ([sep]) token at the end of each sentence. the whole input is ( training strategy. both entailment and hy-brid are binary classification models that can utilize indirect supervision from textual entailment. firstly, we pre-train these models with a large-scale entailment dataset @xcite . for each round, models are fine-tuned on the new classes in c i n . for the setting with additional base classes, we fine-tune the models on base classes first. then we continuously fine-tune the models on new classes. inference strategy. after the training, we use the model to infer the class for a test input. for each input utterance, we generate entailment pairs by accompanying the utterance with all classes except c o . each pair will get a score λ ∈ [0, 1] indicating whether this input belongs to the particular class or not. λ > 0.5 indicates "yes", "no" otherwise. if there is at least one class labeled with "yes", the class with the maximal λ score is returned; otherwise, the system returns c o . we choose the threshold as 0.5 because entailment recognition is a binary classification problem. next, we compare our model with some related systems that can be potentially applied to the incremental few-shot text classification. entailment vs. prototypical network. prototypical network @xcite tries to solve few-shot target tasks given a collection of training tasks. the few-shot learning problem solved in prototypical network is slightly different from our incremental few-shot setting. in prototypical network, the label space for target tasks only contains the new classes. however, in the incremental fewshot setting, the target label space is continuously increasing by adding new classes. due to this essential distinction, applying prototypical network to incremental few-shot are very likely to have performance drop on base classes when fine-tuning on new classes. entailment vs. incremental few-shot approaches in computer vision. in related work, we introduced some typical approaches in computer vision that deal with the incremental few-shot problem. those methods consistently try to learn representations for classes and examples separately (i.e" the w b and w n in section 2). in our model, there are no individual representation vectors for classes or examples. instead, the model learns an overall representation vector for the whole (input, class) pair. our solution enables the learning of the input and the class to interact with each other, which has widely demonstrated its superiority in modeling the relations of two elements @xcite . in addition, the approaches in computer vision mostly rely on large-scale labeled data for base classes to train a robust system. we would argue ## conclusion in this work, we define a new challenge in the nlp domain, incremental few-shot text classification with multi-round new classes in two settings: with or without base classes. in addition to the problem formulation, we also release two benchmark datasets for this particular challenge: ifs-intent and ifs-relation. two approaches, entailment and hybrid are proposed to solve this problem. they convert the text classification problem into textual entailment and make the maximum utilization of the pre-training textual entailment model. extensive experiments are conducted and the results consistently show the effectiveness of our proposed models.