Skip to content

Commit

Permalink
config-config no longer prepends train_ to task ids
Browse files Browse the repository at this point in the history
This makes the "all" language hack easier to use.
When using this hack to achieve shared embeddings, it is no longer
possible to use src_lang and tgt_lang to distinguish tasks from each
other (because all tasks are just "all-all").
The iterate_tasks.py helper also supports using the task id as a
template variable. Having the real src-tgt as the task id, without any
useless train_ prefix makes file naming less painful.
  • Loading branch information
Waino committed Nov 4, 2024
1 parent b8e5735 commit 41adb4a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions mammoth/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ def forward(self, src, decoder_input, src_mask, metadata=None):
return_embeddings=True,
)

# encoder_output, alphas = self.attention_bridge(encoder_output, src_mask)
# if self.attention_bridge.is_fixed_length:
# # turn off masking in the transformer decoder
# src_mask = None
encoder_output, alphas = self.attention_bridge(encoder_output, src_mask)
if self.attention_bridge.is_fixed_length:
# turn off masking in the transformer decoder
src_mask = None

retval = active_decoder(
decoder_input,
Expand Down
2 changes: 1 addition & 1 deletion tools/config_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def _add_language_pair(opts, src_lang, tgt_lang, src_path, tgt_path, valid_src_p
if 'tasks' not in opts.in_config[0]:
opts.in_config[0]['tasks'] = dict()
tasks_section = opts.in_config[0]['tasks']
key = f'train_{src_lang}-{tgt_lang}'
key = f'{src_lang}-{tgt_lang}'
if key not in tasks_section:
tasks_section[key] = dict()
tasks_section[key]['src_tgt'] = f'{src_lang}-{tgt_lang}'
Expand Down
4 changes: 2 additions & 2 deletions tools/iterate_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'--src',
type=str,
default=None,
help='Template for source file paths. Use varibles src_lang and tgt_lang.',
help='Template for source file paths. Use varibles src_lang, tgt_lang, and task_id.',
)
@click.option(
'--output',
Expand All @@ -27,7 +27,7 @@
@click.option(
'--flag',
is_flag=True,
help='Prefix with "--task_id". Implied by --src and --output.'
help='Prefix output with "--task_id". Implied by --src and --output.'
)
def main(config_path, match, src, output, flag):
if src is not None or output is not None:
Expand Down

0 comments on commit 41adb4a

Please sign in to comment.