I have to use TF 1.15 in my project, but it seems that Transformer have to be used with >=TF2.0. Is that right? I got this error for a testing:
from sklearn.metrics.pairwise import cosine_similarity
import tensorflow as tf
from transformers import BertTokenizer, TFBertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = TFBertModel.from_pretrained('bert-base-uncased')
input_ids = tf.constant(tokenizer.encode("Hello, my dog is cute"))[None, :]
outputs = model(input_ids)
last_hidden_states = outputs[0]
And the error message is below:
Traceback (most recent call last):
File "/Users/nlu/tests/random_test.py", line 67, in <module>
model = TFBertModel.from_pretrained('bert-base-uncased')
File "/Users/bm/venv/bm/lib/python3.7/site-packages/transformers/utils/dummy_tf_objects.py", line 542, in from_pretrained
requires_backends(cls, ["tf"])
File "/Users/bm/venv/bm/lib/python3.7/site-packages/transformers/file_utils.py", line 822, in requires_backends
raise ImportError("".join([BACKENDS_MAPPING[backend][1].format(name) for backend in backends]))
ImportError:
TFBertModel requires the TensorFlow library but it was not found in your environment. Checkout the instructions on the
installation page: https://www.tensorflow.org/install and follow the ones that match your environment.
Is there a way to get transorformer with TF 1.15?