Don't Transform the Code, Code the Transforms: Towards Precise Code Rewriting using LLMs
Chris Cummins, Volker Seeker, Jordi Armengol-Estap\'e, Aram H., Markosyan, Gabriel Synnaeve, Hugh Leather

TL;DR
This paper introduces a novel approach using large language models to generate precise, inspectable code transformations through a chain-of-thought method, improving correctness and debugging ease over direct rewriting.
Contribution
It proposes a chain-of-thought approach for code transformations with LLMs, emphasizing explicit, debuggable logic and efficiency, differing from traditional direct rewriting methods.
Findings
LLM-generated transforms are perfectly precise for 7 out of 16 cases.
The approach is less imprecise than direct rewriting in other cases.
Code transformations require minimal compute compared to LLM rewriting.
Abstract
Tools for rewriting, refactoring and optimizing code should be fast and correct. Large language models (LLMs), by their nature, possess neither of these qualities. Yet, there remains tremendous opportunity in using LLMs to improve code. We explore the use of LLMs not to transform code, but to code transforms. We propose a chain-of-thought approach to synthesizing code transformations from a small number of input/output code examples that incorporates execution and feedback. Unlike the direct rewrite approach, LLM-generated transformations are easy to inspect, debug, and validate. The logic of the rewrite is explicitly coded and easy to adapt. The compute required to run code transformations is minute compared to that of LLM rewriting. We test our approach on 16 Python code transformations and find that LLM- generated transforms are perfectly precise for 7 of them and less imprecise…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsDigital Rights Management and Security · Artificial Intelligence in Law
