Newbie question on local model loading

#8
by chaltik - opened

I have downloaded the file llama-2-7b-chat.ggmlv3.q4_K_S.bin and placed it in the folder ../models/llama-2-7b-chat.ggmlv3.q4_K_S.
Calling AutoModel.from_pretrained('../models/llama-2-7b-chat.ggmlv3.q4_K_S') gives the error about not finding the file named pytorch_model.bin`.
Upon renaming the .bin file to such name I get this error:

OSError: Unable to load weights from pytorch checkpoint file for '../models/llama-2-7b-chat.ggmlv3.q4_K_S/pytorch_model.bin' at '../models/llama-2-7b-chat.ggmlv3.q4_K_S/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

what is the correct way to load the model from binaries?
thanks very much!

You can load up the model by just referencing the directory on GGML models using c transformers.

from ctransformers import AutoModelForCausalLM

llm = AutoModelForCausalLM.from_pretrained('models/', model_type='gpt2')

print(llm('AI is going to'))

Loading directly from huggingface doesn't seem to work either. The mysterious error keeps suggesting using from_tf=True even when I have already used it there:

from transformers import AutoModelForCausalLM, AutoTokenizer

model_id="TheBloke/Llama-2-7B-Chat-GGML".lower()

model =AutoModelForCausalLM.from_pretrained(model_id, from_tf=True)
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ in <module>:5                                                                                    โ”‚
โ”‚                                                                                                  โ”‚
โ”‚   2                                                                                              โ”‚
โ”‚   3 model_id="TheBloke/Llama-2-7B-Chat-GGML".lower()                                             โ”‚
โ”‚   4                                                                                              โ”‚
โ”‚ โฑ 5 model =AutoModelForCausalLM.from_pretrained(model_id, from_tf=True)                          โ”‚
โ”‚   6                                                                                              โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ /home/ec2-user/SageMaker/envs/py310/lib/python3.10/site-packages/transformers/models/auto/auto_f โ”‚
โ”‚ actory.py:493 in from_pretrained                                                                 โ”‚
โ”‚                                                                                                  โ”‚
โ”‚   490 โ”‚   โ”‚   โ”‚   )                                                                              โ”‚
โ”‚   491 โ”‚   โ”‚   elif type(config) in cls._model_mapping.keys():                                    โ”‚
โ”‚   492 โ”‚   โ”‚   โ”‚   model_class = _get_model_class(config, cls._model_mapping)                     โ”‚
โ”‚ โฑ 493 โ”‚   โ”‚   โ”‚   return model_class.from_pretrained(                                            โ”‚
โ”‚   494 โ”‚   โ”‚   โ”‚   โ”‚   pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs,   โ”‚
โ”‚   495 โ”‚   โ”‚   โ”‚   )                                                                              โ”‚
โ”‚   496 โ”‚   โ”‚   raise ValueError(                                                                  โ”‚
โ”‚                                                                                                  โ”‚
โ”‚ /home/ec2-user/SageMaker/envs/py310/lib/python3.10/site-packages/transformers/modeling_utils.py: โ”‚
โ”‚ 2560 in from_pretrained                                                                          โ”‚
โ”‚                                                                                                  โ”‚
โ”‚   2557 โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   "use_auth_token": token,                                      โ”‚
โ”‚   2558 โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   }                                                                 โ”‚
โ”‚   2559 โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   if has_file(pretrained_model_name_or_path, TF2_WEIGHTS_NAME, **h  โ”‚
โ”‚ โฑ 2560 โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   raise EnvironmentError(                                       โ”‚
โ”‚   2561 โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   f"{pretrained_model_name_or_path} does not appear to hav  โ”‚
โ”‚   2562 โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   f" {_add_variant(WEIGHTS_NAME, variant)} but there is a   โ”‚
โ”‚   2563 โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   " Use `from_tf=True` to load this model from those weigh  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
OSError: thebloke/llama-2-7b-chat-ggml does not appear to have a file named pytorch_model.bin but there is a file 
for TensorFlow weights. Use `from_tf=True` to load this model from those weights.
chaltik changed discussion status to closed

Sign up or log in to comment