OpenAttack  by thunlp

Text attack toolkit for evaluating & improving NLP model robustness

Created 5 years ago
751 stars

Top 46.2% on SourcePulse

GitHubView on GitHub
Project Summary

OpenAttack is a comprehensive Python toolkit designed for generating and evaluating textual adversarial attacks against NLP models. It caters to researchers and practitioners aiming to assess model robustness, develop new attack strategies, or implement adversarial training. The package streamlines the entire adversarial attack pipeline, from text preprocessing to victim model interaction and result evaluation.

How It Works

OpenAttack employs a modular architecture, separating concerns into TextProcessor, Victim, Attacker, AttackAssist, Metric, AttackEval, and DataManager. This design facilitates extensibility, allowing users to easily integrate custom datasets, victim models, or attack algorithms. It supports various attack types (sentence, word, character level; gradient, score, decision, blind) and offers parallel processing for improved efficiency. The toolkit is tightly integrated with Hugging Face's Transformers and Datasets libraries, simplifying the use of pre-trained models and datasets.

Quick Start & Requirements

  • Install via pip: pip install OpenAttack
  • Clone repo and install: git clone https://github.com/thunlp/OpenAttack.git && cd OpenAttack && python setup.py install
  • Requires Python.
  • Demo available: python demo.py
  • Examples and documentation: README

Highlighted Details

  • Supports 15 attack models, covering sentence, word, and character-level perturbations.
  • Offers multilinguality (English and Chinese) with an extensible design for more languages.
  • Fully compatible with 🤗 Hugging Face Transformers and Datasets.
  • Includes built-in victim models (e.g., BERT, RoBERTa) and supports custom victim models and datasets.

Maintenance & Community

  • Developed by THUNLP.
  • Contributions are welcomed.

Licensing & Compatibility

  • The README does not explicitly state a license. Compatibility for commercial use or closed-source linking is not specified.

Limitations & Caveats

The project's license is not clearly stated in the README, which may pose a barrier for commercial adoption or use in closed-source projects.

Health Check
Last Commit

2 years ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
10 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Yaowei Zheng Yaowei Zheng(Author of LLaMA-Factory), and
7 more.

TextAttack by QData

0.1%
3k
Python framework for NLP adversarial attacks, data augmentation, and model training
Created 6 years ago
Updated 2 months ago
Starred by Elie Bursztein Elie Bursztein(Cybersecurity Lead at Google DeepMind), Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), and
6 more.

llm-attacks by llm-attacks

0.2%
4k
Attack framework for aligned LLMs, based on a research paper
Created 2 years ago
Updated 1 year ago
Feedback? Help us improve.