Entities and Intents: crawling through Natural Language Processing

I’m afraid that the following syllogism may be used by some in the future.

Turing believes machines think
Turing lies with men
Therefore machines do not think

Yours in distress,

Alan
(Alan Turing)

The journey started five months ago when I went to Bangkok to attend the Intelligence Chatbots Masters Training run by Oracle Product Management. Since then, I’ve been lucky enough to dive deeper into the world of Natural Language Processing. While I think it’ll take me a while to transition from crawling into walking through this fascinating world I’m happy to start sharing my findings.

This blog is about Entities and Intents which are the key building blocks for Natural Language Processing.

Artificial Intelligence: What is not possible?

A few days ago I cooked a yummy Vegetarian dish, it looked so good that I took a photo and sent it to a friend who’s a native English speaker. He texted me back one world “perfezionare” which in Italian means “to perfect” (verb) and I laughed because it just made no sense! Then I realised he meant “perfect” (very good)…

image

We call natural language a language that has developed naturally in use – people speak natural language, everyday we use a myriad of words and we use words to communicate and convey messages. We deliberately play with words, we enjoy puzzling our interlocutors – words are the most powerful vehicle to express our emotions, our intentions, our sentiments, our ideas, our concerns. Flirting is made possible by words! Words are powerful and confusing as shown by a few examples below:

  • I’d really truly love going out in this horrible Melbourne weather! (sarcastic, seriously who loves Melbourne weather? 🙂 )
  • What’s my timetable over the next couple of hours?
  • I’m low on bread in my checking account.
  • The red dress is not really my thing

In 1950, Turing wrote on the first page of his Manual for users of the Manchester University computer (Turing 1950a):

Electronic computers are intended to carry out any definite rule of thumb process which could have been done by a human operator working in a disciplined but unintelligent manner.

On the other hand, he also wrote in the more famous paper of that year (Turing 1950b, p. 460)

We may hope that machines will eventually compete with men in all purely intellectual fields.

Is there any intelligence in those operations which were themselves totally routine and mindless—‘entirely without intelligence’? This is the core of the problem Turing faced which is the same problem Artificial Intelligence research faces today. Turing’s underlying argument was that the human brain must somehow be organised for intelligence, and that the organisation of the brain must be realisable as a finite discrete-state machine. The implications of this view were exposed to a wider circle in his famous paper, “Computing Machinery and Intelligence,” which appeared in Mind in October 1950.

What is possible today.

Wikipedia defines a Bot as “a computer program which attempts to maintain a conversation with a person”.

Two people who do not speak the same language cannot have a conversation because they can’t understand each other – meaning words are just sounds and not valuable information. In the opinion of S. K. Kapur, “The communication process is the method by which the sender transfers information and understanding to the receiver.”

This implies communication is a three steps process:

  1. the sender wants to transmit a fact, idea, opinion or other information to the receiver,
  2. the receiver decodes the message sent by the sender,
  3. then the receiver sends a feedback message to the sender.

Therefore, the key for a Bot to understand human languages is its ability to extract the relevant information from user messages provided in the user’s language. Often bots fail to detect the intention of the user and following this, the bots are unable to take any relevant action in response to what is provided by the user.

NLP (Natural language processing) is the science of extracting the intention of text and relevant information from text and it uses Intents and Entities. What are they?

Intents

Simply put an Intent is what enables the Bot to do what the user wants it to do.

"I'd like to fly from Rome to Milan tomorrow"

In this example the final goal/intention of the user is to book a flight to go from Rome to Milan. So, based on some entry made but the user in the Chatbot, we need to map that to a specific and discrete use case or unit of work. How is a free text entry mapped to a specific intent? How does the Bot work out the intent?

Utterances

Utterances are the answer to the question above. They’re common phrases that might typically be associated with the intent.

"I'd like to book a flight from Rome to Milan tomorrow"

"I need to fly from Rome to Milan tomorrow, can you find a flight for me?"

"Is there a flight that can take me from Paris to London next Monday?"

"Could you please book me on the next flight from Melbourne to Sydney?"

"What's the first flight from Brisbane to Perth on Friday morning?"

"Is there a flight that can take me to to Sydney by 7PM?"

These (and many more) are sentences that we would use to ask a customer service representative to book a flight for us. Because the Bot “is” our customer representative we should design the Bot to have the intent “Book flight” and define a rich consistent pool of utterances to help the intents engine to determine the right intent.

Entities

"I'd like to fly from Rome to Milan tomorrow"

What information would the customer representative use to assist the customer? The departure city, the destination city and the enquired date/time – similarly the Bot will extract “Rome”,”Milan”,”Tomorrow” (converted into a valid Date) as search criteria to find all available flights that match the request and respond to the user.  To extract those three values from the input the Bot uses what in NPL we call Entities and I like defining them as “subject matter experts”. They add context to the intent itself and they enable the bot to complete a user request. In other words you might want to think of an intent as having “metadata”, variable elements – so for example the intent “Book flight” could involve the following entities:

  • “Departure”: a custom Entity which is the list of all the possible departure cities
  • “Destination”: a custom Entity which is derived from “Departure” (the prepositional phrase “to” is used as a rule to extract the destination city and disambiguates it from the departure).
  • “Time”: the departure date – a built in Entity like Number, Email, Phone Number, URL, etc.. they’re generally predefined/built-in

“Rome”,”Milan”,”tomorrow” (translated into a Date format) are the variable values that the back-end system uses to search for the flights.

Why are Entities powerful?

  1. They add context to an intent – a well designed bot should be able to extract what the user has provided in input (without asking unnecessary questions).
  2. They make the conversation more “natural”, less “artificial” – value list entities allow to specify synonyms. These can include abbreviations, slang terms, and
    common misspellings as well.
  3. They limit the number of intents and improve the Bot intents detection. As an example let’s consider a Uni Bot that allows students to enroll/unenroll in/from a course. Instead of creating two intents a better solution is having one intent “Manage Courses” and one custom entity of two values “enroll”,”unenroll” mapped to that intent to differentiate the use cases.

 

What will be possible tomorrow.

Finally I’d like to close this post by sharing this last though with you. I don’t think Bots are never going to replace humans and hopefully machines are never going to take control. However today Sentiment Analysis are able to determine the attitude of the user with respect to some topic or the overall contextual polarity or emotional reaction to a document, interaction, or event. Therefore, I strongly believe Artificial Intelligence will get to a degree where Bots will control and condition peoples behaviour.

Thanks for reading and until next post!

2 thoughts on “Entities and Intents: crawling through Natural Language Processing”

Leave a comment