1

我已使用以下命令将从 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=稍后再订车

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

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

返回的意图是正确的,但它的实体对象是空的。正如您在下面的 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": []
  }
}
4

1 回答 1

5

如果您可以包含您在 Rasa 中使用的管道,那将会很有帮助。您可以在配置文件中找到它。假设您没有更改默认管道,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

于 2017-07-26T17:49:03.127 回答