Search code examples
nlpazure-language-understandingnlu

How to correctly use LUIS ML-features?


I just stumbled over the new "ML-features" in LUIS and I am not sure if I really understand how to use them correctly. The documentation seems very abstract and vague to me:

https://learn.microsoft.com/de-de/azure/cognitive-services/luis/luis-concept-feature

Besides a good general explanation a solution for the following example would be very welcome:

Example

Intent: OpenABox

Sample utterances: "open the green box", "open the azure box".

Entity: ColorEntity (no prebuilt entity).

The color should understand "green", "blue", "azure" and "olive", where "olive" should be regarded as synonym to "green" and "azure" to "blue".

Solution Proposal

I assume you would have to

  • Add an intent
  • Add a list-entity, that lists all colors and assigns their synonyms?
  • Add a phrase list, that again lists some, but maybe not all, colors, without respect to their meaning?
  • Make the ML-feature global?
  • Mark the values as interchangable?
  • Add a ML-entity, and assign the list entity as well as the phrase list as features?
  • Make the list-entity-feature required?
  • Add sample utterances and mark the entities with the list-entity? Or with the ML-entity? Or both?
  • Add the ML-Entity as feature to the intent? Or the phrase list? Or the list-entity? Or none at all?

Is it correct, that there is no way to confirm the correct resolution of "olive" to its canonical form "green" using the test panel? So I have to use the API to test this?

The Model

This model has been created as described above. It seems to do its job. But is this really the optimal way to do it? There seems to be a lot of redundancy in there.

{
  "luis_schema_version": "7.0.0",
  "intents": [
    {
      "name": "None",
      "features": []
    },
    {
      "name": "OpenABox",
      "features": [
        {
          "modelName": "ColorMLEntity",
          "isRequired": false
        }
      ]
    }
  ],
  "entities": [
    {
      "name": "ColorMLEntity",
      "children": [],
      "roles": [],
      "features": [
        {
          "featureName": "ColorPhraseList",
          "isRequired": false
        },
        {
          "modelName": "ColorListEntity",
          "isRequired": true
        }
      ]
    }
  ],
  "hierarchicals": [],
  "composites": [],
  "closedLists": [
    {
      "name": "ColorListEntity",
      "subLists": [
        {
          "canonicalForm": "green",
          "list": [
            "olive"
          ]
        },
        {
          "canonicalForm": "blue",
          "list": [
            "azure"
          ]
        }
      ],
      "roles": []
    }
  ],
  "prebuiltEntities": [],
  "utterances": [
    {
      "text": "open the azure box",
      "intent": "OpenABox",
      "entities": [
        {
          "entity": "ColorMLEntity",
          "startPos": 9,
          "endPos": 13,
          "children": []
        }
      ]
    },
    {
      "text": "open the green box",
      "intent": "OpenABox",
      "entities": [
        {
          "entity": "ColorMLEntity",
          "startPos": 9,
          "endPos": 13,
          "children": []
        }
      ]
    }
  ],
  "versionId": "0.1",
  "name": "ColorTest",
  "desc": "",
  "culture": "en-us",
  "tokenizerVersion": "1.0.0",
  "patternAnyEntities": [],
  "regex_entities": [],
  "phraselists": [
    {
      "name": "ColorPhraseList",
      "mode": true,
      "words": "green,blue,azure,olive",
      "activated": true,
      "enabledForAllModels": false
    }
  ],
  "regex_features": [],
  "patterns": [],
  "settings": []
}

Solution

  • Features are supposed to be signals relevant to an intent, or an entity. So for this example,

    • Create an ML entity "ColorEntity",
    • Label the utterances
    • Add ColorEntity as a feature for the intent
    • Then you can add a feature to ColorEntity, either a list entity or phrase list, no need for both.