keras-nlp icon indicating copy to clipboard operation
keras-nlp copied to clipboard

Some keras-nlp (keras 3) colabs stopped working

Open rafaelsf80 opened this issue 1 year ago • 2 comments

If I "Run all" the Pretraining a Transformer from scratch with KerasNLP notebook in Colab, it fails at line: tokenizer = keras_nlp.tokenizers.WordPieceTokenizer with the following error:

ImportError: WordPieceTokenizer requires the `tensorflow-text` package. Please install with `pip install tensorflow-text`.

No modifications are done in the notebook.

Installing the tensorflow-text package does not resolve the issue, since it moves to Keras 2.

I notice the same error in other tutorials, like this one Any suggestions would be apreciated.

Thanks

rafaelsf80 avatar Jan 29 '24 15:01 rafaelsf80

@rafaelsf80 thanks for filing!

For now, pip install tf-keras and this error will go away. The tf-keras package won't even be used, it is purely to work around a temporary issue with the tensorflow-hub package.

The full issue in all it's gory details...

  • We try to keep keras_nlp importable without tf-text, and catch an ImportError to check if we found the library. This is to keep the package runnable on things like macos, where tf-text is not available.
  • Tensorflow text depends on tensorflow hub.
  • Tensorflow hub recently made a release that does not have all the correct dependencies and will fail to import with an ImportError.

There should be a new release of tensorflow hub in a couple days that fixes this issue entirely. If there's any delays will post back here.

mattdangerw avatar Jan 29 '24 23:01 mattdangerw

Thanks for the answer and explanation. That solves the issue.

rafaelsf80 avatar Jan 31 '24 10:01 rafaelsf80

Should have closed the a bit ago. tensorflow hub has re-released, this is fixed.

mattdangerw avatar Mar 29 '24 18:03 mattdangerw