Skip to yearly menu bar Skip to main content


Poster

EditLord: Learning Code Transformation Rules for Code Editing

Weichen Li · Albert Jan · Baishakhi Ray · Junfeng Yang · Chengzhi Mao · Kexin Pei

West Exhibition Hall B2-B3 #W-412
[ ] [ ]
Wed 16 Jul 11 a.m. PDT — 1:30 p.m. PDT

Abstract:

Code editing is a foundational task in software development, where its effectiveness depends on whether it introduces desired code property changes without changing the original code's intended functionality. Existing approaches often formulate code editing as an implicit end-to-end task, omitting the fact that code-editing procedures inherently consist of discrete and explicit steps, and thus suffer from suboptimal performance and lack of robustness and generalization. We introduce EditLord, a code editing framework that makes the code transformation steps explicit. Our key insight is to employ a language model (LM) as an inductive learner to extract code editing rules from the training code pairs as concise meta-rule sets.Such rule sets will be manifested for each training sample to augment them for finetuning or assist in prompting- and iterative-based code editing.EditLord outperforms the state-of-the-art by an average of 22.7% in editing performance and 58.1% in robustness while achieving 20.2% higher functional correctness, across critical software engineering and security applications, LM models, and editing modes.

Lay Summary:

Editing code is a common but complex part of software development. Most current tools try to do this automatically, but they often treat the process as one big step, which can make the results unreliable or hard to generalize.We created a new tool called EditLord that takes a more structured approach. Instead of treating code editing as a black box, EditLord breaks the process down into clear steps. EditLord uses a powerful language model to learn simple editing rules from examples of how code was changed. These rules can then help guide future edits, whether the model is being fine-tuned or used directly.EditLord consistently outperforms other tools across various real-world programming tasks, e.g., performance optimization, readability improvement, and security hardening.It makes more accurate edits, handles different situations better, and maintains the original function of the code more reliably.

Chat is not available.