0

我正在使用 RASA 构建一个天气机器人,并希望我的模型能够将位置提取为实体。我的模型无法识别训练数据之外的位置。所以,我决定为其他实体使用查找表。

我按照博客文章使用查找表进行实体提取并使用查找表通过在数据文件夹下创建查找“.txt”文件来识别训练数据中的位置实体。

这就是我的训练数据的样子:

{
  "rasa_nlu_data": {
    "lookup_tables": [
    {
        "name": "location",
        "elements": "data/location.txt"
    }
]
    "common_examples": [
      {
        "text": "Hello",
        "intent": "greet",
        "entities": []
      },
      {
        "text": "goodbye",
        "intent": "goodbye",
        "entities": []
      },
      {
        "text": "What's the weather in Berlin at the moment?",
        "intent": "inform",
        "entities": [
          {
            "start": 22,
            "end": 28,
            "value": "Berlin",
            "entity": "location"
          }
        ]
      },
      {
        "text": "hey",
        "intent": "greet",
        "entities": []
      },
      {
        "text": "hello",
        "intent": "greet",
        "entities": []
      },
      {
        "text": "hi",
        "intent": "greet",
        "entities": []
      },
      {
        "text": "heya",
        "intent": "greet",
        "entities": []
      },
      {
        "text": "howdy",
        "intent": "greet",
        "entities": []
      },
      {
        "text": "hey there",
        "intent": "greet",
        "entities": []
      },
      {
        "text": "bye",
        "intent": "goodbye",
        "entities": []
      },
      {
        "text": "goodbye",
        "intent": "goodbye",
        "entities": []
      },
      {
        "text": "bye bye",
        "intent": "goodbye",
        "entities": []
      },
      {
        "text": "see ya",
        "intent": "goodbye",
        "entities": []
      },
      {
        "text": "see you later",
        "intent": "goodbye",
        "entities": []
      },
      {
        "text": "What's the weather today?",
        "intent": "inform",
        "entities": []
      },
      {
        "text": "What's the weather in London today?",
        "intent": "inform",
        "entities": [
          {
            "start": 22,
            "end": 28,
            "value": "London",
            "entity": "location"
          }
        ]
      },
      {
        "text": "Show me what's the weather in Paris",
        "intent": "inform",
        "entities": [
          {
            "start": 30,
            "end": 35,
            "value": "Paris",
            "entity": "location"
          }
        ]
      },
      {
        "text": "I wonder what is the weather in Vilnius right now?",
        "intent": "inform",
        "entities": [
          {
            "start": 32,
            "end": 39,
            "value": "Vilnius",
            "entity": "location"
          }
        ]
      },
      {
        "text": "what is the weather?",
        "intent": "inform",
        "entities": []
      },
      {
        "text": "Tell me the weather",
        "intent": "inform",
        "entities": []
      },
      {
        "text": "Is the weather nice in Barcelona today?",
        "intent": "inform",
        "entities": [
          {
            "start": 23,
            "end": 32,
            "value": "Barcelona",
            "entity": "location"
          }
        ]
      },
      {
        "text": "I am going to London today and I wonder what is the weather out there?",
        "intent": "inform",
        "entities": [
          {
            "start": 14,
            "end": 20,
            "value": "London",
            "entity": "location"
          }
        ]
      },
      {
        "text": "I am planning my trip to Amsterdam. What is the weather out there?",
        "intent": "inform",
        "entities": [
          {
            "start": 25,
            "end": 34,
            "value": "Amsterdam",
            "entity": "location"
          }
        ]
      },
      {
        "text": "Show me the weather in Dublin, please",
        "intent": "inform",
        "entities": [
          {
            "start": 23,
            "end": 29,
            "value": "Dublin",
            "entity": "location"
          }
        ]
      },
      {
        "text": "in London",
        "intent": "inform",
        "entities": [
          {
            "start": 3,
            "end": 9,
            "value": "London",
            "entity": "location"
          }
        ]
      },
      {
        "text": "Lithuania",
        "intent": "inform",
        "entities": [
          {
            "start": 0,
            "end": 9,
            "value": "Lithuania",
            "entity": "location"
          }
        ]
      },
      {
        "text": "Oh, sorry, in Italy",
        "intent": "inform",
        "entities": [
          {
            "start": 14,
            "end": 19,
            "value": "Italy",
            "entity": "location"
          }
        ]
      },
      {
        "text": "Tell me the weather in Vilnius",
        "intent": "inform",
        "entities": [
          {
            "start": 23,
            "end": 30,
            "value": "Vilnius",
            "entity": "location"
          }
        ]
      },
      {
        "text": "The weather condition in Italy",
        "intent": "inform",
        "entities": [
          {
            "start": 25,
            "end": 30,
            "value": "Italy",
            "entity": "location"
          }
        ]
      },
      {
        "text": "I am going to Barcelona",
        "intent": "inform",
        "entities": [
          {
            "start": 14,
            "end": 23,
            "value": "Barcelona",
            "entity": "location"
          }
        ]
      },
      {
        "text": "I'm planning a trip to Barcelona",
        "intent": "inform",
        "entities": [
          {
            "start": 22,
            "end": 32,
            "value": " Barcelona",
            "entity": "location"
          }
        ]
      },
      {
        "text": "I am going to Barcelona. I wonder what is the weather out there?",
        "intent": "inform",
        "entities": [
          {
            "start": 13,
            "end": 23,
            "value": " Barcelona",
            "entity": "location"
          }
        ]
      },
      {
        "text": "What is the weather in Argentina?",
        "intent": "inform",
        "entities": [
          {
            "start": 23,
            "end": 32,
            "value": "Argentina",
            "entity": "location"
          }
        ]
      },
      {
        "text": "I am planning a trip to Paris and I wonder what is the weather out there?",
        "intent": "inform",
        "entities": [
          {
            "start": 24,
            "end": 29,
            "value": "Paris",
            "entity": "location"
          }
        ]
      }
    ]
  }
}

我的查找表有一个新行中的每个位置的名称。

但是,当我运行“rasa train nlu”时,出现以下错误:“路径“数据”中不包含有效的 NLU 数据。请验证数据格式。现在将跳过 NLU 模型训练。 ”可能是什么原因 ?我只做了博客里说的。请告诉我哪里出错了。提前致谢

4

1 回答 1

1

这实际上与查找无关,通过加载您的数据,我可以看到您在查找和常见示例之间缺少逗号,它应该如下所示:

{
  "rasa_nlu_data": {
    "lookup_tables": [
    {
        "name": "location",
        "elements": "data/location.txt"
    }
],
    "common_examples"
...

这表明您可能正在手动编写/编辑 json;rasa data convert如果需要,请考虑使用降价并使用来获取 json

于 2020-06-12T16:31:02.817 回答