用多任务表征工程提升大模型生成代码的可读性
Towards the Readability of LLM-Generated Codes through Multitask Representation Engineering

- 通过多任务表征工程实现对代码可读性的精准控制
- 在保持代码正确性的前提下显著提升可读性
- 适合关注代码质量与可维护性的开发者和研究者
正确性和可读性是衡量代码质量的两大关键指标,分别保障功能正确与易于理解。现有研究多聚焦于提升大语言模型生成代码的正确性,而对可读性的关注不足。由于可读性具有主观性,针对性控制难度较大。本文采用表征工程(RepE)作为控制方法,因其数据依赖低、计算成本小。以往的RepE研究主要集中于单一任务控制,但提升代码可读性需跨多个任务协同控制。为此,我们提出多任务表征工程框架,并理论分析了多任务调制对代码可读性与正确性之间权衡的影响。实验全面验证了该方法的有效性,所有代码均已开源。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。