🚀 强大的预训练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许可证。