SlowGuess's picture
Add Batch 73c8ff8c-2792-4163-8438-639ebae950eb
f2d9a6e verified
# Active Learning for BERT: An Empirical Study
# Liat Ein-Dor,\* Alon Halfon,\* Ariel Gera,\* Eyal Shnarch,\* Lena Dankin, Leshem Choshen, Marina Danilevsky, Ranit Aharonov, Yoav Katz and Noam Slonim IBM Research
{liate, alonhal, arielge, eyals, lenad, leshem.choshen, katz, noams} @il.ibm.com, mdanile@us.ibm.com, ranit.aharonov2@ibm.com
# Abstract
Real world scenarios present a challenge for text classification, since labels are usually expensive and the data is often characterized by class imbalance. Active Learning (AL) is a ubiquitous paradigm to cope with data scarcity. Recently, pre-trained NLP models, and BERT in particular, are receiving massive attention due to their outstanding performance in various NLP tasks. However, the use of AL with deep pre-trained models has so far received little consideration. Here, we present a large-scale empirical study on active learning techniques for BERT-based classification, addressing a diverse set of AL strategies and datasets. We focus on practical scenarios of binary text classification, where the annotation budget is very small, and the data is often skewed. Our results demonstrate that AL can boost BERT performance, especially in the most realistic scenario in which the initial set of labeled examples is created using keyword-based queries, resulting in a biased sample of the minority class. We release our research framework, aiming to facilitate future research along the lines explored here.
# 1 Introduction
Automatic text classification is a well studied problem in Natural Language Processing (NLP), with great practical importance and numerous real world applications (Aggarwal and Zhai, 2012). There are two major hurdles to developing effective text classifiers in practice, as well as to developing classifiers in other domains – the lack of labeled data, and class imbalance (Japkowicz and Stephen, 2002). Text classifiers often require high quantities of labeled data for model training. However, collecting such labeled data is a notoriously expensive and time-consuming process, and shortage of labeled data is exacerbated when the desired class has a
relatively low prior in the data. In such a scenario, even going through the burden of labeling a random sample may yield an insufficient number of positive instances to properly train a classifier. Our focus in this work is on this challenging coupled setup, frequently encountered by real-world users – where labeled data is scarce and the prior of the desired class is small.
A classical approach for coping with limited annotation resources is Active Learning (AL) (Cohn et al., 1996). In this paradigm, one assumes that unlabeled data are abundant, and the goal is to focus the expensive labeling process on the most informative instances. Many AL strategies have been proposed, aiming to minimize the labeling burden, or if taken from a different perspective – maximize the value of labeling a small set of examples. Importantly, the usefulness of an AL strategy naturally depends on the classification scheme with which it is coupled. A successful AL approach for a Naive Bayes classifier may not be that effective for a modern deep-learning algorithm such as CNN, and vice versa.
A more recent relevant development is the introduction of pre-trained NLP models (cf. Qiu et al., 2020), which have been shown to substantially improve state-of-the-art results in numerous NLP tasks. A prominent example is the BERT model (Devlin et al., 2018), which has received massive attention from the NLP research community since its inception. However, the use of AL with deep pre-trained models for text classification – and BERT in particular – has so far received surprisingly little consideration. Thus, while recent papers have demonstrated the value of AL for various deep-learning text classification schemes (Shen et al., 2017; Zhang et al., 2017; Siddhant and Lipton, 2018; Prabhu et al., 2019), the potential of AL combined with BERT is yet to be explored. First, given the unique properties of pre-trained models,
and the expectation that such models will yield adequate performance even with small amounts of training data, it is unclear a priori whether – and to what extent – established AL paradigms can further enhance their classification performance. Moreover, more recent Deep AL strategies, such as Core-Set (Sener and Savarese, 2017) and Dropout (Gal and Ghahramani, 2016), were developed in the vision domain for CNNs. The value of these strategies on top of the BERT transformer architecture remains unclear.
Our goal in this work is threefold. We study the potential of (i) various AL strategies; (ii) in conjunction with BERT, an arguably outstanding text classification scheme; (iii) within a highly challenging – yet common – real-world scenario of class imbalance and scarce labeled data. To address this goal, we conduct a systematic study, considering traditional and advanced AL strategies coupled with BERT for a wide range of datasets. We focus on three scenarios: A balanced setting, serving as a reference, where the prior of the class of interest is not too small; the more challenging imbalanced setting, where the class prior is $\leq 15\%$ but we assume a way to obtain an unbiased set of positive samples to be used for initial training; and finally, the imbalanced-practical setting, which is similar to the imbalanced one, but takes a step further towards a truly practical setup, in which there is no access to an unbiased positive sample. Instead, we assume the user has access to a biased sample, hopefully enriched with positive examples, obtained by issuing simple queries of keywords associated with the positive class.
Our results convey that AL strategies can boost BERT performance, under the challenging setting of a small annotation budget and highly skewed data, especially in the more practical real-world settings. We release our research framework<sup>1</sup>, including access to all datasets, an implementation of multiple AL strategies, and an associated automatic evaluation framework, aiming to facilitate further research along the lines explored here.
# 2 Related Work
AL has been widely used in many fields to successfully decrease the labeling effort involved in the training process. A good summary of active learning works prior to the advances in deep learn
ing can be found in Settles (2009). Advances in deep learning have given rise to extensive research into deep active learning, which aims to adapt the classic AL framework to the special properties of DNNs. Deep AL presents some specific challenges. Since DNNs are computationally heavy, training a new model whenever a single training sample is added is highly impractical. This requires a shift to batch mode active learning, where a batch of examples is queried at every iteration. Moreover, the tendency of the softmax layer to over-confidence has led to the development of various uncertainty-based strategies tailored to the special properties of DNNs (Gal and Ghahramani, 2016).
Most of the works in deep active learning focus on image classification with convolutional neural networks (Sener and Savarese, 2017; Gal and Ghahramani, 2016; Gissin and Shalev-Shwartz, 2019). Recent papers have demonstrated the value of deep active learning for text classification (Zhang et al., 2017; Siddhant and Lipton, 2018; Prabhu et al., 2019; Lowell et al., 2018), but in general did not study AL for BERT. One exception is Zhang and Zhang (2019) who applied an ensemble of AL strategies to BERT for the task of intent classification. However, this work focuses on a single task, and does not address the effect of small and imbalanced data. Additionally, Shelmanov et al. (2019) and Liu et al. (2020) focused on particular variants of BERT (BioBERT and BERT-CRF) and studied a single or two specific tasks, with a small collection of AL strategies. To the best of our knowledge, this work is the first to systematically explore advanced strategies like Core-Set (Sener and Savarese, 2017), Dropout (Gal and Ghahramani, 2016), Expected Gradient Length (Huang et al., 2016) and Discriminative Active Learning (Gissin and Shalev-Shwartz, 2019) for BERT, in various settings and a diversity of tasks.
# 3 Empirical Evaluation
# 3.1 Data
We consider 10 datasets (see Table 1) that cover a variety of domains, and for each we select one target class as our classification goal, thus creating a set of binary classification tasks. Three datasets are originally skewed, i.e., the target class prior is $\leq 15\%$ : Wiki Attack (Wulczyn et al., 2017), which annotates Wikipedia discussions for offensive con
<table><tr><td>No.</td><td>Dataset</td><td>Size</td><td>Class</td><td>Prior</td></tr><tr><td>1</td><td>Subjectivity-imb</td><td>5,556</td><td>subjective</td><td>10%</td></tr><tr><td>2</td><td>Polarity-imb</td><td>5,923</td><td>positive</td><td>10%</td></tr><tr><td>3</td><td>AG&#x27;s News-imb</td><td>17,538</td><td>world</td><td>10%</td></tr><tr><td>4</td><td>Wiki attack</td><td>21,000</td><td>general</td><td>12%</td></tr><tr><td>5</td><td>ISEAR</td><td>7,666</td><td>fear</td><td>14%</td></tr><tr><td>6</td><td>TREC</td><td>5,952</td><td>location</td><td>15%</td></tr><tr><td>7</td><td>AG&#x27;s News</td><td>21,000</td><td>world</td><td>25%</td></tr><tr><td>8</td><td>CoLA</td><td>9,594</td><td>unacceptable</td><td>30%</td></tr><tr><td>9</td><td>Subjectivity</td><td>10,000</td><td>subjective</td><td>50%</td></tr><tr><td>10</td><td>Polarity</td><td>10,662</td><td>positive</td><td>50%</td></tr></table>
Table 1: Dataset details: size, target (positive) class, and its prior in the dataset.
tent;2 ISEAR (Shao et al., 2015), which annotates personal reports for emotion; and TREC (Li and Roth, 2002) which considers the answer type of questions. In four datasets the target class prior is $20\% - 50\%$ : AG's News (Zhang et al., 2015), which categorizes news articles; CoLA (Warstadt et al., 2018), which annotates sentences for grammatical acceptability; Subjectivity (Pang and Lee, 2004), which classifies movie snippets into subjective or objective; and Polarity (Pang and Lee, 2005), which includes sentiment analysis on movie reviews. In addition, we enriched the imbalanced datasets by creating imbalanced versions of three balanced datasets via sub-sampling the target class instances towards a prior of $10\%$ (Table 1, rows 1-3).
Each dataset was split into train, dev, and test sets, keeping the original split, if exists, and otherwise applying a $70\% / 10\% / 20\%$ split, respectively. For large datasets, we limit the sizes to $15K / 3K / 3K$ respectively by randomly sampling from each set. The complete details along with links to all datasets are provided in Appendix A.
# 3.2 Experimental setup
We apply pool-based active learning (Settles, 2009) in batch mode, using BERT as the classification model. Seven selection strategies are examined over the 10 fully labeled binary classification datasets described above. The use of fully labeled datasets enables simulating manual labeling (Yang and Loog, 2018). Per dataset, we use its train set as the initial pool of examples from which instances are selected for labeling.
We assume an initial annotation budget that enables labeling 100 examples, used to create an ini
tial seed $L$ . In some setups, $L$ may contain additional instances without their ground truth labels, and in general the way $L$ is selected depends on the experimental scenario, as described below. We denote by $U$ the instances in the pool that do not belong to $L$ .
For a given AL strategy, a single experiment starts with the seed $L$ , used to train BERT as the initial classifier (iteration 0). Next, we conduct 5 iterations. In each, the AL strategy selects a batch of 50 unlabeled instances from $U$ that are added to $L$ along with their true labels, and BERT is trained over these expanded data. Note, the BERT fine-tuning in each iteration is done from scratch, to avoid overfitting data from previous rounds, as suggested in Hu et al. (2018). In each experiment, all AL strategies start with the same initial seed. The reported results are the average over 5 different experiments, i.e., 5 different initial seeds.
For each AL strategy, we consider the following three scenarios:
Balanced: Here, the positive class prior is not very low, hence a randomly selected sample is expected to have a sufficient number of positive examples. Correspondingly, the seed $L$ is simply defined as 100 instances sampled at random from the pool. We apply this scenario to datasets with $20\% - 50\%$ of positive labels. $^3$
For datasets with a positive class label $\leq 15\%$ , a random seed of 100 instances led to unstable BERT runs (data not shown), presumably due to the combination of small and highly skewed training data resulting from such random selection. Hence, for these imbalanced datasets, we consider the two scenarios described below. In both cases, we expand the initial set of 100 labeled examples with another set of 100 instances, selected at random from the remaining data, which are all added to $L$ with a negative label. In other words, the low prior of the positive class naturally implies high prior of the negative class, enabling to expand the fully labeled 100 instances with an additional set of 100 instances that are - weakly - labeled as negative examples (without the need for additional annotation budget). Hence, in both scenarios described below, $L$ contains a total of 200 examples.
Imbalanced: Here, the 100 fully labeled examples are drawn at random from the positive examples in the dataset, hence all 100 are indeed positive, and
are further an unbiased sample of the positive class. In this setting we assume high-precision heuristics that enable generating a relatively unbiased sample; but in many real-world cases such heuristics may not exist, or are expected to have limited coverage and would not enable sampling at will<sup>4</sup>. Thus, such heuristics cannot be assumed to yield a large training set, but may nevertheless be used for obtaining a small initial seed in an active learning setting.
Imbalanced-practical: In this scenario, we simulate a more realistic setting in which a user attempts to obtain as many positive examples as possible using the budget of 100 annotations. To this end, we design a simple keyword-based query for each dataset, which aims to retrieve a set of instances enriched with positive examples, using words assumed to be associated with the positive class. We opted for keyword-based queries as they are often used in practice in real-world scenarios. We apply the query to the pool, and randomly draw 100 instances from the query result, which are then added to the seed with their ground truth labels. Note that these 100 examples are expected to be enriched with positive examples, yet in a biased manner, since by construction, all examples match the query we started with. Specifically, this scenario was tested on four datasets for which a simple string (or sub-string) match query with enough hits could be defined: (i) for the fear class in ISEAR the query is [fear or afraid or scared or scary] (fear, for example, can also capture fearsome); (ii) for the TREC location class, [Where or countr or cit] (matching cit captures both the singular and plural of city); (iii) for the Wiki attack class, $[A-Z]!$ (capturing a word ending with an upper case letter which is immediately followed by an exclamation mark, e.g., IDIOT!), and (iv) for the AG's News-imb world class the query is a list of countries and territories separated by 'or'. It is likely that better queries could be defined. However, our goal here was to simulate a realistic setting in which a user relies on a relatively simple heuristic, and to examine the behavior of AL with BERT when initiated with a potentially biased seed.
# 3.3 Active Learning Strategies
We consider several AL strategies for choosing the batch of 50 instances to label in each iteration. In
addition, as a baseline, we consider a Random strategy, where batch instances are chosen at random from the unlabeled set.
- Least Confidence (LC, Lewis and Gale, 1994): selects instances for which the model is least certain according to the max-entropy decision rule.
- Monte Carlo Dropout (Dropout, Gal and Ghahramani, 2016): Similar to LC, but instance uncertainty is calculated using Monte Carlo Dropout on 10 inference cycles, with the max-entropy acquisition function<sup>5</sup>.
- Perceptron Ensemble (PE): Selects instances with highest uncertainty – similarly to LC – but averaging over an ensemble of models. Here, we use a light-weight ensemble strategy to overcome the unrealistic computational cost required for training an ensemble of BERT models. PE is composed of 10 perceptrons which are trained to solve the original task using $L$ , where the perceptron inputs are the CLS vectors of the fine-tuned BERT model.
- Expected Gradient Length (EGL, Huang et al., 2016): selects instances with the largest expected gradient norm, as they are expected to wield a large influence on the model. The expectation is computed over the posterior distribution of labels for the example according to the trained model.
- Core-Set (Sener and Savarese, 2017): selects instances that best cover the dataset in the learned representation space (CLS), using the greedy method described in Sener and Savarese (2017).
- Discriminative Active Learning (DAL, Gissin and Shalev-Shwartz, 2019): This approach aims to select instances that make L most representative of the entire pool. We follow the exact method used in Gissin and Shalev-Shwartz (2019).
We chose these strategies as spanning the leading state-of-the-art approaches in the AL domain: uncertainty-sampling (LC and Dropout), uncertainty-sampling using ensemble methods (PE), expected model change (EGL), and diversity sampling (DAL and Core-Set).
# 3.4 Implementation Details
Overall, the results presented here consist of 2,520 fine-tuning experiments (14 dataset-scenario combinations $\times$ 5 initial seeds $\times$ (1 base model + (7 selection strategies $\times$ 5 iterations)). In order to run multiple experiments in parallel, experiments were performed on Intel® Xeon CPU E5-2699 v4
<table><tr><td>Random</td><td>LC</td><td>Dropout</td><td>EGL</td><td>Core-Set</td><td>DAL</td><td>PE</td></tr><tr><td>&lt; 1</td><td>84</td><td>840</td><td>1106</td><td>98</td><td>167</td><td>370</td></tr></table>
@ 2.20GHz, with 88 CPUs and 748 GB of RAM. BERT training and inference were performed on Nvidia® Tesla K80 GPUs (single GPU per run).
Table 2 lists AL batch selection runtimes for different AL strategies. Runtimes for all strategies except Random are dominated by BERT inference, as BERT model outputs are used in selecting batch instances. Notably, two strategies demand longer inference times: EGL due to the gradient calculation, and Dropout due to the larger number of inference cycles $(\times 10)$ .
# 3.5 BERT Training Details
In each fine-tuning run, BERT<sub>BASE</sub> (110M paramaters) was trained for 5 epochs, using a learning rate of $5 \times 10^{-5}$ , and keeping the best model based on its performance on the dev set. In practice, dev sets may be unavailable, particularly under a limited annotation budget. Using a dev set to reduce variance and noise between runs helps stabilize the results, but importantly, we verified that ignoring the dev data and setting a constant number of epochs yields qualitatively similar, albeit noisier, results. Our experiments showed that increasing the batch size had a substantial effect on improving the stability of BERT results. However, due to memory limitations of the GPU, increasing the batch size comes at the expense of the maximal sequence length. We empirically determined that setting the batch size to 50, and the maximal sequence length to 100 tokens (after WordPiece tokenization), yielded the best results. We otherwise used the default settings in the TensorFlow implementation of BERT.
# 3.6 AL Research Framework
Our open-source framework allows a user to experiment with the active learning strategies in (§3.3) and evaluate their performance over the datasets in (§3.1). The framework also supports adding new AL strategies, making it easy to evaluate their potential.
Table 2: Runtimes (in seconds) for a single iteration for different AL strategies, assuming 7,000 unlabeled examples.
<table><tr><td>Strategy</td><td>Balanced</td><td>Imbalanced</td><td>Imbalanced practical</td></tr><tr><td>Core-Set</td><td>10-2</td><td>&lt; 10-5</td><td>&lt; 10-8</td></tr><tr><td>Dropout</td><td>&lt; 10-3</td><td>&lt; 10-8</td><td>&lt; 10-8</td></tr><tr><td>EGL</td><td>-- --</td><td>&lt; 10-4</td><td>&lt; 10-8</td></tr><tr><td>LC</td><td>&lt; 10-5</td><td>&lt; 10-9</td><td>&lt; 10-7</td></tr><tr><td>DAL</td><td>&lt; 10-2</td><td>&lt; 10-5</td><td>&lt; 10-6</td></tr><tr><td>PE</td><td>-- --</td><td>&lt; 10-2</td><td>&lt; 10-6</td></tr></table>
Table 3: Wilcoxon test p-values (after Bonferroni correction) for different AL strategies compared to Random. $- - -$ denotes insignificant results $\left( {p \geq {0.05}}\right)$ .
# 4 Results
We report results for the AL strategies (§3.3) in three experimental scenarios (§3.2). Following the standard in the field, we use accuracy as the classification metric for the balanced scenario, and F1<sup>6</sup> for the imbalanced and imbalanced-practical scenarios, where the prior for positives is relatively low.
Figure 1 depicts the classification quality (accuracy or F1) per iteration for each dataset, for the relevant scenarios. For clarity of presentation, we only plot the Random baseline and three strategies that represent the different approaches. As can be seen in the full figure in the Appendix (Figure 3), the other strategies behave similarly.
In most datasets, all AL strategies performed better than the Random baseline, even in cases where the baseline results were already very good, e.g., AG's News and Subjectivity. Interestingly, the largest improvements were observed in the imbalanced-practical scenario. Here, the AL strategies improve the F1 of the Random baseline by a large margin of $4 - 8\%$ on average. These results demonstrate that AL can indeed enhance BERT results when the annotation budget is small, especially for datasets having a low prior for positive examples, as is the case in many real-world settings.
To check the significance of the differences, we calculate the Wilcoxon p-value for every AL strategy compared to the Random baseline, per scenario, and perform a Bonferroni correction to adjust for the multiple strategies examined. To calculate the p-value for a strategy $S$ per scenario, we compare the classification metric for all pairs $(S_{dik}, R_{dik})$ such that $R$ is the Random baseline results, $d \in D$ , where $D$ is the set of datasets in
![](images/5e78eaebe31963759371e7eaaef5745757e67e7bb23c4533bb74fc96237c1982.jpg)
![](images/fc0eeb5b63fdcb4acffb98b71c83322790866c352181e19ae588f4749872323e.jpg)
Balanced
![](images/a9cc6742b17b34fce32d79614be40c47ee639695bbfd1d27884ac93ecc1bb9a6.jpg)
![](images/e7345cd76966d47bb854cd2a2f06651b188848d3ec1ff99c5d15de8e17fb4b45.jpg)
![](images/236ba7533f395d20e307ce1e4165f89cfc828d0cc7022e909f09211046af7405.jpg)
![](images/a9f86c4c7b240ac5b8b7299aeb19b4197027d40bb9310858c64c2554a6684ea6.jpg)
Imbalanced
![](images/923c821b37bb7395ed359d563b9628ae297c716325a1e367cb362736d1c6f8cb.jpg)
![](images/7f8183f7c71a265715bf417d7f1e99accc33a5c6955ba8d0593a708d188d495c.jpg)
![](images/3d89b6dad902eac0e974734ab86073b49833f885c70ee580a3f37dbfa3476c50.jpg)
Imbalanced-practical
![](images/b45a5aa5145a24b2e02519db970d7cc511b4a37bba6a433cc61194531624e5cf.jpg)
![](images/6dcc7eea8308c0b577147875d13fb4ae791aec4cd50b42486dcf615c05ebceaa.jpg)
Figure 1: AL strategies compared to the Random baseline in the balanced (top row), imbalanced (two middle rows) and imbalanced-practical (bottom row) scenarios. Train size indicates the size of L, where each iteration adds 50 samples.
![](images/f14ce76726e472e3e512baa3fcb956f31364e2c63e9c9503d6caafc27f68f01e.jpg)
![](images/9c9cd8fff3933e2e6d61cff9eb59cd0dd2368a70ebe60c9c73a30fe67b669c78.jpg)
![](images/09c3a99d0619b1c52d2a113914474a831812256469dc19eb11216729058f0987.jpg)
![](images/5566e1dcd01f904bb15992ffb0e44a1723a4f884f64258851d8c7e86b9b84a74.jpg)
cluded in the scenario, $i = (1\dots 5)$ is the iteration index, and $k = (1\dots 5)$ is the experiment number. As can be seen in Table 3, all the examined AL strategies significantly and consistently outperform the Random baseline when the dataset is highly skewed (imbalanced and imbalanced-practical scenarios). All strategies except PE and EGL also outperform the baseline for the balanced scenario.
While AL strategies improve over the Random baseline, apparently no single strategy consistently outperforms all its counterparts. This finding echoes Lowell et al. (2018), who studied AL for text classification and sequence tagging in non-BERT models, and demonstrated the brittleness and inconsistency of AL results. For significance analysis, we calculate the p-value for every pair of strategies per scenario in a similar manner to the one described above per strategy versus Random, correcting for the multiple pairs examined, and indeed find no overall significant performance difference between any pair of AL strategies. Note, however, that some AL strategies are more efficient than others with respect to runtime - see Table 2.
As may be expected, using a seed with positive labels obtained by a query, which is naturally biased towards instances that satisfy the query, typically results in an initial model with lower F1, compared to starting with an unbiased set of positive examples (compare iteration 0 per dataset in Figure 1 between the imbalanced-practical and imbalanced scenarios). Interestingly, though, after several iterations, the AL strategies seem to bridge the gap and end up with similar classification performance in both scenarios. We further examined whether the increase in F1 for the imbalanced scenarios is driven by an increase in precision or recall. We find that in the imbalanced-practical scenario, the improvement in F1 is completely dominated by an increase in recall, supporting the notion that the AL strategies enable the model to extrapolate and generalize beyond the biased sample obtained by the query<sup>8</sup>. In contrast, in the imbalanced scenario the increase in F1 is mostly driven by an increase in precision. For the precision and recall curves, see Figures 4 and 5 in the Appendix.
To conclude, our analyses suggest two results that were not trivial to begin with. Applying AL to BERT can further boost the performance of this top performing model. Furthermore, even when
initiated with a biased seed of positive examples – as may often occur in practice – AL strategies can swiftly generalize from this seed and significantly improve the model recall, ending up with overall strong F1 performance.
# 5 Analysis
We perform a comparative analysis of the different AL strategies, aiming to better understand their relative advantages and disadvantages, and provide some insights that may lead to improved AL strategies in future work.
To enable an appropriate comparison, this analysis is performed after the initial BERT model is trained and each AL strategy has selected 50 examples for labeling. Correspondingly, all strategies select examples from the same unlabeled set $U$ while using outputs from the same BERT model. We measure two batch properties which are known in the literature to impact AL effectiveness:
Diversity: Choosing a batch of diverse examples is often better than choosing one containing very similar and perhaps redundant examples. Following Zhdanov (2019), we define the Diversity of a set $B$ as:
$$
D (B) = \left(\frac {1}{| U |} \sum_ {x _ {i} \in U} \min _ {x _ {j} \in B} d \left(x _ {i}, x _ {j}\right)\right) ^ {- 1} \tag {1}
$$
where $x_{i}$ denotes the representation of the [CLS] token of example $i$ obtained by the model which was trained using $L$ , and $d(x_{i},x_{j})$ denotes the Euclidean distance between $x_{i}$ and $x_{j}$ .
Representativeness: A known issue with AL strategies, especially the uncertainty-based ones, is their tendency to select outlier examples that do not properly represent the overall data distribution. We thus examine the representativeness of the selected batches. We rely on the KNN-density measure proposed by Zhu et al. (2008), in which the density of an example is quantified by the average distance between the example in question and its K most similar examples (i.e., K nearest neighbors) within $U$ , based on the [CLS] representations as above. An example with high density degree is less likely to be an outlier. We define the representativeness of a batch as one over the average KNN-density of its instances using the Euclidean distance with $K = 10$ .
The diversity and representativeness of the different strategies are depicted in Figure 2, where for
![](images/14bdb4cc8ff2364f78ba0e6e7e08cf9d5c4e4d5b72808fe4fb19be7937124de7.jpg)
Figure 2: Diversity (left) and Representativeness (right) of the batches selected by the different AL strategies in each of the three scenarios.
![](images/7f0686316651e38a06b4e1d9333f903e8cd14fe5204f54054036a5b508d475ee.jpg)
each scenario we average results over all datasets and seed selections. As expected, the batch-aware strategies, DAL and Core-Set, which were designed to increase diversity, are characterized by the most diverse batches, with DAL achieving the highest diversity values, demonstrating the success of using mini-queries (Gissin and Shalev-Shwartz, 2019) to reduce redundancy of the selected examples. In contrast, the other strategies tend to select less diverse batches, i.e., they are prone to choose redundant examples, especially in the imbalanced-practical scenario. Thus, combining these approaches with methods that encourage diversity (e.g., He et al., 2014; Zhdanov, 2019; Ash et al., 2019) can potentially lead to further improvement in their resultant prediction performance. In terms of representativeness, DAL, which is a representativeness-driven method, again consistently leads across the scenarios. In contrast, the tendency of the greedy core-set version to select outliers (Sener and Savarese, 2017), is indeed reflected in its relatively low representativeness scores. Interestingly, this is not the case for the imbalanced-practical scenario. This result can be attributed to the high bias of L towards query matches, which results in poor representativeness of L, which in turn leaves the main "responsibility" for representing the dataset on the batch examples selected from U. A deeper investigation of this result is left for further investigation. Other strategies have low representativeness scores compared to DAL, implying that they can be improved by combining them with techniques for encouraging representativeness and avoiding outliers.
A popular approach for improving classification quality is combining several, preferably complementary, AL strategies. In order to find pairs of
strategies with high synergistic potential, we measured the overlap between the batches selected by each pair of strategies. Our analysis shows that for all pairs of strategies, the expected batch overlap is relatively low, and does not exceed $15\%$ . In general, overlap was higher in the imbalanced scenarios, probably due to the general incentive to select positive examples, which are rare in the data. Also, the overlap within the uncertainty-based strategies was generally quite high. Nevertheless, the highest overlap between batches was between EGL (which is not an uncertainty-based approach) and LC. We leave for future work to try a combination of strategies with low overlap as a way to improve classification even further.
# 6 Conclusions
The recent emergence of pre-trained models, with BERT as a prominent example, is reshaping the NLP arena (Qiu et al., 2020). The promise embodied in these models is their ability to exploit massive unlabeled textual data to learn versatile, arguably universal language representations. These representations, in turn, are proven to be effective for a multitude of downstream NLP tasks.
A parallel line of research, dating back nearly three decades, is the notion of AL, aiming to minimize labeling burden within the supervised learning paradigm. The pairing of these two influential threads raises non-trivial questions. For example, BERT arguably attains excellent performance with relatively little labeled data, used to fine-tune this pre-trained model for a concrete task. It is not obvious to begin with, to what extent AL strategies can be used to outperform this already high bar.
To the best of our knowledge, the present work provides the first systematic study in this context,
while focusing on the prevalent problem of text classification. Moreover, we further focus our attention on a scenario well known to many practitioners – and notoriously difficult from a learning perspective – that of building a classifier when the class of interest is scarce in the data at hand. Aiming to further bridge the gap between research and practice, in our imbalanced-practical mode we simulate a user within this challenging scenario, armed only with simple queries to define the labeled seed that will bootstrap the AL process. Our results demonstrate the potential of AL on top of BERT, especially in this latter scenario. Notably, a training data seed resulting from a simple query is expected to capture only limited, and perhaps somewhat obvious, aspects of the class under consideration. Our study shows that the initial BERT model indeed suffers from poor prediction performance, mainly due to low recall values. However, while the random AL baseline is limited in its ability to help BERT emerge from this poor initial model, AL strategies turn out to be very helpful. Using the AL pipeline, BERT improves its recall by a large margin, generalizing beyond the narrow data it was initially exposed to.
This work focused on various binary classification tasks. A natural future direction is to conduct a similar empirical investigation of AL over BERT in the context of multi-class classification and regression tasks. It would also be interesting to investigate the realm of larger annotation budgets, and more recent BERT variants (Liu et al., 2019; Lan et al., 2019). Finally, the present work focused on existing AL strategies, which were mostly developed in the vision domain for CNNs. The development of novel AL methods, that are tailored for pre-trained models such as BERT, seems like an important direction for future work. We hope that the experimental results and analyses reported here, as well as the release of the research framework we developed, would be instrumental for these and other future studies.
# References
Charu C Aggarwal and ChengXiang Zhai. 2012. A survey of text classification algorithms. In Mining text data, pages 163-222. Springer.
Jordan T Ash, Chicheng Zhang, Akshay Krishnamurthy, John Langford, and Alekh Agarwal. 2019. Deep batch active learning by diverse, un
certain gradient lower bounds. arXiv preprint arXiv:1906.03671.
David A Cohn, Zoubin Ghahramani, and Michael I Jordan. 1996. Active learning with statistical models. Journal of artificial intelligence research, 4:129-145.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2018. Bert: Pre-training of deep bidirectional transformers for language understanding.
Yarin Gal and Zoubin Ghahramani. 2016. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In international conference on machine learning, pages 1050-1059.
Daniel Gissin and Shai Shalev-Shwartz. 2019. Discriminative active learning. arXiv preprint arXiv:1907.06347.
Tianxu He, Shukui Zhang, Jie Xin, Pengpeng Zhao, Jian Wu, Xuefeng Xian, Chunhua Li, and Zhiming Cui. 2014. An active learning approach with uncertainty, representativeness, and diversity. The Scientific World Journal, 2014.
Peiyun Hu, Zachary C Lipton, Anima Anandkumar, and Deva Ramanan. 2018. Active learning with partial feedback. arXiv preprint arXiv:1802.07427.
Jiaji Huang, Rewon Child, Vinay Rao, Hairong Liu, Sanjeev Satheesh, and Adam Coates. 2016. Active learning for speech recognition: the power of gradients. arXiv preprint arXiv:1612.03226.
Nathalie Japkowicz and Shaju Stephen. 2002. The class imbalance problem: A systematic study. Intelligent Data Analysis, pages 429-449.
Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. 2019. Albert: A lite bert for self-supervised learning of language representations.
David D Lewis and William A Gale. 1994. A sequential algorithm for training text classifiers. In SIGIR'94, pages 3-12. Springer.
Xin Li and Dan Roth. 2002. Learning question classifiers. In COLING 2002: The 19th International Conference on Computational Linguistics.
Mingyi Liu, Zhiying Tu, Zhongjie Wang, and Xiaofei Xu. 2020. Ltp: A new active learning strategy for bert-crf based named entity recognition. arXiv preprint arXiv:2001.02524.
Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. 2019. Roberta: A robustly optimized bert pretraining approach.
David Lowell, Zachary C Lipton, and Byron C Wallace. 2018. Practical obstacles to deploying active learning. arXiv preprint arXiv:1807.04801.
Bo Pang and Lillian Lee. 2004. A sentimental education: Sentiment analysis using subjectivity summarization based on minimum cuts. In Proceedings of the 42nd Annual Meeting of the Association for Computational Linguistics (ACL-04), pages 271–278, Barcelona, Spain.
Bo Pang and Lillian Lee. 2005. Seeing stars: Exploiting class relationships for sentiment categorization with respect to rating scales. In Proceedings of the 43rd Annual Meeting of the Association for Computational Linguistics (ACL'05), pages 115-124, Ann Arbor, Michigan. Association for Computational Linguistics.
Ameya Prabhu, Charles Dognin, and Maneesh Singh. 2019. Sampling bias in deep active classification: An empirical study. arXiv preprint arXiv:1909.09389.
Xipeng Qiu, Tianxiang Sun, Yige Xu, Yunfan Shao, Ning Dai, and Xuanjing Huang. 2020. Pre-trained models for natural language processing: A survey. arXiv preprint arXiv:2003.08271.
Ozan Sener and Silvio Savarese. 2017. Active learning for convolutional neural networks: A core-set approach. arXiv preprint arXiv:1708.00489.
Burr Settles. 2009. Active learning literature survey. Technical report, University of Wisconsin-Madison Department of Computer Sciences.
Bo Shao, Lorna Doucet, and David R. Caruso. 2015. Universality versus cultural specificity of three emotion domains: Some evidence based on the cascading model of emotional intelligence. Journal of Cross-Cultural Psychology, 46(2):229-251.
A. Shelmanov, V. Liventsev, D. Kireev, N. Khromov, A. Panchenko, I. Fedulova, and D. V. Dylov. 2019. Active learning with deep pre-trained models for sequence tagging of clinical and biomedical texts. In 2019 IEEE International Conference on Bioinformatics and Biomedicine (BIBM), pages 482-489.
Yanyao Shen, Hyokun Yun, Zachary C Lipton, Yakov Kronrod, and Animashree Anandkumar. 2017. Deep active learning for named entity recognition. arXiv preprint arXiv:1707.05928.
Aditya Siddhant and Zachary C. Lipton. 2018. Deep bayesian active learning for natural language processing: Results of a large-scale empirical study.
Alex Warstadt, Amanpreet Singh, and Samuel R Bowman. 2018. Neural network acceptability judgments. arXiv preprint arXiv:1805.12471.
Ellery Wulczyn, Nithum Thain, and Lucas Dixon. 2017. Wikipedia Talk Labels: Personal Attacks.
Yazhou Yang and Marco Loog. 2018. A benchmark and comparison of active learning for logistic regression. Pattern Recognit., 83:401-415.
Leihan Zhang and Le Zhang. 2019. An ensemble deep active learning method for intent classification. In Proceedings of the 2019 3rd International Conference on Computer Science and Artificial Intelligence, pages 107-111.
Xiang Zhang, Junbo Zhao, and Yann LeCun. 2015. Character-level convolutional networks for text classification. In Advances in neural information processing systems, pages 649-657.
Ye Zhang, Matthew Lease, and Byron C Wallace. 2017. Active discriminative text representation learning. In Thirty-First AAAI Conference on Artificial Intelligence.
Fedor Zhdanov. 2019. Diverse mini-batch active learning. arXiv preprint arXiv:1901.05954.
Jingbo Zhu, Huizhen Wang, Tianshun Yao, and Benjamin K Tsou. 2008. Active learning with sampling by uncertainty and density for word sense disambiguation and text classification. In Proceedings of the 22nd International Conference on Computational Linguistics (Coling 2008), pages 1137-1144.
# A Datasets
In this paper we used the following datasets:
Subjectivity: http://www.cs.cornell.edu/ people/pabo/movie-review-data/.
Polarity: http://www.cs.cornell.edu/ people/pabo/movie-review-data/.
AG's News: http://groups.di.unipi.it/\~gulli/AG Corpus_of_news_articles.
html. We used the version from: https: //pathmind.com/wiki/open-datasets (look for the link Text Classification Datasets).
Wiki attack: https://figshare.com/articles/Wikipedia_Talk Labels_Personal_Attacks/4054689.
ISEAR: https://www.unige.ch/cisa/research/materials-and-online-research/research-material/.
TREC: https://cogcomp.seas.upenn.edu/Data/QA/QC/
CoLA: https://nyu-mll.github.io/CoLA/
<table><tr><td>no.</td><td>dataset</td><td>class</td><td># train</td><td>prior</td><td># dev</td><td>prior</td><td># test</td><td>prior</td><td>imb.</td></tr><tr><td>1</td><td>AG&#x27;s News-imb</td><td>world</td><td>12,569</td><td>10%</td><td>2,456</td><td>10%</td><td>2,513</td><td>10%</td><td>Y</td></tr><tr><td>2</td><td>Subjectivity-imb</td><td>subjective</td><td>3,919</td><td>10%</td><td>560</td><td>10%</td><td>1,077</td><td>10%</td><td>Y</td></tr><tr><td>3</td><td>Polarity-imb</td><td>positive</td><td>4,142</td><td>10%</td><td>588</td><td>10%</td><td>1,193</td><td>10%</td><td>Y</td></tr><tr><td>4</td><td>Wiki attack</td><td>general</td><td>15,000</td><td>12%</td><td>3,000</td><td>11%</td><td>3,000</td><td>12%</td><td>Y</td></tr><tr><td>5</td><td>ISEAR</td><td>fear</td><td>5,366</td><td>14%</td><td>766</td><td>15%</td><td>1,534</td><td>15%</td><td>Y</td></tr><tr><td>6</td><td>TREC</td><td>location</td><td>4,674</td><td>15%</td><td>778</td><td>15%</td><td>500</td><td>16%</td><td>Y</td></tr><tr><td>7</td><td>AG&#x27;s News</td><td>world</td><td>15,000</td><td>25%</td><td>3,000</td><td>26%</td><td>3,000</td><td>25%</td><td>N</td></tr><tr><td>8</td><td>CoLA</td><td>unacceptable</td><td>7,592</td><td>30%</td><td>959</td><td>30%</td><td>1,043</td><td>31%</td><td>N</td></tr><tr><td>9</td><td>Subjectivity</td><td>subjective</td><td>7,000</td><td>50%</td><td>1,000</td><td>50%</td><td>2,000</td><td>52%</td><td>N</td></tr><tr><td>10</td><td>Polarity</td><td>positive</td><td>7,463</td><td>50%</td><td>1,066</td><td>50%</td><td>2,133</td><td>50%</td><td>N</td></tr></table>
Table 4: Datasets, target classes and the split for train/dev/test sets with the class prior in each set (imb.=imbalanced).
<table><tr><td>dataset-category</td><td>query</td><td>precision</td><td>recall</td><td>F1</td></tr><tr><td>ISEAR-fear</td><td>fear/afraid/scared/scary</td><td>0.92</td><td>0.24</td><td>0.38</td></tr><tr><td>TREC-location</td><td>Where/countr/cit</td><td>1.00</td><td>0.48</td><td>0.65</td></tr><tr><td>Wiki attack-general</td><td>[A-Z]!</td><td>0.48</td><td>0.08</td><td>0.14</td></tr><tr><td>AG&#x27;s news-imb</td><td>or over a list of countries and territories</td><td>0.32</td><td>0.42</td><td>0.36</td></tr></table>
Table 5: Queries performance on the test set
Table 4 provides details about their split into train, dev, and test sets. For each set its size and the prior of the target class is presented. Information about the performance on the test set of the queries used in the Imbalanced-practical scenario is given in Table 5.
![](images/72217364c056749194ba293d7869dce1c080b6154e3e41bfb28691ca2a18220e.jpg)
![](images/0fc603e3f9e83431887ece6f0d7cf00f16b52b8fbd75c7eb9918933a2fb48bd8.jpg)
Imbalanced
![](images/e7d6d5c7a9f46610097c45878ee1652a2e1360c81b78f17411a9ab4cdcb16a27.jpg)
Balanced
![](images/09ce6262d593fa6c62d8cb01d920eca6baa0c7347d6674f9068ea6979c89ccaa.jpg)
![](images/e34c9eb42c7267f58cd2fdaaba8ec477ac5773141e0b2b647649a1f6453f2bda.jpg)
![](images/c7e099e0dbdee3bbe08d786b44ec955fe404af8330fe8b6799d1e29d812ce451.jpg)
![](images/2395fcf2b2d1d61ec23817654db3f380249d0acbb135aab381336a1c78aa0ef3.jpg)
![](images/98262c0ee2f293ed3b273891ca1039cbe7218323bc384caf52425edacfab64ca.jpg)
![](images/c162dcf67791bf99651cd24a691d762b1cd07b0f23f7ac98ac237651cf1ad350.jpg)
Imbalanced-practical
![](images/98f31b2d6e33e55bc21a79651799f4f37da5f510d796f4e123a3aa6da194919d.jpg)
![](images/ab8fe95e824a984c01a76730b01c1483bc78a7b04d014836c2b050950946bd20.jpg)
Figure 3: AL strategies compared to the Random baseline in the balanced (top row), imbalanced (two middle rows) and imbalanced-practical (bottom row) scenarios. Train size indicates the size of L.
![](images/968da007fcaf2bcf8a7cd5a1c9ee3b03856507364555d0341059ed3a3541f7fd.jpg)
![](images/19f105358c9de56be9e173cd29aa6a477255088306f2db9ce7fda76d9ab20a56.jpg)
![](images/7f522d0db59c065928058787286151409c1a78948ffecc636b8c7562cb7f8711.jpg)
![](images/56f13317b4adb091ba9d6304875a4c1505f12b6bdee5ac076cdb03a90ba08051.jpg)
![](images/9a912dde7527e4a1b20984cada748880124d6c5fbf01e66fbc5813f377f3870a.jpg)
![](images/8126db8fa83ff5e0d369ce84d975f1ab2073b13d56adabd6a0de91611e60f43b.jpg)
Imbalanced
![](images/032b8487f82b425904165d6d7509ed578e96953255b2b2ceb01aba71ab05a9b6.jpg)
![](images/6224a4bc3bb3fff526317d952ecaefb0193e971eb4ad9b8535218af71348b2b5.jpg)
![](images/1e23e64fc8c427b27badc5ed269adafe120c9284013ae4302f520a3c40c8cf65.jpg)
Imbalanced-practical
![](images/2c5a1f73734a2b78a29aad82e9523b7253e8a1e7f7a62caa806f2056e9a789fa.jpg)
![](images/a746f9c488cac3021648f50744ff34f151a90e6c8dbd19e574c19c6aee4f055e.jpg)
Figure 4: Precision of AL strategies and the Random baseline in the imbalanced (two top rows) and imbalanced-practical (bottom row) scenarios. Train size indicates the size of L.
![](images/a376931d7f3398d2b4738f749ddb094b0422920c896752864af8d05ba81df824.jpg)
![](images/04dd0a1d19f8df9a0349756cd041c77c1e66090678afd94308fbfbf40b4e85ae.jpg)
![](images/6b93fb55b15452af63340adcd431a90bab80857af07ee4ff643ca572d4358cb9.jpg)
![](images/ef955b7dcea74e394c5bad060cca7cb3222bf73041d662adb38305d2a8125d19.jpg)
![](images/d90989a7783cee0ec5fc242c96d95c4162f09ab628962f2eb7647f44a2fc7b5c.jpg)
![](images/94b6d6a8ec6d6d3c538bf030061713ae4edd1ae389522062f3eb0660754709d3.jpg)
Imbalanced
![](images/472b39908a35a37a34926499d52f2074ec17fd45f3c450808bd879672de8d89e.jpg)
![](images/cca2aaa32071336f71b357db6a316d741617c6c5dbb60bedf2f698c696efbdf8.jpg)
![](images/7ada410962f6cf4a742ec9250798f20a1a6c8d6ab558d604e6ff6d654d38b0c5.jpg)
Imbalanced-practical
![](images/c0d6086706d5113b6838d5fa73ec23d15241b4b043d2d4354a84a5a412f7cc49.jpg)
![](images/db97014ced28ba6810ee611595040cfa2d1c8e61c29f445850b06cf090d3c820.jpg)
Figure 5: Recall of AL strategies and the Random baseline in the imbalanced (two top rows) and imbalanced-practical (bottom row) scenarios. Train size indicates the size of L.
![](images/0c15c3305042e989a784815790a1f08190978584469ea940f05e1f565529f9c9.jpg)
![](images/5a535b72cb4e2051874569d6fceba8337b3cea7ab892d477692d63261d1e615d.jpg)
![](images/fe77d0ee9015b08fc39bf0f03aacd3144df35f5a640487267421899fc054b35b.jpg)
![](images/97b5737c22124756118687e80fe917fbc3fcabaa613042ea218b4aec885a204d.jpg)