Copilot Beta Experience
Say goodbye to programming for Google, experience the Copilot test version
Info
Author: Jeremy, Published on July 29, 2021, Reading time: about 8 minutes, WeChat public account article link:
Recently, OpenAI and GitHub jointly released a code generation tool called Copilot. This tool is developed based on the GPT-3 natural language processing model and uses billions of lines of code on GitHub as training data to automatically provide code suggestions when writing code.
At present, the product has been launched in the Vscode extension. As a novice who has been programming for Google for a long time, I couldn't wait to try it out and fortunately got the opportunity to test it a week or two ago.
After a week of experience, I think Copilot's functionality is more powerful and flexible compared to other code completion tools. Sometimes I even feel like Copilot can really understand my thoughts and code, and its implementation. This significantly improves coding efficiency.
1 GTP-3 behind Copilot¶
GPT-3 is not unfamiliar to everyone-it may be the most popular natural language processing model in 2020, with a training cost close to 5 million yuan and model parameters exceeding 175 billion. It is a self-regressive model, which means that it predicts the probability distribution of the next text based on the front part of a piece of input text. Since its birth, GTP-3 has developed into several large and small different applications, such as some creative writing (poetry, novels, etc.), writing front-end code (debuild.co), and so on.
Lu Xun once said that XXX is the best language. Since GTP-3 is so talented in language, it should also achieve something in writing code. As expected, CodeX-a programming language version based on GTP-3 modification-appeared soon, and Copilot is the first commercial application of CodeX.
2 Copilot experience¶
Copilot Official Website lists four usage directions of Copilot: * Convert comments to code * Automatically fill in repetitive code * Automatically write tests * Provide multiple code schemes
It can be said that if the above four points can really be achieved, it can greatly improve the efficiency of code writing. After obtaining the trial qualification, I tested and experienced it according to the above points. Can it achieve the magical effect mentioned on the official website?
2.1 Writing programs from scratch¶
First, I created a new project and happened to want to check the price of Bitcoin at that time. By the way, let Copilot write me a function! I defined the function I wanted in the comments to see if Copilot could understand my meaning?
Check the video of WeChat public account: []
The first time I ran it, I was really "shocked" by Copilot. It seemed to understand my comments and started to define the function, pushing the incoming arguments to me eagerly, followed by the complete function code. Although there are similar language-to-code generation tools before, in terms of smoothness and accuracy of generated code, personally I feel that Copilot is far ahead of other tools.
2.2 Writing code on an existing project¶
More often, we need to add or modify existing code, including writing functions with similar formats. Sometimes I choose to directly copy and paste the function and then modify it, but if there are many variables to be modified, I often miss, which causes errors during testing. So, in a similar scenario, can Copilot provide us with a more suitable "reference answer"?
I did a simple test with the following code. In the DeepaiImageApi module, I want to pass the image data and image url to the API interface provided by DeepAI through two different functions. After I defined the first function method, let's see if Copilot can directly generate the code I want based on my comments:
The result is amazing! It can be seen that Copilot not only provides function names, codes, and parameter calls that conform to the project code, but also corresponds to the changes in the function content (the "files" parameter passed to "request.post" changes from "image" to "url"). It shows that Copilot does use the code in the local file as the input value of the model, and "understands" the important features of the code well, such as format, norms, structure, etc.
3 Intuitive feeling¶
Overall, although the code generated by Copilot still needs to be checked and adjusted in most cases, its revolutionary code generation effect still amazes me, and sometimes even if the program is already written, I will deliberately press Ctrl+Enter to see Copilot's different ideas and methods.
Finally, I would like to express a little personal opinion. Some people question that Copilot may take away some programmers' jobs after becoming mature, or gradually reduce the ability of programmers to think independently. As a novice programmer, I don't think there is a need to worry about it at present. Copilot feels like a Google specially provided for programmers, or a set of well-organized and fully-indexed code answer libraries. In the face of similar problems encountered by most people, Copilot can improve programming efficiency and reduce the time spent searching for appropriate answers when programming for Google.
On the other hand, GTP-3 is essentially a self-regressive model, and we cannot rely on it to provide us with more innovative algorithms or code solutions. When most programmers are freed from repetitive and boring code, perhaps more human wisdom will be used in innovative work, thereby accelerating the progress of the industry.