Using BERT for Text Classification

Let's use BERT to train a text classifier.

In this lesson, we'll train a binary text classifier with BERT and tf.keras. We'll reuse some of the code we have used previously, but this time the code will be much shorter because we'll replace the embedding and LSTM layers with BERT. The complete code is available at the Jupyter notebook at the end. We'll skip the data preparation. We used the SMS Spam Collection dataset from Kaggle.

Let's get started by importing the BERT models and tokenizer:

Get hands-on with 1200+ tech skills courses.