No module named 'keras.saving.legacy'

#2
by fccoelho - opened

Getting this exception when trying to run the examples from the documentation

OpenAI community org

Hey @fccoelho , could you share which example you're trying to run?

cc @Rocketknight1 @joaogante

Hi @fccoelho , TF engineer here! Can you also share the version of TensorFlow and the version of Transformers you're using? We'll try to reproduce the problem here.

Transformers: 4.25.1
tensorflow: 2.11.0

@lysandre

from transformers import pipeline, set_seed
generator = pipeline('text-generation', model='gpt2-large')
set_seed(42)
generator("Hello, I'm a language model,", max_length=30, num_return_sequences=5)

Hi @fccoelho - we think this might be an incompatibility with TF 2.11 and that version of Transformers. We've added some patches to enable 2.11 support in Transformers but they haven't been released yet. Can you try installing transformers from main with the following code, and seeing if that resolves the issue? pip install --upgrade git+https://github.com/huggingface/transformers.git

Thanks @Rocketknight1 , I tried again, after installing the version from main, but I am still getting the same Exception.

I tried the same example as we are now in 2024 and still the same error.
Transformers version: 4.28.1
Tensorflow version: 2.16.1

@mosjel63 👋

You'll need to use an older TF version or a newer transformers version :)

Sign up or log in to comment