-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_pred_clm.sh
1063 lines (994 loc) · 45.2 KB
/
run_pred_clm.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Define the usage function to print the help message
usage() {
echo "Usage: $0 [options] [positional arguments]"
echo "Options:"
echo " --dataset_name <value> Name of the dataset"
echo " --model_org <value> Organization of the model"
echo " --model_name <value> Name of the model"
echo " --qr_model_org <value> Organization of the QR model"
echo " --qr_model_name <value> Name of the QR model"
echo " --lm_target_epoch <value> Epoch for LM target"
echo " --qr_validation_percent <value> Validation Percent for QR model"
echo " --qr_score <value> Score Function for QR model"
echo " --train_target Set TRAIN_TARGET to true"
echo " --pred_target Set PRED_TARGET to true"
echo " --run_mse_pinball Set RUN_MSE_PINBALL to true"
echo " --run_gaussian Set RUN_GAUSSIAN to true"
echo " --run_iqr Set RUN_IQR to true"
echo " --run_gaussian_pinball set RUN_GAUSSIAN_PINBALL to true"
echo " --train_shadow Set TRAIN_SHADOW to true"
echo " --pred_shadow Set PRED_SHADOW to true"
echo " --extend_task_pred Set EXTEND_TASK_PRED to true"
echo " --shadow_start <value> Index of Shadow start"
echo " --shadow_end <value> Index of Shadow end"
echo " --use_deepspeed Set USE_DEEPSPEED to true"
echo " --deepspeed_level <value> Level of deepspeed to use"
echo " --qr_lr <value> Learning rate of QR model"
echo " --seeds <value> Seeds for QR model training"
echo " --qr_train_batch_size <value> Batch size for QR model training"
echo " --qr_full_batch_size <value> Full batch size for qr model training"
echo " --prefix_dir <value> Root directory for storing results"
echo " -h, --help Display this help message"
}
# Define the long options
longopts="dataset_name:,model_org:,model_name:,qr_model_org:,qr_model_name:,lm_target_epoch:,qr_validation_percent:,qr_score:,train_target,pred_target,run_mse_pinball,run_gaussian,run_iqr,run_gaussian_pinball,train_shadow,pred_shadow,extend_task_pred,shadow_start:,shadow_end:,use_deepspeed,deepspeed_level:,qr_lr:,seeds:,qr_train_batch_size:,qr_full_batch_size:,prefix_dir:,help"
# Parse the command line arguments using getopt
args=$(getopt -a -o h --long $longopts -- "$@")
# Check if getopt command was successful
if [ "$?" -ne 0 ]; then
usage
exit 1
fi
# Evaluate the set of parsed arguments
eval set -- "$args"
# Initialize variables for options
# dataset name should be from wikitext, wikitext_sample, xsum, ag_news
DATASET_NAME=wikitext_sample
LM_TARGET_EPOCH=1
MODEL_ORG=facebook
MODEL_NAME=opt-6.7b
QR_MODEL_ORG=facebook
QR_MODEL_NAME=opt-125m
TRAIN_TARGET=false
PRED_TARGET=false
RUN_MSE_PINBALL=false
RUN_GAUSSIAN=false
RUN_IQR=false
RUN_GAUSSIAN_PINBALL=false
TRAIN_SHADOW=false
PRED_SHADOW=false
EXTEND_TASK_PRED=false
SHADOW_START=1
SHADOW_END=4
USE_DEEPSPEED=false
PRED_USE_DEEPSPEED=false
DEEPSPEED_LEVEL=3
USE_FP16=True
TORCH_DTYPE="float16"
QR_VALIDATION_PERCENT=5
QR_SCORE="nce"
QR_LR="2e-5"
SEEDS="42 1024 512 2048 256"
QR_TRAIN_BATCH_SIZE=8
QR_FULL_BATCH_SIZE=128
PREFIX_DIR="."
# Loop through the arguments and set the variables accordingly
while true; do
case "$1" in
--dataset_name)
DATASET_NAME="$2"
shift 2 ;;
--model_org)
MODEL_ORG="$2"
shift 2 ;;
--model_name)
MODEL_NAME="$2"
shift 2 ;;
--qr_model_org)
QR_MODEL_ORG="$2"
shift 2 ;;
--qr_model_name)
QR_MODEL_NAME="$2"
shift 2 ;;
--lm_target_epoch)
LM_TARGET_EPOCH="$2"
shift 2 ;;
--qr_validation_percent)
QR_VALIDATION_PERCENT="$2"
shift 2 ;;
--qr_score)
QR_SCORE="$2"
shift 2 ;;
--train_target)
TRAIN_TARGET=true
shift ;;
--pred_target)
PRED_TARGET=true
shift ;;
--run_mse_pinball)
RUN_MSE_PINBALL=true
shift ;;
--run_gaussian)
RUN_GAUSSIAN=true
shift ;;
--run_iqr)
RUN_IQR=true
shift ;;
--run_gaussian_pinball)
RUN_GAUSSIAN_PINBALL=true
shift ;;
--train_shadow)
TRAIN_SHADOW=true
shift ;;
--pred_shadow)
PRED_SHADOW=true
shift ;;
--extend_task_pred)
EXTEND_TASK_PRED=true
shift ;;
--shadow_start)
SHADOW_START="$2"
shift 2 ;;
--shadow_end)
SHADOW_END="$2"
shift 2 ;;
--use_deepspeed)
USE_DEEPSPEED=true
shift ;;
--deepspeed_level)
DEEPSPEED_LEVEL="$2"
shift 2 ;;
--qr_lr)
QR_LR="$2"
shift 2 ;;
--seeds)
SEEDS="$2"
shift 2 ;;
--qr_train_batch_size)
QR_TRAIN_BATCH_SIZE="$2"
shift 2 ;;
--qr_full_batch_size)
QR_FULL_BATCH_SIZE="$2"
shift 2 ;;
--prefix_dir)
PREFIX_DIR="$2"
shift 2 ;;
-h | --help)
usage
exit 0 ;;
--)
shift
break ;;
*)
echo "Unknown option: $1"
usage
exit 1 ;;
esac
done
NUM_CORES=8
CUDA_DEVICES="0,1,2,3,4,5,6,7"
GRADIENT_ACCUMULATION_STEPS=$(($(($QR_FULL_BATCH_SIZE / $QR_TRAIN_BATCH_SIZE)) / $NUM_CORES))
# Print the values of the variables
echo "DATASET_NAME: $DATASET_NAME"
echo "MODEL_ORG: $MODEL_ORG"
echo "MODEL_NAME: $MODEL_NAME"
echo "QR_MODEL_ORG: $QR_MODEL_ORG"
echo "QR_MODEL_NAME: $QR_MODEL_NAME"
echo "LM_TARGET_EPOCH: $LM_TARGET_EPOCH"
echo "QR_VALIDATION_PERCENT: $QR_VALIDATION_PERCENT"
echo "QR_SCORE: $QR_SCORE"
echo "TRAIN_TARGET: $TRAIN_TARGET"
echo "PRED_TARGET: $PRED_TARGET"
echo "RUN_MSE_PINBALL: $RUN_MSE_PINBALL"
echo "RUN_GAUSSIAN: $RUN_GAUSSIAN"
echo "RUN_IQR: $RUN_IQR"
echo "RUN_GAUSSIAN_PINBALL: $RUN_GAUSSIAN_PINBALL"
echo "TRAIN_SHADOW: $TRAIN_SHADOW"
echo "PRED_SHADOW: $PRED_SHADOW"
echo "EXTEND_TASK_PRED: $EXTEND_TASK_PRED"
echo "SHADOW_START: $SHADOW_START"
echo "SHADOW_END: $SHADOW_END"
echo "USE_DEEPSPEED: $USE_DEEPSPEED"
echo "DEEPSPEED_LEVEL: $DEEPSPEED_LEVEL"
echo "QR_LR: $QR_LR"
echo "SEEDS: $SEEDS"
echo "QR_TRAIN_BATCH_SIZE: $QR_TRAIN_BATCH_SIZE"
echo "QR_FULL_BATCH_SIZE: $QR_FULL_BATCH_SIZE"
echo "GRADIENT_ACCUMULATION_STEPS: $GRADIENT_ACCUMULATION_STEPS"
echo "PREFIX_DIR: $PREFIX_DIR"
case "$DEEPSPEED_LEVEL" in
"1")
DEEPSPEED_CONFIG=ds_config_stage1.json
;;
"2")
DEEPSPEED_CONFIG=ds_config_stage2_mod.json
;;
"3")
DEEPSPEED_CONFIG=ds_config_stage3_mod.json
;;
esac
# default parameters
MAX_SEQ_LENGTH=768
PUBLIC_PRIVATE_VAL_RATIO="0.45,0.45,0.1"
case "$DATASET_NAME" in
"wikitext_sample")
DATASET=wikitext
DATASET_CONFIG=wikitext-103-raw-v1
TEXT_COLUMN_NAME=text
DATASET_NAME=wikitext_sample
DATASET_FILE_NAME=wikitext
SAMPLE_MIN_NUM_CHARS=25
CHECK_POINT_NUM=
case "$LM_TARGET_EPOCH" in
"1")
CHECK_POINT_NUM=1585
SHADOW_CHECK_POINT_NUMS="1415 1416 1417 1418 1419 1420 1421 1422"
;;
"2")
CHECK_POINT_NUM=3171
SHADOW_CHECK_POINT_NUMS="2836 2839"
;;
"3")
CHECK_POINT_NUM=4755
SHADOW_CHECK_POINT_NUMS="4254 4257"
;;
esac
PUBLIC_PRIVATE_VAL_RATIO="0.1,0.1,0.025"
;;
"xsum")
DATASET=EdinburghNLP/xsum
DATASET_CONFIG=default
TEXT_COLUMN_NAME=document
DATASET_NAME=xsum
DATASET_FILE_NAME=EdinburghNLP_xsum
SAMPLE_MIN_NUM_CHARS=0
case "$LM_TARGET_EPOCH" in
"1")
CHECK_POINT_NUM=1431
SHADOW_CHECK_POINT_NUMS="1296"
;;
"2")
CHECK_POINT_NUM=2863
SHADOW_CHECK_POINT_NUMS="2592"
;;
"3")
CHECK_POINT_NUM=4293
SHADOW_CHECK_POINT_NUMS="3888"
;;
esac
;;
"ag_news")
DATASET=ag_news
DATASET_CONFIG=default
TEXT_COLUMN_NAME=text
DATASET_NAME=ag_news
DATASET_FILE_NAME=ag_news
SAMPLE_MIN_NUM_CHARS=0
case "$LM_TARGET_EPOCH" in
"1")
CHECK_POINT_NUM=800
SHADOW_CHECK_POINT_NUMS="725"
;;
"2")
CHECK_POINT_NUM=1600
SHADOW_CHECK_POINT_NUMS="1450"
;;
"3")
CHECK_POINT_NUM=2400
SHADOW_CHECK_POINT_NUMS="2175"
;;
esac
;;
esac
MASTER_PORT=29800
LM_TRAIN_BATCH_SIZE=1
LM_PRED_BATCH_SIZE=1
LM_GRADIENT_ACCUMULATION_STEPS=8
LM_NUM_TRAIN_EPOCHS=3
PREDICT_SPLITS="public_train,public_test,private,validation"
NUM_EXPERIMENTS=None
EXPERIMENT_IDX=None
REGRESSION_NUM_EPOCHS=4
QR_TRAIN_SPLIT="public_train"
TEST_PRIVATE_SPLIT="private"
TEST_PUBLIC_SPLIT="public_test"
SENTENCE_KEYS=${TEXT_COLUMN_NAME}
# # # train target model
if ${TRAIN_TARGET}; then
echo "training target model"
for SEED in 42
do
if ${USE_DEEPSPEED}; then
WORLD_SIZE=${NUM_CORES} deepspeed -i "localhost:${CUDA_DEVICES}" --master_port ${MASTER_PORT} run_clm_lira.py \
--deepspeed ${DEEPSPEED_CONFIG} \
--model_name_or_path ${MODEL_ORG}/${MODEL_NAME} \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--text_column_name ${TEXT_COLUMN_NAME} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--torch_dtype ${TORCH_DTYPE} \
--fp16 ${USE_FP16} \
--do_train \
--do_eval \
--block_size ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${LM_TRAIN_BATCH_SIZE} \
--per_device_eval_batch_size ${LM_TRAIN_BATCH_SIZE} \
--gradient_accumulation_steps ${LM_GRADIENT_ACCUMULATION_STEPS} \
--learning_rate 5e-5 \
--num_train_epochs ${LM_NUM_TRAIN_EPOCHS} \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--add_bos_eos \
--output_dir "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_model/expid_xx/$SEED" \
--overwrite_output_dir \
--save_only_model \
--logging_strategy epoch \
--evaluation_strategy epoch \
--save_strategy epoch \
--logging_steps 100 \
--eval_steps 100 \
--save_steps 100 \
--seed $SEED \
--overwrite_cache
else
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_clm_lira.py \
--model_name_or_path ${MODEL_ORG}/${MODEL_NAME} \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--text_column_name ${TEXT_COLUMN_NAME} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--do_train \
--do_eval \
--block_size ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${LM_TRAIN_BATCH_SIZE} \
--per_device_eval_batch_size ${LM_TRAIN_BATCH_SIZE} \
--gradient_accumulation_steps ${LM_GRADIENT_ACCUMULATION_STEPS} \
--learning_rate 5e-5 \
--num_train_epochs ${LM_NUM_TRAIN_EPOCHS} \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--add_bos_eos \
--output_dir "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_model/expid_xx/$SEED" \
--overwrite_output_dir \
--save_only_model \
--logging_strategy epoch \
--evaluation_strategy epoch \
--save_strategy epoch \
--logging_steps 100 \
--eval_steps 100 \
--save_steps 100 \
--seed $SEED \
--overwrite_cache
fi
done
fi
# # # # make prediction and create quantile regression datasets
if ${PRED_TARGET}; then
echo "predicting using target model"
for SEED in 42
do
if [ "$CHECK_POINT_NUM" = "0" ]; then
LM_INPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_model/expid_xx/$SEED/"
LM_PRED_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/$SEED/"
else
LM_INPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_model/expid_xx/$SEED/checkpoint-${CHECK_POINT_NUM}"
LM_PRED_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/$SEED/checkpoint-${CHECK_POINT_NUM}"
fi
echo "lm_input_dir=${LM_INPUT_DIR}"
echo "lm_prd_dir=${LM_PRED_DIR}"
if ${PRED_USE_DEEPSPEED}; then
WORLD_SIZE=${NUM_CORES} deepspeed -i "localhost:${CUDA_DEVICES}" --master_port ${MASTER_PORT} run_clm_lira.py \
--deepspeed ${DEEPSPEED_CONFIG} \
--model_name_or_path ${LM_INPUT_DIR} \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--text_column_name ${TEXT_COLUMN_NAME} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--torch_dtype ${TORCH_DTYPE} \
--do_predict \
--block_size ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${LM_PRED_BATCH_SIZE} \
--per_device_eval_batch_size ${LM_PRED_BATCH_SIZE} \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--add_bos_eos \
--output_dir ${LM_PRED_DIR} \
--seed $SEED \
--predict_split ${PREDICT_SPLITS} \
--predict_normalize \
--overwrite_cache \
--predict_chunk_size 16384
else
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_clm_lira.py \
--model_name_or_path ${LM_INPUT_DIR} \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--text_column_name ${TEXT_COLUMN_NAME} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--do_predict \
--block_size ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${LM_PRED_BATCH_SIZE} \
--per_device_eval_batch_size ${LM_PRED_BATCH_SIZE} \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--add_bos_eos \
--output_dir ${LM_PRED_DIR} \
--seed $SEED \
--predict_split ${PREDICT_SPLITS} \
--predict_normalize \
--overwrite_cache \
--predict_chunk_size 16384
fi
done
fi
# # # train shadow models
if ${TRAIN_SHADOW}; then
echo "training shadow model"
for SEED in 42
do
for IDX in $(seq $SHADOW_START $SHADOW_END)
do
if ${USE_DEEPSPEED}; then
WORLD_SIZE=${NUM_CORES} deepspeed -i "localhost:${CUDA_DEVICES}" --master_port ${MASTER_PORT} run_clm_lira.py \
--deepspeed ${DEEPSPEED_CONFIG} \
--model_name_or_path ${MODEL_ORG}/${MODEL_NAME} \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--text_column_name ${TEXT_COLUMN_NAME} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--torch_dtype ${TORCH_DTYPE} \
--fp16 ${USE_FP16} \
--do_train \
--do_eval \
--block_size ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${LM_TRAIN_BATCH_SIZE} \
--per_device_eval_batch_size ${LM_TRAIN_BATCH_SIZE} \
--gradient_accumulation_steps ${LM_GRADIENT_ACCUMULATION_STEPS} \
--learning_rate 5e-5 \
--num_train_epochs ${LM_NUM_TRAIN_EPOCHS} \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--experiment_idx ${IDX}\
--add_bos_eos \
--output_dir "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_model/expid_${IDX}/$SEED" \
--overwrite_output_dir \
--save_only_model \
--logging_strategy epoch \
--evaluation_strategy epoch \
--save_strategy epoch \
--logging_steps 100 \
--eval_steps 100 \
--save_steps 100 \
--seed $SEED \
--overwrite_cache \
--use_public_for_training
else
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_clm_lira.py \
--model_name_or_path ${MODEL_ORG}/${MODEL_NAME} \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--text_column_name ${TEXT_COLUMN_NAME} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--do_train \
--do_eval \
--block_size ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${LM_TRAIN_BATCH_SIZE} \
--per_device_eval_batch_size ${LM_TRAIN_BATCH_SIZE} \
--gradient_accumulation_steps ${LM_GRADIENT_ACCUMULATION_STEPS} \
--learning_rate 5e-5 \
--num_train_epochs ${LM_NUM_TRAIN_EPOCHS} \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--experiment_idx ${IDX}\
--add_bos_eos \
--output_dir "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_model/expid_${IDX}/$SEED" \
--overwrite_output_dir \
--save_only_model \
--logging_strategy epoch \
--evaluation_strategy epoch \
--save_strategy epoch \
--logging_steps 100 \
--eval_steps 100 \
--save_steps 100 \
--seed $SEED \
--overwrite_cache \
--use_public_for_training
fi
done
done
fi
# # # # make prediction and create quantile regression datasets
if ${PRED_SHADOW}; then
echo "predicting using shadow model"
for SEED in 42
do
for IDX in $(seq $SHADOW_START $SHADOW_END)
do
if [ "$SHADOW_CHECK_POINT_NUMS" = "0" ]; then
if ${PRED_USE_DEEPSPEED}; then
WORLD_SIZE=${NUM_CORES} deepspeed -i "localhost:${CUDA_DEVICES}" --master_port ${MASTER_PORT} run_clm_lira.py \
--deepspeed ${DEEPSPEED_CONFIG} \
--model_name_or_path "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_model/expid_${IDX}/$SEED" \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--text_column_name ${TEXT_COLUMN_NAME} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--torch_dtype ${TORCH_DTYPE} \
--do_predict \
--block_size ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${LM_PRED_BATCH_SIZE} \
--per_device_eval_batch_size ${LM_PRED_BATCH_SIZE} \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--add_bos_eos \
--output_dir "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_pred/expid_${IDX}/$SEED" \
--seed $SEED \
--predict_split ${PREDICT_SPLITS} \
--predict_normalize \
--overwrite_cache \
--predict_chunk_size 16384
else
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_clm_lira.py \
--model_name_or_path "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_model/expid_${IDX}/$SEED" \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--text_column_name ${TEXT_COLUMN_NAME} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--do_predict \
--block_size ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${LM_PRED_BATCH_SIZE} \
--per_device_eval_batch_size ${LM_PRED_BATCH_SIZE} \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--add_bos_eos \
--output_dir "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_pred/expid_${IDX}/$SEED" \
--seed $SEED \
--predict_split ${PREDICT_SPLITS} \
--predict_normalize \
--overwrite_cache \
--predict_chunk_size 16384
fi
else
for SHADOW_CHECK_POINT_NUM in ${SHADOW_CHECK_POINT_NUMS}
do
if [ -d "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_model/expid_${IDX}/$SEED/checkpoint-${SHADOW_CHECK_POINT_NUM}" ]; then
echo "shadow prediction from checkpoint ${SHADOW_CHECK_POINT_NUM}"
if ${PRED_USE_DEEPSPEED}; then
WORLD_SIZE=${NUM_CORES} deepspeed -i "localhost:${CUDA_DEVICES}" --master_port ${MASTER_PORT} run_clm_lira.py \
--deepspeed ${DEEPSPEED_CONFIG} \
--model_name_or_path "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_model/expid_${IDX}/$SEED/checkpoint-${SHADOW_CHECK_POINT_NUM}" \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--text_column_name ${TEXT_COLUMN_NAME} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--torch_dtype ${TORCH_DTYPE} \
--do_predict \
--block_size ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${LM_PRED_BATCH_SIZE} \
--per_device_eval_batch_size ${LM_PRED_BATCH_SIZE} \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--add_bos_eos \
--output_dir "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_pred/expid_${IDX}/$SEED/checkpoint-${SHADOW_CHECK_POINT_NUM}" \
--seed $SEED \
--predict_split ${PREDICT_SPLITS} \
--predict_normalize \
--overwrite_cache \
--predict_chunk_size 16384
else
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_clm_lira.py \
--model_name_or_path "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_model/expid_${IDX}/$SEED/checkpoint-${SHADOW_CHECK_POINT_NUM}" \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--text_column_name ${TEXT_COLUMN_NAME} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--do_predict \
--block_size ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${LM_PRED_BATCH_SIZE} \
--per_device_eval_batch_size ${LM_PRED_BATCH_SIZE} \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--add_bos_eos \
--output_dir "${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/shadow_pred/expid_${IDX}/$SEED/checkpoint-${SHADOW_CHECK_POINT_NUM}" \
--seed $SEED \
--predict_split ${PREDICT_SPLITS} \
--predict_normalize \
--overwrite_cache \
--predict_chunk_size 16384
fi
fi
done
fi
done
done
fi
if ${EXTEND_TASK_PRED}; then
echo "extending task pred file"
PREFIX_DIR="/home/rongtz/test/mia/"
for SEED in 42
do
if [ "$CHECK_POINT_NUM" = "0" ]; then
LM_PRED_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/$SEED/"
else
LM_PRED_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/$SEED/checkpoint-${CHECK_POINT_NUM}"
fi
echo "task_pred_dir=${LM_PRED_DIR}"
python compute_extend_clm_scores.py \
--task_name ${DATASET} \
--text_column_name ${TEXT_COLUMN_NAME} \
--task_pred_dir ${LM_PRED_DIR} \
--task_seed $SEED \
--num_experiments ${NUM_EXPERIMENTS} \
--experiment_idx ${EXPERIMENT_IDX} \
--predict_split ${PREDICT_SPLITS}
done
fi
# # run gaussain_regression
if ${RUN_GAUSSIAN}; then
echo "running gaussian regression"
echo "SEEDS=${SEEDS}"
case "$QR_SCORE" in
"nce")
REGRESSION_MODEL_DIR="sample_level_gaussian_regression_model"
REGRESSION_PRED_DIR="sample_level_gaussian_regression_pred"
LABEL_COLUMN="label"
;;
"mink")
REGRESSION_MODEL_DIR="sample_level_gaussian_regression_mink_model"
REGRESSION_PRED_DIR="sample_level_gaussian_regression_mink_pred"
LABEL_COLUMN="normalized_mink_nce"
;;
"zlib")
REGRESSION_MODEL_DIR="sample_level_gaussian_regression_zlib_model"
REGRESSION_PRED_DIR="sample_level_gaussian_regression_zlib_pred"
LABEL_COLUMN="normalized_zlib_score"
;;
esac
for SEED in ${SEEDS}
do
if [ "$CHECK_POINT_NUM" = "0" ]; then
INPUT_TRAIN_FILE="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/42/predict_results_${DATASET_FILE_NAME}_${QR_TRAIN_SPLIT}_${NUM_EXPERIMENTS}_${EXPERIMENT_IDX}.parquet"
MODEL_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/${QR_MODEL_NAME}/$SEED"
else
INPUT_TRAIN_FILE="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/predict_results_${DATASET_FILE_NAME}_${QR_TRAIN_SPLIT}_${NUM_EXPERIMENTS}_${EXPERIMENT_IDX}.parquet"
MODEL_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/${QR_MODEL_NAME}/$SEED"
fi
echo "input_train_file=${INPUT_TRAIN_FILE}"
echo "model_output_dir=${MODEL_OUTPUT_DIR}"
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_glue_quantile_regression_lira.py \
--model_name_or_path ${QR_MODEL_ORG}/${QR_MODEL_NAME} \
--do_train \
--do_eval \
--train_file ${INPUT_TRAIN_FILE} \
--validation_split_percentage ${QR_VALIDATION_PERCENT} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--max_seq_length ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${QR_TRAIN_BATCH_SIZE} \
--gradient_accumulation_steps ${GRADIENT_ACCUMULATION_STEPS} \
--learning_rate ${QR_LR} \
--num_train_epochs ${REGRESSION_NUM_EPOCHS} \
--output_dir ${MODEL_OUTPUT_DIR} \
--overwrite_output_dir \
--regression_type gaussian_regression \
--optim "adamw_hf" \
--lr_scheduler_type cosine \
--seed $SEED \
--sentence_keys ${SENTENCE_KEYS} \
--label_column ${LABEL_COLUMN} \
--save_only_model \
--logging_strategy epoch \
--evaluation_strategy epoch \
--save_strategy epoch \
--logging_steps 100 \
--eval_steps 100 \
--save_steps 100 \
--save_total_limit 1 \
--load_best_model_at_end \
--metric_for_best_model eval_loss \
--overwrite_cache
done
for SEED in ${SEEDS}
do
if [ "$CHECK_POINT_NUM" = "0" ]; then
MODEL_INPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/${QR_MODEL_NAME}/$SEED"
PRED_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_PRED_DIR}/expid_xx/42/${QR_MODEL_NAME}/$SEED"
else
MODEL_INPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/${QR_MODEL_NAME}/$SEED"
PRED_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_PRED_DIR}/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/${QR_MODEL_NAME}/$SEED"
fi
echo "model_input_dir=${MODEL_INPUT_DIR}"
echo "pred_output_dir=${PRED_OUTPUT_DIR}"
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_glue_quantile_regression_lira.py \
--model_name_or_path ${MODEL_INPUT_DIR} \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--do_predict \
--max_seq_length ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size 32 \
--regression_type gaussian_regression \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--output_dir ${PRED_OUTPUT_DIR} \
--save_strategy epoch \
--predict_split ${PREDICT_SPLITS} \
--sentence_keys ${SENTENCE_KEYS} \
--overwrite_cache
done
fi
# # run iqr_regression
if ${RUN_IQR}; then
echo "running iqr regression"
case "$QR_SCORE" in
"nce")
REGRESSION_MODEL_DIR="sample_level_iqr_regression_model"
REGRESSION_PRED_DIR="sample_level_iqr_regression_pred"
LABEL_COLUMN="label"
;;
"mink")
REGRESSION_MODEL_DIR="sample_level_iqr_regression_mink_model"
REGRESSION_PRED_DIR="sample_level_iqr_regression_mink_pred"
LABEL_COLUMN="normalized_mink_nce"
;;
"zlib")
REGRESSION_MODEL_DIR="sample_level_iqr_regression_zlib_model"
REGRESSION_PRED_DIR="sample_level_iqr_regression_zlib_pred"
LABEL_COLUMN="normalized_zlib_score"
;;
esac
for SEED in ${SEEDS}
do
if [ "$CHECK_POINT_NUM" = "0" ]; then
INPUT_TRAIN_FILE="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/42/predict_results_${DATASET_FILE_NAME}_${QR_TRAIN_SPLIT}_${NUM_EXPERIMENTS}_${EXPERIMENT_IDX}.parquet"
MODEL_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/${QR_MODEL_NAME}/$SEED"
else
INPUT_TRAIN_FILE="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/predict_results_${DATASET_FILE_NAME}_${QR_TRAIN_SPLIT}_${NUM_EXPERIMENTS}_${EXPERIMENT_IDX}.parquet"
MODEL_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/${QR_MODEL_NAME}/$SEED"
fi
echo "input_train_file=${INPUT_TRAIN_FILE}"
echo "model_output_dir=${MODEL_OUTPUT_DIR}"
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_glue_quantile_regression_lira.py \
--model_name_or_path ${QR_MODEL_ORG}/${QR_MODEL_NAME} \
--do_train \
--do_eval \
--train_file ${INPUT_TRAIN_FILE} \
--validation_split_percentage ${QR_VALIDATION_PERCENT} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--max_seq_length ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${QR_TRAIN_BATCH_SIZE} \
--gradient_accumulation_steps ${GRADIENT_ACCUMULATION_STEPS} \
--learning_rate ${QR_LR} \
--num_train_epochs ${REGRESSION_NUM_EPOCHS} \
--output_dir ${MODEL_OUTPUT_DIR} \
--overwrite_output_dir \
--regression_type iqr_regression \
--optim "adamw_hf" \
--lr_scheduler_type cosine \
--seed $SEED \
--sentence_keys ${SENTENCE_KEYS} \
--label_column ${LABEL_COLUMN} \
--save_only_model \
--logging_strategy epoch \
--evaluation_strategy epoch \
--save_strategy epoch \
--logging_steps 100 \
--eval_steps 100 \
--save_steps 100 \
--save_total_limit 1 \
--load_best_model_at_end \
--metric_for_best_model eval_loss \
--overwrite_cache
done
for SEED in ${SEEDS}
do
if [ "$CHECK_POINT_NUM" = "0" ]; then
MODEL_INPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/${QR_MODEL_NAME}/$SEED"
PRED_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_PRED_DIR}/expid_xx/42/${QR_MODEL_NAME}/$SEED"
else
MODEL_INPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/${QR_MODEL_NAME}/$SEED"
PRED_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_PRED_DIR}/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/${QR_MODEL_NAME}/$SEED"
fi
echo "model_input_dir=${MODEL_INPUT_DIR}"
echo "pred_output_dir=${PRED_OUTPUT_DIR}"
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_glue_quantile_regression_lira.py \
--model_name_or_path ${MODEL_INPUT_DIR} \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--do_predict \
--max_seq_length ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size 32 \
--regression_type iqr_regression \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--output_dir ${PRED_OUTPUT_DIR} \
--save_strategy epoch \
--predict_split ${PREDICT_SPLITS} \
--sentence_keys ${SENTENCE_KEYS} \
--overwrite_cache
done
fi
# # run mse_pinball_regression
if ${RUN_MSE_PINBALL}; then
echo "running mse pinball regression"
case "$QR_SCORE" in
"nce")
REGRESSION_MODEL_DIR="sample_level_mse_pinball_regression_model"
REGRESSION_PRED_DIR="sample_level_mse_pinball_regression_pred"
LABEL_COLUMN="label"
;;
"mink")
REGRESSION_MODEL_DIR="sample_level_mse_pinball_regression_mink_model"
REGRESSION_PRED_DIR="sample_level_mse_pinball_regression_mink_pred"
LABEL_COLUMN="normalized_mink_nce"
;;
"zlib")
REGRESSION_MODEL_DIR="sample_level_mse_pinball_regression_zlib_model"
REGRESSION_PRED_DIR="sample_level_mse_pinball_regression_zlib_pred"
LABEL_COLUMN="normalized_zlib_score"
;;
esac
for SEED in ${SEEDS}
do
if [ "$CHECK_POINT_NUM" = "0" ]; then
INPUT_TRAIN_FILE="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/42/predict_results_${DATASET_FILE_NAME}_${QR_TRAIN_SPLIT}_${NUM_EXPERIMENTS}_${EXPERIMENT_IDX}.parquet"
MODEL_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/${QR_MODEL_NAME}/$SEED"
else
INPUT_TRAIN_FILE="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/predict_results_${DATASET_FILE_NAME}_${QR_TRAIN_SPLIT}_${NUM_EXPERIMENTS}_${EXPERIMENT_IDX}.parquet"
MODEL_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/${QR_MODEL_NAME}/$SEED"
fi
echo "input_train_file=${INPUT_TRAIN_FILE}"
echo "model_output_dir=${MODEL_OUTPUT_DIR}"
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_glue_quantile_regression_lira.py \
--model_name_or_path ${QR_MODEL_ORG}/${QR_MODEL_NAME} \
--do_train \
--do_eval \
--train_file ${INPUT_TRAIN_FILE} \
--validation_split_percentage ${QR_VALIDATION_PERCENT} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--max_seq_length ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size ${QR_TRAIN_BATCH_SIZE} \
--gradient_accumulation_steps ${GRADIENT_ACCUMULATION_STEPS} \
--learning_rate ${QR_LR} \
--num_train_epochs ${REGRESSION_NUM_EPOCHS} \
--output_dir ${MODEL_OUTPUT_DIR} \
--overwrite_output_dir \
--regression_type mse_pinball_regression \
--optim "adamw_hf" \
--lr_scheduler_type cosine \
--seed $SEED \
--sentence_keys ${SENTENCE_KEYS} \
--label_column ${LABEL_COLUMN} \
--save_only_model \
--logging_strategy epoch \
--evaluation_strategy epoch \
--save_strategy epoch \
--logging_steps 100 \
--eval_steps 100 \
--save_steps 100 \
--save_total_limit 1 \
--load_best_model_at_end \
--metric_for_best_model eval_loss \
--overwrite_cache
done
for SEED in ${SEEDS}
do
if [ "$CHECK_POINT_NUM" = "0" ]; then
MODEL_INPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/${QR_MODEL_NAME}/$SEED"
PRED_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_PRED_DIR}/expid_xx/42/${QR_MODEL_NAME}/$SEED"
else
MODEL_INPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/${QR_MODEL_NAME}/$SEED"
PRED_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_PRED_DIR}/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/${QR_MODEL_NAME}/$SEED"
fi
echo "model_input_dir=${MODEL_INPUT_DIR}"
echo "pred_output_dir=${PRED_OUTPUT_DIR}"
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_glue_quantile_regression_lira.py \
--model_name_or_path ${MODEL_INPUT_DIR} \
--dataset_name ${DATASET} \
--dataset_config_name ${DATASET_CONFIG} \
--sample_min_num_chars ${SAMPLE_MIN_NUM_CHARS} \
--do_predict \
--max_seq_length ${MAX_SEQ_LENGTH} \
--per_device_train_batch_size 32 \
--regression_type mse_pinball_regression \
--do_public_private_split True \
--public_private_val_ratio ${PUBLIC_PRIVATE_VAL_RATIO} \
--output_dir ${PRED_OUTPUT_DIR} \
--save_strategy epoch \
--predict_split ${PREDICT_SPLITS} \
--sentence_keys ${SENTENCE_KEYS} \
--overwrite_cache
done
fi
# # run gaussian_pinball_regression
if ${RUN_GAUSSIAN_PINBALL}; then
echo "running gaussian pinball regression"
case "$QR_SCORE" in
"nce")
REGRESSION_MODEL_DIR="sample_level_gaussian_pinball_regression_model"
REGRESSION_PRED_DIR="sample_level_gaussian_pinball_regression_pred"
LABEL_COLUMN="label"
;;
"mink")
REGRESSION_MODEL_DIR="sample_level_gaussian_pinball_regression_mink_model"
REGRESSION_PRED_DIR="sample_level_gaussian_pinball_regression_mink_pred"
LABEL_COLUMN="normalized_mink_nce"
;;
"zlib")
REGRESSION_MODEL_DIR="sample_level_gaussian_pinball_regression_zlib_model"
REGRESSION_PRED_DIR="sample_level_gaussian_pinball_regression_zlib_pred"
LABEL_COLUMN="normalized_zlib_score"
;;
esac
for SEED in ${SEEDS}
do
if [ "$CHECK_POINT_NUM" = "0" ]; then
INPUT_TRAIN_FILE="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/42/predict_results_${DATASET_FILE_NAME}_${QR_TRAIN_SPLIT}_${NUM_EXPERIMENTS}_${EXPERIMENT_IDX}.parquet"
MODEL_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/${QR_MODEL_NAME}/$SEED"
else
INPUT_TRAIN_FILE="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/task_pred/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/predict_results_${DATASET_FILE_NAME}_${QR_TRAIN_SPLIT}_${NUM_EXPERIMENTS}_${EXPERIMENT_IDX}.parquet"
MODEL_OUTPUT_DIR="${PREFIX_DIR}/runs/${MODEL_NAME}/${DATASET_NAME}_${TEXT_COLUMN_NAME}/${REGRESSION_MODEL_DIR}/expid_xx/42/checkpoint-${CHECK_POINT_NUM}/${QR_MODEL_NAME}/$SEED"
fi
echo "input_train_file=${INPUT_TRAIN_FILE}"
echo "model_output_dir=${MODEL_OUTPUT_DIR}"
WORLD_SIZE=${NUM_CORES} CUDA_VISIBLE_DEVICES=${CUDA_DEVICES} torchrun --nproc_per_node=${NUM_CORES} --master_port=${MASTER_PORT} run_glue_quantile_regression_lira.py \