HuggingFace镜像/prophetnet-large-uncased
模型介绍文件和版本分析
下载使用量0

prophetnet-large-uncased

ProphetNet的预训练权重。
ProphetNet是一种新的预训练语言模型,用于序列到序列学习,其具有名为未来n元预测的新型自监督目标。
ProphetNet能够通过n流解码器预测更多的未来标记。原始实现为Fairseq版本,详见github repo。

用法

此预训练模型可在序列到序列任务上进行微调。例如,可按如下方式将该模型训练用于标题生成:

from transformers import ProphetNetForConditionalGeneration, ProphetNetTokenizer

model = ProphetNetForConditionalGeneration.from_pretrained("microsoft/prophetnet-large-uncased")
tokenizer = ProphetNetTokenizer.from_pretrained("microsoft/prophetnet-large-uncased")

input_str = "the us state department said wednesday it had received no formal word from bolivia that it was expelling the us ambassador there but said the charges made against him are `` baseless ."
target_str = "us rejects charges against its ambassador in bolivia"

input_ids = tokenizer(input_str, return_tensors="pt").input_ids
labels = tokenizer(target_str, return_tensors="pt").input_ids

loss = model(input_ids, labels=labels).loss

引用

@article{yan2020prophetnet,
  title={Prophetnet: Predicting future n-gram for sequence-to-sequence pre-training},
  author={Yan, Yu and Qi, Weizhen and Gong, Yeyun and Liu, Dayiheng and Duan, Nan and Chen, Jiusheng and Zhang, Ruofei and Zhou, Ming},
  journal={arXiv preprint arXiv:2001.04063},
  year={2020}
}