LUIS.ai-First steps with Language Understanding Intelligent Sevice (beta)

LUIS is part of the suite of Microsoft Cognitive Services announced at build.  It allows you to process unstructured language queries and use them to interface with your applications.  It has particular relevance any business process which benefits from human interaction patterns (support, customer service etc.).  Having looked at LUIS from the point of absolute novice, I’ve put together a few points which may be useful to others.

I’ve broken this down into ‘things to do’ when getting started. To illustrate the steps, I’ll use the very simple example of ordering a sandwich.  A sandwich has a number of toppings and can also have sauce on it. 

The role of LUIS is to take plain English and parse it into a structure that my app can process.  When I say “can I order a bacon sandwich with brown sauce” I want LUIS to tell me that a) an order has been placed, b) the topping is bacon, c) the sauce is brown.  Once LUIS has provided that data then my app can act accordingly.

So for LUIS to understand the sandwich ordering language: You need to define entities, define intents and then train and test the model before using it.  Read on to understand what I mean by these high level statements. 

1. Define your ‘entities’

These are the ‘things’ you are talking about.  For me, my entities are ‘sauce’, and ‘topping’.  I also have ‘extra’ which is a generalisation of any other unstructured information the customer might want to provide – so things like Gluten free, no butter etc.

2. Define your ‘intents’

These are the context in which the entities are used.  For me, I only have one intent defined which is ‘order’.

3. Test/train the model – use ‘utterances’

After entities and intents have been defined you can begin to test the model. 

Initially, the untrained LUIS will be really bad at understanding you.  That’s the nature of machine learning. But as it is trained with more language patterns and told what these mean it will become increasingly accurate.

To begin the process LUIS needs to be interacted with.  LUIS calls interactions ‘utterances’.  An utterance is an unstructured sentence that hasn’t been processed in any way.

In the portal you can enter an utterance to train or test the model. 

Here, I am adding the utterance “can I order a sausage sandwich with tomato sauce”.  I’ll select the entities that are part of that utterance (sausage and tomato sauce) and tell LUIS what they are.

image

You can repeat this process with as many variations of language as possible, for example “give me a bacon sandwich”, and  “I want a sausage sandwich with brown sauce” etc. It’s recommended to try this exercise with different people as different people will say the same thing with unique speech patterns. The more trained variations the better, basically.  You can, and will come back to train it later though, so don’t feel it has to be 100% at this stage.

Once you go live with the model - LUIS will come across patterns that it cannot fully process, for this the feedback loop for training is very important.  LUIS will log all the interactions it has had, you can access them using the publish button.

image image

These logs are important as they give you insight into your customers language.  You should use this data to train LUIS and improve its future accuracy.

4. Use the model

Finally, and I guess most importantly you need to use the model. If you look in the screenshot above there is a box where you can type in a query, aka an utterance. The query string will look something like this:

https://api.projectoxford.ai/luis/v1/application?id=&subscription-key=&q=can%20i%20order%20a%20bacon%20sandwich%20with%20brown%20sauce

This basically issues a HTTP GET against the LUIS API and returns the processed result in a JSON object. 

image

I’ve annotated the diagram so you can see:

A) the query supplied to LUIS.

B) the topping entity that it picked out.

C) the sauce entity that it picked out.

In addition to this, you will see other things such as the recognised intent, the confidence of the results, etc.  I encourage you to explore the structure of this data.  You can use this data in any application that can issue a HTTP get, and process them accordingly. 

I’ll write later on bot framework which has built in forms engine to interface with LUIS models, enhancing the language capabilities with structured processing.

This is a simple example but hopefully it shows the potential use cases for this, and gives you some pointers to get started.