A Seq2seq chatbot written in python using tensorflow and keras.
As the creator of a chat website and as an avid Westworld fan, I figured I'd take a try at creating my own chatbot.
The goal of this project was to train a chatbot using my text messages, so that the chatbot would resemble the way I speak. Along the way, I discovered that my text messages were not an amazing dataset, so I pulled in the Cornell Movie Dialogs which seems to be very popular for chatbots.
To setup the project, navigate to the root directory and use pip:
$ pip3 install -e .
You can use the train
command to train the chatbot model. This command will assemble everything your computer needs to begin training.
The train
command will do the following:
- Download the Cornell Movie Dialogs dataset.
- Download the GloVe Embeddings for vector representations of words.
- Tokenize the dataset
- Train the model
The initial downloads can take some time to complete, but, you'll only need to download them the first time you run the command.
$ bot train --epochs 100
--epochs <int>
(Default: 10)--learning-rate <int>
(Default: 0.00005)--batch-size <int>
(Default: 128)--build-dir <path>
(Default: "./build")--k-folds
(Default: 10)--starting-build
(Default: None)--upload
(Default: False)--continue
(Default: False)
Once you have trained the chatbot model, you can use the chat
command to test the chatbot. This command starts a basic interaction loop. You can type in a response and see how the chatbot will respond.
$ bot chat
--build-dir <path>
(Default: "./build")
In order to help with organizing models trained with different types of data, I created a build management system for this project. All the builds are stored in an S3 bucket, and can be managed using the command line. Here are the highlights:
bot builds list
— list all models stored in the bucketbot builds put
— upload the model that was just trainedbot builds get
— download a previously trained modelbot builds delete
— delete a model
You can also automatically upload a build after training by including the --upload
flag. This can be useful when submitting a headless job on a more powerful computer such as GCP's AI Platform.
$ bot train --upload
For now the S3 bucket is hardcoded into builds.py
you'll have to configure it there. You'll also need to include your AWS credentials in either builds.py
or your local ~/.aws/configure