Difeng Wang, et al., “Global-to-Local Neural Networks for Document-Level Relation Extraction”, EMNLP 2020
1 简介
这篇文章是做 document RE,是对 Connecting the Dots 的改进,改动也不大:图没变,只是最后把 inference 换成了还挺有意义的 attn,得到 entity 的表示;后面在分类时,还用文档里所有 entity pair 的表示 self-attn 求和,搞出一个 topic embedding,辅助最后的分类。
我一说就显得没什么创新的样子,但是作者就很有文化,他说:our model differs in further learning entity local representations to reduce the influence of irrelevant information and considering other relations in the document to refine the prediction.
最后结果也不够 solid —— 他自己复现的 baseline 比别人复现的低了不少,最后的成绩也就是和 2020 上半年发表的文章 comparable,和另一篇 EMNLP 2020 的 GAIN 相比,差了很多。
文章写得真是非常不错,intro 部分很能激发人的兴趣,related 结构严谨,详略得当,实验部分也写得很清楚,可以说是一篇范文了。
2 方法

整体流程如图所示,其中 encoder 是 BERT,global representation layer 同 Connecting the Dots 几乎完全一样,只是建图的时候,边不是直接拼,而是用 01 表示出邻接矩阵,然后用 r-GCN 进行消息传播,不同种类的边有不同的权重。下面就只详细讲 cd 两个模块。
2.1 local representation
上一步通过 RGCN 得到 entity 的 global 表示 $e_i^{glo}\in \mathbb{R}^{d_n}$,下面通过 attn,将 global mention 聚合成 entity 的 local 表示。
何谓 local?作者在文中说,The “local” can be understood from two angles: (i) It aggregates the original mention information from the encoding layer. (ii) For different entity pairs, each entity would have multiple different local representations w.r.t. the counterpart entity.
就是让每个 entity pair,都有和上下文相关的表示(如果只有 global,那每个 entity 只有一种表示,这里是要让每个 entity 在不同的 entity pair 中都有不同的表示)。具体流程如下:
首先是一个多头 attn:$$\text{MHead}(Q,K,V) = [\text{head}_1,…, \text{head}_z]W^{out}$$ $$head_i = \text{softmax}\big(\frac{QW_i^Q(KW_i^K)}{\sqrt{d_v}}\big)VW_i^V$$
其中 $W^{out}\in\mathbb{R}^{d_n\times d_n}$,$W_i^Q,W_i^K,W_i^V\in\mathbb{R}^{d_n\times d_v}$ 为参数,都仅仅是为了 reshape(我觉得),$z$ 是 head 的个数,满足 $z\times d_v = d_n$。
attn 的 Q 是 entity 的 global 表示 $e_i^{glo}$,K 是第一步 encoder 得到的句子 [cls] 表示,V 是 encoder 得到的 mention 表示。$$e_a^{loc} = \text{LN}(\text{MHead}_0(e^{glo}_b, \{n_{s_i}\}_{s_i\in\mathcal{S}_a}, \{n_{m_j}\}_{m_j\in\mathcal{M}_a}))$$ $$e_b^{loc} = \text{LN}(\text{MHead}_1(e^{glo}_a, \{n_{s_i}\}_{s_i\in\mathcal{S}_b}, \{n_{m_j}\}_{m_j\in\mathcal{M}_b}))$$
这里 $\text{MHead}$ 对于头尾实体是分别的两组多头 attn,$\text{LN}$ 指 layer normalization,$\mathcal{S}_a$ 是所有包含 entity a 对应 mention 的句子的 node embedding 集合,$\mathcal{M}_a$ 是 entity a 对应 mention 的 node embedding 集合。
因此,enity a 的 local representation 是对 encoder 得到的所有与 a 相关的 mention 进行加权得到的。用什么作为加权的分数呢?用 entity pair 的对方 attn 所有句子:在不同句子(语境)里面,如果句子跟 entity b 越接近(语境更对),那么这里的 mention a 在构成 entity a 时也就越重要。这样一来,每个 entity 在不同的 entity pair 中都有不同的表示。
2.2 classifier
先按照传统套路,把上面得到的 entity 特征表示全都拼起来,得到句子里一对 entity,或者说一个关系的表示:$$\hat{e}_a = [e_a^{glo};e_a^{loc};\triangle(\delta_{ab})]$$ $$\hat{e}_b = [e_b^{glo};e_b^{loc};\triangle(\delta_{ba})]$$ $$o_r = [\hat{e}_a;\hat{e}_b]$$
这里 $\delta$ 指的是 entity 之间的相对距离,$\triangle(·)$ 是将这个距离通过 $[2^0,2^1,…,2^n]$ 这样映射成 one-hot 向量。
接下来,作者提出一个想法:文档的主题和关系分布是有关系的。因此,为了隐式地表示文档主题,作者将一篇文档中的所有关系表示 attn 加权求和,得到文档的主题表示:$$o_c = \sum_{i=0}^p\theta_io_i = \sum_{i=0}^p\frac{\exp(o_iWo_r’)}{\sum_{j=0}^p \exp(o_jWo_r’)}o_i$$
最后分类时,就直接将 $o_r$ 和 $o_c$ 拼起来,linear 分类。
3 实验
- sota @ DocRED & CDR
- 在多步推理的 relation 上,表现提升很大,作者说是因为 global heterogeneous graph can effectively model the interactions of semantic information of different nodes,同时本文提出的 entity local representations can reduce the influence of noisy context of multiple men- tions of entities in long distance.
- local 表示是聚合多个 mention,所以作者做了一个新实验:entity 有不同 mention 数量,发现只有一个 mention 的,性能很低;别人方法 mention 多时,性能也没长多少(因为 the model indiscriminately aggregated the information of multiple mentions and introduced much noisy context, which limited its performance.),本文方法的 local attn,改善了这点
ablation
- 引入 BERT 在 DocRED 上性能提升比 CDR 显著
- CDR 上有 54% DocRED 有 19% 的 entity 对应多种 mention,所以去掉 local rep,drop 很大
case study:① 推理是有必要的 ② 先验知识是有必要的 ③ conreference 是有必要的
主要错误:41% 推理错误,29% 句子成分丢失,13% 缺少先验知识,13% conreference 错误
4 思考
- 对于最后引入主题表示,为什么要拼起来,然后一起分类呢?为什么不分别分类,然后 loss 上两项相加呢?这样后一个任务其实可以用聚类得到的主体分布来 guide,整体流程就类似深度聚类!而且这种半监督的方法,还(说不定)能用上 DocRED 的远程监督数据!我可没看到过有人用远程监督的数据!而且都用了新数据,冲 SOTA 应该也是不难的吧!
5 TODO
- related 部分写得很好,还有实验的 baseline 部分,挑一些看看
- Michael Schlichtkrull, Thomas N. Kipf, Peter Bloem, Rianne van den Berg, Ivan Titov, and Max Welling. 2018. Modeling relational data with graph convolu- tional networks. In ESWC, pages 593–607, Herak- lion, Greece. Springer.
- Pankaj Gupta, Subburam Rajaram, Hinrich Schu ̈tze, and Thomas Runkler. 2019. Neural relation extrac- tion within and across sentence boundaries. In AAAI, pages 6513–6520, Honolulu, HI, USA. AAAI Press.
- Guoshun Nan, Zhijiang Guo, Ivan Sekulic, and Wei Lu. 2020. Reasoning with latent structure refinement for document-level relation extraction. In ACL, pages 1546–1557, Online. ACL.
- Linfeng Song, Yue Zhang, Zhiguo Wang, and Daniel Gildea. 2018. N-ary relation extraction using graph- state LSTM. In EMNLP, pages 2226–2235, Brus- sels, Belgium. ACL.
- Hengzhu Tang, Yanan Cao, Zhenyu Zhang, Jiangxia Cao, Fang Fang, Shi Wang, and Pengfei Yin. 2020. HIN: Hierarchical inference network for document- level relation extraction. In PAKDD, pages 197–209, Singapore. Springer.
- Hong Wang, Christfried Focke, Rob Sylvester, Nilesh Mishra, and William Wang. 2019. Fine-tune Bert for DocRED with two-step process. arXiv:1909.11898.
- Deming Ye, Yankai Lin, Jiaju Du, Zhenghao Liu, Maosong Sun, and Zhiyuan Liu. 2020. Coreferen- tial reasoning learning for language representation. In EMNLP, Online. ACL.