SlowGuess/ACL_2020_OCR huggingface dataset:
Zhengbao Jiang $^{1}$ , Wei Xu $^{2}$ , Jun Araki $^{3}$ , Graham Neubig $^{1}$
Department of Computer Science and Engineering, Ohio State University
Bosch Research North America<sup>3</sup>
{zhengbai,gneubig}@cs.cmu.edu1
xu.1265@osu.edu², jun.araki@us.bosch.com³
Natural language processing covers a wide variety of tasks predicting syntax, semantics, and information content, and usually each type of output is generated with specially designed architectures. In this paper, we provide the simple insight that a great variety of tasks can be represented in a single unified format consisting of labeling spans and relations between spans, thus a single task-independent model can be used across different tasks. We perform extensive experiments to test this insight on 10 disparate tasks spanning dependency parsing (syntax), semantic role labeling (semantics), relation extraction (information content), aspect based sentiment analysis (sentiment), and many others, achieving performance comparable to state-of-the-art specialized models. We further demonstrate benefits of multi-task learning, and also show that the proposed method makes it easy to analyze differences and similarities in how the model handles different tasks. Finally, we convert these datasets into a unified format to build a benchmark, which provides a holistic testbed for evaluating future models for generalized natural language analysis.
A large number of natural language processing (NLP) tasks exist to analyze various aspects of human language, including syntax (e.g., constituency and dependency parsing), semantics (e.g., semantic role labeling), information content (e.g., named entity recognition and relation extraction), or sentiment (e.g., sentiment analysis). At first glance, these tasks are seemingly very different in both the structure of their output and the variety of information that they try to capture. To handle these different characteristics, researchers usually use specially designed neural network architectures. In this paper we ask the simple questions: are the
Figure 1: An example from BRAT, consisting of POS, NER, and RE.
task-specific architectures really necessary? Or with the appropriate representational methodology, can we devise a single model that can perform — and achieve state-of-the-art performance on — a large number of natural language analysis tasks?
Interestingly, in the domain of efficient human annotation interfaces, it is already standard to use unified representations for a wide variety of NLP tasks. Figure 1 shows one example of the BRAT (Stenetorp et al., 2012) annotation interface, which has been used for annotating data for tasks as broad as part-of-speech tagging, named entity recognition, relation extraction, and many others. Notably, this interface has a single unified format that consists of spans (e.g., the span of an entity), labels on the spans (e.g., the variety of entity such as "person" or "location"), and labeled relations between the spans (e.g., "born-in"). These labeled relations can form a tree or a graph structure, expressing the linguistic structure of sentences (e.g., dependency tree). We detail this BRAT format and how it can be used to represent a wide number of natural language analysis tasks in Section 2.
The simple hypothesis behind our paper is: if humans can perform natural language analysis in a single unified format, then perhaps machines can as well. Fortunately, there already exist NLP models that perform span prediction and prediction of relations between pairs of spans, such as the end-to-end coreference model of Lee et al. (2017). We extend this model with minor architectural modifications (which are not our core contributions) and pre-trained contextualized representations (e.g.,
Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 2120-2133 July 5 - 10, 2020. ©2020 Association for Computational Linguistics
Information Extraction	POS	Parsing	SRL	Sentiment
NER	RE	Coref.	OpenIE	Dep.	Consti.	ABSA	ORL
Different Models for Different Tasks
ELMo (Peters et al., 2018)	✓	X	✓	X	X	X	X	X	✓	X
BERT (Devlin et al., 2019)	✓	X	X	X	X	X	X	X	X	X
SpanBERT (Joshi et al., 2019)	X	✓	✓	X	X	X	X	X	X	X
Single Model for Different Tasks
Guo et al. (2016)	X	✓	X	X	X	X	X	✓	X	X
Swayamdipta et al. (2018)	X	X	✓	X	X	X	✓	✓	X	X
Strubell et al. (2018)	X	X	X	X	✓	✓	X	✓	X	X
Clark et al. (2018)	✓	X	X	X	✓	✓	X	X	X	X
Luan et al. (2018, 2019)	✓	✓	✓	X	X	X	X	X	X	X
Dixit and Al-Onaizan (2019)	✓	✓	X	X	X	X	X	X	X	X
Marasović and Frank (2018)	X	X	X	X	X	X	X	✓	X	✓
Hashimoto et al. (2017)	X	X	X	X	✓	✓	X	X	X	X
This Work	✓	✓	✓	✓	✓	✓	✓	✓	✓	✓
Table 1: A comparison of the tasks covered by previous work and our work.
BERT; Devlin et al.  $(2019)^{1}$  ) then demonstrate the applicability and versatility of this single model on 10 tasks, including named entity recognition (NER), relation extraction (RE), coreference resolution (Coref.), open information extraction (OpenIE), part-of-speech tagging (POS), dependency parsing (Dep.), constituency parsing (Consti.), semantic role labeling (SRL), aspect based sentiment analysis (ABSA), and opinion role labeling (ORL). While previous work has used similar formalisms to understand the representations learned by pretrained embeddings (Tenney et al., 2019a,b), to the best of our knowledge this is the first work that uses such a unified model to actually perform analysis. Moreover, we demonstrate that despite the model's simplicity, it can achieve comparable performance with special-purpose state-of-the-art models on the tasks above (Table 1). We also demonstrate that this framework allows us to easily perform multi-task learning (MTL), leading to improvements when there are related tasks to be learned from or data is sparse. Further analysis shows that dissimilar tasks exhibit divergent attention patterns, which explains why MTL is harmful on certain tasks. We have released our code and the General Language Analysis Datasets (GLAD) benchmark with 8 datasets covering 10 tasks in the BRAT format
at https://github.com/neulab/cmu-multinlp, and provide a leaderboard to facilitate future work on generalized models for NLP.
2 Span-relation Representations
In this section, we explain how the BRAT format can be used to represent a large number of tasks. There are two fundamental types of annotations: span annotations and relation annotations. Given a sentence  $\mathbf{x} = [w_{1}, w_{2}, \dots, w_{n}]$  of  $n$  tokens, a span annotation  $(s_{i}, l_{i})$  consists of a contiguous span of tokens  $s_{i} = [w_{b_{i}}, w_{b_{i+1}}, \dots, w_{e_{i}}]$  and its label  $l_{i}$  ( $l_{i} \in \mathcal{L}$ ), where  $b_{i}/e_{i}$  are the start/end indices respectively, and  $\mathcal{L}$  is a set of span labels. A relation annotation  $(s_{j}, s_{k}, r_{jk})$  refers to a relation  $r_{jk}$  ( $r_{jk} \in \mathcal{R}$ ) between the head span  $s_{j}$  and the tail span  $s_{k}$ , where  $\mathcal{R}$  is a set of relation types. This span-relation representation can easily express many tasks by defining  $\mathcal{L}$  and  $\mathcal{R}$  accordingly, as summarized in Table 2a and Table 2b. These tasks fall in two categories: span-oriented tasks, where the goal is to predict labeled spans (e.g., named entities in NER) and relation-oriented tasks, where the goal is to predict relations between two spans (e.g., relation between two entities in RE). For example, constituency parsing (Collins, 1997) is a span-oriented task aiming to produce a syntactic parse tree for a sentence, where each node of the tree is an individual span associated with a constituent label. Coreference resolution (Pradhan et al., 2012) is a relation-oriented task that links an expression to its mentions within or beyond a single sentence. Dependency parsing (Kübler et al.,
<sup>1</sup>In contrast to work on pre-trained contextualized representations like ELMo (Peters et al., 2018) or BERT (Devlin et al., 2019) that learn unified features to represent the input in different tasks, we propose a unified representational methodology that represents the output of different tasks. Analysis models using BERT still use special-purpose output predictors for specific tasks or task classes.
Task	Spans annotated with labels
NER	Barack Obama was born in Hawaii. person location
Consti.	And their suspicions of each other run deep. NP NP PP NP S
POS	What kind of memory?
WP NN IN NN
ABSA	Great laptop that offers many great features! positive
Table 2a: Span-oriented tasks. Spans are annotated by underlines and their labels.
Task	Spans and relations annotated with labels
RE	cause-effect
The burst has been caused by pressure.
Coref.	I voted for Tom because he is clever.
ARG0, ARG2, ARG1
SRL	We brought you the tale of two cities.
ARG0, ARG1
OpenIE	The four lawyers climbed out from under a table.
det amod nsubj doobj advmod nummod
Dep.	The entire division employs about 850 workers.
holder target
ORL	We therefore as MDC do not accept this result.
Table 2b: Relation-oriented tasks. Directed arcs indicate the relations between spans.
2009) is also a relation-oriented task that aims to relate a word (single-word span) to its syntactic parent word with the corresponding dependency type. Detailed explanations of all tasks can be found in Appendix A.
While the tasks above represent a remarkably broad swath of NLP, it is worth mentioning what we have not covered, to properly scope this work. Notably, sentence-level tasks such as text classification and natural language inference are not covered, although they can also be formulated using this span-relation representation by treating the entire sentence as a span. We chose to omit these tasks because they are already well-represented by previous work on generalized architectures (Lan and Xu, 2018) and multi-task learning (Devlin et al., 2019; Liu et al., 2019), and thus we mainly focus on tasks using phrase-like spans. In addition, the span-relation representations described here are designed for natural language analysis, and cannot handle tasks that require generation of text, such as machine translation (Bojar et al., 2014), dialog response generation (Lowe et al., 2015), and summarization (Nallapati et al., 2016). There are also a small number of analysis tasks such as semantic parsing to logical forms (Banarescu et al., 2013) where the outputs are not directly associated with spans in the input, and handling these tasks is beyond the scope of this work.
3 Span-relation Model
Now that it is clear that a very large number of analysis tasks can be formulated in a single format, we turn to devising a single model that can solve these tasks. We base our model on a span-based model first designed for end-to-end coreference resolution
(Lee et al., 2017), which is then adapted for other tasks (He et al., 2018; Luan et al., 2018, 2019; Dixit and Al-Onaizan, 2019; Zhang and Zhao, 2019). At the core of the model is a module to represent each span as a fixed-length vector, which is used to predict labels for spans or span pairs. We first briefly describe the span representation used and proven to be effective in previous works, then highlight some details we introduce to make this model generalize to a wide variety of tasks.
Span Representation Given a sentence  $\mathbf{x} = [w_1, w_2, \dots, w_n]$  of  $n$  tokens, a span  $s_i = [w_{b_i}, w_{b_i + 1}, \dots, w_{e_i}]$  is represented by concatenating two components: a content representation  $\mathbf{z}_i^c$  calculated as the weighted average across all token embeddings in the span, and a boundary representation  $\mathbf{z}_i^u$  that concatenates the embeddings at the start and end positions of the span. Specifically,
$$
\begin{array}{l} \mathbf {c} _ {1}, \mathbf {c} _ {2}, \dots , \mathbf {c} _ {n} = \operatorname {T o k e n R e p r} \left(w _ {1}, w _ {2}, \dots , w _ {n}\right), (1) \\ \mathbf {u} _ {1}, \mathbf {u} _ {2}, \dots , \mathbf {u} _ {n} = \operatorname {B i L S T M} \left(\mathbf {c} _ {1}, \mathbf {c} _ {2}, \dots , \mathbf {c} _ {n}\right), (2) \\ \mathbf {z} _ {i} ^ {c} = \operatorname {S e l f A t t n} \left(\mathbf {c} _ {b _ {i}}, \mathbf {c} _ {b _ {i} + 1}, \dots , \mathbf {c} _ {e _ {i}}\right), (3) \\ \mathbf {z} _ {i} ^ {u} = \left[ \mathbf {u} _ {b _ {i}}; \mathbf {u} _ {e _ {i}} \right], \mathbf {z} _ {i} = \left[ \mathbf {z} _ {i} ^ {c}; \mathbf {z} _ {i} ^ {u} \right], (4) \\ \end{array}
$$
where TokenRepr could be non-contextualized, such as GloVe (Pennington et al., 2014), or contextualized, such as BERT (Devlin et al., 2019). We refer to Lee et al. (2017) for further details.
Span and Relation Label Prediction Since we extract spans and relations in an end-to-end fashion, we introduce two additional labels NEG_SPAN and NEG_REL in  $\mathcal{L}$  and  $\mathcal{R}$  respectively. NEG_SPAN indicates invalid spans (e.g., spans that are not named entities in NER) and NEG_REL indicates invalid span pairs without any relation between them (i.e., no relation exists between two arguments in SRL). We first predict labels for all spans up to a length
Dataset	Domain	#Sent.	Task	#Spans	#Relations	Metric
Wet Lab Protocols (Kulkarni et al., 2018)	biology	14,301	NER	60,745	-	F1
RE	60,745	43,773	F1
CoNLL-2003 (Sang and Meulder, 2003)	news	20,744	NER	35,089	-	F1
SemEval-2010 Task 8 (Hendrickx et al., 2010)	misc.	10,717	RE	21,437	10,717	Macro F1°
OntoNotes 5.0* (Pradhan et al., 2013)	misc.	94,268	Coref.	194,477	1,166,513	Avg F1
SRL	745,796	543,534	F1
POS	1,631,995	-	Accuracy
Dep.	1,722,571	1,628,558	LAS
Consti.	1,320,702	-	Evalb F1†
Penn Treebank (Marcus et al., 1994)	speech, news	49,208	POS	1,173,766	-	Accuracy
43,948	Dep.	1,090,777	1,046,829	LAS
43,948	Consti.	871,264	-	Evalb F1†
OIE2016 (Stanovsky and Dagan, 2016)	news, Wiki	2,534	OpenIE	15,717	12,451	F1
MPQA 3.0 (Deng and Wiebe, 2015)	news	3,585	ORL	13,841	9,286	F1
SemEval-2014 Task 4 (Pontiki et al., 2014)	reviews	4,451	ABSA	7,674	-	Accuracy°
Table 3: Statistics of GLAD, consisting of 10 tasks from 8 datasets.  $\star$  Following He et al. (2018), we use a subset of OntoNotes 5.0 dataset based on CoNLL 2012 splits (Pradhan et al., 2012).  $^\circ$  Previous works use gold standard spans in these evaluations.  $\dagger$  We use the bracket scoring program Evalb (Collins, 1997) in constituency parsing.
of  $l$  words using a multilayer perceptron (MLP):  $\mathrm{softmax}(\mathrm{MLP}^{\mathrm{span}}(\mathbf{z}_i))\in \Delta^{|\mathcal{L}|}$ , where  $\Delta^{|\mathcal{L}|}$  is a  $|\mathcal{L}|$ -dimensional simplex. Then we keep the top  $K = \tau \cdot n$  spans with the lowest NEG_SPAN probability in relation prediction for efficiency, where smaller pruning threshold  $\tau$  indicates more aggressive pruning. Another MLP is applied to pairs of the remaining spans to produce their relation scores:  $\mathbf{o}_{jk} = \mathrm{MLP}^{\mathrm{rel}}([\mathbf{z}_j;\mathbf{z}_k;\mathbf{z}_j\cdot \mathbf{z}_k])\in \mathbb{R}^{|\mathcal{R}|}$ , where  $j$  and  $k$  index two spans.
Application to Disparate Tasks For most of the tasks, we can simply maximize the probability of the ground truth relation for all pairs of the remaining spans. However, some tasks might have different requirements, e.g., coreference resolution aims to cluster spans referring to the same concept and we do not care about which antecedent a span is linked to if there are multiple ones. Thus, we provide two training loss functions:
1. Pairwise Maximize the probabilities of the ground truth relations for all pairs of the remaining spans independently:  $\mathrm{softmax}(\mathbf{o}_{jk})_{r_{jk}}$ , where  $r_{jk}$  indexes the ground truth relation.
2. Head Maximize the probability of ground truth head spans for a specific span  $s_j$ :  $\sum_{k \in \mathrm{head}(s_j)} \mathrm{softmax}([o_{j1}, o_{j2}, \dots, o_{jK}])_k$ , where  $\mathrm{head}(\cdot)$  returns indices of one or more heads and  $o_j$  is the corresponding scalar from  $\mathbf{o}_j$ . indicating how likely two spans are related.
We use option 1 for all tasks except for coreference
resolution which uses option 2. Note that the above loss functions only differ in how relation scores are normalized and the other parts of the model remain the same across different tasks. At test time, we follow previous inference methods to generate valid outputs. For coreference resolution, we link a span to the antecedent with highest score (Lee et al., 2017). For constituency parsing, we use greedy top-down decoding to generate a valid parse tree (Stern et al., 2017). For dependency parsing, each word is linked to exactly one parent with the highest relation probability. For other tasks, we predict relations for all span pairs and use those not predicted as NEG_REL to construct outputs.
Our core insight is that the above formulation is largely task-agnostic, meaning that a task can be modeled in this framework as long as it can be formulated as a span-relation prediction problem with properly defined span labels  $\mathcal{L}$  and relation labels  $\mathcal{R}$ . As shown in Table 1, this unified Span-Relation (SpanRel) model makes it simple to scale to a large number of language analysis tasks, with breadth far beyond that of previous work.
Multi-task Learning The SpanRel model makes it easy to perform multi-task learning (MTL) by sharing all parameters except for the MLPs used for label prediction. However, because different tasks capture different linguistic aspects, they are not equally beneficial to each other. It is expected that jointly training on related tasks is helpful, while forcing the same model to solve unrelated tasks might even hurt the performance (Ruder, 2017).
Category	Task	Metric	Dataset	Setting	SOTA Model	Previous SOTA	Our Model
IE	NER	F1	CoNLL03	BERT	Devlin et al. (2019)	92.8	92.2
WLP	ELMo	Luan et al. (2019)	79.5	79.2
RE	Macro F1	SemEval10	BERT, gold	Wu and He (2019)	89.3	87.4
F1	WLP	ELMo	Luan et al. (2019)	64.1	65.5
Coref.	Avg F1	OntoNotes	GloVe, CharCNN	Lee et al. (2017)°	62.0	61.1
OpenIE	F1	OIE2016	ELMo	Stanovsky et al. (2018)*	31.1	35.2
SRL	F1	OntoNotes	ELMo	He et al. (2018)†	82.9	82.4
Parsing	Dep.	LAS	PTB	ELMo	Clark et al. (2018)	94.4	94.7
Consti.	Evalb F1	PTB	BERT	Kitaev et al. (2019)	95.6	95.5
Sentiment	ABSA	Accuracy	SemEval14	BERT, gold	Xu et al. (2019)‡	85.0/78.1	85.5/76.6
ORL	F1	MPQA 3.0	GloVe, gold	Marasović and Frank (2018)*	56.4	55.6
POS	Accuracy	PTB	ELMo	Clark et al. (2018)	97.7	97.7
Table 4: Comparison between SpanRel models and task-specific SOTA models. Following Luan et al. (2019), we perform NER and RE jointly on WLP dataset. We use gold entities in SemEval-2010 Task 8, gold aspect terms in SemEval-2014 Task 4, and gold opinion expressions in MPQA 3.0 to be consistent with existing works.
Compared to manually choosing source tasks based on prior knowledge, which might be sub-optimal when the number of tasks is large, SpanRel offers a systematic way to examine relative benefits of source-target task pairs by either performing pairwise MTL or attention-based analysis, as we will show in Section 4.3.
4 GLAD Benchmark and Results
We first describe our General Language Analysis Datasets (GLAD) benchmark and evaluation metrics, then conduct experiments to (1) verify that SpanRel can achieve comparable performance across all tasks (Section 4.2), and (2) demonstrate its benefits in multi-task learning (Section 4.3).
GLAD Benchmark and Evaluation Metrics As summarized in Table 3, we convert 8 widely used datasets with annotations of 10 tasks into the BRAT format and include them in the GLAD benchmark. It covers diverse domains, providing a holistic testbed for natural language analysis evaluation. The major evaluation metric is span-based  $\mathrm{F_1}$  (denoted as  $\mathbf{F}_1$ ), a standard metric for SRL. Precision is the proportion of extracted spans (spans not predicted as NEG_SPAN) that are consistent with
the ground truth. Recall is the proportion of ground truth spans that are correctly extracted. Span  $\mathrm{F_1}$  is also applicable to relations, where an extracted relation (relations not predicted as NEG_REL) is correct iff both head and tail spans have correct boundaries and the predicted relation is correct. To make fair comparisons with existing works, we also compute standard metrics for different tasks, as listed in Table 3.
Implementation Details We attempted four token representation methods (Equation 1), namely GloVe (Pennington et al., 2014), ELMo (Peters et al., 2018), BERT (Devlin et al., 2019), and SpanBERT (Joshi et al., 2019). We use  $\mathrm{BERT}_{\mathrm{base}}$  in our main results and report  $\mathrm{BERT}_{\mathrm{large}}$  in Appendix B. A three-layer BiLSTM with 256 hidden units is used (Equation 2). Both span and relation prediction MLPs have two layers with 128 hidden units. Dropout (Srivastava et al., 2014) of 0.5 is applied to all layers. For GloVe and ELMo, we use Adam (Kingma and Ba, 2015) with learning rate of 1e-3 and early stop with patience of 3. For BERT and SpanBERT, we follow standard fine-tuning with learning rate of 5e-5,  $\beta_{1} = 0.9$ ,  $\beta_{2} = 0.999$ , L2 weight decay of 0.01, warmup over the first  $10\%$  steps, and number of epochs tuned on development set. Task-specific hyperparameters maximal span length and pruning ratio are tuned on development set and listed in Appendix C.
4.2 Comparison with Task-specific SOTA
We compare the SpanRel model with state-of-the-art task-specific models by training on data from a single task. By doing so we attempt to answer the
2° The small version of Lee et al. (2017)'s method with 100 antecedents and no speaker features. * For OpenIE and ORL, we use span-based  $\mathrm{F}_1$  instead of syntactic-head-based  $\mathrm{F}_1$  and binary coverage  $\mathrm{F}_1$  used in the original papers because they are biased towards extracting long spans.† For SRL, we choose to compare with He et al. (2018) because they also extract predicates and arguments in an end-to-end way.‡ We follow Xu et al. (2019) to report accuracy of restaurant and laptop domain separately in ABSA.
research question "can a single model with minimal task-specific engineering achieve competitive or superior performance to other models that have been specifically engineered?" We select competitive SOTA models mainly based on settings, e.g., single-task learning and end-to-end extraction of spans and relations. To make fair comparisons, token embeddings (GloVe, ELMo, BERT) and other hyperparameters (e.g., the number of antecedents in Coref. and the maximal span length in SRL) in our method are set to match those used by SOTA models, to focus on differences brought about by the model architecture.
As shown in Table 4, the SpanRel model achieves comparable performances as task-specific SOTA methods (regardless of whether the token representation is contextualized or not). This indicates that the span-relation format can generically represent a large number of natural language analysis tasks and it is possible to devise a single unified model that achieves strong performance on all of them. It provides a strong and generic baseline for natural language analysis tasks and a way to examine the usefulness of task-specific designs.
4.3 Multi-task Learning with SpanRel
To demonstrate the benefit of the SpanRel model in MTL, we perform single-task learning (STL) and MTL across all tasks using end-to-end settings. Following Liu et al. (2019), we perform MTL+fine-tuning and show the results in separate columns of Table 5. Contextualized token representations yield significantly better results than GloVe on all tasks, indicating that pre-training on large corpora is almost universally helpful to NLP tasks. Comparing the results of MTL+fine-tuning with STL, we found that performance with GloVe drops on 8 out of 15 tasks, most of which are tasks with relatively sparse data. It is probably because the capacity of the GloVe-based model is too small to store all the patterns required by different tasks. The results of contextualized representations are mixed, with some tasks being improved and others remaining the same or degrading. We hypothesize that this is because different tasks capture different linguistic aspects, thus are not equally helpful to each other. Reconciling these seemingly different tasks in the same model might be harmful to some tasks.