# ChatGPT Translation of Program Code for Image Sketch Abstraction
## 4 Methodology of the M-to-PY Conversion
### Pair Programming with LLMs  
The application of pair programming with AI was implemented in the ongoing \"Image abstraction from the center of balance of motion detection\" project, as the case study by [PERSON] et al. [11]. The original code, written in MATLAB and provided by its authors, had a history of conversion attempts that started before the release of ChatGPT. After several initial attempts with M-to-PY converters performed by junior developers, about 30% of the initial MATLAB code was translated and tested. These were mainly static functions unrelated to the two objects used in the code. A comparison of existing tools demonstrated that in comparison with several other converters such as Libra, SMOP, Mat2 Py, and the NumPy, Oct2 Py, and SciPy Python packages and libraries, the tool matlab2 python produced the best results. At that time, the results of the whole project execution were obscured, and its success was uncertain. It was stated that such a complex project could not be translated by simple, unintelligent tools by junior developers without previous knowledge in MATLAB and with minimum knowledge in Python, which was later established as a condition to validate LLM's effectiveness in the process. The releases of ChatGPT-3, ChatGPT-3.5, and ChatGPT-4 all served as trampolines to move the conversion further. With the first release, both MATLAB and Python environments were set up, and researchers started asking ChatGPT-3 to translate the code through its chat capacity. It was impossible to provide all the code simultaneously due to ChatGPT-3 limitations on both input and output. As the code was object-oriented and consisted of both static and instance functions that belong to their classes, it was very difficult to split it into chunks that could be easily fed into the model one by one and then, without much difficulty, could be assembled back. Python code upgrades to the latest version of the language itself and its libraries added level of complexity. The code was translated in small chunks, and a human copilot had to perform most of the debugging and troubleshooting. The project saw some progress with the early ChatGPT-3 model but the whole code still did not run at once. Situations when not all input was accepted, or part of the code was sent in response, were very disappointing. The attempt at auto-debugging was unsuccessful. The editor, Visual Studio Code (version 1.81), was used with little success for human debugging. A significant problem was situations when the shape or dimensions of data structures that were returned from a function in Python (aka arrays) did not match the MATLAB code. Many cases of array vs. list data structures were encountered where some functionality that could work with the array was not working with lists and vice versa. At the same time, this AI pair programming experience was very useful for team members to understand the LLM capabilities, improve prompt engineering skills, and understand the source code better. The prominent test cases of the conducted experiments are in Table 2.  
The release of ChatGPT-3.5 gave a new breath to the project, and visible progress was made. It should be noted that it was worth it to rerun the code already generated by ChatGPT-3 after the new version of the bot came out. The goal at this point was not to translate the code as soon as possible but to test and validate the AI Pair programming experience with ChatGPT-3.5, comparing it with the previous trials and tools. The overall quality of the code generation from version to version increased. The release of ChatGPT-4 was the event that made the study successful. The model's \"understanding\" of the code was significantly improved. It can be compared to the transition from working with an entry-level developer as a pair programmer whom you must lead to an advanced junior or early senior developer who might lead you. The team even invented the terminology of a human copilot as the model served as a team lead.