On the Difficulty of Selecting Few-Shot Examples for Effective LLM-based Vulnerability Detection
Md Abdul Hannan, Ronghao Ni, Chi Zhang, Limin Jia, Ravi Mangal, Corina S. Pasareanu

TL;DR
This paper investigates how the selection of few-shot examples influences the effectiveness of large language models in detecting code vulnerabilities, revealing that selection strategies improve results for some languages but not others.
Contribution
It introduces and evaluates two criteria for selecting few-shot examples in vulnerability detection, highlighting their impact across multiple programming languages.
Findings
Selection improves Python and JavaScript vulnerability detection.
Limited impact of selection on C and C++ programs.
More advanced methods may be needed for C/C++.
Abstract
Large language models (LLMs) have demonstrated impressive capabilities across a wide range of coding tasks, including summarization, translation, completion, and code generation. Despite these advances, detecting code vulnerabilities remains a challenging problem for LLMs. In-context learning (ICL) has emerged as an effective mechanism for improving model performance by providing a small number of labeled examples within the prompt. Prior work has shown, however, that the effectiveness of ICL depends critically on how these few-shot examples are selected. In this paper, we study two intuitive criteria for selecting few-shot examples for ICL in the context of code vulnerability detection. The first criterion leverages model behavior by prioritizing samples on which the LLM consistently makes mistakes, motivated by the intuition that such samples can expose and correct systematic model…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Adversarial Robustness in Machine Learning · Software Testing and Debugging Techniques
