Git Product home page Git Product logo

leap's Introduction

LEAP

An efficient and automated test method for NLP software.

Code release and supplementary materials for:
"LEAP: Efficient and Automated Test Method for NLP Software"
The 38th IEEE/ACM International Conference on Automated Software Engineering (ASE 2023)

Datesets

There are three datasets used in our experiments:

Repo structure

  • datasets: define the dataset object used for carrying out attacks
  • goal_functions: determine if the test method generates successful test cases
  • search_methods: explore the space of potential transformations and try to locate a successful perturbation
  • transformations: transform the input text, e.g. synonym replacement
  • constraints: determine whether or not a given transformation is valid

The most important files in this project are as follows:

  • victim models.zip: victim models obtained by training on three datasets
  • search_methods/leap.py: search test cases based on PSO
  • attack_recipes/leap_2023.py: code to execute LEAP in the TextAttack framework
  • leap_demo.ipynb: an example of testing the fine-tuned "bert-base-uncased" model on the "AG's News" dataset

Dependencies

The code was tested with:

  • bert-score>=0.3.5
  • editdistance
  • flair
  • filelock
  • language_tool_python
  • lemminflect
  • lru-dict
  • datasets
  • nltk
  • numpy>=1.19.2
  • pandas>=1.0.1
  • scipy>=1.4.1
  • torch>=1.7.0,!=1.8
  • transformers>=3.3.0
  • terminaltables
  • tqdm>=4.27,<4.50.0
  • word2number
  • num2words
  • more-itertools
  • PySocks!=1.5.7,>=1.5.6

How to Run:

Follow these steps to run the attack from the library:

  1. Fork this repository

  2. Run the following command to install it.

    $ pip install -e . ".[dev]"
    
  3. Run notebook leap_demo.ipynb to test the fine-tuned "bert-base-uncased" model on the "AG's News" dataset

Take a look at the models directory in TextAttack to run the attack across any dataset and any target model.

Supplementary

Experimental result of LEAP on the query times

In RQ2 of Section V EXPERIMENT RESULTS AND ANALYSIS, we measure the efficiency of the test method based on the time overhead and the query times, and due to space constraints, we report the experimental results for the query times in the repository.

image

Similar to the experiment on time overhead, the table presents the average query times per successful generation of a test case on the long-text datasets IMDB and AG's News. Compared to existing heuristic testing methods, LEAP demonstrates suboptimal performance in terms of query times. Although IGA has lower query times than LEAP, its time overhead is higher across all victim models, and its success rate in generating test cases is also lower than LEAP.

License

This code and model are available for non-commercial scientific research purposes as defined in the LICENSE file. By downloading and using the code and model you agree to the terms in the LICENSE.

Acknowledgement

This code is based on the TextAttack framework.

leap's People

Contributors

lumos-xiao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.