🚀 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 |