In my ongoing quest to learn as much as I can about the Artificial Intelligence (AI) products and features in Azure, in this blog article we will look at the first introduction to the Language Understanding Intelligent Services (LUIS).
LUIS is part of the Azure Cognitive services API and helps developers build in natural conversational like programming features in order to look to extract meaning from the spoken or written word with AI to help.
As part of this article we will take a high level look at some of the complexities involved with trying to understand the spoken or written language, before dipping into how to create a resource in Azure and then actually looking to create our first basic application.
What goes into Understanding Language?
When we talk to each other face to face, over the phone or via text message as an example, we would generally its probably safe to say that as humans, we don’t always get the phrasing, the question, or the answer to that question correct. Things like tone, context, or even the relationship we have with the other party come into play which all influence to the answer we receive. Whether we realise it or not, inference of meaning and sentiment is quite a complex thing to do.
Now factor this into the vast number of languages across the world from your own primary language, factor in various dialects and subtleties of slang across all these things. Inferencing meaning can be a troublesome thing to do at the best of times.
In order for AI to start to make sense and provide meaningful and accurate predictions and inferences, it utilises three key features in order to do this:
- Utterances – This is the input from a user, typically via an app, spoken or written word.
- Intents – These are the things or actions that a user would like to do, i.e. the end goal of what a person is trying to achieve via their spoken or written word.
- Entities – These represent a word or a phrase in the utterance that needs to be extracted and potentially acted upon.
Create a LUIS service resource
You will need an Azure Subscription to set up the required resources to progress through to creating our first LUIS enabled application.
Sign into our Azure Portal:
Creating a LUIS App
Currently there are three sets of URL’s representing the region where you set up your LUIS service in Azure:
For the purposes of this article I will be using the link for ‘Europe’
Once signed in, select the subscription utilised for your service
Select your resource and click Done
Select ‘New app‘
Give your app a name, and select the culture most appropriate for you or your intended application audience. Select the Prediction resource you created earlier and click Done
Add Intents and Entities to our Application
For the purposes of this article we want our application to understand how to do a few things:
- Find pictures
- Share pictures on social media
- Order prints of pictures
- Greet the user
So we need to add our first intent:
We can start off adding an example of a typical greeting, but we know there are more ways to greet someone
So I have added a few more ways, you should always supply a minimum of 5 example utterances per intent.
That’s our first intent created, now let move onto the next one.
Create our ‘SearchPics‘ Intent click Done
Next we add a bunch of example utterances to our Intent.
With two Intents created, we can now look at creating Entities.
From the menu, select Entities and click Create
Give the Entity a name, in this case ‘facet’, basically whatever the ‘facet’ picks up is what the app will search for.
Mapping the search subjects to our ‘facet’ entity
If we now go back to our Intents page and select our ‘SearchPics’ Intent, we can hover over the keyword that specifies the search subject and we can select the facet entity as per the above image.
We can quickly add the remaining 2 Intents as follows:
Finally we will add a few utterances to the existing ‘None’ Intent:
At this stage we have our utterances and out intents created, now we need to train our model.
Train the LUIS Model
In the top bar, click on Train, this may take a few minutes to complete.
Once training has completed:
Select Azure Resources, this is used to manage the URL endpoints for access to this LUIS service
Publish the App
From the top toolbar, click Publish
Select Production Slot and click on Done
Testing the App
From the top toolbar, click Test
Now we have done our first round of training, we can actually start to enter a few utterances and test our application.
After entering a few test utterances, you can actually see that we have a selected intent with a prediction score. We can use these results to either further retrain our model, or we can take our endpoints to start using our app within a client application that you may be developing.
I hope you have enjoyed this first interaction with LUIS on Azure and how you can build your first LUIS app with Intent, Utterances and entities and the steps involved to prepare an app for training. Once adequately trained, using the endpoint URL’s and integration guides, this can be included inside a client application of your choosing to add this LUIS application in to maybe a Bot service