Install conda or miniconda.
Optional: Install mamba. Mamba is much faster than Conda at resolving dependencies.
conda install mamba -n base -c conda-forge
Create an environment and install the dependencies. If you went with conda, run:
conda env create --file alpaca.yml
Otherwise, if you went with mamba, run:
mamba env create --file alpaca.yml
Activate the virtual environment.
conda activate alpaca
Upgrade pip:
pip install --upgrade pip
Manually install transformers. This needs to be done manually!
pip install git+https://github.com/huggingface/transformers
preprocessing.slurm. We follow the process in paper "Visualizing and Measuring the Geometry of BERT" (GitHub) to calculate word embeddings.get_FC.py, get_FT.py, and get_FK.py to calculate candidate perturbations generated by different semantic perturbation functions. We include a script (get_perturbation_candidates.slurm) to process for all models.attacks/attack.py to perform SemAttack. We include a script attack.slurm to perform attack for all models.Note: We also provide the processed perturbation candidates. You can download them at https://drive.google.com/file/d/103cRN_15sY246LSnqaG0nD3aO_p9VkaE/view?usp=sharing
Use atatcks/open_attack.py to perform other word-level attacks.
You may check the code for more details. You may also try different semantic perturbation functions and different attack parameters.
Python
95.8%
Shell
4.2%
Install conda or miniconda.
Optional: Install mamba. Mamba is much faster than Conda at resolving dependencies.
conda install mamba -n base -c conda-forge
Create an environment and install the dependencies. If you went with conda, run:
conda env create --file alpaca.yml
Otherwise, if you went with mamba, run:
mamba env create --file alpaca.yml
Activate the virtual environment.
conda activate alpaca
Upgrade pip:
pip install --upgrade pip
Manually install transformers. This needs to be done manually!
pip install git+https://github.com/huggingface/transformers
preprocessing.slurm. We follow the process in paper "Visualizing and Measuring the Geometry of BERT" (GitHub) to calculate word embeddings.get_FC.py, get_FT.py, and get_FK.py to calculate candidate perturbations generated by different semantic perturbation functions. We include a script (get_perturbation_candidates.slurm) to process for all models.attacks/attack.py to perform SemAttack. We include a script attack.slurm to perform attack for all models.Note: We also provide the processed perturbation candidates. You can download them at https://drive.google.com/file/d/103cRN_15sY246LSnqaG0nD3aO_p9VkaE/view?usp=sharing
Use atatcks/open_attack.py to perform other word-level attacks.
You may check the code for more details. You may also try different semantic perturbation functions and different attack parameters.
Python
95.8%
Shell
4.2%