Code-SPA: Style Preference Alignment to Large Language Models for Effective and Robust Code Debugging

Tengfei Wen, Xuanang Chen, Ben He, Le Sun


Abstract
Large language models (LLMs) have demonstrated impressive capabilities in coding tasks like code generation and debugging. However, code from real-world users is often poorly styled, containing various types of noise, such as structural inconsistencies, stylistic deviations and flawed test cases. To investigate this, we first simulate poorly styled code using eight types of code perturbations, and then demonstrate that the debugging performance of existing LLM-based methods significantly declines on such inputs. Furthermore, to address this, we propose a novel debugging method called Code-SPA, which aligns noisy code with the well-structured style familiar to LLMs, mitigating the impact of stylistic inconsistencies. Specifically, Code-SPA extracts the model’s preferred coding style from a reference snippet, then adjusts the input code by Concrete Syntax Tree (CST)-based transformations and LLM-assisted refinements before debugging. By aligning the code style preference, Code-SPA enhances the debugging performance of both code-specific and general-purpose LLMs on both poorly and well-styled code across the HumanEval, MBPP and EvalPlus datasets.
Anthology ID:
2025.findings-acl.912
Volume:
Findings of the Association for Computational Linguistics: ACL 2025
Month:
July
Year:
2025
Address:
Vienna, Austria
Editors:
Wanxiang Che, Joyce Nabende, Ekaterina Shutova, Mohammad Taher Pilehvar
Venue:
Findings
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
17730–17743
Language:
URL:
https://preview.aclanthology.org/mtsummit-25-ingestion/2025.findings-acl.912/
DOI:
10.18653/v1/2025.findings-acl.912
Bibkey:
Cite (ACL):
Tengfei Wen, Xuanang Chen, Ben He, and Le Sun. 2025. Code-SPA: Style Preference Alignment to Large Language Models for Effective and Robust Code Debugging. In Findings of the Association for Computational Linguistics: ACL 2025, pages 17730–17743, Vienna, Austria. Association for Computational Linguistics.
Cite (Informal):
Code-SPA: Style Preference Alignment to Large Language Models for Effective and Robust Code Debugging (Wen et al., Findings 2025)
Copy Citation:
PDF:
https://preview.aclanthology.org/mtsummit-25-ingestion/2025.findings-acl.912.pdf