forked from ruizheng20/robust_ticket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
attack_ticket.sh
64 lines (57 loc) · 1.86 KB
/
attack_ticket.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
export CUDA_DEVICE_ORDER=PCI_BUS_ID
export CUDA_VISIBLE_DEVICES=0
all_attack_type=("textfooler" "bertattack" "textbugger")
log_file="robust-ticket.log"
# IMDB
model_log=imdb_robust-ticket
file='./your_draw-retrain-ticket_path' # model for attack
for attack_method in "${all_attack_type[@]}"
do
python attack_ticket_more_attackers.py \
--model_name_or_path $file \
--num_examples 1000 \
--dataset_name imdb \
--neighbour_vocab_size 50 \
--modify_ratio 0.9 \
--sentence_similarity 0.2 \
--attack_method ${attack_method} \
--attack_log ${model_log}_${attack_method}.csv \
--official_log ${model_log}_${attack_method}_official.csv \
--perturbed_file ${model_log}_${attack_method}_perturbed_sentences.csv >> ${log_file}
done
# AGNEWS
model_log=agnews_robust-ticket
file='./your_draw-retrain-ticket_path' # model for attack
for attack_method in "${all_attack_type[@]}"
do
python attack_ticket_more_attackers.py \
--model_name_or_path $file \
--num_examples 1000 \
--dataset_name ag_news \
--neighbour_vocab_size 50 \
--modify_ratio 0.9 \
--sentence_similarity 0.2 \
--attack_method ${attack_method} \
--attack_log ${model_log}_${attack_method}.csv \
--official_log ${model_log}_${attack_method}_official.csv \
--perturbed_file ${model_log}_${attack_method}_perturbed_sentences.csv >> ${log_file}
done
# SST-2
model_log=sst2_robust-ticket
file='./your_draw-retrain-ticket_path' # model for attack
for attack_method in "${all_attack_type[@]}"
do
python attack_ticket_more_attackers.py \
--model_name_or_path $file \
--num_examples 1000 \
--dataset_name glue \
--task_name sst2 \
--neighbour_vocab_size 50 \
--modify_ratio 0.9 \
--sentence_similarity 0.2 \
--attack_method ${attack_method} \
--attack_log ${model_log}_${attack_method}.csv \
--official_log ${model_log}_${attack_method}_official.csv \
--perturbed_file ${model_log}_${attack_method}_perturbed_sentences.csv >> ${log_file}
done