Home

Awesome

Synonyms Encoding Method (SEM)

This repository contains necessary code for reproducing main results in the paper:

Natural Language Adversarial Defense through Synonym Encoding (UAI 2021)

Xiaosen Wang, Hao Jin, Yichen Yang and Kun He

For IGA attack, please refer to IGA!

Datesets

There are three datasets used in our experiments:

Requirements

The code was tested with:

File Description

Experiments

  1. Generating the embedding matrix for original dictionary and encoded dictionary:

    python build_embedding.py
    
  2. Training the models with the original word dictionary:

    python train_orig.py --data aclImdb --sn 10 --sigma 0.5 --nn_type textrnn
    
  3. Training the models with the encoded word dictionary:

    python train_enc.py --data aclImdb --sn 10 --sigma 0.5 --nn_type textrnn
    

Contact

This repository is under active development. Questions and suggestions can be sent to xswanghuster@gmail.com.