Induction Networks for Few-Shot Text Classification

Text classification tends to struggle when data is deficient or when it needs to adapt to unseen classes. In such challenging scenarios, recent studies have used meta-learning to simulate the few-shot task, in which new queries are compared to a small support set at the sample-wise level. However, this sample-wise comparison may be severely disturbed by the various expressions in the same class. Therefore, we should be able to learn a general representation of each class in the support set and then compare it to new queries. In this paper, we propose a novel Induction Network to learn such a generalized class-wise representation, by innovatively leveraging the dynamic routing algorithm in meta-learning. In this way, we find the model is able to induce and generalize better. We evaluate the proposed model on a well-studied sentiment classification dataset (English) and a real-world dialogue intent classification dataset (Chinese). Experiment results show that on both datasets, the proposed model significantly outperforms the existing state-of-the-art approaches, proving the effectiveness of class-wise generalization in few-shot text classification.


Introduction
Deep learning has achieved a great success in many fields such as computer vision, speech recognition and natural language processing (Kuang et al., 2018). However, supervised deep learning is notoriously greedy for large labeled datasets, which limits the generalizability of deep models to new classes due to annotation cost. Humans on the other hand are readily capable of rapidly learning new classes of concepts with few examples or stimuli. This notable gap provides a fertile ground for further research. * * Corresponding authors: Y. Li and P.Jian. Few-shot learning is devoted to resolving the data deficiency problem by recognizing novel classes from very few labeled examples. The limitation of only one or very few examples challenges the standard fine-tuning method in deep learning. Early studies (Salamon and Bello, 2017) applied data augmentation and regularization techniques to alleviate the overfitting problem caused by data sparseness, only to a limited extent. Instead, researchers have explored meta-learning (Finn et al., 2017) to leverage the distribution over similar tasks, inspired by human learning. Contemporary approaches to few-shot learning often decompose the training procedure into an auxiliary metalearning phase, which includes many meta-tasks, following the principle that the testing and training conditions must match. They extract some transferable knowledge by switching the metatask from mini-batch to mini-batch. As such, fewshot models can classify new classes with just a small labeled support set.
However, existing approaches for few-shot learning still confront many important problems, including the imposed strong priors (Fei-Fei et al., 2006), complex gradient transfer between tasks (Munkhdalai and Yu, 2017), and fine-tuning the target problem (Qi et al., 2018). The approaches proposed by Snell et al. (2017) and Sung et al. (2018), which combine non-parametric methods and metric learning, provide potential solutions to some of those problems. The non-parametric methods allow novel examples to be rapidly assimilated, without suffering from catastrophic overfitting. Such non-parametric models only need to learn the representation of the samples and the metric measure. However, instances in the same class are interlinked and have their uniform fraction and their specific fractions. In previous studies, the class-level representations are calculated by simply summing or averaging represen-tations of samples in the support set. In doing so, essential information may be lost in the noise brought by various forms of samples in the same class. Note that few-shot learning algorithms do not fine-tune on the support set. When increasing size of the support set, the improvement brought by a bigger data size will also be diminished by more sample level noises.
Instead, we explore a better approach by performing induction at the class-wise level: ignoring irrelevant details and encapsulating general semantic information from samples with various linguistic forms in the same class. As a result, there is a need for a perspective architecture that can reconstruct hierarchical representations of support sets and dynamically induce sample representations to class representations.
Recently, capsule network (Sabour et al., 2017) has been proposed, which possesses the exciting potential to address the aforementioned issue. A capsule network uses "capsules" that perform dynamic routing to encode the intrinsic spatial relationship between parts and whole that constitutes viewpoint invariant knowledge. Following a similar spirit, we can regard samples as parts and class as a whole. We propose the Induction Networks, which aims to model the ability of learning generalized class-level representation from samples in a small support set, based on the dynamic routing process. First, an Encoder Module generates representations for a query and support samples. Next, an Induction Module executes a dynamic routing procedure, in which the matrix transformation can be seen as a map from the sample space to the class space, and then the generation of the class representation is all depending on the routing-by-agreement procedure other than any parameters, which renders a robust induction ability to the proposed model to deal with unseen classes. By regarding the samples' representations as input capsules and the classes' as output capsules, we expect to recognize the semantics of classes that is invariant to sample-level noise. Finally, the interaction between queries and classes is modelled-their representations are compared by a Relation Module to determine if the query matches the class or not. Defining an episodebased meta-training strategy, the holistic model is meta-trained end-to-end with the generalizability and scalability to recognize unseen classes.
The specific contributions of our work are listed as follows: • We propose the Induction Networks for fewshot text classification. To deal with samplewise diversity in the few-shot learning task, our model is the first, to the best of our knowledge, that explicitly models the ability to induce class-level representations from small support sets.
• The proposed Induction Module combines the dynamic routing algorithm with typical meta-learning frameworks. The matrix transformation and routing procedure enable our model to generalize well to recognize unseen classes.
• Our method outperforms the current state-ofthe-art models on two few-shot text classification datasets, including a well-studied sentiment classification benchmark and a realworld dialogue intent classification dataset.
2 Related Work

Few-Shot Learning
The seminal work on few-shot learning dates back to the early 2000s (Fe-Fei et al., 2003;Fei-Fei et al., 2006). The authors combined generative models with complex iterative inference strategies. More recently, many approaches have used a meta-learning (Finn et al., 2017;Mishra et al., 2018) strategy in the sense that they extract some transferable knowledge from a set of auxiliary tasks, which then helps them to learn the target few-shot problem well without suffering from overfitting. In general, these approaches can be divided into two categories.
Optimization-based Methods This type of approach aims to learn to optimize the model parameters given the gradients computed from the fewshot examples. Munkhdalai and Yu (2017) proposed the Meta Network, which learnt the metalevel knowledge across tasks and shifted its inductive biases via fast parameterization for rapid generalization. Mishra et al. (2018) introduced a generic meta-learning architecture called SNAIL which used a novel combination of temporal convolutions and soft attention.
Distance Metric Learning These approaches are different from the above approaches that entail some complexity when learning the target few-shot problem. The core idea in metric-based fewshot learning is similar to nearest neighbours and kernel density estimation. The predicted probability over a set of known labels is a weighted sum of labels of support set samples. Vinyals et al. (2016) produced a weighted K-nearest neighbour classifier measured by the cosine distance, which was called Matching Networks. Snell et al. (2017) proposed the Prototypical Networks which learnt a metric space where classification could be performed by computing squared Euclidean distances to prototype representations of each class. Different from fixed metric measures, the Relation Network learnt a deep distance metric to compare the query with given examples (Sung et al., 2018).
Recently, some studies have been presented focusing specifically on few-shot text classification problems. Xu et al. (2018) studied lifelong domain word embeddings via meta-learning.  argued that the optimal meta-model may vary across tasks, and they employed the multimetric model by clustering the meta-tasks into several defined clusters. Rios and Kavuluru (2018) developed a few-shot text classification model for multi-label text classification where there was a known structure over the label space. Xu et al. (2019) proposed a open-world learning model to deal with the unseen classes in the product classification problem. We solve the few-shot learning problem from a different perspective and propose a dynamic routing induction method to encapsulate the abstract class representation from samples, achieving state-of-the-art performances on two datasets.

Capsule Network
The Capsule Network was first proposed by Sabour et al. (2017), which allowed the network to learn robustly the invariants in part-whole relationships. Lately, Capsule Network has been explored in the natural language processing field.  successfully applied Capsule Network to fully supervised text classification problem with large labeled datasets. Unlike their work, we study few-shot text classification. Xia et al. (2018) reused the supervised model similar to that of  for intent classification, in which a capsule-based architecture is extended to compute similarity between the target intents and source intents. Unlike their work, we propose Induction Networks for few-shot learning, in which we propose to use capsules and dynamic routing to learn generalized class-level representation from samples based. The dynamic routing method makes our model generalize better in the few-shot text classification task.

Few-Shot Classification
Few-shot classification (Vinyals et al., 2016;Snell et al., 2017) is a task in which a classifier must be adapted to accommodate new classes not seen in training, given only a few examples of each of these new classes. We have a large labeled training set with a set of classes C train . However, after training, our ultimate goal is to produce classifiers on the testing set with a disjoint set of new classes C test , for which only a small labeled support set will be available. If the support set contains K labeled examples for each of the C unique classes, the target few-shot problem is called a C-way Kshot problem. Usually, the K is too small to train a supervised classification model. Therefore, we aim to perform meta-learning on the training set, and extract transferable knowledge that will allow us to deliver better few-shot learning on the support set and thus classify the test set more accurately.

Training Procedure
The training procedure has to be chosen carefully to match inference at test time. An effective way to exploit the training set is to decompose the training procedure into an auxiliary meta-learning phase and mimic the few-shot learning setting via episode-based training, as proposed in Vinyals et al. (2016). We construct an meta-episode to compute gradients and update our model in each training iteration. The meta-episode is formed by randomly selecting a subset of classes from the training set first, and then choosing a subset of examples within each selected class to act as the support set S and a subset of the remaining examples to serve as the query set Q. The meta-training procedure explicitly learns to learn from the given support set S to minimise a loss over the query set Q. We call this strategy as episode-based meta training, and the details are shown in Algorithm 1. It is worth noting that there are exponentially many possible meta tasks to train the model on, making it hard to overfit. For example, if a dataset contains 159 training classes, this leads to Algorithm 1 Episode-Based Meta Training 1: for each episode iteration do 2: Randomly select C classes from the class space of the training set; 3: Randomly select K labeled samples from each of the C classes as support set S = {(x s , y s )} m s=1 (m = K × C), and select a fraction of the reminder of those C classes' samples as query set Q = {(x q , y q )} n q=1 ; 4: Feed the support set S to the model and update the parameters by minimizing the loss in the query set Q; 5: end for 159 5 = 794, 747, 031 possible 5−way tasks.

The Models
Our Induction Networks, depicted in Figure 1 (the case of 3-way 2-shot model), consists of three modules: Encoder Module, Induction Module and Relation Module. In the rest of this section, we will show how these modules work in each metaepisode.

Encoder Module
This module is a bi-direction recurrent neural network with self-attention as shown in Lin et al. (2017). Given an input text x = (w 1 , w 2 , ..., w T ), represented by a sequence of word embeddings. We use a bidirectional LSTM to process the text: And we concatenate − → h t with ← − h t to obtain a hidden state h t . Let the hidden state size for each unidirectional LSTM be u. For simplicity, we note all the T h t s as H = (h 1 , h 2 , ..., h T ). Our aim is to encode a variable length of text into a fixed size embedding. We achieve that by choosing a linear combination of the T LST M hidden vectors in H. Computing the linear combination requires the self-attention mechanism, which takes the whole LSTM hidden states H as input, and outputs a vector of weights a: here W a1 ∈ R da×2u and W a2 ∈ R da are weight matrices and d a is a hyperparameter. The final rep-resentation e of the text is the weighted sum of H:

Induction Module
This section introduces the proposed dynamic routing induction algorithm. We regard these vectors e obtained from the support set S by Eq 4 as sample vectors e s , and the vectors e from the query set Q as query vectors e q . The most important step is to extract the representation for each class in the support set. The main purpose of the induction module is to design a non-linear mapping from sample vector e s ij to class vector c i : We apply the dynamic routing algorithm (Sabour et al., 2017) in this module, in the situation where the number of the output capsule is one. In order to accept any-way any-shot inputs in our model, a weight-sharable transformation across all sample vectors in the support set is employed. All of the sample vectors in the support set share the same transformation weights W s ∈ R 2u×2u and bias b s , so that the model is flexible enough to handle the support set at any scale. Each sample prediction vectorê s ij is computed by: where squash is a non-linear squashing function through the entire vector, which leaves the direction of the vector unchanged but decreases its magnitude. Given input vector x, squash is defined as: Eq 5 encodes important invariant semantic relationships between lower level sample features and higher level class features (Hinton et al., 2011).
To ensure the class vector encapsulates the sample feature vectors of this class automatically, dynamic routing is applied iteratively. In each iteration, the process dynamically amends the connection strength and makes sure that the coupling coefficients d i sum to 1 between class i and all support samples in this class by a "routing softmax": / A r f 6 R + A f 6 F 9 4 Z p + A D 0 Q l J z p x 7 z 5 m 5 9 4 Z 5 z K X y v J e S M z I 6 N j 5 R n p y a n p m d m 6 8 s V N s / A r f 6 R + A f 6 F 9 4 Z p + A D 0 Q l J z p x 7 z 5 m 5 9 4 Z 5 z K X y v J e S M z I 6 N j 5 R n p y a n p m d m 6 8 s V N s / A r f 6 R + A f 6 F 9 4 Z p + A D 0 Q l J z p x 7 z 5 m 5 9 4 Z 5 z K X y v J e S M z I 6 N j 5 R n p y a n p m d m 6 8 s V N s Y c S a T P K 4 p T h E X t N 3 y H t u j k b 0 V 5 7 p k b N 6 J S A X k l K G z u k i S l P E t a n 2 S a e G W f N / u Y 9 N p 7 6 b i P 6 + 7 l X S K z C F b F / 6 S a Z / 9 X p W h Q G O D Q 1 C K o p M Y y u j u U u m e m K v r n 9 p S p F D g l x G v c p L g k z o 5 z 0 2 T a a 1 N S u e + u Z + J v J 1 K z e s z w 3 w 7 u + J Q 3 Y / T n O a d D a q 7 p O 1 T 3 d r 9 S O 8 l E X s Y V t 7 N I 8 D 1 D D M R p o k n e E R z z h 2 T q x M u v W u v 9 M t Q q 5 Z h P f l v X w A c E J k s Q = < / l a t e x i t > C ⇥ K ⇥ d < l a t e x i t s h a 1 _ b a s e 6 4 = " s E V D M 1 R o s q Z V g 3 4 K U x l 5 l p 6 f Q 4 I = " > A A A C 1 3 i c j V H L S s N A F D 2 N r / q u d e k m W A R X J R F B l 0 U 3 g p s K 9 i F V S p K O O p g X M x N R R N y J W 3 / A r f 6 R + A f 6 F 9 4 Z p + A D 0 Q l J z p x 7 z 5 m 5 9 4 Z 5 z K X y v J e S M z I 6 N j 5 R n p y a n p m d m 6 8 s V N s y K 0 T E W l E W Z 6 I b B p L F P G U t x V X M u r l g Q R L G r B O e b e t 4 5 5 w J y b N 0 X 1 3 m 7 C g J T l J + z K N A E d W v V L c P F U + Y d H d d C w b 9 S s 2 r e 2 a 5 P 4 F v Q Q 1 2 N b P K M w 4 x Q I Y I B R I w p F C E Y w S Q 9 P T g w 0 N r 1 p f V Z d u g k V w V R I R 7 L L g x p 0 V 7 A N b k S S d 1 q F 5 M Z k I p e r W H 3 C r v y X + g f 6 F d 8 Y p q E V 0 Q p I z 5 9 5 z Z u 6 9 f h r y T D r O a 8 G a m 1 9 Y X C o u l 1 Z W 1 9 Y 3 y p t b r S z J R c C a Q R I m o u N 7 G Q t 5 z J q S y 5 B 1 U s G 8 y A 9 Z 2 x 8 d q 3 j 7 h o m M J / G 5 H K f s M v K G M R / w w J N E X f T t n u Q R y + z + V b n i V B 2 9 7 F n g G l C B W Y 2 k / I I e + k g Q I E c E h h i S c A g P G T 1 d u H C Q E n e J C X G C E N d x h j u U S J t T F q M M j 9 g R f Y e 0 6 x o 2 p r 3 y z L Q 6 o F N C e g U p b e y R J q E 8 Q V i d Z u t 4 r p 0 V + 5 v 3 R H u q u 4 3 p 7 x u v i F i J a 2 L / 0 k 0 z / 6 t T t U g M U N M 1 c K o p 1 Y y q L j A u u e 6 K u r n 9 p S p J D i l x C v c p L g g H W j n t s 6 0 1 m a 5 d 9 d b T 8 T e d q V i 1 D 0 x u j n d 1 S x q w + 3 O c s 6 B 1 U H W d q n t 2 W K n X z K i L 2 M E u 9 m m e R 6 j j B A 0 0 y T v G I 5 7 w b J 1 a u X V r 3 X + m W g W j 2 c a 3 Z T 1 8 A A 2 f k t s = < / l a t e x i t > < l a t e x i t s h a 1 _ b a s e 6 4 = " W T M n V Y N f M U r q j 7 7 E c 5 N T i U 1 v D N g = " > A A A C z X i c j V H L S s N A F D 2 N r 1 p f V Z d u g k V w V R I R 7 L L g x p 0 V 7 A N b k S S d 1 q F 5 M Z k I p e r W H 3 C r v y X + g f 6 F d 8 Y p q E V 0 Q p I z 5 9 5 z Z u 6 9 f h r y T D r O a 8 G a m 1 9 Y X C o u l 1 Z W 1 9 Y 3 y p t b r S z J R c C a Q R I m o u N 7 G Q t 5 z J q S y 5 B 1 U s G 8 y A 9 Z 2 x 8 d q 3 j 7 h o m M J / G 5 H K f s M v K G M R / w w J N E X f T t n u Q R y + z + V b n i V B 2 9 7 F n g G l C B W Y 2 k / I I e + k g Q I E c E h h i S c A g P G T 1 d u H C Q E n e J C X G C E N d x h j u U S J t T F q M M j 9 g R f Y e 0 6 x o 2 p r 3 y z L Q 6 o F N C e g U p b e y R J q E 8 Q V i d Z u t 4 r p 0 V + 5 v 3 R H u q u 4 3 p 7 x u v i F i J a 2 L / 0 k 0 z / 6 t T t U g M U N M 1 c K o p 1 Y y q L j A u u e 6 K u r n 9 p S p J D i l x C v c p L g g H W j n t s 6 0 1 m a 5 d 9 d b T 8 T e d q V i 1 D 0 x u j n d 1 S x q w + 3 O c s 6 B 1 U H W d q n t 2 W K n X z K i L 2 M E u 9 m m e R 6 j j B A 0 0 y T v G I 5 7 w b J 1 a u X V r 3 X + m W g W j 2 c a 3 Z T 1 8 A A 2 f k t s = < / l a t e x i t > < l a t e x i t s h a 1 _ b a s e 6 4 = " W T M n V Y N f M U r q j 7 7 E c 5 N T i U 1 v D N g = " > A A A C z X i c j V H L S s N A F D 2 N r 1 p f V Z d u g k V w V R I R 7 L L g x p 0 V 7 A N b k S S d 1 q F 5 M Z k I p e r W H 3 C r v y X + g f 6 F d 8 Y p q E V 0 Q p I z 5 9 5 z Z u 6 9 f h r y T D r O a 8 G a m 1 9 Y X C o u l 1 Z W 1 9 Y 3 y p t b r S z J R c C a Q R I m o u N 7 G Q t 5 z J q S y 5 B 1 U s G 8 y A 9 Z 2 x 8 d q 3 j 7 h o m M J / G 5 H K f s M v K G M R / w w J N E X f T t n u Q R y + z + V b n i V B 2 9 7 F n g G l C B W Y 2 k / I I e + k g Q I E c E h h i S c A g P G T 1 d u H C Q E n e J C X G C E N d x h j u U S J t T F q M M j 9 g R f Y e 0 6 x o 2 p r 3 y z L Q 6 o F N C e g U p b e y R J q E 8 Q V i d Z u t 4 r p 0 V + 5 v 3 R H u q u 4 3 p 7 x u v i F i J a 2 L / 0 k 0 z / 6 t T t U g M U N M 1 c K o p 1 Y y q L j A u u e 6 K u r n 9 p S p J D i l x C v c p L g g H W j n t s 6 0 1 m a 5 d 9 d b T 8 T e d q V i 1 D 0 x u j n d 1 S x q w + 3 O c s 6 B 1 U H W d q n t 2 W K n X z K i L 2 M E u 9 m m e R 6 j j B A 0 0 y T v G I 5 7 w b J 1 a u X V r 3 X + m W g W j 2 c a 3 Z T 1 8 A A 2 f k t s = < / l a t e x i t > Figure 1: Induction Networks architecture for a C-way K-shot (C = 3, K = 2) problem with one query example where b i is the logits of coupling coefficients, and initialized by 0 in the first iteration. Given each sample prediction vectorê s ij , each class candidate vectorĉ i is a weighted sum of all sample prediction vectorsê s ij in class i: then a non-linear "squashing" function is applied to ensure that the length of the vector output of the routing process will not exceed 1: The last step in every iteration is to adjust the logits of coupling coefficients b ij by a "routing by agreement" method. If the produced class candidate vector has a large scalar output with one sample prediction vector, there is a top-down feedback which increases the coupling coefficient for that sample and decreases it for other samples. This type of adjustment is very effective and robust for the few-shot learning scenario because it does not need to restore any parameters. Each b ij is updated by: Formally, we call our induction method as dynamic routing induction and summarize it in Algorithm 2.

Relation Module
After the class vector c i is generated by the Induction Module and each query text in the query set is encoded to a query vector e q by the Encoder

Algorithm 2 Dynamic Routing Induction
Require: sample vector e s ij in support set S and initialize the logits of coupling coefficients b ij = 0 Ensure: class vector c i 1: for all samples j = 1, ..., K in class i: for all samples j = 1, ..., K in class i: ij · c i 9: end for 10: Return c i Module, the next essential procedure is to measure the correlation between each pair of query and class. The output of the Relation Module is called the relation score, representing the correlation between c i and e q , which is a scalar between 0 and 1. Specifically, we use the neural tensor layer (Socher et al., 2013) in this module, which has shown great advantages in modeling the relationship between two vectors (Wan et al., 2016;Geng et al., 2017). We choose it as an interaction function in this paper. The tensor layer outputs a relation vector as follows: where M k ∈ R 2u×2u , k ∈ [1, ..., h] is one slice of the tensor parameters and f is a non-linear activation function called RELU (Glorot et al., 2011).
The final relation score r iq between the i-th class and the q-th query is calculated by a fully connected layer activated by a sigmoid function.

Objective Function
We use the mean square error (MSE) loss to train our model, regressing the relation score r iq to the ground truth y q : matched pairs have similarity 1 and the mismatched pair have similarity 0. Given the support set S with C classes and query set Q = {(x q , y q )} n q=1 in an episode, the loss function is defined as: conceptually we are predicting relation scores, which can be considered as a regression problem and the ground truth is within the space { 0, 1} .
All parameters of the three modules are trained jointly by backpropagation. The Adagrad (Duchi et al., 2011) is used on all parameters in each training episode. Our model does not need any finetuning on the classes it has never seen due to its generalization nature. The induction and comparison ability are accumulated in the model along with the training episodes.

Experiments
We evaluate our model by conducting experiments on two few-shot text classification datasets. All the experiments are implemented with Tensorflow.

Datasets
Amazon Review Sentiment Classification (ARSC) Following , we use the multiple tasks with the multi-domain sentiment classification (Blitzer et al., 2007) dataset. The dataset comprises English reviews for 23 types of products on Amazon. For each product domain, there are three different binary classification tasks. These buckets then form 23 × 3 = 69 tasks in total. Following , we select 12(4 × 3) tasks from 4 domains (Books, DVD, Electronics and Kitchen) as the test set, and there are only five examples as support set for each label in the test set. We create 5-shot learning models on this dataset.  Matching Networks (Vinyals et al., 2016) 65.73 Prototypical Networks (Snell et al., 2017) 68.17 Graph Network (Garcia and Bruna, 2017) 82.61 Relation Network (Sung et al., 2018) 83.07 SNAIL (Mishra et al., 2018) 82.57 ROBUSTTC-FSL  83.12 Induction Networks (ours) 85.63 Open Domain Intent Classification for Dialog System (ODIC) We create this dataset by fetching the log data on a real-world conversational platform. The enterprises submit various dialogue tasks with a great number of intents, but many intents have only a few labeled samples, which is a typical few-shot classification application. Following the definition of the few-shot learning task, we divide the ODIC into a training set and a testing set and ensure that the labels of the two sets have no intersection. The details of the set partition are shown in Table 1.

Experiment Setup
Baselines In this section, the baseline models in our experiments are introduced as follows.
• Matching Networks: a few-shot learning model using a metric-based attention method (Vinyals et al., 2016).
• Prototypical Networks: a deep metric-based method using sample average as class prototypes (Snell et al., 2017).
• Graph Network: a graph-based few-shot learning model that implements a task-driven message passing algorithm on the samplewise level (Garcia and Bruna, 2017).
• Relation Network: a few-shot learning model which uses a neural network as the distance metric and sums up sample vectors in the support set as class vectors (Sung et al., 2018).
• ROBUSTTC-FSL: This approach combines several metric-based methods by clustering the tasks .
The baseline results on ARSC are reported in  and we implemented the baseline models on ODIC with the same text encoder module.
Implementation Details We use 300-dimension Glove embeddings (Pennington et al., 2014) for ARSC dataset and 300-dimension Chinese word embeddings trained by  for ODIC. We set the hidden state size of LSTM u = 128 and the attention dimension d a = 64. The iteration number iter used in dynamic routing algorithm is 3. The relation module is a neural tensor layer with h = 100 followed by a fully connected layer activated by sigmoid. We build 2-way 5-shot models on ARSC following , and build episode-based meta training with C = [5, 10] and K = [5, 10] for comparison on ODIC. In addition to K sample texts as support set, the query set has 20 query texts for each of the C sampled classes in every training episode. This means, for example, that there are 20 × 5 + 5 × 5 = 125 texts in one training episode for the 5-way 5-shot experiments.

Evaluation Methods
We evaluate the performance by few-shot classification accuracy following previous studies in few-shot learning (Snell et al., 2017;Sung et al., 2018). To evaluate the proposed model with the baselines objectively, we compute mean few-shot classification accuracies on ODIC over 600 randomly selected episodes from the testing set. We sample 10 test texts per class in each episode for evaluation in both 5-shot and 10-shot scenarios. Note that for ARSC, the support set for testing is fixed by . Consequently, we just need to run the test episode once for each of the target tasks. The mean accuracy of the 12 target task is compared to the baseline models following .

Experiment Results
Overall Performance Experiment results on ARSC are presented in Table 2. The proposed Induction Networks achieves a 85.63% accuracy, outperforming the existing state-of-the-art model, ROBUSTTC-FSL, by a notable 3% improvement. We due the improvement to the fact that ROBUSTTC-FSL builds a general metric method by integrating several metrics at the sample level, which faces the difficulty of getting rid of the noise among different expressions in the same class. In addition to that, the task-clustering-based method used by ROBUSTTC-FSL must be found on the relevance matrix, which is inefficient when applied to real-world scenarios where the tasks change rapidly. Our Induction Networks, however, is trained in the meta-learning framework with more flexible generalization and its induction ability can hence be accumulated through different tasks.
We also evaluate our method with a real-world intent classification dataset ODIC. The experiment results are listed in Table 3. We can see that our proposed Induction Networks achieves best classification performances on all of the four experiments. In the distance metric learning models (Matching Networks, Prototypical Networks, Graph Network and Relation Network), all the learning occurs in representing features and measuring distances at the sample-wise level. Our work builds an induction module focusing on the class-wise level of representation, which we claim to be more robust to variation of samples in the support set. Our model also outperforms the latest optimization-based method-SNAIL. The difference between Induction Networks and SNAIL shown in Table 3 is statistically significant under the paired at the 99% significance level. In  addition, the performance difference between our model and other baselines in the 10-shot scenario is more significant than in the 5-shot scenario. This is because in the 10-shot scenario, for the baseline models the improvement brought by a bigger data size is also diminished by more sample level noises.

Ablation Study
To analyze the effect of varying different components of the Induction Module and Relation Module, we further report the ablation experiments on the ARSC dataset as shown in Table 4. We can see that the best performance is achieved when we used 3 iterations, corresponding to the best result reported in Table 2 (more rounds of iterations did not further improve the performance), and the table shows the effectiveness of the routing component. We also changed the Induction Module with sum and self-attention and changed Relation Module with cosine distance. Changes in the performances validate the benefit of both the Relation Module and Induction Module. The Attention+Relation models the induction ability by self-attention mechanism, but the ability is limited by the learnt attention parameters. Conversely, the proposed dynamic routing induction method captures class-level information by automatically adjusting the coupling coefficients according to inputted support sets, which is more suitable for the few-shot learning task.

Further Analysis
We further analyze the effect of transformation and visualize query text vectors to show the advantage of the Induction Networks.
Effect of Transformation Figure 2 shows the t-SNE (Maaten and Hinton, 2008) visualization of support sample vectors before and after matrix transformation under the 5-way 10-shot scenario. We randomly select a support set with 50 texts (10 texts per class) from the ODIC testing set, and ob- after transformation. We can see that the vectors after matrix transformation are more separable, demonstrating the effectiveness of matrix transformation to encode semantic relationships between lower-level sample features and higher-level class features.

Query Text Vector Visualization
We also find out that our induction module does not only work well in generating effective class-level features, but also helps the encoders to learn better text vectors, as it can give different weights to instances and features during backpropagation. Figure 3 shows the t-SNE (Maaten and Hinton, 2008) visualization of text vectors from the same randomly selected five classes, learnt by the Relation Network and our Induction Networks. It is clear that the text vectors learnt by Induction Networks are better separated semantically than those of Relation Network.

Conclusion
In this paper, we propose the Induction Networks, a novel neural model for few-shot text classification. We propose to induce the class-level representations from support sets to deal with samplewise diversity in few-shot learning tasks. The Induction Module combines the dynamic routing algorithm with a meta-learning framework, and the routing mechanism makes our model more general to recognize unseen classes. The experiment results show that the proposed model outperforms the existing state-of-the-art few-shot text classification models. We found that both the matrix transformation and routing procedure contribute consistently to the few-shot learning tasks.