IP Library Granted Patent US 12,093,672
Granted Patent B2
US 12,093,672 · App. 18/076,189 · Granted Sep 17, 2024

Iterative neural code translation

Inventors: Giovanni De Toni (Recoaro Terme, IT); Rishabh Singh (San Jose, CA); Jonathan Malmaud (Campbell, CA); Navneet Potti (Sunnyvale, CA)
Assignee: GOOGLE LLC
G06F8/51G06F8/42G06F11/3616G06N3/0455G06N3/08
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 12,093,672
App. No.
18/076,189
Granted
Sep 17, 2024
Kind
B2
Abstract

Techniques are described herein for iterative code generation using neural language models. In various implementations, an original source code snippet in a first programming language may be processed using a translation machine learning model to generate a first translation of the original source code snippet in a second programming language. The first translation of the original source code snippet may be evaluated to identify error(s) in the first translation. Based on the error(s), respective mask(s) may be inserted to generate a masked first translation of the original source code snippet in the second programming language. The masked first translation of the original source code snippet may be processed using the translation machine learning model to generate a second translation of the original source code snippet in the second language. The second translation may include infill(s) of corrected source code in place of one or more of the masks.

Claims (35)

1. A method implemented using one or more processors and comprising:

processing an original source code snippet in a first programming language using a translation machine learning model to generate a first translation of the original source code snippet in a second programming language;

evaluating the first translation of the original source code snippet to identify one or more errors in the first translation of the original source code snippet;

based on the one or more errors in the first translation of the original source code snippet, inserting one or more respective masks to generate a masked first translation of the original source code snippet in the second programming language; and

processing the masked first translation of the original source code snippet using the translation machine learning model to generate a second translation of the original source code snippet in the second language, wherein the second translation includes one or more infills of corrected source code in place of one or more of the masks.

2. The method of claim 1 , wherein the masked first translation of the original source code snippet is processed using the translation machine learning model in conjunction with the original source code snippet in the first programming language.

3. The method of claim 2 , wherein the masked first translation of the original source code snippet is processed using the translation machine learning model as a prefix.

4. The method of claim 3 , wherein the translation machine learning model comprises an encoder and a decoder, the original source code snippet is processed using the encoder, and the masked first translation of the original source code snippet is processed as the prefix using the decoder.

5. The method of claim 1 , wherein the evaluation of the first translation of the original source code snippet is performed using a static analyzer or a syntax checker.

6. The method of claim 1 , wherein the evaluation of the first translation of the original source code snippet is performed by compiling the first translation to generate an executable program, and executing the executable program using one or more test cases.

7. The method of claim 1 , wherein the evaluation of the first translation of the original source code snippet is performed using one or more confidence properties of the translation machine learning model.

8. The method of claim 1 , wherein the evaluation of the first translation of the original source code snippet is performed using a machine learning model trained to detect errors in source code.

9. The method of claim 1 , wherein the masked first translation of the original source code snippet is processed with a greater beam width than the original source code snippet.

10. The method of claim 1 , wherein the one or more errors comprise a first error, the one or more masks comprise a first mask, the second translation includes a first infill of corrected source code in place of the first mask, and the method further comprises:

evaluating the second translation of the original source code snippet to identify a second error in the second translation of the original source code snippet;

based on the second error in the second translation of the original source code snippet, inserting a second mask to generate a masked second translation of the original source code snippet in the second programming language; and

processing the masked second translation of the original source code snippet using the translation machine learning model to generate a third translation of the original source code snippet in the second language, wherein the third translation includes a second infill of corrected source code in place of the second mask.

11. The method of claim 1 , wherein the inserting comprises replacing the one or more errors with the one or more masks.

12. A method implemented using one or more processors and comprising:

processing an original source code snippet in a first domain using a neural language model to generate a first translation of the original source code snippet in a second domain;

evaluating the first translation of the original source code snippet to identify one or more errors in the first translation of the original source code snippet in the second domain;

based on the one or more errors in the first translation of the original source code snippet, inserting one or more respective masks to generate a masked first translation of the original source code snippet in the second domain; and

processing the masked first translation of the original source code snippet using the neural language model to generate a second translation of the original source code snippet in the second domain, wherein the second translation includes one or more infills of corrected source code in place of one or more of the masks.

13. The method of claim 12 , wherein the masked first translation of the original source code snippet is processed using the neural language model in conjunction with the original source code snippet.

14. The method of claim 13 , wherein the masked first translation of the original source code snippet is processed using the neural language model as a prefix.

15. The method of claim 14 , wherein the neural language model comprises an encoder and a decoder, the original source code snippet is processed using the encoder, and the masked first translation of the original source code snippet is processed as the prefix using the decoder.

16. The method of claim 12 , wherein the evaluation of the first translation of the original source code snippet is performed using a static analyzer, compiler, and/or a syntax checker.

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

process an original source code snippet in a first programming language using a translation machine learning model to generate a first translation of the original source code snippet in a second programming language;

evaluate the first translation of the original source code snippet to identify one or more errors in the first translation of the original source code snippet;

based on the one or more errors in the first translation of the original source code snippet, insert one or more respective masks to generate a masked first translation of the original source code snippet in the second programming language; and

process the masked first translation of the original source code snippet using the translation machine learning model to generate a second translation of the original source code snippet in the second language, wherein the second translation includes one or more infills of corrected source code in place of one or more of the masks.

18. The system of claim 17 , wherein the masked first translation of the original source code snippet is processed using the translation machine learning model in conjunction with the original source code snippet in the first programming language.

19. The system of claim 18 , wherein the masked first translation of the original source code snippet is processed using the translation machine learning model as a prefix.

20. The system of claim 19 , wherein the translation machine learning model comprises an encoder and a decoder, the original source code snippet is processed using the encoder, and the masked first translation of the original source code snippet is processed as the prefix using the decoder.

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 Dec 8, 2022
From: DE TONI, GIOVANNI; SINGH, RISHABH; MALMAUD, JONATHAN; POTTI, NAVNEET
To: X DEVELOPMENT LLC
Reel/Frame 062027/0614 →
Continuity (1)
Related Publication 20240184555A1 · Jun 6, 2024