Skip to content

Commit f600eb6

Browse files
authored
Update docstring for the callback argument (OpenNMT#1313)
1 parent e62675e commit f600eb6

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

python/cpp/generator.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,9 @@ namespace ctranslate2 {
254254
sampling_topp: Keep the most probable tokens whose cumulative probability exceeds
255255
this value.
256256
sampling_temperature: Sampling temperature to generate more random samples.
257-
callback: Optional function that is called for each generated token.
258-
This requires a beam size of 1.
257+
callback: Optional function that is called for each generated token when
258+
:obj:`beam_size` is 1. If the callback function returns ``True``, the
259+
decoding will stop for this batch.
259260
260261
Returns:
261262
A list of generation results.

python/cpp/translator.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,9 @@ namespace ctranslate2 {
490490
this value.
491491
sampling_temperature: Sampling temperature to generate more random samples.
492492
replace_unknowns: Replace unknown target tokens by the source token with the highest attention.
493-
callback: Optional function that is called for each generated token.
494-
This requires a beam size of 1.
493+
callback: Optional function that is called for each generated token when
494+
:obj:`beam_size` is 1. If the callback function returns ``True``, the
495+
decoding will stop for this batch.
495496
496497
Returns:
497498
A list of translation results.

0 commit comments

Comments
 (0)