Facebook Has Released a Machine Learning Tool to Help Engineers Code

Facebook AI has released Aroma, a machine learning tool capable of searching large libraries and making code recommendations to engineers.
Aroma searches codebases and creates recommendations in three stages: feature-based search, rerank and clustering, and intersecting. (Image source: Facebook AI) 

Engineers will often write code that can be similar or identical to code used elsewhere. A tool that allowed programmers to search though the massive codebases of sites like Github would be very valuable in terms of helping engineers learn from one another, extend and modify code, avoid common errors and mistakes, and even perform quality checks.

No such tool has existed in the past. But Facebook's AI team has released a tool that leverages machine learning to give engineers code recommendations to help in their own coding of machine learning-based tools, apps, and algorithms.

Similar to how Google's Image Search feature can conduct a search using an image to find similar and identical images, Facebook's code recommendation engine, dubbed Aroma, can conduct queries using snippets of code to find similar uses of that code elsewhere – giving engineers an easy way to see how other developers may have implemented a particular bit of code in other projects. By leveraging machine learning, Aroma is able to not only find exact matches of the code snippet but also different iterations of it as well as ensuring that no two recommendations are too similar to one another.

According to Facebook's AI team, before Aroma there were no existing tools in place that really addressed the problem of searching large codebases in an efficient and accurate manner. “Documentation tools are not always available and can be out of date, code search tools often return myriad matching results, and it is difficult to immediately find idiomatic usage patterns,” Facebook software engineers Celeste Barnaby, Satish Chandra, and Frank Luan wrote in a blog post. “With Aroma, engineers can easily find common coding patterns without the need to manually go through dozens of code snippets, saving time and energy in their day-to-day development workflow.”

Facebook AI has also published a paper detailing the development and testing of Aroma.

Let's say you've written a bit of code but you want to check to see how others working on similar projects may have implemented it. Seeing things like options other programmers have set or common errors that are handled can help avoid the same pitfalls in your own work.

Aroma can search large codebases for clusters of code snippets that contain the same pattern as yours and generate code recommendations in real time. The tool is also language-agnostic, according to Facebook, and can recognize a number of popular languages including, but not limited to, Python, Javascript, and Java.

Aroma creates its code recommendations by working through three steps: The first step is a feature-based search – essentially Aroma combs through the code, and parses out the most important details. It then uses this to rank code from its codebase based on similarity.

The second step is to cluster the candidates. This is done by pruning each candidate to remove any irrelevant bits of code and re-rank the recommendations. The new list of candidates is then searched for code snippets that are both similar and contain extra coding statements that may be useful to an engineer.

Finally, the code recommendations are checked to make sure none are too similar. This ensures Aroma can return results that are helpful rather than redundant. Ultimately, Aroma takes the engineer's code query, breaks it down into its base components, and uses that base code to find clusters of similar and augmented code, while also removing any redundancies or unhelpful examples.

While developing Aroma Facebook AI engineers tested it against recommendations made by humans on the popular coding discussion site Stack Overflow.

According to the study: “We manually analyzed and categorized the recommendations into several representative categories. We also evaluated Aroma recommendations on 50 partial code snippets, where we found that Aroma can recommend the exact code snippets for 37 queries, and in the remaining 13 cases Aroma recommends alternative recommendations that are still useful.”

On average Aroma is able to return recommendations from a query in 1.6 seconds, according to the researchers.

In their blog post, the Facebook AI engineers said that their hope is Aroma will be a tool to help engineers to easily discover and learn from code that already exists. In the same way that AI is proposed to take on the dull, repetitive tasks associated with automation, allowing human workers to focus on higher-level job functions, Facebook hopes Aroma and tools like it can provide that same advantage for programmers. “...We believe that programming should become a semiautomated task in which humans express higher-level ideas and detailed implementation is done by the computers themselves.”

Chris Wiltz is a Senior Editor at Design News covering emerging technologies including AI, VR/AR, blockchain, and robotics

ESC, Embedded Systems Conference

ESC BOSTON IS BACK!
REGISTER TODAY!

The nation's largest embedded systems conference is back with a new education program tailored to the needs of today's embedded systems professionals, connecting you to hundreds of software developers, hardware engineers, start-up visionaries, and industry pros across the space. Be inspired through hands-on training and education across five conference tracks. Plus, take part in technical tutorials delivered by top embedded systems professionals. Click here to register today!

Comments (1)

Please log in or to post comments.
  • Oldest First
  • Newest First
Loading Comments...