def test1_rule_based_user(): """ Method for testing the rule-based user on the movie booking data set """ simulation_mode = const.SEMANTIC_FRAME_SIMULATION_MODE # the path to the user goals and load it # TODO: change it with a relative path goal_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/user_goals_first_turn_template.part.movie.v1.p' goal_set = util.load_goal_set(goal_set_file_path) # the path to the act set and load it # TODO: change it with a relative path act_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/dia_acts.txt' act_set = util.text_to_dict(act_set_file_path) # the path to the slot set and load it # TODO: change it with a relative path slot_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/slot_set.txt' slot_set = util.text_to_dict(slot_set_file_path) # the list of initial inform slots init_inform_slots = ['moviename'] # the ultimate slot set ultimate_request_slot = 'ticket' # create the rule-based user user = GORuleBasedUser(simulation_mode, goal_set, act_set, init_inform_slots, ultimate_request_slot) # reset the user user.reset()
def test1_rule_based_state_tracker(): """ Method for testing the rule-based state tracker on the movie booking data set """ # the path to the act set and load it # TODO: change it with a relative path act_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/dia_acts.txt' act_set = util.text_to_dict(act_set_file_path) # the path to the slot set and load it # TODO: change it with a relative path slot_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/slot_set.txt' slot_set = util.text_to_dict(slot_set_file_path) # maximum number of turns max_nb_turns = 30 # the dimensionality of the state act_cardinality = len(act_set) slot_cardinality = len(slot_set) state_dim = 2 * act_cardinality + 7 * slot_cardinality + 3 + max_nb_turns # Create the KB Helper class ultimate_request_slot = 'ticket' special_slots = ['numberofpeople'] filter_slots = ['ticket', 'numberofpeople', 'taskcomplete', 'closing'] knowledge_dict_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/movie_kb.1k.p' knowledge_dict = pickle.load(open(knowledge_dict_path, 'rb')) kb_helper = GOKBHelper(ultimate_request_slot, special_slots, filter_slots, knowledge_dict) # create the state tracker state_tracker = GORuleBasedStateTracker(act_set=act_set, slot_set=slot_set, max_nb_turns=max_nb_turns, kb_helper=kb_helper) # reset the state tracker state_tracker.reset() # get three mock actions init_usr_action, agt_action, usr_action = test1_actions() state_tracker.update(init_usr_action, const.USR_SPEAKER_VAL) # produce state for the agent init_state = state_tracker.produce_state() state_tracker.update(agt_action, const.AGT_SPEAKER_VAL) state_tracker.update(usr_action, const.USR_SPEAKER_VAL) state = state_tracker.produce_state()
def prepare_dialogue_system(): # the path to the act set and load it # TODO: change it with a relative path act_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/dia_acts.txt' act_set = util.text_to_dict(act_set_file_path) # the path to the slot set and load it # TODO: change it with a relative path slot_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/slot_set.txt' slot_set = util.text_to_dict(slot_set_file_path) # the path to the user goals and load it # TODO: change it with a relative path goal_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/user_goals_first_turn_template.part.movie.v1.p' goal_set = util.load_goal_set(goal_set_file_path) # the list of initial inform slots init_inform_slots = ['moviename'] # the ultimate slot set ultimate_request_slot = 'ticket' kb_special_slots = ['numberofpeople'] kb_filter_slots = ['ticket', 'numberofpeople', 'taskcomplete', 'closing'] # feasible actions agt_feasible_actions = feasible_actions() # the agent memory agt_memory = GOMemory(warmup_size=1000) # the agent policy agt_policy = EpsGreedyQPolicy(eps=0.1) warmup_policy_request_set = ['moviename', 'starttime', 'city', 'date', 'theater', 'numberofpeople'] agt_warmup_policy = GORuleBasedPolicy(feasible_actions=agt_feasible_actions, request_set=warmup_policy_request_set) # testing policy agt_eval_policy = EpsGreedyQPolicy(eps=0.1) # all system params params = {} params[const.MAX_NB_TURNS] = 40 params[ const.KB_PATH_KEY] = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/movie_kb.1k.p' # Environment params params[const.SIMULATION_MODE_KEY] = const.SEMANTIC_FRAME_SIMULATION_MODE params[const.IS_TRAINING_KEY] = True params[const.USER_TYPE_KEY] = const.RULE_BASED_USER params[const.STATE_TRACKER_TYPE_KEY] = const.RULE_BASED_STATE_TRACKER params[const.SUCCESS_REWARD_KEY] = 2 * params[const.MAX_NB_TURNS] params[const.FAILURE_REWARD_KEY] = - params[const.MAX_NB_TURNS] params[const.PER_TURN_REWARD_KEY] = -1 # TODO: change it with a relative path params[ const.NLU_PATH_KEY] = "/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/models/nlu/lstm_[1468447442.91]_39_80_0.921.p" params[ const.DIAACT_NL_PAIRS_PATH_KEY] = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/dia_act_nl_pairs.v6.json' params[ const.NLG_PATH_KEY] = "/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/models/nlg/lstm_tanh_relu_[1468202263.38]_2_0.610.p" # Agent params params[const.AGENT_TYPE_KEY] = const.AGENT_TYPE_DQN params[const.GAMMA_KEY] = .99 params[const.BATCH_SIZE_KEY] = 32 params[const.NB_STEPS_WARMUP_KEY] = 10000 params[const.TRAIN_INTERVAL_KEY] = 20 params[const.MEMORY_INTERVAL_KEY] = 50 params[const.TARGET_MODEL_UPDATE_KEY] = 100 params[const.ENABLE_DOUBLE_DQN_KEY] = False params[const.ENABLE_DUELING_NETWORK_KEY] = False params[const.DUELING_TYPE_KEY] = 'avg' params[const.HIDDEN_SIZE_KEY] = 80 params[const.ACTIVATION_FUNCTION_KEY] = const.RELU # create the dialogue system dialogue_sys = GODialogSys(act_set=act_set, slot_set=slot_set, goal_set=goal_set, init_inform_slots=init_inform_slots, ultimate_request_slot=ultimate_request_slot, kb_special_slots=kb_special_slots, kb_filter_slots=kb_filter_slots, agt_feasible_actions=agt_feasible_actions, agt_memory=agt_memory, agt_policy=agt_policy, agt_warmup_policy=agt_warmup_policy, agt_eval_policy=agt_eval_policy, params=params) return dialogue_sys
def test1_environment(): """ Method for testing the Environment class for the movie booking data set """ # the path to the act set and load it # TODO: change it with a relative path act_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/dia_acts.txt' act_set = util.text_to_dict(act_set_file_path) # the path to the slot set and load it # TODO: change it with a relative path slot_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/slot_set.txt' slot_set = util.text_to_dict(slot_set_file_path) # the path to the user goals and load it # TODO: change it with a relative path goal_set_file_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/user_goals_first_turn_template.part.movie.v1.p' goal_set = util.load_goal_set(goal_set_file_path) # the list of initial inform slots init_inform_slots = ['moviename'] # the ultimate slot set ultimate_request_slot = 'ticket' # feasible actions test_feasible_actions = test1_feasible_actions() # define the arguments for the KB ultimate_request_slot = 'ticket' special_slots = ['numberofpeople'] filter_slots = ['ticket', 'numberofpeople', 'taskcomplete', 'closing'] knowledge_dict_path = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/movie_kb.1k.p' knowledge_dict = pickle.load(open(knowledge_dict_path, 'rb')) # Create the KB Helper class kb_helper = GOKBHelper(ultimate_request_slot, special_slots, filter_slots, knowledge_dict) # all params params = {} params[const.SIMULATION_MODE_KEY] = const.SEMANTIC_FRAME_SIMULATION_MODE params[const.IS_TRAINING_KEY] = True params[const.USER_TYPE_KEY] = const.RULE_BASED_USER params[const.STATE_TRACKER_TYPE_KEY] = const.RULE_BASED_STATE_TRACKER params[const.MAX_NB_TURNS] = 30 params[const.SUCCESS_REWARD_KEY] = 2 * params[const.MAX_NB_TURNS] params[const.FAILURE_REWARD_KEY] = -params[const.MAX_NB_TURNS] params[const.PER_TURN_REWARD_KEY] = -1 params[ const. NLU_PATH_KEY] = "/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/models/nlu/lstm_[1468447442.91]_39_80_0.921.p" params[ const. DIAACT_NL_PAIRS_PATH_KEY] = '/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/data/dia_act_nl_pairs.v6.json' params[ const. NLG_PATH_KEY] = "/Users/vladimirilievski/Desktop/Vladimir/Master_Thesis_Swisscom/GitHub Repo/GO-Chatbots/resources/models/nlg/lstm_tanh_relu_[1468202263.38]_2_0.610.p" env = GOEnv(act_set=act_set, slot_set=slot_set, goal_set=goal_set, init_inform_slots=init_inform_slots, ultimate_request_slot=ultimate_request_slot, feasible_actions=test_feasible_actions, kb_helper=kb_helper, params=params) env.reset() agt_action = {} agt_action[const.DIA_ACT_KEY] = 'request' agt_action[const.INFORM_SLOTS_KEY] = {} agt_action[const.INFORM_SLOTS_KEY]['theater'] = 'manville 12 plex' agt_action[const.REQUEST_SLOTS_KEY] = {} agt_action[const.REQUEST_SLOTS_KEY]['starttime'] = 'UKN' env.step(agt_action)