【关系抽取】Three Sentences Are All You Need Local Path Enhanced Document Relation Extractio(文档级别)

Three Sentences Are All You Need Local Path Enhanced Document Relation Extraction

  • 论文地址:https://arxiv.org/abs/2106.01793
  • 代码地址:https://github.com/AndrewZhe/Three-Sentences-Are-All-You-Need

Abstract

本文属于Document-level Relation Extraction任务,和句子级关系抽取任务不一样的是:用一系列句子来表明实体间的关系。

本文使用了一个简单,但是非常有效的方法启发式地选择有用的句子进行关系抽取,该方法结合BiLSTM达到非常好的效果,甚至超越图神经网络模型。

Introduction

文档级别的关系抽取和句子级别的关系抽取的区别是,在文档级别的关系抽取中,使用了不止一个句子描述实体之间的关系。在文档级关系抽取中,一个给定的实体对,并不需要整篇文档,只需要一个或者几个句子即可确定实体对的关系。

图1

如上图,S[1]已经足够确定Finland是Espoo的一个country。其余两个关系也只需要两句话足以。整个篇章包含了6个句子,但是确定每个实体对之间的关系,其实只需要1-2个句子。然后就给我们一个思考: 对于一个给定的实体对,需要多少个句子即可确定他们之间的关系?

本文在DocRED1、CDR2和GDA3文档级关系抽取语料上统计,结果如表一,我们找到超过95%的实例需要不超过3句的支撑证据,87%需要2句或更少。 所以初步的建议是:比起整篇文章考虑,选择特定句子进行考虑可能更有用。已有的研究成果应用GNNs进行过滤工作45,在这GNN则使用GNNs通过一个注意力机制(aggregation scheme)6 ,在整篇文章中选取相关的信息。但是始终没有比较好的解析性,如果上述的统计结果是有效地,那么是否有更好地方式来筛选支撑句子和关键性信息?

本文通过设计**三个启发式规则 **来找到一系列地路径,作为支撑的证据。

  • 特别的,连续的路径被认为是两个实体在文本中比较相近的情况,所以如果他们有三个连续的句子,那么就把这些句子作为一个路径。
  • 两个实体距离比较远,则需要Multi-Hop 路径,通过一些和两个实体共同出现的其他实体作为桥梁连接。比如,在图1中,The Espoo Cathedral在S[1]出现,the EC Parish在S[6]中出现,则需要通过一个桥梁连接。在这种情况下,S[1]和S[6]组成Multi-Hop路径。
  • 如果以上两种情况都不适用,收集所有的句子对,这些句子对中一个包含头实体,一个包含尾实体,来作为默认的路径(Default Paths)。

作者发现87.5%的情况能用以上启发式选择给i则覆盖,然后输入到一个简单的神经网络进行关系抽取,发现他在DocRED语料集上的效果异常的好。

Do we need the entire document?

文档级关系抽取难点:两个实体和关系被包含在不同的句子中。

提出问题:how many sentences from the entire document are required to identify the relationship
between an entity pair?

解决:分析了DocRED的所有支撑证据表示,96%的样本最多只需要3个支撑证据。总共只占了一个文档的37.5%,平均每篇文档有8个句子。这就意味着,只要阅读一小部分文档,就能确定关系。除此之外,还在CDR、GDA语料集上进行分析,结果相同。

Which sentences are decisive?

那么怎么去选择支撑句子,才能充分的确定实体间的关系呢?

图2

对于最简单的情况:两个实体都在一个句子中,这个句子就能当作一个路径。

对于比较复杂一点的情况,也就是两个实体不会在同一个句子中出现,就定义了一下三种路径类型:

Consecutive Paths

之前的研究已经表明:大部分的句子间的相互关系经常都在相邻的文本中。78因此,当头尾实体在附近的句子中时,我们选择这些连续的句子来组成一个路径,但是这些句子不能超过3个,当他们在同一个句子中出现时就变成了上述最简单的情况。

Multi-Hop Paths

另一种比较典型的情况就是句间关系时Multi-hop关系15,这种情况下头实体和尾实体距离较远,但都能通过bridge entites进行连接。从头实体出发,通过所有的桥实体,最终到达尾实体,选择所有经过的句子作为路径。如果这些实体包含在 S p 1 , … , S p k + 1 S_{p1},\dots,S_{pk+1} Sp1,,Spk+1总共 k + 1 k+1 k+1个句子中,根据上述发现的规律,我们将限定 k k k的值最大为2。

Default Paths

以上两种情况失效时,才采用这种方式。

{ S h 1 , … , S h p } \{S_{h1},\dots,S_{hp}\} {Sh1,,Shp} { S t 1 , … , S t q } \{S_{t1},\dots,S_{tq}\} {St1,,Stq}分别表示包含头实体和尾实体的句子,然后一共有 p × q p \times q p×q种组合 { S h 1 , S t 1 } , … , { S h p , S t q } \{ S_{h1},S_{t1} \} , \dots , \{ S_{hp},S_{tq} \} {Sh1,St1},,{Shp,Stq}

Comparing with Annotated Evidence

为了表明本文方法的有效性,检查我们的从DocRED种获得路径集合的大小和一致性。

在章节2种提到,gold annotation作为一个所有相关证据的收集器,而我们收集的每一个路径表示,可能是最小的句子集合。理想情况下,实体之间的关系,能通过我们的路径集合进行表示。因此,路径的每个单元被表示成一个支撑证据的超集。然后本文使用支撑证据的覆盖率来衡量我们的路径集合的充分性。

图3

Experiments

本文所使用的是BiLSTM模型进行关系抽取,然后以下是试验结果,可以看见这个效果,比使用GNN这些复杂的神经网络还要好的!!

图4

References


  1. Yuan Yao, Deming Ye, Peng Li, Xu Han, Yankai Lin, Zhenghao Liu, Zhiyuan Liu, Lixin Huang, Jie Zhou, and Maosong Sun. 2019. DocRED: A large-scale document-level relation extraction dataset. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 764–777, Florence, Italy. Association for Computational Linguistics. ↩︎ ↩︎

  2. Jiao Li, Yueping Sun, Robin J Johnson, Daniela Sciaky, Chih-Hsuan Wei, Robert Leaman, Allan Peter Davis, Carolyn J Mattingly, Thomas C Wiegers, and Zhiyong Lu. 2016. Biocreative V CDR task corpus: A resource for chemical disease relation extraction. Database: the journal of biological databases and curation, 2016:baw068. ↩︎

  3. Ye Wu, Ruibang Luo, Henry CM Leung, Hing-Fung Ting, and Tak-Wah Lam. 2019. Renet: A deep learning approach for extracting gene-disease associations from literature. In International Conference on Research in Computational Molecular Biology, pages 272–284. Springer. ↩︎

  4. Fenia Christopoulou, Makoto Miwa, and Sophia Ananiadou. 2019. Connecting the dots: Document-level neural relation extraction with edge-oriented graphs. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 4925– 4936, Hong Kong, China. Association for Computational Linguistics. ↩︎

  5. Shuang Zeng, Runxin Xu, Baobao Chang, and Lei Li. 2020b. Double graph based reasoning for documentlevel relation extraction. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 1630–1640, Online. Association for Computational Linguistics. ↩︎ ↩︎

  6. Guoshun Nan, Zhijiang Guo, Ivan Sekulic, and Wei Lu. 2020a. Reasoning with latent structure refinement for document-level relation extraction. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 1546– 1557, Online. Association for Computational Linguistics. ↩︎

  7. Kumutha Swampillai and Mark Stevenson. 2010. Intersentential relations in information extraction corpora. In Proceedings of the Seventh International Conference on Language Resources and Evaluation (LREC’10), Valletta, Malta. European Language Resources Association (ELRA). ↩︎

  8. Chris Quirk and Hoifung Poon. 2017. Distant supervision for relation extraction beyond the sentence boundary. In Proceedings of the 15th Conference of the European Chapter of the Association for Computational Linguistics: Volume 1, Long Papers, pages 1171–1182, Valencia, Spain. Association for Computational Linguistics. ↩︎

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
关系抽取自然语言处理中的一个重要任务,它的目标是从文本中提取实体之间的关系。以下是一个使用Python进行中文关系抽取的示例代码: 1. 安装相关依赖库 ```python pip install pyltp pip install gensim pip install numpy pip install pandas ``` 2. 下载LTP模型和Word2Vec模型 LTP模型可以从官网下载,Word2Vec模型可以从[中文维基百科语料库](https://dumps.wikimedia.org/zhwiki/latest/zhwiki-latest-pages-articles.xml.bz2)中训练得到。 3. 加载模型和数据 ```python import os import numpy as np import pandas as pd import jieba import jieba.posseg as pseg from pyltp import SentenceSplitter, Segmentor, Postagger, Parser from gensim.models import KeyedVectors # 加载LTP模型 LTP_DATA_DIR = 'ltp_data_v3.4.0' cws_model_path = os.path.join(LTP_DATA_DIR, 'cws.model') pos_model_path = os.path.join(LTP_DATA_DIR, 'pos.model') par_model_path = os.path.join(LTP_DATA_DIR, 'parser.model') segmentor = Segmentor() segmentor.load(cws_model_path) postagger = Postagger() postagger.load(pos_model_path) parser = Parser() parser.load(par_model_path) # 加载Word2Vec模型 word2vec_model_path = 'zhwiki_word2vec_300.bin' word2vec = KeyedVectors.load_word2vec_format(word2vec_model_path, binary=True) # 加载数据 data = pd.read_csv('data.csv') ``` 4. 对文本进行分句和分词,提取实体和关系 ```python # 分句 sentences = SentenceSplitter.split(data['text']) # 实体和关系提取 entities = [] relations = [] for sentence in sentences: words = segmentor.segment(sentence) postags = postagger.postag(words) arcs = parser.parse(words, postags) # 提取实体 for i in range(len(words)): if postags[i] == 'nh': entity = words[i] for j in range(i+1, len(words)): if arcs[j].head == i+1 and postags[j] == 'ni': entity += words[j] else: break entities.append(entity) # 提取关系 for i in range(len(words)): if postags[i] == 'v': relation = words[i] for j in range(len(words)): if arcs[j].head == i+1 and postags[j] == 'nh': relation += words[j] else: break relations.append(relation) # 去重 entities = list(set(entities)) relations = list(set(relations)) ``` 5. 计算实体和关系的相似度 ```python # 计算相似度 def similarity(a, b): if a in word2vec.vocab and b in word2vec.vocab: return word2vec.similarity(a, b) else: return 0 # 构建相似度矩阵 entity_matrix = np.zeros((len(entities), len(entities))) for i in range(len(entities)): for j in range(i+1, len(entities)): entity_matrix[i][j] = similarity(entities[i], entities[j]) entity_matrix[j][i] = entity_matrix[i][j] relation_matrix = np.zeros((len(relations), len(relations))) for i in range(len(relations)): for j in range(i+1, len(relations)): relation_matrix[i][j] = similarity(relations[i], relations[j]) relation_matrix[j][i] = relation_matrix[i][j] ``` 6. 输出结果 ```python # 输出结果 print('实体:') for entity in entities: print(entity) print('关系:') for relation in relations: print(relation) ``` 以上是一个简单的中文关系抽取示例,具体实现还需要根据具体场景进行调整和优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值