Closed jinzzasol closed 1 year ago
Hi, thank you for opening the issue.
Could you please share your system info with us. You can run the command transformers-cli env
and copy-paste its output below.
@ydshieh Sorry but I'm using Google Colab and I'm not able to run a command in Colab. It is a Pro feature.
Just type !transformers-cli env
no?
Otherwise share the colab notebook maybe?
Ok, I just found out that I should install transformers
again before running it.
Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.
- `transformers` version: 4.34.0
- Platform: Linux-5.15.120+-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.17.3
- Safetensors version: 0.4.0
- Accelerate version: not installed
- Accelerate config: not found
- PyTorch version (GPU?): 2.0.1+cu118 (False)
- Tensorflow version (GPU?): 2.13.0 (False)
- Flax version (CPU?/GPU?/TPU?): 0.7.4 (cpu)
- Jax version: 0.4.16
- JaxLib version: 0.4.16
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
I0000 00:00:1696604507.367394 1255 tfrt_cpu_pjrt_client.cc:352] TfrtCpuClient destroyed.
Thank you.
@Rocketknight1 could you take a look here?
@ydshieh Just to tell you, I ran the same code on my local machine and I encountered the same issue. Below is the OS info.
Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.
- `transformers` version: 4.33.3
- Platform: Linux-5.15.90.2-microsoft-standard-WSL2-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.17.3
- Safetensors version: 0.3.3
- Accelerate version: not installed
- Accelerate config: not found
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): 2.14.0 (True)
- 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>
Woah, this is a blast from the past! TFTrainer
is very old and completely deprecated now, and we don't support it anymore. We generally advise people to just use the Keras API for TF.
You can keep most of your code the same up to the model.compile()
line, and then on the next line I'd just do something like this:
model.fit(train_tokenized, y_train, validation_data=(val_tokenized, y_val), epochs=3)
For more info on training Hugging Face models with TF, please see our TensorFlow Philosophy post, or any of the Keras documentation, particularly the docs on supported dataset types and model.fit()
- you can find them here.
I forgot it's TFTrainer. Sorry @Rocketknight1 !
No problem, it was a nice nostalgia moment!
@Rocketknight1 @ydshieh Thank you all. I was referring to one post I found and did not know this was deprecated.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
[<ipython-input-32-021f97abfd29>](https://localhost:8080/#) in <cell line: 1>()
----> 1 model.fit(train_tokenized, y_train, validation_data=(val_tokenized, y_val), epochs=3)
3 frames
[/usr/local/lib/python3.10/dist-packages/tensorflow/core/function/polymorphism/function_type.py](https://localhost:8080/#) in __hash__(self)
144
145 def __hash__(self):
--> 146 return hash((self.name, self.kind, self.optional, self.type_constraint))
147
148 def __repr__(self):
ValueError: Cannot generate a hashable key for IteratorSpec(({'input_ids': TensorSpec(shape=(None, 128), dtype=tf.int32, name=None), 'attention_mask': TensorSpec(shape=(None, 128), dtype=tf.int32, name=None)}, TensorSpec(shape=(None,), dtype=tf.int64, name=None)),) because the _serialize() method returned an unsupproted value of type <class 'transformers.tokenization_utils_base.BatchEncoding'>
I ran the model.fit()
and got this error message.
I think this is a different topic but any ideas?
Yeah, that's a regular problem we have! Just do train_tokenized = dict(train_tokenized)
before passing the data to model.fit()
- the output data is a BatchEncoding
that Keras doesn't quite understand.
One day I'll figure out a cleaner solution for it, but I'll probably have to slip a couple of shims into Keras's methods!
Thank you!
System Info
Google Colab
Who can help?
No response
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
I encountered this issue while I was running the model. The dataset is an IMDB movie review on Kaggle.
Below is the code:
Data Cleaning
Preprocessing
Expected behavior
trainer.train() should run.