[Paper Review] An Empirical Evaluation of LLM-Based Approaches for Code Vulnerability Detection: RAG, SFT, and Dual-Agent Systems
The paper compares RAG, SFT (QLoRA adapters), and a Dual-Agent LLM system against a baseline LLM for code vulnerability detection across five CWEs, finding RAG achieves the highest overall performance.
The rapid advancement of Large Language Models (LLMs) presents new opportunities for automated software vulnerability detection, a crucial task in securing modern codebases. This paper presents a comparative study on the effectiveness of LLM-based techniques for detecting software vulnerabilities. The study evaluates three approaches, Retrieval-Augmented Generation (RAG), Supervised Fine-Tuning (SFT), and a Dual-Agent LLM framework, against a baseline LLM model. A curated dataset was compiled from Big-Vul and real-world code repositories from GitHub, focusing on five critical Common Weakness Enumeration (CWE) categories: CWE-119, CWE-399, CWE-264, CWE-20, and CWE-200. Our RAG approach, which integrated external domain knowledge from the internet and the MITRE CWE database, achieved the highest overall accuracy (0.86) and F1 score (0.85), highlighting the value of contextual augmentation. Our SFT approach, implemented using parameter-efficient QLoRA adapters, also demonstrated strong performance. Our Dual-Agent system, an architecture in which a secondary agent audits and refines the output of the first, showed promise in improving reasoning transparency and error mitigation, with reduced resource overhead. These results emphasize that incorporating a domain expertise mechanism significantly strengthens the practical applicability of LLMs in real-world vulnerability detection tasks.
Motivation & Objective
- Motivate improved vulnerability detection in code using LLM-based methods.
- Curate a balanced vulnerability dataset from BigVul and enterprise repositories to enable robust evaluation.
- Compare RAG, SFT (QLoRA adapters), and a Dual-Agent architecture against a base model.
- Analyze performance and statistical significance to guide method selection for practical vulnerability detection.
Proposed method
- Use a balanced dataset with 5000 training and 1000 test instances across five CWE categories from BigVul and GlassHouse repositories.
- Evaluate three LLM-based approaches: Retrieval-Augmented Generation (RAG), Supervised Fine-Tuning (SFT) with QLoRA adapters, and a Dual-Agent LLM system with detector and validator agents.
- Implement a base LLM model (LLaMA 3.2-3B) as a baseline for comparison.
- In RAG, augment the LLM with external domain knowledge from MITRE CWE data and perform chunked text processing with embeddings stored in Chroma.
- In SFT, fine-tune with an instruction-input-output format using 30k steps-equivalent settings and 8-bit AdamW optimization.
- In Dual-Agent, have a detector agent produce initial vulnerability judgments and a validator agent review and correct reasoning.

Experimental results
Research questions
- RQ1How do RAG, SFT, and Dual-Agent LLM approaches compare to a baseline LLM in detecting code vulnerabilities across multiple CWE categories?
- RQ2What is the impact of domain knowledge augmentation and parameter-efficient fine-tuning on detection performance?
- RQ3Can a Dual-Agent architecture improve reasoning transparency and reduce errors without excessive resource overhead?
Key findings
- RAG achieves the highest overall performance with an average F1 score of 0.85 and accuracy of 0.86 across all CWE categories.
- RAG’s performance per CWE includes: CWE-119 (F1 0.80), CWE-399 (F1 0.89), CWE-264 (F1 0.84), CWE-20 (F1 0.86), CWE-200 (F1 0.89).
- SFT attains an average F1 score of 0.80 and accuracy of 0.81, with CWE-wise F1 ranging from 0.73 to 0.84.
- Dual-Agent LLM achieves an average F1 score of 0.77 and accuracy of 0.78, with CWE-wise F1 ranging from 0.73 to 0.86.
- Base model (no augmentation) yields an average F1 score of 0.67 and accuracy of 0.65.
- Statistical tests (paired t-tests) show all three techniques significantly outperform the base model, with RAG: t(4)=5.97, p=0.0042; SFT: t(4)=3.75, p=0.0195; Dual-Agent: t(4)=2.89, p=0.0440.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.