Natural Language Processing: What it IS and ISN’T

Source: Deep Learning on Medium

Natural Language Processing, or NLP, means different things to different people. NLP has several subtypes, including the ability to recognize words (speech-to-text or vice-versa), understand words (document topic recognition, sentiment analysis), and intelligently respond to words (chatbots). Here, I’m using the term “words” to mean either written or spoken language.

Slot-Filling and Intent:

Some people think programming skills for voice-activated home assistants like Amazon’s Alexa is NLP. But designing human interactions with these devices is actually what’s known as “slot-filling,” not natural language processing. Slot-filling is an important part of using existing NLP services, but on its own it’s not machine learning.

My eyes always go a little screwy when someone refers to Alexa programming as NLP

Intents are key to programming an Alexa skill. An Intent is basically what its name implies: something you want to have Alexa do. Intents use Slots for interactivity. A slot is a space Alexa uses to fill in a value. When you create an intent, you can use preexisting slot types like date and time, or you can create your own.

If you’ve ever played Mad Libs, you know what a slot is. It’s just a space to fill in a part of speech in a sentence. When you create an Intent for Alexa, you’re essentially creating your own Mad Lib. For instance, if you have a skill to launch a smart machine like a smart lawnmower, you might create an intent called SmartLawn that looked something like this:

Alexa, ask Smart Lawn to mow _____________ ______________.

Each of the above blanks is known as a slot. The first slot expects an area (e.g, side yard) while the second expects a time or date. So you might say to your device:

“Alexa, ask Smart Lawn to mow the backyard tomorrow morning at 8:00.”

While Amazon has a slot type for time and date, it doesn’t have one for areas of your yard. So you’d have to create a custom slot type (let’s call it “YardAreas”) that might include values like:

  • Front Yard
  • Left Side Yard
  • Right Side Yard
  • Backyard

That’s not NLP. That’s just defining and filling slots and, in this case, custom slot types. So what is NLP? This is a great definition from Amazon Comprehend’s FAQs:

Natural Language Processing (NLP) is a way for computers to analyze, understand, and derive meaning from textual information in a smart and useful way. By utilizing NLP, you can extract important phrases, sentiment, syntax, key entities such as brand, date, location, person, etc., and the language of the text.

That’s not NLP, but you’re still awesome:

Of course, behind the scenes, your Amazon device is absolutely using all sorts of advanced machine learning. Speech-to-text, natural language comprehension, background noise elimination, and a ton of other cool stuff that you don’t need to program, train, optimize or even worry about. Behind the scenes, Alexa is utilizing tools like Amazon Polly for text-to-speech, Amazon Transcribe for speech-to-text, Amazon Lex for all the chatbot things, and maybe even Amazon Comprehend for sentiment analysis or classification of what you’re asking Alexa to do.

While all of this is amazing (and a little creepy if you think about it), you didn’t create any of those services. You’re just instructing Alexa to use them. This is pretty awesome, but don’t kid yourself into thinking that you’re an NLP programmer. Instead, you should feel empowered by the realization that you don’t need a deep understanding of natural language processing, deep learning or advanced mathematics to take advantage of these services. Just embrace the fact that you can.

What’s actually happening behind the scenes of those services is something called Deep Learning. Deep Learning is a special type of machine learning that can learn both linear and nonlinear relationships between variables to make predictions on never-seen-before data. In a future post, I’ll discuss a few NLP applications using machine learning, most of which use deep learning like the Amazon services mentioned above.

This post just scratches the surface of popular misconceptions around NLP, I encourage you to dig a bit deeper and think about your own perceived uses of NLP. In a future post, I’ll go deeper into NLP applications that utilize machine learning, most of which involve deep learning, like the Amazon services mentioned above.