Natural Language Understanding (NLU) is one of the most important parts of any chatbot. Natural Language Understanding helps the chatbot to understand the user’s intent more accurately.
There are many platforms that have their inbuilt NLU Engine such as Dialogflow and IBM Watson. But if you are building your chatbot without these platforms, don’t worry there are many options that you can use to integrate NLU in your chatbot such as Wit.ai by Facebook and LUIS.ai by Microsoft.
In this blog, I will be talking about Luis.ai and how to get started with it.
What is Microsoft LUIS?
Microsoft LUIS stands for Microsoft Language Understanding Intelligent Service. It is a part of Microsoft’s Cognitive Services toolkit.
Luis provides you with a way to build a custom language understanding model for your chatbot. It is powered by Machine Learning algorithms that can be used for building chatbots, apps and IoT devices.
To know more about Luis click here.
To get started with Luis, the first thing you need is a Microsoft account. Sign in with your Microsoft account and allow Luis to access your account basic info.
In the next, select your Country/Region and agree with the terms and hit continue.
Click on “Create a LUIS app now” in the next step.
Click on “Create new app” and fill all the details in the next step.
Once you finish the above step, click on the app name from the list and you will see a similar dashboard as shown below.
If you have worked with any other NLU platform before then you must be aware of Intents and Entities.
If not, here’s a quick and simple introduction to Intents and Entities.
Intents help to identify what the user wants to do
Entities are used to extract data from the user’s query
Consider a simple example of a user query below…
“Turn off the light in the kitchen”
Here the intent is to “turn off the light” and the “kitchen” is the entity. There can be anything in place of kitchen such as a bedroom or living room.
Click on the “Create new intent” button and provide the intent name to create a new intent.
Add some examples as shown below for the intents. You can add as many examples you want that user might say to perform an action.
To test the model, you first need to train it. Click on the “Train” button to train your model.
After the training is finished. Hit the “Test” button for testing.
Type a test utterance matching the intent example and you will see the intent name with confidence score as shown below.
You can create multiple intents similarly with different examples of phrases.
To create entities, open the Entities tab and click on “create new entity” button and provide entity name and type to create a new entity.
There are six entity types to choose from Simple, Hierarchy, Composite, List, Regex and Pattern.any.
For this blog, we will use the Simple entity type.
After you enter the details, you now have to add some roles. To do that, open entity and enter roles as shown below.
The next step is to use the entity in the intent phrases to extract information the query. You have to modify your intent phrases to do that. Modify the intent phrases as shown below.
To add the intents hover over the kitchen text and select and select “home-location” (select as per your entity name).
Train the model and then you can check if the model is performing as expected or not.
You can see the below screenshots that the model has correctly identified the home location as kitchen and bedroom.
So our model is performing well. Once we build our model on Luis, we can use this model in our app or chatbot. I will cover this in another blog later in detail.
If you have any query, please leave the comment below.
Thank you for checking this out. 🙏
Happy Coding. 😊