Saturday 31 March 2018

Chatbots : Intents or Entities ?

A general architecture of chatbots can be found in this article. Required reading, if you want to understand chatbots. As of now, the most popular open-source framework to create chatbots is RASA, which is made of RASA_NLU and RASA_CORE.



The NLU (National Language Understanding) component

A chatbot must have a NLU component, whose purpose is to identify the intents and the entities of user queries.

Intents : the bots must be able to understand what the intention of the user is. Whether he wants to make a reservation at a restaurant, for instance.

Entities: In the context of Bots, these are neither "Nouns" nor Named Entities that may be recognized by a NLP library such as Spacy (though these may overlap). An entity is an actionable piece of information.

For instance, if the user says : I want to reserve a table for two at Stacy's, tonight at 19:30 , the intent would be make_reservation, while the entities would be two, Stacy's and 19:30. We can use this information to book a table for two at Stacy at 19:30. However, for Christ's sake, table in this context is not an entity, it is actually part of the intent that we identified, make_reservation (at a restaurant)!

Intents or Entities?

 While it would be great to have a system which would be able to recognize a good amount of intents and entities, in practice you see that successful chatbots choose to concentrate either on one or the other.

Prioritize Intents ? : the typical use case of this is when you want your bot to answer users' Frequently Asked Questions. If the expected action is just give a canned answer once you recognized an intent, you don't need entities at all

Prioritize Entities ? : this is a typical scenario for the most focused (and usually most successful) bots. Usually these are the bots who drive the conversation so that they know exactly what intent to expect at a certain juncture. For instance:


ChatBot: Hi,  I am the Stacy's restaurant chatbot. Choose your action:
1. Make a Reservation
2. Cancel a Reservation

(User picks 1)
Please tell me about your reservation.
User: I want to reserve a table for two, tonight at 19:30

In this case, the chatbot knows that the user's next sentence will be about reserving a table, so it will just concentrate on getting the entities. Even easier is decomposing the query even further.

ChatBot: Hi,  I am the Stacy's restaurant chatbot. Choose your action:
1. Make a Reservation
2. Cancel a Reservation

(User picks 1)
For how many people?
User: Two
When?

User: Tonight, at 19:30


In this case, forget about intents, drive the conversation and just train your bot to recognize entities.  

Bootstrapping Chatbots


It is ok to bootstrap your chatbot using keywords / hand-coded rules, but you should think of ways to gather data from users interaction and leverage it using machine learning.  

 

Introducing WeChat


I found this article about the experience learnt while creating the WeChat chatbots, in China, of all places.

WeChat started creating simple chatbots in 2009. WeChat proves that, as a matter of fact, chatbots can be successful. China lives in another internet ecosystem and may show us an alternative timeline, compared to the one we are living in the west. In our "Western" timeline, chatbots are nowhere as successful as they are in China.

Too bad I don't speak Chinese and cannot actually try these chatbots.

How is WeChat doing ?


WeChat has made it easy to create very simple chatbots that are actually not very intelligent. It has become one of the favored ways for customer service to reduce the work they do interacting with customers online.

 Chumen Wenwen ... has built a very sophisticated bot that ... combines voice recognition, AI and the WeChat platform into a package that queries information for its users. By connecting with third party API’s the app can answer questions about what is around you, including movies, restaurants, massage and more.

We are astonished to learn that many entrepreneurs doing business in China create an official WeChat account before they even launch their website.


Customer service accounts

The kind of bots we are interested in are customer service accounts. 
They turned out to be necessary in China because customers
bombard the brand themselves with questions, before they make a purchase online or in-store. The sheer number of consumers and their zest for questioning is what created the need for chatbots in China before they ever came into the minds of Facebook and others.
 

Nevertheless, it is important to point out that bots are incapable of handling all types of customer requests. As a result these accounts need to be supported by employees.
 

Technology

Let's get to the part that interests us most - technology. 

WeChat bots work by identifying keywords in text strings and using hand-coded rules for how to respond to different situations. Yet, they still use machine learning and the more users interact with companies and brands via chatbots, the smarter they will become, and the faster they will learn to understand user inputs.

Lesson To Learn: it is ok to bootstrap your chatbot using keywords / hand-coded rules, but you should think of ways to gather data from users interaction  that you can leverage using machine learning.

What do these bots have to do anyway ? They have mainly to answer users' queries, not to take actions on them. So my guess would be that they are focused on intents rather than on entities.
Although bots are gradually learning to understand customer requests, they still text back only pre-set responses.

So after they have recognized users' intents, they text back precanned-responses. Got it.