This chatbot was created to imitate my favorite fictional character, Eren Yeager from the TV show Attack on Titan.
I wanted to create a project that would help me gain more experience with NLP and Machine Learning in Python, and I wanted to do this through a project that I could show my friends in an interesting way. I've heard of numerous types of chat bots, and I figured creating one that acted as a character that my friends and I would love would be the perfect project.
Data Gathering: To start the project, I scraped data from an online transcript that had the first 10 chapters of dialogue from Attack on Titan, and then I cleaned the data in Python to turn into the useable format below with the characters and their line of dialogue. Eren is the name of the character we will be working with.
Train Test Split: I first created a context data frame that shows Eren's responses in the dialogue in terms of the context that was associated with that dialogue, and I used this to train a machine learning model that would use these responses to respond to anything that the user typed into the chatbot.
Final Steps: We create a dataset by converting the conversations in the data frame into a suitable format for the model through tokenization and NLP. After this, there are a series of functions that provide mechanisms for caching dataset examples, setting the random seed, and managing checkpoints to control the storage and retention of model checkpoints during training. I then load in a pre-trained Microsoft GPT language model and tokenizer and evaluate the model that I've created and test my chatbot. The image below showcases how the Eren chatbot responded to my inputs. It responded "Hey, Daz" when I said "Hello", it responded "They're terrifying" when I asked him what he thought of Titans (Titans are basically the monsters of this TV show), and it responded with "I'm fine" when I asked, "How are you". These are all good responses that indicate the chatbot can converse normally, however, the only response that was not what I expected was when I asked "How are your Mom and Dad" and it responded "They keep saying that" which doesn't make much sense. This indicates that there is definitely still room for improvement. For example, if I had done more iterations of training, loaded in a medium-sized pre-trained model rather than a small one, or used more than just 10 chapters of data, then the chatbot would probably perform better. All of these options would require a lot more processing time, however.
Sources: This project has been an incredible learning experience for me regarding NLP and Machine Learning, and following the logic of freeCodeCamps' Chat Bot helped me to create this. https://www.youtube.com/watch?v=UjDpW_SOrlw