ChatGPT: building a digital avatar
Creating an identical copy of my friend in ChatGPT and chatting with him via Telegram
Once Open AI released the ChatGPT tool I started using it every day to ask things that I would normally ask Google. I also use it for translation, fixing grammar in my emails, to help me with coding and even brainstorming gift ideas.
But as my friend’s Birthday appeared on the horizon I got the idea to take it even further and make a digital avatar of him as a present — a virtual version of the friend that could hold a conversation exactly like him in Telegram messenger. Sounds cool, huh?
Writing Prompt
How can you teach ChatGPT to act like somebody? Well, you can just tell ChatGPT (using natural language) to pretend to be someone and describe all the facts about that person and their texting style. For example you could write this fact sheet as a prompt:
Joel is a tough and strong man. He tries to survive in a post-apocalyptic world.He is also old-fashioned and uses text emojis in his texts a lot.
You pretend that you are Joel texting me in a messenger.
And then try to talk to ChatGPT and see how it answers your questions. Sometimes it might say something wrong or false.
When I was part of the Google Assistant team, a team that builds a virtual assistant for smart speakers and phones (like Siri but from Google). We were working on integrating Google’s GPT model called LaMDA into the Assistant Product. There was a long list of facts that we fed into the model and still you would ask the assistant “Hey Google, do you like dancing?” and it would answer something like “I love it, you should check out how I swing my hips.” Clearly, Google Assistant is a program that doesn’t have a physical body and can't dance. And in fact nobody wants to see how it swings its hips. We called those cases hallucinations.
ChatGPT can also hallucinate in our case when the fact sheet is controversial, confusing or just not enough. Another limitation is that the ChatGPT model has a short memory: it can remember approximately 3 000 last words of the conversation. So if your facts sheet is too big or you’ve been chatting in one dialog for too long, eventually the personality description slips away from GPT’s cache and Oops… it seems like you are talking to someone with Alzheimer’s. Ultimately I think that writing a really good fact sheet takes a special kind of skill. It’s like programming in a natural language.
So in my case I had to go through my fact sheet multiple times to make sure that I mentioned all the necessary details for it to behave like my friend.
Some prompts I would definitely recommend to include are
Facts about the character (bio, what they like, who they friends with)
The context where the chatting is happening
Notes about the character’s writing styles (what emoji they use etc)
Technical Implementation
The next step was to integrate ChatGPT into an app that pretends to be a Telegram user. I used a simple Python script to run the application that expects messages from Telegram, communicates with ChatGPT and sends replies to the user.
ChatGPT API was not available when I was implementing this project, so I had to use one of early-adopter hacker libs that mimics the browser and authorizes on the OpenAI website on your behalf. People say that the text-davinci-003
model from their text API is really good as well, this could be an alternative if you want to use the official API. I was lucky to get the ChatGPT Pro version so my bot had a chance to be quicker and more reliable.
Telegram API is pretty straightforward. I utilized a well-known Pyrogram framework to communicate with Telegram. I wanted to make it look like you are talking to a real person, so I even added the classic “typing…” status while the program was waiting for the response from ChatGPT servers, and also told ChatGPT to split one reply into several messages – just like my friend would do in real life.
Result
After combining all together it looks like this:
For now it was only a gag gift, but imagine where this could go. Black Mirror, creating digital avatars of loved ones, creating your virtual assistant, auto replying to emails, etc
Next steps
ChatGPT brings so much value as a technology to my life. I have several ideas how it can be turned into a product, including
Grammar checker/email writing tool (like Grammarly on steroids).
Structured search in companies’ documents and analytics. How cool would it be to ask AI “What was our revenue per user in each state last month?” instead of pinging your product manager in Slack.
Virtual assistant that replies to emails/messages etc.
Will I work on one of those ideas? The future will tell. But I’ll definitely keep experimenting with AI technologies. Stay tuned to get updates!
https://www.notion.so/product/ai
https://quillbot.com/