# ParaVul: A Parallel Large Language Model and Retrieval-Augmented Framework for Smart Contract Vulnerability Detection

Crypto.world

> Smart contracts automate blockchain services, but bugs in them are irreversible once deployed, and traditional static analysis, dynamic analysis, and formal verification are inefficient, poorly…

**arXiv**: 2510.17919

**Published**: 2025-10-20

**Authors**: Tenghui Huang, Jinbo Wen, Jiawen Kang, Siyong Chen, Zhengtao Li, Tao Zhang, Dongning Liu, Jiacheng Wang, Chengjun Cai, Yinqiu Liu, Dusit Niyato

## AI summary

## Overview

- **Research area:** Blockchain security / smart contract vulnerability detection, combining large language models (LLMs), retrieval-augmented generation (RAG), and parameter-efficient fine-tuning.
- **Technical level:** Advanced — assumes familiarity with LoRA/QLoRA fine-tuning, dense vector retrieval, BM25 lexical retrieval, and meta-learning.
- **Scope (1 sentence):** The paper proposes ParaVul, a framework that runs a fine-tuned LLM detector and a hybrid dense-plus-BM25 RAG detector in parallel, fuses their outputs with a meta-learning verification module, and then uses chain-of-thought prompting to generate structured vulnerability reports.

## What This Paper Is About

Smart contracts automate blockchain services, but bugs in them are irreversible once deployed, and traditional static analysis, dynamic analysis, and formal verification are inefficient, poorly generalizable, and prone to high false-positive rates. LLM-based detectors help with semantic understanding but are expensive to fine-tune and prone to hallucination, while RAG-based detectors still produce many false positives. ParaVul aims to raise detection reliability and accuracy while lowering the computational cost of LLM fine-tuning, by combining a sparsified LoRA adapter, a two-strategy retrieval system, and a learned fusion of both detectors.

## Key Contributions

1. **ParaVul framework:** A parallel detection architecture that runs LLM-based detection and RAG-based detection simultaneously on preprocessed smart contract code (standardized into a unified JSON format with binary vulnerability-label vectors), plus a designed vulnerability report template to help users understand findings and remediation.
2. **SLoRA (Sparse Low-Rank Adaptation):** Built on QLoRA, it adds a trainable sparse matrix with a top-*k* binary mask alongside a standard low-rank adapter, freezes the quantized backbone, and trains only adapter parameters — reducing fine-tuning cost while improving vulnerability understanding.
3. **Hybrid RAG system:** A constructed vulnerability contract dataset plus a retrieval system that combines dense retrieval (sliding-window segmented embeddings, cosine similarity, dynamic voting) with BM25 lexical retrieval, providing auxiliary verification of the LLM's output to mitigate hallucination.
4. **Meta-learning verification module:** A two-hidden-layer MLP meta-learner that takes the three base model outputs (dense retrieval, BM25, SLoRA), applies learned feature weights, and produces the final label prediction; reported to improve F1 by at least 4% over LLMs and 12% over RAG.

## Main Findings

- **Single-label detection F1:** ParaVul achieves an F1 score of **0.9398**.
- **Multi-label detection F1:** ParaVul achieves an F1 score of **0.9330**.
- **Verification module gain:** The meta-learning fusion improves F1 by at least **4%** over LLM-only detection and at least **12%** over RAG-only detection.
- **Computational cost reduction:** SLoRA's overall complexity is **O(n(dr + k))**, far below the full-rank update cost of **O(nd²)**, because only the low-rank matrices and the sparse matrix are updated while the quantized weights stay frozen (∂L/∂W_q = 0).
- **Retrieval design settings:** Dense retrieval uses a 1500-character window with 300-character overlap (about 20% of the window), discards fragments shorter than 100 characters, and applies a dynamic voting threshold of max(N* × 0.4, 1). The fusion module combines Ψ = 3 base models.
- **Report structure:** Reports contain five elements — location and manifestation, root causes, security risks, potential impact, and mitigation strategies.

## Methodology in Plain English

The pipeline has four stages. First, contract source code is cleaned (comments and noise removed, semantics preserved), standardized into JSON, and labeled with a binary vector marking which vulnerability types are present. Second, two detectors run in parallel: a locally deployed LLM fine-tuned with SLoRA, and a locally deployed hybrid RAG system that searches a knowledge base of vulnerable contracts two ways — BM25 keyword matching for explicit code-level issues, and dense embedding similarity for deeper semantic and logical patterns. Each retrieved fragment "votes" for the vulnerability labels of its source contract, and a label is kept only if its votes exceed an adaptive threshold.

Third, a meta-learning verification module combines the three base outputs (dense retrieval, BM25, SLoRA) into a weighted feature vector and passes it through an MLP trained with binary cross-entropy loss, producing the final detection result. Because the meta-learner learns which detector to trust, it adapts quickly to new detection tasks. Fourth, verified findings go to a cloud LLM via API, guided by chain-of-thought prompts and a report template, to generate an auditor-friendly vulnerability report. Notably, the paper's experimental section (dataset statistics, baseline comparisons, ablations, hardware) is not included in the provided content, so those details are not reported here.

## Why This Matters

- **Research impact:** It reframes smart contract vulnerability detection as an ensemble problem — pairing a semantically strong but hallucination-prone LLM with evidence-grounded retrieval — and shows that sparsifying LoRA adapters can cut cost without sacrificing accuracy, which is relevant to the broader efficient-fine-tuning literature.
- **DeFi and exchange security teams:** Pre-deployment auditing of contracts where a missed reentrancy or locked-funds bug means direct, irreversible financial loss.
- **Blockchain platforms and auditors:** The five-part CoT report (location, root cause, risk, impact, mitigation) turns a binary label into actionable remediation guidance.
- **Resource-constrained security teams:** Local deployment of the LLM, RAG system, and verifier, with cloud LLMs reserved only for report writing, lowers the barrier for smaller firms.
- **Industry relevance:** As Web3 and decentralized finance grow, automated, scalable, low-false-positive auditing becomes a compliance and insurance requirement; ParaVul's plug-in verification module is also a general pattern for combining any set of detectors.

## Future Directions

- **Evaluate beyond the reported F1 numbers:** Full benchmark comparisons against traditional static analyzers, prior LLM-based tools, and RAG-only baselines — including precision, recall, and latency — are needed to substantiate the claimed gains.
- **Dataset generalization:** The vulnerability dataset is self-constructed; testing on contracts from other chains and on newly emerging vulnerability types would test the claimed adaptability of the meta-learner.
- **Reducing cloud dependency:** Report generation still relies on API calls to a cloud LLM, which raises code-confidentiality concerns; a fully local reporting path is an open design question.
- **Sparsity and threshold sensitivity:** How the sparsity level α, the retained top-*k* count, and the 40% dynamic voting threshold trade off against accuracy is a natural ablation target.

## Target Audience

Blockchain security researchers and auditors, applied NLP researchers working on code-oriented LLMs and RAG, and practitioners building automated smart contract auditing tools who want a concrete architecture for combining fine-tuned LLMs with retrieval-based verification.

## Authors’ abstract

Smart contracts play a significant role in automating blockchain services. Nevertheless, vulnerabilities in smart contracts pose serious threats to blockchain security. Currently, traditional detection methods primarily rely on static analysis and formal verification, which can result in high false-positive rates and poor scalability. Large Language Models (LLMs) have recently made significant progress in smart contract vulnerability detection. However, they still face…

[The full abstract on arXiv](https://arxiv.org/abs/2510.17919)

[Read the original paper](https://arxiv.org/abs/2510.17919)

---

Canonical: https://crypto.world/paper/paravul-a-parallel-large-language-model-and-retrieval-augmented-2510.17919
