🚀 BART释义模型(大模型)
这是一个基于BART的大型序列到序列(文本生成)模型,在3个释义数据集上进行了微调。该模型可有效用于文本释义生成。
🚀 快速开始
你可以使用预训练模型对输入句子进行释义。以下是使用示例:
import torch
from transformers import BartForConditionalGeneration, BartTokenizer
input_sentence = "They were there to enjoy us and they were there to pray for us."
model = BartForConditionalGeneration.from_pretrained('eugenesiow/bart-paraphrase')
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = model.to(device)
tokenizer = BartTokenizer.from_pretrained('eugenesiow/bart-paraphrase')
batch = tokenizer(input_sentence, return_tensors='pt')
generated_ids = model.generate(batch['input_ids'])
generated_sentence = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
print(generated_sentence)
输出
['They were there to enjoy us and to pray for us.']
✨ 主要特性
- 模型架构:Bart采用标准的序列到序列/机器翻译架构,包含一个双向编码器(如BERT)和一个从左到右的解码器(如GPT)。
- 预训练任务:预训练任务包括随机打乱原句子的顺序和一种新颖的填充方案,其中文本片段被单个掩码标记替换。
- 微调效果:BART在针对文本生成进行微调时特别有效。此模型在3个释义数据集(Quora、PAWS和MSR释义语料库)上进行了微调。
📚 详细文档
模型描述
BART模型由Lewis等人(2019年)在论文BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension中提出。
原始的BART代码来自这个仓库。
预期用途和限制
该模型可用于对输入句子进行释义。
训练数据
该模型在预训练的facebook/bart-large
基础上进行微调,使用了Quora、PAWS和MSR释义语料库。
训练过程
我们遵循simpletransformers序列到序列示例中提供的训练过程。
引用信息
@misc{lewis2019bart,
title={BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension},
author={Mike Lewis and Yinhan Liu and Naman Goyal and Marjan Ghazvininejad and Abdelrahman Mohamed and Omer Levy and Ves Stoyanov and Luke Zettlemoyer},
year={2019},
eprint={1910.13461},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
📄 许可证
本项目采用Apache-2.0许可证。
📦 信息表格
属性 |
详情 |
模型类型 |
基于BART的序列到序列(文本生成)模型 |
训练数据 |
Quora、PAWS和MSR释义语料库 |