Reproduce “Towards the Readability of LLM-Generated Codes through Multitask Representation Engineering” on OpenResearch

Turn your favorite coding agents into research agents that review literature, develop hypotheses, and run experiments.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Huifan Gao, Liuhua He, Yinghui Pan, Shenbao Yu, Yifeng Zeng, Shengchao Qin, Weidi Sun

This work introduces Multitask Representation Engineering (MRepE) and a novel algorithm, MOC-JPCA, to enhance the readability of code generated by large language models across multiple metrics like comment density, naming conventions, and cyclomatic complexity. The framework enables controllable improvements in readability while theoretically bounding the potential degradation in functional correctness, providing a principled approach to balance these code quality aspects.

Key insights

  • Code readability, a multi-faceted and subjective concept, can be effectively controlled in LLMs through internal representation manipulation (RepE) without costly fine-tuning.
  • Enforcing orthogonality among steering vectors for different readability metrics through MOC-JPCA is critical to prevent interference and ensure stable, coordinated multi-task control.
  • A theoretical framework with lower bounds for readability improvement and upper bounds for correctness degradation allows for quantifiable and predictable management of the inherent trade-off between these quality aspects.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.