【问题标题】:LUIS.ai json migrated to Rasa format json is not returning the entities but correct intent is returnedLUIS.ai json 迁移到 Rasa 格式 json 没有返回实体,但返回了正确的意图
【发布时间】:2017-07-26 14:52:06
【问题描述】:

我已使用以下命令将从 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"] 
}

使用 json 格式生成模型,如下所示。但是,当我使用

查询此模型时

http://localhost:5000/parse?q=book稍后再搭车

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

http://localhost:5000/parse?q=I今天下午 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": []
  }
}

【问题讨论】:

    标签: python json rasa-nlu


    【解决方案1】:

    如果您可以包含您在 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

    【讨论】:

    • 嗨 Caleb Keller,感谢您的及时和详尽的解释。添加“ner_duckling”确实解决了我的日期和时间问题,但问题仍然存在,如“我想预订”、“稍后”、“醒来”等话语。他们既没有返回正确的意图,也没有返回各自的实体。根据我提供的训练数据,您的模型是否也会发生这种情况?我该如何解决这个问题..请提出建议。
    • 我以为你说意图有效?我会尝试提供一个完整的工作训练集,但正如我所说,它只是需要更多的训练数据。
    • 实际上他们最初是在工作的。这是我在将您的解决方案标记为答案时现在观察到的新行为。感谢您提供的所有帮助。
    • 我为适合我的完整训练集添加了要点链接。
    • 谢谢。现在稳定了。
    猜你喜欢
    • 1970-01-01
    • 2023-02-09
    • 2018-08-04
    • 1970-01-01
    • 2022-11-04
    • 1970-01-01
    • 1970-01-01
    • 2012-11-29
    • 1970-01-01
    相关资源
    最近更新 更多