+
80
-

huggingface transformers pipeline如何加载本地下载好的模型?

huggingface transformers pipeline如何加载本地下载好的模型?


网友回复

+
0
-
from transformers import pipeline

# 加载本地下载好的模型
model_path = "/path/to/local/model"
nlp = pipeline("text-generation", model=model_path)

# 使用模型生成文本
text = nlp("Hello, how are you?")
print(text)

我知道答案,我要回答