Research map / Large language models / Agents, code and math
EditLord: Learning Code Transformation Rules for Code Editing
Read the paperCheck your idea against 108,967 papers
AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.
Proposes EditLord, which uses an LM to induce a concise meta-rule set of explicit code transformation rules and functional specifications from training code pairs, then finetunes code LMs to output rules and specs before the edited code.
Problem
Code editing is typically learned as an implicit end-to-end mapping via finetuning, which decouples poorly from modular, reusable editing steps and leads to suboptimal performance, weak robustness, and poor generalization.
Approach
An LM acts as an inductive learner that extracts natural-language "switch from X to Y" editing rules from training pairs, refines them via ADD/MERGE/PRUNE operations into a concise meta-rule set, and augments each training sample with per-sample rules and functional specifications so the model predicts specs and rules before the edited code.
Key results
- On performance optimization with DeepSeek-Coder 6.7B, OPT@1 rises from 7.8 (finetuned) to 11.0 and Speedup@1 from 2.1 to 2.7.
- On decompilation with GPT-4o mini, readability (char) improves from 45.6 to 51.4 and compilability from 86.3 to 97.7 over the finetuned baseline.
- On security hardening with DeepSeek-Coder 1.3B, Correct & Security@1 improves from 5.3 to 7.4 and Correct@10 from 35.7 to 49.6 over finetuned baseline; human-augmented rules further raise Correct@1 on performance to 53.0 with DeepSeek-Coder 1.3B.
Measured effects reported in the paper
| What was changed | Where | Measured | Effect |
|---|---|---|---|
| Use EditLord instead of finetuning | DeepSeek-Coder 1.3B · Performance optimization (HQ test) | OPT@8: 47.5 -> 53.1 | Helped |
| Use EditLord instead of finetuning | DeepSeek-Coder 1.3B · Decompilation (HumanEval-Decompile) | Readability char: 36.6 -> 44.0 | Helped |
| Use EditLord instead of finetuning | DeepSeek-Coder 1.3B · Security hardening (CWEval) | Correct & Security@10: 13.8 -> 18.7 | Helped |
| Add functional specification learning only (ablation) | Finetuned DeepSeek-Coder 1.3B · Performance optimization (HQ test) | OPT@8: 47.5 -> 49.2 | Helped |
| Add editing-rule learning only (ablation) | Finetuned DeepSeek-Coder 1.3B · Performance optimization (HQ test) | OPT@8: 47.5 -> 51.9 | Helped |
| Add functional specification learning only (ablation) | Finetuned DeepSeek-Coder 1.3B · Performance optimization (HQ test) | Correct@8: 67.5 -> 73.4 | Helped |
| Add editing-rule learning only (ablation) | Finetuned DeepSeek-Coder 1.3B · Performance optimization (HQ test) | Correct@8: 67.5 -> 70.0 | Helped |
| Add functional specification learning only (ablation) | Finetuned DeepSeek-Coder 1.3B · Decompilation (HumanEval-Decompile) | Readability char: 36.6 -> 38.9 | Helped |
| Add editing-rule learning only (ablation) | Finetuned DeepSeek-Coder 1.3B · Decompilation (HumanEval-Decompile) | Correctness: 38.9 -> 29.8 | Hurt |
| Add functional specification learning only (ablation) | Finetuned DeepSeek-Coder 1.3B · Security hardening (CWEval) | Correct & Security@10: 13.8 -> 15.8 | Helped |
| Add editing-rule learning only (ablation) | Finetuned DeepSeek-Coder 1.3B · Security hardening (CWEval) | Correct & Security@10: 13.8 -> 17.5 | Helped |
| Combine functional specifications and editing rules (ablation) | Finetuned DeepSeek-Coder 1.3B · Decompilation (HumanEval-Decompile) | Compilability: 77.1 -> 93.1 | Helped |
Surprising findings
- Prompting alone sometimes yields higher functional correctness than the proposed method because unmodified pre-edit code is trivially correct, while readability drops under prompting.
- Chain-of-thought prompting substantially degrades decompilation compilability for DeepSeek-Coder 6.7B (4.4 vs 83.2 for plain prompting).
Limitations
- No formal guarantee of functional correctness; edited code may still be incorrect and fall back to original code would fail to edit.
- Relies on coarse-grained execution feedback in iterative refinement and underperforms some baselines there.
- Rule induction depends on a proprietary LM (GPT-4o mini), and rules are generated with possible hallucinations requiring verification.
Experimental setup
Datasets: HQ (performance optimization) AnghaBench HumanEval-Decompile SVEN CWEval CodeEditorBench
Benchmarks: HQ performance optimization test set HumanEval-Decompile CWEval CodeEditorBench Code Polish
Metrics: OPT@k Speedup@k Correct@k Compilability Correctness Readability (char/token/embedding) Security@k Correct & Security@k
Baselines: Prompt CoT Finetuned baseline (task-specific prior approaches)
Builds on: chain-of-thought prompting STaR-style bootstrapping of reasoning Ghidra
Closest papers by meaning
- NextCoder: Robust Adaptation of Code LMs to Diverse Code Edits (ICML 2025 · similarity 0.88)
- Training Language Models on Synthetic Edit Sequences Improves Code Synthesis (ICLR 2025 · similarity 0.87)
- Unsupervised Evaluation of Code LLMs with Round-Trip Correctness (ICML 2024 · similarity 0.85)
- LLM-Assisted Code Cleaning For Training Accurate Code Generators (ICLR 2024 · similarity 0.85)
- Let the Code LLM Edit Itself When You Edit the Code (ICLR 2025 · similarity 0.84)
- ObscuraCoder: Powering Efficient Code LM Pre-Training Via Obfuscation Grounding (ICLR 2025 · similarity 0.84)
Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.
