TextAttack Documentation¶
Get Started
- Basic-Introduction
- Installation
- Command-Line Usage
- Quick API Usage
- FAQ
- Via Slack: Where to Ask Questions:
- Via CLI:
--help
- Via our papers: More details on results
- Via readthedocs: More details on APIs
- More Concrete Questions:
Recipes
- Attack Recipes CommandLine Use
- Attack Recipes API
- Attacks on classification models
- A2T (A2T: Attack for Adversarial Training Recipe)
- Alzantot Genetic Algorithm
- Faster Alzantot Genetic Algorithm
- BAE (BAE: BERT-Based Adversarial Examples)
- BERT-Attack:
- CheckList:
- DeepWordBug
- HotFlip
- Improved Genetic Algorithm
- Input Reduction
- Kuleshov2017
- Particle Swarm Optimization
- PWWS
- TextFooler (Is BERT Really Robust?)
- TextBugger
- CLARE Recipe
- Pruthi2019: Combating with Robust Word Recognition
- Attacks on sequence-to-sequence models
- Attacks on classification models
- Augmenter Recipes CommandLine Use
- Augmenter Recipes API
- TextAttack Model Zoo
- Available Models
- Evaluation Results of Available Models
- How we have trained the TextAttack Models
- Training details for each TextAttack Model
- More details on TextAttack fine-tuned NLP models (details on target NLP task, input type, output type, SOTA results on paperswithcode; model card on huggingface):
Using TextAttack
- What is an adversarial attack in NLP?
- How to Cite TextAttack
- Main Paper: TextAttack: A Framework for Adversarial Attacks, Data Augmentation, and Adversarial Training in NLP
- Our Analysis paper: Reevaluating Adversarial Examples in Natural Language
- Our Analysis paper: Searching for a Search Method: Benchmarking Search Algorithms for Generating NLP Adversarial Examples
- Our defense paper: Title: “Towards Improving Adversarial Training of NLP Models”
- Our extended use case paper: “Expanding Scope: Adapting English Adversarial Attacks to Chinese”
- Four Components of TextAttack Attacks
- Benchmarking Search Algorithms for Generating NLP Adversarial Examples
- On Quality of Generated Adversarial Examples and How to Set Attack Contraints
- Title: Reevaluating Adversarial Examples in Natural Language
- Our Github on Reevaluation: Reevaluating-NLP-Adversarial-Examples Github
- Some of our evaluation results on quality of two SOTA attack recipes
- Some of our evaluation results on how to set constraints to evaluate NLP model’s adversarial robustness
- Making Vanilla Adversarial Training of NLP Models Feasible!
- Lessons learned in designing TextAttack
- TextAttack Extended Functions (Multilingual)
- How can I contribute to TextAttack?
Notebook Tutorials
- Tutorial 0: TextAttack End-To-End (Train, Eval, Attack)
- Tutorial 1: Transformations
- Tutorial 2: Constraints
- Tutorial 3: Augmentation
- Tutorial 4: Custom Word Embeddings
- Tutorial 5: Attacking TensorFlow models
- Tutorial 6: Attacking scikit-learn models
- Tutorial 7: Attacking AllenNLP models
- Tutorial 8: Attacking Keras models
- Tutorial 9: Attacking multilingual models
- Tutorial10: Explaining Attacking BERT model using Captum
- Tutorial11: Attacking multilingual - Chinese NLP model using Textattack
API User Guide
Full Reference
- textattack package
- textattack.attack_recipes package
- Attack Recipes Package:
- A2T (A2T: Attack for Adversarial Training Recipe)
- Attack Recipe Class
- BAE (BAE: BERT-Based Adversarial Examples)
- BERT-Attack:
- CheckList:
- CLARE Recipe
- DeepWordBug
- Faster Alzantot Genetic Algorithm
- Alzantot Genetic Algorithm
- HotFlip
- Improved Genetic Algorithm
- Input Reduction
- Kuleshov2017
- MORPHEUS2020
- Pruthi2019: Combating with Robust Word Recognition
- Particle Swarm Optimization
- PWWS
- Seq2Sick
- TextBugger
- TextFooler (Is BERT Really Robust?)
- textattack.attack_results package
- textattack.augmentation package
- textattack.commands package
- textattack.constraints package
- Constraints
- textattack.constraints.grammaticality package
- Grammaticality:
- textattack.constraints.grammaticality.language_models package
- CoLA for Grammaticality
- LanguageTool Grammar Checker
- Part of Speech Constraint
- textattack.constraints.overlap package
- textattack.constraints.pre_transformation package
- textattack.constraints.semantics package
- Semantic Constraints
- textattack.constraints.semantics.sentence_encoders package
- BERT Score
- Word Embedding Distance
- TextAttack Constraint Class
- Pre-Transformation Constraint Class
- textattack.datasets package
- textattack.goal_function_results package
- textattack.goal_functions package
- textattack.loggers package
- textattack.metrics package
- textattack.models package
- textattack.search_methods package
- Search Methods
- Reimplementation of search method from Generating Natural Language Adversarial Examples
- Beam Search
- Genetic Algorithm Word Swap
- Greedy Search
- Greedy Word Swap with Word Importance Ranking
- Reimplementation of search method from Xiaosen Wang, Hao Jin, Kun He (2019).
- Particle Swarm Optimization
- Population based Search
- Search Method Abstract Class
- textattack.shared package
- textattack.transformations package
- Transformations
- textattack.transformations.sentence_transformations package
- textattack.transformations.word_insertions package
- textattack.transformations.word_merges package
- textattack.transformations.word_swaps package
- word_swaps package
- Word Swap
- Word Swap by Changing Location
- Word Swap by Changing Name
- Word Swap by Changing Number
- Word Swap by Contraction
- Word Swap by Embedding
- Word Swap by Extension
- Word Swap by Gradient
- Word Swap by Homoglyph
- Word Swap by OpenHowNet
- Word Swap by inflections
- Word Swap by BERT-Masked LM.
- Word Swap by Neighboring Character Swap
- Word Swap by swaps characters with QWERTY adjacent keys
- Word Swap by Random Character Deletion
- Word Swap by Random Character Insertion
- Word Swap by Random Character Substitution
- Word Swap by swapping synonyms in WordNet
- Composite Transformation
- Transformation Abstract Class
- word deletion Transformation
- Word Swap Transformation by swapping the order of words
- Attack Class
- AttackArgs Class
- Attacker Class
- AugmenterArgs Class
- DatasetArgs Class
- ModelArgs Class
- Trainer Class
- TrainingArgs Class
- textattack.attack_recipes package