Skip to content

Commit

Permalink
Merge pull request #519 from QData/Add-textattack-highlevel-overview-…
Browse files Browse the repository at this point in the history
…diagram

Add a high level overview diagram to docs
  • Loading branch information
qiyanjun committed Sep 3, 2021
2 parents 60d179f + 9e99e90 commit 8181de0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ The [`examples/`](examples/) folder includes scripts showing common TextAttack u
The [documentation website](https://textattack.readthedocs.io/en/latest) contains walkthroughs explaining basic usage of TextAttack, including building a custom transformation and a custom constraint..



<img src="docs/_static/imgs/overview.png" alt="TextAttack Overview" style="display: block; margin: 0 auto;" />


### Running Attacks: `textattack attack --help`

The easiest way to try out an attack is via the command-line interface, `textattack attack`.
Expand Down
11 changes: 8 additions & 3 deletions docs/0_get_started/quick_api_tour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ TextAttack requires both the model and the tokenizer to be wrapped by a :class:`
Next, let's build the attack that we want to use. TextAttack provides prebuilt attacks in the form of :class:`~transformers.attack_recipes.AttackRecipe`. For this example, we will use :ref:TextFooler attack

Let us also load the IMDB dataset using 🤗 Datasets library. TextAttack also requires that the dataset

.. code-block::
>>> import datasets
>>> dataset = datasets.load_dataset("imdb", split="test")
>>> dataset = textattack.datasets.HuggingFaceDataset("imdb", split="test")
>>> attack = textattack.attack_recipes.TextFoolerJin2019.build(model_wrapper)
>>> # Attack 20 samples with CSV logging and checkpoint saved every 5 interval
>>> # Attack 20 samples with CSV logging and checkpoint saved every 5 interval
>>> attack_args = textattack.AttackArgs(num_examples=20, log_to_csv="log.csv", checkpoint_interval=5, checkpoint_dir="checkpoints", disable_stdout=True)
>>> attacker = textattack.Attacker(attack, dataset, attack_args)
>>> attacker.attack_dataset()
.. image:: ../_static/imgs/overview.png
Binary file added docs/_static/imgs/overview.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8181de0

Please sign in to comment.