-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·161 lines (139 loc) · 4.21 KB
/
run.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env bash
function clone_bcb() {
model=$1
mode_path=$2
tokenizer_path=$3
re=$4
python adv_clone_detection_bigclonebench.py \
--test_data_file ./dataset/clone_detection_bigclonebench/transforms.Identifier/adv_data.jsonl \
--model_name_or_path $mode_path \
--tokenizer_name $tokenizer_path \
--model $model \
--save_dir ./saved_models/ \
--task clone_bcb \
--num_examples -1 \
--recipe $re \
--parallel \
2>&1 | tee ./saved_models/$model/clone_detection_bigclonebench_$re_test.log
}
function clone_poj() {
model=$1
mode_path=$2
tokenizer_path=$3
re=$4
python adv_clone_detection_poj.py \
--test_data_file ./dataset/clone_detection_poj/transforms.Replace/adv_test.jsonl \
--model_name_or_path $mode_path \
--tokenizer_name $tokenizer_path \
--model $model \
--save_dir ./saved_models/ \
--task clone_poj \
--num_examples -1 \
--recipe $re \
--parallel \
2>&1 | tee ./saved_models/$model/clone_detection_poj_$re.log
}
function defect() {
model=$1
mode_path=$2
tokenizer_path=$3
re=$4
python adv_defect_detection.py \
--test_data_file ./dataset/defect_detection/transforms.Replace/adv_test.jsonl \
--model_name_or_path $mode_path \
--tokenizer_name $tokenizer_path \
--model $model \
--save_dir ./saved_models/ \
--task defect \
--num_examples -1 \
--recipe $re \
--parallel \
2>&1 | tee ./saved_models/$model/defect_detection_$re.log
}
function search() {
model=$1
mode_path=$2
tokenizer_path=$3
re=$4
python adv_search.py \
--test_data_file ./dataset/code_search/transforms.Replace/adv_test.jsonl \
--model_name_or_path $mode_path \
--tokenizer_name $tokenizer_path \
--model $model \
--save_dir ./saved_models/ \
--task search \
--num_examples -1 \
--recipe $re \
--parallel \
2>&1 | tee ./saved_models/$model/code_search_$re.log
}
function summarization() {
model=$1
mode_path=$2
tokenizer_path=$3
re=$4
python adv_summarization.py \
--test_data_file ./dataset/code_summarization/transforms.Replace/adv_test.jsonl \
--model_name_or_path $mode_path \
--tokenizer_name $tokenizer_path \
--model $model \
--save_dir ./saved_models/ \
--task summarization \
--num_examples 1000 \
--recipe $re \
--parallel \
2>&1 | tee ./saved_models/$model/code_summarization_$re.log
}
function codebert() {
task=$1
attack=$2
$task codebert microsoft/codebert-base roberta-base $attack
}
function codegpt() {
task=$1
attack=$2
$task codegpt microsoft/CodeGPT-small-java-adaptedGPT2 microsoft/CodeGPT-small-java-adaptedGPT2 $attack
}
function graphcodebert() {
task=$1
attack=$2
$task graphcodebert microsoft/graphcodebert-base microsoft/graphcodebert-base $attack
}
function codet5() {
task=$1
attack=$2
$task codet5 Salesforce/codet5-base Salesforce/codet5-base $attack
}
function codetrans() {
task=$1
attack=$2
$task codetrans SEBIS/code_trans_t5_base_transfer_learning_pretrain SEBIS/code_trans_t5_base_transfer_learning_pretrain $attack
}
function contracode() {
task=$1
attack=$2
$task contracode ./saved_models/contracode/ckpt_transformer_hybrid_pretrain_240k.pth ./saved_models/contracode/csnjs_8k_9995p_unigram_url.model $attack
}
function cotext() {
task=$1
attack=$2
$task cotext ./saved_models/cotext/cc/ ./saved_models/cotext/cc/sentencepiece.model $attack
}
function plbart() {
task=$1
attack=$2
$task plbart ./saved_models/plbart/checkpoint_11_100000.pt ./saved_models/plbart/sentencepiece.bpe.model $attack
}
model=$1
task=$2
# attack=$3
num=$#
one=1
stop_args=2
array=($@)
while [ ${num} != ${stop_args} ]
do
let "num-=one"
# echo "${array[num]}"
$model $task ${array[num]}
done