🚀 CoReNer
CoReNer是一个多任务模型,可用于命名实体识别、关系抽取、实体提及检测和共指消解。它能有效处理多种实体类型和关系类型,为信息抽取任务提供强大支持。
🚀 快速开始
我们发布了一个在线演示,你可以轻松体验模型。点击查看:http://corener-demo.aiola-lab.com。该演示使用了 aiola/roberta-base-corener 模型。
✨ 主要特性
- 多任务处理:能够同时进行命名实体识别、关系抽取、实体提及检测和共指消解。
- 广泛的实体和关系类型:可识别多种实体类型,如GPE、ORG、PERSON等;以及多种关系类型,如Kill、Live_In等。
📦 安装指南
文档未提供安装步骤,暂不展示。
💻 使用示例
基础用法
import json
from transformers import AutoTokenizer
from corener.models import Corener, ModelOutput
from corener.data import MTLDataset
from corener.utils.prediction import convert_model_output
tokenizer = AutoTokenizer.from_pretrained("aiola/roberta-base-corener")
model = Corener.from_pretrained("aiola/roberta-base-corener")
model.eval()
examples = [
"Apple Park is the corporate headquarters of Apple Inc., located in Cupertino, California, United States. It was opened to employees in April 2017, while construction was still underway, and superseded the original headquarters at 1 Infinite Loop, which opened in 1993."
]
dataset = MTLDataset(
types=model.config.types,
tokenizer=tokenizer,
train_mode=False,
)
dataset.read_dataset(examples)
example = dataset.get_example(0)
output: ModelOutput = model(
input_ids=example.encodings,
context_masks=example.context_masks,
entity_masks=example.entity_masks,
entity_sizes=example.entity_sizes,
entity_spans=example.entity_spans,
entity_sample_masks=example.entity_sample_masks,
inference=True,
)
print(json.dumps(convert_model_output(output=output, batch=example, dataset=dataset), indent=2))
高级用法
更多详细信息和使用示例请查看:https://github.com/aiola-lab/corener 。
📚 详细文档
模型描述
这是一个用于命名实体识别、关系抽取、实体提及检测和共指消解的多任务模型。
我们将命名实体识别建模为一个跨度分类任务,将关系抽取建模为(命名实体识别)跨度元组的多标签分类。同样,将实体提及检测建模为一个跨度分类任务,将共指消解建模为(实体提及检测)跨度元组的二元分类。为了构建共指簇,我们保留每个提及的前一个先行词,然后计算提及的无向图的连通分量。
该模型经过训练,可识别以下内容:
- 实体类型:GPE、ORG、PERSON、DATE、NORP、CARDINAL、MONEY、PERCENT、WORK_OF_ART、ORDINAL、EVENT、LOC、TIME、FAC、QUANTITY、LAW、PRODUCT、LANGUAGE。
- 关系类型:Kill、Live_In、Located_In、OrgBased_In、Work_For。
🔧 技术细节
文档未提供技术细节相关内容,暂不展示。
📄 许可证
本项目采用Apache-2.0许可证。
属性 |
详情 |
模型类型 |
多任务模型,用于命名实体识别、关系抽取、实体提及检测和共指消解 |
训练数据 |
Ontonotes、CoNLL04 |