Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dependencies #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions evaluate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from src.eval.eval_util import GPT2_processor
from src.data_util.dataloader import get_task_type
import pickle
Expand Down Expand Up @@ -78,6 +79,7 @@ def reduplicate_list(item_list):
print("attack success rate: ", success / (success + fail))
print("avg ppl: ", np.mean(ppl_by_sample))

os.makedirs("adv_examples", exist_ok=True)

save_name = f"adv_examples/attack_{args.victim}_{args.dataset}.txt"
assert len(adv_by_sample) == len(orig_sentences)
Expand Down
5 changes: 5 additions & 0 deletions run_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import torch
import pickle
import os

import nltk
nltk.download('averaged_perceptron_tagger')
nltk.download('wordnet')

from src.logging.logger import LogModule
from src.attack.text_grad import PGDAttack

Expand Down