Illustration: Colourbox

Machines recognize feelings using algorithm and Emojis

Cyber security
With 64 emojis and DKK 1.2 billion tweets, an algorithm has learned to recognize sarcasm in text messages. The method can revolutionize computers’ understanding of human communication.

By Jeppe Mølgaard

Aboard the space shuttle of any good sci-fi film we find a robot with artificial intelligence capable of communicating with the crew in a humorous way, but the idea of software communicating like human beings is perhaps not as far-fetched as it sounds.

Former DTU student Bjarke Felbo—currently studying at the Massachusetts Institute of Technology (MIT) on a grant—has developed an algorithm that can detect underlying messages such as sarcasm in text messages using deep-emoji analysis. Associate Professor Sune Lehmann from DTU Compute—senior author on a dissertation on the algorithm—believes that its potential is greater still. More about this later.

The algorithm can detect underlying messages in a text by dividing it into emotional categories. Previously, computers only had a specific word or a few hashtags to go on and were therefore limited to extracting the literal meaning from a given text. However, with the help of the 64 selected emojis, the algorithm suddenly has a similar number of new textual dimensions, allowing it to draw new conclusions about the significance of the text.

"The smart thing about this algorithm is that in reality it gives us the key to understanding textual emotions."
Sune Lehmann, associate professor at DTU Compute

“The smart thing about this algorithm is that in reality it gives us the key to understanding textual emotions,” says Sune Lehmann.

The algorithm has been trained to analyse how the selected emojis have been used in more than one billion Twitter updates. It has learned that we are angry when we write ‘this is shit’ and that we are expressing enthusiasm when we write ‘this is the shit’. It knows this because we end the messages with different emojis.

No limits
When an algorithm learns to distinguish between a multitude of nuances involving very large amounts of data, we call this ‘deep learning’. The emoji algorithm is based on this principle. However, it is also capable of ‘transfer learning’—i.e. the transfer of experience from the solution of one problem to another—which makes it special.

“Deep learning has made the algorithm good at guessing which emoji belongs to a specific text. We can then use transfer learning to make adjustments so it can distinguish between sarcasm and non-sarcasm—and subsequently add additional data to the algorithm so it can learn lots of other things,” says Sune Lehmann.

You have to imagine placing 64 emojis flat down next to each other and ranking them from the most tearful to the happiest smiley. Additional data—positive and negative—can then be added to these different dimensions of ranked emotions, enabling large-scale analyses of many messages at once.

Useful for politicians
“For example, the algorithm could be used by politicians to gauge how an entire population reacts online to their comments and standpoints,” says Sune Lehmann.

However, the algorithm is capable of a great deal more. It can also be developed to detect hate speech on social media and render voice control programs like Apple’s Siri more intelligent.
And who knows—maybe one day it will be you having a humorous conversation with the robot from the sci-fi films.