diff --git a/console_play.py b/console_play.py index e3debf6..aff558f 100644 --- a/console_play.py +++ b/console_play.py @@ -122,7 +122,7 @@ def play_cached_hospital(): if __name__ == '__main__': - play_constrained() + play_unconstrained() diff --git a/generator/ctrl/ctrl_generator.py b/generator/ctrl/ctrl_generator.py index fd8fd6a..0f5ee3e 100644 --- a/generator/ctrl/ctrl_generator.py +++ b/generator/ctrl/ctrl_generator.py @@ -20,7 +20,7 @@ def loss(labels, logits): class CTRLGenerator(): - def __init__(self, control_code="Writing Text: ", generate_num=40, temperature=0.3, topk=20, nucleus_prob=0): + def __init__(self, control_code="Writing Text: ", generate_num=32, temperature=0.3, topk=20, nucleus_prob=0): self.generate_num=generate_num model_dir = "generator/ctrl/training_utils/seqlen256_v1.ckpt/" @@ -219,10 +219,7 @@ class CTRLGenerator(): forbidden_tokens = ['', 'Sco@@', "&@@", "1]@@", "2]@@", "3]@@", "4]@@", "https://www.@@", "[@@", ":@@", "Edit", "&@@", "2:","1:", ":", "Edit@@", "EDI@@", "EDIT@@", "edit", "TL@@", "tl@@", ";@@", '**', "http://@@", "Redd@@", "UP@@", "mom", "Up@@", "Me:", "Update", "mom@@", "Part", - "http://www.@@", "edit@@", "*@@", "\n", "Writing", "Text@@", "\\@@", "
@@", " self.max_new_lines: - forbidden_tokens.append("\n") + "http://www.@@", "edit@@", "*@@", "Writing", "Text@@", "\\@@", "
@@", " 1: + self.result_replace(result) print(repr(self.idx2word[idx]), end="_") diff --git a/generator/ctrl/training_utils/make_forest_tf_records.py b/generator/ctrl/training_utils/make_forest_tf_records.py index 4ac75a2..4685e1f 100644 --- a/generator/ctrl/training_utils/make_forest_tf_records.py +++ b/generator/ctrl/training_utils/make_forest_tf_records.py @@ -20,7 +20,7 @@ def make_samples_helper(context, story_block, action_results, path, tree_id): new_path = path[:] new_path.append(i) if action_result["result"] is not None: - sample = [context, story_block, "action:", action_result["action"], "result:", action_result["result"]] + sample = [context, story_block, action_result["action"], action_result["result"]] samples.append(sample) if len(action_result["action_results"]) is not 0: sub_result = make_samples_helper(context, action_result["result"], action_result["action_results"], new_path, tree_id) @@ -43,8 +43,8 @@ def build_tokenized_samples(bpe, tree): for sample in samples: sample = [string.strip() for string in sample] - sample[3] = sample[3][0].lower() + sample[3][1:] - sample[3] = "You " + sample[3] + sample[2] = sample[2][0].lower() + sample[2][1:] + sample[2] = "You " + sample[2] string_samples.append(" ".join(sample)) tokenized_samples = [bpe.apply([sample.encode('ascii', errors='ignore') if not use_py3 else sample])[0] for sample in diff --git a/story/story_manager.py b/story/story_manager.py index 3d7d3d9..c1bec84 100644 --- a/story/story_manager.py +++ b/story/story_manager.py @@ -212,7 +212,7 @@ class CTRLStoryManager(ConstrainedStoryManager): results = [] options = {"word_blacklist": {0:[]}} for phrase in self.action_phrases: - result = self.generate_action_result(self.story_context() + " action: ", phrase, options=options) + result = self.generate_action_result(self.story_context(), phrase, options=options) action_verb = result[0].split()[1] print("blacklisted verb is ", action_verb) options["word_blacklist"][0].append(action_verb)