Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chatbot only produces 1 answer despite beam width being 20 #169

Open
eniteCZ opened this issue Oct 11, 2020 · 4 comments
Open

Chatbot only produces 1 answer despite beam width being 20 #169

eniteCZ opened this issue Oct 11, 2020 · 4 comments

Comments

@eniteCZ
Copy link

eniteCZ commented Oct 11, 2020

Hello I have tried adding new scoring functions but none have changed the chatbot's responses. After I checked why it is because the model only produces 1 response and therefore the scoring is pointless. I checked the settings and the beam width is at 20 so it should choose from a list of 20 as far as I know. However when I use the deployed version and integrate it and tell it to list all the answers to a user input it only produces 1 answer.

Thank you for helping :)

@Nathan-Chell
Copy link

Inference.py returns the highest scoring response. If you look in inference.py you will see a line at the bottom that mentions max (Not at my pc rn cannot confirm line number), that is returning the highest score. If you want to print all responses you'll have to change this section of code.

Hope this helps.

@dennorak
Copy link

Does anyone know what line needs to be changed to fix this?

@Nathan-Chell
Copy link

On line 308, in inference.py:

for i, _ in enumerate(answers['scores']): print("{}- {}{} [{}] {}{}{}".format(colorama.Fore.GREEN if answers['scores'][i] == max(answers['scores']) and answers['scores'][i] >= score_settings['bad_response_threshold'] else colorama.Fore.YELLOW if answers['scores'][i] >= score_settings['bad_response_threshold'] else colorama.Fore.RED, answers['answers'][i], colorama.Fore.RESET, answers['scores'][i], colorama.Fore.BLUE, answers['score_modifiers'][i] if score_settings['show_score_modifiers'] else '', colorama.Fore.RESET))

If you just want all the answers produced, try changing this to print(answers['answers'])

That should print out all the answers that inference returns

@aditya543
Copy link

Hey everyone! I finally solved this issue after doing a lot of R&D on the nmt package. The reason why your chatbot produces only one response is due to the hyper-parameter: 'infer-mode' set to 'greedy'. Go to setup/settings.py and in the hparams dict add a new key: 'infer-mode' and set it to 'beam-search'. This will solve your issue, thanks!
Check out the image below.

Screen Shot 2022-06-19 at 3 09 08 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants