Skip to content

Commit

Permalink
Fix the padding bug in BannedSequenceProcessor (facebookresearch#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbalioglu authored Nov 6, 2023
1 parent fa7f9c4 commit 6197f6e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/fairseq2/generation/step_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __call__(self, seqs: Tensor, probs: Tensor, lprob: bool = False) -> None:

if (len_delta := banned_prefix_len - seqs.size(1)) > 0:
# (N, S) -> (N, S_pre)
seqs = pad(seqs, (len_delta, -1))
seqs = pad(seqs, (len_delta, 0), value=-1)
elif len_delta < 0:
# (N, S) -> (N, S_pre)
seqs = seqs[:, -banned_prefix_len:]
Expand Down

0 comments on commit 6197f6e

Please sign in to comment.