How Can Machine-Learning Features Improve Your Chatbot?

How Can Machine-Learning Features Improve Your Chatbot?

Define Data Traits To Augment Chatbot Learning

Introduction

When designing and creating a NLU Application, you really want to leverage overarching commonalities in data. This can expedite and improve your application’s machine learning.

Image for post
Example: A Phrase List Feature of Car Makes

See this as a process of sharing training data between different components of your NLU environment.

These components can be intents, entities, ML Composed Entities and more.

Tis overarching commonality is described as a feature.

The environment in which I am going to build and demonstrate the prototype is Microsoft LUIS. Features give LUIS cues on how to find different concepts in your data and how to distinguish those concepts.

In machine learning, a feature is a distinguishing trait or attribute of data that your system observes and learns through.

Features should be part and parcel of any LUIS schema designed.

LUIS supports both phrase lists and models as features:

  • Phrase List Feature
  • Using a Model (intent or entity) as a Feature.

The best way to illustrate the implementation and power of features is to walk through a basic example implementation of the two. A guide if you like.

Phrase List As A Feature

In this first example, I created a phrase list of vehicle manufacturers and names. To create an augmented list like this is quite fast, as the suggestions from LUIS is astonishing accurate.

Image for post
LUIS automatically creating suggestions to add to the phrase list feature.

As suggestions are trimmed and added to the Values, subsequent suggestions by LUIS improve drastically in accuracy and relevance. This I see as a significant value add of LUIS.

The next step is to create an entity called CarsEntity and add the phrase list called CarMakes as a machine learning feature.

Image for post
An Entity called CarsEntity is created and defined by adding as a Machine Learning Feature the Phrase List.

So far we have created the phrase list, and the entity. From here, the intent can be created, with example user utterances. And the entity added as a Machine learning feature.

As shown here below.

Image for post
The intent is created with a few examples of user input. The Entity is defined contextually in the utterance. The entity is also added as a ML Feature.

Conveniently, when the intents are listed, the added feature or features are listed per intent.

The feature or features linked to the intent is listed.

Once trained the configurate can be tested and the ML entity detection accuracy confirmed. Of course this does not stop us from adding more examples to the CarsEntity entity.

From the prototype, it is clear how these features can be shared and re-used for greater efficiency.

Let’s look at a second example which is slightly more complex…

Using A Model As A Feature Helping Other Models

That sounds confusing and superfluous, but shortly you will see the value of this…

In LUIS a machine-learning composite entity is is constituted of smaller sub-entities. This is used to indicate and define a concept which is present in the entity we are trying to define.

Image for post
Example Composite ML Entity

The value of the sub-entity acts as a feature to its parent.

Sub-entities can have both a phrase list or another entity as a feature.

So let’s look at a practical example to clarify what the goal is…

In this example we want to capture a delivery address. The parent entity in this case will be the delivery address.

The sub-entities are all on the same level, with no further nesting.

They are:

  • Street Number,
  • Street Name,
  • City,
  • State or Province,
  • County and
  • Postal Code.

Here below it is shown in a graphic fashion.

Image for post
The Composed ML Entity with six sub-entities.

From here we are going to create the other elements which constitute the LUIS application. This graphic shows how the pieces fit into each other.

Image for post

We have created the Composite ML Entity, next we create the Intent with a few example user utterances. The ML entity and sub-entities are defined within the user utterance examples.

Image for post
The intent ShippingDetail is shown here with example utterances which are annotated.

Now we have our intent and entity created, but let’s enrich it with a feature.

We are going to create a phrase list of towns and cities within South Africa.

What amazed me within LUIS, was the accuracy with which LUIS made suggestions of South African towns and cities.

Image for post
Phrase List of City & Town Names In South Africa

This phrase list can now be saved and made part of an entity called Cities. As shown below…

Image for post
Entity called Cities with the Phrase List added as a Machine Learning Feature.

The entity called Cities is enriched by this phrase list, and we can also add other examples within the entity. Or even add more phrase lists.

The entity Cities is added to the composite ML Entity of ShippingAddress. What makes this particularly interesting is that we can add the entity as a ML feature to a specific sub-entity. As seen here below…

Image for post
The entity of Cities is added to a particular sub-entity called City.

And lastly, the entity of Cities can also be added to the intent (ShippingDetail) created earlier.

Image for post
Machine Learning feature added to an intent.

The last step is to test the interface and see how it performs.

Conclusion

Microsoft LUIS is really at the forefront of creating new structures to define natural language parameters. Composite ML Entities is a big leap forward, and fueling this with dynamic phrase lists acting as machine learning features is astute indeed.

~ January 2021