Table of Contents
Fetching ...

Model See, Model Do? Exposure-Aware Evaluation of Bug-vs-Fix Preference in Code LLMs

Ali Al-Kaswan, Claudio Spiess, Prem Devanbu, Arie van Deursen, Maliheh Izadi

TL;DR

This work introduces an exposure-aware evaluation pipeline to study how prior exposure to buggy versus fixed code shapes code LLM behavior. By merging membership testing on the Stack-v2 corpus with ManySStuBs4J bug–fix pairs and a suite of likelihood- and generation-based metrics, the authors disentangle memorisation from learned correctness. They find that most bug–fix pairs are unseen, but when exposure exists fixes are more often present; yet model generations still reproduce bugs at higher rates, especially under bug exposure, while minimum- and maximum-probability metrics consistently favor fixes. The results reveal robust, category-specific patterns and demonstrate that exposure can skew bug-fix evaluations, underscoring the need for exposure-aware benchmarks and mitigation strategies to prevent memorised errors from propagating in practice.

Abstract

Large language models are increasingly used for code generation and debugging, but their outputs can still contain bugs, that originate from training data. Distinguishing whether an LLM prefers correct code, or a familiar incorrect version might be influenced by what it's been exposed to during training. We introduce an exposure-aware evaluation framework that quantifies how prior exposure to buggy versus fixed code influences a model's preference. Using the ManySStuBs4J benchmark, we apply Data Portraits for membership testing on the Stack-V2 corpus to estimate whether each buggy and fixed variant was seen during training. We then stratify examples by exposure and compare model preference using code completion as well as multiple likelihood-based scoring metrics We find that most examples (67%) have neither variant in the training data, and when only one is present, fixes are more frequently present than bugs. In model generations, models reproduce buggy lines far more often than fixes, with bug-exposed examples amplifying this tendency and fix-exposed examples showing only marginal improvement. In likelihood scoring, minimum and maximum token-probability metrics consistently prefer the fixed code across all conditions, indicating a stable bias toward correct fixes. In contrast, metrics like the Gini coefficient reverse preference when only the buggy variant was seen. Our results indicate that exposure can skew bug-fix evaluations and highlight the risk that LLMs may propagate memorised errors in practice.

Model See, Model Do? Exposure-Aware Evaluation of Bug-vs-Fix Preference in Code LLMs

TL;DR

This work introduces an exposure-aware evaluation pipeline to study how prior exposure to buggy versus fixed code shapes code LLM behavior. By merging membership testing on the Stack-v2 corpus with ManySStuBs4J bug–fix pairs and a suite of likelihood- and generation-based metrics, the authors disentangle memorisation from learned correctness. They find that most bug–fix pairs are unseen, but when exposure exists fixes are more often present; yet model generations still reproduce bugs at higher rates, especially under bug exposure, while minimum- and maximum-probability metrics consistently favor fixes. The results reveal robust, category-specific patterns and demonstrate that exposure can skew bug-fix evaluations, underscoring the need for exposure-aware benchmarks and mitigation strategies to prevent memorised errors from propagating in practice.

Abstract

Large language models are increasingly used for code generation and debugging, but their outputs can still contain bugs, that originate from training data. Distinguishing whether an LLM prefers correct code, or a familiar incorrect version might be influenced by what it's been exposed to during training. We introduce an exposure-aware evaluation framework that quantifies how prior exposure to buggy versus fixed code influences a model's preference. Using the ManySStuBs4J benchmark, we apply Data Portraits for membership testing on the Stack-V2 corpus to estimate whether each buggy and fixed variant was seen during training. We then stratify examples by exposure and compare model preference using code completion as well as multiple likelihood-based scoring metrics We find that most examples (67%) have neither variant in the training data, and when only one is present, fixes are more frequently present than bugs. In model generations, models reproduce buggy lines far more often than fixes, with bug-exposed examples amplifying this tendency and fix-exposed examples showing only marginal improvement. In likelihood scoring, minimum and maximum token-probability metrics consistently prefer the fixed code across all conditions, indicating a stable bias toward correct fixes. In contrast, metrics like the Gini coefficient reverse preference when only the buggy variant was seen. Our results indicate that exposure can skew bug-fix evaluations and highlight the risk that LLMs may propagate memorised errors in practice.
Paper Structure (24 sections, 7 figures, 3 tables)

This paper contains 24 sections, 7 figures, 3 tables.

Figures (7)

  • Figure 1: Overview of our exposure-aware evaluation framework
  • Figure 2: Distribution of exposure of bugs and fixes in logarithmic scale
  • Figure 3: Model preference per bug category (StarCoder2-7B)
  • Figure 4: Model preference per bug category (Mellum-4B)
  • Figure 5: Model preference per bug category (SmolLM3)
  • ...and 2 more figures