We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bed1788 commit fe9051cCopy full SHA for fe9051c
1 file changed
onmt/translate/translation.py
@@ -47,7 +47,7 @@ def _build_target_tokens(self, src, src_vocab, src_raw, pred, attn):
47
if self.replace_unk and attn is not None and src is not None:
48
for i in range(len(tokens)):
49
if tokens[i] == tgt_field.unk_token:
50
- _, max_index = attn[i].max(0)
+ _, max_index = attn[i][:len(src_raw)].max(0)
51
tokens[i] = src_raw[max_index.item()]
52
if self.phrase_table != "":
53
with open(self.phrase_table, "r") as f:
0 commit comments