Aller au contenu

Virtual assistants: a new phase in computer engineering?

Dr. Estelle Delouche

In research, computer engineering is an essential component for solving complex problems, testing hypotheses and exploring new approaches. One of the main difficulties is to transcribe what you want to test into a new language: programming or code. Anyone wishing to learn programming has already spent many hours browsing forums to find solutions to the errors displayed or to determine which functions would be optimal for the problem to be solved. This is where the question arises as to whether NLP (Natural Language Processing) can improve user experiences by providing quality explanations and codes. The emergence of virtual assistants such as ChatGPT or Copilot could offer valuable help in the way developers access information about programming languages. In this article, I propose an overview of the advantages of using a language model (ChatGPT version 4o in this case) to help develop code in the Python language.

1- Active Learning

One of the major advantages of the virtual assistant lies in its flexibility and its ability to quickly provide functional code (in just a few seconds) with detailed explanations. So, by generating code while explaining the role of each function or library used, the assistant offers real educational value. For example, while working with dates vector I obtained this error :

The error ValueError: could not convert string to float: '2018-08-23' means that the algorithm tries to treat a column containing dates ('2018-08-23') as if it were a numeric value, which is not possible.

ChatGPT explanation:
« The date column must be removed before training the models, but we can keep it for analysis and visualization after predictions. »

So whether it’s a novice developer wanting to understand basic concepts or an expert looking for advanced solutions, there’s something for everyone. For example, when creating an application or optimizing an algorithm, ChatGPT not only details the process, but also suggests alternatives and improvements.

For example, I asked ChatGPT to help me deploy machine learning algorithms on bicycle data (Dataset available on the “Ile de France Mobilité” website). The aim was to be able to predict the number of bike passages at a given location. The chatbot naturally advised me to use several regression algorithms and to optimize the results by selecting the best parameters for each model using a “GridSearch”. In this way, I was able to compare the different models, but also choose the most appropriate model according to my data and parameters.

2- Intuitive to use

One of the difficulties in programming is transcribing what you want to achieve into functional code. Calculations or detailed explanatory figures that are as easy to read as possible can sometimes take a lot of time… And the result is not always what you wanted!
In the context of my projects, I found that ChatGPT was very good at transcribing my ideas into Python code, even if it meant rewriting my request to make sure it was in line with what I wanted.

Prompt:
“Can you shift the annotation to the right corner because it’s overlapping on the graphic itself?”

ChatGPT answer:
To shift the annotation slightly to the right so that it doesn’t overlap the graphic, you can adjust the annotation’s position by modifying the xytext coordinates. This will allow you to move the annotation horizontally while maintaining good legibility.

In my personal opinion, one of Python’s weak points is its graphical interface, which I don’t find very practical compared to Matlab, which for example offers a great deal of freedom when it comes to creating and modifying graphics, based on an interactive version like Illustrator. With Python, to modify or add a detail, you have to redo the entire figure. In other words, you have to rethink the code section so that the elements are strategically placed. With the help of ChatGPT, I was able not only to create more complex graphics, but also prettier and more comprehensible ones. Which is ultimately more practical and faster than sifting through user responses on Stack Overflow!

3- Some limitations

Be careful when using ChatGPT, particularly for individuals without programming experience. While ChatGPT provides confident and detailed answers, it may still make mistakes when completing certain tasks. For instance, errors can occur in creating graphical representations, which may result in misinterpretations (see Figure 1). Or, as far as Machine Learning algorithms are concerned, an experienced person knows that it is imperative not to train a model and predict on the same dataset. This precaution is not automatically taken into account by the LLM, who may sometimes forget how the variables were defined. However, if the error is pointed out, the model can take it into account and adjust the code accordingly. Thus, an inexperienced user could make mistakes by relying on code that works technically, but is methodologically incorrect. Conversely, an experienced programmer will quickly spot these inconsistencies and be able to correct them easily.

My advice is to always visualize your variables, check the dimensions of the data, and compare the results obtained (and plotting figures!). Moreover, if you already have an idea of the expected result, you increase your chances of getting the code right.

Figure 1 : Figure representing the values of the prediction of the number of bikes over time(in red) compared with the real prediction (in blue). We might believe that the predictions are wrong because none of them are synchonized with the real ones, but in fact they are just not ordered with the dates. The code didn’t take that variable into account while plotting the result which can mislead the user that the model was not converging.

Figure 2 : Graph showing prediction values ordered by date. The difference between the two graphs lies in the fact that ChatGPT did not rank the prediction values by date. In the end, the predictions are very good (and the quality of the model can always be verified by calculating the RMSE (root mean square deviation), for example!)

In conclusion:

ChatGPT pleasantly surprised me with the quality and relevance of its answers. It is particularly efficient for writing complex code, while offering clear and accessible explanations of algorithms, even for beginners. However, as mentioned in the last part of this article, it is essential to check the results and the proposed solutions. Still, an experienced programmer will find this tool as a significant time-saver, while a beginner can start learning programming!

Finally, prompt engineering techniques, which consist in formulating effective prompts, can be used to explore more complex subjects. For example, it becomes possible to create more detailed graphs, as is the case with figure 3, where we were able to change the graph font, add legends and even specify the moment showing the first confinement!

Figure 3 : Graph showing actual data (grey curve) and the one predicted using a gradient boosting model (red curve). We can see that the minimum number of bicycles is due to the first confinement, and that the increases in September are due to users who use bicycles more at the start of the school year

So using virtual assistants to create code is a real advantage, enabling you to explore new programming approaches and quickly test different models. These tools also offer the possibility of experimenting with more advanced concepts, optimizing algorithms, and automating certain repetitive tasks. Thanks to this support, developers can concentrate more on innovation and solving complex problems, rather than on technical aspects, which is a considerable time saver!