LUIS Build Application - microsoft-campus-community/workshop-shopping-list-bot GitHub Wiki
the steps to create one first.
Prerequisite: This page assumes that you have a LUIS (Language Understanding) resource up and running in Azure. If you do not have one yet, followWiring LUIS up to our Azure Language Understanding Resource
Now, you are going to create your LUIS application so that you can use it to predict what action (add/remove/mark/unmark item to/from/in the shopping list, get all items in the shopping list and remove all items from shopping list) the user wants the bot to perform (intents). You are also going to train the LUIS model so that it can extract entities from a message. Entities are domain-specific. For the shopping list domain, you will define entities like the name of an item and the unit (i.e., 1 kg, 2 pounds) for an item. This will enable our bot to know what the chat participant wants (intents) and the input (entities) for the specific action on the shopping list.
- Go to Luis.ai in your browser.
- Click on 'Login / Sign up' and log in with the Microsoft account you used to create the Language Understanding resource in Azure.
- You are greeted with a prompt. Select the Azure subscription you used to create the language understanding resource previously. Under the 'Authoring resource' dropdown, you should select the '<NAME_OF_YOUR_LUIS_APPLICATION>-Authoring' resource you created previously. Click on 'Done'.
- Now, you have three options to create all the intents and entities for LUIS. Pick one path.
- FIRST PATH is the easiest path because you can simply import the completed LUIS application and move on.
- SECOND PATH will start by using prebuilt intents and entities included in LUIS. With the prebuilt intents and entities as a starting point, we then only need to add a couple more by hand.
- THIRD PATH will create all intents and entities by hand.
[FIRST PATH] import LUIS application
This is the quickest way to create the LUIS application to use with the shopping list bot. If you are short on time, this way is for you. Import the complete LUIS application and be done with the LUIS application.
- Select 'Import as JSON' from the dropdown menu right to '+ New app'.
- When the 'Import new app' prompt is open upload the exported [LUIS JSON from our repository] (../blob/master/luis-shopping-list-app/Shopping-List.json). Give it a name, for example, 'Shopping List'.
- Now, you are ready to move on to the next part of the workshop.
Train LUIS
NEXT:[SECOND PATH] Prebuilt intents
This is the second of three ways to create the LUIS application for the shopping list bot. You will start with prebuilt intents LUIS provides. Afterward, you will need to add some more intents by hand.
- Create a new LUIS application by clicking the '+ New app' button.
- Create a new app
- In the 'Create new app' prompt, enter a new name for your LUIS application, for example, 'Shopping List'.
- For culture, this documentation uses 'English'. The culture tells LUIS what language it can expect for the messages we will send to it. You could use a different culture. However, this will be more work for you later because you will need to remember to translate some of the later instructions.
- Add a small description to your app.
- Lastly, select the prediction resource you created earlier from the dropdown.
- When everything is filled out, click 'Done'.
- After the LUIS application is created, it will open automatically. You can click through the getting started documentation or close it.
LUIS provides prebuilt intents and entities that you can use if they fit your domain. It has some prebuilt intents for the ToDo domain, a great starting point for the shopping list bot.
- Click on the '+ Add prebuilt domain intent' button, which will show you all the available prebuilt intents.
- Type 'Todo' in the search bar of the 'Add prebuilt domain models' prompt. Of the prebuilt intents select 'ToDo.AddToDo', 'ToDo.DeleteToDo', 'ToDo.MarkToDo' and 'ToDo.ShowToDo'. When you have the four checkboxes selected click 'Done'.
- You should now see the four prebuilt intents and the 'None' intent in the list.
- Rename the four prebuilt intents so they match with the naming the bot will use. Rename 'ToDo.AddToDo' to 'AddItem', 'ToDo.DeleteToDo' to 'Remove Item', 'ToDo.MarkToDo' to 'MarkItem' and 'ToDo.ShowToDo' to 'GetAll'.
- Set the checkbox in front of one prebuilt intent.
- Click the 'Rename' button. It is in the row with the search bar.
- In the 'Rename Intent' Name field, enter the new name and click 'Done'.
- Repeat step 4. until you have all four prebuilt intents renamed.
- Now navigate to the entities page by clicking on 'Entities' in the left navigation list.
- Three prebuilt entities have been added with the prebuilt intents. If your entities list is empty, refreshing the website should help. You are going to rename 'ToDo.TaskContent' to 'ItemName' and 'ToDo.TaskContent.Any' to 'ItemName.Any'. This is done through the same steps as renaming intents. After renaming, your entities page should look like the following.
- Now, you have a great starting point of intents and entities, which you can extend by adding your own intents and entities specific to the shopping list bot functionality. For this, you will need to follow some steps of the third path.
- Number entity while the prebuilt ordinal entity is already there, you still need to add the prebuilt number entity.
- Create UnitName entity so LUIS can recognize common units when it comes to food.
- Create RemoveAll intent, which is not included in the prebuilt ToDo domain. This is a functionality the bot provides.
- Create UnmarkItem intent The prebuilt ToDo domain includes a mark item intent you already added. The bot also provides the reverse functionality unmarking an item. You need to create one last intent before you can move on to the next part of this workshop.
- If you have all 4 bullet points listed above from the third path completed, you can move on to the next part of the workshop.
Train LUIS
NEXT:[THIRD PATH] LUIS application from scratch
This is the third way to create the LUIS application. You will create all your intents and entities by hand.
- Create a new LUIS application by clicking the '+ New app' button.
- Create a new app
- In the 'Create new app' prompt, enter a new name for your LUIS application, for example, 'Shopping List'.
- For culture, you can use 'English'. The culture tells LUIS what language it can expect for the messages. You could use a different culture. However, this will be more work for you later because you will need to remember to translate some of the other instructions.
- Add a small description to your app.
- Lastly, select the prediction resource you created earlier from the dropdown.
- When everything is filled out, click 'Done'.
- After the LUIS application is created, it will open automatically. You can click through the getting started documentation or close it.
[THIRD PATH] First, we will define the entities we want LUIS to recognize
- Navigate to the 'Entities' Page by clicking on it in the left navigation list.
[THIRD PATH] Create ItemName entity
Create an entity called 'ItemName', representing the part of a text that should be added to the shopping list.
- On the 'Entities' page, click '+ Create'.
- In the 'Create an entity' prompt, give the new entity the name 'ItemName' and leave the type as Machine Learned. Machine Learned means that LUIS should learn what we mean by ItemName from examples using machine learning algorithms. Click the 'Create' button, and the new entity should show up if you go to the 'Entities' page again.
[SECOND & THIRD PATH] Add prebuilt ordinal and number entity
The bot should be able to recognize the quantity of an item for the shopping list. For this, LUIS needs to be able to recognize numbers. LUIS provides prebuilt entities for numbers. You also want the bot to know which item in the shopping list the user might reference by position (1st, second, ...). For this, we can use the prebuilt ordinal entity.
- On the 'Entities' page, click 'Add prebuilt entity'.
- In the 'Add prebuilt entities' prompt, scroll down until you find 'number' and 'ordinal'. Make sure both are selected. Click 'Done' to add them to your LUIS application.
[SECOND & THIRD PATH] Create UnitName entity
When a chat participant adds an item to the shopping list, they should be able to specify a unit (e.g., kg, pounds, etc.) for the item. Hence, you need one more entity so LUIS can recognize these units.
- On the 'Entities' page, click '+ Create'.
- In the 'Create an entity' prompt, type in name 'UnitName' and as type select 'List'. List means that this entity will be a fixed set you will have to define next. Before you do that, click 'Create'.
- After the UnitName entity is created, it should automatically open. Here you define the list of units and for each unit optional synonyms. LUIS will take care to recognize the units even if they are differently capitalized than defined. Here are the units that you should enter.
Normalized values | Synonyms |
---|---|
gram | grams, g |
kilogram | kilograms, kg |
milligram | milligram s, mg |
ounce | ounces |
pound | pounds |
gallon | gallons |
liter | liters, l |
milliliter | milliliter, ml |
This is how the unit list looks like after typing in all the values.
Now you are ready to define the intents you want LUIS to recognize
- Navigate to the 'Intents' page. There should be a 'None' intent. The 'None' intent tells LUIS example sentences that are not a command in our domain. After creating new intents for the positive cases where LUIS should recognize commands, you can add some everyday sentences.
[THIRD PATH] Creating AddItem Intent
LUIS should recognize if a text is a command to add a new item to a list and extract all the new item information from the text.
- Click '+ Create' on the LUIS 'Intents' page to create a new intent.
- As the name type in 'AddItem' and click 'Done'
- Once created, the page for the 'AddItem' intent will open, and you can train LUIS by typing in sentences you want it to associate with adding an item.
- In the textbox below 'Example User Input', type in a sentence like 'add two kilograms of flour' and hit enter.
- Once it is submitted, you can see it in the list of example sentences. You also see that LUIS can already recognize some entities like 'two' as a number and 'kilograms' as UnitName because they are underlined. However, LUIS does not yet know about the ItemName, which in this case should be flour. Click on 'flour' in the example sentence so that it gets selected. By dragging the brackets, you could extend the selection. For this example, sentence you only want it to extract 'flour' as the ItemName, so the selection should be good. The flyout presented below the selected 'flour' word shows all the custom entities you can mark this word as for LUIS to learn that words like it belong to this entity class. Click on 'ItemName' because this is the entity 'flour' should be classified as.
- Now, 'flour' is marked as 'ItemName' entity. You should train LUIS with more examples so it can get better. Below the image is a list of examples for you to get started. Of course, you can get creative and enter sentences about how you would add something to a list. Please share your sentences by creating an issue in this repository.
Example sentence | ItemName | number | UnitName |
---|---|---|---|
create a task to get green beans from the grocery store | green beans | ||
please add two cans of chopped tomatoes | chopped tomatoes | two | |
put ice cream on the grocery list | ice cream | ||
put caramel cheese popcorn on my grocery shopping list | caramel cheese popcorn | ||
remind me to buy milk | milk | ||
remind me to get 2 pounds of apples | apples | 2 | pounds |
please add heavy cream to the list | heavy cream | ||
to grocery list add 12 eggs | eggs | 12 | |
remind me to get a liter cooking oil | cooking oil | liter |
[THIRD PATH] Creating GetAll Intent
LUIS should recognize if a text is a command to get all items in the list.
- Click '+ Create' on the LUIS 'Intents' page to create a new intent.
- As the name type in 'GetAll' and click 'Done'
- Once created, the page for the 'GetAll' intent will open, and you can train LUIS by typing in example sentences you want it to associate with getting all items from the shopping list.
- In the textbox below 'Example User Input', type in a sentence like 'what do i have to buy on the shopping list' and hit enter.
- Once it is submitted, you can see it in the list of example sentences. For this intent, you do not need to mark any entities because there are no entities to extract. LUIS should just know which kind of sentences mean that all items in the list should be shown.
- You should train LUIS with more examples so it can get better. Below is a list of examples for you to get started. Of course, you can get creative and enter sentences about how you would like to ask a shopping list to tell you all its items. Please share with which sentences you produce by creating an issue in this repository.
Example sentence |
---|
get all items |
show me my shopping list |
get everything on my shopping list |
what do i need to buy in the shopping list |
what is on my shopping list |
would you bring up my shopping list |
please show me my shopping list items |
can you show my shopping list |
all shopping list |
[THIRD PATH] Creating MarkItem Intent
LUIS should recognize if a text is a command to mark an item in the list as completed and extract information about which item should be marked.
- Click '+ Create' on the LUIS 'Intents' page to create a new intent.
- As the name type in 'MarkItem' and click 'Done'
- Once created, the page for the 'MarkItem' intent will open, and you can train LUIS by typing in sentences you want it to associate with marking an item as completed.
- In the textbox below 'Example User Input', type in a sentence like 'mark bananas as completed' and hit enter.
- LUIS should extract which item to mark as completed. Click on 'bananas' in the example sentence so that it gets selected. By dragging the brackets, you could extend the selection. For this example, sentence you only want it to extract 'bananas' as the ItemName, so the one-word selection is good. The flyout presented below the selected 'bananas' word shows all the custom entities you can mark this word as for LUIS to learn that words like it belong to this entity class. Click on 'ItemName' because the entity 'bananas' should be classified in this sentence.
- Now 'bananas' is marked as 'ItemName' entity. You should train LUIS with more examples so it can get better. Below the image is a list of examples for you to get started. Of course, you can get creative and enter sentences about how you would mark an item in a shopping list as completed. Please share with which sentences you produce by creating an issue in this repository.
Example sentence | ItemName | ordinal |
---|---|---|
task completed buy gum | gum | |
cross apples off my shopping list | apples | |
the 3rd task finished | 3rd | |
mark the second task as completed | second | |
buying orange juice is done | orange juice | |
mark task buy a bottle of vinegar as finished | vinegar | |
mark salad on the groceries list | salad | |
completed buying red onions | red onions | |
mark pancake mix on my to-do list | pancake mix |
[THIRD PATH] Creating RemoveItem Intent
LUIS should recognize if a text is a command to remove an item from the shopping list. You also need to train LUIS to find out which item should be removed.
- Click '+ Create' on the LUIS 'Intents' page to create a new intent.
- As the name type in 'RemoveItem' and click 'Done'
- Once created, the page for the 'RemoveItem' intent will open, and you can train LUIS by typing in sentences you want it to associate with removing an item.
- In the textbox below 'Example User Input', type in a sentence like 'shopping list delete pineapple' and hit enter.
- You also want LUIS to extract which item should be removed. Click on 'pineapple' in the example sentence so that it gets selected. By dragging the brackets, you could extend the selection. For this example, sentence you only want it to extract 'pineapple' as the ItemName. The flyout presented below the selected 'pineapple' word shows all the custom entities you can mark this word as for LUIS to learn that words like it belong to this entity class. Click on 'ItemName' because this is the entity you want 'pineapple' to be part of.
- Now, 'pineapple' is marked as 'ItemName' entity. You should train LUIS with more examples so it can get better. Below the image is a list of examples for you to get started. Of course, you can get creative and enter sentences about how you remove an item from a shopping list. Please share with which sentences you produce by creating an issue in this repository.
Example sentence | ItemName | ordinal |
---|---|---|
take coffee off my groceries list | coffee | |
remove peanuts | peanuts | |
todo list delete trail mix | trail mix | |
remove tomato sauce from grocery list | tomato sauce | |
delete mushrooms | mushrooms | |
delete the first item in my shopping list | first | |
remove the 7th shopping list item | 7th | |
remove third | third | |
erase limes from shopping list | limes |
[SECOND & THIRD PATH] Creating RemoveAll Intent
LUIS should recognize if a text is a command to remove all items from the list.
- Click '+ Create' on the LUIS 'Intents' page to create a new intent.
- As the name type in 'RemoveAll' and click 'Done'
- Once created, the page for the 'RemoveAll' intent will open, and you can train LUIS by typing in sentences you want it to associate with removing all items from the shopping list.
- In the textbox below 'Example User Input', type in a sentence like 'remove all items from my shopping list' and hit enter.
- Once it is submitted, you can see it in the list of example sentences. For this intent, you do not need to mark any entities because LUIS does not need to extract any input. LUIS should just know which kind of sentences means that to remove all items from the list.
- You should train LUIS with more examples so it can get better. Below is a list of examples for you to get started. Of course, you can get creative and enter sentences about how you would like to ask a shopping list to remove all its items. Please share with which sentences you produce by creating an issue in this repository.
Example sentence |
---|
remove everything |
delete all items from my list |
delete all |
clear my shopping list |
please remove all tasks |
shopping list delete everything |
remove every item in my todo list |
delete my shopping list completely |
delete my entire list |
[SECOND & THIRD PATH] Creating UnmarkItem Intent
LUIS should recognize if a text is a command to mark an item in the list as NOT completed and extract information about which item should be unmarked.
- Click '+ Create' on the LUIS 'Intents' page to create a new intent.
- As the name type in 'UnmarkItem' and click 'Done'
- Once created, the page for the 'UnmarkItem' intent will open, and you can train LUIS by typing in sentences you want it to associate with unmarking an item.
- In the textbox below 'Example User Input', type in a sentence like 'mark spinach as not completed' and hit enter.
- You also want LUIS to extract which item should be marked as NOT completed. Click on 'spinach' in the example sentence so that it gets selected. By dragging the brackets, you could extend the selection. For this example sentence, we only want it to extract 'spinach' as the ItemName, so you do not need to extend the selection. The flyout presented below the selected 'spinach' word shows all the custom entities you can mark this word as for LUIS to learn that words like it belong to this entity class. Click on 'ItemName' because this is the entity you want 'spinach' to be part of.
- Now, 'spinach' is marked as 'ItemName' entity. You should train LUIS with more examples so it can get better. Below the image is a list of examples for you to get started. Of course, you can get creative and enter sentences how you would mark something on a list as not completed. Please share which sentences you produce by creating an issue in this repository.
Example sentence | ItemName | ordinal |
---|---|---|
set fifth task as not finished | fifth | |
task not completed buy red cabbage | red cabbage | |
the 2nd task is not done | 2nd | |
uncheck cheese in my shopping list | cheese | |
unmark kidney beans | kidney beans | |
please set red lentils in my shopping list as not done | red lentils | |
shopping list unmark romaine lettuce | romaine lettuce | |
rice uncheck | rice | |
untick cucumber on my list | cucumber |