Skip to content

Commit 57c8fc5

Browse files
author
gongel
committed
docs: update annotation
1 parent fc98084 commit 57c8fc5

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

examples/machine_translation/transformer/predict_beamsearch_v2.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ def do_predict(args):
5959
test_loader, to_tokens = reader.create_infer_loader(args)
6060

6161
# Define model
62-
# `TransformerGenerator` automatically chioces using `FasterTransformer`
63-
# (with jit building) or the slower verison `InferTransformerModel`.
6462
transformer = TransformerModel(
6563
src_vocab_size=args.src_vocab_size,
6664
trg_vocab_size=args.trg_vocab_size,
@@ -98,8 +96,6 @@ def do_predict(args):
9896

9997
with paddle.no_grad():
10098
for (src_word, ) in test_loader:
101-
# The shape of finished_seq is `[seq_len, batch_size, beam_size]`
102-
# when `output_time_major` argument is `True` for TransformerGenerator.
10399
finished_seq, finished_scores = transformer.beam_search_v2(
104100
src_word=src_word,
105101
beam_size=args.beam_size,

paddlenlp/transformers/transformer/modeling.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,9 +1028,8 @@ def grow_finished(finished_seq, finished_scores, finished_flags,
10281028

10291029
# Accounting for corner case: It's possible that no sequence in alive for a
10301030
# particular batch item ever reached EOS. In that case, we should just copy
1031-
# the contents of alive for that batch item. tf.reduce_any(finished_flags, 1)
1032-
# if 0, means that no sequence for that batch index had reached EOS. We need
1033-
# to do the same for the scores as well.
1031+
# the contents of alive for that batch item. if no sequence for that batch
1032+
# index had reached EOS. We need to do the same for the scores as well.
10341033
finished_flags = paddle.any(paddle.cast(
10351034
finished_flags, dtype='bool'),
10361035
axis=1,

0 commit comments

Comments
 (0)