Towards the Readability of LLM-Generated Codes through Multitask Representation Engineering
For developers using LLMs for code generation, this work provides a low-cost method to improve code readability across multiple tasks, though the gains are incremental over existing RepE approaches.
This paper addresses the under-explored problem of improving readability in LLM-generated code using representation engineering (RepE). The proposed multitask RepE framework enhances readability while maintaining correctness, with experiments demonstrating its effectiveness.
Correctness and readability are key measures of code quality, respectively ensuring functional fidelity and ease of comprehension. While most existing research focuses on improving the correctness of large language models~(LLMs) generated codes, readability remains under-addressed. Enhancing readability through targeted control is challenging due to its subjective nature. In this article, we employ representation engineering~(RepE) as the targeted control method given its characteristics of low data dependency and low computational cost. Prior work on RepE has primarily focused on the targeted control for a single task, but improving the code readability requires the control across multiple tasks. Accordingly we proposes the multitask RepE framework and theoretically discuss the impact of the multitask steering method on the tradeoff between the code readability and correctness. We further provide comprehensive experiments in support. All the relevant implementations are open-source and available upon request.