2017-08-28 65 views
0

使用Chatterbot的BestMatchAdapter,它将两个问题用相同的答案混淆。例如,培训ai.yml。BestMatchAdapter以相同的响应混淆了两个不同的问题

什么是ai?

人工智能是工程和科学的一个分支,致力于构建思维机器。

什么是笑话?

人工智能是工程和科学的一个分支,致力于构建思维机器。

在otherhand,以下类似的问题没什么意义的BOT答案:

可以弯曲?

不,我可以无限期地延续下去。

你能说谎吗?

不,我可以无限期地延续下去。

回答

1

@taiwotman我不知道你已经训练语料文件。简而言之,最佳匹配算法就是这样工作的,Bot会迭代你已经训练过的所有语句。

closest_match.confidence = 0 

# Find the closest matching known statement 
for statement in statement_list: 
    confidence = self.compare_statements(input_statement, statement) 

    if confidence > closest_match.confidence: 
     statement.confidence = confidence 
     closest_match = statement 

聊天机器人使用默认的说法比较算法是levenshtein_distance

在您的例子,该方案是这样的

confidence = self.compare_statements('What is ai?', 'what is ai') 

在这个信心是1.0,您将得到回答Artificial Intelligence is the branch of engineering and science devoted to constructing machines that think.

我想你对这种情况感到困惑。 chatterbot default threshold values is 65%。在所有对有更大信心的声明中,那么它将成为回应。

confidence = self.compare_statements('What is ai?', 'What is a joke?') 

在这个信心是0.77是大于0.65,您将得到回答Artificial Intelligence is the branch of engineering and science devoted to constructing machines that think.我想你想你的机器人ai conversations其它你可能会得到准确的结果。

但是你可以得到通过使用low-confidence-response-adapter设置信心0.90更细化的结果。

同样的答案也适用于第二个问题。让我知道你对这个问题的建议/改进

+0

感谢您的详细回复。我使用ai.yml文件进行了培训。请允许我研究这个算法,并在48小时内回复。你所说的是关于[levenshtein_distance]的权重计算(https://github.com/gunthercox/ChatterBot/blob/master/chatterbot/comparisons.py#L35)。 –

+0

'聊天机器人= { '名称': '技术支持博特', 'logic_adapters':[ { “import_path”: “chatterbot.logic.BestMatch”, “statement_comparison_function”: “chatterbot.comparisons.levenshtein_distance”, “response_selection_method”: “chatterbot.response_selection.get_first_response” }, { 'import_path': 'chatterbot.logic.LowConfidenceAdapter', '门槛':0.90, 'default_response':“我很抱歉,但我不明白。' }, ],' –

1

这个调整使得它的工作@Mallikarjunarao Kosuri(你的建议很多功劳)。

CHATTERBOT = { 
     'name': 'Tech Support Bot', 
     'logic_adapters': [ 
      { 
       "import_path": "chatterbot.logic.BestMatch", 
       "statement_comparison_function": "chatterbot.comparisons.levenshtein_distance", 
       "response_selection_method": "chatterbot.response_selection.get_first_response" 
      }, 

       { 
        'import_path': 'chatterbot.logic.LowConfidenceAdapter', 
        'threshold': 0.90, 
        'default_response': 'I am sorry, but I do not understand.' 
       }, 

     ],