【问题标题】:Can I add more data to snips-nlu on the fly?我可以即时向 snips-nlu 添加更多数据吗?
【发布时间】:2019-07-31 16:52:07
【问题描述】:

我正在使用 snips-nlu 创建一个“简单”的聊天机器人来管理某些任务。但我似乎缺乏对如何(如果可能的话)在运行时添加新意图的理解。

我面临的问题是假设我的 yaml 文件中有以下内容:

type: intent
name: questionAboutFood
slots:
  - name: foodType
    entity: foodType
utterances:
  - what color is a [foodType]
  - where can I buy a [foodType]
---
type: entity
name: foodType
automatically_extensible: yes
values:
  - banana
  - apple
  - orange

从这个文件中,我可以将它安装到我的 snips-nlu 引擎中。 但是我如何在运行时附加更多的 foodTypes?

代码:

from snips_nlu import SnipsNLUEngine
from snips_nlu.default_configs import CONFIG_EN
import io
import json

seed = 42
engine = SnipsNLUEngine(config=CONFIG_EN, random_state=seed)
with io.open("dataset.json") as f:
    dataset = json.load(f)
engine.fit(dataset)
parsing = self.engine.parse("what color is the apple?")

【问题讨论】:

    标签: python-3.x nlp dataset yaml chatbot


    【解决方案1】:

    我可以看到两种解决方法:

    重新训练

    一种方法是动态地重新训练engine,使用附加实体值更新的数据集。如果您的数据集不是太大,这可能是一个合理的解决方案,因为训练会很快。

    改进数据集

    另一种解决方案是在 yaml 文件中提供更多关于您的意图的表述,以便生成的 engine 能够提取看不见的实体值。 在您的情况下,您只提供了两个公式,其中实体是最后一个标记。此外,您提供的实体值只是一元组。由于这些原因,当实体跨越多个标记和/或位于句子中间时,NLU 引擎很可能无法捕获实体。

    这是一个稍微好一点的数据集,它已经可以更好地概括:

    type: intent
    name: questionAboutFood
    slots:
      - name: foodType
        entity: foodType
    utterances:
      - what color is a [foodType]
      - what is the color of an [foodType] in general
      - how much does an [foodType] cost
      - can you describe a [foodType] for me please
      - in which country is [foodType] generally found
      - where can I buy a [foodType]
      - how big are [foodType] in average
    
    ---
    type: entity
    name: foodType
    automatically_extensible: yes
    values:
      - banana
      - apple
      - orange
      - red meat
      - black eyed pea
      - brussels sprouts
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-19
      • 2014-01-07
      • 1970-01-01
      • 1970-01-01
      • 2021-02-17
      • 2011-01-31
      相关资源
      最近更新 更多