Abstract
Modern code intelligence models primarily rely on static analysis of source code, treating programming languages as a variant of natural language. However, code is fundamentally dynamic, and its true meaning lies in its execution. This paper presents Fuzz Tuning, a method that enhances Large Language Models (LLMs) by incorporating runtime behavior. By using grey-box fuzzing to generate diverse input-output pairs and integrating them into the training process via specialized prompts, the authors achieve state-of-the-art results in code clone detection and classification. The approach demonstrates significant improvements across multiple languages, including C++, Java, and Python.
The Challenge of Static Code Intelligence
Current "Code Intelligence" models, such as CodeBERT and UniXcoder, are typically trained on massive corpora of source code to learn statistical patterns. While effective, this approach treats code as text, ignoring its functional essence: execution. Two programs may look syntactically different but behave identically (semantic clones), or look similar while producing different outputs for edge cases. Static analysis often fails to capture these deep functional semantics. The core challenge is providing LLMs with a dynamic understanding of programs without the prohibitive overhead of running a full execution environment during every inference.
Methodology: The Fuzz Tuning Pipeline
The researchers introduced Fuzz Tuning, a three-step pipeline designed to bridge the gap between static code and dynamic behavior:
- Fuzzing for Data Generation: Using AFL++, a popular grey-box fuzzer, the system generates diverse inputs for a given program. Unlike random generation, fuzzers monitor code coverage to find inputs that trigger as many different execution branches as possible.
- Automated Code Fixing: To ensure raw source code snippets are "fuzzable," the authors developed a tool to automatically fix common compilation errors, such as missing headers or undeclared identifiers.
- Prompting and Tuning: Generated (Input, Output) pairs are converted into "cloze prompts." The study found that programming-language-based prompts (e.g.,
cin >> [INPUT]; cout << [OUTPUT];for C++) performed better than natural language descriptions. These prompts are concatenated with the source code to fine-tune pre-trained models.
Experimental Evaluation
The method was evaluated on major benchmarks including POJ104 (C/C++ programs for clone detection) and CodeNet (subsets for Java, Python, and C++).
Key Results and Insights
The authors achieved new state-of-the-art (SOTA) results across multiple tasks:
- Code Clone Detection: On the POJ104 dataset, UniXcoder with Fuzz Tuning reached a 93.40 MAP@R, outperforming the previous SOTA (ContraBERT) by nearly 3 points.
- Code Classification: Fuzz Tuning significantly reduced error rates. On the C++1000 subset, CodeBERT's error rate dropped from 16.34% to 7.63%.
- Cross-Language Generalization: The benefits were language-agnostic, showing consistent gains across C++, Java, and Python.
Why Fuzzing Works
A critical insight from the study is that dynamic profiles serve as a logic signature. Random input generation is largely ineffective because random bytes rarely pass initial syntax checks. Fuzzing, however, specifically hunts for inputs that "unlock" deeper program logic. Furthermore, Fuzz Tuning proved exceptionally data-efficient; in low-data scenarios (using only 4% of training data), it provided a much larger performance boost than standard fine-tuning.
Limitations and Future Work
While promising, the approach faces constraints. Fuzzers like AFL++ are optimized for C/C++, making adaptation to interpreted languages like Python more complex. Additionally, fuzzing every program in a massive dataset requires significant upfront computational overhead. Future work may explore data-flow coverage—tracking how data moves through variables—as a more granular metric than branch coverage to further refine test case quality.
Summary updated