Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KexinFeng committed Jul 31, 2023
1 parent 7a4e63f commit 2fb20f0
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ public NDArray contrastiveSearch(NDArray inputIds) throws TranslateException {
}

// TODO: <EOS>, delete the sentence and add it to result.
long[] outputIdsArray = searchState.getPastOutputIds().toLongArray();
for (int i = 0; i < outputIdsArray.length; i++) {
if (outputIdsArray[i] == config.getEosTokenId()) {
if (!exitIndexEndPosition.containsKey((long) i)) {
exitIndexEndPosition.put((long) i, seqLength);
}
}
}
if (searchState.getPastOutputIds().getShape().get(1) >= config.getMaxSeqLength()) {
break;
}
Expand Down

0 comments on commit 2fb20f0

Please sign in to comment.