From 4050e5b2a9afa24175e77968482070b6bf647701 Mon Sep 17 00:00:00 2001 From: AccidentallyOnPurpose <4935931+AccidentallyOnPurpose@users.noreply.github.com4935931+AccidentallyOnPurpose@users.noreply.github.com> Date: Tue, 24 Dec 2019 23:41:51 +0800 Subject: [PATCH] comments --- gpt2generator.py | 5 +++-- play.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gpt2generator.py b/gpt2generator.py index 9121911..7a9bfed 100644 --- a/gpt2generator.py +++ b/gpt2generator.py @@ -159,11 +159,11 @@ class GPT2Generator: # prompt = second_to_first_person(prompt) - logger.debug("AFTER PROMPT_REPLACE: `%s`", repr(prompt)) + # logger.debug("AFTER PROMPT_REPLACE: `%s`", repr(prompt)) return prompt def result_replace(self, result): - logger.debug("BEFORE RESULT_REPLACE: `%s`", repr(result)) + # logger.debug("BEFORE RESULT_REPLACE: `%s`", repr(result)) result = cut_trailing_sentence(result) if len(result) == 0: @@ -187,6 +187,7 @@ class GPT2Generator: # TODO instead of taking last 1024, take first X and last Y # crop context to avoid going of the GPT2 max context size of 1024 if len(context_tokens) > self.max_history_tokens: + # FIXME it would be better to pass in a list of strings so we can cut some out, and a truncation strategy https://github.com/huggingface/transformers/blob/ce50305e5b8c8748b81b0c8f5539a337b6a995b9/src/transformers/tokenization_utils.py#L791 first = self.max_history_tokens // 4 last = self.max_history_tokens - first context_tokens = context_tokens[:first] + context_tokens[-last:] diff --git a/play.py b/play.py index d912566..a8d0f40 100644 --- a/play.py +++ b/play.py @@ -177,6 +177,7 @@ def play(): colPrint('Suggested actions:', colors['selection-value']) action_suggestion_lines = 1 for i in range(settings.getint('action-alternatives')): + # FIXME it might be better to pass in a longer history suggested_action = ai_player.get_action(action_prompt) suggested_actions.append(suggested_action) suggestion = '{}> {}'.format(i, suggested_action)