Paper deep dive
Automatic Identification of Parallelizable Loops Using Transformer-Based Source Code Representations
Izavan dos S. Correia, Henrique C. T. Santos, Tiago A. E. Ferreira
Intelligence
Status: succeeded | Model: google/gemini-3.1-flash-lite-preview | Prompt: intel-v1 | Confidence: 96%
Last extracted: 4/1/2026, 1:49:15 AM
Summary
This paper presents a Transformer-based approach using DistilBERT to classify source code loops as either parallelizable or undefined. By leveraging subword tokenization and contextual embeddings, the model eliminates the need for complex manual feature engineering and dimensionality reduction required by previous token-based methods. The approach was evaluated on a balanced dataset of 8,340 synthetic and real-world code samples using 10-fold cross-validation, achieving over 99% accuracy and demonstrating high robustness and computational efficiency.
Entities (5)
Relation Signals (3)
DistilBERT â uses â Transformer
confidence 100% ¡ DistilBERT, a distilled and computationally efficient variant of BERT
10-fold cross-validation â evaluates â DistilBERT
confidence 95% ¡ evaluated the model using rigorous 10-fold cross-validation
DistilBERT â performs â Automatic Parallelization
confidence 95% ¡ We adopt DistilBERT to process source code sequences... to classify the parallelization potential
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
Abstract:Automatic parallelization remains a challenging problem in software engineering, particularly in identifying code regions where loops can be safely executed in parallel on modern multi-core architectures. Traditional static analysis techniques, such as dependence analysis and polyhedral models, often struggle with irregular or dynamically structured code. In this work, we propose a Transformer-based approach to classify the parallelization potential of source code, focusing on distinguishing independent (parallelizable) loops from undefined ones. We adopt DistilBERT to process source code sequences using subword tokenization, enabling the model to capture contextual syntactic and semantic patterns without handcrafted features. The approach is evaluated on a balanced dataset combining synthetically generated loops and manually annotated real-world code, using 10-fold cross-validation and multiple performance metrics. Results show consistently high performance, with mean accuracy above 99\% and low false positive rates, demonstrating robustness and reliability. Compared to prior token-based methods, the proposed approach simplifies preprocessing while improving generalization and maintaining computational efficiency. These findings highlight the potential of lightweight Transformer models for practical identification of parallelization opportunities at the loop level.
Tags
Links
- Source: https://arxiv.org/abs/2603.30040v1
- Canonical: https://arxiv.org/abs/2603.30040v1
Trouble viewing inline? Open PDF directly â
Full Text
53,998 characters extracted from source content.
Expand or collapse full text
Automatic Identification of Parallelizable Loops Using Transformer-Based Source Code Representations Izavan dos S. Correia 1 , Henrique C. T. Santos 2 , and Tiago A. E. Ferreira 1 1 Graduate Program in Applied Informatics (PPGIA), Federal Rural University of Pernambuco (UFRPE), Recife, Pernambuco, Brazil. izavan.correia@ufrpe.br, tiago.espinola@ufrpe.br 2 Undergraduate Program in Analysis and Systems Development (TADS), Federal Institute of Pernambuco (IFPE), Recife, Pernambuco, Brazil. henrique.santos@recife.ifpe.edu.br Abstract Automatic parallelization remains a challenging problem in software engineering, particularly in identifying code regions where loops can be safely executed in parallel on modern multi-core architectures. Traditional static analysis techniques, such as dependence analysis and polyhedral models, often struggle with irregular or dy- namically structured code. In this work, we propose a Transformer-based approach to classify the parallelization potential of source code, focusing on distinguishing independent (parallelizable) loops from undefined ones. We adopt DistilBERT to process source code sequences using subword tokenization, enabling the model to capture contextual syntactic and semantic patterns without handcrafted features. The approach is evaluated on a balanced dataset combining synthetically generated loops and manually annotated real-world code, using 10-fold cross-validation and multiple performance metrics. Results show consistently high performance, with mean accuracy above 99% and low false positive rates, demonstrating robustness and reliability. Compared to prior token-based methods, the proposed approach sim- plifies preprocessing while improving generalization and maintaining computational efficiency. These findings highlight the potential of lightweight Transformer models for practical identification of parallelization opportunities at the loop level. 1 arXiv:2603.30040v1 [cs.SE] 31 Mar 2026 Keywords: Automatic parallelization; Source code analysis; Transformer models; Distil- BERT; Loop independence classification Funding: This work was supported by the Coordination for the Improvement of Higher Education Personnel â Brazil (CAPES) â Finance Code 001 through a masterâs scholarship. Conflict of interest: The authors declare no conflicts of interest. 2 1 Introduction Automatic parallelization remains a key challenge in software engineering and compiler optimization, as it directly impacts application performance on modern multi-core and heterogeneous architectures. Traditional static analysis techniques, such as dependence analysis and polyhedral frameworks, rely on precise code representations including abstract syntax trees (ASTs) and control-flow graphs to determine whether loop iterations can be executed in parallel without conflicts [1,2]. However, these approaches often face limitations when dealing with irregular, non-affine, or highly dynamic code structures, which are common in real-world software systems. Machine learning and deep learning have emerged as promising alternatives for source code analysis by learning latent representations directly from raw code, reducing the need for handcrafted rules and domain-specific heuristics [3]. Early approaches primarily relied on token-level or sequence-based representations combined with shallow classifiers, while more recent methods leverage deep neural architectures capable of capturing richer syntactic and semantic properties of code. These techniques have shown effectiveness across a wide range of software engineering tasks, including code summarization, defect prediction, clone detection, and program classification [4, 5]. More recently, transformer-based models have significantly advanced representation learning for both natural language and source code through self-attention mechanisms that enable the modeling of long-range dependencies within sequences [6]. Pre-trained transformer models such as CodeBERT and GraphCodeBERT adapt this architecture to programming languages by jointly modeling natural language and code tokens, as well as incorporating data-flow information, achieving state-of-the-art performance in tasks such as code search, clone detection, and program classification [7,8]. Furthermore, trans- former architectures have also been explored in contexts directly related to parallelization, demonstrating their potential to classify code regions suitable for OpenMP-based parallel execution [9]. Despite these advances, many existing approaches for detecting parallelizable code still rely on structured representations, such as ASTs or graph-based embeddings, which require complex preprocessing pipelines and substantial domain expertise. Previous work from this research group proposed a lightweight approach based on deep neural networks (DNNs) and convolutional neural networks (CNNs), trained on token sequences generated by a Python preprocessing script, to distinguish independent (parallelizable) loops from dependent ones in synthetic datasets [10]. While the results demonstrated that token-level representations contain relevant information for parallelism classification, the approach required external preprocessing steps and dimensionality reduction techniques such as principal component analysis (PCA), and did not exploit contextual representations of code. 3 In this work, we extend that foundation by leveraging transformer-based contextual representations to improve the automatic classification of parallelization potential in source code. Specifically, we adopt DistilBERT, a distilled and computationally efficient variant of BERT that preserves much of the representational power of larger transformer models while reducing model size and inference cost [11]. DistilBERT produces contextualized embeddings that capture both syntactic patterns and semantic relationships directly from raw code sequences, enabling effective learning without extensive manual feature engineering and making it suitable for scenarios with constrained computational resources when compared to larger code-specific models. To assess the effectiveness of the proposed approach, we constructed a balanced dataset combining synthetically generated loops and manually annotated real-world code samples, and evaluated the model using rigorous 10-fold cross-validation. In addition to overall accuracy, we emphasize metrics such as the false positive rate (FPR), which is particularly relevant in parallelization scenarios where incorrectly classifying dependent code as par- allelizable may lead to unsafe or inefficient execution. The experimental results indicate that the transformer-based model achieves stable and competitive performance across multiple evaluation metrics, while simplifying the preprocessing pipeline and improving generalization when compared to the previous token-based approach. The remainder of this paper is organized as follows: Section 2 reviews related work on parallelization and deep learning for code analysis, Section 3 describes the proposed method, Section 4 presents the experimental evaluation, Section 5 discusses the findings, and Section 6 concludes the paper and outlines directions for future work. 2 Related Works Research on automatic parallelization has traditionally been dominated by compiler-based static analysis techniques. Classical approaches rely on dependence analysis, control-flow analysis, and polyhedral models to determine whether loop iterations can be safely executed in parallel [1,2]. While these methods provide strong theoretical guarantees, they require affine loop bounds and regular memory access patterns, which significantly limits their applicability to real-world programs that exhibit dynamic control flow, pointer aliasing, and irregular data access patterns. To overcome these limitations, machine learning techniques have been increasingly explored for source code analysis. Early work focused on learning from token-level representations or handcrafted features extracted from code, demonstrating that statistical models could capture useful properties related to program behavior [4]. More comprehensive surveys highlight the growing adoption of machine learning and deep learning methods across software engineering tasks, including bug detection, clone detection, and program classification, emphasizing their ability to generalize beyond rigid syntactic rules [3, 5]. 4 The introduction of transformer architectures marked a significant advancement in code representation learning. By leveraging self-attention mechanisms, transformers enable the modeling of long-range dependencies within sequences, which is particularly relevant for source code understanding [6]. Building on this paradigm, models such as CodeBERT and GraphCodeBERT incorporate pre-training on large-scale code corpora and, in some cases, explicit data-flow information, achieving state-of-the-art performance on several downstream tasks, including code search, clone detection, and program classification [7,8]. Despite their effectiveness, these models are typically large and computationally demanding, which may limit their applicability in scenarios with constrained resources. More closely related to this work are studies that apply deep learning techniques to identify parallelizable regions in code. Recent transformer-based approaches, such as PragFormer, have demonstrated the feasibility of using attention-based models to classify code segments according to their suitability for OpenMP parallelization [9]. These methods highlight the potential of learned representations to support parallelization decisions without relying solely on traditional compiler analyses. Prior work from this research group proposed a lightweight deep learning approach based on deep neural networks and convolutional neural networks trained on token sequences generated via Python-based preprocessing scripts [10]. That study demonstrated that even shallow token representations contain sufficient information to distinguish independent from dependent loops. However, the approach required external preprocessing steps and dimensionality reduction techniques, such as principal component analysis, and did not exploit contextual representations capable of modeling long-range dependencies within code. In contrast to existing methods, the present work leverages a distilled transformer model to balance representational power and computational efficiency. By adopting DistilBERT, the proposed approach captures contextual syntactic and semantic information directly from source code while maintaining a lightweight architecture suitable for practical deployment. This positions the method as a complementary alternative to both traditional static analysis techniques and larger transformer-based models, addressing the need for efficient and accurate identification of parallelization opportunities in modern software systems. 3 Methodology This section describes the methodology for developing and evaluating the automatic classification system for parallelization potential in programming codes. The process involves five main stages: (1) database construction, (2) data preparation, (3) model setup and training, (4) experimental evaluation, and (5) computational environment. Figure 1 shows the complete pipeline and the flow of each stage. The process starts with the construction of the dataset using real and synthetic code 5 samples. Next, the data are automatically tokenized and split into training, validation, and test sets. The DistilBERT model is then configured and fine-tuned using the prepared data. Finally, the trained models are evaluated using performance metrics and statistical analyses. Figure 1: Workflow of the proposed methodology. 3.1 Database Construction The database was carefully built from two complementary sources: automatically generated synthetic codes and real-world codes collected from public repositories. 3.1.1 Synthetic Code Generation To ensure diversity and control over the classes of interest, we used two generators based on genetic algorithms, following the methodology established in our previous work [10]. The generators were implemented in Python using the DEAP (Distributed Evolutionary Algorithms in Python) library [12] and produced two distinct types of codes: ⢠Class 1 â Parallelizable: Independent loops where each iteration has no data dependencies with other iterations, allowing parallel execution without conflicts. â˘Class 0 â Undefined: Loops with non-trivial dependencies or whose parallelization analysis requires complex considerations, including cases where parallelization is not possible or cannot be straightforwardly determined. The evolutionary process employed a population of 10,000 individuals over 50 gen- erations, with a crossover rate of 0.9 and a mutation rate of 0.1. The fitness function considered multiple structural aspects of the code, including the number of functions, conditionals, variables, loops, and the guarantee of successful compilation. A total of 8,000 6 synthetic samples were generated, with the distribution between classes determined by the evolutionary process. 3.1.2 Real Code Collection and Annotation To complement the synthetic data and enhance the databaseâs representativeness, we collected 340 real code samples from public GitHub repositories and examples available on the internet. Each real code sample underwent a thorough manual analysis conducted by the authors and was classified using the same criteria defined in Section 3.1.1: ⢠Class 1 â Parallelizable ⢠Class 0 â Undefined This manual analysis ensured the quality of the annotations and the relevance of the examples for the classification task. 3.1.3 Final Database Composition The final database totaled 8,340 examples, consisting of: â˘4,140 parallelizable codes: comprising 4,000 synthetic samples and 170 real samples. â˘4,140 undefined codes: comprising 4,000 synthetic samples and 170 real samples. After balancing the dataset, both classes (Parallelizable and Undefined) are equally represented, ensuring a more uniform learning process and reducing potential bias during training. No resampling techniques were required in the final configuration, as the balanced distribution itself provided a robust foundation for model training. With this updated dataset, the models achieved excellent and stable performance, indicating that the class balance contributed positively to the predictive reliability. This research assumes that the synthetically generated loops cover representative pat- terns of the repetition structures observed in real codes. More complex loop transformationsâ such as fusion, unrolling, or tilingâwere not included, as these variations fall outside the scope of this work. 3.2 Data Preparation Unlike the previous work [10], which relied on an external Python script for automated tokenization and required dimensionality reduction via Principal Component Analysis (PCA) [13,14], the selected Transformer model processes source code directly as text, significantly simplifying the preparation pipeline. 7 3.2.1 Automatic Tokenization We employed the tokenizer from the DistilBERT model [11] to convert source codes into sequences of numerical tokens. The tokenization parameters were configured as follows: ⢠Maximum length: 512 tokens. ⢠Truncation: enabled for exceeding sequences. ⢠Padding: enabled to uniformize sequence length. ⢠Attention masks: automatically generated to distinguish real tokens from padding. This integrated tokenization approach leverages the modelâs pre-trained subword vocabulary, which provides a more natural representation of programming language constructs compared to the traditional Deep Learning models like DNNs and CNNs in our previous work [10]. The subword tokenization effectively captures common programming patterns while maintaining the ability to process unseen tokens through their constituent parts. 3.2.2 Data Splitting To ensure robust evaluation and prevent overfitting, we employed 10-fold cross-validation using the Scikit-learn implementation [15]. For each fold, the data was subdivided as follows: ⢠Training set: 64% of the data. ⢠Validation set: 16% of the data. ⢠Test set: 20% of the data. This partitioning was achieved through a two-step process within each fold: first separating the test set (20%), then dividing the remaining 80% into training (64%) and validation (16%) subsets. This approach maintained consistent class distributions across all splits while preserving the independence of the test set throughout the cross-validation process. 3.3 Model Setup and Training 3.3.1 Model Selection We selected the DistilBERT model, a lighter and more efficient Transformer architecture that maintains advanced contextual understanding capabilities. This choice was based on the following criteria: 8 â˘Computational efficiency: distilled version of BERT, suitable for iterative experi- ments. â˘Context capture: ability to understand complex relationships in structured lan- guage, such as source code. â˘Direct processing: eliminates the need for complex preprocessing and manual feature engineering. â˘Pre-training: leverages linguistic knowledge acquired during pre-training on large corpora. The model was loaded from the Hugging Face Transformers library [16] using the distilbert-base-uncased version. 3.3.2 Architecture and Hyperparameters We configured the model for binary classification with the following specifications: ⢠Number of labels: 2 (Parallelizable, Undefined). ⢠Number of epochs: 50. ⢠Batch size: 16. ⢠Optimizer: AdamW [17]. ⢠Learning rate: 2Ă 10 â5 . ⢠Learning rate scheduler: linear with warmup. ⢠Loss function: Binary Cross-Entropy [18]. ⢠Early stopping: patience of 50 epochs. These hyperparameters were defined after a series of preliminary tests with different configurations, where we explored various parameter combinations. The selected configu- ration proved to be the most suitable for the task, demonstrating stability during training and good generalization performance, with no evidence of overfitting or convergence issues. 3.3.3 Training Process The training was conducted using the Trainer class from the Transformers library, with the following configurations: ⢠Evaluation strategy: every epoch. 9 ⢠Saving strategy: every epoch. ⢠Metric for best model: lowest validation loss. ⢠Loading best model at end: enabled. ⢠Save limit: 1 checkpoint. ⢠Early stopping callback: EarlyStoppingCallback with patience of 50 epochs. For each of the 10 folds, the model was reinitialized and trained from scratch, ensuring independence between executions. The early stopping callback was configured with a patience of 50 epochs, serving as a contingency mechanism while allowing complete training cycles. The best model for each fold was automatically selected based on validation loss and loaded at the end of training. 3.4 Experimental Evaluation 3.4.1 Performance Metrics We evaluated the model using multiple metrics to obtain a comprehensive performance overview: ⢠Accuracy: proportion of correct classifications. ⢠Precision: ability to avoid classifying non-parallelizable loops as parallelizable. ⢠Recall: ability to identify all parallelizable loops. ⢠F1-score: harmonic mean between precision and recall. ⢠Confusion matrix: detailed analysis of classification errors. All metrics were calculated using Scikit-learn functions, with binary averaging for precision, recall, and F1-score. 3.4.2 Evaluation Procedures For each of the 10 folds, we performed the following analyses: ⢠Learning curves: plots of loss and accuracy during training. ⢠Per-class metrics: precision, recall, and F1-score for each class. ⢠Confusion matrices: analysis of error patterns. ⢠Cross-fold comparison: stability and consistency of performance across folds. The evaluation included comprehensive analysis of all 10 trained models, with detailed comparison of training, validation, and test performance for each fold. 10 3.4.3 Statistical Analysis Data analysis was performed through a dedicated Python workflow that integrated spe- cialized libraries for the calculation of descriptive statistics and confidence intervals. For each metricâtraining accuracy, validation accuracy, and test accuracyâwe computed the mean, sample standard deviation, median, and the 95% confidence interval using the Studentâs t-distribution over the sample means [19]. These metrics were obtained from the ten executions corresponding to the ten folds used in the experimental procedure, ensuring consistency with the overall evaluation protocol. To visually characterize the variability of the results, boxplots were generated for all accuracy metrics, including the explicit representation of potential outliers when present. Complementarily, histograms were plotted to examine the distribution shape of the accuracy values across the folds. Beyond accuracy, the analysis also included the mean, standard deviation, median, and 95% confidence intervals for the F1-score, precision, and recall, computed over the ten folds using the same Studentâs t-distribution approach [19]. A detailed analysis of the validation error was also performed across all folds. For each fold, we computed the mean, standard deviation, median, and the 95% confidence interval of the validation loss, measured using the binary cross-entropy function. This evaluation was conducted because the validation error constitutes one of the key criteria used to identify the best and worst-performing modelsâspecifically, the model exhibiting the lowest validation error. In an analogous manner, a comprehensive statistical analysis of the false positive rate (FPR) was conducted across all folds. For this metric, we computed the mean, standard deviation, median, and the 95% confidence interval using the same Studentâs t-distribution procedure applied to the validation error. This analysis enables a robust assessment of the modelâs tendency to incorrectly classify instances from the Undefined class (negative) as Parallelizable (positive), which represents a critical error in the context of automatic parallelization. Following this analysis, we proceed to the identification of the best and worst cases according to the two selection criteria adopted in this study. The first criterion selects the model with the lowest validation error (best case) and the model with the highest validation error (worst case). The second criterion focuses on the modelâs behavior regarding the critical error for our application: the false positive rate (FPR), defined as the proportion of instances from the Undefined class (negative) that are incorrectly predicted as Parallelizable (positive). Under this criterion, the best model is the one that presents a zero or minimal FPR, while the worst model is the one exhibiting the highest FPR. For each selected modelâbest and worst under each criterionâwe present the results 11 in the following order: (1) the training and validation curves, (2) the confusion matrix, and (3) the classification report. This structured evaluation enables a thorough inspection of model behavior under both performance-oriented and application-critical perspectives. 4 Results This section provides a comprehensive analysis of the performance of the DistilBERT model in classifying parallelizable and undefined loops. The results are organized progressively, beginning with an overview of the modelâs average behavior across all folds, followed by a detailed analysis of accuracy. Subsequent subsections present the remaining performance metricsâprecision, recall, and F1-scoreâin a dedicated evaluation. The section also incorporates two independent criteria for selecting representative models: the validation error and the number of false positives. Because these criteria assess different and equally relevant aspects of performance, four models are examined in the best- and worst-case analyses: the model with the lowest validation error and the one with the lowest number of false positives (best cases), as well as the model with the highest validation error and the one with the highest number of false positives (worst cases). The section concludes with a discussion of the results and the modelâs robustness. All evaluations were conducted using 10-fold cross-validation, ensuring statistically robust and reliable analysis. 4.1 Average Model Behavior To assess the average behavior of the DistilBERT model across all cross-validation folds, we analyzed the accuracy distributions for the training, validation, and test sets. Figure 2 presents a boxplot that statistically summarizes these distributions, while Figure 3 shows the corresponding histograms, providing a more detailed visualization of accuracy frequency. The results show that the model achieved high and highly consistent performance across all evaluated sets. The mean training accuracy was approximately 0.99965, indi- cating excellent ability to fit the data. The mean validation accuracy, around 0.99753, demonstrates that the model maintains very high performance even on unseen data, with low variation across folds. The mean test accuracy, equal to 0.99600, reinforces the modelâs robustness and the absence of overfitting, as validation and test performances remain close and at high levels. The small dispersion observed in both the boxplot and histograms highlights the stability of DistilBERT for the proposed task. 4.1.1 Overall Accuracy Performance For a more detailed quantitative analysis of the modelâs performance, Table 1 presents the main consolidated statistical metrics of accuracies obtained in the training, validation, and test sets across the 10 cross-validation folds. 12 Figure 2: Boxplot of training, validation, and test accuracies for the 10 cross-validation folds. Figure 3: Histograms of training, validation, and test accuracies for the 10 folds. Table 1: Statistical metrics for training, validation, and test accuracies across the 10 cross-validation folds. SetMean Std. Dev. Median95% CI Training 0.99965 0.000300.99983 0.99944â0.99986 Validation 0.99753 0.001090.99784 0.99675â0.99831 Test0.99600 0.002610.99650 0.99413â0.99787 13 The results demonstrate exceptionally high and consistent performance across all sets. The mean training accuracy of 99.96% confirms the modelâs ability to effectively learn the patterns present in the data. The mean validation (99.75%) and test (99.60%) accuracies show excellent generalization capability, maintaining very close and high-level results. The analysis of the standard deviation reveals low variability across folds, reinforcing the modelâs stability. The training set exhibited the lowest variability (SD = 0.00030), followed by validation (SD = 0.00109) and test (SD = 0.00261). The proximity between means and medians indicates balanced distributions with no relevant skewness. The 95% confidence intervals, calculated using Studentâst-test, provide a robust estimate of mean precision. For the test set, for example, we can state with 95% confidence that the mean accuracy lies between 99.41% and 99.78%. For validation, the interval ranges between 99.67% and 99.83%. These narrow intervals further reinforce the strong statistical reliability of the results. The combination of high mean accuracies, low variability, and narrow confidence intervals confirms the robustness of DistilBERT for the classification task, showing that the model consistently maintains its performance when exposed to new data. 4.1.2 Performance on Precision, Recall, and F1-Score To complement the analysis of the modelâs performance, we evaluated the precision, recall, and F1-Score metrics on the test set. Figure 4 presents the distribution of these metrics using boxplots, while Figure 5 shows the corresponding histograms, allowing for a detailed visual analysis of the behavior of the three metrics across the 10 cross-validation folds. Figure 4: Boxplots of precision, recall, and F1-Score metrics across the 10 cross-validation folds. The visualizations show that all metrics maintain consistently high values, with most observations concentrated above 0.990. Recall exhibits a slightly more compact distribution, 14 Figure 5: Histograms of precision, recall, and F1-Score metrics across the 10 cross-validation folds. indicating stable performance in correctly identifying positive examples. Precision, although exhibiting slightly greater variation across folds, remains consistently high in all cases. The F1-Score, as a balanced metric between precision and recall, reflects an intermediate behavior while maintaining high stability across the folds. For a more detailed quantitative analysis, Table 2 presents the consolidated statistics for the three metrics: Table 2: Statistical metrics for Precision, Recall, and F1-Score on the test set. Metric Mean Std. Dev. Median 95% CI Precision 0.99710.00260.9976 0.9953â0.9989 Recall0.99490.00380.9952 0.9922â0.9976 F1-Score 0.99600.00260.9970 0.9941â0.9979 The numerical results confirm the visual observations from the figures. Precision exhibits the highest mean among the metrics (99.71%) with low variability (SD = 0.0026), indicating stability in the modelâs ability to avoid false positives. Recall, with a mean of 99.49%, also demonstrates strong performance in identifying true positives, although with slightly higher variability (SD = 0.0038). The F1-Score, with a mean of 99.60%, reflects an appropriate balance between the two previous metrics, capturing both the modelâs ability to correctly identify positive examples and its ability to minimize classification errors. The 95% confidence intervals, computed using Studentâst-test, reinforce the reliability of the results: for the F1-Score, the population mean lies between 99.41% and 99.79%; for recall, between 99.22% and 99.76%; and for precision, between 99.53% and 99.89%. The proximity between means and medians across all metrics indicates symmetrical and consistent distributions across the folds, corroborating the modelâs stability. 15 The high and consistent performance observed across all evaluated metricsâprecision, recall, and F1-Scoreâconfirms the effectiveness of the DistilBERT model for the loop classification task. The results demonstrate not only high overall accuracy but also a proper balance between the ability to correctly identify positive examples and avoid false positives, reinforcing the robustness of the model. 4.2 Analysis of the Validation Error as a Selection Criterion The criterion used to select the best model in each fold was based on the lowest validation error, employing the Binary Cross-Entropy function as the evaluation metric during training. This approach makes it possible to identify the points of best model generalization, avoiding overfitting and ensuring that performance is preserved on unseen data. Figure 6 presents the distribution of the validation error through a boxplot, while Figure 7 shows the corresponding histogram, allowing a detailed visual inspection of the error behavior across the 10 folds. Figure 6: Boxplot of the validation error (Binary Cross-Entropy) for the 10 folds. The visualizations show that the validation error exhibits consistently low values, ranging approximately from 0.007 to 0.040. The boxplot reveals a compact distribution, with most values concentrated in the lower range, indicating good stability across the folds. The histogram reveals an asymmetric distribution with higher density in the lowest error values, which is desirable for an error metric. For a more detailed quantitative analysis, Table 3 presents the consolidated statistics of the validation error: The numerical results confirm the visual observations. The mean validation error of 0.01772, combined with the median of 0.01512, indicates that most folds exhibit very low error values, with a few slightly higher values pulling the mean upwardâas reflected by 16 Figure 7: Histogram of the validation error (Binary Cross-Entropy) for the 10 folds. Table 3: Statistical metrics of the validation error (Binary Cross-Entropy). MetricMean Std. Dev. Median95% CI Validation Error 0.01772 0.009650.01512 0.01081â0.02462 the maximum of approximately 0.040. The standard deviation of 0.00965 reveals moderate variability, also reflected in the extent of the whiskers in the boxplot. The 95% confidence interval, estimated between 0.01081 and 0.02462, shows that the population mean validation error is concentrated within a narrow range, reinforcing the stability of the validation process. The combination of low absolute error values and the consistency observed across the folds validates the effectiveness of the selection criterion based on the lowest validation error, demonstrating that this approach is suitable for identifying models with strong generalization capability in the proposed classification task. 4.3 False Positive Rate (FPR) Analysis In addition to using the validation error as the selection criterion for the best-performing model, we also conducted a detailed analysis of the False Positive Rate (FPR) across all folds of the cross-validation. The FPR represents the proportion of negative instances incorrectly classified as positive, which is particularly relevant in software defect prediction tasks. A high FPR would lead to false alarms, unnecessarily increasing the inspection effort and causing inefficient allocation of maintenance resources. Therefore, examining the statistical behavior of this metric provides further insight into the reliability and robustness of the model. Figure 8 presents the boxplot of the FPR values. The distribution is highly concentrated near zero, reflecting that the model rarely produces false alarms. Only a few folds exhibit 17 Figure 8: Boxplot of the False Positive Rate (FPR) across the 10-fold cross-validation. Figure 9: Histogram of the False Positive Rate (FPR) across the 10-fold cross-validation. 18 small non-zero values, and even in these cases, the rate remains extremely low. Figure 9 shows the corresponding histogram, reinforcing the observation that most folds lie within the lowest bins of the distribution. Table 4: Statistical metrics for the False Positive Rate (FPR) across the 10-fold cross- validation. Metric Mean Std. Dev. Median95% CI FPR0.002872 0.002439 0.002418 0.001197â0.004546 Table 4 summarizes the descriptive statistics for the FPR across the 10 folds. The mean FPR is 0.002872, and the median (0.002418) is of the same magnitude, indicating consistent behavior among the folds. The standard deviation is low, demonstrating limited variability, and the 95% confidence interval (0.001197â0.004546) remains tightly bounded, further confirming the stability of the model regarding false positive generation. 4.4 Analysis of the Best-Performing Models Based on the two selection criteria previously discussedâthe lowest validation error and the lowest critical error (False Positive Rate)âthis section presents a detailed analysis of the best-performing models identified during the 10-fold cross-validation process. For each criterion, the selected model is analyzed through its training dynamics, confusion matrix, and classification metrics, providing a comprehensive evaluation of its performance and reliability. 4.4.1 Best Model According to the Lowest Validation Error Among the ten folds evaluated, Fold 7 achieved the lowest validation error, making it the best-performing model according to the validation loss criterion. This result indicates superior generalization capability, as the model minimizes the Binary Cross-Entropy loss on unseen validation data. Figure 10 presents the training and validation loss curves, along with the corresponding accuracy curves. The training loss rapidly converges toward zero, while the validation loss stabilizes at a low value, showing no signs of divergence or instability. Additionally, the training accuracy reaches 100%, and the validation accuracy remains consistently high throughout the training process, indicating a well-fitted model without evidence of overfitting. The classification performance of Fold 7 is summarized by the confusion matrix presented in Table 5. The results show that the model correctly classified almost all instances, with only a minimal number of misclassifications. Quantitatively, Fold 7 achieved 417 true positives (TP), 414 true negatives (TN), only 2 false negatives (FN), and 1 false positive (FP). Table 6 presents the corresponding 19 Figure 10: Training and validation loss and accuracy curves for Fold 7. Table 5: Confusion matrix for Fold 7. Actual / Predicted Undefined Independent Undefined4141 Independent2417 classification metrics. The model achieved a recall of 0.9952, precision of 0.9976, and an F1-score of 0.9964, demonstrating an excellent balance between sensitivity and precision. Table 6: Classification report for Fold 7. MetricPrecision Recall F1-score Independent Class 0.99760.9952 0.9964 4.4.2 Best Model According to the Lowest Critical Error Considering the False Positive Rate (FPR) as the critical error criterion, Fold 8 emerged as the best-performing model. This fold achieved the lowest FPR among all evaluated models, which is particularly relevant for the proposed task, as false positives may lead to unnecessary inspections and inefficient allocation of maintenance resources. Figure 11 presents the training and validation curves for Fold 8. The training process shows fast convergence, with training loss approaching zero and validation loss stabilizing at a low level. The training accuracy reaches 100%, while the validation accuracy remains consistently high, indicating stable learning behavior and strong generalization. The confusion matrix for Fold 8 is presented in Table 7. Notably, this model produced no false positives, which directly explains its selection under the critical error criterion. From a quantitative perspective, Fold 8 achieved 414 true positives (TP), 419 true negatives (TN), 1 false negative (FN), and zero false positives (FP). Table 8 summarizes the classification metrics. The model attained a recall of 0.9976, perfect precision of 1.0000, 20 Figure 11: Training and validation loss and accuracy curves for Fold 8. Table 7: Confusion matrix for Fold 8. Actual / Predicted Undefined Independent Undefined4190 Independent1414 and an F1-score of 0.9988, highlighting its robustness in minimizing critical classification errors. Table 8: Classification report for Fold 8. MetricPrecision Recall F1-score Independent Class 1.00000.9976 0.9988 Overall, the analysis of both selected models demonstrates that the proposed approach is capable of producing highly accurate and reliable classifiers under different optimization criteria. While Fold 7 excels in terms of overall generalization as indicated by the lowest validation error, Fold 8 provides superior performance in minimizing critical errors, offering a complementary perspective for model selection depending on application-specific requirements. 4.5 Analysis of the Worst-Performing Models Although the proposed approach demonstrated highly stable performance across all folds, an analysis of the worst-performing cases provides additional insight into the lower bounds of the method under different selection criteria. Using the same criteria adopted for the best-performing modelsâhighest validation error and highest critical error (False Positive Rate)âthis section discusses the least favorable scenarios observed during the cross-validation process. 21 4.5.1 Worst Model According to the Highest Validation Error With respect to validation loss, Fold 8 presented the highest validation error among all evaluated folds. This behavior indicates comparatively weaker generalization performance according to the Binary Cross-Entropy objective. It is important to note that Fold 8 was previously analyzed in detail in Section 4.4.2, where it was identified as the best-performing model under the critical error criterion. Therefore, its training dynamics, confusion matrix, and classification report are not repeated here to avoid redundancy. From a quantitative perspective, Fold 8 achieved 414 true positives (TP), 419 true negatives (TN), 1 false negative (FN), and no false positives (FP). Despite exhibiting the highest validation loss, the model maintains excellent classification performance, with a recall of 0.9976, perfect precision of 1.0000, and an F1-score of 0.9988. These results highlight a clear trade-off between optimization objectives, where minimizing validation error and minimizing critical errors may lead to different model selections. 4.5.2 Worst Model According to the Highest Critical Error Considering the False Positive Rate as the critical error criterion, Fold 2 was identified as the worst-performing model, presenting the highest number of false positives among all folds. Although the absolute number of critical errors remains limited, this fold represents the least favorable case in scenarios where false alarms must be strictly minimized. Figure 12 illustrates the training and validation loss and accuracy curves for Fold 2. The training loss rapidly converges toward zero, while the validation loss stabilizes without signs of divergence. Both training and validation accuracy remain high throughout the training process, indicating stable learning behavior despite the increased critical error. Figure 12: Training and validation loss and accuracy curves for Fold 2 (worst critical error). Table 9 presents the confusion matrix for Fold 2. The presence of three false positives 22 directly explains its selection as the worst case under the critical error criterion. Table 9: Confusion matrix for Fold 2 (worst critical error). Actual / Predicted Undefined Independent Undefined4323 Independent5394 Table 10 summarizes the classification metrics for Fold 2. While precision, recall, and F1-score remain above 0.98, this fold exhibits the highest False Positive Rate among the evaluated models, characterizing it as the least favorable case under the critical error perspective. Table 10: Classification report for Fold 2 (worst critical error). MetricPrecision Recall F1-score Independent 0.99240.9875 0.9899 Undefined0.98860.9931 0.9908 Overall, this analysis confirms that even the worst-performing models maintain high predictive performance. The observed variations mainly reflect trade-offs between opti- mization criteria rather than instability or poor generalization, reinforcing the robustness of the proposed approach. 5 Discussion The experimental results demonstrate that the proposed DistilBERT-based approach achieves consistently high performance in the task of classifying parallelization potential in source code. Across the 10-fold cross-validation, the model exhibited high accuracy on training, validation, and test sets, with narrow confidence intervals and low variability. The proximity between validation and test accuracies indicates that the model generalizes well to unseen data, with no evidence of overfitting, despite the high capacity of the Transformer architecture. Beyond overall accuracy, the analysis of precision, recall, and F1-score confirms that the model maintains a balanced classification behavior. Precision remains consistently high across folds, indicating strong control over false positives, while recall values also remain above 99% on average, demonstrating effective identification of parallelizable loops. The resulting F1-scores reflect this balance, reinforcing the robustness of the classifier and its suitability for tasks where both correct detection and error minimization are critical. The validation error analysis further supports the stability of the training process. The Binary Cross-Entropy loss exhibits low absolute values and a compact distribution 23 across folds, confirming that the optimization procedure converges reliably. However, the comparison between validation error and application-critical metrics reveals an important trade-off: the model with the lowest validation loss is not necessarily the one that minimizes false positives. This finding highlights the relevance of considering multiple evaluation criteria when selecting models for practical deployment. The False Positive Rate analysis provides additional insight into the modelâs reliability from an application-oriented perspective. The very low average FPR observed across all folds indicates that the model rarely misclassifies undefined loops as parallelizable. Notably, one fold achieved zero false positives, demonstrating that the proposed approach is capable of completely eliminating this critical error under certain conditions. This behavior is particularly relevant in scenarios where incorrect parallelization decisions may lead to unsafe or inefficient execution. Finally, the examination of best- and worst-performing cases shows that performance variations are limited and primarily reflect trade-offs between optimization objectives rather than instability. Even the least favorable models maintain high accuracy and F1-scores, confirming the robustness of the approach. Overall, the results indicate that the proposed method effectively leverages Transformer-based representations for source code analysis, providing accurate, stable, and reliable classification within the defined scope of the study. 6 Conclusion This work presented a Transformer-based approach for the automatic classification of parallelization potential in source code, focusing on the identification of independent loops that can be safely parallelized. The proposed methodology combines a carefully constructed and balanced datasetâcomposed of synthetic codes generated via evolutionary algorithms and manually annotated real-world examplesâwith a fine-tuned DistilBERT model capable of processing source code directly as text. The experimental evaluation was conducted using a rigorous 10-fold cross-validation protocol and a comprehensive set of performance metrics. The results demonstrate that the proposed approach achieves consistently high per- formance across all folds, with strong generalization capability and low variability. High accuracy, precision, recall, and F1-score values were observed on the test sets, indicating that the model effectively distinguishes between parallelizable and undefined loop struc- tures. The statistical analysis, including confidence intervals and distribution visualizations, further confirms the stability and robustness of the learned models. Beyond overall performance, the study highlighted the importance of considering application-specific evaluation criteria. While validation error proved effective for identify- ing models with strong generalization behavior, the analysis of the False Positive Rate 24 revealed complementary insights, particularly for scenarios where incorrect classification of non-parallelizable code as parallelizable may lead to undesirable consequences. The ability of the proposed approach to achieve extremely lowâand in some cases zeroâfalse positives reinforces its suitability for practical code analysis contexts. Despite these promising results, some limitations should be acknowledged. The scope of this study is restricted to loop-level analysis and does not account for more advanced loop transformations, such as fusion, unrolling, or tiling. In addition, although the inclusion of real-world code samples enhances representativeness, the dataset remains limited to a specific set of programming patterns and languages. Future work will focus on extending the analysis to more complex code structures and transformations, expanding the dataset with additional real-world examples, and exploring the integration of the proposed classifier into static analysis tools or development environments. Investigating alternative Transformer architectures and multilingual code representations also represents a promising direction for further research. Overall, the results indicate that Transformer-based models constitute a viable and effective solution for automatic parallelization potential classification, offering a robust and scalable foundation for supporting parallel programming analysis within the defined scope of this study. Acknowledgments This work was supported by the Coordination for the Improvement of Higher Education Personnel â Brazil (CAPES) â Finance Code 001 through a masterâs scholarship. The authors acknowledge the institutional support from the Federal Rural University of Pernambuco (UFRPE) and the Graduate Program in Applied Informatics (PPGIA). We also thank the IFROG research group for their valuable collaboration. Author Contributions Izavan dos Santos Correia: conceptualization, methodology, software, validation, formal analysis, investigation, writing original draft, writing review and editing. Henrique Correia Torres Santos: supervision, review and editing. Tiago Alessandro EspĂnola Ferreira: supervision, review and editing. Data Availability The datasets used and/or analyzed during the current study are available from the corresponding author upon reasonable request. 25 Code Availability The code used for experiments in this study is available from the corresponding author upon reasonable request. References [1]Oleksandr Zinenko. Dependence analysis. Encyclopedia of Parallel Computing, 2018. [2]Louis-NoĂŤl Pouchet, CĂŠdric Bastoul, Albert Cohen, and Nicolas Vasilache. Itera- tive optimization in the polyhedral model: Part i, one-dimensional time. IEEE Transactions on Parallel and Distributed Systems, 22(1):137â150, 2011. [3]Miltiadis Allamanis, Earl T. Barr, Christian Bird, and Charles Sutton. A survey of machine learning for big code and naturalness. ACM Computing Surveys, 51(4):1â37, 2018. [4]Miltiadis Allamanis, Hao Peng, and Charles Sutton. A convolutional attention network for extreme summarization of source code. In International Conference on Machine Learning, 2016. [5] Martin White, Michele Tufano, Christopher Vendome, and Denys Poshyvanyk. Deep learning code fragments for code clone detection. In Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering, 2016. [6]Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Ĺukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, volume 30, 2017. [7]Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, et al. Codebert: A pre-trained model for programming and natural languages. arXiv preprint arXiv:2002.08155, 2020. [8] Daya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng, et al. Graphcodebert: Pre-training code representations with data flow. arXiv preprint arXiv:2009.08366, 2020. [9] Le Chen, Quazi Ishtiaque Mahmud, et al. Pragformer: Data-driven parallel source code classification with transformers. International Journal of Parallel Programming, 2024. doi: 10.1007/s10766-024-00778-9. [10] Izavan dos S. Correia, Henrique C. T. Santos, and Tiago A. E. Ferreira. Discovering software parallelization points using deep neural networks. arXiv preprint, September 2025. URL https://arxiv.org/abs/2509.16215. Submitted for publication. 26 [11]Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. DistilBERT, a distilled version of BERT: Smaller, faster, cheaper and lighter. In NeurIPS 2019 Workshop on Energy Efficient Machine Learning and Cognitive Computing, Vancouver, Canada, December 2019. URL https://arxiv.org/abs/1910.01108. [12]FĂŠlix-Antoine Fortin, François-Michel De Rainville, Marc-AndrĂŠ Gardner, Marc Parizeau, and Christian GagnĂŠ. DEAP: Evolutionary algorithms made easy. Journal of Machine Learning Research, 13:2171â2175, 2012. ISSN 1533-7928. URLhttps: //jmlr.org/papers/v13/fortin12a.html. [13]Karl Pearson. Liii. on lines and planes of closest fit to systems of points in space. The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science, 2(11):559â572, 1901. doi: 10.1080/14786440109462720. [14]Vincent Gray. Principal Component Analysis: Methods, Applications, and Technology. Mathematics Research Developments Series. Nova Science Publishers, New York, NY, USA, 2017. ISBN 978-1-53610-889-7. [15] Fabian Pedregosa, GaĂŤl Varoquaux, Alexandre Gramfort, Vincent Michel, Bertrand Thirion, Olivier Grisel, Mathieu Blondel, Peter Prettenhofer, Ron Weiss, Vincent Dubourg, Jake Vanderplas, Alexandre Passos, David Cournapeau, Matthieu Brucher, Matthieu Perrot, and Ădouard Duchesnay. Scikit-learn: Machine learning in Python. Journal of Machine Learning Research, 12:2825â2830, 2011. ISSN 1533-7928. URL http://jmlr.org/papers/v12/pedregosa11a.html. [16]Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, RĂŠmi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 38â45, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-demos.6. URLhttps://aclanthology. org/2020.emnlp-demos.6. [17] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. Interna- tional Conference on Learning Representations, 2019. URLhttps://openreview. net/forum?id=Bkg6RiCqY7. Version published at ICLR 2019. [18]Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep Learning. MIT Press, Cambridge, MA, USA, 2016. ISBN 9780262035613. URLhttps://w. deeplearningbook.org/. 27 [19]William Sealy Gosset. The probable error of a mean. Biometrika, 6(1):1â25, 1908. doi: 10.1093/biomet/6.1.1. URLhttps://w.jstor.org/stable/2331554. Published under the pseudonym "Student". 28