GithubHelp home page GithubHelp logo

classicvalues / adversarial-polyglots Goto Github PK

View Code? Open in Web Editor NEW

This project forked from salesforce/adversarial-polyglots

2.0 1.0 0.0 32 KB

Code for the paper "Code-Mixing on Sesame Street: Dawn of the Adversarial Polyglots" (NAACL-HLT 2021)

License: Apache License 2.0

Python 100.00%

adversarial-polyglots's Introduction

Adversarial Polyglots

This repository contains code for the paper "Code-Mixing on Sesame Street: Dawn of the Adversarial Polyglots" (NAACL-HLT 2021).

Authors: Samson Tan and Shafiq Joty

Usage

Adversarial Polyglots

Scripts for running PolyGloss and Bumblebee on NLI and QA datasets (MNLI/SQuAD formats) are in the attacks folder. Preprocessing scripts can be found in scripts. PolyGloss and Bumblebee return the adversarial examples with the highest and lowest losses. The one that induced the lower loss (minimally perturbed) is usually less perturbed, but the one that induced a higher loss (maximally perturbed) should transfer more successfully to other models.

PolyGloss requires a dictionary constructed from the bilingual MUSE dictionaries. After downloading the dictionaries into a folder under scripts labeled dictionaries, run scripts/create_polygloss_dictionaries_from_muse.py.

Bumblebee requires a dictionary/JSON consisting of sentence-translations pairs. The extract-xnli-sentences-to-dict.py and extract-xquad-questions-to-dict.py scripts in scripts can be used to create these dictionaries for files in the MNLI and SQuAD formats (e.g., XNLI and XQuAD). JSONs for the XNLI test set can be found here.

Code-mixed Adversarial Training

Code for generating code-mixed adversarial training (CAT) examples are in adversarial-training. Since the alignment step is the most time-consuming, we decouple it from the example perturbation step. Users can generate only the alignments by using the --extract_phrases option or load precomputed alignments via the phrase_alignments option.

Similar to Bumblebee, Code-Mixer requires a dictionary/JSON consisting of sentence-translations pairs. The extract-xnli-sentences-to-dict.py and extract-xquad-questions-to-dict.py scripts in scripts can be used to create these dictionaries for files in the MNLI and SQuAD formats (e.g., XNLI and XQuAD).

Translated XNLI Data

We translated the XNLI data to 18 other languages using machine-translation systems (see paper for details). Translation script is in scripts. Translated data can be found here.

Citation

Please cite the following if you use the code/data in this repository:

@inproceedings{tan-joty-2021-code-mixing,
    title = "Code-Mixing on Sesame Street: {D}awn of the Adversarial Polyglots",
    author = "Tan, Samson and Joty, Shafiq",
    booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
    month = jun,
    year = "2021",
    address = "Online",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/2021.naacl-main.282",
    pages = "3596--3616",
}

adversarial-polyglots's People

Contributors

samsontmr avatar

Stargazers

 avatar Classic Values 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.