赞
踩
默认使用的模型是gpt2,会下载到本地的~/.cache/huggingface/目录下,
第一次运行会自动下载,第二次运行直接从本地加载,
可以尝试断网之后运行,也一样的会出结果.
先安装以下:
from transformers import pipeline
from huggingface_hub.hf_api import HfFolder
HfFolder.save_token('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')
pipe = pipeline("text-generation",
num_return_sequences=2)
print(pipe("In this course, we will teach you how to"))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。