OpenNRE

神经关系提取(NRE)的开源软件包。「An Open-Source Package for Neural Relation Extraction (NRE).」

Github星跟蹤圖

OpenNRE

我们有一个 DEMO 网站(http://opennre.thunlp.ai/)。试试看!

OpenNRE 是一个开源且可扩展的工具包,它提供了一个统一的框架来实现关系提取模型。该软件包是为以下人群设计的:

关系提取新手:我们提供了手工教程和详细的文档,不仅可以让你使用关系提取工具,而且帮助你更好地了解该领域的研究进展。

开发人员:我们易于使用的界面和高性能的实现可以加速您在实际应用程序中的部署。此外,我们提供了几种预训练的模型,无需任何培训即可投入生产。

研究人员:借助我们的模块化设计,各种任务设置和度量工具,您只需进行少量修改即可轻松地对自己的模型进行实验。我们还为关系提取的不同设置提供了几种最常用的基准。

任何需要提交NLP作业以打动他们的教授的人:借助最先进的模型,我们的软件包可以绝对帮助您在同学中脱颖而出!

该软件包主要由 Tianyu Gao, Xu Han, Shulian Cao, Lumin Tang, Yankai Lin, Zhiyuan Liu 贡献。

什么是关系提取

关系提取是一种自然语言处理(NLP)任务,旨在提取实体(例如 Bill Gates 和 Microsoft)之间的关系(例如,创始人)。例如,从创建微软的比尔·盖茨的句子中,我们可以提取出三元关系(微软的创始人比尔·盖茨)。

关系提取是自动知识图构建中的关键技术。通过使用关系提取,我们可以累积地提取新的关系事实并扩展知识图谱,作为机器了解人类世界的一种方式,它具有许多下游应用程序,例如问题解答,推荐系统和搜索引擎。

如何引用

出色的研究工作总是伴随着详尽而忠实的参考。 如果您使用或扩展我们的工作,请引用以下文章:

@inproceedings{han-etal-2019-opennre,
    title = "{O}pen{NRE}: An Open and Extensible Toolkit for Neural Relation Extraction",
    author = "Han, Xu and Gao, Tianyu and Yao, Yuan and Ye, Deming and Liu, Zhiyuan and Sun, Maosong",
    booktitle = "Proceedings of EMNLP-IJCNLP: System Demonstrations",
    year = "2019",
    url = "https://www.aclweb.org/anthology/D19-3029",
    doi = "10.18653/v1/D19-3029",
    pages = "169--174"
}

很荣幸能够帮助您更好地利用我们的OpenNRE工具包探索关系提取!

论文和文件

如果您想了解有关神经关系提取的更多信息,请访问我们的另一个项目(NREPapers)。

关于这个项目的更多细节,你可以参考我们的文档

安装

作为 Python 软件包安装

我们现在正在努力将 OpenNRE 作为 Python 包进行部署。快来了!

使用 Git 仓库

从我们的 github 页面克隆存储库(别忘了给我们加注星标:))

git clone https://github.com/thunlp/OpenNRE.git

如果太慢,可以尝试

git clone https://github.com/thunlp/OpenNRE.git --depth 1

然后安装所有依赖:

pip install -r requirements.txt

然后安装包

python setup.py install 

如果您还想修改代码,请运行以下命令:

python setup.py develop

请注意,为了快速部署,我们已排除了所有数据和预训练文件。您可以通过运行基准和预培训文件夹中的脚本来手动下载它们。例如,如果要下载FewRel数据集,则可以运行
注意,为了快速部署,我们已排除了所有数据和预训练文件。您可以通过在基准测试和预训练文件夹中运行脚本来手动下载它们。例如,如果您想下载 FewRel 数据集,您可以运行

bash benchmark/download_fewrel.sh

轻松启动

将 OpenNRE 目录添加到 PYTHONPATH 环境变量,或在 OpenNRE 文件夹下打开 python 会话。然后导入我们的包并加载预先训练的模型。

>>> import opennre
>>> model = opennre.get_model('wiki80_cnn_softmax')

请注意,第一次下载检查点和数据可能要花费几分钟。然后使用推断进行句子级关系提取

>>> model.infer({'text': 'He was the son of Máel Dúin mac Máele Fithrich, and grandson of the high king Áed Uaridnach (died 612).', 'h': {'pos': (18, 46)}, 't': {'pos': (78, 91)}})
('father', 0.5108704566955566)

您将获得关系结果及其置信度分数。

对于更高级别的用法,您可以参考我们的文档

Google群组

如果您想接收我们的最新消息或参加讨论,请加入我们的Google 组

(The first version translated by vz on 2020.07.19)

主要指標

概覽
名稱與所有者thunlp/OpenNRE
主編程語言Python
編程語言Python (語言數: 2)
平台Linux, Mac, Windows
許可證MIT License
所有者活动
創建於2017-02-26 07:37:12
推送於2024-01-10 11:52:49
最后一次提交2024-01-10 19:52:48
發布數0
用户参与
星數4.4k
關注者數121
派生數1.1k
提交數177
已啟用問題?
問題數367
打開的問題數14
拉請求數15
打開的拉請求數4
關閉的拉請求數6
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

OpenNRE

CircleCI

We have a DEMO website (http://opennre.thunlp.ai/). Try it out!

OpenNRE is an open-source and extensible toolkit that provides a unified framework to implement relation extraction models. This package is designed for the following groups:

  • New to relation extraction: We have hand-by-hand tutorials and detailed documents that can not only enable you to use relation extraction tools, but also help you better understand the research progress in this field.
  • Developers: Our easy-to-use interface and high-performance implementation can acclerate your deployment in the real-world applications. Besides, we provide several pretrained models which can be put into production without any training.
  • Researchers: With our modular design, various task settings and metric tools, you can easily carry out experiments on your own models with only minor modification. We have also provided several most-used benchmarks for different settings of relation extraction.
  • Anyone who need to submit an NLP homework to impress their professors: With state-of-the-art models, our package can definitely help you stand out among your classmates!

This package is mainly contributed by Tianyu Gao, Xu Han, Shulian Cao, Lumin Tang, Yankai Lin, Zhiyuan Liu

What is Relation Extraction

Relation extraction is a natural language processing (NLP) task aiming at extracting relations (e.g., founder of) between entities (e.g., Bill Gates and Microsoft). For example, from the sentence Bill Gates founded Microsoft, we can extract the relation triple (Bill Gates, founder of, Microsoft).

Relation extraction is a crucial technique in automatic knowledge graph construction. By using relation extraction, we can accumulatively extract new relation facts and expand the knowledge graph, which, as a way for machines to understand the human world, has many downstream applications like question answering, recommender system and search engine.

How to Cite

A good research work is always accompanied by a thorough and faithful reference. If you use or extend our work, please cite the following paper:

@inproceedings{han-etal-2019-opennre,
    title = "{O}pen{NRE}: An Open and Extensible Toolkit for Neural Relation Extraction",
    author = "Han, Xu and Gao, Tianyu and Yao, Yuan and Ye, Deming and Liu, Zhiyuan and Sun, Maosong",
    booktitle = "Proceedings of EMNLP-IJCNLP: System Demonstrations",
    year = "2019",
    url = "https://www.aclweb.org/anthology/D19-3029",
    doi = "10.18653/v1/D19-3029",
    pages = "169--174"
}

It's our honor to help you better explore relation extraction with our OpenNRE toolkit!

Papers and Document

If you want to learn more about neural relation extraction, visit another project of ours (NREPapers).

You can refer to our document for more details about this project.

Install

Install as A Python Package

We are now working on deploy OpenNRE as a Python package. Coming soon!

Using Git Repository

Clone the repository from our github page (don't forget to star us!)

git clone https://github.com/thunlp/OpenNRE.git

If it is too slow, you can try

git clone https://github.com/thunlp/OpenNRE.git --depth 1

Then install all the requirements:

pip install -r requirements.txt

Then install the package with

python setup.py install 

If you also want to modify the code, run this:

python setup.py develop

Note that we have excluded all data and pretrain files for fast deployment. You can manually download them by running scripts in the benchmark and pretrain folders. For example, if you want to download FewRel dataset, you can run

bash benchmark/download_fewrel.sh

Easy Start

Add OpenNRE directory to the PYTHONPATH environment variable, or open a python session under the OpenNRE folder. Then import our package and load pre-trained models.

>>> import opennre
>>> model = opennre.get_model('wiki80_cnn_softmax')

Note that it may take a few minutes to download checkpoint and data for the first time. Then use infer to do sentence-level relation extraction

>>> model.infer({'text': 'He was the son of Máel Dúin mac Máele Fithrich, and grandson of the high king Áed Uaridnach (died 612).', 'h': {'pos': (18, 46)}, 't': {'pos': (78, 91)}})
('father', 0.5108704566955566)

You will get the relation result and its confidence score.

For higher-level usage, you can refer to our document.

Google Group

If you want to receive our update news or take part in discussions, please join our Google Group