SlowGuess/ACL_2020_OCR huggingface dataset:
Changmao Li
changmao.li@emory.edu
Jinho D. Choi
jinho. Choi@emory.edu
We introduce a novel approach to transformers that learns hierarchical representations in multiparty dialogue. First, three language modeling tasks are used to pre-train the transformers, token- and utterance-level language modeling and utterance order prediction, that learn both token and utterance embeddings for better understanding in dialogue contexts. Then, multitask learning between the utterance prediction and the token span prediction is applied to fine-tune for span-based question answering (QA). Our approach is evaluated on the FRIENDSQA dataset and shows improvements of  $3.8\%$  and  $1.4\%$  over the two state-of-the-art transformer models, BERT and ROBERTa, respectively.
Transformer-based contextualized embedding approaches such as BERT (Devlin et al., 2019), XLM (CONNEAU and Lample, 2019), XLNet (Yang et al., 2019), RoBERTa (Liu et al., 2019), and AlBERT (Lan et al., 2019) have re-established the state-of-the-art for practically all question answering (QA) tasks on not only general domain datasets such as SQUAD (Rajpurkar et al., 2016, 2018), MS MARCO (Nguyen et al., 2016), TRIVIAQA (Joshi et al., 2017), NEWSQA (Trischler et al., 2017), or NARRATIVEQA (Koisk et al., 2018), but also multi-turn question datasets such as SQA (Iyyer et al., 2017), QUAC (Choi et al., 2018), CoQA (Reddy et al., 2019), or CQA (Talmor and Berant, 2018). However, for span-based QA where the evidence documents are in the form of multiparty dialogue, the performance is still poor even with the latest transformer models (Sun et al., 2019; Yang and Choi, 2019) due to the challenges in representing utterances composed by heterogeneous speakers.
Several limitations can be expected for language models trained on general domains to process dialogue. First, most of these models are pre-trained
on formal writing, which is notably different from colloquial writing in dialogue; thus, fine-tuning for the end tasks is often not sufficient enough to build robust dialogue models. Second, unlike sentences in a wiki or news article written by one author with a coherent topic, utterances in a dialogue are from multiple speakers who may talk about different topics in distinct manners such that they should not be represented by simply concatenating, but rather as sub-documents interconnected to one another.
This paper presents a novel approach to the latest transformers that learns hierarchical embeddings for tokens and utterances for a better understanding in dialogue contexts. While fine-tuning for span-based QA, every utterance as well as the question are separated encoded and multi-head attention and additional transformers are built on the token and utterance embeddings respectively to provide a more comprehensive view of the dialogue to the QA model. As a result, our model achieves a new state-of-the-art result on a span-based QA task where the evidence documents are multiparty dialogue. The contributions of this paper are:1
- New pre-training tasks are introduced to improve the quality of both token-level and utterance-level embeddings generated by the transformers, that better suit to handle dialogue contexts (§2.1).
- A new multi-task learning approach is proposed to fine-tune the language model for span-based QA that takes full advantage of the hierarchical embeddings created from the pre-training (§2.2).
- Our approach significantly outperforms the previous state-of-the-art models using BERT and RoBERTa on a span-based QA task using dialogues as evidence documents (§3).
<sup>1</sup>All our resources including the source codes and the dataset with the experiment split are available at
https://github.com/emorynlp/friendsqa
5709
Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 5709-5714
(a) Token-level MLM (§2.1.1)
(b) Utterance-level MLM (§2.1.2)
(c) Utterance order prediction (§2.1.3)
Figure 1: The overview of our models for the three pre-training tasks (Section 2.1).
2 Transformers for Learning Dialogue
This section introduces a novel approach for pretraining (Section 2.1) and fine-tuning (Section 2.2) transformers to effectively learn dialogue contexts. Our approach has been evaluated with two kinds of transformers, BERT (Devlin et al., 2019) and RoBERTa (Liu et al., 2019), and shown significant improvement to a question answering task (QA) on multiparty dialogue (Section 3).
2.1 Pre-training Language Models
Pre-training involves 3 tasks in sequence, the token-level masked language modeling (MLM; §2.1.1), the utterance-level MLM (§2.1.2), and the utterance order prediction (§2.1.3), where the trained weights from each task are transferred to the next task. Note that the weights of publicly available transformer encoders are adapted to train the token-level MLM, which allows our QA model to handle languages in both dialogues, used as evidence documents, and questions written in formal writing. Transformers from BERT and RoBERTa are trained with static and dynamic MLM respectively, as described by Devlin et al. (2019); Liu et al. (2019).
2.1.1 Token-level Masked LM
Figure 1(a) illustrates the token-level MLM model. Let  $D = \{U_1, \ldots, U_m\}$  be a dialogue where  $U_i = \{s_i, w_{i1}, \ldots, w_{in}\}$  is the  $i$ 'th utterance in  $D$ ,  $s_i$  is the speaker of  $U_i$ , and  $w_{ij}$  is the  $j$ 'th token in  $U_i$ .
All speakers and tokens in  $D$  are appended in order with the special token CLS, representing the entire dialogue, which creates the input string sequence  $I = \{\mathrm{CLS}\} \oplus U_1\oplus \ldots \oplus U_n$ . For every  $w_{ij}\in I$ , let  $I_{ij}^{\mu} = (I\setminus \{w_{ij}\})\cup \{\mu_{ij}\}$ , where  $\mu_{ij}$  is the masked token substituted in place of  $w_{ij}$ .  $I_{ij}^{\mu}$  is then fed into the transformer encoder (TE), which generates a sequence of embeddings  $\{e^{c}\} \oplus E_{1}\oplus \dots \oplus E_{m}$  where  $E_{i} = \{e_{i}^{s},e_{i1}^{w},\dots,e_{in}^{w}\}$  is the embedding list for  $U_{i}$ , and  $(e^{c},e_{i}^{s},e_{ij}^{w},e_{ij}^{\mu})$  are the embeddings of (CLS,  $s_i,w_{ij},\mu_{ij}$ ) respectively. Finally,  $e_{ij}^{\mu}$  is fed into a softmax layer that generates the output vector  $o_{ij}^{\mu}\in \mathbb{R}^{|V|}$  to predict  $\mu_{ij}$ , where  $V$  is the set of all vocabularies in the dataset.
2.1.2 Utterance-level Masked LM
The token-level MLM (t-MLM) learns attentions among all tokens in  $D$  regardless of the utterance boundaries, allowing the model to compare every token to a broad context; however, it fails to catch unique aspects about individual utterances that can be important in dialogue. To learn an embedding for each utterance, the utterance-level MLM model is trained (Figure 1(b)). Utterance embeddings can be used independently and/or in sequence to match contexts in the question and the dialogue beyond the token-level, showing an advantage in finding utterances with the correct answer spans (§2.2.1).
${}^{2}n$  : the maximum number of words in every utterance,  $m$  : the maximum number of utterances in every dialogue.
5710
Figure 2: The overview of our fine-tuning model exploiting multi-task learning (Section 2.2).
For every utterance  $U_{i}$ , the masked input sequence  $I_{ij}^{\mu} = \{\mathrm{CLS}_{i}\} \oplus \{(U_{i} \setminus \{w_{ij}\}) \cup \mu_{ij}\}$  is generated. Note that  $\mathrm{CLS}_{i}$  now represents  $U_{i}$  instead of  $D$  and  $I_{ij}^{\mu}$  is much shorter than the one used for t-MLM.  $I_{ij}^{\mu}$  is fed into TE, already trained by t-MLM, and the embedding sequence  $E_{i} = \{e_{i}^{c}, e_{i}^{s}, e_{i1}^{w}, \dots, e_{in}^{w}\}$  is generated. Finally,  $e_{i}^{c}$ , instead of  $e_{ij}^{\mu}$ , is fed into a softmax layer that generates  $o_{ij}^{\mu}$  to predict  $\mu_{ij}$ . The intuition behind the utterance-level MLM is that once  $e_{i}^{c}$  learns enough contents to accurately predict any token in  $U_{i}$ , it consists of most essential features about the utterance; thus,  $e_{i}^{c}$  can be used as the embedding of  $U_{i}$ .
2.1.3 Utterance Order Prediction
The embedding  $e_i^c$  from the utterance-level MLM (u-MLM) learns contents within  $U_i$ , but not across other utterances. In dialogue, it is often the case that a context is completed by multiple utterances; thus, learning attentions among the utterances is necessary. To create embeddings that contain cross-utterance features, the utterance order prediction model is trained (Figure 1(c)). Let  $D = D_1 \oplus D_2$  where  $D_1$  and  $D_2$  comprise the first and the second halves of the utterances in  $D$ , respectively. Also, let  $D' = D_1 \oplus D_2'$  where  $D_2'$  contains the same set of utterances as  $D_2$  although the ordering may be different. The task is whether or not  $D'$  preserves the same order of utterances as  $D$ .
For each  $U_{i}\in D^{\prime}$  , the input  $I_{i} = \{\mathrm{CLS}_{i}\} \oplus U_{i}$  is created and fed into TE, already trained by u-MLM, to create the embeddings  $E_{i} = \{e_{i}^{c},e_{i}^{s},e_{i1}^{w},\dots,e_{in}^{w}\}$  The sequence  $E^c = \{e_1^c,\ldots ,e_n^c\}$  is fed into two transformer layers, TL1 and TL2, that generate the new utterance embedding list  $T^c = \{t_1^c,\dots,t_n^c\}$  Finally,  $T^c$  is fed into a softmax layer that generates  $o^\nu \in \mathbb{R}^2$  to predict whether or not  $D^{\prime}$  is in order.
2.2 Fine-tuning for QA on Dialogue
Fine-tuning exploits multi-task learning between the utterance ID prediction (§2.2.1) and the token span prediction (§2.2.2), which allows the model to train both the utterance- and token-level attentions. The transformer encoder (TE) trained by the utterance order prediction (UOP) is used for both tasks. Given the question  $Q = \{q_{1},\ldots ,q_{n}\}$  ( $q_{i}$  is the  $i$ 'th token in  $Q$ ) and the dialogue  $D = \{U_1,\dots ,U_m\}$ ,  $Q$  and all  $U_{*}$  are fed into TE that generates  $E_{q} = \{e_{q}^{c},e_{1}^{q},\dots ,e_{n}^{q}\}$  and  $E_{i} = \{e_{i}^{c},e_{i}^{s},e_{i1}^{w},\dots ,e_{in}^{w}\}$  for  $Q$  and every  $U_{i}$ , respectively.
2.2.1 Utterance ID Prediction
The utterance embedding list  $E^{c} = \{e_{q}^{c}, e_{1}^{c}, \dots, e_{n}^{c}\}$  is fed into TL1 and TL2 from UOP that generate  $T^{c} = \{t_{q}^{c}, t_{1}^{c}, \dots, t_{n}^{c}\}$ .  $T^{c}$  is then fed into a softmax layer that generates  $o^{u} \in \mathbb{R}^{m + 1}$  to predict the ID of the utterance containing the answer span if exists; otherwise, the 0'th label is predicted, implying that the answer span for  $Q$  does not exist in  $D$ .
2.2.2 Token Span Prediction
For every  $E_{i}$ , the pair  $(E_q', E_i')$  is fed into the multihead attention layer, MHA, where  $E_{q}' = E_{q} \setminus \{e_{q}^{c}\}$  and  $E_{i}' = E_{i} \setminus \{e_{i}^{c}\}$ . MHA (Vaswani et al., 2017) then generates the attended embedding sequences,  $T_1^a, \ldots, T_m^a$ , where  $T_i^a = \{t_i^s, t_{i1}^w, \ldots, t_{in}^w\}$ . Finally, each  $T_i^a$  is fed into two softmax layers, SL and SR, that generate  $o_i^\ell \in \mathbb{R}^{n+1}$  and  $o_i^r \in \mathbb{R}^{n+1}$  to predict the leftmost and the rightmost tokens in  $U_i$  respectively, that yield the answer span for  $Q$ . It is possible that the answer spans are predicted in multiple utterances, in which case, the span from the utterance that has the highest score for the utterance ID prediction is selected, which is more efficient than the typical dynamic programming approach.
5711
Despite of all great work in QA, only two datasets are publicly available for machine comprehension that take dialogues as evidence documents. One is DREAM comprising dialogues for language exams with multiple-choice questions (Sun et al., 2019). The other is FRIENDSQA containing transcripts from the TV show Friends with annotation for span-based question answering (Yang and Choi, 2019). Since DREAM is for a reading comprehension task that does not need to find the answer contents from the evidence documents, it is not suitable for our approach; thus, FRIENDSQA is chosen.
Each scene is treated as an independent dialogue in FRIENDSQA. Yang and Choi (2019) randomly split the corpus to generate training, development, and evaluation sets such that scenes from the same episode can be distributed across those three sets, causing inflated accuracy scores. Thus, we re-split them by episodes to prevent such inflation. For finetuning ( $\S 2.2$ ), episodes from the first four seasons are used as described in Table 1. For pre-training ( $\S 2.1$ ), all transcripts from Seasons 5-10 are used as an additional training set.
Set	D	Q	A	E
Training	973	9,791	16,352	1 - 20
Development	113	1,189	2,065	21 - 22
Evaluation	136	1,172	1,920	23 - *
The weights from the BERTbase and ROBERTabase models (Devlin et al., 2019; Liu et al., 2019) are transferred to all models in our experiments. Four baseline models, BERT, BERTpre, RoBERTa, and ROBERTapre, are built, where all models are finetuned on the datasets in Table 1 and the  $\star_{\mathrm{pre}}$  models are pre-trained on the same datasets with the additional training set from Seasons 5-10 ( $\S 3.1$ ). The baseline models are compared to BERTour and ROBERTAour that are trained by our approach. $^3$
Table 2 shows results achieved by all the models. Following Yang and Choi (2019), exact matching (EM), span matching (SM), and utterance matching (UM) are used as the evaluation metrics. Each
model is developed three times and their average score as well as the standard deviation are reported. The performance of ROBERTa  $\star$  is generally higher than BERT  $\star$  although ROBERTa  $\mathrm{base}$  is pre-trained with larger datasets including CC-NEWS (Nagel, 2016), OPENWEBTEXT (Gokaslan and Cohen, 2019), and STORIES (Trinh and Le, 2018) than BERT  $\mathrm{base}$  such that results from those two types of transformers cannot be directly compared.
Table 1: New data split for FriendsQA. D/Q/A: # of dialogues/questions/answers, E: episode IDs.
Model	EM	SM	UM
BERT	43.3(±0.8)	59.3(±0.6)	70.2(±0.4)
BERTpre	45.6(±0.9)	61.2(±0.7)	71.3(±0.6)
BERTour	46.8(±1.3)	63.1(±1.1)	73.3(±0.7)
RoBERTa	52.6(±0.7)	68.2(±0.3)	80.9(±0.8)
RoBERTa pre	52.6(±0.7)	68.6(±0.6)	81.7(±0.7)
RoBERTa our	53.5(±0.7)	69.6(±0.8)	82.7(±0.5)
The  $\star_{\mathrm{pre}}$  models show marginal improvement over their base models, implying that pre-training the language models on FRIENDSQA with the original transformers does not make much impact on this QA task. The models using our approach perform noticeably better than the baseline models, showing  $3.8\%$  and  $1.4\%$  improvements on SM from BERT and ROBERTa, respectively.
Table 2: Accuracies (± standard deviations) achieved by the BERT and ROBERTa models.
Type	Dist.	EM	SM	UM
Where	18.16	66.1(±0.5)	79.9(±0.7)	89.8(±0.7)
When	13.57	63.3(±1.3)	76.4(±0.6)	88.9(±1.2)
What	18.48	56.4(±1.7)	74.0(±0.5)	87.7(±2.1)
Who	18.82	55.9(±0.8)	66.0(±1.7)	79.9(±1.1)
How	15.32	43.2(±2.3)	63.2(±2.5)	79.4(±0.7)
Why	15.65	33.3(±2.0)	57.3(±0.8)	69.8(±1.8)
Table 3: Results from the ROBERTaour model by different question types.
Table 3 shows the results achieved by ROBERTa our w.r.t. question types. UM drops significantly for Why that often spans out to longer sequences and also requires deeper inferences to answer correctly than the others. Compared to the baseline models, our models show more well-around performance regardless the question types.
Table 4 shows the results from ablation studies to analyze the impacts of the individual approaches. BERTpre and ROBERTa pre are the same as in Table 2, that are the transformer models pre-trained by
Question type results for all models are in Appendices.
<sup>3</sup>Detailed experimental setup are provided in Appendices.
5712
the token-level masked LM (§2.1.1) and fine-tuned by the token span prediction (§2.2.2). BERTuid and ROBERTauid are the models that are pre-trained by the token-level masked LM and jointly fine-tuned by the token span prediction as well as the utterance ID prediction (UID: §2.2.1). Given these two types of transformer models, the utterance-level masked LM (ULM: §2.1.2) and the utterance order prediction (UOP: §2.1.3) are separately evaluated.
Model	EM	SM	UM
BERTpre	45.6(±0.9)	61.2(±0.7)	71.3(±0.6)
⊕ULM	45.7(±0.9)	61.8(±0.9)	71.8(±0.5)
⊕ULM⊕UOP	45.6(±0.9)	61.7(±0.7)	71.7(±0.6)
BERTuid	45.7(±0.8)	61.1(±0.8)	71.5(±0.5)
⊕ULM	46.2(±1.1)	62.4(±1.2)	72.5(±0.8)
⊕ULM⊕UOP	46.8(±1.3)	63.1(±1.1)	73.3(±0.7)
RoBERTa pre	52.6(±0.7)	68.6(±0.6)	81.7(±0.7)
⊕ULM	52.9(±0.8)	68.7(±1.1)	81.7(±0.6)
⊕ULM⊕UOP	52.5(±0.8)	68.8(±0.5)	81.9(±0.7)
RoBERTa uid	52.8(±0.9)	68.7(±0.8)	81.9(±0.5)
⊕ULM	53.2(±0.6)	69.2(±0.7)	82.4(±0.5)
⊕ULM⊕UOP	53.5(±0.7)	69.6(±0.8)	82.7(±0.5)
These two dialogue-specific LM approaches, ULM and UOP, give very marginal improvement over the baseline models, that is rather surprising. However, they show good improvement when combined with UID, implying that pre-training language models may not be enough to enhance the performance by itself but can be effective when it is coupled with an appropriate fine-tuning approach. Since both ULM and UOP are designed to improve the quality of utterance embeddings, it is expected to improve the accuracy for UID as well. The improvement on UM is indeed encouraging, giving  $2\%$  and  $1\%$  boosts to  $\mathrm{BERT}_{\mathrm{pre}}$  and  $\mathrm{ROBERTa}_{\mathrm{pre}}$ , respectively and consequently improving the other two metrics.
As shown in Table 3, the major errors are from the three types of questions, who, how, and why; thus, we select 100 dialogues associated with those question types that our best model, ROBERTaour, incorrectly predicts the answer spans for. Specific examples are provided in Tables 12, 13 and 14 (§A.3). Following Yang et al. (2019), errors are grouped into 6 categories, entity resolution, paraphrase and partial match, cross-utterance reasoning, question bias, noise in annotation, and miscellaneous.
Table 5 shows the errors types and their ratios with respect to the question types. Two main error types are entity resolution and cross-utterance reasoning. The entity resolution error happens when many of the same entities are mentioned in multiple utterances. This error also occurs when the QA system is asked about a specific person, but predicts wrong people where there are so many people appearing in multiple utterances. The cross-utterance reasoning error often happens with the why and how questions where the model relies on pattern matching mostly and predicts the next utterance span of the matched pattern.
Table 4: Results for the ablation studies. Note that the  $\star_{\mathrm{uid}}\oplus \mathrm{ULM}\oplus \mathrm{UOP}$  models are equivalent to the  $\star_{\mathrm{our}}$  models in Table 2, respectively.
Error Types	Who	How	Why
Entity Resolution	34%	23%	20%
Paraphrase and Partial Match	14%	14%	13%
Cross-Utterance Reasoning	25%	28%	27%
Question Bias	11%	13%	17%
Noise in Annotation	4%	7%	9%
Miscellaneous	12%	15%	14%
Table 5: Error types and their ratio with respect to the three most challenging question types.
This paper introduces a novel transformer approach that effectively interprets hierarchical contexts in multiparty dialogue by learning utterance embeddings. Two language modeling approaches are proposed, utterance-level masked LM and utterance order prediction. Coupled with the joint inference between token span prediction and utterance ID prediction, these two language models significantly outperform two of the state-of-the-art transformer approaches, BERT and RoBERTa, on a span-based QA task called FriendsQA. We will evaluate our approach on other machine comprehension tasks using dialogues as evidence documents to further verify the generalizability of this work.
We gratefully acknowledge the support of the AWS Machine Learning Research Awards (MLRA). Any contents in this material are those of the authors and do not necessarily reflect the views of them.
Eunsol Choi, He He, Mohit Iyyer, Mark Yatskar, Wentau Yih, Yejin Choi, Percy Liang, and Luke Zettle-moyer. 2018. Quac: Question answering in context.
5713
Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing.
Alexis CONNEAU and Guillaume Lample. 2019. Cross-lingual language model pretraining. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 7057-7067. Curran Associates, Inc.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL'19, pages 4171-4186.
Aaron Gokaslan and Vanya Cohen. 2019. OpenWeb-Text Corpus.
Mohit Iyyer, Wen-tau Yih, and Ming-Wei Chang. 2017. Search-based neural structured learning for sequential question answering. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1821–1831, Vancouver, Canada. Association for Computational Linguistics.
Mandar Joshi, Eunsol Choi, Daniel Weld, and Luke Zettlemoyer. 2017. Triviaqa: A large scale distantly supervised challenge dataset for reading comprehension. Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).
Tom Koisk, Jonathan Schwarz, Phil Blunsom, Chris Dyer, Karl Moritz Hermann, Gbor Melis, and Edward Grefenstette. 2018. The narrativeqa reading comprehension challenge. Transactions of the Association for Computational Linguistics, 6:317328.
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.
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. arXiv, 1907.11692.
Sebastian Nagel. 2016. News Dataset Available.
Tri Nguyen, Mir Rosenberg, Xia Song, Jianfeng Gao, Saurabh Tiwary, Rangan Majumder, and Li Deng. 2016. MS MARCO: A human generated machine reading comprehension dataset. In Proceedings of the Workshop on Cognitive Computation: Integrating neural and symbolic approaches 2016 collocated with the 30th Annual Conference on Neural Information Processing Systems (NIPS 2016), Barcelona, Spain, December 9, 2016.