NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Learning Generalizable Multimodal Representations for Software Vulnerability Detection

Zeming Dong, Yuejun Guo, Qiang Hu, Yao Zhang, Maxime Cordy, Hao Liu, Mike Papadakis, Yongqiang LyuarXiv 2026

TL;DR

MULTIVUL is a new multimodal contrastive learning framework that significantly boosts software vulnerability detection by using LLM-generated code comments during training. Crucially, it retains a lightweight, code-only pipeline during inference, avoiding any extra latency at test time while delivering up to a 27.07% F1 improvement over standard prompting methods.

What Problem Does This Paper Address?

Automated software vulnerability detection is critical for security, but it is notoriously difficult because security flaws are often subtle semantic errors rather than obvious syntax mistakes.

Current deep learning approaches suffer from two main limitations:

  1. Single-Modality Focus: Most models rely strictly on source code (either token sequences or graph representations). They miss out on the high-level developer intent and functional context that natural language comments provide.
  2. Poor Generalization: Code-only models frequently overfit to dataset-specific artifacts or coding conventions, causing their performance to tank when deployed on unseen projects or out-of-distribution (OOD) data.

While adding natural language descriptions helps, real-world code repositories often lack high-quality comments. Furthermore, requiring text descriptions or prompts during deployment is impractical and introduces severe latency bottlenecks.

Methods

The authors introduce MULTIVUL, a framework that leverages the power of multimodal learning during training but discards the text overhead during inference.

[Training Phase]
Raw Code ──> Critique Prompting ──> Generated Comment 
   │                                      │
   ├──> Augmentation (RS/RD) ──> Augmented Code 
   └──> Augmentation (RS/RD) ──> Augmented Text
   │                                      │
   └───> Dual-Encoder + Dual-CLIP + Consistency Regularization ──> Supervised Classifier

[Inference Phase]
Raw Code ──> Code Encoder ──> Supervised Classifier ──> Vulnerability Prediction (0/1)

The core pipeline consists of five key steps:

  • Critique Prompting: To bypass the lack of high-quality comments in real codebases, the authors use a strong model (Qwen2.5-Coder-32B-Instruct) to automatically generate concise, one-sentence functional summaries. To prevent "label leakage" (where the LLM accidentally reveals a security flaw in the comment), they use a self-critique loop that forces the model to only describe explicitly evidenced code behaviors, strictly forbidding any mention of security or vulnerabilities.
  • Data Augmentation: They apply lightweight token-level perturbations—Random Swap (RS) and Random Deletion (RD)—to both the code and the generated text to create alternative "augmented views."
  • Dual-Encoder & Dual-CLIP Alignment: Using modality-specific projection heads, code and text are mapped into a shared embedding space. A symmetric InfoNCE (CLIP) loss is applied to both the original code-text pairs and the augmented pairs to enforce cross-modal alignment.
  • Cross-View Consistency Regularization: To stabilize the embedding space against minor variations, they minimize the squared $\ell_2$ distance between the original and augmented embeddings.
  • Vulnerability Classification: A simple Multi-Layer Perceptron (MLP) binary classifier is trained on top of the code embeddings. At test time, the text encoder is completely dropped, allowing for pure code-only inference.

Datasets

The framework was evaluated on two widely adopted vulnerability detection benchmarks:

  • Devign: A dataset composed of functions collected from four large-scale, diversified open-source C projects.
  • DiverseVul: A larger, more recent dataset spanning a much broader range of projects and Common Weakness Enumerations (CWEs), making it ideal for testing out-of-distribution generalization.

Key Insights and Ideas

  • Multimodal Training for Unimodal Inference: You don't actually need comments at test time to benefit from them. Forcing a code encoder to align its representations with natural language descriptions during training acts as a powerful regularizer, pushing the model to learn deeper semantic features rather than superficial token patterns.
  • The Power of Mild Perturbations: Instead of relying on complex, language-specific code refactoring pipelines (which are hard to scale), simple token-level swaps and deletions provide excellent regularization when paired with cross-view consistency losses.
  • Context-Heavy Bugs Benefit Most: Aligning code with text is particularly effective for vulnerabilities that depend on contextual program behavior—like exception handling or memory boundary checks—where the flaw is distributed across execution paths rather than isolated in a single token.

Key Results

The authors evaluated MULTIVUL across four distinct 7B-scale code LLMs (DeepSeek-Coder-6.7B, Qwen2.5-Coder-7B, StarCoder2-7B, and CodeLlama-7B).

  • Superior Accuracy and F1: MULTIVUL consistently outperformed both prompting-based baselines (Chain-of-Thought) and standard supervised fine-tuning. It achieved up to a 27.07% F1 improvement over prompting and up to a 13.37% F1 improvement over code-only fine-tuning.
  • Excellent OOD Generalization: In cross-dataset evaluations (e.g., training on Devign and testing on DiverseVul), MULTIVUL maintained robust performance where other models degraded, showing F1 improvements of up to 17.72%.
  • Maintained Inference Efficiency: Because the text modality is omitted at test time, MULTIVUL completely avoids expensive autoregressive decoding. It clocks an inference latency of just 0.127 to 0.197 seconds per sample, making it 1 to 2 orders of magnitude faster than prompting methods.
  • Fewer False Negatives: Qualitative analysis showed a sharp drop in false negatives for tricky bug categories like CWE-703 (Improper Check of Exceptional Conditions) and CWE-119 (Memory Buffer Restrictions).

Limitations and Future Work

  • Arithmetic and Value-Flow Blindspots: The model showed limited improvement on CWE-190 (Integer Overflow). The authors note that while natural language comments provide excellent functional context, they do not explicitly model mathematical constraints or value propagation.
  • Dataset Noise: Public vulnerability datasets are known to contain noisy labels and project-specific artifacts, which can cap the model's real-world utility.
  • Future Directions: The authors plan to explore incorporating other training-time modalities beyond comments, such as commit messages, issue reports, and vulnerability advisories, to further bridge the gap between code structure and developer intent.

Summary updated

BibTeX
@misc{dong2026learning,
  author = {Zeming Dong and Yuejun Guo and Qiang Hu and Yao Zhang and Maxime Cordy and Hao Liu and Mike Papadakis and Yongqiang Lyu},
  title = {{Learning Generalizable Multimodal Representations for Software Vulnerability Detection}},
  year = {2026},
  eprint = {2604.25711},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.25711},
}
Figure