Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Fix dimension off by not adding things to dictionary in intermediate eval #573

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pytorch_translate/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ def _generate_score(models, args, task, dataset):
maxlen_b=args.max_len_b,
cuda=use_cuda,
timer=gen_timer,
prefix_size=1 if pytorch_translate_data.is_multilingual_many_to_one(args) else 0,
prefix_size=1
if pytorch_translate_data.is_multilingual_many_to_one(args)
else 0,
)

for trans_info in _iter_translations(
Expand Down Expand Up @@ -432,7 +434,7 @@ def _iter_translations(args, task, dataset, translations, align_dict, rescorer):
# Convert back to tokens for evaluation with unk replacement
# and/or without BPE
target_tokens = task.target_dictionary.encode_line(
target_str, add_if_not_exist=True
target_str, add_if_not_exist=False
)
# The probs score for the hypo_str; whether it's normalized by
# sequence length or not depends on normalize_scores, which is
Expand Down