Skip to content

Commit

Permalink
Replaced "synopsis" with "description"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
machinewrapped committed Jul 9, 2023
1 parent 82bd2ca commit b50a51a
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions GUI/Widgets/ProjectOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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()
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion PySubtitleGPT/ChatGPTPrompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
2 changes: 1 addition & 1 deletion PySubtitleGPT/ChatGPTTranslation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down
6 changes: 5 additions & 1 deletion PySubtitleGPT/SubtitleFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def UpdateContext(self, options):
'gpt_prompt': "",
'instructions': "",
'movie_name': "",
'synopsis': "",
'description': "",
'characters': None,
'substitutions': None,
'min_batch_size' : None,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion PySubtitleGPT/SubtitleTranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions gpt-subtrans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion instructions (brief).txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 1 addition & 7 deletions instructions (more natural).txt
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
12 changes: 7 additions & 5 deletions instructions (thorough).txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 <summary/> tag - do not improvise. For example:
<summary>A police officer tells his team to get ready</summary>
At the end of each set of translations, include a one or two line synopsis of the input text in a <summary/> tag, for example:
<summary>John and Sarah discuss their plan to locate a suspect, deducing that he is likely in the uptown area.</summary>

Add a short synopsis of the scene so far in a <scene/> tag, for example:
<scene>Some police officers are chasing a killer, they follow him to an apartment building and trap him on the roof.</scene>
Use the available information to add a short synopsis of the current scene in a <scene/> tag, for example:
<scene>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.</scene>

Do not guess or improvise if the context is unclear, just summarise the dialogue.

#######################
There was an issue with the previous translation.
Expand Down
2 changes: 1 addition & 1 deletion instructions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b50a51a

Please sign in to comment.