我有一个rasa_nlu
的工作安装,在macOS High Sierra上运行Python 3.6.5。我能够让示例教程正常工作。我在使用同义词时遇到了麻烦。
这是我的培训文件first-model.md
的相关部分。
## intent:select
- what is the [max](operator) rating?
## synonym:max
- best
- highest
- maximum
现在,rasa_nlu
正确地检测了诸如what is the max rating?
之类的问题的意图和实体
{'intent': {'name': 'select', 'confidence': 0.9542820453643799},
'entities': [{'start': 12,
'end': 15,
'value': 'max',
'entity': 'operator',
'confidence': 0.8146240434922525,
'extractor': 'ner_crf'}],
'intent_ranking': [{'name': 'select', 'confidence': 0.9542820453643799},
{'name': 'identity', 'confidence': 0.036332450807094574}],
'text': 'what is the max rating?'}
但是,当我在问题中使用同义词时,它不会检测到实体。例如,what is the best rating?
{'intent': {'name': 'select', 'confidence': 0.9382177591323853},
'entities': [],
'intent_ranking': [{'name': 'select', 'confidence': 0.9382177591323853},
{'name': 'identity', 'confidence': 0.10226328670978546}],
'text': 'what is the best rating?'}
没有同义词的骰子。我和spacy_sklearn
和tensorflow_embedding
一起尝试了这个,看到了类似的结果。
非常感谢任何指针。
干杯。
更新:Per @ Caleb的建议如下,我将培训更新为:
## intent:select
- what is the [max](operator) rating?
- what is the [highest](operator:max) rating?
- what is the [maximum](operator:max) rating?
- what is the [best](operator:max) rating?
虽然它改善了这种情况,但它并没有完全解决问题。现在系统返回每个同义词(例如highest
,maximum
,best
)作为实体值而不是实际值(max
)。例如,如果我问what is the best rating?
,我希望max
作为实体值,而不是best
。不幸的是,系统返回best
。
{'intent': {'name': 'select', 'confidence': 0.9736428260803223},
'entities': [{'start': 12,
'end': 16,
'value': 'best',
'entity': 'operator',
'confidence': 0.9105035376516767,
'extractor': 'ner_crf'}],
'intent_ranking': [{'name': 'select', 'confidence': 0.9736428260803223},
{'name': 'identity', 'confidence': 0.0}],
'text': 'what is the best rating?'}
我偶然发现了一个适用于我的用例的组合。
json
格式代替markdown
作为训练数据(例如见下文)spacy_sklearn
管道而不是tensorflow_embedding
(例如见下文)我确信有一个很好的解释为什么这个组合有效,而其他人没有,但我还没有处理。或者,也许还需要其他配置才能使其他组合正常工作。
干杯。
这是训练数据的JSON版本。
{
"rasa_nlu_data": {
"common_examples": [
{
"text": "what is the best rating?",
"intent": "select",
"entities": [
{
"start": 12,
"end": 16,
"value": "max",
"entity": "operator"
}
]
},
{
"text": "what is the max rating?",
"intent": "select",
"entities": [
{
"start": 12,
"end": 15,
"value": "max",
"entity": "operator"
}
]
},
{
"text": "what is the highest rating?",
"intent": "select",
"entities": [
{
"start": 12,
"end": 19,
"value": "max",
"entity": "operator"
}
]
}
],
"regex_features" : [],
"entity_synonyms": [
{
"entity": "operator",
"value": "max",
"synonyms": ["maximum", "most", "highest", "biggest", "best"]
}
]
}
}
这是我使用的管道(感谢@Caleb建议也包括它)。
language: "en_core_web_md"
pipeline: "spacy_sklearn"