Unsupervised Relation Extraction from Language Models using Constrained Cloze Completion (2020)

Abstract: We show that state-of-the-art self-supervised language models can be readily used to extract relations from a corpus without the need to train a fine-tuned extractive head. We introduce RE-Flex, a simple framework that performs constrained cloze completion over pretrained language models to perform unsupervised relation extraction. RE-Flex uses contextual matching to ensure that language model predictions matches supporting evidence from the input corpus that is relevant to a target relation. We perform an extensive experimental study over multiple relation extraction benchmarks and demonstrate that RE-Flex outperforms competing unsupervised relation extraction methods based on pretrained language models by up to 27.8 F1 points compared to the next-best method. Our results show that constrained inference queries against a language model can enable accurate unsupervised relation extraction.

## introduction relation extraction is a fundamental problem in constructing knowledge bases from unstructured text. the goal of relational extraction is to identify mentions of relational facts (i.e., binary relations between entities) in a text corpus. traditionally, relation extraction systems leverage supervised machine learning approaches to train specialized extraction models for different relations @xcite . however, advances in natural language understanding models, such as bert @xcite and roberta @xcite , have shifted the focus towards general relation extraction where a single natural language model is used for extraction across different relations @xcite . a key idea behind general relation extraction is to leverage question answering (qa) models and use the reading comprehension capabilities of modern natural language models to identify relation mentions in text. for example, the relation drafted by can be completed for the subject stephen curry by answering the question who drafted stephen curry? state-ofthe-art results leverage fine-tuned qa models over self-supervised contextual representations @xcite . initial approaches @xcite learn extractive qa models by exploiting annotated question-answer pairs and following a supervised setting. while effective in domains related to the annotated question-answer data, supervised extractive qa approaches can fail to generalize to new domains for which annotations are not available @xcite . for this reason, more recent approaches @xcite propose to use automatically generated question-answer pairs for training and adopt a weakly-supervised setting @xcite . however, noisy or inaccurate training data leads to a significant drop in performance. in this work, we revisit the problem of general relation extraction and show that one can perform unsupervised relation extraction by directly using the generative ability of self-supervised contextual language models and without training a finetuned qa model. we build upon the recent observation that modern language models encode the semantic information captured in text and are capable of generating answers to relational queries by answering cloze queries that represent a relation @xcite . for instance, the previous extraction example can be transformed to the cloze query stephen curry was drafted by @xcite and the language model can be used to predict the most probable value for the masked token. further, recent works @xcite show that prefixing cloze queries with relevant information, i.e., relevant context, can improve extraction accuracy by utilizing the models' reading comprehension ability @xcite . while promising, we show that an out-of-box application of these methods to general relation extraction falls short of extractive qa models. the core limitation is that of factual generation: language models do not memorize general factual information @xcite , and are liable to predict off-topic or non-factual tokens @xcite . we propose a novel two-pronged approach that ensures factual predictions from a contextual language model. first, given an extractive relational cloze query and an associated context, we propose a method to restrict the model's answer to the query to be factual information in the associated context. we introduce a context-constrained inference procedure over language models and does not require altering the pre-training algorithm. this procedure relies on redistributing the probability mass of the language model's initial prediction to tokens only present in the context. by restricting the model's inference to be present in the context, we ensure a factual response to a relational cloze query. this strategy is similar to methods used in unsupervised neural summarization @xcite to ensure factual summary generation. second, we introduce an unsupervised solution to determining whether the context associated with the query contains an answer to a relational query. we propose an information theoretic scoring function to measure how well a relation is represented in a given context, then cluster contexts into "accept" and "reject" categories, denoting whether the contexts express the relation or not. we present an extensive experimental evaluation of re-flex against state of the art general relation extraction methods across several settings. we demonstrate that re-flex outperforms methods that rely on weakly supervised qa models @xcite by up to 27.8 f 1 points compared to the next-best method, and can even outperform methods that rely on supervised qa models @xcite by up to 12.4 f 1 points in certain settings. our results demonstrate that by constraining language generation, re-flex yields accurate unsupervised relation extractions. ## related work typical relation extraction relies on rule-based methods @xcite and supervised machine learning models that target specific relation types @xcite @xcite . these approaches are lim-ited to predefined relations and do not extend to relations that are not specified during training. to alleviate this problem, open information extraction (openie) @xcite proposes to represent relations as unstructured text. however, in openie different phrasings of the same relation can be treated as different relations, leading to redundant extractions. to address this issue, universal schema @xcite uses matrix factorization to link openie relations to an existing knowledge base to distill extracted relations. our problem is aligned with the thrust of openie: enabling general relations to be extracted from text corpora without relation specific supervision. more recently, question answering has become a popular method to extract relations from text. @xcite showed that casting relation extraction as a qa problem can enable new, unseen relations to be extracted without additional training. advances in large self-supervised language models @xcite have enabled qa models to achieve human level performance on some datasets @xcite . because these models are trained on a slot-filling objective, there has been a branch between methods that use a qa head to extract spans from input, and methods that use token generation capability of language models to perform information extraction. both are relevant to our work. many qa-based methods have been proposed to identify spans from text. @xcite present a reading comprehension model based on the architecture of @xcite to track the dynamic state of a knowledge graph as the model reads the text. li et al. (2019) there are also many generative methods that rely only on a language model to generate the answer to queries. @xcite show that self-supervised language models can generate answers to questions. @xcite show that given natural language cloze templates that represent relations, masked language models (devlin ## problem statement we consider a slot filling form of relation extraction: given incomplete relations, we must complete the relations using evidence from an underlying text source. we assume a set of input relations r. for each relation @xmath0, we assume access to a collection of entity-context candidate pairs. let ec r denote this collection for relation r. we consider each pair (e, c) ∈ ec r to be candidate evidence that some span in c completes relation r for the given entity mention e. if we consider the context to be composed of a sequence of tokens @xmath1, c 2 , . . . , c n ), we must return some subsequence @xmath2, ..., c i+m ) such that the relation r(e, a) holds, or ∅ if c does not express the relation for the given entity. furthermore, we represent each relation with a cloze template: a natural language representation of what the relation is attempting to capture. a cloze template for relation r is a sequence of tokens @xmath3, . . . , t sub , . . . , t obj , . . . , t k ), where t sub and t obj are special tokens denoting the expected locations of the subject and object entities of the relation. for each (e, c), we substitute the special token t sub with e. let t(e) = (t 1 , . . . , e, . . . , t obj , . . . , t k ) denote this substitution. we form our final cloze query by concatenating the context c to the cloze task t(e) and denote the close query q(e, c) = [c, t(e)]. given a cloze query q(e, c), we express relation extraction as the following inference task: predict if there is a subsequence of the context c that correctly substitutes the special token t obj in the cloze task t(e), otherwise return ∅. as an example, consider the relation drafted by ## the re-flex framework an overview of re-flex is shown in figure 1 . given a target relation, re-flex assumes as input a set of entities, a set of candidate contexts, and a cloze template expressing the relation. the output of re-flex is a table containing subject-object instances of this relation for the input entities. re-flex is built around two key parts: 1) context rejection and 2) anchor token identification and token expansion. in the first part, re-flex determines if the cloze query for a candidate entity-context pair does not contain a valid mention of the target relation, and hence, we must return ∅. in the second part, given valid entity-context pairs for the target relation, re-flex identifies the subsequence in the corresponding context that completes the relation for the given entity. we describe each part next. ## conclusion we introduced re-flex, a simple framework that constrains the inference of self-supervised language models after they have been trained. we perform an extensive experimental study over multiple relation extraction benchmarks and demonstrate that re-flex outperforms competing relation extraction methods by up to 27.8 f 1 points compared to the next-best unsupervised method. stephen soderland, david fisher, jonathan aseltine, and wendy lehnert. 1995. crystal inducing a conceptual dictionary. in proceedings of the 14th international joint conference on artificial intelligence -volume 2, ijcai'95, pages 1314-1319, san francisco, ca, usa. morgan kaufmann publishers inc. thomas wolf, lysandre debut, victor sanh, julien chaumond, clement delangue, anthony moi, pierric cistac, tim rault, rémi louf, morgan funtowicz, et al. 2019. transformers: state-of-theart natural language processing. arxiv preprint arxiv:1910.03771. wenhan xiong, mo yu, shiyu chang, xiaoxiao guo, and william yang wang. 2019. improving question answering over incomplete kbs with knowledgeaware reader. in proceedings of the 57th annual meeting of the association for computational linguistics, pages 4258-4264, florence, italy. association for computational linguistics. yuhao zhang, victor zhong, danqi chen, gabor angeli, and christopher d. manning. 2017a. positionaware attention and supervised data improve slot filling. in proceedings of the 2017 conference on empirical methods in natural language processing (emnlp 2017), pages 35-45. yuhao zhang, victor zhong, danqi chen, gabor angeli, and christopher d manning. 2017b. positionaware attention and supervised data improve slot filling. in proceedings of the 2017 conference on empirical methods in natural language processing, pages 35-45. jiawei zhou and alexander rush. 2019. simple unsupervised summarization by contextual matching. in proceedings of the 57th annual meeting of the association for computational linguistics, pages 5101-5106, florence, italy. association for computational linguistics.