IP Library Granted Patent US 11,150,877
Granted Patent B2
US 11,150,877 · App. 16/676,032 · Granted Oct 19, 2021

Automatically generating machine learning models for software tools that operate on source code

Inventors: Marko Ivankovic (Mountain View, CA); Vedrana Jankovic (Mountain View, CA)
Assignee: Google LLC
G06F8/34G06F8/40G06N5/04G06N20/00
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,150,877
App. No.
16/676,032
Filed
Nov 6, 2019
Granted
Oct 19, 2021
Kind
B2
Examiner
WU, DAXIN
Art Unit
2191
USPC
717/109
Abstract

A method includes receiving a code insight request requesting a code insight for target source code. The code insight request includes the target source code and a tool type indicator specifying that the software development tool comprises one of a code labeling type of software development tool or a code transformation type of software development tool. The method also includes obtaining a machine learning model based on the tool type indicator and generating the code insight using the machine learning model. The code insight includes one of a predicted label for the target source code when the tool type indicator specifies that the software development tool comprises the code labeling type of software development tool, or a predicted code transformation for the target source code when the tool type indicator specifies that the software development tool comprises the code transformation type of software building tool.

Claims (84)

1. A method comprising:

receiving, at data processing hardware, a code insight request requesting a code insight for target source code from a developer device associated with a developer using the target source code to build a software development tool, the code insight request comprising:

the target source code, wherein the target source code comprises a pair of target source code snippets from a target codebase; and

a tool type indicator specifying that the software development tool comprises one of a code labeling type of software development tool or a code transformation type of software development tool;

obtaining, by the data processing hardware, a machine learning model based on the tool type indicator, the machine learning model trained on training source code associated with the specified one of the code labeling type of software development tool or the code transformation type of software development tool;

generating, by the data processing hardware, the code insight for the target source code using the machine learning model, the code insight for the target source code comprising one of:

a predicted label for the target source code when the tool type indicator specifies that the software development tool comprises the code labeling type of software development tool; or

a predicted code transformation for the target source code when the tool type indicator specifies that the software development tool comprises the code transformation type of software building tool; and

transmitting, by the data processing hardware, the code insight to the developer device, the code insight when received by the developer device causing a graphical user interface executing on the developer device to display the code insight on a display screen of the developer device,

wherein generating the code insight for the target source code using the machine learning model comprises:

for each target source code snippet in the pair of target source code snippets, generating a vector representation for the corresponding target source code snippet using the machine learning model configured to receive a set of target features extracted from the corresponding target source code snippet as feature inputs;

determining a vector-space distance between the pair of target source code snippets based on the vector representations; and

determining the pair of target source code snippets are duplicates of one another when the vector-space distance satisfies a distance threshold.

2. The method of claim 1 , further comprising:

extracting, by the data processing hardware, a set of target features from the target source code, the set of target features corresponding to a syntactic representation of the target source code that is suitable for input to the machine learning model,

wherein the machine learning model is configured to:

receive the set of target features as input; and

generate the code insight for the target source code as output.

3. The method of claim 2 , wherein the syntactic representation of the target source code comprises an abstract syntax tree.

4. The method of claim 1 , wherein obtaining the machine learning model comprises generating the machine learning model in response to receiving the code insight request by:

selecting, from a source code repository stored on memory hardware in communication with the data processing hardware, the training source code associated with the specified one of the code labeling type of software development tool or the code transformation type of software development tool; and

training, using a machine learning model generator, the machine learning model on the selected training source code.

5. The method of claim 4 , further comprising extracting, by the data processing hardware, a set of training features from the selected training source code, the set of training features corresponding to a syntactic representation of the training source code that is suitable for training the machine learning model.

6. The method of claim 5 , wherein the syntactic representation of the training source code comprises an abstract syntax tree.

7. The method of claim 1 , further comprising:

identifying, by the data processing hardware, from a source code repository stored on memory hardware in communication with the data processing hardware, training examples of the training source code paired with human-generated comments based on a review cycle of the training source code; and

training, by the data processing hardware, the machine learning model on the training examples comprising the training source code paired with the human-generated comments.

8. The method of claim 1 , further comprising, when the predicted code transformation for the target source code comprises executable code, training, by the data processing hardware, the machine learning model on training examples comprising the training source code paired with corresponding training executable code resulting from compiling or interpreting the training source code.

9. The method of claim 1 , wherein generating the code insight for the target source code using the machine learning model comprises:

determining similarity scores for a pool of training source code snippets stored in memory hardware in communication with the data processing hardware, each similarity score associated with a corresponding training source code snippet and indicating a level of similarity between the vector representation for the target source code and a respective vector representation for the corresponding training code snippet; and

identifying one or more training source code snippets from the pool of training source code snippets that have similarity scores satisfying a similarity threshold as corresponding to mutations of the target source code.

10. The method of claim 1 , wherein the predicted label for the training source code comprises at least one of:

a predicted level of complexity of the target source code;

a predicted quality of the target source code;

a predicted testing requirement for the target source code; or

a predicted difficulty rating of the target source code.

11. The method of claim 1 , wherein the predicted code transformation for the target source code comprises at least one of:

updated target source code fixing a build error in the target source code;

executable code interpreted/compiled from the target source code;

a revision to the target source code; or

suggested replacement source code for replacing the target source code.

12. A system comprising:

data processing hardware; and

memory hardware in communication with the data processing hardware and storing instructions that when executed on the data processing hardware cause the data processing hardware to perform operations comprising:

receiving a code insight request requesting a code insight for target source code from a developer device associated with a developer using the target source code to build a software development tool, the code insight request comprising:

the target source code, wherein the target source code comprises a pair of target source code snippets from a target codebase; and

a tool type indicator specifying that the software development tool comprises one of a code labeling type of software development tool or a code transformation type of software development tool;

obtaining a machine learning model based on the tool type indicator, the machine learning model trained on training source code associated with the specified one of the code labeling type of software development tool or the code transformation type of software development tool;

generating the code insight for the target source code using the machine learning model, the code insight for the target source code comprising one of:

a predicted label for the target source code when the tool type indicator specifies that the software development tool comprises the code labeling type of software development tool; or

a predicted code transformation for the target source code when the tool type indicator specifies that the software development tool comprises the code transformation type of software building tool; and

transmitting the code insight to the developer device, the code insight when received by the developer device causing a graphical user interface executing on the developer device to display the code insight on a display screen of the developer device,

wherein generating the code insight for the target source code using the machine learning model comprises:

for each target source code snippet in the pair of target source code snippets, generating a vector representation for the corresponding target source code snippet using the machine learning model configured to receive a set of target features extracted from the corresponding target source code snippet as feature inputs;

determining a vector-space distance between the pair of target source code snippets based on the vector representations; and

determining the pair of target source code snippets are duplicates of one another when the vector-space distance satisfies a distance threshold.

13. The system of claim 12 , wherein the operations further comprise:

extracting a set of target features from the target source code, the set of target features corresponding to a syntactic representation of the target source code that is suitable for input to the machine learning model,

wherein the machine learning model is configured to:

receive the set of target features as input; and

generate the code insight for the target source code as output.

14. The system of claim 13 , wherein the syntactic representation of the target source code comprises an abstract syntax tree.

15. The system of claim 12 , wherein obtaining the machine learning model comprises generating the machine learning model in response to receiving the code insight request by:

selecting, from a source code repository stored on the memory hardware, the training source code associated with the specified one of the code labeling type of software development tool or the code transformation type of software development tool; and

training, using a machine learning model generator, the machine learning model on the selected training source code.

16. The system of claim 15 , wherein the operations further comprise extracting a set of training features from the selected training source code, the set of training features corresponding to a syntactic representation of the training source code that is suitable for training the machine learning model.

17. The system of claim 16 , wherein the syntactic representation of the training source code comprises an abstract syntax tree.

18. The system of claim 12 , wherein the operations further comprise:

identifying from a source code repository stored on the memory hardware, training examples of the training source code paired with human-generated comments based on a review cycle of the training source code; and

training the machine learning model on the training examples comprising the training source code paired with the human-generated comments.

19. The system of claim 12 , wherein the operations further comprise, when the predicted code transformation for the target source code comprises compiled or interpreted code, training the machine learning model on training examples comprising the training source code paired with corresponding training executable code resulting from compiling or interpreting the training source code.

20. The system of claim 12 , wherein generating the code insight for the target source code using the machine learning model comprises:

determining similarity scores for a pool of training source code snippets stored in the memory hardware, each similarity score associated with a corresponding training code snippet and indicating a level of similarity between the vector representation for the target source code and a respective vector representation for the corresponding training code snippet; and

identifying one or more training source code snippets from the pool of training source code snippets that have similarity scores satisfying a similarity threshold as corresponding to mutations of the target source code.

21. The system of claim 12 , wherein the predicted label for the training source code comprises at least one of:

a predicted level of complexity of the target source code;

a predicted quality of the target source code;

a predicted testing requirement for the target source code; or

a predicted difficulty rating of the target source code.

22. The system of claim 12 , wherein the predicted code transformation for the target source code comprises at least one of:

updated target source code fixing a build error in the target source code;

executable code interpreted/compiled from the target source code;

a revision to the target source code; or

suggested replacement source code for replacing the target source code.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Nov 7, 2019
From: IVANKOVIC, MARKO; JANKOVIC, VEDRANA
To: GOOGLE LLC
Reel/Frame 050941/0170 →
Continuity (1)
Related Publication 20210132915A1 · May 6, 2021
Cited By (3)
US 12,314,707 US 12,487,819 US 12,699,556