Language Understanding Intelligent Service

Azure’s Language Understanding Intelligence Service, a.k.a LUIS, lets you understand phrases given by users, or as LUIS refers to them, an utterance. This utterance is translated into an intent and entity. An intent is what they want to do, an entity is what you are referring the intent to. A simple overview of what LUIS does is as follows:

luisapioverview

Send the phrase “open passenger door” and receive the intent of open and entity type of door and entity of passenger. How it determines this is based upon training of your model, which we will go into shortly.

Overview In Action

Expanding on from the example above, say you have a Tesla and want to open the door. Typing into a field, the user types: “Opens passenger door.” 

Note: Yes, you could use a Speech to Text API to have this voice activated, but that will be another article. To understand the basics, they will be typing the phrase.

This utterance, is sent to the LUIS API and this is returned.

{
    "query": "open passenger door",
    "topScoringIntent": {
        "intent": "Open",
        "score": 0.999999046,
        "actions": [
        {
            "triggered": true,
            "name": "Open",
            "parameters": []
        }
        ]
    },
    "intents": [
    {
        "intent": "Open",
        "score": 0.999999046,
        "actions": [
        {
            "triggered": true,
            "name": "Open",
            "parameters": []
        }
        ]
    },
    {
        "intent": "None",
        "score": 0.147127971
    }
    ],
    "entities": [
    {
        "entity": "passenger",
        "type": "Door",
        "startIndex": 5,
        "endIndex": 13,
        "score": 0.900215864
    }
    ],
    "dialog": {
        "contextId": "a8364520-4903-4090-a922-5d84089bbb89",
        "status": "Finished"
    }
}

Intent = Open
Entity = Door – Passenger

It shows the entity, the passenger door and the intent of open, weighted with a probably of how confident LUIS is, in its assessment of the utterance. This is what LUIS does.

But people don’t say the same phrase the same way. What if they said “Please open the passenger door” or “Open up the passenger side door please”. This is where LUIS comes in. It takes these phrases and can discover the intent and entity of the phrase, when given some training. It will even make suggestion for you to confirm to train the model further.

luisoverview

Setup Cognitive Services

Go to the Azure Portal, and search for Cognitive Services.

cognitiveservices

Set your API type as Language Intelligence Understanding Service, and set the other options as appropriate.

languageunderstandingintelligentservice

Next, go to Keys and record them for upcoming use.

luis_keys

Create Application

Now go to the LUIS Dashboard (https://luis.ai). This is the main dashboard, where we can setup and train our model.

First, lets create a new Application.

newluisapp

Name your application, and choose the appropriate options.

addnewluisapplication

Intent

First lets create an intent, from the left hand menu. The intent in this context is “Open”.

addintent

Entity

Next, add an entity. In this context, it is a “Door”.

addentity

Utterance

LUIS supports a few different languages, but for this post, I will focus purely on English. An utterance, in this context, is a plain English sentence. In this example it is “Please open the passenger door”.

First we want to enter an utterance. When you enter this, it will show you a box, where it might have automatically highlighted the entity, and it will have chosen the most likely intent.

newutterance

If nothing is highlight, double click the word and a small dialog will pop up. This will let you choose which entity this is.

Training Model

As you continue to add in more utterance’s, the model gets smarter. However, before we can use it, we need to tell LUIS to train our model with the new data. Press the Train button in the bottom left hand corner.

trainmodel

You can review utterances if needed, by going to the Review labels tab.

reviewutterances

LUIS will even suggest some to you in the Suggest tab.

Setup API Key

Before we can use the API, we need to setup the keys. Click on your name in the top right hand corner.

usersettingsclick

Now you want to go to the Subscription Keys tab.

  1. Copy your Programmatic API Key, you will need this to call the API.
  2. Enter in Key1, from Azure.

usersettings

Now go back to your application, and press App Settings. Add in the new key. Also take note of the AppId, you will also need that later for API access.

appsettings

Publish

Press the Publish button, just below App Settings in the left menu. Then make sure you Publish or Update your API. Once this is done, you can even enter in a phrase and then click on the link below to see what the API will return.

publishapi

API Usage

I have created a Sample Cognitive Services project, with a working sample. It just involves calling the API above and deserializing it in to an object you can now work with.

Now, go and enjoy the new possibilities this API can bring to your mobile app.

Microsoft MVP | Xamarin MVP | Xamarin Forms Developer | Melbourne, Australia

Related Posts

Leave A Comment?