Sentiment pipeline and evaluator are importing roberta_hate_speach as tensorflow model but the notebook is working with pytorch/transformers

Greetings!,

The “facebook/roberta-hate-speech-dynabench-r4-target” is a Pytorch model. (isn’t it?) but when trying to use it in the pipeline and in the evaluator, both give me the following error in Google colab:

RuntimeError: Failed to import transformers.models.roberta.modeling_tf_roberta because of the following error (look up to see its traceback): No module named 'keras.engine'

I get to make the sentiment_pipe work with pytorch specifying the framework like this:

sentiment_pipe = pipeline("sentiment-analysis", 
                          model=toxicity_model_name, #toxicity_model,tokenizer=toxicity_tokenizer,
                          framework="pt",
                          device=device)

But later I get the same error from the evaluator, it appears that it haven’t that parameter and even adding it gives the same error. Any ideas?

toxicity_evaluator = evaluate.load("toxicity", 
                                    toxicity_model_name,
                                    module_type="measurement",
                                    #framework="pt",
                                    toxic_label="hate")
RuntimeError: Failed to import transformers.models.roberta.modeling_tf_roberta because of the following error (look up to see its traceback):
No module named 'keras.engine'

Thanks for your help

I could get it working by changing tensorflow version to 2.10.

In the terminal:

pip uninstall tensorflow
pip install tensorflow==2.10

1 Like