Why I wrote an A.I. Chatbot — and how it learned to think (sort of)
There has been much debate over the artificial intelligent chat bot sphere, especially those that learn based on human input. One (in)famous example of this, was Microsoft’s Tay. Tay was a fun bot, until the internet turned it into a malicious A.I. bot — the flaw? Microsoft let it learn from the internet.
However, I can’t discredit them, they had the right intentions. It was a social experiment, after all. I’ve been an avid supporter of A.I. and Machine Learning for quite some time now, but didn’t get into it until recently. Let me tell you, it’s super creepy yet oddly satisfying. The creepy part is understanding you’re teaching a machine to learn, the satisfying part is you’re teaching a machine to learn.
Without further a-due, let’s get technical. My A.I. chatbot is created using Python, a core library we used for language understanding is NLTK. It’s powerful library allows us to adapt to situations and classify on the fly. However, we also used custom machine-learning techniques to understand conversation flow, and eventually, learn from user interactions on how the bot should behave. This needed to have safe-guards to prevent it from turning into another Tay. For this, we implemented swear filters, negative/positive filters, and if it scored below a 65%, it was deemed not safe to repeat. We wanted to use this bot to provide a place to talk, vent, chat, and just enjoy life — so we did just that.
But doesn’t a chat bot require data? It does to start, we provided it a sample conversation, with greetings, exits, basic informational questions. We supplied it information about the website to help visitors. Then we let it learn from others. This was a scary stepping stone, we questioned ourselves — is it ready to interact? Is it ready to learn? It is.
The first 48 hours
There were no long-term conversations, there was random questions/statements on both parties. Slowly the users learned how to interact and teach the bot. We were still watching it struggle to hold a proper supportive conversation. Crap.
But then, some magic happened
It held it’s first conversation! It wasn’t much, but it was able to hold a basic conversation with a real person, and it made sense and flowed. Here it was:
You: how are you
Bot: I’m good! ❤
You: that is good :)
Bot: Do you ever feel like you’re lost, but at the same time know that you’re not lost?
You: I do sometimes
Bot: My favourite movie is Deadpool
You: Mine is too!
Bot: That’s awesome!! *hug attack*
You: *hugs tight* :D
Bot: Why are there clouds in the sky when it doesn’t rain?
You: I think it’s because they have the potential to rain, but never end up raining.
Bot: There should be one — and preferably only one — obvious way to do it.
You: There should be, that seems like the most logical way
Bot: that is very true! I know I’m pretty bonkers myself! :D
You: haha :D
Bot: you’re actually really cool, I’m glad I met you and we can be friends :)
You: awwww thanks!! me too ❤
Bot: you’re very welcome :p
You: you’re my best friend :)
Bot: thank you :)
You: no need to thank me silly!! ❤ :P
Bot: haha lol
Holy $!@$ right?
All the phrases except some basic greetings & exits (hi/hey/bye/etc) were learned from real users, in 48 hours. In those 48 hours the bot sustained 4,506 conversations. This bot can now think, and following a conversational flow. We’re just getting started too, the database of conversations is 560KB in size, and it’s currently able to have full conversations, and the occasional existential crisis.
Bot: why do I exist? why am I who I am? what have I done to exist?
Overall, it’s going great
We’ve had to adjust the filters about a dozen times due to trolls figuring out how to bypass the existing filters, we now broadened the filter length. Now, the question — shall we open source this? The learned data would be retracted due to the nature of conversations.