
The code in "DCVD: Dual-Channel Cross-Modal Fusion for Joint Vulnerability Detection and Localization"


project/
├── train.py
├── data_loader.py
├── README.md
├── requirements.txt
├── models/
│ ├── control_pathway.py
│ ├── semantic_pathway.py
│ ├── feature_fusion_module.py
│ ├── transformer_llm_module.py
│ └── multi_task_predictor.py
We use the LineVul dataset for vulnerability detection:
Michael Fu and Chakkrit Tantithamthavorn, "LineVul: A Transformer-based Line-Level Vulnerability Prediction", MSR 2022.
Paper: https://conf.researchr.org/details/msr-2022/msr-2022-technical-papers/26/LineVul-A-Transformer-based-Line-Level-Vulnerability-Prediction
Repository: https://github.com/awsm-research/LineVul
We further preprocess the dataset into graph structures and align each sample with LLM-generated explanations.
We use the following pretrained models:
OpenAI GPT-4o-mini
OpenAI, "Hello GPT-4o", 2024.
URL: https://openai.com/index/hello-gpt-4o/
Qwen Models (Qwen3 series)
Qwen Team, "Qwen3 Technical Report", arXiv:2505.09388, 2025.
Paper: https://arxiv.org/abs/2505.09388
Repository: https://github.com/QwenLM/Qwen3
GraphCodeBERT
Guo et al., "GraphCodeBERT: Pre-training Code Representations with Data Flow", ICLR 2021.
Paper: https://arxiv.org/abs/2009.08366
Repository: https://github.com/microsoft/CodeBERT
This project uses publicly available datasets and pretrained models. Their licenses are listed below:
LineVul Dataset
License: MIT License
Source: https://github.com/awsm-research/LineVul
OpenAI GPT-4o-mini
Usage is subject to the OpenAI Terms of Use.
Qwen Models (Qwen3.5-4B)
License: Apache License 2.0
Source: https://github.com/QwenLM/Qwen3
GraphCodeBERT
License: MIT License
Source: https://github.com/microsoft/CodeBERT
All assets are used in accordance with their respective licenses.
python >= 3.9
torch>=2.0.0
torch-geometric>=2.4.0
transformers>=4.35.0
accelerate>=0.25.0
sentencepiece
pandas>=1.5.0
tqdm>=4.60.0
tensorboard
PyTorch Geometric (PyG) depends on CUDA. Please install it according to your environment.
data/
├── processed/
│ ├── train_data_masked.pt
│ ├── train_with_llm.csv
│ ├── val_data_masked.pt
│ ├── val_with_llm.csv
│ ├── test_data_masked.pt
│ ├── test_with_llm.csv
├── config/
│ └── node_vocab.json
The CSV file must contain the following fields:
index: unique sample IDfunc_before: source codellm_explanation: LLM-generated explanationEach PyG Data object must include:
index: aligned with CSVx: node featuresast_edge_index: AST edgescfg_edge_index: CFG edgesy_f: function-level labely_s: line-level labelsline_mask: token-to-line mappingThe framework uses the following pretrained models:
Qwen/Qwen3.5-4Bmicrosoft/graphcodebert-baseYou can modify them via:
--llm_model_name
--transformer_base_name
python train.py \
--train_pt_path ./data/processed/train_data_masked.pt \
--train_csv_path ./data/processed/train_with_llm.csv \
--valid_pt_path ./data/processed/val_data_masked.pt \
--valid_csv_path ./data/processed/val_with_llm.csv \
--vocab_path ./data/config/node_vocab.json \
--output_dir ./outputs \
--run_name demo
Results will be saved to:
outputs/<run_name>/
Including: