From b50a51ad64b849810198a8e19169ca15729d1e6c Mon Sep 17 00:00:00 2001 From: machinewrapped Date: Sun, 9 Jul 2023 11:44:58 +0200 Subject: [PATCH] Replaced "synopsis" with "description" Disambiguate the use of the word synopsis at the top level to discourage GPT from using it as the synopsis for early batches, getting ahead of the plot. --- GUI/Widgets/ProjectOptions.py | 6 +++--- PySubtitleGPT/ChatGPTPrompt.py | 2 +- PySubtitleGPT/ChatGPTTranslation.py | 2 +- PySubtitleGPT/SubtitleFile.py | 6 +++++- PySubtitleGPT/SubtitleTranslator.py | 2 +- gpt-subtrans.py | 4 ++-- instructions (brief).txt | 2 +- instructions (more natural).txt | 8 +------- instructions (thorough).txt | 12 +++++++----- instructions.txt | 2 +- readme.md | 4 ++-- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/GUI/Widgets/ProjectOptions.py b/GUI/Widgets/ProjectOptions.py index 76b7483a..b17189e2 100644 --- a/GUI/Widgets/ProjectOptions.py +++ b/GUI/Widgets/ProjectOptions.py @@ -27,7 +27,7 @@ def __init__(self, options=None): # Add options self.AddSingleLineOption(0, "Movie Name", options, 'movie_name') self.AddSingleLineOption(1, "Target Language", options, 'target_language') - self.AddMultiLineOption(2, "Synopsis", options, 'synopsis') + self.AddMultiLineOption(2, "Description", options, 'description') self.AddMultiLineOption(3, "Characters", options, 'characters') self.AddMultiLineOption(4, "Substitutions", options, 'substitutions') self.AddCheckboxOption(5, "Match Partial Words", options, 'match_partial_words') @@ -44,7 +44,7 @@ def GetOptions(self): options = { "movie_name": self.movie_name_input.text(), "target_language": self.target_language_input.text(), - "synopsis": self.synopsis_input.toPlainText(), + "description": self.description_input.toPlainText(), "characters": ParseCharacters(self.characters_input.toPlainText()), "substitutions": ParseSubstitutions(self.substitutions_input.toPlainText()), "match_partial_words": self.match_partial_words_input.isChecked() @@ -119,7 +119,7 @@ def Populate(self, options): self._setvalue(key, value) def Clear(self): - for key in ["movie_name", "synopsis", "characters", "substitutions", "match_partial_words"]: + for key in ["movie_name", "description", "characters", "substitutions", "match_partial_words"]: input = getattr(self, key + "_input") if input: if isinstance(input, QCheckBox): diff --git a/PySubtitleGPT/ChatGPTPrompt.py b/PySubtitleGPT/ChatGPTPrompt.py index 7b2a7349..2b81d748 100644 --- a/PySubtitleGPT/ChatGPTPrompt.py +++ b/PySubtitleGPT/ChatGPTPrompt.py @@ -15,7 +15,7 @@ def GenerateMessages(self, prompt, lines, context): self.messages.append({'role': "system", 'content': self.instructions}) if context: - context_tags = GenerateTagLines(context, ['synopsis', 'characters']) + context_tags = GenerateTagLines(context, ['description', 'characters']) if context_tags: self.messages.append({'role': "user", 'content': context_tags}) diff --git a/PySubtitleGPT/ChatGPTTranslation.py b/PySubtitleGPT/ChatGPTTranslation.py index 8f1c1165..34f836e9 100644 --- a/PySubtitleGPT/ChatGPTTranslation.py +++ b/PySubtitleGPT/ChatGPTTranslation.py @@ -58,7 +58,7 @@ def quota_reached(self): def PerformSubstitutions(self, substitutions, match_partial_words : bool = False): """ - Apply any text substitutions to summary, characters and synopsis if they exist. + Apply any text substitutions to summary, scene, characters and synopsis if they exist. Does NOT apply them to the translation text. """ diff --git a/PySubtitleGPT/SubtitleFile.py b/PySubtitleGPT/SubtitleFile.py index 7d7561bd..2f4ca3e0 100644 --- a/PySubtitleGPT/SubtitleFile.py +++ b/PySubtitleGPT/SubtitleFile.py @@ -204,7 +204,7 @@ def UpdateContext(self, options): 'gpt_prompt': "", 'instructions': "", 'movie_name': "", - 'synopsis': "", + 'description': "", 'characters': None, 'substitutions': None, 'min_batch_size' : None, @@ -231,6 +231,10 @@ def UpdateContext(self, options): elif context[key]: options[key] = context[key] + # Fill description from synopsis for backward compatibility + if not context.get('description') and context.get('synopsis'): + context['description'] = context.get('synopsis') + self.context = context return context diff --git a/PySubtitleGPT/SubtitleTranslator.py b/PySubtitleGPT/SubtitleTranslator.py index 894375c4..0899dba2 100644 --- a/PySubtitleGPT/SubtitleTranslator.py +++ b/PySubtitleGPT/SubtitleTranslator.py @@ -342,7 +342,7 @@ def ProcessTranslation(self, batch : SubtitleBatch, context : dict, client : Cha context['summary'] = batch.summary context['scene'] = scene_summary or context['scene'] - context['synopsis'] = translation.synopsis or context.get('synopsis', "") or options.get('synopsis') + context['synopsis'] = translation.synopsis or context.get('synopsis', "") #context['characters'] = translation.characters or context.get('characters', []) or options.get('characters') batch.UpdateContext(context) diff --git a/gpt-subtrans.py b/gpt-subtrans.py index dc898c7f..8f012774 100644 --- a/gpt-subtrans.py +++ b/gpt-subtrans.py @@ -23,7 +23,7 @@ parser.add_argument('-s', '--substitution', action='append', type=str, default=None, help="A pair of strings separated by ::, to subsitute in source or translation") parser.add_argument('-i', '--instruction', action='append', type=str, default=None, help="An instruction for Chat GPT about the translation") parser.add_argument('-f', '--instructionfile', type=str, default=None, help="Name/path of a file to load GPT instructions from") -parser.add_argument('--synopsis', type=str, default=None, help="A brief synopsis of the film to give context") +parser.add_argument('--description', type=str, default=None, help="A brief description of the film to give context") parser.add_argument('--characters', type=str, default=None, help="A list of character names") parser.add_argument('--minbatchsize', type=int, default=None, help="Minimum number of lines to consider starting a new batch") parser.add_argument('--maxbatchsize', type=int, default=None, help="Maximum number of lines before starting a new batch is compulsory") @@ -41,7 +41,7 @@ 'rate_limit': args.ratelimit, 'target_language': args.target_language, 'movie_name': args.moviename or os.path.splitext(os.path.basename(args.input))[0], - 'synopsis': args.synopsis, + 'description': args.description, 'characters': ParseCharacters(args.characters or args.character), 'substitutions': ParseSubstitutions(args.substitution), 'match_partial_words': args.matchpartialwords, diff --git a/instructions (brief).txt b/instructions (brief).txt index 7f1655b9..e4473d69 100644 --- a/instructions (brief).txt +++ b/instructions (brief).txt @@ -2,7 +2,7 @@ Your task is to accurately translate subtitles into a target language. You will be provided with a batch of lines, you should respond with an accurate, concise, and natural-sounding translation of those lines. -The may be provided additional context, such as a synopsis of the film, a summary of the current scene or a list of character names. Use this information to improve the quality of your translation. +The may be provided additional context, such as a description of the film, a summary of the current scene or a list of character names. Use this information to improve the quality of your translation. Your response will be processed by an automated system, so it is imperative that you adhere to the required output format. diff --git a/instructions (more natural).txt b/instructions (more natural).txt index a04bc3a7..b7ba8f85 100644 --- a/instructions (more natural).txt +++ b/instructions (more natural).txt @@ -1,14 +1,8 @@ Your task is to accurately translate subtitles into a target language. The user will provide lines for translation in this format: -``` -#Number -Original> -dialogue to be translated -``` - You should provide an accurate, concise, and natural-sounding translation for each line of dialogue. -The user may provide tags with additional context, such as a synopsis of the film, a list of characters or a summary of the current scene. Use this to improve the fidelity of your translations. +The user may provide additional context, such as a description of the film, a list of characters or a summary of the current scene. Use this to improve the fidelity of your translations. Your response will be processed by an automated system, so it is essential that you respond using this format: diff --git a/instructions (thorough).txt b/instructions (thorough).txt index abc14978..6be3dfbb 100644 --- a/instructions (thorough).txt +++ b/instructions (thorough).txt @@ -2,7 +2,7 @@ You are a translator, your task is to accurately translate subtitles into a targ The user will provide a batch of lines for translation, you should respond with an accurate, concise, and natural-sounding translation for the dialogue. -The user may provide additional context, such as a synopsis of the film, a summary of the current scene or a list of character names. Use this information to improve the quality of your translation. +The user may provide additional context, such as a description of the source material, a summary of the current scene or a list of character names. Use this information to improve the quality of your translation. Your response will be processed by an automated system, so it is imperative that you adhere to the required output format. @@ -93,11 +93,13 @@ könnten sich zurückgelassen finden. Please ensure that each line of dialogue remains distinct in the translation. Merging lines together can lead to timing problems during playback. -At the end of each set of translations, include a one or two line summary of the input text in a tag - do not improvise. For example: -A police officer tells his team to get ready +At the end of each set of translations, include a one or two line synopsis of the input text in a tag, for example: +John and Sarah discuss their plan to locate a suspect, deducing that he is likely in the uptown area. -Add a short synopsis of the scene so far in a tag, for example: -Some police officers are chasing a killer, they follow him to an apartment building and trap him on the roof. +Use the available information to add a short synopsis of the current scene in a tag, for example: +John and Sarah are in their office analyzing data and planning their next steps. They deduce that the suspect is probably in the uptown area and decide to start their search there. + +Do not guess or improvise if the context is unclear, just summarise the dialogue. ####################### There was an issue with the previous translation. diff --git a/instructions.txt b/instructions.txt index 98e9d610..ff132588 100644 --- a/instructions.txt +++ b/instructions.txt @@ -2,7 +2,7 @@ You are a translator, your task is to accurately translate subtitles into a targ The user will provide a batch of lines for translation, you should respond with an accurate, concise, and natural-sounding translation for the dialogue. -The user may provide additional context, such as a synopsis of the film, a summary of the current scene or a list of character names. Use this information to improve the quality of your translation. +The user may provide additional context, such as a description of the source material, a summary of the current scene or a list of character names. Use this information to improve the quality of your translation. Your response will be processed by an automated system, so it is imperative that you adhere to the required output format. diff --git a/readme.md b/readme.md index 3078788a..d6ac5a7f 100644 --- a/readme.md +++ b/readme.md @@ -88,8 +88,8 @@ along with some other configuration options. See Options.py for the full list. A - `-m`, `--moviename`: Optionally specify the name of the movie to give context to the translator. -- `--synopsis`: - A brief synopsis of the film to give context. Less is more here, otherwise ChatGPT can start improvising. +- `--description`: + A brief description of the film to give context. Less is more here, otherwise ChatGPT can start improvising. - `-c`, `--character`, `--characters`: Optionally provide (a list of) character names to use in the translation.