yizhongw / Tk-Instruct

Tk-Instruct is a Transformer model that is tuned to solve many NLP tasks by following instructions.
https://arxiv.org/abs/2204.07705
MIT License
177 stars 27 forks source link

Cannot load `tk-instruct-11b-def` with Huggingface transformers #11

Closed timoschick closed 2 years ago

timoschick commented 2 years ago

Hi there, it seems like the 11B-def model cannot be loaded with Huggingface's transformers library, because the pytorch_model.bin file is missing.

I've used the following code (which works fine if we replace 11b with 3b):

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
model = AutoModelForSeq2SeqLM.from_pretrained("allenai/tk-instruct-11b-def")

which results in this error:

Traceback (most recent call last):
  File "/transformers/src/transformers/modeling_utils.py", line 1359, in from_pretrained
    resolved_archive_file = cached_path(
  File "/transformers/src/transformers/file_utils.py", line 1938, in cached_path
    output_path = get_from_cache(
  File "/transformers/src/transformers/file_utils.py", line 2142, in get_from_cache
    _raise_for_status(r)
  File "/transformers/src/transformers/file_utils.py", line 2065, in _raise_for_status
    raise EntryNotFoundError(f"404 Client Error: Entry Not Found for url: {request.url}")
transformers.file_utils.EntryNotFoundError: 404 Client Error: Entry Not Found for url: https://huggingface.co/allenai/tk-instruct-11b-def/resolve/main/pytorch_model.bin

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/transformers/src/transformers/models/auto/auto_factory.py", line 447, in from_pretrained
    return model_class.from_pretrained(pretrained_model_name_or_path, *model_args, config=config, **kwargs)
  File "/transformers/src/transformers/modeling_utils.py", line 1404, in from_pretrained
    raise EnvironmentError(
OSError: allenai/tk-instruct-11b-def does not appear to have a file named pytorch_model.bin, tf_model.h5, model.ckpt or flax_model.msgpack.
yizhongw commented 2 years ago

@timoschick which version of Huggingface transformers are you using? Their old version doesn't support loading separate files for one model. You can try update the library to transformers==4.18.0.

timoschick commented 2 years ago

Ahh, then that's probably it. I'm using transformers==4.17.0, will try out the most recent version and let you know if it works!

timoschick commented 2 years ago

Everything works with the most recent version, thanks again!