I'm trying to do some basic text inference using the bloom model
from transformers import AutoModelForCausalLM, AutoModel
# checkpoint = "bigscience/bloomz-7b1-mt"
checkpoint = "bigscience/bloom-1b7"
tokenizer = AutoModelForCausalLM.from_pretrained(checkpoint)
model = AutoModel.from_pretrained(checkpoint, torch_dtype="auto", device_map="auto")
# Set the prompt and maximum length
prompt = "This is the prompt text"
max_length = 100000
# Tokenize the prompt
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt").to("cuda")
# Generate the text
outputs = model.generate(inputs)
result = tokenizer.result(outputs[0])
# Print the generated text
print(result)
I get the error
Traceback (most recent call last):
File "/tmp/pycharm_project_444/bloom.py", line 15, in <module>
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt").to("cuda")
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1265, in __getattr__
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'BloomForCausalLM' object has no attribute 'encode'
Anyone know what the issue is?
It's running on a remote server