Reader small image

You're reading from  Learning Microsoft Cognitive Services

Product typeBook
Published inMar 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781786467843
Edition1st Edition
Languages
Right arrow
Author (1)
Leif Larsen
Leif Larsen
author image
Leif Larsen

Leif Larsen is a software engineer based in Norway. After earning a degree in computer engineering, he went on to work with the design and configuration of industrial control systems, for the most part, in the oil and gas industry. Over the last few years, he has worked as a developer, developing and maintaining geographical information systems, working with .NET technology. Today, he is working with a start-up, developing a brand new SaaS product. In his spare time, he develops mobile apps and explores new technologies to keep up with the high-paced tech world. You can find out more about him by checking out his blog, "Leif Larsen", and following him on Twitter (@leif_larsen) and LinkedIn (lhlarsen).
Read more about Leif Larsen

Right arrow

Chapter 4. Letting Applications Understand Commands

 

LUIS saved us tremendous time while going from a prototype to production.

 
 --Eyal Yavor, Co-founder and CTO Meekan

Throughout the previous chapters, we have focused on Vision APIs. Starting with this chapter, we move on to the Language APIs, where we will start with Language Understanding Intelligent Service. Throughout this chapter, we will see how to create and maintain language-understanding models. We will learn how to add simple conversational intelligence to our applications. Finally, we will see how to complete actions on the user's behalf.

By the end of the chapter, we will have covered the following topics:

  • Creating language-understanding models

  • Adding conversational intelligence (maintaining context and executing dialog)

  • Handling common requests, using pre-built models from Bing and Cortana

  • Executing actions based on intent

Creating language-understanding models


Often, we wish that our computer could understand what we want. As we go on with our day-to-day business, we would like to be able to talk to the computer, or mobile phone, using regular sentences. With no help at all, this is hard to do.

Utilizing the power of Language Understanding Intelligent Service (LUIS), we can now solve this problem. By creating language-understanding models, we allow applications to understand what users want. We can also recognize key data. This is typically data you want to be a part of a query or command. If you are asking for the latest news, key data may be the topic you are asking to get the news for.

Register an account and get a license key

To get started with LUIS, you should head over to https://www.luis.ai. This is where we will set up our application. Click on the Sign in or create an account button to get started.

Once inside, we want to make sure we have a subscription key. We can register for one using Microsoft...

Training a model


Now that we have a working model, it is time to put it into action.

Training and publishing the model

The first step to using the model is to make sure the model has some utterances to work with. As we have seen, we have added one utterance per intent for now. Before we deploy the application, we need more.

Think of three to four different ways to set or get the room temperature and add them, specifying the entities and intents. Also add a couple of utterances that fall into the None intent, just for reference.

When we have added new utterances, we need to train the model. Doing so will make LUIS develop code to recognize relevant entities and intents in the future. This process is done periodically; however, it is wise to do it when you have made changes, before publication. This can be done by clicking on the Train button, in the bottom-left corner of the screen.

With the training completed, we can now publish the application. This will deploy the models to an HTTP endpoint...

Executing operations based on commands


One of the key features of LUIS is the possibility to recognize intents. Doing so allows us to execute actions based on the intent.

Maintaining conversations from unclear utterances

If we ask the application what the temperature is, how will it respond without knowing which room to look for? As it is right now, it will not give any desired results back.

Click on the intent, GetRoomTemperature, in the Intent name field. As we are now in preview, we can add Action Parameters, as well as selecting the Fulfillment box in the Action Info section. Add a new Action Parameter, naming it Rooms. The entity type should be set to Rooms, and you should select Rooms as the phrase list.

In the Prompt field, enter a sentence that will be used as the response if this parameter is missing. For instance, we can add, What room do you want the temperature for?.

The intent dialog should look like the following screenshot:

Publish the updated application and head back to Visual...

Summary


Throughout this chapter, we have created a LUIS application. We have seen how to create language-understanding models, which can recognize entities in sentences. We have learned to understand the user's intent, and seen how we can trigger actions from this. An important step was to see how to improve the model in various ways. We also covered how to add conversational intelligence. This way, the LUIS application could ask for missing entities in queries.

In the following chapter, we will utilize what we have learned here, using LUIS when we learn about the Speech APIs, adding the possibility of speaking with our application.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learning Microsoft Cognitive Services
Published in: Mar 2017Publisher: PacktISBN-13: 9781786467843
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Leif Larsen

Leif Larsen is a software engineer based in Norway. After earning a degree in computer engineering, he went on to work with the design and configuration of industrial control systems, for the most part, in the oil and gas industry. Over the last few years, he has worked as a developer, developing and maintaining geographical information systems, working with .NET technology. Today, he is working with a start-up, developing a brand new SaaS product. In his spare time, he develops mobile apps and explores new technologies to keep up with the high-paced tech world. You can find out more about him by checking out his blog, "Leif Larsen", and following him on Twitter (@leif_larsen) and LinkedIn (lhlarsen).
Read more about Leif Larsen