I am trying to follow this article to use the AutoModelForCasualLM
from transformers
to generate text with bloom. But I keep getting an error saying that python cannot AutoModelForCasualLM from transformers. I have tried multiple computers and multiple versions of transformers but I always get the following error. (Traceback from latest version of transformers)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[28], line 1
----> 1 from transformers import AutoTokenizer, AutoModelForCasualLM, BloomConfig
2 from transformers.models.lboom.modeling_bloom import BloomBlock, build_alibi_tensor
ImportError: cannot import name 'AutoModelForCasualLM' from 'transformers' (/mnt/MLDr/venv/lib/python3.10/site-packages/transformers/__init__.py)
code snippet from where the error occurs (first ~10 lines):
import os
import torch
import torch.nn as nn
from collections import OrderedDict
def get_state_dict(shard_num, prefix=None):
d = torch.load(os.path.join(model_path, f"pytorch_model_{shard_num:05d}-of-00072.bin"))
return d if prefix is None else OrderedDict((k.replace(prefix, ''), v) for k, v in d.items())
from transformers import AutoTokenizer, AutoModelForCasualLM, BloomConfig
from transformers.models.lboom.modeling_bloom import BloomBlock, build_alibi_tensor
model = "./bloom"
config = BloomConfig.from_pretrained(model_path)
device = 'cpu'
transformers-cli env results:
transformers
version: 4.25.1- Platform: Linux-5.15.0-58-generic-x86_64-with-glibc2.35
- Python version: 3.10.6
- Huggingface_hub version: 0.11.1
- PyTorch version (GPU?): 1.13.1+cu117 (False)
- Tensorflow version (GPU?): 2.11.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
I had the same issue, it wasn't related to spelling, what fixed my problem was installing this version of transformers and NOT using the git version: