Skip to content

Commit 24db54f

Browse files
committed
revert changes attacks4components
1 parent 11c27e9 commit 24db54f

1 file changed

Lines changed: 23 additions & 19 deletions

File tree

docs/1start/attacks4Components.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
# Four Components of TextAttack Attacks
1+
Four Components of TextAttack Attacks
2+
========================================
3+
4+
To unify adversarial attack methods into one system, We formulate an attack as consisting of four components: a **goal function** which determines if the attack has succeeded, **constraints** defining which perturbations are valid, a **transformation** that generates potential modifications given an input, and a **search method** which traverses through the search space of possible perturbations. The attack attempts to perturb an input text such that the model output fulfills the goal function (i.e., indicating whether the attack is successful) and the perturbation adheres to the set of constraints (e.g., grammar constraint, semantic similarity constraint). A search method is used to find a sequence of transformations that produce a successful adversarial example.
5+
26

3-
To unify adversarial attack methods into one system, We formulate an attack as consisting of four components: a **goal function** which determines if the attack has succeeded, **constraints** defining which perturbations are valid, a **transformation** that generates potential modifications given an input, and a **search method** which traverses through the search space of possible perturbations. The attack attempts to perturb an input text such that the model output fulfills the goal function (i.e., indicating whether the attack is successful) and the perturbation adheres to the set of constraints (e.g., grammar constraint, semantic similarity constraint). A search method is used to find a sequence of transformations that produce a successful adversarial example.
47

58
This modular design enables us to easily assemble attacks from the literature while re-using components that are shared across attacks. TextAttack provides clean, readable implementations of 16 adversarial attacks from the literature. For the first time, these attacks can be benchmarked, compared, and analyzed in a standardized setting.
69

10+
711
- Two examples showing four components of two SOTA attacks
8-
![two-categorized-attacks](/_static/imgs/intro/01-categorized-attacks.png)
12+
![two-categorized-attacks](/_static/imgs/intro/01-categorized-attacks.png)
913

10-
- You can create one new attack (in one line of code!!!) from composing members of four components we proposed, for instance:
1114

12-
```bash
15+
- You can create one new attack (in one line of code!!!) from composing members of four components we proposed, for instance:
16+
17+
```bash
1318
# Shows how to build an attack from components and use it on a pre-trained model on the Yelp dataset.
1419
textattack attack --attack-n --model bert-base-uncased-yelp --num-examples 8 \
1520
--goal-function untargeted-classification \
@@ -34,20 +39,27 @@ A `Transformation` takes as input an `AttackedText` and returns a list of possib
3439

3540
A `SearchMethod` takes as input an initial `GoalFunctionResult` and returns a final `GoalFunctionResult` The search is given access to the `get_transformations` function, which takes as input an `AttackedText` object and outputs a list of possible transformations filtered by meeting all of the attack’s constraints. A search consists of successive calls to `get_transformations` until the search succeeds (determined using `get_goal_results`) or is exhausted.
3641

42+
43+
3744
### On Benchmarking Attack Recipes
3845

39-
- Please read our analysis paper: Searching for a Search Method: Benchmarking Search Algorithms for Generating NLP Adversarial Examples at [EMNLP BlackBoxNLP](https://arxiv.org/abs/2009.06368).
46+
- Please read our analysis paper: Searching for a Search Method: Benchmarking Search Algorithms for Generating NLP Adversarial Examples at [EMNLP BlackBoxNLP](https://arxiv.org/abs/2009.06368).
47+
48+
- As we emphasized in the above paper, we don't recommend to directly compare Attack Recipes out of the box.
49+
50+
- This is due to that attack recipes in the recent literature used different ways or thresholds in setting up their constraints. Without the constraint space held constant, an increase in attack success rate could come from an improved search or a better transformation method or a less restrictive search space.
51+
4052

41-
- As we emphasized in the above paper, we don't recommend to directly compare Attack Recipes out of the box.
4253

43-
- This is due to that attack recipes in the recent literature used different ways or thresholds in setting up their constraints. Without the constraint space held constant, an increase in attack success rate could come from an improved search or a better transformation method or a less restrictive search space.
54+
### Four components in Attack Recipes we have implemented
4455

45-
### Four components in Attack Recipes we have implemented
4656

4757
- TextAttack provides clean, readable implementations of 16 adversarial attacks from the literature.
4858

4959
- To run an attack recipe: `textattack attack --recipe [recipe_name]`
5060

61+
62+
5163
<table style="width:100%" border="1">
5264
<thead>
5365
<tr class="header">
@@ -212,21 +224,13 @@ A `SearchMethod` takes as input an initial `GoalFunctionResult` and returns a fi
212224
<td ><sub>Greedy attack with goal of changing every word in the output translation. Currently implemented as black-box with plans to change to white-box as done in paper (["Seq2Sick: Evaluating the Robustness of Sequence-to-Sequence Models with Adversarial Examples" (Cheng et al., 2018)](https://arxiv.org/abs/1803.01128)) </sub> </td>
213225
</tr>
214226

215-
<tr><td style="text-align: center;" colspan="6"><strong><br>General: <br></strong></td></tr>
216-
217-
<tr class="odd">
218-
<td style="text-align: left;"><code>bad-characters</code> <span class="citation" data-cites=""></span></td>
219-
<td style="text-align: left;"><sub>TargetedClassification, TargetedStrict, TargetedBonus, NamedEntityRecognition, LogitSum, MinimizeBleu, MaximizeLevenshtein</sub></td>
220-
<td style="text-align: left;"></td>
221-
<td style="text-align: left;"><sub>(Homoglyph, Invisible Characters, Reorderings, Deletions) Word Swap</sub></td>
222-
<td style="text-align: left;"><sub>DifferentialEvolution</sub></td>
223-
<td><sub>Uses imperceptible character-level perturbations including homoglyph substitutions, Unicode reordering, deletions, and invisibles. Based on (["Bad Characters: Imperceptible NLP Attacks" (Boucher et al., 2021)](https://arxiv.org/abs/2106.09898)).</sub></td>
224-
</tr>
225227

226228
</tbody>
227229
</font>
228230
</table>
229231

232+
233+
230234
- Citations
231235

232236
```

0 commit comments

Comments
 (0)