Hackernoon logoHow To Train Your Robot — AI For Everyone by@burkeholland

How To Train Your Robot — AI For Everyone

Burke H0lland Hacker Noon profile picture

@burkehollandBurke H0lland

Senior Developer Advocate

In the movie “How To Train Your Dragon”, the characters live on an island called “Berk” (Thanks, Stephanie Ehrenberg), and they learn that dragons are not evil, they are just “misunderstood”, and you can train them and ride on them and stuff and they won’t eat you.

The only thing that movie and this article have in common is that my name is actually Burke (spelled CORRECTLY) and I needed a title. Also I trained a robot this week and I’m feeling pretty good about it.

I’ve been working a lot with the Natural Language Processing in Azure. Azure calls this service LUIS. So LUIS is my robot and I have trained it to understand me when I ask it to turn lights on or off in a specific room. In the process I learned a few things…

  • Artificial Intelligence can by crazy smart, but you really gotta train it
  • Machine Learning tools have come a LONG way
  • If you don’t eat breakfast and drink a lot of coffee, make sure you stay near a bathroom

Let’s take a look at how to teach LUIS to process a simple command like, “Turn the kitchen lights off”.


Microsoft exposes the LUIS service through the luis.ai site. You don’t have to have an Azure account to use it, but you do need to have an email address. If you don’t have an email address then your name is likely “Brenden Frasier”. But I specifically mean “Blast From The Past” Brenden Frasier.

LUIS operates on two main concepts — Intents and Entities. An Intent is a specific action or idea from a user. They could vocalize that action in a number of different ways, but their underlying “intent” remains the same. For instance, in the case of “Turn the kitchen lights on”, the user might try and do this one of several different ways, including but not limited to…

  • Turn on the kitchen lights
  • Turn the lights on in the kitchen
  • Turn on the lights in the kitchen
  • Kitchen lights. On. NOW.

The entities are the pieces of information that we want to parse out of the intent. In this case, it’s Location (i.e. kitchen, living room, pool house — just kidding, I don’t have a pool house. I barely have a house house) and Light State (on or off).

The LUIS site is pretty simple to use. It’s hard for even me to screw it up.

I put two and two together and realized I need to click the “Create New Intent” button.

Then it wants you to enter in some utterances. The world “utterance” has got to be the least majestic word in the english language. Nobody has ever said, “I enjoy listening to your utterances”. Or maybe they have and you have been on that bad date.

I started with 3 that I listed above.

Now it wants you to create some entities and label the parts of the utterance that you want to extract. You do that by just mousing over the words and assigning the entities to them. I created my two entities as simple entities. You can create lots of other types of entities, but I don’t fully understand what they are and you should probably check the docs.

Now I can label my utterances with entities. You do this by just clicking on a word and labeling it by selecting the entity. When I’m done it looks like this…

Now we get the “train” the model. This is my favorite part because it involves just clicking the “Train” button and then going to twitter to brag about how I’m a data scientist.

Now we get to test our model. This is where things get fun and interesting. Clicking the “Test” button opens a little side panel where I can enter an utterance. Clicking on the utterance after I’ve entered it opens another panel where we can see what LUIS makes of it.

It works! Now let’s get down to the business of seeing if we can fool this AI.

If I say “please turn off the kitchen lights”, LUIS only picks up the location.

Which makes me wonder if LUIS even knows that off is a valid choice for Light State.

Nope. I need to add an utterance to the model to handle that.

let’s re-train and try again. Each time we make changes to the model like adding utterances, we have to click the “Train” button again. Also another good time to do some more bragging on Twitter.

Looking better! What happens if we try a room that has two words. Something like “living room”.

It can’t handle that at all. So we add another utterance and label “living room” as “location”.

Now it works, but if I switch it up and say “Turn off the living room lights”, LUIS only gets the location. More training!

After spending about an hour trying to fool the robot, I have the following utterances and labels.

And it’s pretty rock solid. I can give it almost utter nonsense and it can pick out the room and the light state.

Well, sometimes…

I guess I need to train this robot in the fine art of memery.

Once I’m done, LUIS exposes this AI from a simple HTTP endpoint. I can then use that to create a bot or consume it from my application. I used Azure Bot Service along with Twilio and a serverless Azure Function to create a text bot. Behold the glory!

Train Your Own

I enjoyed learning how to use LUIS. More than anything I’m encouraged because I feel like, “I can do this!”. I’ve been super skeptical of AI and Machine Learning for the sole reason that it feels like you have to be a theoretical physicist to figure it out and I can barely tie my shoes.

The tooling is getting to the point where we can start building AI into our apps, and you don’t have a Phd to do it.

You can train your own robot by heading over to luis.ai.


Join Hacker Noon

Create your free account to unlock your custom reading experience.