H-LLM-IM: An Adaptive Imbalance-Aware Hybrid Framework Using LLM-Based Code Embeddings for Software Vulnerability Detection
Abstract
Software vulnerabilities remain a critical threat to modern software systems, while existing detection approaches often suffer from high computational cost, limited scalability, and severe class imbalance in real-world datasets. To address these challenges, this study proposes H-LLM-IM, an adaptive imbalance-aware hybrid framework for efficient software vulnerability detection. The proposed framework leverages semantic code embeddings extracted from a pre-trained code language model (CodeBERT) and integrates them with lightweight machine learning classifiers, thereby avoiding expensive fine-tuning of large language models.A key contribution of H-LLM-IM is an adaptive imbalance-aware learning mechanism that dynamically regulates imbalance mitigation intensity through controlled oversampling and adaptive reweighting based on minority-class performance feedback. Extensive experiments conducted on the Big-Vul benchmark dataset evaluate four classifiers (Logistic Regression, SVM, Random Forest, and XGBoost) under multiple imbalance-handling scenarios, including static and adaptive strategies.The results demonstrate that the proposed adaptive framework substantially improves minority-class vulnerability detection, achieving up to a 2.5-fold increase in F1-score and up to 83% improvement in MCC compared to the no-imbalance baseline. Importantly, these performance gains are obtained while maintaining practical training time and controlled memory growth. In particular, Logistic Regression and XGBoost exhibit the most favorable performance–efficiency trade-off, highlighting the scalability and practical applicability of H-LLM-IM for large-scale vulnerability analysis under severe class imbalance.