textflint.generation_layer.transformation.UT.back_trans¶
Back translation class¶
-
class
textflint.generation_layer.transformation.UT.back_trans.BackTrans(from_model_name=None, to_model_name=None, device=None, **kwargs)[source]¶ Bases:
textflint.generation_layer.transformation.transformation.TransformationBack Translation with hugging-face translation models. A sentence can only be transformed into one sentence at most.
-
__init__(from_model_name=None, to_model_name=None, device=None, **kwargs)[source]¶ - Parameters
from_model_name (str) – model to translate original language to target language
to_model_name (str) – model to translate target language to original language
device – indicate utilize cpu or which gpu device to run neural network
-
-
class
textflint.generation_layer.transformation.UT.back_trans.Transformation(**kwargs)[source]¶ Bases:
abc.ABCAn abstract class for transforming a sequence of text to produce a list of potential adversarial example.
-
processor= <textflint.common.preprocess.en_processor.EnProcessor object>¶
-
transform(sample, n=1, field='x', **kwargs)[source]¶ Transform data sample to a list of Sample.
- Parameters
sample (Sample) – Data sample for augmentation.
n (int) – Max number of unique augmented output, default is 5.
field (str|list) – Indicate which fields to apply transformations.
**kwargs (dict) –
other auxiliary params.
- Returns
list of Sample
-