我已使用以下命令将从LUIS应用程序下载的json迁移为RASA格式:python -m rasa_nlu.train -c config_spacy.json

我的配置文件如下所示:

{
"path" : "./models",
"data" : "./data/examples/rasa/BookACab.json",
"pipeline" : ["nlp_spacy", "tokenizer_spacy", "intent_featurizer_spacy",
              "ner_crf", "ner_synonyms", "intent_classifier_sklearn",
              "ner_duckling"]
}


如下所示,使用RASA格式的json生成了一个模型。但是,当我使用


  http://localhost:5000/parse?q=book过一会儿


与我输入的文字及其所有相关实体相关的正确的高分意图。但是当我尝试另一个文本时:


  http://localhost:5000/parse?q=I今天下午5点想去骑


返回的意图是正确的,但其Entities对象为空。正如您在json下方看到的那样,这种话语也具有与工作示例类似的映射到它的实体。

请帮助我知道这是否是每个使用RASA的人都遇到的问题,还是我在做任何错误?谢谢!

  {
  "rasa_nlu_data": {
    "common_examples": [
      {
        "entities": [
          {
            "entity": "RideTime",
            "value": "later",
            "start": 0,
            "end": 5
          }
        ],
        "intent": "None",
        "text": "later"
      },
      {
        "entities": [],
        "intent": "ServiceRequestEnquiry",
        "text": "wake up"
      },
      {
        "entities": [],
        "intent": "ConfirmationNo",
        "text": "no not now"
      },
      {
        "entities": [],
        "intent": "ConfirmationNo",
        "text": "not sure"
      },
      {
        "entities": [],
        "intent": "ConfirmationNo",
        "text": "no bot"
      },
      {
        "entities": [],
        "intent": "ConfirmationNo",
        "text": "no goride bot"
      },
      {
        "entities": [
          {
            "entity": "RideTime",
            "value": "later",
            "start": 12,
            "end": 17
          }
        ],
        "intent": "BookCab",
        "text": "book a ride later"
      },
      {
        "entities": [
          {
            "entity": "RideTime",
            "value": "now",
            "start": 21,
            "end": 24
          }
        ],
        "intent": "BookCab",
        "text": "i want go for a ride now"
      },
      {
        "entities": [
          {
            "entity": "RideTime",
            "value": "today",
            "start": 12,
            "end": 17
          }
        ],
        "intent": "BookCab",
        "text": "book a ride today"
      },
      {
        "entities": [
          {
            "entity": "RideTime",
            "value": "today 5pm",
            "start": 18,
            "end": 27
          }
        ],
        "intent": "BookCab",
        "text": "I want to go ride today 5pm"
      },
      {
        "entities": [
          {
            "entity": "RideTime",
            "value": "today",
            "start": 12,
            "end": 17
          }
        ],
        "intent": "BookCab",
        "text": "book a ride today 5pm"
      },
      {
        "entities": [
          {
            "entity": "RideTime",
            "value": "later",
            "start": 13,
            "end": 18
          }
        ],
        "intent": "BookCab",
        "text": "book shuttle later"
      },
      {
        "entities": [
          {
            "entity": "RideTime",
            "value": "now",
            "start": 15,
            "end": 18
          }
        ],
        "intent": "None",
        "text": "i want to book now"
      },
      {
        "entities": [
          {
            "entity": "RideTime",
            "value": "booknow",
            "start": 10,
            "end": 17
          }
        ],
        "intent": "None",
        "text": "i want to booknow"
      },
      {
        "entities": [
          {
            "entity": "RideTime",
            "value": "book later",
            "start": 10,
            "end": 20
          }
        ],
        "intent": "None",
        "text": "i want to book later"
      }
    ],
    "regex_features": []
  }
}

最佳答案

如果可以包括您在Rasa中使用的pipeline,这将很有帮助。您可以在configuration文件中找到它。假设您尚未更改config_spacy.json中的默认管道,那么您将使用ner_crf进行实体识别。

由于库的差异,Rasa可能需要的培训数据比LUIS还要多。从质量上讲,mitie管道通常需要较少的培训数据,但是要权衡的是需要花费更多的时间进行培训。

因此,问题的基本答案是:如果要使用ner_crf,则需要增加为实体识别提供的训练数据量。

话虽这么说:RideTime是您唯一的实体吗?如果是这样,您应该考虑将ner_duckling添加到管道中,该管道可以识别日期。这比您尝试自己训练日期的效果更好。

因此,使用上面的训练数据和管道:

["nlp_spacy", "tokenizer_spacy", "intent_featurizer_spacy", "ner_crf", "ner_synonyms",  "intent_classifier_sklearn", "ner_duckling"]


结果如下:

{
    "entities": [
        {
            "additional_info": {
                "grain": "hour",
                "others": [
                    {
                        "grain": "hour",
                        "value": "2017-07-26T17:00:00.000Z"
                    }
                ],
                "value": "2017-07-26T17:00:00.000Z"
            },
            "end": 27,
            "entity": "time",
            "extractor": "ner_duckling",
            "start": 18,
            "text": "today 5pm",
            "value": "2017-07-26T17:00:00.000Z"
        }
    ],
    "intent": {
        "confidence": 0.5469262356494486,
        "name": "BookCab"
    },
    "intent_ranking": [
        {
            "confidence": 0.5469262356494486,
            "name": "BookCab"
        },
        {
            "confidence": 0.2812606328712321,
            "name": "None"
        },
        {
            "confidence": 0.08727531874740564,
            "name": "ConfirmationNo"
        },
        {
            "confidence": 0.0845378127319134,
            "name": "ServiceRequestEnquiry"
        }
    ],
    "text": "I want to go ride today 5pm"
}


完整的培训对我来说非常有效。只需添加更多培训示例即可。因此,当您进行更多测试时,如果遇到无法正常工作的示例,请将其添加到训练数据中并重新训练。因此,教您的模型处理更多不同的请求。

https://gist.github.com/wrathagom/7f05fbda75c785977bd07cd89e62ddd7

10-06 06:27