So...how is this a generative chatbot again?

Hi, I was wondering if someone could share their code where they followed the directions and they actually have a chatbot that says…anything? All mine does is say the greeting, then whatever I say to him he either responds with “Your grandfather’s”, or “What grandfathers”. I don’t know where the “grandfather” thing is coming from, and I don’t get how it’s a chatbot because I followed the directions. Would appreciate some enlightenment. Thank you.

Hello! Could you post your code, please (along with a link to the exercise)? To see how to format code correctly, see this post.

1 Like

Lol thats quite funny, im having a similar issue with the Twitter Generative Chat bot training on Cat.txt.

Its not at all a conversation, halarious as it is, mine just replies with stuff like:

  Hi, I'm a chatbot trained on dialog from cat.txt. Would you like to chat with me?

wheres your cat?
i don’t like cat cat cat
why dont you like cat?
peaches 20 year old
why is she so fat?
i don’t like the cat cat cat
why dont you like cat?
peaches 20 year old
where is peaches?
peaches ( our 20 old geriatric
presidents cat
peaches 20 20 year old geriatric
whos cat
peaches 20 20 year old geriatric
pipita
peaches ( our 20 year old )
no
i don’t like the way cat cat
nope
peaches ( our 20 year old )
quit
Ok, have a great day!

I was trying to trigger replies based on the twitter pairs, but didnt really work. The code for the chat class is taken from the generative chatbot code cademy, and the files provided by the project

cat.txt
twitter_prep.py
preprocessing.py
training_model.py
test_model.py

chat.py is

class ChatBot: negative_responses = ("no", "nope", "nah", "naw", "not a chance", "sorry") exit_commands = ("quit", "pause", "exit", "goodbye", "bye", "later", "stop") def start_chat(self): user_response = input("Hi, I'm a chatbot trained on dialog from The Princess Bride. Would you like to chat with me?\n") if user_response in self.negative_responses: print("Ok, have a great day!") return self.chat(user_response) def chat(self, reply): while not self.make_exit(reply): reply = input(self.generate_response(reply)) def string_to_matrix(self, user_input): tokens = re.findall(r"[\w']+|[^\s\w]", user_input) user_input_matrix = np.zeros( (1, max_encoder_seq_length, num_encoder_tokens), dtype='float32') for timestep, token in enumerate(tokens): if token in input_features_dict: user_input_matrix[0, timestep, input_features_dict[token]] = 1. return user_input_matrix def generate_response(self, user_input): input_matrix = self.string_to_matrix(user_input) states_value = encoder_model.predict(input_matrix) target_seq = np.zeros((1, 1, num_decoder_tokens)) target_seq[0, 0, target_features_dict['<START>']] = 1. chatbot_response = '' stop_condition = False while not stop_condition: output_tokens, hidden_state, cell_state = decoder_model.predict( [target_seq] + states_value) sampled_token_index = np.argmax(output_tokens[0, -1, :]) sampled_token = reverse_target_features_dict[sampled_token_index] chatbot_response += " " + sampled_token if (sampled_token == '<END>' or len(chatbot_response) > max_decoder_seq_length): stop_condition = True target_seq = np.zeros((1, 1, num_decoder_tokens)) target_seq[0, 0, sampled_token_index] = 1. states_value = [hidden_state, cell_state] chatbot_response = chatbot_response.replace("<START>", "").replace("<END>", "") return chatbot_response def make_exit(self, reply): for exit_command in self.exit_commands: if exit_command in reply: print("Ok, have a great day!") return True return False chatbot = ChatBot() chatbot.start_chat()

Im running 250 epochs at the moment.

Any help on how to improve it would be better.

I havent started the project and it said that:

ModuleNotFoundError: No module named 'preprocessing'

anyone know how fix this the files name are not misspelled

Link to project/lesson?
What library are you importing? scikit-learn? Is scikit installed?

Also, going forward, please don’t revive old topics from 2 years ago. It’s better if you start a new, specific thread. :slight_smile:

I have f i n i s h e d the course