You can create your own chatbot with GPT3
ChatGPT has caused a huge storm on the internet. People have already figured out many use cases for ChatGPT. However, what many people don’t know yet is that it’s possible to create your ‘own’ version of such a chatbot. Dollar Shave Club, for instance, are using their own personalized chatbot which is able to answer many shaving-related questions (hyperlink for more information). The idea is very simple, the chatbot has learned from the content found on Dollar Shave Club’s website.
The technique which OpenAI (the creators of ChatGPT and GPT3) use for personalization is a form of transfer learning. For transfer learning, an already trained model is used to finetune on a different, but similar task. Since the model has already been trained previously, the already ‘learned’ knowledge can be repurposed for a new task and speeds up learning by several magnitudes. An example of this is detecting puppies in images. Training a model from scratch will take a lot of time. However, you can speed up the training process considerably if you repurpose a model that was initially trained to detect bunnies, since it already knows a thing or two about detecting cute, furry animals.
GPT3 is the predecessor of ChatGPT and is an almost equally impressive dialogue partner. The model behind ChatGPT can be repurposed to meet our own goals. We tested it to perform two tasks in the Dutch language:
- Classifying chat messages
- Creating a ‘personalized’ chatbot
Classifying chat messages
A colleague of ours has been working on a model that classifies anonymized chat messages, in order to quickly gain insight into the questions that our members ask us on a daily basis. Traditionally speaking, we find that these ‘text mining’ jobs are difficult, since they require a lot of data handling. To make things more complicated, the Dutch language brings a whole plethora of challenges with it, such as complicated grammar, word use in different contexts, et cetera.
In order to use GPT3 as a classifier, we needed to wrangle our labeled messages into the correct data format, choose a model type and retrain the model. OpenAI indicated that the cheapest and quickest model type (“ada”) was good enough for classification, so that’s what we went with.
The results were surprisingly good! The model was able to correctly classify 38 messages from the 50 that were tested. And that without any data cleaning or any other difficult parsing jobs.
Personalized chatbot
Building a chatbot is generally seen as a more complicated task compared to a classifying job. For this test, we thankfully did not need to reinvent the wheel. Personalizing your own chatbot works in the same way as retraining your model for classification. We scraped the FAQs from the Dutch government on the Coronavirus vaccines and used this data to retrain the model. This time, we chose the most powerful and expensive model presented by OpenAI, ‘davinci’. They indicate that this model performs best at holding a conversation.
After about an hour, the retraining job was finished and we were able to test it. The first thing that we found is that the model is pretty good at Dutch, so it seems that this will not form any bottleneck for us. Additionally, the FAQs seem to be incorporated well into the answers that the model gives to the questions asked. General questions regarding the coronavirus were answered similarly by both the original GPT3 model and the personalized GPT3 model. However, specific questions asked about Dutch circumstances were better answered with the personalized model.
Example response from the original GPT3 model (Translated to English):
Human: where are the vaccination locations for the corona vaccine?
AI: There are different vaccination locations for the corona vaccine in The Netherlands. You can find the most up-to-date information on the website of the RIVM. You can also find information about your eligibility for the vaccine and how you can sign up for it.
Example response from the personalized GPT3 model (Translated to English):
AI: In The Netherlands, you can get your vaccine at the corona vaccination locations of the GGD. The GGD-locations are listed on the website of the GGD.
The model seems to have learned from the very small number of FAQS that we added to the model. Very cool! However, the model did answer incorrectly or vaguely to some of our questions, so it seems that is not perfect yet. Of course, there are ways to further fine tune the model. Another good option would be to add more data.
Conclusion
At a glance, OpenAI have given us a great out-of-the-box tool which works reasonably well on many different use cases. It should be noted that you will need some more time for research, development and tuning to create a production-grade solution. Our takeaway, however, is that the total development time will probably still be quicker than creating something from scratch.
One last thing to keep an eye on are costs. These may increase quickly due to the tokens that you consume to train the model and the number of characters you use in your conversation (both input and output). This little test cost a little over 4 USD, which is still very manageable. 😊
Thanks for reading! — Analytics Center of Excellence at ANWB