赞
踩
目录
- from transformers import BartTokenizer, BartForConditionalGeneration
- model = BartForConditionalGeneration.from_pretrained('facebook/bart-base')
- tokenizer = BartTokenizer.from_pretrained("facebook/bart-base")
- input = "UN Chief Says There Is <mask> in Syria"
- batch = tokenizer(input, return_tensors = 'pt')
- output_ids = model.generate(input_ids=batch['input_ids'], attention_mask = batch['attention_mask'])
- output = tokenizer.batch_decode(output_ids, skip_special_tokens = True)
- print(output)
-
- # 输出:['UN Chief Says There Is No War in Syria']
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。