Don't Transform the Code, Code the Transforms: Towards Precise Code Rewriting using LLMs

Chris Cummins, Volker Seeker, Jordi Armengol-Estapé, Aram H. Markosyan, Gabriel Synnaeve +1 more
10/11/2024
cs.LG

No confident code implementation found for this paper.

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 than direct LLM rewriting on the others. We hope to encourage further research to improving the precision of LLM code rewriting.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{cummins2024dont,
  title  = {Don't Transform the Code, Code the Transforms: Towards Precise Code Rewriting using LLMs},
  author = {Chris Cummins and Volker Seeker and Jordi Armengol-Estapé and Aram H. Markosyan and Gabriel Synnaeve and Hugh Leather},
  year   = {2024},
  eprint = {2410.08806},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.08806v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.08806.svg)](https://codeofpaper.com/paper/2410.08806)

Discussion