作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试在 Mac M1 和 Google Colab 中运行 Hugging Face 中的 flan-t5-xxx 模型,但都出现相同的错误:
ValueError:需要包含卸载权重的 state_dict 或 save_folder。
模型卡中的代码:
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xxl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xxl", device_map="auto")
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
最佳答案
对于需要的人:
创建一个文件夹(例如名称 save_folder)。然后更新:
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xxl", device_map="auto")
至
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xxl", device_map="auto", offload_folder="save_folder")
关于huggingface-transformers - 果馅饼-t5-xxl : ValueError: Need either a `state_dict` or a `save_folder` containing offloaded weights,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76617863/
我是一名优秀的程序员,十分优秀!