我有一个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
进行了尝试,并且看到了相似的结果。
非常感谢您提出任何建议。
干杯。
更新: 根据以下@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?'}
答案 0 :(得分:1)
我偶然发现了一个适用于我的用例的组合。
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"
答案 1 :(得分:0)