Learn practical skills, build real-world projects, and advance your career

Assignment 4: Chatbot

alt

Welcome to the last assignment of Course 4. Before you get started, we want to congratulate you on getting here. It is your 16th programming assignment in this Specialization and we are very proud of you! In this assignment, you are going to use the Reformer, also known as the efficient Transformer, to generate a dialogue between two bots. You will feed conversations to your model and it will learn how to understand the context of each one. Not only will it learn how to answer questions but it will also know how to ask questions if it needs more info. For example, after a customer asks for a train ticket, the chatbot can ask what time the said customer wants to leave. You can use this concept to automate call centers, hotel receptions, personal trainers, or any type of customer service. By completing this assignment, you will:

  • Understand how the Reformer works
  • Explore the MultiWoz dataset
  • Process the data to feed it into the model
  • Train your model
  • Generate a dialogue by feeding a question to the model

Outline

Part 1: Exploring the MultiWoz dataset

You will start by exploring the MultiWoz dataset. The dataset you are about to use has more than 10,000 human annotated dialogues and spans multiple domains and topics. Some dialogues include multiple domains and others include single domains. In this section, you will load and explore this dataset, as well as develop a function to extract the dialogues.

Let's first import the modules we will be using:

import json
import random
import numpy as np
from termcolor import colored

import trax   
from trax import layers as tl
from trax.supervised import training
!pip list | grep trax
INFO:tensorflow:tokens_length=568 inputs_length=512 targets_length=114 noise_density=0.15 mean_noise_span_length=3.0 trax 1.3.4 WARNING: You are using pip version 20.1.1; however, version 20.2.3 is available. You should consider upgrading via the '/opt/conda/bin/python3 -m pip install --upgrade pip' command.

Let's also declare some constants we will be using in the exercises.