🚀 強大的預訓練RoBERTa-Large自然語言推理(NLI)模型
這是一個強大的預訓練RoBERTa-Large自然語言推理(NLI)模型,它使用了多個知名的NLI數據集進行訓練,能夠有效處理自然語言推理任務,為自然語言理解提供有力支持。
🚀 快速開始
本模型使用多個知名的NLI數據集進行訓練,以下是這些數據集的列表:
snli
anli
multi_nli
multi_nli_mismatch
fever
你可以通過以下代碼示例來嘗試使用這個模型:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
if __name__ == '__main__':
max_length = 256
premise = "Two women are embracing while holding to go packages."
hypothesis = "The men are fighting outside a deli."
hg_model_hub_name = "ynie/roberta-large-snli_mnli_fever_anli_R1_R2_R3-nli"
tokenizer = AutoTokenizer.from_pretrained(hg_model_hub_name)
model = AutoModelForSequenceClassification.from_pretrained(hg_model_hub_name)
tokenized_input_seq_pair = tokenizer.encode_plus(premise, hypothesis,
max_length=max_length,
return_token_type_ids=True, truncation=True)
input_ids = torch.Tensor(tokenized_input_seq_pair['input_ids']).long().unsqueeze(0)
token_type_ids = torch.Tensor(tokenized_input_seq_pair['token_type_ids']).long().unsqueeze(0)
attention_mask = torch.Tensor(tokenized_input_seq_pair['attention_mask']).long().unsqueeze(0)
outputs = model(input_ids,
attention_mask=attention_mask,
token_type_ids=token_type_ids,
labels=None)
predicted_probability = torch.softmax(outputs[0], dim=1)[0].tolist()
print("Premise:", premise)
print("Hypothesis:", hypothesis)
print("Entailment:", predicted_probability[0])
print("Neutral:", predicted_probability[1])
print("Contradiction:", predicted_probability[2])
更多內容請參考 這裡。
✨ 主要特性
- 多數據集訓練:訓練數據結合了多個知名的NLI數據集,包括
SNLI
、MNLI
、FEVER-NLI
、ANLI (R1, R2, R3)
,使得模型具有更廣泛的適用性和更強的泛化能力。
- 多模型可選:除了RoBERTa-Large模型,還提供了其他預訓練的NLI模型,如
RoBERTa
、ALBert
、BART
、ELECTRA
、XLNet
,滿足不同場景的需求。
📦 安裝
文檔中未提及具體安裝步驟,可參考transformers
庫的安裝方式來使用本模型。
📚 詳細文檔
數據集信息
屬性 |
詳情 |
模型類型 |
預訓練的RoBERTa-Large自然語言推理(NLI)模型 |
訓練數據 |
結合了多個知名的NLI數據集,包括SNLI 、MNLI 、FEVER-NLI 、ANLI (R1, R2, R3) |
引用信息
如果你使用了本模型,請引用以下論文:
@inproceedings{nie-etal-2020-adversarial,
title = "Adversarial {NLI}: A New Benchmark for Natural Language Understanding",
author = "Nie, Yixin and
Williams, Adina and
Dinan, Emily and
Bansal, Mohit and
Weston, Jason and
Kiela, Douwe",
booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
year = "2020",
publisher = "Association for Computational Linguistics",
}
📄 許可證
本項目採用MIT許可證。