You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BackTranslationAugmenter produces an incorrect number of transformations #800
Describe the bug
Calling the augment function of a BackTranslationAugmenter produces a list with a length that appears to be non-deterministic, sometimes not matching the value of the transformations_per_example initialization parameter.
To Reproduce
Run the following code:
import textattack
augmenter = textattack.augmentation.recipes.BackTranslationAugmenter(transformations_per_example=5)
s = "You are in the kitchen."
ls = augmenter.augment(s)
print(len(ls))
Expected behavior
Expected output: 5
Actual output: 3
System Information (please complete the following information):
Root cause: Augmenter.augment accumulates results in a set() but only ever attempts exactly transformations_per_example outer-loop calls to the transformation. BackTranslationAugmenter defaults to chained_back_translation=5 (randomly chained through 5 languages), and for a short sentence like yours, two of those attempts can easily land on the identical final phrasing — the set silently collapses the duplicate, so you get fewer results than requested. It's not really about back-translation specifically; any transformation with limited output diversity for a given input hits this.
Opened #831 with a bounded retry (up to 3x the requested count) so the loop backfills collisions instead of accepting a short result. Transformations with large search spaces (the common case) see zero behavior change. Will close automatically once that merges.
Activity
qiyanjun commentedon Aug 13, 2026
Root cause:
Augmenter.augmentaccumulates results in aset()but only ever attempts exactlytransformations_per_exampleouter-loop calls to the transformation.BackTranslationAugmenterdefaults tochained_back_translation=5(randomly chained through 5 languages), and for a short sentence like yours, two of those attempts can easily land on the identical final phrasing — the set silently collapses the duplicate, so you get fewer results than requested. It's not really about back-translation specifically; any transformation with limited output diversity for a given input hits this.Opened #831 with a bounded retry (up to 3x the requested count) so the loop backfills collisions instead of accepting a short result. Transformations with large search spaces (the common case) see zero behavior change. Will close automatically once that merges.
Fix remaining review findings from PR QData#831
Fix six more bugs from the unresolved-bugs triage list