Views
No views yet
1from transformers import ProphetNetForConditionalGeneration, ProphetNetTokenizer
2
3model = ProphetNetForConditionalGeneration.from_pretrained("microsoft/prophetnet-large-uncased")
4tokenizer = ProphetNetTokenizer.from_pretrained("microsoft/prophetnet-large-uncased")
5
6input_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 ."
7target_str = "us rejects charges against its ambassador in bolivia"
8
9input_ids = tokenizer(input_str, return_tensors="pt").input_ids
10labels = tokenizer(target_str, return_tensors="pt").input_ids
11
12loss = model(input_ids, labels=labels).loss1@article{yan2020prophetnet,
2 title={Prophetnet: Predicting future n-gram for sequence-to-sequence pre-training},
3 author={Yan, Yu and Qi, Weizhen and Gong, Yeyun and Liu, Dayiheng and Duan, Nan and Chen, Jiusheng and Zhang, Ruofei and Zhou, Ming},
4 journal={arXiv preprint arXiv:2001.04063},
5 year={2020}
6}