ai-forever / ru-gpts

Russian GPT3 models.
Apache License 2.0
2.08k stars 444 forks source link

Can't load a model from path. #29

Closed airogachev closed 3 years ago

airogachev commented 3 years ago

I use a path to a downloaded model instead of using it's name to avoid downloading. Unfortunately, it doesn't work for me.

`/content/generate_transformers.py in predict(modelname, start, length, temperature_) 191 raise KeyError("the model {} you specified is not supported. You are welcome to add it and open a PR :)") 192 --> 193 tokenizer = tokenizer_class.from_pretrained(args.model_name_or_path) 194 model = model_class.from_pretrained(args.model_name_or_path) 195 model.to(args.device)

/usr/local/lib/python3.6/dist-packages/transformers/tokenization_utils.py in from_pretrained(cls, *inputs, *kwargs) 391 392 """ --> 393 return cls._from_pretrained(inputs, **kwargs) 394 395 @classmethod

/usr/local/lib/python3.6/dist-packages/transformers/tokenization_utils.py in _from_pretrained(cls, pretrained_model_name_or_path, *init_inputs, *kwargs) 542 # Instantiate tokenizer. 543 try: --> 544 tokenizer = cls(init_inputs, **init_kwargs) 545 except OSError: 546 raise OSError(

/usr/local/lib/python3.6/dist-packages/transformers/tokenization_gpt2.py in init(self, vocab_file, merges_file, errors, unk_token, bos_token, eos_token, kwargs) 147 kwargs 148 ): --> 149 super().init(bos_token=bos_token, eos_token=eos_token, unk_token=unk_token, **kwargs) 150 self.max_len_single_sentence = ( 151 self.max_len

/usr/local/lib/python3.6/dist-packages/transformers/tokenization_utils.py in init(self, max_len, **kwargs) 335 assert isinstance(value, (list, tuple)) and all(isinstance(t, str) for t in value) 336 else: --> 337 assert isinstance(value, str) 338 setattr(self, key, value) 339 `

The path looks like /content/gdrive/MyDrive/rugpt3small_based_on_gpt2/gpt3_small_ppl_21_8/

It also doesn't run if I use a path to the .tar So, any solutions for using downloaded models? Thanks.

king-menin commented 3 years ago

version of transformers is 2.8.0? Can you give us code of starting script? Do you use something like this

king-menin commented 3 years ago

I had just tested example on colab. I download files from hf, move to model directory and run generation. Check this here

airogachev commented 3 years ago

Well, it works, even if I store all the files from s3 on gdrive. So, looks like an issue with the files from the link provided in the repo? Can you test the model from the link locally? Thanks