A generative chatbot is an open-domain chatbot program that generates original combinations of language rather than selecting from pre-defined responses. seq2seq models used for machine translation can be used to build generative chatbots.
Choosing the right dataset is a common issue when creating generative chatbots. Common concerns include:
For generative chatbots using a Keras-based seq2seq model, it is necessary to convert user input into NumPy matrices of one-hot vectors.
# the following function converts# user input into a NumPy matrix:def string_to_matrix(user_input):tokens = re.findall(r"[\w']+|[^\s\w]", user_input)user_input_matrix = np.zeros((1, max_encoder_seq_length, num_encoder_tokens),dtype='float32')for timestep, token in enumerate(tokens):if token in input_features_dict:user_input_matrix[0, timestep, input_features_dict[token]] = 1.return user_input_matrix
There are several solutions to handling unknown words for generative chatbots including ignoring unknown words, requesting that the user rephrase, or using <UNK>
tokens.
Generative chatbot research is currently working to resolve how best to handle chat context and information from previous turns of dialog. Some proposed solutions to this include: