diff --git a/.gitignore b/.gitignore index 86c194d..dd3e348 100644 --- a/.gitignore +++ b/.gitignore @@ -194,3 +194,4 @@ cplus_transforms/traverse.py *.pdf .references/* +/results/ diff --git a/AGENTS.md b/AGENTS.md old mode 100644 new mode 100755 index 7afb14c..3c3be48 --- a/AGENTS.md +++ b/AGENTS.md @@ -136,6 +136,9 @@ cd downstream/Clone-detection-POJ-104 ./run.sh ``` +Pre-generated per-model evaluation scripts live in `experiments_downstream/`, including +ModernBERT variants. Regenerate them with `python3 experiments_downstream/gen_all.py`. + Metrics: MAP@R for clone detection, accuracy for defect detection and code classification. ## Code Conventions diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 120000 index 47dc3e3..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1 +0,0 @@ -AGENTS.md \ No newline at end of file diff --git a/README.md b/README.md index c13f1f4..91529d7 100755 --- a/README.md +++ b/README.md @@ -262,6 +262,23 @@ cd downstream/Clone-detection-POJ-104 ./run.sh ``` +Pre-generated per-model evaluation scripts live in `experiments_downstream/`, including +ModernBERT variants. Regenerate them with `python3 experiments_downstream/gen_all.py`. + +To launch the 8 downstream tasks (clone detection + code classification across POJ and +CodeNet) in parallel on 8 GPUs, use the helper script in `experiments_downstream/`. +Each subtask writes to its own output directory (e.g., `results////`): + +```sh +python experiments_downstream/run_all_downstream.py --loss supcon --model inv-codebert +``` + +Override GPU ids with `--gpus` (comma-separated, must be 8): + +```sh +python experiments_downstream/run_all_downstream.py --loss supcon --model inv-codebert --gpus 0,1,2,3,4,5,6,7 +``` + To evaluate robustness, use the augmented test scripts: ```sh @@ -276,6 +293,14 @@ Generate t-SNE visualizations of code embeddings across models: uv run plot/visualize.py --input_test_file dataset/aug_test.jsonl --output_file clusters.png ``` +### Results Parsing + +Parse downstream evaluation outputs into a regular vs augmented table: + +```sh +python experiments_downstream/parse_results.py --results-root results --digits 2 +``` + ## Invariant Code Transformations InvPT uses six semantic-preserving transformation operators: diff --git a/downstream/Clone-detection-BigCloneBench/code/run.py b/downstream/Clone-detection-BigCloneBench/code/run.py index c964ec6..6ad838a 100644 --- a/downstream/Clone-detection-BigCloneBench/code/run.py +++ b/downstream/Clone-detection-BigCloneBench/code/run.py @@ -882,14 +882,16 @@ def main(): if args.do_eval and args.local_rank in [-1, 0]: checkpoint_prefix = "checkpoint-best-f1/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir)) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir)) model.to(args.device) result = evaluate(args, model, tokenizer, pool=pool) if args.do_test and args.local_rank in [-1, 0]: checkpoint_prefix = "checkpoint-best-f1/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir)) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir)) model.to(args.device) test(args, model, tokenizer, pool=pool, best_threshold=0.5) diff --git a/downstream/Clone-detection-CodeNet/code/run.py b/downstream/Clone-detection-CodeNet/code/run.py index 84109e2..6480efc 100644 --- a/downstream/Clone-detection-CodeNet/code/run.py +++ b/downstream/Clone-detection-CodeNet/code/run.py @@ -873,7 +873,8 @@ def main(): if args.do_eval and args.local_rank in [-1, 0]: checkpoint_prefix = "checkpoint-best-map/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir), strict=False) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir), strict=False) model.to(args.device) result = evaluate(args, model, tokenizer) logger.info("***** Eval results *****") @@ -883,7 +884,8 @@ def main(): if args.do_test and args.local_rank in [-1, 0]: checkpoint_prefix = "checkpoint-best-map/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir), strict=False) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir), strict=False) model.to(args.device) test(args, model, tokenizer) diff --git a/downstream/Clone-detection-CodeNet/run.sh b/downstream/Clone-detection-CodeNet/run.sh index d5fbaef..42e256c 100755 --- a/downstream/Clone-detection-CodeNet/run.sh +++ b/downstream/Clone-detection-CodeNet/run.sh @@ -5,7 +5,12 @@ subset=$3 model_type=${4:-roberta} tokenizer_name=${5:-roberta-base} -output_dir=$save_path/$subset +base_name=$(basename "$save_path") +if [ "$base_name" = "$subset" ]; then + output_dir=$save_path +else + output_dir=$save_path/$subset +fi mkdir -p $output_dir touch $output_dir/train.log @@ -40,4 +45,4 @@ python evaluator/evaluator.py \ echo "Running evaluation for augmented test set..." -./run_aug_test.sh $model_path $save_path $subset $model_type $tokenizer_name +./run_aug_test.sh "$model_path" "$save_path" "$subset" "$model_type" "$tokenizer_name" diff --git a/downstream/Clone-detection-CodeNet/run_aug_test.sh b/downstream/Clone-detection-CodeNet/run_aug_test.sh index dc06ce8..8d62804 100755 --- a/downstream/Clone-detection-CodeNet/run_aug_test.sh +++ b/downstream/Clone-detection-CodeNet/run_aug_test.sh @@ -5,7 +5,12 @@ subset=$3 model_type=${4:-roberta} tokenizer_name=${5:-roberta-base} -output_dir=$save_path/$subset +base_name=$(basename "$save_path") +if [ "$base_name" = "$subset" ]; then + output_dir=$save_path +else + output_dir=$save_path/$subset +fi mkdir -p $output_dir touch $output_dir/aug_train.log diff --git a/downstream/Clone-detection-POJ104/code/run.py b/downstream/Clone-detection-POJ104/code/run.py index 84109e2..6480efc 100644 --- a/downstream/Clone-detection-POJ104/code/run.py +++ b/downstream/Clone-detection-POJ104/code/run.py @@ -873,7 +873,8 @@ def main(): if args.do_eval and args.local_rank in [-1, 0]: checkpoint_prefix = "checkpoint-best-map/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir), strict=False) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir), strict=False) model.to(args.device) result = evaluate(args, model, tokenizer) logger.info("***** Eval results *****") @@ -883,7 +884,8 @@ def main(): if args.do_test and args.local_rank in [-1, 0]: checkpoint_prefix = "checkpoint-best-map/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir), strict=False) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir), strict=False) model.to(args.device) test(args, model, tokenizer) diff --git a/downstream/Code-classification-CodeNet/code/run.py b/downstream/Code-classification-CodeNet/code/run.py index d612d28..f187b44 100644 --- a/downstream/Code-classification-CodeNet/code/run.py +++ b/downstream/Code-classification-CodeNet/code/run.py @@ -456,7 +456,8 @@ def main(): if args.do_eval: checkpoint_prefix = "checkpoint-best-acc/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir)) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir)) model.to(args.device) result = evaluate(args, model, tokenizer) logger.info("***** Eval results *****") @@ -466,7 +467,8 @@ def main(): if args.do_test: checkpoint_prefix = "checkpoint-best-acc/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir)) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir)) model.to(args.device) result = test(args, model, tokenizer) logger.info("***** Test results *****") diff --git a/downstream/Code-classification-CodeNet/run.sh b/downstream/Code-classification-CodeNet/run.sh index 2c4d515..b8c475b 100755 --- a/downstream/Code-classification-CodeNet/run.sh +++ b/downstream/Code-classification-CodeNet/run.sh @@ -5,7 +5,12 @@ subset=$3 model_type=${4:-roberta} tokenizer_name=${5:-microsoft/codebert-base} -output_dir=$save_path/$subset +base_name=$(basename "$save_path") +if [ "$base_name" = "$subset" ]; then + output_dir=$save_path +else + output_dir=$save_path/$subset +fi mkdir -p $output_dir touch $output_dir/test_train.log @@ -31,4 +36,4 @@ python ./code/run.py \ echo "Running evaluation for augmented test set..." -./run_aug_test.sh $model_path $save_path $subset $model_type $tokenizer_name +./run_aug_test.sh "$model_path" "$save_path" "$subset" "$model_type" "$tokenizer_name" diff --git a/downstream/Code-classification-CodeNet/run_aug_test.sh b/downstream/Code-classification-CodeNet/run_aug_test.sh index bcfe01f..1e9bf94 100755 --- a/downstream/Code-classification-CodeNet/run_aug_test.sh +++ b/downstream/Code-classification-CodeNet/run_aug_test.sh @@ -5,7 +5,12 @@ subset=$3 model_type=${4:-roberta} tokenizer_name=${5:-microsoft/codebert-base} -output_dir=$save_path/$subset +base_name=$(basename "$save_path") +if [ "$base_name" = "$subset" ]; then + output_dir=$save_path +else + output_dir=$save_path/$subset +fi mkdir -p $output_dir touch $output_dir/test_train.log diff --git a/downstream/Code-classification-POJ104/code/run.py b/downstream/Code-classification-POJ104/code/run.py index d612d28..c8c6cb0 100644 --- a/downstream/Code-classification-POJ104/code/run.py +++ b/downstream/Code-classification-POJ104/code/run.py @@ -53,6 +53,22 @@ "modernbert": (AutoConfig, AutoModelForSequenceClassification, AutoTokenizer), } + +def resolve_model_type(model_type, model_name_or_path): + if model_type in MODEL_CLASSES: + return model_type + candidate = model_name_or_path or model_type or "" + name = candidate.lower() + resolved = "modernbert" if "modernbert" in name else "roberta" + logger.warning( + "Unknown model_type '%s'; inferring '%s' from '%s'.", + model_type, + resolved, + candidate, + ) + return resolved + + logger = logging.getLogger(__name__) @@ -82,7 +98,8 @@ def convert_examples_to_features(js, tokenizer, args): class TextDataset(Dataset): - def __init__(self, tokenizer, args, file_path=None): + def __init__(self, tokenizer, args, file_path: str): + file_path = str(file_path) self.examples = [] with open(file_path) as f: for line in f: @@ -429,6 +446,7 @@ def main(): # Set seed set_seed(args.seed) + args.model_type = resolve_model_type(args.model_type, args.model_name_or_path) config_class, model_class, tokenizer_class = MODEL_CLASSES[args.model_type] config = config_class.from_pretrained(args.model_name_or_path) config.num_labels = 104 @@ -456,7 +474,8 @@ def main(): if args.do_eval: checkpoint_prefix = "checkpoint-best-acc/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir)) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir)) model.to(args.device) result = evaluate(args, model, tokenizer) logger.info("***** Eval results *****") @@ -466,7 +485,8 @@ def main(): if args.do_test: checkpoint_prefix = "checkpoint-best-acc/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir)) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir)) model.to(args.device) result = test(args, model, tokenizer) logger.info("***** Test results *****") diff --git a/downstream/Code-classification-POJ104/run.sh b/downstream/Code-classification-POJ104/run.sh index 963d538..ad102d5 100755 --- a/downstream/Code-classification-POJ104/run.sh +++ b/downstream/Code-classification-POJ104/run.sh @@ -5,12 +5,22 @@ subset=$3 model_type=${4:-roberta} tokenizer_name=${5:-microsoft/codebert-base} -output_dir=$save_path/$subset +base_name=$(basename "$save_path") +if [ "$base_name" = "$subset" ]; then + output_dir=$save_path +else + output_dir=$save_path/$subset +fi mkdir -p $output_dir touch $output_dir/test_train.log echo "Running fine-tuning for POJ104" +train_suffix="" +if [ -n "$subset" ]; then + train_suffix="/$subset" +fi + python ./code/run.py \ --output_dir=$output_dir \ --model_type=$model_type \ @@ -18,9 +28,9 @@ python ./code/run.py \ --model_name_or_path=$model_path \ --do_train \ --do_test \ - --train_data_file=./dataset/$subset/train.jsonl \ - --eval_data_file=./dataset/$subset/valid.jsonl \ - --test_data_file=./dataset/$subset/test.jsonl \ + --train_data_file=./dataset${train_suffix}/train.jsonl \ + --eval_data_file=./dataset${train_suffix}/valid.jsonl \ + --test_data_file=./dataset${train_suffix}/test.jsonl \ --num_train_epochs 10 \ --block_size 512 \ --train_batch_size 32 \ @@ -30,4 +40,4 @@ python ./code/run.py \ --seed 123456 2>&1 | tee $output_dir/test_train.log echo "Running evaluation for augmented test set..." -./run_aug_test.sh $model_path $save_path $subset $model_type $tokenizer_name +./run_aug_test.sh "$model_path" "$save_path" "$subset" "$model_type" "$tokenizer_name" diff --git a/downstream/Code-classification-POJ104/run_aug_test.sh b/downstream/Code-classification-POJ104/run_aug_test.sh index bcfe01f..6abcc64 100755 --- a/downstream/Code-classification-POJ104/run_aug_test.sh +++ b/downstream/Code-classification-POJ104/run_aug_test.sh @@ -5,20 +5,30 @@ subset=$3 model_type=${4:-roberta} tokenizer_name=${5:-microsoft/codebert-base} -output_dir=$save_path/$subset +base_name=$(basename "$save_path") +if [ "$base_name" = "$subset" ]; then + output_dir=$save_path +else + output_dir=$save_path/$subset +fi mkdir -p $output_dir touch $output_dir/test_train.log +train_suffix="" +if [ -n "$subset" ]; then + train_suffix="/$subset" +fi + python ./code/run.py \ --output_dir=$output_dir \ --model_type=$model_type \ --tokenizer_name=$tokenizer_name \ --model_name_or_path=$model_path \ --do_test \ - --train_data_file=./dataset/$subset/train.jsonl \ - --eval_data_file=./dataset/$subset/valid.jsonl \ - --test_data_file=./dataset/$subset/aug_test.jsonl \ + --train_data_file=./dataset${train_suffix}/train.jsonl \ + --eval_data_file=./dataset${train_suffix}/valid.jsonl \ + --test_data_file=./dataset${train_suffix}/aug_test.jsonl \ --num_train_epochs 5 \ --block_size 256 \ --train_batch_size 8 \ diff --git a/downstream/Defect-detection/code/run.py b/downstream/Defect-detection/code/run.py index fa104d1..a065f54 100644 --- a/downstream/Defect-detection/code/run.py +++ b/downstream/Defect-detection/code/run.py @@ -819,7 +819,8 @@ def main(): if args.do_eval and args.local_rank in [-1, 0]: checkpoint_prefix = "checkpoint-best-acc/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir)) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir)) model.to(args.device) result = evaluate(args, model, tokenizer) logger.info("***** Eval results *****") @@ -829,7 +830,8 @@ def main(): if args.do_test and args.local_rank in [-1, 0]: checkpoint_prefix = "checkpoint-best-acc/model.bin" output_dir = os.path.join(args.output_dir, "{}".format(checkpoint_prefix)) - model.load_state_dict(torch.load(output_dir)) + model_to_load = model.module if hasattr(model, "module") else model + model_to_load.load_state_dict(torch.load(output_dir)) model.to(args.device) test(args, model, tokenizer) diff --git a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_codebert.sh b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_codebert.sh index f934894..275290c 100755 --- a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_codebert.sh +++ b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-BigCloneBench with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-BigCloneBench" ./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Clone-detection-BigCloneBench" diff --git a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_contrabert_c.sh b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_contrabert_c.sh index 3160e0b..d59981f 100755 --- a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_contrabert_c.sh +++ b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-BigCloneBench with contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-BigCloneBench" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Clone-detection-BigCloneBench" diff --git a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_contrabert_g.sh b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_contrabert_g.sh index 1c83546..d87a720 100755 --- a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_contrabert_g.sh +++ b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-BigCloneBench with contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-BigCloneBench" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Clone-detection-BigCloneBench" diff --git a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_graphcodebert.sh b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_graphcodebert.sh index 9421fa4..ff65f51 100755 --- a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_graphcodebert.sh +++ b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-BigCloneBench with graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-BigCloneBench" ./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Clone-detection-BigCloneBench" diff --git a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-codebert.sh b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-codebert.sh index cbcf312..78764dc 100755 --- a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-codebert.sh +++ b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-BigCloneBench with inv-codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-BigCloneBench" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Clone-detection-BigCloneBench" +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Clone-detection-BigCloneBench" diff --git a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-contrabert_c.sh b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-contrabert_c.sh index f037725..654585a 100755 --- a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-contrabert_c.sh +++ b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-BigCloneBench with inv-contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-BigCloneBench" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Clone-detection-BigCloneBench" +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Clone-detection-BigCloneBench" diff --git a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-contrabert_g.sh b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-contrabert_g.sh index 4ff8ed8..2404aac 100755 --- a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-contrabert_g.sh +++ b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-BigCloneBench with inv-contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-BigCloneBench" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Clone-detection-BigCloneBench" +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Clone-detection-BigCloneBench" diff --git a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-graphcodebert.sh b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-graphcodebert.sh index 4c6d4a6..5c6b1af 100755 --- a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-graphcodebert.sh +++ b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-BigCloneBench with inv-graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-BigCloneBench" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Clone-detection-BigCloneBench" +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Clone-detection-BigCloneBench" diff --git a/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-modernbert.sh b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-modernbert.sh new file mode 100755 index 0000000..f30bce8 --- /dev/null +++ b/experiments_downstream/Clone-detection-BigCloneBench/clone-bcb_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Clone-detection-BigCloneBench with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Clone-detection-BigCloneBench" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Clone-detection-BigCloneBench" diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_codebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_codebert.sh index 06a7a1a..92dae63 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_codebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (C++1400) with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Clone-detection-CodeNet" C++1400 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_contrabert_c.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_contrabert_c.sh index 1ac93ab..5746536 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_contrabert_c.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (C++1400) with contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Clone-detection-CodeNet" C++1400 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_contrabert_g.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_contrabert_g.sh index 9980723..09a946f 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_contrabert_g.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (C++1400) with contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Clone-detection-CodeNet" C++1400 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_graphcodebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_graphcodebert.sh index 232b7d7..d5f7849 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_graphcodebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (C++1400) with graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Clone-detection-CodeNet" C++1400 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-codebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-codebert.sh index 1fd8e12..260d89d 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-codebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (C++1400) with inv-codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Clone-detection-CodeNet" C++1400 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Clone-detection-CodeNet" C++1400 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-contrabert_c.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-contrabert_c.sh index 40b89fb..2c4640e 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-contrabert_c.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (C++1400) with inv-contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Clone-detection-CodeNet" C++1400 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Clone-detection-CodeNet" C++1400 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-contrabert_g.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-contrabert_g.sh index 6ad5cce..8cac84d 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-contrabert_g.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (C++1400) with inv-contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Clone-detection-CodeNet" C++1400 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Clone-detection-CodeNet" C++1400 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-graphcodebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-graphcodebert.sh index 82568e4..a28fbe1 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-graphcodebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (C++1400) with inv-graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Clone-detection-CodeNet" C++1400 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Clone-detection-CodeNet" C++1400 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-modernbert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-modernbert.sh new file mode 100755 index 0000000..8f20cde --- /dev/null +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_C++1400_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Clone-detection-CodeNet (C++1400) with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Clone-detection-CodeNet" C++1400 modernbert answerdotai/ModernBERT-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_codebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_codebert.sh index f584af0..ea86a95 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_codebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Java250) with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Clone-detection-CodeNet" Java250 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_contrabert_c.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_contrabert_c.sh index e2f33f4..5d795d9 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_contrabert_c.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Java250) with contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Clone-detection-CodeNet" Java250 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_contrabert_g.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_contrabert_g.sh index 5c45ae0..61bd93a 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_contrabert_g.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Java250) with contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Clone-detection-CodeNet" Java250 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_graphcodebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_graphcodebert.sh index a228875..8c8fcc2 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_graphcodebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Java250) with graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Clone-detection-CodeNet" Java250 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-codebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-codebert.sh index ce83d95..e644659 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-codebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Java250) with inv-codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Clone-detection-CodeNet" Java250 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Clone-detection-CodeNet" Java250 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-contrabert_c.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-contrabert_c.sh index 269102c..14e57e0 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-contrabert_c.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Java250) with inv-contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Clone-detection-CodeNet" Java250 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Clone-detection-CodeNet" Java250 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-contrabert_g.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-contrabert_g.sh index 1591e84..55faa2b 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-contrabert_g.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Java250) with inv-contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Clone-detection-CodeNet" Java250 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Clone-detection-CodeNet" Java250 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-graphcodebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-graphcodebert.sh index b298954..a8f171d 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-graphcodebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Java250) with inv-graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Clone-detection-CodeNet" Java250 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Clone-detection-CodeNet" Java250 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-modernbert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-modernbert.sh new file mode 100755 index 0000000..407f06a --- /dev/null +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Java250_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Clone-detection-CodeNet (Java250) with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Clone-detection-CodeNet" Java250 modernbert answerdotai/ModernBERT-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_codebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_codebert.sh index 8f4affc..1b46200 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_codebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Python800) with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Clone-detection-CodeNet" Python800 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_contrabert_c.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_contrabert_c.sh index 7c7291d..7b7839b 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_contrabert_c.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Python800) with contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Clone-detection-CodeNet" Python800 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_contrabert_g.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_contrabert_g.sh index 211c493..a2e5190 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_contrabert_g.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Python800) with contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Clone-detection-CodeNet" Python800 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_graphcodebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_graphcodebert.sh index 926a7fa..a45be28 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_graphcodebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Python800) with graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" ./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Clone-detection-CodeNet" Python800 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-codebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-codebert.sh index 9d684bc..0c85cee 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-codebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Python800) with inv-codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Clone-detection-CodeNet" Python800 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Clone-detection-CodeNet" Python800 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-contrabert_c.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-contrabert_c.sh index ac08095..a6a86cf 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-contrabert_c.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Python800) with inv-contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Clone-detection-CodeNet" Python800 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Clone-detection-CodeNet" Python800 roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-contrabert_g.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-contrabert_g.sh index c515dc1..1ccf942 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-contrabert_g.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Python800) with inv-contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Clone-detection-CodeNet" Python800 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Clone-detection-CodeNet" Python800 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-graphcodebert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-graphcodebert.sh index 05e3cb2..715dfee 100755 --- a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-graphcodebert.sh +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-CodeNet (Python800) with inv-graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Clone-detection-CodeNet" Python800 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Clone-detection-CodeNet" Python800 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-modernbert.sh b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-modernbert.sh new file mode 100755 index 0000000..d00f72f --- /dev/null +++ b/experiments_downstream/Clone-detection-CodeNet/clone-codenet_Python800_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Clone-detection-CodeNet (Python800) with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Clone-detection-CodeNet" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Clone-detection-CodeNet" Python800 modernbert answerdotai/ModernBERT-base diff --git a/experiments_downstream/Clone-detection-POJ104/clone-poj104_codebert.sh b/experiments_downstream/Clone-detection-POJ104/clone-poj104_codebert.sh index dc50820..3c11b52 100755 --- a/experiments_downstream/Clone-detection-POJ104/clone-poj104_codebert.sh +++ b/experiments_downstream/Clone-detection-POJ104/clone-poj104_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-POJ104 with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-POJ104" ./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Clone-detection-POJ104" roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-POJ104/clone-poj104_contrabert_c.sh b/experiments_downstream/Clone-detection-POJ104/clone-poj104_contrabert_c.sh index c5c1f1f..98b0176 100755 --- a/experiments_downstream/Clone-detection-POJ104/clone-poj104_contrabert_c.sh +++ b/experiments_downstream/Clone-detection-POJ104/clone-poj104_contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-POJ104 with contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-POJ104" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Clone-detection-POJ104" roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-POJ104/clone-poj104_contrabert_g.sh b/experiments_downstream/Clone-detection-POJ104/clone-poj104_contrabert_g.sh index f481c1c..ccb63ee 100755 --- a/experiments_downstream/Clone-detection-POJ104/clone-poj104_contrabert_g.sh +++ b/experiments_downstream/Clone-detection-POJ104/clone-poj104_contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-POJ104 with contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-POJ104" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Clone-detection-POJ104" roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-POJ104/clone-poj104_graphcodebert.sh b/experiments_downstream/Clone-detection-POJ104/clone-poj104_graphcodebert.sh index a154952..66c499f 100755 --- a/experiments_downstream/Clone-detection-POJ104/clone-poj104_graphcodebert.sh +++ b/experiments_downstream/Clone-detection-POJ104/clone-poj104_graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-POJ104 with graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-POJ104" ./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Clone-detection-POJ104" roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-codebert.sh b/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-codebert.sh index 953b883..af4ddba 100755 --- a/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-codebert.sh +++ b/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-POJ104 with inv-codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-POJ104" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Clone-detection-POJ104" roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Clone-detection-POJ104" roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-contrabert_c.sh b/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-contrabert_c.sh index 9be34d9..ce105db 100755 --- a/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-contrabert_c.sh +++ b/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-POJ104 with inv-contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-POJ104" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Clone-detection-POJ104" roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Clone-detection-POJ104" roberta microsoft/codebert-base diff --git a/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-contrabert_g.sh b/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-contrabert_g.sh index ad23aa4..54d6503 100755 --- a/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-contrabert_g.sh +++ b/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-POJ104 with inv-contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-POJ104" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Clone-detection-POJ104" roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Clone-detection-POJ104" roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-graphcodebert.sh b/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-graphcodebert.sh index ec5fff5..79a12a1 100755 --- a/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-graphcodebert.sh +++ b/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Clone-detection-POJ104 with inv-graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Clone-detection-POJ104" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Clone-detection-POJ104" roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Clone-detection-POJ104" roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-modernbert.sh b/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-modernbert.sh new file mode 100755 index 0000000..f6bd6c4 --- /dev/null +++ b/experiments_downstream/Clone-detection-POJ104/clone-poj104_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Clone-detection-POJ104 with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Clone-detection-POJ104" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Clone-detection-POJ104" modernbert answerdotai/ModernBERT-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_codebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_codebert.sh index a7098eb..31382b8 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_codebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (C++1400) with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Code-classification-CodeNet" C++1400 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_contrabert_c.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_contrabert_c.sh index 5f25b48..9665711 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_contrabert_c.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (C++1400) with contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Code-classification-CodeNet" C++1400 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_contrabert_g.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_contrabert_g.sh index 77eb658..e68a245 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_contrabert_g.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (C++1400) with contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Code-classification-CodeNet" C++1400 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_graphcodebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_graphcodebert.sh index 420b007..3e93ac1 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_graphcodebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (C++1400) with graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Code-classification-CodeNet" C++1400 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-codebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-codebert.sh index 2552f68..6c27b0e 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-codebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (C++1400) with inv-codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Code-classification-CodeNet" C++1400 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Code-classification-CodeNet" C++1400 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-contrabert_c.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-contrabert_c.sh index 9ff69f6..ac30e81 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-contrabert_c.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (C++1400) with inv-contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Code-classification-CodeNet" C++1400 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Code-classification-CodeNet" C++1400 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-contrabert_g.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-contrabert_g.sh index 8d5df3c..61b20de 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-contrabert_g.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (C++1400) with inv-contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Code-classification-CodeNet" C++1400 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Code-classification-CodeNet" C++1400 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-graphcodebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-graphcodebert.sh index caed086..9a35213 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-graphcodebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (C++1400) with inv-graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Code-classification-CodeNet" C++1400 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Code-classification-CodeNet" C++1400 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-modernbert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-modernbert.sh new file mode 100755 index 0000000..aef8d25 --- /dev/null +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_C++1400_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-CodeNet (C++1400) with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-CodeNet" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Code-classification-CodeNet" C++1400 modernbert answerdotai/ModernBERT-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_codebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_codebert.sh index 8e7ea16..4aa0e51 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_codebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Java250) with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Code-classification-CodeNet" Java250 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_contrabert_c.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_contrabert_c.sh index 4f27974..47dc5a2 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_contrabert_c.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Java250) with contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Code-classification-CodeNet" Java250 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_contrabert_g.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_contrabert_g.sh index 0fd50b1..592b704 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_contrabert_g.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Java250) with contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Code-classification-CodeNet" Java250 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_graphcodebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_graphcodebert.sh index fe99ed7..515cd6c 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_graphcodebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Java250) with graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Code-classification-CodeNet" Java250 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-codebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-codebert.sh index 69e8108..cc57b50 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-codebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Java250) with inv-codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Code-classification-CodeNet" Java250 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Code-classification-CodeNet" Java250 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-contrabert_c.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-contrabert_c.sh index 8103c60..4b79406 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-contrabert_c.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Java250) with inv-contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Code-classification-CodeNet" Java250 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Code-classification-CodeNet" Java250 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-contrabert_g.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-contrabert_g.sh index 1bbfb4a..c78d8de 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-contrabert_g.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Java250) with inv-contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Code-classification-CodeNet" Java250 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Code-classification-CodeNet" Java250 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-graphcodebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-graphcodebert.sh index 97a648c..63d6383 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-graphcodebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Java250) with inv-graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Code-classification-CodeNet" Java250 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Code-classification-CodeNet" Java250 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-modernbert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-modernbert.sh new file mode 100755 index 0000000..d3e99f7 --- /dev/null +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Java250_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-CodeNet (Java250) with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-CodeNet" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Code-classification-CodeNet" Java250 modernbert answerdotai/ModernBERT-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_codebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_codebert.sh index 39fb03c..1c3389d 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_codebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Python800) with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Code-classification-CodeNet" Python800 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_contrabert_c.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_contrabert_c.sh index 1aa25b7..69aba3d 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_contrabert_c.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Python800) with contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Code-classification-CodeNet" Python800 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_contrabert_g.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_contrabert_g.sh index f1cef41..45d606b 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_contrabert_g.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Python800) with contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Code-classification-CodeNet" Python800 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_graphcodebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_graphcodebert.sh index aca03e6..5286874 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_graphcodebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Python800) with graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" ./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Code-classification-CodeNet" Python800 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-codebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-codebert.sh index a8f6379..4745f51 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-codebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Python800) with inv-codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Code-classification-CodeNet" Python800 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Code-classification-CodeNet" Python800 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-contrabert_c.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-contrabert_c.sh index 30269f6..cc03fe7 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-contrabert_c.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Python800) with inv-contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Code-classification-CodeNet" Python800 roberta microsoft/codebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Code-classification-CodeNet" Python800 roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-contrabert_g.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-contrabert_g.sh index f8f6f08..5fab41d 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-contrabert_g.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Python800) with inv-contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Code-classification-CodeNet" Python800 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Code-classification-CodeNet" Python800 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-graphcodebert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-graphcodebert.sh index b67e352..34c119e 100755 --- a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-graphcodebert.sh +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-classification-CodeNet (Python800) with inv-graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-CodeNet" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Code-classification-CodeNet" Python800 roberta microsoft/graphcodebert-base +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Code-classification-CodeNet" Python800 roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-modernbert.sh b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-modernbert.sh new file mode 100755 index 0000000..416d497 --- /dev/null +++ b/experiments_downstream/Code-classification-CodeNet/cls-codenet_Python800_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-CodeNet (Python800) with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-CodeNet" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Code-classification-CodeNet" Python800 modernbert answerdotai/ModernBERT-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_contrabert_c.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_contrabert_c.sh deleted file mode 100755 index f9fa75e..0000000 --- a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_contrabert_c.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# Downstream evaluation: Code-classification-POJ104 (Cpp) with contrabert_c -set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" - -cd "$ROOT_DIR/downstream/Code-classification-POJ104" -./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Code-classification-POJ104" Cpp roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_contrabert_g.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_contrabert_g.sh deleted file mode 100755 index a87fb4f..0000000 --- a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_contrabert_g.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# Downstream evaluation: Code-classification-POJ104 (Cpp) with contrabert_g -set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" - -cd "$ROOT_DIR/downstream/Code-classification-POJ104" -./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Code-classification-POJ104" Cpp roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_graphcodebert.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_graphcodebert.sh deleted file mode 100755 index aa05ab0..0000000 --- a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_graphcodebert.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# Downstream evaluation: Code-classification-POJ104 (Cpp) with graphcodebert -set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" - -cd "$ROOT_DIR/downstream/Code-classification-POJ104" -./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Code-classification-POJ104" Cpp roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-codebert.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-codebert.sh deleted file mode 100755 index 0306d6f..0000000 --- a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-codebert.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# Downstream evaluation: Code-classification-POJ104 (Cpp) with inv-codebert -set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" - -cd "$ROOT_DIR/downstream/Code-classification-POJ104" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Code-classification-POJ104" Cpp roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-contrabert_c.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-contrabert_c.sh deleted file mode 100755 index 71a2807..0000000 --- a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-contrabert_c.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# Downstream evaluation: Code-classification-POJ104 (Cpp) with inv-contrabert_c -set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" - -cd "$ROOT_DIR/downstream/Code-classification-POJ104" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Code-classification-POJ104" Cpp roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-contrabert_g.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-contrabert_g.sh deleted file mode 100755 index 48df121..0000000 --- a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-contrabert_g.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# Downstream evaluation: Code-classification-POJ104 (Cpp) with inv-contrabert_g -set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" - -cd "$ROOT_DIR/downstream/Code-classification-POJ104" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Code-classification-POJ104" Cpp roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-graphcodebert.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-graphcodebert.sh deleted file mode 100755 index db645bd..0000000 --- a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_inv-graphcodebert.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# Downstream evaluation: Code-classification-POJ104 (Cpp) with inv-graphcodebert -set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" - -cd "$ROOT_DIR/downstream/Code-classification-POJ104" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Code-classification-POJ104" Cpp roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_codebert.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_codebert.sh similarity index 51% rename from experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_codebert.sh rename to experiments_downstream/Code-classification-POJ104/cls-poj104_codebert.sh index f406cf7..ff8ced4 100755 --- a/experiments_downstream/Code-classification-POJ104/cls-poj104_Cpp_codebert.sh +++ b/experiments_downstream/Code-classification-POJ104/cls-poj104_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash -# Downstream evaluation: Code-classification-POJ104 (Cpp) with codebert +# Downstream evaluation: Code-classification-POJ104 with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-classification-POJ104" -./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Code-classification-POJ104" Cpp roberta microsoft/codebert-base +./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Code-classification-POJ104" "" roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_contrabert_c.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_contrabert_c.sh new file mode 100755 index 0000000..ac022e1 --- /dev/null +++ b/experiments_downstream/Code-classification-POJ104/cls-poj104_contrabert_c.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-POJ104 with contrabert_c +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-POJ104" +./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Code-classification-POJ104" "" roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_contrabert_g.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_contrabert_g.sh new file mode 100755 index 0000000..d7dd82e --- /dev/null +++ b/experiments_downstream/Code-classification-POJ104/cls-poj104_contrabert_g.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-POJ104 with contrabert_g +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-POJ104" +./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Code-classification-POJ104" "" roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_graphcodebert.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_graphcodebert.sh new file mode 100755 index 0000000..2168831 --- /dev/null +++ b/experiments_downstream/Code-classification-POJ104/cls-poj104_graphcodebert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-POJ104 with graphcodebert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-POJ104" +./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Code-classification-POJ104" "" roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-codebert.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-codebert.sh new file mode 100755 index 0000000..9be9b07 --- /dev/null +++ b/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-codebert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-POJ104 with inv-codebert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-POJ104" +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Code-classification-POJ104" "" roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-contrabert_c.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-contrabert_c.sh new file mode 100755 index 0000000..226d8c7 --- /dev/null +++ b/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-contrabert_c.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-POJ104 with inv-contrabert_c +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-POJ104" +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Code-classification-POJ104" "" roberta microsoft/codebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-contrabert_g.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-contrabert_g.sh new file mode 100755 index 0000000..7dd0641 --- /dev/null +++ b/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-contrabert_g.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-POJ104 with inv-contrabert_g +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-POJ104" +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Code-classification-POJ104" "" roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-graphcodebert.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-graphcodebert.sh new file mode 100755 index 0000000..782ba59 --- /dev/null +++ b/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-graphcodebert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-POJ104 with inv-graphcodebert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-POJ104" +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Code-classification-POJ104" "" roberta microsoft/graphcodebert-base diff --git a/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-modernbert.sh b/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-modernbert.sh new file mode 100755 index 0000000..aa0264f --- /dev/null +++ b/experiments_downstream/Code-classification-POJ104/cls-poj104_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-classification-POJ104 with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-classification-POJ104" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Code-classification-POJ104" "" modernbert answerdotai/ModernBERT-base diff --git a/experiments_downstream/Code-translation/translation_codebert.sh b/experiments_downstream/Code-translation/translation_codebert.sh index 4e1156a..07d81d6 100755 --- a/experiments_downstream/Code-translation/translation_codebert.sh +++ b/experiments_downstream/Code-translation/translation_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-translation with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-translation" ./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Code-translation" diff --git a/experiments_downstream/Code-translation/translation_contrabert_c.sh b/experiments_downstream/Code-translation/translation_contrabert_c.sh index 35eb1cf..c70ba5f 100755 --- a/experiments_downstream/Code-translation/translation_contrabert_c.sh +++ b/experiments_downstream/Code-translation/translation_contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-translation with contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-translation" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Code-translation" diff --git a/experiments_downstream/Code-translation/translation_contrabert_g.sh b/experiments_downstream/Code-translation/translation_contrabert_g.sh index b273b76..42a02c0 100755 --- a/experiments_downstream/Code-translation/translation_contrabert_g.sh +++ b/experiments_downstream/Code-translation/translation_contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-translation with contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-translation" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Code-translation" diff --git a/experiments_downstream/Code-translation/translation_graphcodebert.sh b/experiments_downstream/Code-translation/translation_graphcodebert.sh index 9a61086..afd3dcc 100755 --- a/experiments_downstream/Code-translation/translation_graphcodebert.sh +++ b/experiments_downstream/Code-translation/translation_graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-translation with graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-translation" ./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Code-translation" diff --git a/experiments_downstream/Code-translation/translation_inv-codebert.sh b/experiments_downstream/Code-translation/translation_inv-codebert.sh index 91621d0..4528b08 100755 --- a/experiments_downstream/Code-translation/translation_inv-codebert.sh +++ b/experiments_downstream/Code-translation/translation_inv-codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-translation with inv-codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-translation" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Code-translation" +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Code-translation" diff --git a/experiments_downstream/Code-translation/translation_inv-contrabert_c.sh b/experiments_downstream/Code-translation/translation_inv-contrabert_c.sh index 4aa7dfa..4f13441 100755 --- a/experiments_downstream/Code-translation/translation_inv-contrabert_c.sh +++ b/experiments_downstream/Code-translation/translation_inv-contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-translation with inv-contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-translation" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Code-translation" +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Code-translation" diff --git a/experiments_downstream/Code-translation/translation_inv-contrabert_g.sh b/experiments_downstream/Code-translation/translation_inv-contrabert_g.sh index 5000dc1..bbc7036 100755 --- a/experiments_downstream/Code-translation/translation_inv-contrabert_g.sh +++ b/experiments_downstream/Code-translation/translation_inv-contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-translation with inv-contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-translation" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Code-translation" +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Code-translation" diff --git a/experiments_downstream/Code-translation/translation_inv-graphcodebert.sh b/experiments_downstream/Code-translation/translation_inv-graphcodebert.sh index 759ca8a..c0801e6 100755 --- a/experiments_downstream/Code-translation/translation_inv-graphcodebert.sh +++ b/experiments_downstream/Code-translation/translation_inv-graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Code-translation with inv-graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Code-translation" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Code-translation" +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Code-translation" diff --git a/experiments_downstream/Code-translation/translation_inv-modernbert.sh b/experiments_downstream/Code-translation/translation_inv-modernbert.sh new file mode 100755 index 0000000..16fdbf2 --- /dev/null +++ b/experiments_downstream/Code-translation/translation_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Code-translation with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Code-translation" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Code-translation" diff --git a/experiments_downstream/Defect-detection/defect_codebert.sh b/experiments_downstream/Defect-detection/defect_codebert.sh index f9d68b2..86418c6 100755 --- a/experiments_downstream/Defect-detection/defect_codebert.sh +++ b/experiments_downstream/Defect-detection/defect_codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Defect-detection with codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Defect-detection" ./run.sh microsoft/codebert-base "$ROOT_DIR/results/codebert/Defect-detection" diff --git a/experiments_downstream/Defect-detection/defect_contrabert_c.sh b/experiments_downstream/Defect-detection/defect_contrabert_c.sh index fbd9e5c..f2136f5 100755 --- a/experiments_downstream/Defect-detection/defect_contrabert_c.sh +++ b/experiments_downstream/Defect-detection/defect_contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Defect-detection with contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Defect-detection" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_C" "$ROOT_DIR/results/contrabert_c/Defect-detection" diff --git a/experiments_downstream/Defect-detection/defect_contrabert_g.sh b/experiments_downstream/Defect-detection/defect_contrabert_g.sh index 57caab6..6e0c441 100755 --- a/experiments_downstream/Defect-detection/defect_contrabert_g.sh +++ b/experiments_downstream/Defect-detection/defect_contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Defect-detection with contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Defect-detection" ./run.sh "$ROOT_DIR/saved_models/ContraBERT_G" "$ROOT_DIR/results/contrabert_g/Defect-detection" diff --git a/experiments_downstream/Defect-detection/defect_graphcodebert.sh b/experiments_downstream/Defect-detection/defect_graphcodebert.sh index 3ef89f9..ca81163 100755 --- a/experiments_downstream/Defect-detection/defect_graphcodebert.sh +++ b/experiments_downstream/Defect-detection/defect_graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Defect-detection with graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Defect-detection" ./run.sh microsoft/graphcodebert-base "$ROOT_DIR/results/graphcodebert/Defect-detection" diff --git a/experiments_downstream/Defect-detection/defect_inv-codebert.sh b/experiments_downstream/Defect-detection/defect_inv-codebert.sh index 930e26f..16e7d3d 100755 --- a/experiments_downstream/Defect-detection/defect_inv-codebert.sh +++ b/experiments_downstream/Defect-detection/defect_inv-codebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Defect-detection with inv-codebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Defect-detection" -./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon" "$ROOT_DIR/results/inv-codebert/Defect-detection" +./run.sh "$ROOT_DIR/saved_models/InvCodeBERT-supcon/final" "$ROOT_DIR/results/inv-codebert/Defect-detection" diff --git a/experiments_downstream/Defect-detection/defect_inv-contrabert_c.sh b/experiments_downstream/Defect-detection/defect_inv-contrabert_c.sh index fdc2c5a..315aa99 100755 --- a/experiments_downstream/Defect-detection/defect_inv-contrabert_c.sh +++ b/experiments_downstream/Defect-detection/defect_inv-contrabert_c.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Defect-detection with inv-contrabert_c set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Defect-detection" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon" "$ROOT_DIR/results/inv-contrabert_c/Defect-detection" +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_C-supcon/final" "$ROOT_DIR/results/inv-contrabert_c/Defect-detection" diff --git a/experiments_downstream/Defect-detection/defect_inv-contrabert_g.sh b/experiments_downstream/Defect-detection/defect_inv-contrabert_g.sh index 390d8db..9fc514b 100755 --- a/experiments_downstream/Defect-detection/defect_inv-contrabert_g.sh +++ b/experiments_downstream/Defect-detection/defect_inv-contrabert_g.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Defect-detection with inv-contrabert_g set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Defect-detection" -./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon" "$ROOT_DIR/results/inv-contrabert_g/Defect-detection" +./run.sh "$ROOT_DIR/saved_models/InvContraBERT_G-supcon/final" "$ROOT_DIR/results/inv-contrabert_g/Defect-detection" diff --git a/experiments_downstream/Defect-detection/defect_inv-graphcodebert.sh b/experiments_downstream/Defect-detection/defect_inv-graphcodebert.sh index 1b40338..80d5266 100755 --- a/experiments_downstream/Defect-detection/defect_inv-graphcodebert.sh +++ b/experiments_downstream/Defect-detection/defect_inv-graphcodebert.sh @@ -1,8 +1,14 @@ #!/bin/bash # Downstream evaluation: Defect-detection with inv-graphcodebert set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + cd "$ROOT_DIR/downstream/Defect-detection" -./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon" "$ROOT_DIR/results/inv-graphcodebert/Defect-detection" +./run.sh "$ROOT_DIR/saved_models/InvGraphCodeBERT-supcon/final" "$ROOT_DIR/results/inv-graphcodebert/Defect-detection" diff --git a/experiments_downstream/Defect-detection/defect_inv-modernbert.sh b/experiments_downstream/Defect-detection/defect_inv-modernbert.sh new file mode 100755 index 0000000..03b85d3 --- /dev/null +++ b/experiments_downstream/Defect-detection/defect_inv-modernbert.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Downstream evaluation: Defect-detection with inv-modernbert +set -euo pipefail + +# Parse CUDA device argument (default: 0) +CUDA_DEVICE="${1:-0}" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE" + +cd "$ROOT_DIR/downstream/Defect-detection" +./run.sh "$ROOT_DIR/saved_models/aug-only/InvModernBERT-supcon/final" "$ROOT_DIR/results/inv-modernbert/Defect-detection" diff --git a/experiments_downstream/__init__.py b/experiments_downstream/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/experiments_downstream/gen_all.py b/experiments_downstream/gen_all.py index 3b54ad4..4471370 100644 --- a/experiments_downstream/gen_all.py +++ b/experiments_downstream/gen_all.py @@ -31,28 +31,34 @@ # Our trained models ( "inv-codebert", - "./saved_models/InvCodeBERT-supcon", + "./saved_models/InvCodeBERT-supcon/final", "microsoft/codebert-base", "roberta", ), ( "inv-graphcodebert", - "./saved_models/InvGraphCodeBERT-supcon", + "./saved_models/InvGraphCodeBERT-supcon/final", "microsoft/graphcodebert-base", "roberta", ), ( "inv-contrabert_c", - "./saved_models/InvContraBERT_C-supcon", + "./saved_models/InvContraBERT_C-supcon/final", "microsoft/codebert-base", "roberta", ), ( "inv-contrabert_g", - "./saved_models/InvContraBERT_G-supcon", + "./saved_models/InvContraBERT_G-supcon/final", "microsoft/graphcodebert-base", "roberta", ), + ( + "inv-modernbert", + "./saved_models/aug-only/InvModernBERT-supcon/final", + "answerdotai/ModernBERT-base", + "modernbert", + ), ] # These are the literal shell lines we want in the output. @@ -69,6 +75,13 @@ def model_ref(model_path: str) -> str: return model_path +def tokenizer_ref(tokenizer_path: str) -> str: + """Return the shell expression for the tokenizer path.""" + if tokenizer_path.startswith("./"): + return f'"{D}ROOT_DIR/{tokenizer_path[2:]}"' + return tokenizer_path + + def make_script( task_dir: str, short: str, @@ -84,9 +97,15 @@ def make_script( "#!/bin/bash", f"# Downstream evaluation: {task_dir}{sl} with {short}", "set -euo pipefail", + "", + "# Parse CUDA device argument (default: 0)", + 'CUDA_DEVICE="${1:-0}"', + "", SD_LINE, RD_LINE, "", + 'export CUDA_VISIBLE_DEVICES="$CUDA_DEVICE"', + "", f'cd "{D}ROOT_DIR/downstream/{task_dir}"', f"./run.sh {mr} {op}{args_extra}", "", @@ -104,12 +123,13 @@ def write_script(task_dir: str, fname: str, content: str) -> None: count = 0 for short, mpath, tok, mtype in models: + tok_ref = tokenizer_ref(tok) # Clone-detection-POJ104: run.sh write_script( "Clone-detection-POJ104", f"clone-poj104_{short}.sh", make_script( - "Clone-detection-POJ104", short, mpath, args_extra=f" {mtype} {tok}" + "Clone-detection-POJ104", short, mpath, args_extra=f" {mtype} {tok_ref}" ), ) count += 1 @@ -124,7 +144,7 @@ def write_script(task_dir: str, fname: str, content: str) -> None: short, mpath, subset=sub, - args_extra=f" {sub} {mtype} {tok}", + args_extra=f" {sub} {mtype} {tok_ref}", ), ) count += 1 @@ -138,15 +158,15 @@ def write_script(task_dir: str, fname: str, content: str) -> None: count += 1 # Code-classification-POJ104: run.sh + # POJ104 has no language subsets — data lives directly in ./dataset/ write_script( "Code-classification-POJ104", - f"cls-poj104_Cpp_{short}.sh", + f"cls-poj104_{short}.sh", make_script( "Code-classification-POJ104", short, mpath, - subset="Cpp", - args_extra=f" Cpp {mtype} {tok}", + args_extra=f' "" {mtype} {tok_ref}', ), ) count += 1 @@ -161,7 +181,7 @@ def write_script(task_dir: str, fname: str, content: str) -> None: short, mpath, subset=sub, - args_extra=f" {sub} {mtype} {tok}", + args_extra=f" {sub} {mtype} {tok_ref}", ), ) count += 1 diff --git a/experiments_downstream/parse_results.py b/experiments_downstream/parse_results.py new file mode 100644 index 0000000..9673698 --- /dev/null +++ b/experiments_downstream/parse_results.py @@ -0,0 +1,203 @@ +#!/usr/bin/env python3 +"""Parse downstream evaluation logs into pivot-style Markdown tables.""" + +from __future__ import annotations + +import argparse +import json +import re +from pathlib import Path + +import pandas as pd + +# --------------------------------------------------------------------------- +# Score parsing helpers +# --------------------------------------------------------------------------- + +MAP_PATTERN = re.compile(r"MAP@R\W*[:=]?\W*(\d*\.?\d+)") +TEST_ACC_PATTERN = re.compile(r"\btest_acc\b\s*=\s*(\d*\.?\d+)") +FLOAT64_PATTERN = re.compile(r"np\.float64\((\d*\.?\d+)\)") + + +def _read_text(path: Path) -> str: + try: + return path.read_text(encoding="utf-8", errors="ignore") + except FileNotFoundError: + return "" + + +def parse_clone_score(path: Path) -> float | None: + text = _read_text(path).strip() + if not text: + return None + match = MAP_PATTERN.search(text) + if match: + return float(match.group(1)) + match = FLOAT64_PATTERN.search(text) + if match: + return float(match.group(1)) + try: + data = json.loads(text.replace("'", '"')) + except json.JSONDecodeError: + return None + value = data.get("MAP@R") + if isinstance(value, (int, float)): + return float(value) + if isinstance(value, str): + try: + return float(value) + except ValueError: + return None + return None + + +def parse_classification_score(path: Path) -> float | None: + text = _read_text(path) + if not text: + return None + matches = TEST_ACC_PATTERN.findall(text) + if not matches: + return None + return float(matches[-1]) + + +# --------------------------------------------------------------------------- +# Column definitions +# --------------------------------------------------------------------------- + +# Ordered subsets that become column pairs (, aug). +SUBSETS = ["Java250", "Python800", "C++1400", "POJ104"] + +# Map from task category to (codenet_task_dir_name, poj104_task_dir_name). +CLONE_CODENET = "Clone-detection-CodeNet" +CLONE_POJ104 = "Clone-detection-POJ104" +CLS_CODENET = "Code-classification-CodeNet" +CLS_POJ104 = "Code-classification-POJ104" + + +# --------------------------------------------------------------------------- +# Result collection +# --------------------------------------------------------------------------- + + +def _fmt(value: float | None, digits: int) -> str: + if value is None: + return "-" + return f"{value * 100:.{digits}f}" + + +def _collect_clone_row(model_dir: Path, digits: int) -> dict[str, str]: + row: dict[str, str] = {} + # CodeNet subsets + codenet_dir = model_dir / CLONE_CODENET + for subset in ("Java250", "Python800", "C++1400"): + subset_dir = codenet_dir / subset + reg = parse_clone_score(subset_dir / "test.log") + aug = parse_clone_score(subset_dir / "aug_test.log") + row[subset] = _fmt(reg, digits) + row[f"{subset} aug"] = _fmt(aug, digits) + # POJ104 (logs directly in the task dir) + poj_dir = model_dir / CLONE_POJ104 + reg = parse_clone_score(poj_dir / "test.log") + aug = parse_clone_score(poj_dir / "aug_test.log") + row["POJ104"] = _fmt(reg, digits) + row["POJ104 aug"] = _fmt(aug, digits) + return row + + +def _collect_cls_row(model_dir: Path, digits: int) -> dict[str, str]: + row: dict[str, str] = {} + # CodeNet subsets + codenet_dir = model_dir / CLS_CODENET + for subset in ("Java250", "Python800", "C++1400"): + subset_dir = codenet_dir / subset + reg = parse_classification_score(subset_dir / "test_train.log") + aug = parse_classification_score(subset_dir / "aug_test.log") + row[subset] = _fmt(reg, digits) + row[f"{subset} aug"] = _fmt(aug, digits) + # POJ104 + poj_dir = model_dir / CLS_POJ104 + reg = parse_classification_score(poj_dir / "test_train.log") + aug = parse_classification_score(poj_dir / "aug_test.log") + row["POJ104"] = _fmt(reg, digits) + row["POJ104 aug"] = _fmt(aug, digits) + return row + + +def build_table( + results_root: Path, + collector, + digits: int, +) -> pd.DataFrame: + columns = [] + for s in SUBSETS: + columns.extend([s, f"{s} aug"]) + + rows: list[dict[str, str]] = [] + if not results_root.exists(): + return pd.DataFrame(columns=["Model"] + columns) + + for model_dir in sorted(results_root.iterdir()): + if not model_dir.is_dir(): + continue + row = collector(model_dir, digits) + row["Model"] = model_dir.name + rows.append(row) + + if not rows: + return pd.DataFrame(columns=["Model"] + columns) + + df = pd.DataFrame(rows) + df = df[["Model"] + columns] + return df + + +# --------------------------------------------------------------------------- +# CLI +# --------------------------------------------------------------------------- + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser( + description="Parse downstream results into pivot Markdown tables." + ) + parser.add_argument( + "--results-root", + default="results", + help="Root directory containing model result folders.", + ) + parser.add_argument( + "--digits", + type=int, + default=2, + help="Decimal places for percentage scores.", + ) + return parser.parse_args() + + +def main() -> None: + args = parse_args() + results_root = Path(args.results_root).resolve() + + clone_df = build_table(results_root, _collect_clone_row, args.digits) + cls_df = build_table(results_root, _collect_cls_row, args.digits) + + found = False + if not clone_df.empty: + found = True + print("# Clone Detection (MAP@R)\n") + print(clone_df.to_markdown(index=False)) + print() + + if not cls_df.empty: + found = True + print("# Code Classification (Acc)\n") + print(cls_df.to_markdown(index=False)) + print() + + if not found: + print(f"No results found under {results_root}") + + +if __name__ == "__main__": + main() diff --git a/experiments_downstream/run_all_downstream.py b/experiments_downstream/run_all_downstream.py new file mode 100644 index 0000000..aa0694e --- /dev/null +++ b/experiments_downstream/run_all_downstream.py @@ -0,0 +1,324 @@ +#!/usr/bin/env python3 +"""Launch downstream tasks across GPUs with a work-stealing pool.""" + +from __future__ import annotations + +import os +import queue +import subprocess +import threading +from concurrent.futures import ThreadPoolExecutor +from dataclasses import dataclass +from pathlib import Path +from typing import TextIO + +import typer +from tqdm import tqdm + + +@dataclass(frozen=True) +class ModelSpec: + model_path: str + tokenizer_name: str + model_type: str + + +@dataclass(frozen=True) +class RunHandle: + label: str + process: subprocess.Popen + log_file: TextIO + + +MODELS: dict[tuple[str, str], ModelSpec] = { + # --- baselines --- + ("codebert", "supcon"): ModelSpec( + "microsoft/codebert-base", + "microsoft/codebert-base", + "roberta", + ), + ("graphcodebert", "supcon"): ModelSpec( + "microsoft/graphcodebert-base", + "microsoft/graphcodebert-base", + "roberta", + ), + ("contrabert_c", "supcon"): ModelSpec( + "./saved_models/ContraBERT_C", + "microsoft/codebert-base", + "roberta", + ), + ("contrabert_g", "supcon"): ModelSpec( + "./saved_models/ContraBERT_G", + "microsoft/graphcodebert-base", + "roberta", + ), + # --- InvPT models --- + ("inv-codebert", "supcon"): ModelSpec( + "./saved_models/InvCodeBERT-supcon/final", + "microsoft/codebert-base", + "roberta", + ), + ("inv-graphcodebert", "supcon"): ModelSpec( + "./saved_models/InvGraphCodeBERT-supcon/final", + "microsoft/graphcodebert-base", + "roberta", + ), + ("inv-contrabert_c", "supcon"): ModelSpec( + "./saved_models/InvContraBERT_C-supcon/final", + "microsoft/codebert-base", + "roberta", + ), + ("inv-contrabert_g", "supcon"): ModelSpec( + "./saved_models/InvContraBERT_G-supcon/final", + "microsoft/graphcodebert-base", + "roberta", + ), + ("inv-modernbert", "supcon"): ModelSpec( + "./saved_models/aug-only/InvModernBERT-supcon/final", + "answerdotai/ModernBERT-base", + "modernbert", + ), +} + + +TASKS = [ + ("Clone-detection-POJ104", None), + ("Clone-detection-CodeNet", "Java250"), + ("Clone-detection-CodeNet", "Python800"), + ("Clone-detection-CodeNet", "C++1400"), + ("Code-classification-POJ104", None), + ("Code-classification-CodeNet", "Java250"), + ("Code-classification-CodeNet", "Python800"), + ("Code-classification-CodeNet", "C++1400"), +] + + +app = typer.Typer(add_completion=False, no_args_is_help=True) + + +def resolve_model(model_key: str, loss: str) -> ModelSpec: + key = (model_key, loss) + if key not in MODELS: + available = ", ".join( + f"{model}/{loss_key}" + for model, loss_key in sorted(MODELS.keys(), key=lambda x: (x[0], x[1])) + ) + raise typer.BadParameter( + f"Unknown model/loss: {model_key}/{loss}. Available: {available}" + ) + return MODELS[key] + + +def run_task( + root: Path, + model_key: str, + spec: ModelSpec, + task_dir: str, + subset: str | None, + gpu_id: str, + results_root: Path, + dry_run: bool, +) -> RunHandle | None: + task_path = root / "downstream" / task_dir + model_path = spec.model_path + if model_path.startswith("./"): + model_path = str((root / model_path[2:]).resolve()) + + results_base = results_root / model_key / task_dir + results_dir = results_base / subset if subset else results_base + results_dir_str = str(results_dir.resolve()) + log_path = results_dir / "run.log" + + cmd = ["./run.sh", model_path] + if task_dir == "Clone-detection-POJ104": + cmd.extend([results_dir_str, spec.model_type, spec.tokenizer_name]) + elif task_dir == "Clone-detection-CodeNet": + if subset is None: + raise ValueError("Subset is required for Clone-detection-CodeNet") + cmd.extend( + [ + results_dir_str, + subset, + spec.model_type, + spec.tokenizer_name, + ] + ) + elif task_dir == "Code-classification-POJ104": + subset_arg = subset or "" + cmd.extend( + [ + results_dir_str, + subset_arg, + spec.model_type, + spec.tokenizer_name, + ] + ) + elif task_dir == "Code-classification-CodeNet": + if subset is None: + raise ValueError("Subset is required for Code-classification-CodeNet") + cmd.extend( + [ + results_dir_str, + subset, + spec.model_type, + spec.tokenizer_name, + ] + ) + else: + raise ValueError(f"Unsupported task: {task_dir}") + + env = os.environ.copy() + env["CUDA_VISIBLE_DEVICES"] = gpu_id + + label = f"{model_key}/{task_dir}{'/' + subset if subset else ''}" + if dry_run: + print(f"[launch] GPU {gpu_id}: {label}") + print(f" cwd: {task_path}") + print(f" cmd: {' '.join(cmd)}") + return None + + results_dir.mkdir(parents=True, exist_ok=True) + log_file = log_path.open("w") + log_file.write(f"[launch] GPU {gpu_id}: {label}\n") + log_file.write(f"[launch] cwd: {task_path}\n") + log_file.write(f"[launch] cmd: {' '.join(cmd)}\n\n") + log_file.flush() + proc = subprocess.Popen( + cmd, + cwd=str(task_path), + env=env, + stdout=log_file, + stderr=subprocess.STDOUT, + ) + return RunHandle(label=label, process=proc, log_file=log_file) + + +@app.command() +def main( + all_models: bool = typer.Option( + False, "--all", help="Run all models in the registry." + ), + loss: str = typer.Option( + None, "--loss", help="Training loss identifier (e.g., supcon)." + ), + model: str = typer.Option( + None, + "--model", + help="Pretrained model key(s), comma-separated (e.g., inv-codebert,inv-graphcodebert).", + ), + gpus: str = typer.Option( + "0,1,2,3,4,5,6,7", + "--gpus", + help="Comma-separated GPU ids to use.", + ), + results_root: str = typer.Option( + "results", "--results-root", help="Base output directory for results." + ), + dry_run: bool = typer.Option( + False, "--dry-run", help="Print commands without executing them." + ), +) -> None: + root = Path(__file__).resolve().parents[1] + + # Resolve which models to run + if all_models: + if model is not None: + raise typer.BadParameter("Cannot use --model with --all") + entries = list(MODELS.items()) + if loss is not None: + loss_key = loss.strip() + entries = [((m, lk), s) for (m, lk), s in entries if lk == loss_key] + if not entries: + raise typer.BadParameter(f"No models found for loss={loss}") + else: + if model is None or loss is None: + raise typer.BadParameter( + "Either --all or both --model and --loss are required" + ) + loss_key = loss.strip() + model_keys = [m.strip() for m in model.split(",") if m.strip()] + if not model_keys: + raise typer.BadParameter("No model keys provided") + entries = [] + for model_key in model_keys: + spec = resolve_model(model_key, loss_key) + entries.append(((model_key, loss_key), spec)) + + gpu_ids = [gpu.strip() for gpu in gpus.split(",") if gpu.strip()] + if not gpu_ids: + raise typer.BadParameter("No GPU ids provided") + + # Build all jobs: (model_key, spec, task_dir, subset) + jobs: list[tuple[str, ModelSpec, str, str | None]] = [] + for (mk, _lk), sp in entries: + for task_dir, subset in TASKS: + jobs.append((mk, sp, task_dir, subset)) + + total = len(jobs) + results_root_path = Path(results_root).resolve() + + if dry_run: + for i, (mk, sp, task_dir, subset) in enumerate(jobs): + gpu_id = gpu_ids[i % len(gpu_ids)] + run_task(root, mk, sp, task_dir, subset, gpu_id, results_root_path, True) + print(f"\n[dry-run] {total} total jobs across {len(gpu_ids)} GPUs") + raise typer.Exit(0) + + # GPU work-stealing pool + gpu_pool: queue.Queue[str] = queue.Queue() + for gid in gpu_ids: + gpu_pool.put(gid) + + running = 0 + failed = 0 + lock = threading.Lock() + failures: list[str] = [] + pbar = tqdm(total=total, desc="Downstream", unit="task") + + def run_job(mk: str, sp: ModelSpec, task_dir: str, subset: str | None) -> None: + nonlocal running, failed + gpu_id = gpu_pool.get() + label = f"{mk}/{task_dir}{'/' + subset if subset else ''}" + try: + with lock: + running += 1 + pbar.set_postfix(running=running, failed=failed, refresh=True) + handle = run_task( + root, mk, sp, task_dir, subset, gpu_id, results_root_path, False + ) + if handle is not None: + code = handle.process.wait() + handle.log_file.close() + with lock: + running -= 1 + if code != 0: + failed += 1 + failures.append(f"{label} (exit {code})") + tqdm.write(f"[FAIL] GPU {gpu_id}: {label} (exit {code})") + else: + tqdm.write(f"[done] GPU {gpu_id}: {label}") + pbar.set_postfix(running=running, failed=failed, refresh=False) + pbar.update(1) + finally: + gpu_pool.put(gpu_id) + + with ThreadPoolExecutor(max_workers=len(gpu_ids)) as executor: + futures = [ + executor.submit(run_job, mk, sp, task_dir, subset) + for mk, sp, task_dir, subset in jobs + ] + for f in futures: + f.result() + pbar.close() + + if failures: + print(f"\n[error] {len(failures)}/{total} tasks failed:") + for failure in failures: + print(f" - {failure}") + raise typer.Exit(1) + + print(f"\n[done] All {total} downstream tasks completed successfully.") + + +if __name__ == "__main__": + app() diff --git a/experiments_downstream/run_task.py b/experiments_downstream/run_task.py new file mode 100755 index 0000000..5b7cda7 --- /dev/null +++ b/experiments_downstream/run_task.py @@ -0,0 +1,204 @@ +#!/usr/bin/env python3 +"""Run all models for a given task+dataset combination. + +Usage examples: + # Run all models for Code-classification-POJ104 on GPUs 0-7 + python run_task.py Code-classification-POJ104 + + # Run all models for Clone-detection-CodeNet on GPUs 0,1,2,3 + python run_task.py Clone-detection-CodeNet --gpus 0,1,2,3 + + # Only run scripts matching a subset (e.g., Java250) + python run_task.py Clone-detection-CodeNet --subset Java250 + + # Dry run to see what would execute + python run_task.py Defect-detection --dry-run + + # List all available tasks + python run_task.py --list +""" + +from __future__ import annotations + +import os +import queue +import subprocess +import threading +from concurrent.futures import ThreadPoolExecutor +from pathlib import Path + +import typer +from tqdm import tqdm + +app = typer.Typer(add_completion=False, no_args_is_help=True) + +SCRIPT_DIR = Path(__file__).resolve().parent + +# Models to skip (not yet ready / under development) +SKIP_MODELS = {"modernbert"} + + +def _is_skipped(script_name: str) -> bool: + """Return True if the script belongs to a skipped model.""" + return any(m in script_name for m in SKIP_MODELS) + + +def discover_tasks() -> list[str]: + """Return sorted list of task directories (those containing .sh files).""" + return sorted( + d.name for d in SCRIPT_DIR.iterdir() if d.is_dir() and any(d.glob("*.sh")) + ) + + +def discover_scripts(task: str, subset: str | None = None) -> list[Path]: + """Return all .sh scripts for a task, optionally filtered by subset.""" + task_path = SCRIPT_DIR / task + if not task_path.is_dir(): + raise typer.BadParameter( + f"Task directory not found: {task}\n" + f"Available tasks: {', '.join(discover_tasks())}" + ) + scripts = sorted(s for s in task_path.glob("*.sh") if not _is_skipped(s.name)) + if not scripts: + raise typer.BadParameter(f"No .sh scripts found in {task}") + if subset: + filtered = [s for s in scripts if subset in s.name] + if not filtered: + all_names = [s.name for s in scripts] + raise typer.BadParameter( + f"No scripts matching subset '{subset}' in {task}.\n" + f"Available scripts: {', '.join(all_names)}" + ) + scripts = filtered + return scripts + + +@app.command() +def main( + task: str = typer.Argument( + None, + help="Task+dataset directory name (e.g., Code-classification-POJ104). " + "Use --list to see all available tasks.", + ), + gpus: str = typer.Option( + "0,1,2,3,4,5,6,7", + "--gpus", + help="Comma-separated GPU ids to use.", + ), + subset: str | None = typer.Option( + None, + "--subset", + help="Only run scripts whose filename contains this substring " + "(e.g., Java250, inv-, codebert).", + ), + dry_run: bool = typer.Option( + False, "--dry-run", help="Print commands without executing them." + ), + list_tasks: bool = typer.Option( + False, "--list", help="List all available task directories and exit." + ), +) -> None: + """Run all model scripts for a given task+dataset, distributed across GPUs.""" + + # --list mode + if list_tasks: + tasks = discover_tasks() + typer.echo("Available tasks:") + for t in tasks: + n_scripts = len( + [s for s in (SCRIPT_DIR / t).glob("*.sh") if not _is_skipped(s.name)] + ) + typer.echo(f" {t} ({n_scripts} scripts)") + raise typer.Exit(0) + + if task is None: + typer.echo("Error: Missing argument 'TASK'.\n") + typer.echo("Use --list to see available tasks, or --help for usage.") + raise typer.Exit(1) + + scripts = discover_scripts(task, subset) + gpu_ids = [g.strip() for g in gpus.split(",") if g.strip()] + if not gpu_ids: + raise typer.BadParameter("No GPU ids provided") + + total = len(scripts) + typer.echo(f"Task: {task}") + typer.echo(f"Scripts to run: {total}") + typer.echo(f"GPUs: {', '.join(gpu_ids)}") + typer.echo("") + + if dry_run: + for i, script in enumerate(scripts): + gpu_id = gpu_ids[i % len(gpu_ids)] + typer.echo(f" [GPU {gpu_id}] bash {script.name}") + typer.echo(f"\n[dry-run] {total} jobs across {len(gpu_ids)} GPUs") + raise typer.Exit(0) + + # Work-stealing GPU pool + gpu_pool: queue.Queue[str] = queue.Queue() + for gid in gpu_ids: + gpu_pool.put(gid) + + running = 0 + failed = 0 + lock = threading.Lock() + failures: list[str] = [] + pbar = tqdm(total=total, desc=task, unit="script") + + def run_script(script: Path) -> None: + nonlocal running, failed + gpu_id = gpu_pool.get() + name = script.name + log_path = script.with_suffix(".log") + try: + with lock: + running += 1 + pbar.set_postfix(running=running, failed=failed, refresh=True) + + env = os.environ.copy() + env["CUDA_VISIBLE_DEVICES"] = gpu_id + + with open(log_path, "w") as log_file: + log_file.write(f"[launch] GPU {gpu_id}: {name}\n") + log_file.write(f"[launch] cmd: bash {script}\n\n") + log_file.flush() + + proc = subprocess.Popen( + ["bash", str(script), gpu_id], + cwd=str(script.parent), + env=env, + stdout=log_file, + stderr=subprocess.STDOUT, + ) + code = proc.wait() + + with lock: + running -= 1 + if code != 0: + failed += 1 + failures.append(f"{name} (exit {code})") + tqdm.write(f"[FAIL] GPU {gpu_id}: {name} (exit {code})") + else: + tqdm.write(f"[done] GPU {gpu_id}: {name}") + pbar.set_postfix(running=running, failed=failed, refresh=False) + pbar.update(1) + finally: + gpu_pool.put(gpu_id) + + with ThreadPoolExecutor(max_workers=len(gpu_ids)) as executor: + futures = [executor.submit(run_script, s) for s in scripts] + for f in futures: + f.result() + pbar.close() + + if failures: + typer.echo(f"\n[error] {len(failures)}/{total} scripts failed:") + for failure in failures: + typer.echo(f" - {failure}") + raise typer.Exit(1) + + typer.echo(f"\n[done] All {total} scripts for {task} completed successfully.") + + +if __name__ == "__main__": + app() diff --git a/pyproject.toml b/pyproject.toml index 0d67fbf..959a939 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ dependencies = [ "pyyaml>=6.0", "returns[compatible-mypy]>=0.23.0", "scikit-learn==1.6.0", + "tabulate>=0.9.0", "tensorboardx==2.6.2.2", "tokenizers>=0.20", "torch>=2.6", diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..d1c5ec5 --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail + +uv run experiments_downstream/run_all_downstream.py --all --loss supcon diff --git a/tests/test_model_wrapper.py b/tests/test_model_wrapper.py index bcd23fc..174b8f6 100644 --- a/tests/test_model_wrapper.py +++ b/tests/test_model_wrapper.py @@ -93,6 +93,7 @@ def _make_modernbert_wrapper( num_attention_heads=num_attention_heads, intermediate_size=intermediate_size, max_position_embeddings=max_position_embeddings, + pad_token_id=0, ) mlm = ModernBertForMaskedLM(config) return SplitHeadWrapper(mlm) diff --git a/tests/test_parse_results.py b/tests/test_parse_results.py new file mode 100644 index 0000000..01646e4 --- /dev/null +++ b/tests/test_parse_results.py @@ -0,0 +1,104 @@ +from __future__ import annotations + +from pathlib import Path + +from experiments_downstream.parse_results import ( + _collect_clone_row, + _collect_cls_row, + build_table, + parse_classification_score, + parse_clone_score, +) + + +def _write(path: Path, content: str) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(content) + + +def test_parse_clone_score_float64(tmp_path: Path) -> None: + log = tmp_path / "test.log" + log.write_text("{'MAP@R': np.float64(0.5621)}\n") + assert parse_clone_score(log) == 0.5621 + + +def test_parse_clone_score_missing(tmp_path: Path) -> None: + assert parse_clone_score(tmp_path / "nonexistent.log") is None + + +def test_parse_classification_score(tmp_path: Path) -> None: + log = tmp_path / "test_train.log" + log.write_text( + "02/16/2026 00:00:00 - INFO - __main__ - ***** Test results *****\n" + "02/16/2026 00:00:00 - INFO - __main__ - test_acc = 0.3992\n" + ) + assert parse_classification_score(log) == 0.3992 + + +def test_parse_classification_score_missing(tmp_path: Path) -> None: + assert parse_classification_score(tmp_path / "nonexistent.log") is None + + +def test_build_table_clone_and_classification(tmp_path: Path) -> None: + results_root = tmp_path / "results" + + # Clone detection – POJ104 (files directly in task dir) + _write( + results_root / "inv-codebert" / "Clone-detection-POJ104" / "test.log", + "{'MAP@R': np.float64(0.5621)}\n", + ) + _write( + results_root / "inv-codebert" / "Clone-detection-POJ104" / "aug_test.log", + "{'MAP@R': np.float64(0.4321)}\n", + ) + + # Classification – CodeNet / Java250 + test_train_log = ( + "02/16/2026 00:00:00 - INFO - __main__ - ***** Test results *****\n" + "02/16/2026 00:00:00 - INFO - __main__ - test_acc = 0.3992\n" + ) + _write( + results_root + / "inv-codebert" + / "Code-classification-CodeNet" + / "Java250" + / "test_train.log", + test_train_log, + ) + _write( + results_root + / "inv-codebert" + / "Code-classification-CodeNet" + / "Java250" + / "aug_test.log", + test_train_log.replace("0.3992", "0.2777"), + ) + + clone_df = build_table(results_root, _collect_clone_row, 4) + assert len(clone_df) == 1 + row = clone_df.iloc[0] + assert row["Model"] == "inv-codebert" + assert row["POJ104"] == "56.2100" + assert row["POJ104 aug"] == "43.2100" + + cls_df = build_table(results_root, _collect_cls_row, 4) + assert len(cls_df) == 1 + row = cls_df.iloc[0] + assert row["Model"] == "inv-codebert" + assert row["Java250"] == "39.9200" + assert row["Java250 aug"] == "27.7700" + + +def test_build_table_placeholder_for_missing(tmp_path: Path) -> None: + results_root = tmp_path / "results" + _write( + results_root / "inv-codebert" / "Clone-detection-POJ104" / "test.log", + "{'MAP@R': np.float64(0.5621)}\n", + ) + + clone_df = build_table(results_root, _collect_clone_row, 4) + row = clone_df.iloc[0] + # POJ104 regular is present, but aug and CodeNet subsets should be "-" + assert row["POJ104"] == "56.2100" + assert row["POJ104 aug"] == "-" + assert row["Java250"] == "-" diff --git a/uv.lock b/uv.lock index 1ea8840..fbd8b66 100644 --- a/uv.lock +++ b/uv.lock @@ -645,6 +645,7 @@ dependencies = [ { name = "pyyaml" }, { name = "returns", extra = ["compatible-mypy"] }, { name = "scikit-learn" }, + { name = "tabulate" }, { name = "tensorboardx" }, { name = "tokenizers" }, { name = "torch" }, @@ -686,6 +687,7 @@ requires-dist = [ { name = "pyyaml", specifier = ">=6.0" }, { name = "returns", extras = ["compatible-mypy"], specifier = ">=0.23.0" }, { name = "scikit-learn", specifier = "==1.6.0" }, + { name = "tabulate", specifier = ">=0.9.0" }, { name = "tensorboardx", specifier = "==2.6.2.2" }, { name = "tokenizers", specifier = ">=0.20" }, { name = "torch", specifier = ">=2.6" }, @@ -2038,6 +2040,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/99/ff/c87e0622b1dadea79d2fb0b25ade9ed98954c9033722eb707053d310d4f3/sympy-1.13.3-py3-none-any.whl", hash = "sha256:54612cf55a62755ee71824ce692986f23c88ffa77207b30c1368eda4a7060f73", size = 6189483 }, ] +[[package]] +name = "tabulate" +version = "0.9.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ec/fe/802052aecb21e3797b8f7902564ab6ea0d60ff8ca23952079064155d1ae1/tabulate-0.9.0.tar.gz", hash = "sha256:0095b12bf5966de529c0feb1fa08671671b3368eec77d7ef7ab114be2c068b3c", size = 81090 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/40/44/4a5f08c96eb108af5cb50b41f76142f0afa346dfa99d5296fe7202a11854/tabulate-0.9.0-py3-none-any.whl", hash = "sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f", size = 35252 }, +] + [[package]] name = "tensorboardx" version = "2.6.2.2"