Commit e49b302a authored by Changhan Wang's avatar Changhan Wang Committed by Facebook Github Bot
Browse files

fix score

Summary: Bugfix for inconsistent scores on the same input sentences. This only affects the displayed scores in `generate.py` and does not affect the model outputs.

Reviewed By: MultiPath

Differential Revision: D17799343

fbshipit-source-id: 2b868ac03097a4db27db736e126a61d50958acc5
parent 2d51e04d
...@@ -406,8 +406,8 @@ class LevenshteinTransformerModel(TransformerModel): ...@@ -406,8 +406,8 @@ class LevenshteinTransformerModel(TransformerModel):
word_ins_out, word_ins_attn = self.decoder.forward_word_ins( word_ins_out, word_ins_attn = self.decoder.forward_word_ins(
_skip(output_tokens, can_ins_word), _skip(encoder_out, can_ins_word) _skip(output_tokens, can_ins_word), _skip(encoder_out, can_ins_word)
) )
word_ins_score = F.log_softmax(word_ins_out, 2)
word_ins_pred = word_ins_score.max(-1)[1] word_ins_score, word_ins_pred = F.log_softmax(word_ins_out, 2).max(-1)
_tokens, _scores = _apply_ins_words( _tokens, _scores = _apply_ins_words(
output_tokens[can_ins_word], output_tokens[can_ins_word],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment