SlowGuess/NAACL_2022_OCR huggingface dataset:
Yiwei Wang<sup>1</sup> Muhao Chen<sup>2</sup> Wenxuan Zhou<sup>2</sup> Yujun Cai<sup>3</sup> Yuxuan Liang<sup>1</sup> Dayiheng Liu<sup>4</sup> Baosong Yang<sup>4</sup> Juncheng Liu<sup>1</sup> Bryan Hooi<sup>1</sup>
$^{1}$  National University of Singapore  $^{2}$  University of Southern California
$^{3}$  Nanyang Technological University  $^{4}$ Alibaba Group
Recent literature focuses on utilizing the entity information in the sentence-level relation extraction (RE), but this risks leaking superficial and spurious clues of relations. As a result, RE still suffers from unintended entity bias, i.e., the spurious correlation between entity mentions (names) and relations. Entity bias can mislead the RE models to extract the relations that do not exist in the text. To combat this issue, some previous work masks the entity mentions to prevent the RE models from overfitting entity mentions. However, this strategy degrades the RE performance because it loses the semantic information of entities. In this paper, we propose the CoRE (Counterfactual Analysis based Relation Extraction) debi-aising method that guides the RE models to focus on the main effects of textual context without losing the entity information. We first construct a causal graph for RE, which models the dependencies between variables in RE models. Then, we propose to conduct counterfactual analysis on our causal graph to distill and mitigate the entity bias, that captures the causal effects of specific entity mentions in each instance. Note that our CoRE method is model-agnostic to debias existing RE systems during inference without changing their training processes. Extensive experimental results demonstrate that our CoRE yields significant gains on both effectiveness and generalization for RE. The source code is provided at:
https://github.com/vanoracai/CoRE.
Sentence-level relation extraction (RE) is an important step to obtain a structural perception of unstructured text (Distiawan et al., 2019) by extracting relations between entity mentions (names) from the textual context. From human oracle, textual context should be the main source of information that determines the ground-truth relations between entities. Consider a sentence “Mary gave birth to
Jerry."1. Even if we change the entity mentions from 'Jerry' and 'Mary' to other people's names, the relation 'parents' still holds between the subject and object as described by the textual context "gave birth to".
Recently, some work aims to utilize entity mentions for RE (Yamada et al., 2020; Zhou and Chen, 2021), which, however, leak superficial and spurious clues about the relations (Zhang et al., 2018). In our work, we observe that entity information can lead to biased relation prediction by misleading RE models to extract relations that do not exist in the text. Fig. 1 visualizes a relation prediction from a state-of-the-art RE model (Alt et al., 2020) (see more examples in Tab. 7). Although the context describes no relation between the highlighted entity pair, the model extracts the relation as "countries_of_residence". Such an erroneous result can come from the spurious correlation between entity mentions and relations, or the entity bias in short. For example, if the model sees the relation "countries_of_residence" many more times than other relations when the object entity is Switzerland during training, the model can associate this relation with Switzerland during inference even though the relation does not exist in the text.
To combat this issue, some work (Zhang et al., 2017, 2018) proposes masking entities to prevent the RE models from over-fitting entity mentions. On the other hand, some other work (Peng et al., 2020; Zhou and Chen, 2021) finds that this strategy degrades the performance of RE because it loses the semantic information of entities.
For both machines and humans, RE requires a combined understanding of textual context and entity mentions (Peng et al., 2020). Humans can avoid the entity bias and make unbiased decisions by correctly referring to the textual context that describes the relation. The underlying mechanism is
Human Language Technologies, pages 3071 - 3081
Figure 1: (left) An example of RE produced by LUKE (Yamada et al., 2020). In the input sentence, the subject is in blue and the object is in yellow. The ground-truth relation between the subject and object is “no Relation”, since there is not any relation reflected by the textual context. (right) Our proposed counterfactual analysis for RE, which compares the original prediction (upper) with the counterfactual one (lower) to mitigate the entity bias.
causality-based (Van Hoeck et al., 2015): humans identify the relations by pursuing the main causal effect of the textual context instead of the side-effect of entity mentions. In contrast, RE models are usually likelihood-based: the prediction is analogous to looking up the entity mentions and textual context in a huge likelihood table, interpolated by training (Tang et al., 2020). In this paper, our idea is to teach RE models to distinguish between the effects from the textual context and entity mentions through counterfactual analysis (Pearl, 2018):
Counterfactual analysis: If I had not seen the textual context, would I still extract the same relation?
The counterfactual analysis essentially gifts humans the hypothesizing abilities to make decisions collectively based on the textual context and entity mentions, as well as to introspect whether the decision is deceived (see Fig. 1). Specifically, we are essentially comparing the original instance with a counterfactual instance, where only the textual context is wiped out, while keeping the entity mentions untouched. By doing so, we can focus on the main effects of the textual context without losing the entity information.
In our work, we propose a novel model-agnostic paradigm for debiasing RE, namely CoRE (Counterfactual analysis based Relation Extraction), which adopts the counterfactual analysis to mitigate the spurious influence of the entity mentions. Specifically, CoRE does not touch the training of RE models, i.e., it allows a model to be exposed to biases on the original training set. Then, we construct a causal graph for RE to analyze the dependencies between variables in RE models, which acts as a "roadmap" for capturing the causal effects of textual context and entity
mentions. To rectify the test instances from the potentially biased prediction, in inference, CORE "imagines" the counterfactual counterparts on our causal graph to distill the biases. Last but not least, CORE performs a bias mitigation operation with adaptive weights to produce a debiased decision for RE.
We highlight that CoRE is a flexible debiasing method that is applicable to popular RE models without changing their training processes. To evaluate the effectiveness of CoRE, we perform extensive experiments on public benchmark datasets. The results demonstrate that our proposed method can significantly improve the effectiveness and generalization of the popular RE models by mitigating the biases in an entity-aware manner.
Sentence-level relation extraction. Early research efforts (Nguyen and Grishman, 2015; Wang et al., 2016; Zhang et al., 2017) train RE models from scratch based on lexicon-level features. The recent RE work fine-tunes pretrained language models (PLMs; Devlin et al. 2019; Liu et al. 2019). For example, K-Adapter (Wang et al., 2020) fixes the parameters of the PLM and uses feature adapters to infuse factual and linguistic knowledge. Recent work focuses on utilizing the entity information for RE (Zhou and Chen, 2021; Yamada et al., 2020), but this leaks superficial and spurious clues about the relations (Zhang et al., 2018). Despite the biases in existing RE models, scarce work has discussed the spurious correlation between entity mentions and relations that causes such biases. Our work investigates this issue and proposes CoRE to debias RE models for higher effectiveness.
Figure 2: The causal graph of RE models.
Debiasing for Natural Language Processing. Debiasing is a fundamental problem in machine learning (Torralba and Efros, 2011). For natural language processing (NLP), some work performs data re-sampling to prevent models from capturing the unintended bias in training (Dixon et al., 2018; Geng et al., 2007; Kang et al., 2016; Rayhan et al., 2017; Nguyen et al., 2011). Alternatively, Wei and Zou (2019) and Qian et al. (2020) develop data augmentation for debiasing. Some recent work de biases the NLP models based on causal inference (Qian et al., 2021; Nan et al., 2021). In RE, how to deal with the entity bias is also an important problem. For example, PA-LSTM (Zhang et al., 2017) masks the entity mentions with special tokens to prevent RE models from over-fitting entity names, which was also adopted by C-GCN (Zhang et al., 2018) and SpanBERT (Joshi et al., 2020). However, masking entities loses the semantic information of entities and leads to performance degradation. Different from it, our CORE model tackles entity biases based on structured causal models. In this way, we debias the RE models to focus on the textual context without losing the entity information.
Sentence-level relation extraction (RE) aims to extract the relation between a pair of entities mentioned from a sentence. We propose CoRE (counterfactual analysis based Relation Extraction) as a model-agnostic technique to endow existing RE models with unbiased decisions during inference. CoRE follows the regular training process of existing work regardless of the bias from the entity mentions. During inference, CoRE post-adjusts the biased prediction according to the effects of the bias. CoRE can be flexibly incorporated into popular RE models to improve their effectiveness and generalization based on the counterfactual analysis without re-training the model.
In this section, we first formulate the existing RE models in the form of a causal graph. Then, we introduce our proposed bias distillation method to
distill the entity bias with our designed counterfactual analysis. We conduct an empirical analysis to analyze how heavily the existing RE models rely on the entity mentions to make decisions. Finally, we mitigate the distilled bias from the predictions of RE models to improve their effectiveness.
3.1 Causality of Relation Extraction
In order to perform causal intervention, we first formulate the causal graph (Pearl et al., 2016; Pearl and Mackenzie, 2018), a.k.a., structural causal model, for the RE models as Fig. 2, which sheds light on how the textual context and entity mentions affect the RE predictions. The causal graph is a directed acyclic graph  $\mathcal{G} = \{\mathcal{V},\mathcal{E}\}$ , indicating how a set of variables  $\mathcal{V}$  interact with each other through the causal relations behind the data and how variables obtain their values, e.g.,  $(E,X)\to Y$  in Fig. 2. Before we conduct counterfactual analysis that deliberately manipulates the values of nodes and prunes the causal graph, we first revisit the conventional RE systems in the graphical view.
The causal graph in Fig. 2 is applicable to a variety of RE models and imposes no constraints on the detailed implementations. Node  $X$  is the input text. On the edge  $X \rightarrow E$ , we obtain the spans of subject and object entities as node  $E$  through NER or human annotations (Zhang et al., 2017). For example, in the aforementioned sentence  $X =$  "Mary gave birth to Jerry", the entities are  $E =$  ['Mary', 'Jerry'].
On the edges  $(X,E)\to Y$ , existing RE models take different designs. For example, C-GCN (Zhang et al., 2018) obtains the relation prediction  $Y$  by encoding entity mentions  $E$  on the pruned dependency tree of  $X$  using a graph convolutional network. IRE (Zhou and Chen, 2021) uses PLMs as the encoder for  $X$ , and marks the entity information of  $E$  with special tokens to utilize the entity information.
3.2 Bias Distillation
Based on our causal graph in Fig. 2, we diagnose how the entity bias affects inference. After training, the causal dependencies among the variables are learned in terms of the model parameters. The entity bias can mislead the models to make wrong predictions while ignoring the actual relation-describing textual context in  $X$ , i.e., biased towards the causal dependency:  $E \rightarrow Y$ .
The conventional biased prediction can only see the output  $Y$  of the entire graph given a sentence
Figure 3: The original causal graph of RE models (left) together with its two counterfactual alternates for the entity bias (middle) and label bias (right). The shading indicates the mask of corresponding variables.
$X$ , ignoring how specific entity mentions affect the relation prediction. However, causal inference encourages us to think out of the black box. From the graphical point of view, we are no longer required to execute the entire causal graph as a whole. In contrast, we can directly manipulate the nodes and observe the output. The above operation is termed intervention in causal inference, which we denote as  $do(\cdot)$ . It wipes out all the incoming links of a node and demands it to take a certain value.
We distill the entity bias by intervention and its induced counterfactual. The counterfactual means "counter to the facts", and takes one step that further assigns the hypothetical combination of values to variables. For example, we can remove the input textual context by masking  $X$ , but maintain  $E$  as the original entity mentions, as if  $X$  still exists.
We will use the input text  $X$  as our control variable where the intervention is conducted, aiming to assess its effects, due to the fact that there would not be any valid relation between entities in  $E$  if the input text  $X$  is empty. We denote the output logits  $Y$  after the intervention  $X = \bar{x}$  as follows:
$$
Y _ {\bar {x}} = Y \left(d o (X = \bar {x})\right). \tag {1}
$$
Following the above notation, the original prediction  $Y$ , i.e., can be re-written as  $Y_{x}$ .
To distill the entity bias, we conduct the intervention  $do(X = \bar{x})$  on  $X$ , while keeping the variable  $E$  as the original  $e$ , as if the original input text  $x$  had existed. Specifically, we mask the tokens in  $x$  to produce  $\bar{x}$  but keep the entity mentions  $e$  as original, so that the textual context is removed and the entity information is maintained. Accordingly, the counterfactual prediction is denoted as  $Y_{\bar{x},e}$  (see Fig. 3). In this case, since the model cannot see any textual context in the factual input  $x$  after the intervention  $\bar{x}$ , but still has access to the original entity mentions  $e$  as the inputs, the prediction  $Y_{\bar{x},e}$  purely reflects the influence from  $e$ . In other words,  $Y_{\bar{x},e}$  refers to the output, i.e., a probability distribution
Figure 4:  $\mathrm{Hit}@\bar{k}$  (y-axis) is the fraction of the test instances, that have the original relation prediction  $\arg \max_c Y_x[c]$  ranked in the top  $k$  most confident relations of the counterfactual prediction  $Y_{\bar{x},e}$ . We report  $\mathrm{Hit}@\bar{k}$  of the model  $\mathrm{IRE}_{\mathrm{RoBERTa}}$  on the test instances when the original relation prediction is title, employee_of, or origin.
or a logit vector, where only the entity mentions are given as the input without textual context.
To investigate how heavily the state-of-the-art models rely on the entity mentions for RE, we conduct an empirical study to compare the original prediction  $Y_{x}$  and the counterfactual one  $Y_{\bar{x},e}$ . Specifically, we calculate the fraction of the test instances (y-axis) that have the original relation prediction  $\arg \max_c Y_x[c]$  ranked in the top  $k$  most confident relations of the counterfactual prediction  $Y_{\bar{x},e}$ . This fraction is termed as Hit@k.
We present Hit@k for  $\mathrm{IRE}_{\mathrm{ROBERTa}}$  (Zhou and Chen, 2021), a state-of-the-art RE model, in Fig. 4 on the test instances when the original relation prediction is title, employee_of, or origin. Higher Hit@1 means that for more instances, the model infers the same relation given only the entity mentions no matter whether the textual context is given, which imply stronger causal effects from the entity mentions  $Y_{\bar{x},e}$ , i.e., the models rely more heavily on the entity mentions for RE.
We observe that when  $k = 1$ , the Hit@1 is more than  $50\%$ , which implies that the model typically extracts the same relations even without textual context on more than a half of the instances. For a larger  $k$ , the Hit@k increases significantly and reaches more than  $80\%$  for  $k \geq 2$ . These observations imply a promising but embarrassing result: the state-of-the-art model relies on the entity bias for RE on many instances. The entity bias reflected by  $Y_{\bar{x},e}$  can lead to the wrong extraction if the relation implied by the entity mentions does not exist in the input text. This poses a challenge to the
generalization of RE models, as validated by our experimental results (§4.3).
In addition to  $Y_{\bar{x},e}$  that reflects the causal effects of entity mentions, there is another kind of bias not conditioned on the entity mentions  $e$ , but reflecting the general bias in the whole dataset, which is  $Y_{\bar{x}}$ .  $Y_{\bar{x}}$  corresponds to the counterfactual inputs where both textual context and entity mentions are removed. In this case, since the model cannot access any information from the input after this removal,  $Y_{\bar{x}}$  naturally reflects the label bias that exists in the model from the biased training. The causal graphic views of the original prediction  $Y_{x}$ , the counterfactual  $Y_{\bar{x},e}$  for the entity bias, and  $Y_{\bar{x}}$  for the label bias are visualized in Fig. 3.
3.3 Bias Mitigation
As we have discussed in §1, instead of the static likelihood that tends to be biased, the unbiased relation prediction lies in the difference between the observed outcome  $Y_{x}$  and its counterfactual predictions  $Y_{\bar{x},e}, Y_{\bar{x}}$ . The latter two are the biases that we want to mitigate from the relation prediction.
Intuitively, the unbiased prediction that we seek is the linguistic stimuli from blank to the observed textual context with specific relation descriptions, but not merely from the entity bias. The context-specific clues of the relations are key to the informative unbiased predictions, because even if the overall prediction is biased towards the relation "schools_attended" due to the object entity like "Duke University", the textual context "work at" indicates the relation as "employee_of" rather than "schools_attended".
Our final goal is to use the direct effect of the textual context from  $X$  to  $Y$  for debiased prediction, mitigating (denoted as  $\backslash$ ) the label bias and the entity bias from the prediction:  $Y_{x} \setminus Y_{\bar{x},e} \setminus Y_{\bar{x}}$ , so as to block the spread of the biases from training to inference. The debiased prediction via bias mitigation can be formulated via the conceptually simple but empirically effective element-wise subtraction operation:
$$
Y _ {\text {f i n a l}} = Y _ {x} - \lambda_ {1} Y _ {\bar {x}, e} - \lambda_ {2} Y _ {\bar {x}}, \tag {2}
$$
where  $\lambda_{1}$  and  $\lambda_{2}$  are two independent hyperparameters balancing the terms for mitigating entity and label biases respectively. Note that the bias mitigation in Eq. 2 for the entity and label biases correspond to Total Direct Effect (TDE) and Total Effect (TE) in causal inference (Tang et al., 2020;
Dataset	#Train	#Dev	#Test	#Classes
TACRED	68,124	22,631	15509	42
SemEval	6,507	1,493	2,717	19
Re-TACRED	58,465	19,584	13418	40
TACRED-Revisit	68,124	22,631	15509	42
VanderWeele, 2015; Pearl, 2009) respectively. We adaptively set the values of  $\lambda_{1}$  and  $\lambda_{2}$  for different datasets based on the grid beam search (Hokamp and Liu, 2017) in a scoped two dimensional space:
$$
\lambda_ {1} ^ {\star}, \lambda_ {2} ^ {\star} = \arg \max  _ {\lambda_ {1}, \lambda_ {2}} \psi (\lambda_ {1}, \lambda_ {2}) \lambda_ {1}, \lambda_ {2} \in [ a, b ], \tag {3}
$$
where  $\psi$  is a metric function (e.g., F1 scores) for evaluation,  $a, b$  are the boundaries of the search range. We search the values of  $\lambda_1, \lambda_2$  once on the validation set, and use the fixed values for inference on all testing instances. Since the entity types can restrict the candidate relations (Lyu and Chen, 2021), we use the entity type information, if available, to restrict the candidate relations for inference, which strengthens the effects of entity types for relation extraction.
Overall, the proposed CoRE replaces the conventional one-time prediction with  $Y_{\mathrm{final}}$  to produce the debiased relation predictions, which essentially "thinks" twice: one for the original observation  $Y_{x}$ , the other for hypothesized  $Y_{\bar{x}}, Y_{\bar{x},e}$ .
In this section, we evaluate the performance of our CoRE methods when applied to RE models. We compare our methods against a variety of strong baselines on the task of sentence-level RE. Our experimental settings closely follow those of the previous work (Zhang et al., 2017; Zhou and Chen, 2021; Nan et al., 2021) to ensure a fair comparison.
Datasets. We use four widely-used RE benchmarks: TACRED (Zhang et al., 2017), SemEval (Hendrickx et al., 2019), TACRED-Revisit (Alt et al., 2020), and Re-TACRED (Stoica et al., 2021) for evaluation. TACRED contains over  $106\mathrm{k}$  mention pairs drawn from the yearly TAC KBP challenge. (Alt et al., 2020) relabeled the development and test sets of TACRED. Re-TACRED is a further relabeled version of TACRED after refining its label definitions. The statistics of these datasets are shown in Tab. 1.
Method	TACRED	TACRED-Revisit	Re-TACRED	SemEval
C-SGC (Wu et al., 2019)	52.1	62.8	69.8	71.3
SpanBERT (Joshi et al., 2020)	55.7	65.1	74.1	74.9
CP (Peng et al., 2020)	56.8	67.1	78.1	79.6
RECENT (Lyu and Chen, 2021)	63.3	70.5	81.1	74.6
KnowPrompt (Chen et al., 2021)	57.6	68.7	79.0	81.8
IREBERT (Zhou and Chen, 2021)	59.2	68.4	78.6	79.1
LUKE (Yamada et al., 2020)	58.8	67.5	80.2	82.1
LUKE + Resample (Burnaev et al., 2015)	59.3	68.2	80.5	82.5
LUKE + Focal (Lin et al., 2017)	59.1	67.7	80.3	82.4
LUKE + CFIE (Nan et al., 2021)	59.8	68.0	80.4	82.2
LUKE + Entity Mask (Zhang et al., 2017)	57.9	67.0	79.5	82.0
LUKE + CoRE	61.7	70.2	81.6	83.6
IREROBERTa (Zhou and Chen, 2021)	63.1	70.6	81.5	81.4
IREROBERTa + Resample (Burnaev et al., 2015)	63.3	71.0	81.9	81.6
IREROBERTa + Focal (Lin et al., 2017)	62.9	70.7	81.2	81.1
IREROBERTa + CFIE (Nan et al., 2021)	63.3	70.9	81.6	81.7
IREROBERTa + Entity Mask (Zhang et al., 2017)	61.4	69.3	79.6	81.2
IREROBERTa + CoRE	64.4	71.8	82.8	82.3
Table 2: F1-macro scores (%) of RE on the test sets of TACRED, TACRED-Revisit, Re-TACRED, and SemEval. The best results in each column are highlighted in bold font.
We use the widely-used F1-macro score as the main evaluation metric (Nan et al., 2021), which is the balanced harmonic mean of precision and recall, as well as F1-micro for a more comprehensive evaluation. F1-macro is more suitable than F1-micro to reflect the extent of biases, especially for the highly-skewed cases, since F1-macro is evenly influenced by the performance in each category, i.e. category-sensitive, but F1-micro simply gives equal weights to all instances (Kim et al., 2019).
Compared methods. We take the following RE models into comparison. (1) C-SGC (Wu et al., 2019) simplifies GCN, and combines it with LSTM, leading to improved performance over each method alone. (2) SpanBERT (Joshi et al., 2020) extends BERT by introducing a new pretraining objective of continuous span prediction. (3) CP (Peng et al., 2020) is an entity-masked contrastive pre-training framework for RE. (4) RECENT (Lyu and Chen, 2021) restricts the candidate relations based on the entity types. (5) KnowPrompt (Chen et al., 2021) is Knowledge-aware Prompt-tuning approach. (6) LUKE (Yamada et al., 2020) pretrains the language model on both large text corpora and knowledge graphs and further proposes an entity-aware self-attention mechanism. (7) IRE (Zhou and Chen, 2021) proposes an improved entity representation technique in the data preprocessing.