Some software developers are now letting artificial intelligence help write their code. They’re finding that AI is just as flawed as humans.
Last June, GitHub, a subsidiary of Microsoft that provides tools for hosting and collaborating on code, released a beta version of a program that uses AI to assist programmers. Start typing a command, a database query, or a request to an API, and the program, called Copilot, will guess your intent and write the rest.
Alex Naka, a data scientist at a biotech firm who signed up to test Copilot, says the program can be very helpful, and it has changed the way he works. “It lets me spend less time jumping to the browser to look up API docs or examples on Stack Overflow,” he says. “It does feel a little like my work has shifted from being a generator of code to being a discriminator of it.”
But Naka has found that errors can creep into his code in different ways. “There have been times where I’ve missed some kind of subtle error when I accept one of its proposals,” he says. “And it can be really hard to track this down, perhaps because it seems like it makes errors that have a different flavor than the kind I would make.”
The risks of AI generating faulty code may be surprisingly high. Researchers at NYU recently analyzed code generated by Copilot and found that, for certain tasks where security is crucial, the code contains security flaws around 40 percent of the time.
The figure “is a little bit higher than I would have expected,” says Brendan Dolan-Gavitt, a professor at NYU involved with the analysis. “But the way Copilot was trained wasn’t actually to write good code—it was just to produce the kind of text that would follow a given prompt.”
Despite such flaws, Copilot and similar AI-powered tools may herald a sea change in the way software developers write code. There’s growing interest in using AI to help automate more mundane work. But Copilot also highlights some of the pitfalls of today’s AI techniques.
While analyzing the code made available for a Copilot plugin, Dolan-Gavitt found that it included a list of restricted phrases. These were apparently introduced to prevent the system from blurting out offensive messages or copying well-known code written by someone else.
Oege de Moor, vice president of research at GitHub and one of the developers of Copilot, says security has been a concern from the start. He says the percentage of flawed code cited by the NYU researchers is only relevant for a subset of code where security flaws are more likely.
De Moor invented CodeQL, a tool used by the NYU researchers that automatically identifies bugs in code. He says GitHub recommends that developers use Copilot together with CodeQL to ensure their work is safe.
The GitHub program is built on top of an AI model developed by OpenAI, a prominent AI company doing cutting-edge work in machine learning. That model, called Codex, consists of a large artificial neural network trained to predict the next characters in both text and computer code. The algorithm ingested billions of lines of code stored on GitHub—not all of it perfect—in order to learn how to write code.
OpenAI has built its own AI coding tool on top of Codex that can perform some stunning coding tricks. It can turn a typed instruction, such as “Create an array of random variables between 1 and 100 and then return the largest of them,” into working code in several programming languages.
Another version of the same OpenAI program, called GPT-3, can generate coherent text on a given subject, but it can also regurgitate offensive or biased language learned from the darker corners of the web.
Copilot and Codex have led some developers to wonder if AI might automate them out of work. In fact, as Naka’s experience shows, developers need considerable skill to use the program, as they often must vet or tweak its suggestions.
Hammond Pearce, a postdoctoral researcher at NYU involved with the analysis of Copilot code, says the program sometimes produces problematic code because it doesn’t fully understand what a piece of code is trying to do. “Vulnerabilities are often caused by a lack of context that a developer needs to know,” he says.
Some developers worry that AI is already picking up bad habits. “We have worked hard as an industry to get away from copy-pasting solutions, and now Copilot has created a supercharged version of that,” says Maxim Khailo, a software developer who has experimented with using AI to generate code but has not tried Copilot.
Khailo says it might be possible for hackers to mess with a program like Copilot. “If I was a bad actor, what I would do would be to create vulnerable code projects on GitHub, artificially boost their popularity by buying GitHub stars on the black market, and hope that it will become part of the corpus for the next training round.”
Both GitHub and OpenAI say that, on the contrary, their AI coding tools are only likely to become less error prone. OpenAI says it vets projects and code both manually and using automated tools.
De Moor at GitHub says recent updates to Copilot should have reduced the frequency of security vulnerabilities. But he adds that his team is exploring other ways of improving the output of Copilot. One is to remove bad examples that the underlying AI model learns from. Another may be to use reinforcement learning, an AI technique that has produced some impressive results in games and other areas, to automatically spot bad output, including previously unseen examples. “Enormous improvements are happening,” he says. “It’s almost unimaginable what it will look like in a year.”
Source: AI Can Write Code Like Humans—Bugs and All | WIRED
- Bebbington, Shaun (2014). “What is coding”. Tumblr. Archived from the original on April 29, 2020. Retrieved March 3, 2014.
- Bebbington, Shaun (2014). “What is programming”. Tumblr. Archived from the original on April 29, 2020. Retrieved March 3, 2014.
- Eliam, Eldad (2005). Reversing: Secrets of Reverse Engineering. Wiley. p. 3. ISBN 978-0-7645-7481-8.
- Koetsier, Teun (2001), “On the prehistory of programmable machines: musical automata, looms, calculators”, Mechanism and Machine Theory, Elsevier, 36 (5): 589–603, doi:10.1016/S0094-114X(01)00005-2.
- Kapur, Ajay; Carnegie, Dale; Murphy, Jim; Long, Jason (2017). “Loudspeakers Optional: A history of non-loudspeaker-based electroacoustic music”. Organised Sound. Cambridge University Press. 22 (2): 195–205. doi:10.1017/S1355771817000103. ISSN 1355-7718.
- Fowler, Charles B. (October 1967). “The Museum of Music: A History of Mechanical Instruments”. Music Educators Journal. 54 (2): 45–49. doi:10.2307/3391092. JSTOR 3391092. S2CID 190524140.
- Noel Sharkey (2007), A 13th Century Programmable Robot, University of Sheffield
- Dooley, John F. (2013). A Brief History of Cryptology and Cryptographic Algorithms. Springer Science & Business Media. pp. 12–3. ISBN 9783319016283.
- Fuegi, J.; Francis, J. (2003). “Lovelace & Babbage and the Creation of the 1843 ‘notes‘“. IEEE Annals of the History of Computing. 25 (4): 16. doi:10.1109/MAHC.2003.1253887.
- da Cruz, Frank (March 10, 2020). “Columbia University Computing History – Herman Hollerith”. Columbia University. Columbia.edu. Archived from the original on April 29, 2020. Retrieved April 25, 2010.
- “Memory & Storage | Timeline of Computer History | Computer History Museum”. http://www.computerhistory.org. Retrieved June 3, 2021.Ridgway, Richard (1952). “Compiling routines”. Proceeding ACM ’52 Proceedings of the 1952 ACM National Meeting (Toronto).
- Ceruzzi, Paul E. (1998). History of Computing. Cambridge, Massachusetts: MIT Press. ISBN 9780262032551 – via EBSCOhost.
- Evans, Claire L. (2018). Broad Band: The Untold Story of the Women Who Made the Internet. New York: Portfolio/Penguin. ISBN 9780735211759.
- Gürer, Denise (1995). “Pioneering Women in Computer Science” (PDF). Communications of the ACM. 38 (1): 45–54. doi:10.1145/204865.204875. S2CID 6626310.
- Smith, Erika E. (2013). “Recognizing a Collective Inheritance through the History of Women in Computing”. CLCWeb: Comparative Literature & Culture: A WWWeb Journal. 15 (1): 1–9 – via EBSCOhost.Sources