Neural Network Code Translation via Natural Language Latent Representation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Computer software programming often requires developers to manually translate source code from one programming language to another, which is inefficient due to lack of expertise in the target language, leading to prolonged client device resource usage and inefficiencies.

Innovation Solution

Implementing a machine learning model, such as a neural network, to automatically translate source code from a base programming language to a target programming language, using a base-to-natural language and natural language-to-target model, eliminating the need for human intervention and reducing resource usage.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If programmers manually translate source code from base programming language to target programming language, then code translation can be performed with human understanding, but programmer time and client device resource usage are excessively prolonged

Engineering Contradiction:
Improvecode translation accuracyVSAvoidprogrammer time and device usage time
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The patent introduces natural language descriptions as an intermediary between source code and target code. The translation system first generates natural language descriptions of the source code semantics, then uses these descriptions to generate target code. This intermediary approach enables accurate semantic preservation while automating the translation process, resolving the contradiction between translation accuracy and time efficiency.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent replaces the mechanical manual translation process with an automated neural network-based system. Instead of programmers manually translating code, the system uses trained neural networks to perform translation automatically, significantly reducing programmer time and device resource usage while maintaining translation quality through learned semantic mappings.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

2Ease of manufacture

If programmers with lesser expertise in target language manually translate code, then translation can be performed without new programmers, but translation efficiency is highly reduced and device resources are excessively used

Engineering Contradiction:
Improvetranslation process feasibilityVSAvoidcode translation efficiency
Core Design Contradiction:
Ease of manufactureVSProductivity

Solution Approach 1:

The translation system performs translation automatically without requiring human programmers to manually translate code. The neural network models self-service the translation task by learning from training data and autonomously generating target code from source code, eliminating the need for programmers with target language expertise and dramatically improving translation productivity.

Inventive Principle:
Principle #25Self-service

3Adaptability or versatility

If base-to-target language pairs are non-existent for training, then model generalization is improved, but training data availability is reduced

Engineering Contradiction:
Improvemodel generalization capabilityVSAvoidtraining data availability
Core Design Contradiction:
Adaptability or versatilityVSQuantity of substance

Solution Approach 1:

The patent uses natural language descriptions as a universal intermediary that bridges different programming languages. Instead of requiring parallel base-to-target code pairs for each language combination, the system trains models to translate code to natural language descriptions and from natural language descriptions to target code. This approach enables translation between any language pairs using a common natural language intermediary, greatly improving model versatility without needing extensive language-specific training data.

Inventive Principle:
Principle #24Intermediary (Mediator)

Data Source

PatentUS11960867B1Using natural language latent representation in automated conversion of source code from base programming language to target programming language
Publication Date: 2024.04.16 GOOGLE LLC
  • US11960867B1 patent drawing
  • US11960867B1 patent drawing
  • US11960867B1 patent drawing

AI summary

Using a natural language (NL) latent presentation in the automated conversion of source code from a base programming language (e.g., C++) to a target programming language (e.g., Python). A base-to-NL model can be used to generate an NL latent representation by processing a base source code snippet in the base programming language. Further, an NL-to-target model can be used to generate a target source code snippet in the target programming language (that is functionally equivalent to the base source code snippet), by processing the NL latent representation. In some implementations, output(s) from the NL-to-target model indicate canonical representation(s) of variables, and in generating the target source code snippet, technique(s) are used to match those canonical representation(s) to variable(s) of the base source code snippet. In some implementations, multiple candidate target source code snippets are generated, and a subset (e.g., one) is selected based on evaluation(s).