Text Classification
Transformers
Safetensors
code
roberta
clone-detection
graphcodebert
code-similarity
Eval Results (legacy)
text-embeddings-inference
Instructions to use thealper2/graphcodebert-code-clone-detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thealper2/graphcodebert-code-clone-detection with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="thealper2/graphcodebert-code-clone-detection")# Load model directly from transformers import AutoTokenizer, GraphCodeBERTForCloneDetection tokenizer = AutoTokenizer.from_pretrained("thealper2/graphcodebert-code-clone-detection") model = GraphCodeBERTForCloneDetection.from_pretrained("thealper2/graphcodebert-code-clone-detection", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 8,595 Bytes
2ef4ea4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | {
"model_name": "microsoft/graphcodebert-base",
"model_dir": "/mnt/d/work2/graphcodebert-code-clone-detection/models/graphcodebert-clone-detection",
"dataset_name": "PoolC/1-fold-clone-detection-600k-5fold",
"dataset_split_strategy": {
"train_split": "train",
"heldout_split": "val",
"note": "The repository provides one of 5 predefined folds as `train` + `val`; those groups are disjoint and are kept as-is. `val` is partitioned further into validation/test along problem-group boundaries.",
"heldout_groups": 59,
"validation_groups": 29,
"test_groups": 30,
"dropped_cross_boundary_pairs": 337398,
"validation": {
"num_examples": 483738,
"negatives_label_0": 157558,
"positives_label_1": 326180,
"positive_ratio": 0.674291,
"num_groups": 29
},
"test": {
"num_examples": 503224,
"negatives_label_0": 167224,
"positives_label_1": 336000,
"positive_ratio": 0.667695,
"num_groups": 30
}
},
"num_train_examples": 50000,
"num_validation_examples": 20000,
"num_test_examples": 20000,
"class_distributions": {
"train": {
"num_examples": 50000,
"negatives_label_0": 25000,
"positives_label_1": 25000,
"positive_ratio": 0.5,
"num_groups": 240
},
"validation": {
"num_examples": 20000,
"negatives_label_0": 10000,
"positives_label_1": 10000,
"positive_ratio": 0.5,
"num_groups": 29
},
"test": {
"num_examples": 20000,
"negatives_label_0": 10000,
"positives_label_1": 10000,
"positive_ratio": 0.5,
"num_groups": 30
}
},
"class_weighting": {
"mode": "auto",
"threshold": 0.6,
"majority_class_share": 0.5,
"applied": false,
"weights": null,
"reason": "Measured majority-class share 0.5000 is within the 0.6 threshold, so weighted cross entropy is NOT used."
},
"sequence_length": 512,
"data_flow_length": 128,
"total_sequence_length": 640,
"per_device_train_batch_size": 16,
"gradient_accumulation_steps": 1,
"effective_batch_size": 16,
"learning_rate": 2e-05,
"num_train_epochs": 3.0,
"optimizer": "adamw_torch",
"scheduler": "linear",
"warmup_ratio": 0.1,
"warmup_steps": 938,
"weight_decay": 0.01,
"max_grad_norm": 1.0,
"mixed_precision": "fp16",
"gradient_checkpointing": false,
"seed": 42,
"training_time_seconds": 6921.9,
"training_time_hours": 1.923,
"train_runtime_metrics": {
"train_runtime": 6918.8074,
"train_samples_per_second": 21.68,
"train_steps_per_second": 1.355,
"total_flos": 0.0,
"train_loss": 0.43145505716959637,
"epoch": 3.0
},
"gpu": {
"cuda_available": true,
"torch_version": "2.11.0+cu128",
"transformers_version": "5.17.0",
"python_version": "3.12.3",
"platform": "Linux-6.18.33.2-microsoft-standard-WSL2-x86_64-with-glibc2.39",
"gpu_name": "NVIDIA GeForce RTX 5060 Ti",
"gpu_count": 1,
"gpu_total_memory_gb": 15.9,
"gpu_capability": "12.0",
"cuda_version": "12.8"
},
"parameters": {
"trainable_parameters": 125236994,
"total_parameters": 125236994
},
"best_validation_f1": 0.8671882190520018,
"best_checkpoint": "./outputs/checkpoint-9000",
"validation_metrics": {
"loss": 0.34459105134010315,
"accuracy": 0.8557,
"precision": 0.8032395566922421,
"recall": 0.9422,
"f1": 0.8671882190520018,
"macro_f1": 0.8546121719233737,
"tp": 9422,
"tn": 7692,
"fp": 2308,
"fn": 578,
"confusion_matrix": [
[
7692,
2308
],
[
578,
9422
]
],
"confusion_matrix_layout": "[[TN, FP], [FN, TP]]",
"support": {
"num_examples": 20000,
"label_0": 10000,
"label_1": 10000
},
"runtime": 173.9737,
"samples_per_second": 114.96,
"steps_per_second": 3.592,
"num_examples": 20000,
"eval_seconds": 174.0
},
"test_metrics": {
"loss": 0.3165612816810608,
"model_preparation_time": 0.0022,
"accuracy": 0.87465,
"precision": 0.8409939018840448,
"recall": 0.924,
"f1": 0.8805450993472149,
"macro_f1": 0.874343974488208,
"tp": 9240,
"tn": 8253,
"fp": 1747,
"fn": 760,
"confusion_matrix": [
[
8253,
1747
],
[
760,
9240
]
],
"confusion_matrix_layout": "[[TN, FP], [FN, TP]]",
"support": {
"num_examples": 20000,
"label_0": 10000,
"label_1": 10000
},
"runtime": 181.6455,
"samples_per_second": 110.105,
"steps_per_second": 3.441,
"num_examples": 20000,
"eval_seconds": 181.7
},
"preprocessing": {
"snippet_pool": {
"num_unique_snippets": 44950,
"scan_seconds": 46.3,
"snippets_with_multiple_groups": 1,
"cross_split_snippet_overlap": {
"train|val:snippets": 0,
"train|val:groups": 0
},
"per_split": {
"train": {
"num_examples": 5388622,
"negatives_label_0": 2694311,
"positives_label_1": 2694311,
"positive_ratio": 0.5,
"num_groups": 240
},
"val": {
"num_examples": 1324360,
"negatives_label_0": 662180,
"positives_label_1": 662180,
"positive_ratio": 0.5,
"num_groups": 59
}
}
},
"feature_extraction": {
"num_snippets": 44950,
"extraction_seconds": 64.1,
"status_counts": {
"ok": 44930,
"comment_strip_failed": 13,
"dfg_failed": 7
},
"snippets_with_empty_dataflow": 263,
"dataflow_nodes_mean": 44.22,
"dataflow_nodes_p50": 33,
"dataflow_nodes_p95": 127,
"dataflow_nodes_max": 193,
"code_tokens_mean": 137.9,
"code_tokens_truncated": 885,
"total_dataflow_edges": 2481388,
"sequence_length": 640
},
"subsampling": {
"train": {
"subsampled": true,
"kept": 50000,
"balanced": true
},
"validation": {
"subsampled": true,
"kept": 20000,
"balanced": true
},
"test": {
"subsampled": true,
"kept": 20000,
"balanced": true
}
}
},
"sanity_check": {
"passed": true,
"device": "cuda",
"checks": [
{
"check": "1_dataset_loading",
"passed": true,
"detail": "train=50000 val=20000 test=20000"
},
{
"check": "2_column_detection",
"passed": true,
"detail": "code columns=code1/code2, label=similar; excluded from features: ['code1_group', 'code2_group', 'pair_id', 'question_pair_id']"
},
{
"check": "3_label_correctness",
"passed": true,
"detail": "labels in {0,1}; validation positive ratio=0.5"
},
{
"check": "4_tokenisation",
"passed": true,
"detail": "<s>...</s> wrapping OK, 93 code tokens, decodes to 'import math a , b , c = map ( int , input ( ) . split ( ) ) '"
},
{
"check": "5_dataflow_extraction",
"passed": true,
"detail": "44687/44950 snippets have a non-empty data-flow graph, 2481388 edges, mean nodes=44.22"
},
{
"check": "6_attention_mask",
"passed": true,
"detail": "shape=(640, 640) (code_length 512 + data_flow_length 128), 93 code tokens, 30 nodes, density=0.0215, padding rows empty"
},
{
"check": "7_forward_pass",
"passed": true,
"detail": "logits shape=(16, 2) for batch of 16 pairs; mask tensor=(16, 640, 640)"
},
{
"check": "8_finite_loss",
"passed": true,
"detail": "loss=0.6978 (chance level ~0.6931)"
},
{
"check": "9_training_step",
"passed": true,
"detail": "loss=0.6798, grad_norm=2.4929, weights updated (amp=on, dtype=torch.float16)"
}
],
"parameters": {
"trainable_parameters": 125236994,
"total_parameters": 125236994
},
"sequence_length": 640
},
"test_metrics_provenance": {
"note": "Re-scored after fixing a transformers v5 dataloader-caching bug: Trainer.get_eval_dataloader caches under the key 'eval' when a Dataset object is passed and dataloader_persistent_workers=True, so the original in-training test evaluation silently re-scored the validation split. evaluate_split now uses Trainer.predict and verifies the returned labels.",
"superseded_test_f1": 0.8671882190520018,
"corrected_test_f1": 0.8805450993472149,
"validation_f1_unchanged": 0.8671882190520018
}
} |