Digital Developer Conference: Cloud Security 2021 – Build the skills to secure your cloud and data Register free

Generate restaurant reviews using deep learning


How do you counter fraudulent issues such as product reviews? By using the same generative models that are creating them. This code pattern explains how to train a deep learning language model in a notebook using Keras and TensorFlow. Using downloaded data from Yelp, you’ll learn how to install TensorFlow and Keras, train a deep learning language model, and generate new restaurant reviews. While the scope of this code pattern is limited to an introduction to text generation, it provides a strong foundation for learning how to build a language model.


Fraudulent reviews are issues that companies must deal with on a daily basis. Using deep learning models, you can seemingly generate any material and make it look real, even to the detriment of someone or something. So, how do you counter this? With the exact same approach. By using the same models that were used for harmful activities, you can build a new model as an extension of the original model to counter it.

In this developer code pattern, you’ll learn how to train a deep learning language model in a notebook using Keras and TensorFlow. The initial training set is from a data set about Yelp reviews found on Kaggle. After installing the prerequisites and running the notebook, you can see generated restaurant reviews based on the ones in the initial training set. This code pattern was created for data scientists and data lovers who are interested in deep learning and fraud detection and anyone who is new to deep learning, TensorFlow, or Keras.

When you have completed the code pattern, you should understand how to:

  • Install and use Keras and TensorFlow
  • Run a Jupyter Notebook
  • Create a recurrent neural network (RNN) language model



  1. Install the prerequisites, Keras, and TensorFlow, then execute the notebook.
  2. Train the language model using the training data.
  3. New text is generated based on the model and returned to the user.


Find the detailed steps for this pattern in the README. The steps will show you how to:

  1. Download and install TensorFlow and Keras.
  2. Clone the repository.
  3. Train a model.
  4. Analyze the results.