Mrebel Large 32
mREBEL是REBEL的多語言版本,用於多語言關係抽取任務,支持18種語言。
下載量 22
發布時間 : 6/12/2023
模型概述
mREBEL是一個多語言關係抽取模型,將關係抽取重新定義為序列到序列的任務。它是REBEL模型的多語言擴展版本,支持18種語言的關係抽取。
模型特點
多語言支持
支持18種語言的關係抽取任務
序列到序列框架
將關係抽取重新定義為序列到序列的任務
類型化三元組抽取
能夠抽取帶有類型信息的主語-關係-賓語三元組
模型能力
多語言關係抽取
文本三元組識別
實體關係分類
使用案例
知識圖譜構建
多語言知識圖譜填充
從多語言文本中抽取實體關係,用於構建或擴充知識圖譜
能夠自動識別文本中的實體及其關係
信息抽取
跨語言信息抽取
從不同語言的文本中抽取結構化信息
支持18種語言的關係抽取
🚀 REDFM:過濾式多語言關係抽取數據集
REDFM是REBEL的多語言版本。它既可以作為一個獨立的多語言關係抽取系統使用,也可以作為預訓練系統,在多語言關係抽取數據集上進行微調。
mREBEL在ACL 2023論文RED^{FM}: a Filtered and Multilingual Relation Extraction Dataset中被提出。我們展示了一個新的多語言關係抽取數據集,並訓練了一個多語言版本的REBEL,它將關係抽取重新定義為一個序列到序列(seq2seq)任務。論文可在此處找到。如果您使用了代碼或模型,請在您的論文中引用這項工作:
@inproceedings{huguet-cabot-et-al-2023-redfm-dataset,
title = "RED$^{\rm FM}$: a Filtered and Multilingual Relation Extraction Dataset",
author = "Huguet Cabot, Pere-Llu{\'\i}s and Tedeschi, Simone and Ngonga Ngomo, Axel-Cyrille and
Navigli, Roberto",
booktitle = "Proc. of the 61st Annual Meeting of the Association for Computational Linguistics: ACL 2023",
month = jul,
year = "2023",
address = "Toronto, Canada",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/2306.09802",
}
該論文的原始倉庫可在此處找到。
請注意,右側的推理小部件不會輸出特殊標記,而這些標記對於區分主語、賓語和關係類型是必要的。有關mREBEL及其預訓練數據集的演示,請查看Spaces演示。
🚀 快速開始
支持語言
- 阿拉伯語(ar)
- 加泰羅尼亞語(ca)
- 德語(de)
- 希臘語(el)
- 英語(en)
- 西班牙語(es)
- 法語(fr)
- 印地語(hi)
- 意大利語(it)
- 日語(ja)
- 韓語(ko)
- 荷蘭語(nl)
- 波蘭語(pl)
- 葡萄牙語(pt)
- 俄語(ru)
- 瑞典語(sv)
- 越南語(vi)
- 中文(zh)
推理小部件示例
屬性 | 詳情 |
---|---|
示例文本 | I Red Hot Chili Peppers sono stati formati a Los Angeles da Kiedis, Flea, il chitarrista Hillel Slovak e il batterista Jack Irons. |
示例標題 | Italian |
✨ 主要特性
- 多語言支持:支持多種語言的關係抽取任務。
- 可獨立使用或微調:既可以作為獨立系統,也能在多語言關係抽取數據集上微調。
- 序列到序列任務:將關係抽取重新定義為seq2seq任務。
📦 安裝指南
文檔未提供具體安裝步驟,故跳過此章節。
💻 使用示例
基礎用法
from transformers import pipeline
triplet_extractor = pipeline('translation_xx_to_yy', model='Babelscape/mrebel-large-32', tokenizer='Babelscape/mrebel-large-32')
# We need to use the tokenizer manually since we need special tokens.
extracted_text = triplet_extractor.tokenizer.batch_decode([triplet_extractor("The Red Hot Chili Peppers were formed in Los Angeles by Kiedis, Flea, guitarist Hillel Slovak and drummer Jack Irons.", decoder_start_token_id=250058, src_lang="en_XX", tgt_lang="<triplet>", return_tensors=True, return_text=False)[0]["translation_token_ids"]]) # change en_XX for the language of the source.
print(extracted_text[0])
# Function to parse the generated text and extract the triplets
def extract_triplets_typed(text):
triplets = []
relation = ''
text = text.strip()
current = 'x'
subject, relation, object_, object_type, subject_type = '','','','',''
for token in text.replace("<s>", "").replace("<pad>", "").replace("</s>", "").replace("tp_XX", "").replace("__en__", "").split():
if token == "<triplet>" or token == "<relation>":
current = 't'
if relation != '':
triplets.append({'head': subject.strip(), 'head_type': subject_type, 'type': relation.strip(),'tail': object_.strip(), 'tail_type': object_type})
relation = ''
subject = ''
elif token.startswith("<") and token.endswith(">"):
if current == 't' or current == 'o':
current = 's'
if relation != '':
triplets.append({'head': subject.strip(), 'head_type': subject_type, 'type': relation.strip(),'tail': object_.strip(), 'tail_type': object_type})
object_ = ''
subject_type = token[1:-1]
else:
current = 'o'
object_type = token[1:-1]
relation = ''
else:
if current == 't':
subject += ' ' + token
elif current == 's':
object_ += ' ' + token
elif current == 'o':
relation += ' ' + token
if subject != '' and relation != '' and object_ != '' and object_type != '' and subject_type != '':
triplets.append({'head': subject.strip(), 'head_type': subject_type, 'type': relation.strip(),'tail': object_.strip(), 'tail_type': object_type})
return triplets
extracted_triplets = extract_triplets_typed(extracted_text[0])
print(extracted_triplets)
高級用法
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
def extract_triplets_typed(text):
triplets = []
relation = ''
text = text.strip()
current = 'x'
subject, relation, object_, object_type, subject_type = '','','','',''
for token in text.replace("<s>", "").replace("<pad>", "").replace("</s>", "").replace("tp_XX", "").replace("__en__", "").split():
if token == "<triplet>" or token == "<relation>":
current = 't'
if relation != '':
triplets.append({'head': subject.strip(), 'head_type': subject_type, 'type': relation.strip(),'tail': object_.strip(), 'tail_type': object_type})
relation = ''
subject = ''
elif token.startswith("<") and token.endswith(">"):
if current == 't' or current == 'o':
current = 's'
if relation != '':
triplets.append({'head': subject.strip(), 'head_type': subject_type, 'type': relation.strip(),'tail': object_.strip(), 'tail_type': object_type})
object_ = ''
subject_type = token[1:-1]
else:
current = 'o'
object_type = token[1:-1]
relation = ''
else:
if current == 't':
subject += ' ' + token
elif current == 's':
object_ += ' ' + token
elif current == 'o':
relation += ' ' + token
if subject != '' and relation != '' and object_ != '' and object_type != '' and subject_type != '':
triplets.append({'head': subject.strip(), 'head_type': subject_type, 'type': relation.strip(),'tail': object_.strip(), 'tail_type': object_type})
return triplets
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("Babelscape/mrebel-large-32", src_lang="en_XX", tgt_lang="tp_XX")
# Here we set English ("en_XX") as source language. To change the source language swap the first token of the input for your desired language or change to supported language. For catalan ("ca_XX") or greek ("el_EL") (not included in mBART pretraining) you need a workaround:
# tokenizer._src_lang = "ca_XX"
# tokenizer.cur_lang_code_id = tokenizer.convert_tokens_to_ids("ca_XX")
# tokenizer.set_src_lang_special_tokens("ca_XX")
model = AutoModelForSeq2SeqLM.from_pretrained("Babelscape/mrebel-large-32")
gen_kwargs = {
"max_length": 256,
"length_penalty": 0,
"num_beams": 3,
"num_return_sequences": 3,
"forced_bos_token_id": None,
}
# Text to extract triplets from
text = 'The Red Hot Chili Peppers were formed in Los Angeles by Kiedis, Flea, guitarist Hillel Slovak and drummer Jack Irons.'
# 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),
decoder_start_token_id = tokenizer.convert_tokens_to_ids("tp_XX"),
**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_typed(sentence))
📚 詳細文檔
推理注意事項
右側的推理小部件不會輸出區分主語、賓語和關係類型所需的特殊標記。如需查看mREBEL及其預訓練數據集的演示,請訪問Spaces演示。
語言設置
在使用模型時,可以設置不同的源語言。對於加泰羅尼亞語("ca_XX")或希臘語("el_EL")(不包含在mBART預訓練中),需要進行一些額外的設置:
tokenizer._src_lang = "ca_XX"
tokenizer.cur_lang_code_id = tokenizer.convert_tokens_to_ids("ca_XX")
tokenizer.set_src_lang_special_tokens("ca_XX")
🔧 技術細節
文檔未提供具體技術細節,故跳過此章節。
📄 許可證
該模型遵循CC BY - SA 4.0許可證。許可證文本可在此處找到。
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