我正在使用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从这个文件,我可以把它安装到我的剪贴画-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?")发布于 2019-08-08 13:41:21
我可以看到两个解决办法:
重列
其中一种方法是使用使用附加实体值更新的数据集动态地重新训练engine。这可能是一个合理的解决方案,如果您的数据集不是太大,因为培训将相当快。
改进数据集
另一种解决方案是在yaml文件中提供更多的意图公式,以便生成的engine能够提取不可见的实体值。在您的例子中,您只提供了两个公式,其中实体是最后一个令牌。此外,您提供的实体值仅为unigram。由于这些原因,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 sproutshttps://stackoverflow.com/questions/57295654
复制相似问题