Text Generation
Transformers
PyTorch
TensorBoard
Safetensors
bloom
Eval Results
text-generation-inference
Inference Endpoints

AttributeError: 'dict' object has no attribute 'full_determinism' when trying to train the model

#266
by anuruddhak - opened

I am trying to simply use the smallest bloom model to learn how to train or specialize the model to generate a new language.

I run into this error: AttributeError: 'dict' object has no attribute 'full_determinism'.

I executed pip install transformers so I am hoping it has the latest transformer library. Any help is much appreciated!

Full error message:

AttributeError Traceback (most recent call last)
Cell In[25], line 9
5 t = time.process_time()
6 #model = AutoModelForCausalLM.from_pretrained("bigscience/bloom-1b1", use_cache=True)
7 #tokenizer = AutoTokenizer.from_pretrained("bigscience/bloom-1b1")
----> 9 trainer = Trainer(
10 model=AutoModelForCausalLM.from_pretrained("bigscience/bloom-1b1"),
11 args=training_args,
12 train_dataset=dataset["train"]
13 )
14 t2 = time.process_time()
15 print("Chekpoint 1 elapsed time "+t2-t1)

File /opt/homebrew/lib/python3.11/site-packages/transformers/trainer.py:337, in Trainer.init(self, model, args, data_collator, train_dataset, eval_dataset, tokenizer, model_init, compute_metrics, callbacks, optimizers, preprocess_logits_for_metrics)
335 self.args = args
336 # Seed must be set before instantiating the model when using model
--> 337 enable_full_determinism(self.args.seed) if self.args.full_determinism else set_seed(self.args.seed)
338 self.hp_name = None
339 self.deepspeed = None

AttributeError: 'dict' object has no attribute 'full_determinism'

Here is my code-------------------------------------:

#Load the smallest Bloom tokenizer:

from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("bigscience/bloom-1b1")
print("Done loading")

#Load the treaining dataset
dataset = load_dataset("text", data_files={"train": "FirstTrainingSet_clean_v1.txt"})
print(dataset)

#Define the training arguments:

training_args = {
"output_dir": "trained_model",
"num_train_epochs": 10,
"per_device_train_batch_size": 4,
"learning_rate": 1e-5,
"full_determinism":"False",
}

#Train the model:
from transformers import Trainer, AutoModelForCausalLM
import time

t = time.process_time()
#model = AutoModelForCausalLM.from_pretrained("bigscience/bloom-1b1", use_cache=True)
#tokenizer = AutoTokenizer.from_pretrained("bigscience/bloom-1b1")

trainer = Trainer(
model=AutoModelForCausalLM.from_pretrained("bigscience/bloom-1b1"),
args=training_args,
train_dataset=dataset["train"]
)
t2 = time.process_time()
print("Chekpoint 1 elapsed time "+t2-t)

trainer.train()

t3 = time.process_time()
print("Chekpoint 2 elapsed time [trainer.train()] "+t3-t2)

#save the trained model
trainer.save_model()
t4 = time.process_time()
print("Chekpoint 2 elapsed time [trainer.save_model()] "+t4-t3)

Hello, it seems to me like your args are a dict rather than a TrainingArguments instance. Please update as follows:

- training_args = {
- "output_dir": "trained_model",
- "num_train_epochs": 10,
- "per_device_train_batch_size": 4,
- "learning_rate": 1e-5,
- "full_determinism":"False",
}
+ training_args = TrainingArguments(
+     output_dir="trained_model",
+     num_train_epochs=10,
+     per_device_train_batch_size=4,
+     learning_rate=1e-5,
+     full_determinism=False,
+ )

Thanks for this advice, I was able to move beyond this step. For the benefit of others who might search this, I encountered another error related to my hardware Apple Silicon M2 mac. I used the following to get around those.

conda install -c apple tensorflow-deps
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal

I also ran into an issue with pip time out so I had to use the following:
pip --default-timeout=5000 install tensorflow

I found these medium posts to be helpful:
https://medium.com/@faizififita1/huggingface-installation-on-apple-silicon-2022-m1-pro-max-ultra-m2-9c449b9b4c14
https://claytonpilat.medium.com/tutorial-tensorflow-on-an-m1-mac-using-jupyter-notebooks-and-miniforge-dbb0ef67bf90

Using TrainingArguments I'm getting this error

ImportError Traceback (most recent call last)
in <cell line: 5>()
3 model_name = model_checkpoint.split("/")[-1]
4
----> 5 training_args = TrainingArguments(
6 output_dir=f"{model_name}-finetuned-squad",
7 evaluation_strategy="epoch",

4 frames
/usr/local/lib/python3.10/dist-packages/transformers/training_args.py in _setup_devices(self)
1785 if not is_sagemaker_mp_enabled():
1786 if not is_accelerate_available(min_version="0.20.1"):
-> 1787 raise ImportError(
1788 "Using the Trainer with PyTorch requires accelerate>=0.20.1: Please run pip install transformers[torch] or pip install accelerate -U"
1789 )

ImportError: Using the Trainer with PyTorch requires accelerate>=0.20.1: Please run pip install transformers[torch] or pip install accelerate -U

Sign up or log in to comment