1

We have finetuned our BERT model for text2text generation. It is working fine on the Jupyter notebook. But when I use the same trained model on another server of Ubuntu, then it shows the issue. This is my first post, so please bear with me. The issue I'm facing is that when I generate output on small sentences, it works fine. But on long sentences, it shows the following error:

At most 4 tokens in tensor([ 2, 2, 2, 2, 44763, 44763, 2, 44763]) can be equal to eos_token_id: 2. Make sure tensor([ 2, 2, 2, 2, 44763, 44763, 2, 44763]) are corrected.

My output generation code is:

from simpletransformers.seq2seq import Seq2SeqModel
#logging.basicConfig(level=logging.INFO)
#transformers_logger = logging.getLogger("transformers")
#transformers_logger.setLevel(logging.ERROR)
model = Seq2SeqModel(
    encoder_decoder_type="bart", encoder_decoder_name="PATHOFMODEL",use_cuda=False,
)
while True:
    original = input("Enter text to paraphrase: ")
    to_predict = [original]

    preds = model.predict(to_predict)

    print("---------------------------------------------------------")
    print(original)

    print()
    print("Predictions >>>")
    for pred in preds[0]:
        print(pred)

    print("---------------------------------------------------------")
    print()
  • Are your versions of simpletransformers matching? Can you please paste code on how you are saving the model in the Jupyter environment? – dennlinger Apr 21 '21 at 12:08
  • I'm installing these dependencies through pip. Is it different from installing through conda. – Scorp Amelia Apr 21 '21 at 12:21
  • can you please verify the versions by running `import simpletransformers` and then `print(simpletransformers.__version__)`? There is not guarantee that conda has the same version available as pip. – dennlinger Apr 21 '21 at 12:34
  • Great, thanks for your help. Will let you know when I try it. – Scorp Amelia Apr 21 '21 at 12:44
  • I have checked the versions of simple transformers. It's upgraded and versions are matching of simpletransformers of jupyter notebook and pip. Any other solution? – Scorp Amelia Apr 22 '21 at 07:14
  • As stated before, please include debugging details on how you are saving your models in Jupyter. Without that information it is impossible to solve the problem *for* you. – dennlinger Apr 22 '21 at 08:58

1 Answers1

1

You can check your TensorFlow version in your jupyter notebook and verify it on your Ubuntu server. If it's the same, there should be no error. Firstly uninstall the tensorflow.

pip3 uninstall tensorflow

and then install any old version. Like in the case of version 2.2.0, then install 2.2.0 version using below command.

pip3 install tensorflow==2.2.0

It should work now.

Huzaifa Zahoor
  • 325
  • 2
  • 13