Tools designed for rewriting, refactoring, and optimizing code should prioritize both speed and accuracy. Large language models (LLMs), however, often lack these critical attributes. Despite these limitations, there remains significant potential for leveraging LLMs to enhance code quality.
In a new paper Don’t Transform the Code, Code the Transforms: Towards Precise Code Rewriting using LLMs, a Meta research team proposes a novel chain-of-thought strategy to efficiently generate code transformations using LLMs. Their approach enables LLMs to derive transformations based on a small set of input/output examples.

A code transformation refers to a function that modifies existing code to achieve a desired form, a method applicable to various tasks—from compiler optimizations to legacy code refactoring. Traditional rule-based transformations, while effective, are often complex to design and implement. LLMs present a promising alternative, but their logic can be opaque, lacks guarantees of correctness, and is difficult to debug when errors occur.

Instead of using LLMs to directly rewrite code, the researchers propose a system where LLMs serve as generators for code transformations. Their method hinges on a step-by-step approach, using introspective iterations to refine the model’s output. This process allows the LLM to diagnose its mistakes and hypothesize potential solutions before making adjustments.
The process involves several key steps:
- Initial Example Presentation: The model is given three input/output examples and tasked with describing the underlying transformation in clear natural language.
- Iterative Refinement: The model refines its description, if necessary, over 10 iterations. The initial attempts often fail to capture the full complexity of the transformation, especially for edge cases.
- Generating the Transformation: Once the description is deemed sufficient, the model uses it, along with the original examples, to produce a code transformation implementation.
- Testing and Debugging: The generated transformation is then tested in a controlled environment with 10 input/output examples (including the initial ones). If errors occur or the output is incorrect, counterexamples or error messages are provided to the model.
- Failure Analysis: When failures occur, the model performs an introspection, analyzing the error and attempting to explain the issue.
- Iterative Fixing: The model is prompted with the incorrect code, the failure case, and its own analysis, iterating until a working transformation is produced (up to 50 iterations). Afterward, the quality of the transformation is evaluated on unseen examples.


The research team compared their Code the Transforms (CTT) method with a Transform the Code (TTC) approach, where the LLM directly rewrites code. Their findings show that CTT consistently outperforms TTC in precision, achieving an accuracy rate of 0.95 compared to TTC’s 0.60. Furthermore, errors in CTT are generally easier to diagnose and resolve. On average, the synthesized transformations consisted of 34.4 lines of code, whereas TTC required extensive review to catch mistakes.
In conclusion, the paper demonstrates that having LLMs generate transformations rather than directly rewriting code not only increases precision but also reduces the cost of reviewing and testing code, offering a more efficient alternative for code optimization tasks.
The paper Don’t Transform the Code, Code the Transforms: Towards Precise Code Rewriting using LLMs is on arXiv.
Author: Hecate He | Editor: Chain Zhang

Pingback: LLMs as Code Architects: Meta’s New Approach to Precise Code Transformations - Welcome
I tried both methods and CTT gives much more stable results, without the headache of fixing errors like when using TTC. It feels like playing Drift Boss — with CTT, you just need to keep the right rhythm to reach the destination, while TTC often “loses control” and has to start over. It saves time and is much more effective.
This comparison clearly shows how CTT provides a more stable and efficient experience, while TTC seems less reliable and Crossy Road requires more corrections, making CTT feel smoother and more time-saving overall.
It’s impressive that Meta’s LCMs are already showing strong zero-shot performance across languages — that’s a huge step forward for global speed stars applications. I’m really interested in how this might improve not just translation, but also tasks like reasoning, summarization, and multilingual search.
Nice article with clear and engaging explanation. Cryptocurrency Exchange Development Company
will likely drive the next wave of innovation. Looking forward to more posts like this.
This comparison clearly shows how CTT provides a more stable and efficient experience, while TTC seems less reliable and requires more corrections, Crossy Road making CTT feel smoother and more time-saving overall.
Nice article with clear and engaging explanation, I also found another website tnreginetpoortal
Counterexample testing could make refactoring safer for our team, if kept in CI.
indiramma Illu flagship housing programme launched in 2024 to provide safe, permanent homes for disadvantaged families. Offering up to ₹5 lakh in financial aid and land for landless beneficiaries, it prioritises economically weaker sections and marginalised communities. District-wise phased rollouts, online verification, and transparent disbursement ensure effective implementation while integrating with other welfare initiatives to improve living standards across the state.
Banglar Bhumi is West Bengal’s official online land records portal, providing instant access to Khatian, plot details, RS‑LR maps, ownership records, mutation status, and revenue services. Managed by the Land & Land Reforms and Refugee Relief & Rehabilitation Department, it allows citizens to search land data, track applications, pay online, download certified documents, and file grievances—all from home. By digitizing millions of records and ensuring real-time updates, BanglarBhumi makes property transactions faster, transparent, and hassle-free for landowners, buyers, and researchers across the state.
Confiado Delta Executor APK por su interfaz limpia, actualizaciones regulares, protecciones anti‑ban, alto rendimiento y compatibilidad multiplataforma, esta herramienta es popular tanto entre principiantes como entre jugadores experimentados de Roblox — con navegación intuitiva, fuertes medidas de seguridad para reducir el riesgo de detección y soporte continuo al cliente que hace que la jugabilidad sea más fluida, rápida y más personalizable que las experiencias nativas de Roblox.
KFC Menu South Africa crispy chicken, or tasty sides like mash and gravy, KFC makes ordering easy with online, app, and in-store options. Plus, nutritional info helps you make healthier choices while keeping your budget in check. Stay updated with the latest prices and exciting new offers every week!
Whether you choose to register TNT SIM Registration Online online, via the GigaLife app, or at a nearby store, this simple step keeps you connected, safe, and ready to enjoy all the perks TNT offers. Don’t miss out – register today!
TM SIM registration is required for all users in the Philippines under the SIM Registration Act (Republic Act No. 11934) to keep mobile numbers active, secure, and legally compliant. TM (Touch Mobile), a prepaid brand under Globe Telecom, allows new and existing users to register their SIM cards easily through the official online portal, the GlobeOne app, or authorized TM stores.
Delivery teams often rely on accurate schedules and workplace communication. Access issues can become inconvenient when employees need information before starting work. This guide explains common MySainsburys-related questions for delivery colleagues.
https://mysainsburrys.com/
Forgetting registration details is a common problem with online applications, especially when users apply months before checking their status. Without the correct reference information, tracking progress becomes difficult. This article explains how applicants can manage lost registration details and what information may help during recovery.
https://annapurnabhandarr.com/
Sometimes online services may experience temporary technical problems that affect document downloads. Users searching for Hamraaz payslip solutions often want to know whether the problem is with their account or the portal itself. This guide explains how to identify temporary service-related issues and what steps users can take while waiting for normal access.
https://hamraazweeb.com/