Refactoring and/or rearchitecting source code using machine learning
AssigneeGoogle Inc.
InventorsBin Ni, Joshua Howland
Life of this patent
Estimating the term…
Abstract
Implementations are described herein for leveraging machine learning to automate source code refactoring and/or rearchitecting. In various implementations, one or more ground truth boundaries may be removed from one or more boundaried source code files to produce one or more boundary-less source code files. One or more of the boundary-less source code files may be processed using a machine learning model to predict one or more candidate boundaries for reintroduction into the one or more boundary-less source code files. The one or more ground truth boundaries may be compared with the one or more predicted candidate boundaries. The machine learning model may be trained based on the comparing.
Claims19
A method implemented using one or more processors and comprising:
- creating a training set that includes boundaried source code files and corresponding boundary-less source code files, wherein the creating includes removing ground truth boundaries from the boundaried source code files to produce the boundary-less source code files;
- processing the training set using a machine learning model to predict candidate boundaries for reintroduction into the boundary-less source code files;
- comparing the ground truth boundaries of the boundaried source code files with the predicted candidate boundaries to determine one or more errors;
- and
- training the machine learning model based on the one or more errors to minimize a loss function of the machine learning model.
A method for predicting one or more candidate boundaries for incorporation into source code, the method implemented using one or more processors and comprising:
- processing one or more boundary-deficient source code files using a machine learning model to predict the one or more candidate boundaries for introduction into the one or more boundary-deficient source code files, wherein the machine learning model comprises an encoder-decoder model that was trained previously using training examples comprising source code with boundaries removed, wherein the removed boundaries were used during training of the machine learning model as labels to determine error(s) and wherein the error(s) was used to train the machine learning model to minimize a loss function associated with the encoder-decoder model;
- and
- providing output indicative of one or more of the predicted candidate boundaries.
A system comprising one or more processors and memory storing instructions that, in response to execution of the instructions, cause the one or more processors to:
- create a training set that includes boundaried source code files and corresponding boundary-less source code files, wherein the instructions to create include instructions to remove ground truth boundaries from the more boundaried source code files to produce the boundary-less source code files;
- process the training set using a machine learning model to predict candidate boundaries for reintroduction into the boundary-less source code files;
- compare the ground truth boundaries of the boundaried source code files with the predicted candidate boundaries to determine an error;
- and
- train the machine learning model based on the error to minimize a loss function of the machine learning model.
Dependencies are inferred from the claim text.