Understanding and Mitigating Representation Drift of Code Models under Software Distribution Shifts
Yiqing Shi, Zhifei Chen, Yangyang Zhao, Quanjun Zhang, Wei Song
Abstract
Deep learning-based code models often suffer performance degradation under software distribution shifts. Although recent studies have investigated the robustness of code models to out-of-distribution (OOD) data, how distribution shifts reshape internal representations and how such changes can guide adaptation decisions remain insufficiently understood. To answer such puzzles, we present a systematic empirical study organized along a diagnosis-to-adaptation workflow covering seven tasks, five code models, and five distribution shift types. Specifically, we measure generalization gaps between in-distribution (ID) and OOD data, evaluate task-adapted OOD detection signals, diagnose layer-wise representation geometry, and propose a representation-diagnostics-guided adaptation strategy. Our results show that: 1) performance degradation is decoupled from OOD detectability, with detectors achieving AUROC values below 59.00% even when syntactic shifts reduce classification accuracy by up to 15.69%; 2) settings with OOD performance degradation exhibit weaker cross-distribution alignment and more pronounced layer-wise geometric changes; and 3) diagnostics-guided data allocation and configuration search yield higher OOD scores than traditional adaptation strategies. Overall, our findings highlight the necessity of integrating representation-level diagnostics into the evaluation and adaptation of code models under distribution shifts.
Create a lesson
Related papers
"My Code Runs Fine, I Don't": Understanding How Software Professionals Work Through Chronic Pain
Shared title terminologycs.SEMairieli Wessel, Kiev Gama, Joukje Oosterman et al.
ReleaseSynth: Scaling Data from Software Evolution for Long-Horizon Coding Agents
Shared title terminologycs.SEMan Ho Lam, Chaozheng Wang, Zongjie Li et al.
Software Engineering After Human Comprehension? Review the Checks Instead of Code
Shared title terminologycs.SEChristoph Treude
Solution or Skeleton? Distributional Alignment and Mode Switching in Code Language Models
Shared title terminologycs.SEShaojie Zhang, Yue Yu, Yu Zhang
Useful but Unwieldy: How Software Engineers Perceive the Design of Chain-of-Thought Explanations in Coding Agents
Shared title terminologycs.SECarlos Rafael Catalan, Lheane Marie Dizon, Patricia Nicole Monderin et al.
SWE-Recreation: Benchmarking Coding Agents for Software Recreation
Shared title terminologycs.SEZhiyao Xu, Zhanjie Ding, Hongyao Yu et al.