Run this model with HF Jobs

Run google/flan-t5-large on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/google/flan-t5-large. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/google/flan-t5-large on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

name 'init_empty_weights' is not defined

#11
by estebarb - opened

I'm trying to use this model exactly as the instructions said, but I got the following error:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[5], line 4
      1 from transformers import T5Tokenizer, T5ForConditionalGeneration
      3 tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
----> 4 model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto")

File ~/src/test/venv/lib/python3.10/site-packages/transformers/modeling_utils.py:2273, in PreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
   2271     init_contexts = [deepspeed.zero.Init(config_dict_or_path=deepspeed_config())] + init_contexts
   2272 elif load_in_8bit or low_cpu_mem_usage:
-> 2273     init_contexts.append(init_empty_weights())
   2275 with ContextManagers(init_contexts):
   2276     model = cls(config, *model_args, **model_kwargs)

NameError: name 'init_empty_weights' is not defined

My code is:

from transformers import T5Tokenizer, T5ForConditionalGeneration

tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto")

Hi @estebarb
Thanks for the issue! Can you double check you are using the latest versions of transformers and accelerate ?
pip install --upgrade transformers accelerate

Sign up or log in to comment