New AI Writes Computer Code: Still Not Skynet, But It’s Learning

Sometimes, when you feed an AI content from the Internet, it learns natural language. Sometimes, it reads the entire contents of GitHub and learns to produce simple snippets of code.
This is the story of what happens when the AI does both.
Neural networks are all the rage these days. From Siri to self-driving, to protein folding and medical diagnostics, the powerful duo of machine learning and big data is taking over. Neural nets started out as one-trick ponies: a Markov chain generated a gobbledygook whitepaper that got accepted as a non-reviewed paper to the (“spammy and having low standards”) 2005 WMSCI conference. A Markov chain generated the Kafkaesque glory of “Garkov.” Another was capable of making trippy images where everything looked like an eyeball or a cat.
The reach of AI still exceeds its grasp. Failures and successes in facial recognition software expose both AI’s limitations and how even machine learning is susceptible to the implicit biases of datasets and programmers. But we’ve come a long way from SmarterChild. Every year, we build on what we’ve done before.
You can train an AI to produce prose so close to natural language that humans have trouble telling who wrote it: man or machine. Last year, people at OpenAI Labs (with which Microsoft is an exclusive partner) cooked up a model called GPT-3 that could blog, Tweet, and argue. They trained it using part of the Common Crawl dataset, which includes Wikipedia and a whole ton of books, among other subsets of prose and code. But the Common Crawl also indexes GitHub. When GPT-3 was exposed to the vast swathes of Common Crawl data, it learned to produce prose — but it also learned by osmosis to produce snippets of intelligible computer code.
Intrigued, the OpenAI team made another version of the GPT-3 model and dubbed it Codex, and trained it on a truly colossal set of prose from the Common Crawl and computer code from GitHub and elsewhere. (Codex has entered private beta, but the technology is actually already in use by GitHub, which uses it to power an intelligent code-suggestion tool named Copilot.) OpenAI Codex is a fluent AI that can take a natural-language prompt as input, and generate code for the task it was given. It’s great — sometimes.
The great strength of Codex is its fluency. It can generate code in 12 languages, and its resilient handling of natural language input is extremely powerful. But that’s also a key weakness. Coding is tedious because it’s so detail-sensitive, but natural language is messy and context-dependent. Typos or bad logic can both wreck the function of an entire piece of otherwise solid software. And there’s good code and bad code and just plain weird code posted on the web.
Codex is susceptible to the same problem. Unlike a Markov chain, Codex keeps a record of its actions in a cache, but its scope is still limited and shallow. It’s constrained in the abstract by the rigid syntax and logic rules of programming. It’s also constrained by the patterns and implicit rules in the actual data it uses. And if we don’t tell it to interpolate, it won’t.
In other words, while Codex can return code that does what you want, it doesn’t know why you want that function, and its reasoning won’t necessarily be obvious. It’s like writing a mathematical proof: there may be multiple paths to the same answer, some of them meandering. Sometimes Codex returns code that looks nothing like what a human programmer might do, but sure enough, it accomplishes the same thing. Sometimes, its code has security flaws or just won’t run at all. Thirty-seven percent of the time, it works all the time.
Codex is so robust in part because of the strength of its datasets. Common Crawl indexes a great many things, including WordPress, Blogspot, LiveJournal, archive.org, and a ton of .edu content.


