FriendGPT: Imitate your friends
I spoke a lot about ChatGPT in many of my other projects about how it could have helped me out. So what have I done with ChatGPT?
Like most programmers, HBO's Silicon Valley was a must watch for me. In the show, Gilfoyle (a programmer) wrote an AI version of himself to talk to Dinesh (another programmer), it was so real that it fooled Dinesh for an entire day. So when ChatGPT came out, I thought, since we have talking AIs, can we do this now?
Of course, the only way to achieve this was to have access over the training of ChatGPT. Luckily, OpenAI did provide an API for custom fine-tuning, which is the process of training the AI to a specific goal, in my case, to imitate a person's chat.
It turned out (at the time) that OpenAI does not offer ChatGPT specifically for training, but other GPT-3 models were available, and upon initial testing, they do seem capable enough.
The next important thing was to gather the data. Most people in China use an application called WeChat to send instant text messages. Upon gaining permission from a few friends for this experiment, I was able to extract the chat history with them.
The application consists of 4 parts, the Blazor Server which provides an Web interface to communicate with the AI, the WechatBot which can talk inside WeChat, and DataParser which extracts WeChat history, as well as the “PythonDebug” (sorry bad name) which communicates with OpenAI's API.
Chat history is organized like this (the chat was in Chinese), it consists of the speaker, which would be Jingcheng (me) or Annie (my friend), as well as the date time, and the text.
The date time was useful as one can guess when conversations end. For instance, if Person A sends a message, waits 7 hours, then sends another message, it's most likely that Person B ended the first conversation while Person A starts the next. Using these patterns, the DataParser would segment the chat history into smaller chunks, so that each chat had a consistent theme and topic.
Training was then conducted with various models and configurations. However, such data as “training loss” provides little insight to experience as, lower loss simply means the AI is better at answering the same responses to the same questions. So everything had to be field tested.
The results went from goofy to scary, but, around ⅔ of my friends believed that the AI was able to imitate their behavior to some extent.
In the chat with Tony, one of my friend, he speaks of going to boxing, winning, and seeing Leon (one of our common friends) in the cafeteria (which exists in school). It otherwise not stated, one would not doubt this is one of my typical chats with Tony.
To expand upon this, I thought, was it possible for the AI to send Emoji and Pictures? By emojis, sometimes they are gif images, which meant they did not have a text label. However, by computing a hash from each of the images, I was able to manually assign them an ID, and replace the image with the ID. Hopefully, the AI might learn to send the ID when appropriate. It worked.
Regarding images, it was more difficult. Luckily, OpenAI also provides DALLE and ClipV, which respectively generate an image from a prompt, and outputs a prompt (description) based on an image. Using this, I translated all the images in the chat to prompts, and made adapters for the AI to convert prompts to Images to be sent, and understand images by converting them to prompts.
I asked the AI what was in the image, and he told me it was a “hotel”. It's weird, but not off.
Overall, it was interesting experience, were we able to beat Silicon Valley? No. But I was able to test the capabilities of the GPT models, and learnt a great deal in Natural Language Processing through this.