SlowGuess/NAACL_2021_OCR huggingface dataset:
ConvEx: Data-Efficient and Few-Shot Slot Labeling
Matthew Henderson<sup>1</sup> and Ivan Vulić<sup>1,2</sup>
$^{1}$  PolyAI Ltd, London, UK
$^{2}$  Language Technology Lab, University of Cambridge, UK
ivan@polyai.com
We propose ConVEx (Conversational Value Extractor), an efficient pretraining and fine-tuning neural approach for slot-labeling dialog tasks. Instead of relying on more general pretraining objectives from prior work (e.g., language modeling, response selection), ConVEx's pretraining objective, a novel pairwise cloze task using Reddit data, is well aligned with its intended usage on sequence labeling tasks. This enables learning domain-specific slot labelers by simply fine-tuning decoding layers of the pretrained general-purpose sequence labeling model, while the majority of the pretrained model's parameters are kept frozen. We report state-of-the-art performance of ConVEx across a range of diverse domains and data sets for dialog slot-labeling, with the largest gains in the most challenging, few-shot setups. We believe that ConVEx's reduced pretraining times (i.e., only 18 hours on 12 GPUs) and cost, along with its efficient fine-tuning and strong performance, promise wider portability and scalability for data-efficient sequence-labeling tasks in general.
Slot labeling or slot filling is a critical natural language understanding (NLU) component of any task-oriented dialog system (Young, 2002, 2010; Tur and De Mori, 2011, inter alia). Its goal is to fill the correct values associated with predefined slots: e.g., a dialog system for restaurant bookings is expected to fill slots such as date, time, and the number of guests with the values extracted from a user utterance (e.g., next Thursday, 7pm, 4 people).
Setting up task-oriented dialog systems, as well as slot labeling methods in particular, to support new tasks and domains is highly challenging due to inherent scarcity of expensive expert-annotated data for a plethora of intended use scenarios (Williams, 2014; Henderson et al., 2014; Budzianowski et al., 2018; Zhao et al., 2019). One
plausible and promising solution is the creation of data-efficient models that learn from only a handful annotated examples in few-shot scenarios. This approach has been shown promising for learning intent detectors (Casanueva et al., 2020; Krone et al., 2020; Bunk et al., 2020) as well as for slot-filling methods (Hou et al., 2020; Coope et al., 2020).
The dominant paradigm followed by the existing models of few-shot slot labeling is transfer learning (Ruder et al., 2019): 1) they rely on representations from models pretrained on large data collections in a self-supervised manner on some general NLP tasks such as (masked) language modeling (Devlin et al., 2019; Conneau et al., 2020; Brown et al., 2020) or response selection (Henderson et al., 2019b, 2020; Cer et al., 2018); and then 2) add additional task-specific layers for modeling the input sequences. However, we detect several gaps with the existing setup, and set to address them in this work. First, recent work in NLP has validated that a stronger alignment between a pretraining task and an end task can yield performance gains for tasks such as extractive question answering (Glass et al., 2020) and paraphrase and translation (Lewis et al., 2020). We ask whether it is possible to design a pretraining task which is more suitable for slot labeling in conversational applications. Second, is it possible to bypass learning sequence-level layers from scratch, and simply fine-tune them after pretraining instead? Third, is it possible to build a generally applicable model which fine-tunes pretrained "general" sequence-level layers instead of requiring specialized slot labeling algorithms from prior work (Krone et al., 2020; Hou et al., 2020)?
Inspired by these challenges, we propose ConvVEx (Conversational Value Extractor), a novel Transformer-based neural model which can be pretrained on large quantities of natural language data (e.g., Reddit) and then directly fine-tuned to a variety of slot-labeling tasks. Similar to prior work (Rastogi et al., 2019; Coope et al., 2020), ConvVEx
Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 3375-3389 June 6-11, 2021. ©2021 Association for Computational Linguistics
casts slot labeling as a span-based extraction task. For ConVEx, we introduce a new pretraining objective, termed pairwise cloze. This objective aligns well with the target downstream task: slot labeling for dialog, and emulates slot labeling relying on unlabeled sentence pairs from natural language data which share a keyphrase (i.e., a “value” for a specific “slot”). Instead of learning them from scratch as in prior work (Coope et al., 2020), ConVEx’s pretrained Conditional Random Fields (CRF) layers for sequence modeling are fine-tuned using a small number of labeled in-domain examples.
We evaluate ConVEx on a range of diverse dialog slot labeling data sets spanning different domains: DSTC8 data sets (Rastogi et al., 2019), RESTAURANTS-8K (Coope et al., 2020), and SNIPS (Coucke et al., 2018). ConVEx yields state-of-the-art performance across all evaluation data sets, but its true usefulness and robustness come to the fore in the few-shot scenarios. For instance, it increases average  $F_{1}$  scores on RESTAURANTS-8K over the previous state-of-the-art model (Coope et al., 2020) from 40.5 to 71.7 with only 64 labeled examples. Similar findings are observed with DSTC8, and we also report state-of-the-art performance in the 5-shot slot labeling task on SNIPS.
In summary, our results validate the benefits of task-aligned pretraining from raw natural language data, with particular gains for data-efficient slot labeling given a limited number of annotated examples, which is a scenario typically met in production. They also clearly demonstrate that competitive performance can be achieved via quick fine-tuning, without heavily engineered specialized methods from prior work (Hou et al., 2020). Further, we validate that learning sequence-level layers from scratch is inferior to fine-tuning from pretrained layers. From a broader perspective, we hope that this research will inspire further work on task-aligned pretraining objectives for other NLP tasks beyond slot labeling. From a more focused perspective, we hope that it will guide new approaches to data-efficient slot labeling for dialog.
Before we delve deeper into the description of ConVEx in §2.3, in §2.1 we first describe a novel sentence-pair value extraction pretraining task used by ConVEx, called pairwise cloze, and then in §2.2 a procedure that converts "raw" unlabeled natural language data into training examples.
2.1 Pretraining Task: Pairwise Cloze
Why Pairwise Cloze? Top performing natural language understanding models typically make use of neural nets pretrained on large scale data sets with unsupervised objectives such as language modeling (Devlin et al., 2019; Liu et al., 2019) or response selection (Henderson et al., 2020; Humeau et al., 2020). For sequential tasks such as slot labeling, this involves adding new layers and training them from scratch, as the pretraining procedure does not involve any sequential decoding; therefore, current unsupervised pretraining objectives are suboptimal for sequence-labeling tasks. With ConVEx, we introduce a new pretraining task with the following properties: 1) it is more closely related to the target slot-labeling task, and 2) it facilitates training all the necessary layers for slot-labeling, so these can be fine-tuned rather than learned from scratch.
What is Pairwise Cloze? In a nutshell, given a pair of sentences that have a keyphrase in common, the task treats one sentence as a template sentence and the other as its corresponding input sentence. For the template sentence, the keyphrase is masked out and replaced with a special BLANK token. The model must then read the tokens of both sentences, and predict which tokens in the input sentence constitute the masked phrase. Some examples of such pairs extracted from Reddit are provided in Table 1. The main idea is to teach the model an implicit space of slots and values, where during self-supervised pretraining, slots are represented as the contexts in which a value might occur. The model then gets fine-tuned later to fit domain-specific slot labeling data. $^{1}$
2.2 Pairwise Cloze Data Preparation
Input Data. We assume working with the English language throughout the paper. Reddit has been shown to provide natural conversational English data for learning semantic representations that work well in downstream tasks related to dialog and conversation (Al-Rfou et al., 2016; Cer et al., 2018; Henderson et al., 2019b,a, 2020; Casanueva et al., 2020; Coope et al., 2020). Therefore, following
<sup>1</sup>The pairwise cloze task has been inspired by the recent span selection objective applied to extractive QA by Glass et al. (2020): they create examples emulating extractive QA pairs with long passages and short question sentences. Another similar approach to extractive QA has been proposed by Ram et al. (2021). In contrast, our work seeks to emulate slot labeling in a dialog system by creating examples from short conversational utterances.
Template Sentence
I get frustrated every time I browse  $/ \tau /$  all. I stick to my BLANK most of the time.
Why Puerto Rico? It's Memphis at Dallas, which is in Texas where BLANK hit BLANK is my 3rd favorite animated Movie
It really sucks, as the V30 only has BLANK. Maybe the Oreo update will add this.
I took BLANK, cut it to about 2 feet long and duct taped Vive controllers on each end. Works perfect
I had BLANK and won the last game and ended up with 23/20 and still didn't get it.
Input Sentence
/r/misleadingpuddles Saw it on the frontpage, plenty of content if you like the premise.
Hurricane Harvey. Just a weird coincidence.
Toy Story 3 ended perfectly, but Disney just wants to keep milking it.
Thanks for the input, but 64GB is plenty for me:)
Yeah, I just duct taped mine to a broom stick. You can only play no arrows mode but it's really fun.
I know how you feel my friend and I got 19/20 on the tournament today
recent work, we start with the 3.7B comments in the large Reddit corpus from 2015-2018 (inclusive) (Henderson et al., 2019a), filtering it to comments between 9 and 127 characters in length. This yields a total of almost 2B filtered comments.
Keyphrase Identification. Training sentence pairs are extracted from unlabeled text based on their shared keyphrases. Therefore, we must first identify plausible candidate keyphrases. To this end, the filtered Reddit sentences are tokenized with a simple word tokenizer, and word frequencies are counted. The score of a candidate keyphrase  $kp = (w_{1}, w_{2}, \ldots, w_{n})$  is computed as a function of the individual word counts:
$$
\operatorname {s c o r e} (k p) = 1 / n ^ {\alpha} \sum_ {i = 1} ^ {n} \log \frac {| D |}{\operatorname {c o u n t} \left(w _ {i}\right)}. \tag {1}
$$
where  $|D|$  is the number of sentences used to calculate the word frequencies. This simple scoring function selects phrases that have informative low-frequency words. The factor  $\alpha$  controls the length of the identified keyphrases: e.g., setting it to  $\alpha = 0.8$ , which is default in our experiments later, encourages selecting longer phrases. Given a sentence, the keyphrases are selected as those unigrams, bigrams and trigrams whose score exceeds a predefined threshold.
The keyphrase identification procedure is run for all sentences from the filtered Reddit sentences. At most two keyphrases are extracted per sentence, and keyphrases spanning more than  $50\%$  of the sentence text are ignored. Keyphrases that occur more than once in the sentence are also ignored.
Sentence-Pair Data Extraction. In the next step, sentences from the same subreddit are paired by keyphrase to create paired data, 1.2 billion examples in total, $^{2}$  where one sentence acts as the input
Table 1: Sample data from Reddit converted to sentence pairs for the ConVEx pretraining via the pairwise cloze task. Target spans in the input sentence are denoted with bold, and are "BLANKed" in the template sentence.
Total Reddit comments	3,680,746,776
Comments filtered by length	1,993,294,538
Extracted keyphrases	3,296,519,827
Training set size	1,172,174,919
Test set size	61,696,649
Mean number of words per keyphrase	1.3
Table 2: Statistics of the pairwise cloze training data.
sentence and another as the template sentence (see Table 1 again). Table 2 summarizes statistics from the entire pretraining data preparation procedure.
2.3 The ConVEx Framework
We now present ConVEx, a pretraining and fine-tuning framework that can be applied to a wide spectrum of slot-labeling tasks. ConVEx is pretrained on the pairwise cloze task (§2.1), relying on sentence-pair data extracted from Reddit (§2.2). Similar to prior work (Coope et al., 2020), we frame slot labeling as a span extraction task: spans are represented using a sequence of tags. These tags indicate which members of the sequence are in the span. We use the same tag representation as Coope et al. (2020), which is similar to the standard IOB format: the span is annotated with a sequence of BEFORE, BEGIN, INSIDE and AFTER tags. The ConVEx pretraining and fine-tuning architectures are illustrated in Figures 1a and 1b respectively, and we describe them in what follows.
ConVEx: Pretraining. The ConVEx model encodes the template and input sentences using exactly the same Transformer layer architecture (Vaswani et al., 2017) as the lightweight and highly optimized ConveRT sentence encoder (Henderson et al., 2020): we refer the reader to the original work for all architectural and technical details. This model structure is very compact and resource
same in both sentences. For instance, the original keyphrase "Star Wars" will be expanded to the keyphrase "Star Wars movie" within this pair: "I really enjoyed the latest Star Wars movie." - "We could not stand any Star Wars movie."
2We also expand keyphrases inside paired sentences if there is additional text on either side of the keyphrase that is the
(a) ConVEx: Pretraining
(b) ConVEx: Fine-tuning
Figure 1: An overview of the ConVEx model structure at: (a) pretraining, and (b) fine-tuning. The full description of each component of the model at both stages is provided in §2.3.
efficient (i.e., it is 59MB in size and can be trained in 18 hours on 12 GPUs) while achieving state-of-the-art performance on a range of conversational tasks (Casanueva et al., 2020; Coope et al., 2020; Bunk et al., 2020). The weights in the ConveRT Transformer layers are shared for both sentences.3
The 512-dimensional output representations from the ConveRT layers are projected down to 128-dimensional representations using two separate feed-forward networks (FFNs), one for the template and one for the input sentence. The projected contextual subword representations of the input sentence are then enriched using two blocks of self-attention, attention over the projected template sentence representations, and FFN layers. This provides features for every token in the input sentence that take into account the context of both the input sentence and the template sentence. A final linear layer computes Conditional Random Field (CRF) parameters for tagging the value span using the 4 BEFORE, BEGIN, INSIDE, and AFTER labels.
More formally, for each step  $t$ , corresponding to a subword token in the input sentence, the network outputs a  $4 \times 4$  matrix of transition scores  $\mathbf{W}_t$  and a 4-dimensional vector of unary potentials  $\mathbf{u}_t$ . Under the CRF model, the probability of a predicted tag
sequence  $\mathbf{y}$  is then computed as:
The loss is the negative log-likelihood, which is equal to the negative sum of the transition scores and unary potentials that correspond to the true tag labels, up to a normalization term. The top scoring tag sequences are computed efficiently using the Viterbi algorithm (Sutton and McCallum, 2012).
In addition to the CRF loss, an auxiliary dot-product loss can be added. This loss encourages the model to pair template sentences with the corresponding (semantically similar) input sentences. Let  $\mathbf{f}_i^T$  be the  $d$ -dimensional encoding of the beginning-of-sentence (BOS) token for the  $i^{\mathrm{th}}$  template sentence, and  $\mathbf{f}_i^I$  be the encoding of the BOS token for the  $i^{\mathrm{th}}$  (corresponding) input sentence. As the encodings are contextual, the BOS representations can encapsulate the entire sequence. The auxiliary dot-product loss is then computed as:
$$
- \sum_ {i = 1} ^ {N} C \left\langle \mathbf {f} _ {i} ^ {T}, \mathbf {f} _ {i} ^ {I} \right\rangle + \sum_ {i = 1} ^ {N} \log \sum_ {j = 1} ^ {N} e ^ {C \left\langle \mathbf {f} _ {i} ^ {T}, \mathbf {f} _ {j} ^ {I} \right\rangle} \tag {2}
$$
where  $\langle \cdot, \cdot \rangle$  is cosine similarity and  $C$  is an annealing factor that linearly increases from 0 to  $\sqrt{d}$  over the first 10K training batches as in previous work (Henderson et al., 2020). The auxiliary loss is inspired by the dot-product loss typically used
3The ConVEx pretraining also closely follows ConveRT's tokenization process: the final subword vocabulary contains 31,476 subword tokens plus 1,000 buckets reserved for out-of-vocabulary tokens. Input text is split into subwords following a simple left-to-right greedy prefix matching (Vaswani et al., 2018; Henderson et al., 2020), and we tokenize both input sentences and template sentences the same way.
Activation	Fast GELU approximation
(Hendrycks and Gimpel, 2016)
Total batch size	256
Negatives per batch	64
Learning rate	0.3
Optimizer	Adadelta with ρ = 0.9 (Zeiler, 2012)
ConveRT layers	Same as in (Henderson et al., 2020)
Input / template FFN layer size	512, 128
Decoder FFN size	256
Decoder attention projections	16
Table 3: ConVEx: Hyper-parameters at pretraining.
in retrieval tasks such as response selection (Henderson et al., 2017). Note that this loss does not necessitate any additional model parameters, and does not significantly increase the computational complexity of the pretraining procedure. Later in §4 we evaluate the efficacy of pretraining with and without the auxiliary loss.
ConVEx: Fine-tuning. The majority of the computation and parameters of ConVEx are in the shared ConveRT Transformer encoder layers: they comprise 30M parameters, while the decoder layers comprise only 800K parameters. At ConVEx fine-tuning, the shared ConveRT transformer layers are frozen: these expensive operations are shared across slots, while the fine-tuned slot-specific models are small in memory and fast to run.
To apply the ConVEx model to slot-labeling for a specific slot, the user utterance is treated both as the input sentence and the template sentence (note that at fine-tuning and inference the user input does not contain any BLANK token) - see Figure 1b. This effectively makes the attention layers in the decoder act like additional self-attention layers. For some domains, additional context features such as the binary is_requested feature need to be incorporated (Coope et al., 2020): this is modeled through a residual layer that computes a term to add to the ConveRT output encoding, given the encoding itself and the additional features - see Figure 1b.
We again note that, except for the residual layer, no new layers are added between pretraining and fine-tuning; this implies that the model bypasses learning from scratch any potential complicated dynamics related to the application task, and is directly applicable to various slot-labeling scenarios.
Pretraining: Technical Details. The ConVEx parameters at pretraining are randomly initialized, including the ConveRT layers, and the model is pretrained on the pairwise cloze Reddit data. Pre
training proceeds in batches of 256 examples, 64 of which are randomly paired sentences where no value should be extracted, and the remaining being pairs from the training data. This teaches the model that sometimes no value should be predicted, a scenario frequently encountered with slot labeling. Table 3 provides a concise summary of these and other pretraining hyper-parameters.
Computational Efficiency and Tractability. ConVEx is pretrained for 18 hours on 12 Tesla K80 GPUs; this is typically sufficient to reach convergence. The total pretraining cost is roughly $85 on Google Cloud Platform. This pretraining regime is orders of magnitude cheaper and more efficient than the prevalent pretrained NLP models such as BERT (Devlin et al., 2019), GPT models (Brown et al., 2020), XLNet (Yang et al., 2019), RoBERTa (Liu et al., 2019), etc. The reduced pretraining cost allows for wider experimentation, and aligns with recent ongoing initiatives on improving fairness and inclusion in NLP/ML research and practice (Strubell et al., 2019; Schwartz et al., 2019).
Fine-tuning: Technical Details. We use the same fine-tuning procedure for all fine-tuning experiments on all evaluation data sets. It proceeds for 4,000 steps of batches of size 64, stopping early if the loss drops below 0.001. The ConveRT layers are frozen, while the other layers are initialized to their pretrained values and optimized with Adam (Kingma and Ba, 2015), with a learning rate of 0.001 that decays to  $10^{-6}$  over the first 3,500 steps using cosine decay (Loshchilov and Hutter, 2017). Dropout is applied to the output of the ConveRT layers with a rate of 0.5: it decays to 0 over 4,000 steps also using cosine decay. The residual layer for additional features (e.g., is_requested, token_is_numeric) consists of a single 1024-dim hidden layer. As we demonstrate later in §4, this procedure works well across a variety of data settings. The early stopping and dropout are intended to prevent overfitting on very small data sets.
Fine-tuning and Evaluation: Data and Setup. We rely on several diverse slot-labeling data sets, used as established benchmarks in previous work. First, we evaluate on a recent data set from Coope et al. (2020): RESTAURANTS-8K, which comprises conversations from a commercial restaurant book
4We enforce that exactly  $20\%$  of examples in each batch contain a value, and  $80\%$  contain no value. Further, the batch size is smaller than 64 in few-shot scenarios if the training set is too small to meet this ratio without introducing duplicates.
ing system. It covers 5 slots required for the booking task: date, time, people, first name, and last name. Second, we use the Schema-Guided Dialog Dataset (SGDD) (Rastogi et al., 2019), originally released for DSTC8, in the same way as prior work (Coope et al., 2020), extracting span annotated data sets from SGDD in four different domains. The particulars of the RESTAURANTS-8K and DSTC8 evaluation data are provided in the appendix.
Similar to Coope et al. (2020), we simulate few-shot scenarios and measure performance on smaller sets sampled from the full data. We (randomly) subsample the training sets of various sizes while maintaining the same test set.
Furthermore, we also evaluate ConVEx in the 5-shot evaluation task on the SNIPS data (Coucke et al., 2018), following the exact setup of Hou et al. (2020), which covers 7 diverse domains, ranging from Weather to Creative Work (see Table 4 later for the list of domains). The statistics of the SNIPS evaluation are also provided in the appendix.