BestMatchAdapter confuse two different questions with same response

限于喜欢 提交于 2019-12-08 10:50:47

问题


Using the BestMatchAdapter of Chatterbot, it confuses two questions with the same answer. For example, training the ai.yml.

What is ai?

Artificial Intelligence is the branch of engineering and science devoted to constructing machines that think.

What is a joke?

Artificial Intelligence is the branch of engineering and science devoted to constructing machines that think.

On the otherhand, the following similar questions make much sense in the bot answer:

Can you bend?

No I can be perpetuated indefinitely.

Can you lie?

No I can be perpetuated indefinitely.


回答1:


@taiwotman I don't know the corpus files you have trained. In short the best match algorithm works like this, Bot will iterate all the statements which you have trained the 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

Chatterbot uses the default statement comparison algorithm is levenshtein_distance

In your example, the scenario look like this

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

In this the confidence is 1.0 and you will get answer Artificial Intelligence is the branch of engineering and science devoted to constructing machines that think.

I think you were confused with this case. The chatterbot default threshold values is 65%. Among on all statement which have greater confidence then it will become as response.

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

In this the confidence is 0.77 which is greater than 0.65 and you will get answer Artificial Intelligence is the branch of engineering and science devoted to constructing machines that think. I think you tried your bot ai conversations other you may get accurate results.

However you could get more granular results by setting confidence to 0.90 by using low-confidence-response-adapter.

The same answer applies to second question also. Let me know your suggestion/improvements on this question




回答2:


This adjustment makes it work @Mallikarjunarao Kosuri(much credit for your suggestion).

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.'
                },

        ],


来源:https://stackoverflow.com/questions/45910997/bestmatchadapter-confuse-two-different-questions-with-same-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!