transformer调用t5模型过程的代码
from transformers import T5Tokenizer, T5ForConditionalGeneration tokenizer = T5Tokenizer.from_pretrained("t5-small") model = T5ForConditionalGeneration.from_pretrained("t5-small") input_ids = tokenizer('translate English to German: The house is wonderful.', return_tensors='pt').input_ids outputs = model.generate(input_ids) print(tokenizer.decode(outputs[0], skip_special_tokens=True))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)