TextAttack icon indicating copy to clipboard operation
TextAttack copied to clipboard

Could TextAttack only attack substring of input.

Open ludybupt opened this issue 2 years ago • 1 comments

I would like to employ TextAttack for further research. does TextAttack support setting attack range of input text?

ludybupt avatar May 09 '23 11:05 ludybupt

Yes, definitely. You can implement a PreTransformationConstraint that filters out transformations to the words that you don't want to alter. Here's an example, which we used to prevent modifying the premise (or hypothesis) in SNLI: https://github.com/QData/TextAttack/blob/master/textattack/constraints/pre_transformation/input_column_modification.py#L11

jxmorris12 avatar May 10 '23 20:05 jxmorris12