July 2018
Beginner to intermediate
312 pages
8h 31m
English
Finally, we can interact with our chatbot by following the framework described in the previous sections. After each user utterance, we ask the memory network to predict a response based on the conversation history and the utterance. Then, the utterance and response are appended to the conversation history and we can enter an utterance once again:
def interactive_mode(self): facts = [] utterance = None response = None turn_count = 1 while True: line = input("==> ").strip().lower() if line == "exit": break if line == "restart": facts = [] turn_count = 1 print("Restarting dialog...\n") continue utterance = tokenize(line) data = [(facts, utterance, -1)] # Vectorize data and make prediction f, q, a = vectorize_data(data, ...Read now
Unlock full access