【问题标题】:Lookup table not working in training data of Rasa NLU查找表在 Rasa NLU 的训练数据中不起作用
【发布时间】:2019-05-14 10:29:37
【问题描述】:

我有一个特定意图的示例也显示了实体,我希望模型能够识别可能是该特定意图的实体的其他单词,但它无法识别它。

## intent: frequency
* what is the frequency of [region](field)?
* what's the frequency of[region](field)?
* frequency of [region](field)?
* [region](field)s frequency?
* [region](field) frequency?
* frequency [region](field)?

## lookup: field
* price
* phone type
* region

所以当我输入文本“区域的频率是多少?”时我得到了输出

{'intent': {'name': 'frequency', 'confidence': 0.9517087936401367},
'entities': [{'start': 17, 'end': 23, 'value': 'region', 
'entity': 'field', 'confidence': 0.9427971487440825, 
'extractor': 'CRFEntityExtractor'}], 'text': 'What is the frequency of region?'}

但是当我输入文本“价格的频率是多少?”时我得到了输出

{'intent': {'name': 'frequency', 'confidence': 0.9276150465011597},
'entities': [], 'text': 'What is the frequency of price?'}

【问题讨论】:

    标签: nlp markdown rasa-nlu


    【解决方案1】:

    根据 RasaNLU 文档,为了使查找工作,您需要包含查找表中的一些示例。

    另外,您需要了解“phone type”和“region”是不同的模式,因为“phone type”有两个词,“region”是一个词。牢记这一点,我已将您的数据集扩展为

    ## intent: frequency
    * what is the frequency of [region](field)?
    * what is the frequency of [city](field)?
    * what is the frequency of [work](field)?
    * what's the frequency of [phone type](field)?
    * what is the frequency of [phone type](field)?
    * frequency of [region](field)?
    * frequency of [phone type](field)?
    * [region](field)s frequency?
    * [region](field) frequency?
    * frequency [region](field)?
    

    现在,当我尝试了您提到的所有示例时,即使“价格”未包含在数据集中但所有模式都已涵盖,它们仍然有效。

    Enter a message: What is the frequency of price?
    {
      "intent": {
        "name": "frequency",
        "confidence": 0.966820478439331
      },
      "entities": [
        {
          "start": 25,
          "end": 30,
          "value": "price",
          "entity": "field",
          "confidence": 0.7227365687405007,
          "extractor": "CRFEntityExtractor"
        }
      ]
    }
    

    我建议使用https://github.com/rodrigopivi/Chatito 来生成简单的数据集,它会让您更轻松,并自动生成同义词等。

    此外,以防万一您不知道您还可以使用文件来指向大型查找,例如

    ## lookup:city
      data/lookups/city_lookup.txt
    
    
    

    【讨论】:

    • 如果我们提供一个文件进行查找,我们是否还需要为每次查找添加示例?
    • 文件只是列表的替代品,所以功能是一样的,但是当您有大量查找时它很有用。我使用了城市和州的查找,添加一些示例就足以让 rasa 完成它的工作。
    • 我已经尝试过了,似乎除非至少有一个查找示例,否则它不会检测到它。如果是这种情况,那么查找表将变得毫无用处,因为无论如何我们都需要为每个不同的实体值写下一个示例。
    • 我的城市和州的例子工作得很好......查找表中有超过 3k 个城市,我只需要添加 10 到 20 个的例子......感觉没那么没用。 ..
    • 你使用的是 tensorflow 还是 spacy 的管道?它可能有效,因为您使用的是 spacy。我正在使用 tensorflow,它似乎不起作用。
    【解决方案2】:

    在 config.yml 中使用以下管道

    管道:

    • 名称:WhitespaceTokenizer
    • 名称:RegexFeaturizer
    • 名称:CRFEntityExtractor
    • 名称:LexicalSyntacticFeaturizer
    • 名称:CountVectorsFeaturizer
    • 名称:CountVectorsFeaturizer 分析器:“char_wb” min_ngram: 1 max_ngram: 4
    • 名称:DIET分类器 实体识别:假 时代:100
    • 名称:EntitySynonymMapper
    • 名称:响应选择器 时代:100

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-22
      • 1970-01-01
      相关资源
      最近更新 更多