Rebel Large
REBEL是一种基于BART的序列到序列模型,用于端到端关系抽取,支持200多种不同关系类型。
下载量 37.57k
发布时间 : 3/2/2022
模型简介
REBEL通过将关系抽取重新定义为序列到序列任务,简化了从原始文本中提取关系三元组的过程。它使用自回归序列到序列模型,能够直接从文本中提取关系三元组,支持多种应用如知识库填充和事实核查。
模型特点
端到端关系抽取
将关系抽取任务简化为序列到序列任务,直接从文本中生成关系三元组。
多关系类型支持
支持200多种不同关系类型,适用于广泛的信息抽取场景。
高性能
在多个关系抽取基准测试中达到最先进的性能。
模型能力
关系抽取
实体关系识别
知识库填充
使用案例
知识库构建
知识库填充
从非结构化文本中提取关系三元组,用于填充或验证知识库。
提高知识库的覆盖率和准确性。
信息抽取
事实核查
从文本中提取关系三元组,用于验证事实的准确性。
支持自动化事实核查流程。
🚀 REBEL
:端到端语言生成的关系抽取
REBEL提出了一种新的线性化方法,并将关系抽取重新定义为一个序列到序列(seq2seq)任务。该模型可用于从原始文本中抽取关系三元组,适用于知识图谱填充、事实核查等多个下游任务。
多语言更新!查看 mREBEL,这是一个多语言版本,涵盖更多关系类型、语言,并包含实体类型。
✨ 主要特性
- 新的线性化方法:提出了一种新的线性化方法,将关系三元组表示为文本序列,简化了关系抽取任务。
- 端到端关系抽取:基于BART的seq2seq模型,可进行端到端的关系抽取,支持200多种不同的关系类型。
- 灵活性高:在多个关系抽取和关系分类基准测试上进行微调,在大多数基准测试中达到了最先进的性能。
📚 详细文档
这是2021年EMNLP会议论文 REBEL: Relation Extraction By End-to-end Language generation 的模型卡片。如果您使用了相关代码,请在论文中引用这项工作:
@inproceedings{huguet-cabot-navigli-2021-rebel-relation,
title = "{REBEL}: Relation Extraction By End-to-end Language generation",
author = "Huguet Cabot, Pere-Llu{\'\i}s and
Navigli, Roberto",
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2021",
month = nov,
year = "2021",
address = "Punta Cana, Dominican Republic",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2021.findings-emnlp.204",
pages = "2370--2381",
abstract = "Extracting relation triplets from raw text is a crucial task in Information Extraction, enabling multiple applications such as populating or validating knowledge bases, factchecking, and other downstream tasks. However, it usually involves multiple-step pipelines that propagate errors or are limited to a small number of relation types. To overcome these issues, we propose the use of autoregressive seq2seq models. Such models have previously been shown to perform well not only in language generation, but also in NLU tasks such as Entity Linking, thanks to their framing as seq2seq tasks. In this paper, we show how Relation Extraction can be simplified by expressing triplets as a sequence of text and we present REBEL, a seq2seq model based on BART that performs end-to-end relation extraction for more than 200 different relation types. We show our model{'}s flexibility by fine-tuning it on an array of Relation Extraction and Relation Classification benchmarks, with it attaining state-of-the-art performance in most of them.",
}
论文的原始仓库可以在 这里 找到。
请注意,右侧的推理小部件不会输出特殊标记,这些标记对于区分主语、宾语和关系类型是必要的。有关REBEL及其预训练数据集的演示,请查看 Spaces演示。
💻 使用示例
基础用法
from transformers import pipeline
triplet_extractor = pipeline('text2text-generation', model='Babelscape/rebel-large', tokenizer='Babelscape/rebel-large')
# We need to use the tokenizer manually since we need special tokens.
extracted_text = triplet_extractor.tokenizer.batch_decode([triplet_extractor("Punta Cana is a resort town in the municipality of Higuey, in La Altagracia Province, the eastern most province of the Dominican Republic", return_tensors=True, return_text=False)[0]["generated_token_ids"]])
print(extracted_text[0])
# Function to parse the generated text and extract the triplets
def extract_triplets(text):
triplets = []
relation, subject, relation, object_ = '', '', '', ''
text = text.strip()
current = 'x'
for token in text.replace("<s>", "").replace("<pad>", "").replace("</s>", "").split():
if token == "<triplet>":
current = 't'
if relation != '':
triplets.append({'head': subject.strip(), 'type': relation.strip(),'tail': object_.strip()})
relation = ''
subject = ''
elif token == "<subj>":
current = 's'
if relation != '':
triplets.append({'head': subject.strip(), 'type': relation.strip(),'tail': object_.strip()})
object_ = ''
elif token == "<obj>":
current = 'o'
relation = ''
else:
if current == 't':
subject += ' ' + token
elif current == 's':
object_ += ' ' + token
elif current == 'o':
relation += ' ' + token
if subject != '' and relation != '' and object_ != '':
triplets.append({'head': subject.strip(), 'type': relation.strip(),'tail': object_.strip()})
return triplets
extracted_triplets = extract_triplets(extracted_text[0])
print(extracted_triplets)
高级用法
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
def extract_triplets(text):
triplets = []
relation, subject, relation, object_ = '', '', '', ''
text = text.strip()
current = 'x'
for token in text.replace("<s>", "").replace("<pad>", "").replace("</s>", "").split():
if token == "<triplet>":
current = 't'
if relation != '':
triplets.append({'head': subject.strip(), 'type': relation.strip(),'tail': object_.strip()})
relation = ''
subject = ''
elif token == "<subj>":
current = 's'
if relation != '':
triplets.append({'head': subject.strip(), 'type': relation.strip(),'tail': object_.strip()})
object_ = ''
elif token == "<obj>":
current = 'o'
relation = ''
else:
if current == 't':
subject += ' ' + token
elif current == 's':
object_ += ' ' + token
elif current == 'o':
relation += ' ' + token
if subject != '' and relation != '' and object_ != '':
triplets.append({'head': subject.strip(), 'type': relation.strip(),'tail': object_.strip()})
return triplets
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("Babelscape/rebel-large")
model = AutoModelForSeq2SeqLM.from_pretrained("Babelscape/rebel-large")
gen_kwargs = {
"max_length": 256,
"length_penalty": 0,
"num_beams": 3,
"num_return_sequences": 3,
}
# Text to extract triplets from
text = 'Punta Cana is a resort town in the municipality of Higüey, in La Altagracia Province, the easternmost province of the Dominican Republic.'
# Tokenizer text
model_inputs = tokenizer(text, max_length=256, padding=True, truncation=True, return_tensors = 'pt')
# Generate
generated_tokens = model.generate(
model_inputs["input_ids"].to(model.device),
attention_mask=model_inputs["attention_mask"].to(model.device),
**gen_kwargs,
)
# Extract text
decoded_preds = tokenizer.batch_decode(generated_tokens, skip_special_tokens=False)
# Extract triplets
for idx, sentence in enumerate(decoded_preds):
print(f'Prediction triplets sentence {idx}')
print(extract_triplets(sentence))
📄 许可证
本项目采用 cc-by-nc-sa-4.0
许可证。
📦 模型信息
属性 | 详情 |
---|---|
模型类型 | seq2seq |
训练数据 | Babelscape/rebel-dataset |
任务类型 | 关系抽取 |
评估数据集 | CoNLL04、NYT |
CoNLL04指标 | RE+ Macro F1:76.65 |
NYT指标 | F1:93.4 |
Rebel Large
REBEL是一种基于BART的序列到序列模型,用于端到端关系抽取,支持200多种不同关系类型。
知识图谱
Transformers 英语

R
Babelscape
37.57k
219
Nel Mgenre Multilingual
基于mGENRE的多语言生成式实体检索模型,针对历史文本优化,支持100+种语言,特别适配法语、德语和英语的历史文档实体链接。
知识图谱
Transformers 支持多种语言

N
impresso-project
17.13k
2
Biomednlp KRISSBERT PubMed UMLS EL
MIT
KRISSBERT是一个基于知识增强自监督学习的生物医学实体链接模型,通过利用无标注文本和领域知识训练上下文编码器,有效解决实体名称多样性变异和歧义性问题。
知识图谱
Transformers 英语

B
microsoft
4,643
29
Coder Eng
Apache-2.0
CODER是一种知识增强型跨语言医学术语嵌入模型,专注于医学术语规范化任务。
知识图谱
Transformers 英语

C
GanjinZero
4,298
4
Umlsbert ENG
Apache-2.0
CODER是一个基于知识注入的跨语言医学术语嵌入模型,专注于医学术语标准化任务。
知识图谱
Transformers 英语

U
GanjinZero
3,400
13
Text2cypher Gemma 2 9b It Finetuned 2024v1
Apache-2.0
该模型是基于google/gemma-2-9b-it微调的Text2Cypher模型,能够将自然语言问题转换为Neo4j图数据库的Cypher查询语句。
知识图谱
Safetensors 英语
T
neo4j
2,093
22
Triplex
Triplex是SciPhi.AI基于Phi3-3.8B微调的模型,专为从非结构化数据构建知识图谱设计,可将知识图谱创建成本降低98%。
知识图谱
T
SciPhi
1,808
278
Genre Linking Blink
GENRE是一种基于序列到序列方法的实体检索系统,采用微调后的BART架构,通过受约束的束搜索技术生成唯一实体名称。
知识图谱 英语
G
facebook
671
10
Text To Cypher Gemma 3 4B Instruct 2025.04.0
Gemma 3.4B IT 是一个基于文本到文本生成的大语言模型,专门用于将自然语言转换为Cypher查询语言。
知识图谱
Safetensors
T
neo4j
596
2
Mrebel Large
REDFM是REBEL的多语言版本,用于多语言关系抽取任务,支持18种语言的关系三元组提取。
知识图谱
Transformers 支持多种语言

M
Babelscape
573
71
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98