skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

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

  2. @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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search