IP Library Granted Patent US 11,340,873
Granted Patent B2
US 11,340,873 · App. 16/946,982 · Granted May 24, 2022

Code change graph node matching with machine learning

Inventors: Catalina Codruta Cangea (Mountain View, CA); Qianyu Zhang (Sunnyvale, CA)
Assignee: X DEVELOPMENT LLC
G06F8/33G06N5/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,340,873
App. No.
16/946,982
Granted
May 24, 2022
Kind
B2
Abstract

Implementations are described herein for training and using machine learning to determine mappings between matching nodes of graphs representing predecessor source code snippets and graphs representing successor source code snippets. In various implementations, first and second graphs may be obtained, wherein the first graph represents a predecessor source code snippet and the second graph represents a successor source code snippet. The first graph and the second graph may be applied as inputs across a trained machine learning model to generate node similarity measures between individual nodes of the first graph and nodes of the second graph. Based on the node similarity measures, a mapping may be determined across the first and second graphs between pairs of matching nodes.

Claims (31)

1. A method implemented by one or more processors, the method comprising:

obtaining first and second graphs, wherein the first graph represents a predecessor source code snippet and the second graph represents a successor source code snippet;

applying the first graph and the second graph as inputs across a trained machine learning model to generate node similarity measures between individual nodes of the first graph and nodes of the second graph; and

based on the node similarity measures, determining a mapping across the first and second graphs between pairs of matching nodes.

2. The method of claim 1 , further comprising generating a change graph based on the mapping, wherein the change graph represents one or more edits made to the predecessor source code snippet to yield the successor source code snippet.

3. The method of claim 2 , further comprising applying the change graph as input across another machine learning model to generate a prediction associated with the predecessor source code snippet or the successor source code snippet.

4. The method of claim 1 , wherein the machine learning model comprises a graph matching network (GMN).

5. The method of claim 4 , wherein each node similarity measure of the node similarity measures is based on an attention weight generated by the GMN for a pair of nodes that includes a node from the first graph and a node from the second graph.

6. The method of claim 1 , further comprising eliminating at least some pairs of nodes from the first and second graphs as potential matches based on the at least some pairs of nodes having different types or values.

7. The method of claim 1 , wherein the mapping is further based on relative positions of nodes of each pair of matching nodes within the first and second graphs.

8. A method implemented by one or more processors, the method comprising:

obtaining first and second graphs, wherein the first graph represents a predecessor source code snippet and the second graph represents a successor source code snippet;

calculating a first global similarity measure between the first graph and the second graph using an arithmetic formula that uses counts of nodes in the first and second graphs as operands;

applying the first graph and the second graph as inputs across a first machine learning model to generate a second global similarity measure between the first graph and the second graph;

training the first machine learning model based on a comparison of the first and second global similarity measures; and

extracting, as a second machine learning model, a portion of the first machine learning model that is applicable to generate a plurality of node similarity measures between individual nodes of the first graph and nodes of the second graph.

9. The method of claim 8 , wherein the machine learning model comprises a graph matching network (GMN).

10. The method of claim 9 , wherein each node similarity measure of the plurality of node similarity measures is based on an attention weight generated by the GMN for a pair of nodes that includes a node from the first graph and a node from the second graph.

11. A system comprising one or more processors and memory storing instructions that, in response to execution of the instructions by the one or more processors, cause the one or more processors to:

obtain first and second graphs, wherein the first graph represents a predecessor source code snippet and the second graph represents a successor source code snippet;

apply the first graph and the second graph as inputs across a trained machine learning model to generate node similarity measures between individual nodes of the first graph and nodes of the second graph; and

based on the node similarity measures, determine a mapping across the first and second graphs between pairs of matching nodes.

12. The system of claim 11 , further comprising instructions to generate a change graph based on the mapping, wherein the change graph represents one or more edits made to the predecessor source code snippet to yield the successor source code snippet.

13. The system of claim 12 , further comprising instructions to apply the change graph as input across another machine learning model to generate a prediction associated with the predecessor source code snippet or the successor source code snippet.

14. The system of claim 13 , wherein the prediction comprises a change log entry.

15. The system of claim 13 , wherein the prediction comprises a comment to be embedding into source code.

16. The system of claim 13 , wherein the prediction comprises a coding mistake.

17. The system of claim 11 , wherein the machine learning model comprises a graph matching network (GMN).

18. The system of claim 17 , wherein each node similarity measure of the node similarity measures is based on an attention weight generated by the GMN for a pair of nodes that includes a node from the first graph and a node from the second graph.

19. The system of claim 11 , further comprising eliminating at least some pairs of nodes from the first and second graphs as potential matches based on the at least some pairs of nodes having different types or values.

20. The system of claim 11 , wherein the mapping is further based on relative positions of nodes of each pair of matching nodes within the first and second graphs.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Feb 2, 2023
From: X DEVELOPMENT LLC
To: GOOGLE LLC
Reel/Frame 062572/0565 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 5, 2020
From: CANGEA, CATALINA CODRUTA; ZHANG, QIANYU
To: X DEVELOPMENT LLC
Reel/Frame 053412/0173 →
Continuity (1)
Related Publication 20220019410A1 · Jan 20, 2022
Cited By (12)
US 12,443,462 US 12,511,106 US 12,572,338 US 12,579,011 US 12,585,470 US 12,602,230 US 12,619,480 US 12,639,054 US 12,663,995 US 12,688,019 US 12,705,060 US 12,717,561