Seedlabs
Source research

An Empirical Evaluation of LLM-Based Approaches for Code Vulnerability Detection: RAG, SFT, and Dual-Agent Systems

Md Hasan Saju, Maher Muhtadi, Akramul Azim · 2025 · 6 citationsRead the paper

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 [1] and real-world code repositories from GitHub, focusing on five critical Common Weakness Enumeration (CWE) categories: CWE-119, CWE399, 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.

What the full text shows

Working prototype
  • RAG approach achieved the highest overall accuracy and F1 score. — 0.86 accuracy, 0.85 F1 score (Evaluated on a curated dataset of five CWE categories (CWE-119, CWE-399, CWE-264, CWE-20, CWE-200))
  • SFT approach using QLoRA adapters demonstrated strong performance. (Trained on 5,000 data instances using parameter-efficient fine-tuning)
  • Dual-Agent system improved reasoning transparency and error mitigation. — reduced resource overhead (Architecture consisting of a detector agent and a validator agent)
Setup
Dataset of 6,000 total instances (5,000 for fine-tuning, 1,000 for testing) sourced from BigVul and proprietary GitHub repositories, balanced across five CWE categories.
How
The study compared four LLM configurations: a baseline model, RAG (using a Chroma vector store and MITRE CWE database), SFT (using QLoRA adapters), and a Dual-Agent system (detector and validator agents). Performance was measured by analyzing code changes (before/after) and commit messages to determine if a vulnerability was mitigated.

Summarized by Gemma 4 from the open-access full text · 22 Nov 2026. Read it