python-3.x 在transformers中加载safetensor文件

9jyewag0  于 2023-05-30  发布在  Python
关注(0)|答案(1)|浏览(917)

我从huggingface下载了这个model。我正在尝试在transformers中加载此模型,以便进行推理:

from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("path_to/TheBloke/vicuna-13B-1.1-GPTQ-4bit-128g")

model = AutoModelForCausalLM.from_pretrained("path_to/TheBloke/vicuna-13B-1.1-GPTQ-4bit-128g")

但我得到的错误说,它需要一个.bin或.h5或.ckpt文件,但上述只有.safetensors或.pt文件
如何加载模型?

4uqofj5v

4uqofj5v1#

你得让它去找安全Tensor

AutoModelForCausalLM.from_pretrained(
    <path>,
    use_safetensors=True,
    <rest_of_args>
)

这假设您在同一文件夹ofc中有safetensors权重Map

model.safetensors.index.json

相关问题