AI Code Translation with Feedback-Driven Quality Control
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for automatically translating program code are inefficient, lack guarantees for functional correctness, and often produce unreadable or non-maintainable code, especially when using large language models (LLMs) or code assistants.
Innovation Solution
A method involving a language model for translating program code, with repeated translations under varied conditions, comparison against a test harness, and evaluation using code and test quality metrics, along with a training process that adjusts the model's weights based on feedback from formal checks and rewards.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If dedicated code translators are used for translation, then translation availability for specific language pairs is improved, but code functionality and maintainability deteriorate
Solution Approach 1:
The patent implements a feedback mechanism where the generated target code is automatically tested against the source code behavior, and the results are used to refine subsequent translations. This ensures functional correctness while maintaining translation availability across language pairs.
Solution Approach 2:
The patent replaces mechanical translation systems with a language model-based approach that uses neural networks to generate code. This substitution enables better translation quality and functionality while maintaining broad language pair support.
2Adaptability or versatility
If dedicated code translators are used for translation, then translation availability for specific language pairs is improved, but code readability and maintainability deteriorate
Solution Approach 1:
The system uses feedback from code execution and testing to improve translation quality. By continuously refining translations based on actual code behavior and readability metrics, the system maintains both availability and maintainability.
Solution Approach 2:
The patent changes parameters such as temperature, max tokens, and other model settings to optimize translation output. These parameter adjustments enable the system to generate readable and maintainable code while preserving translation availability across multiple language pairs.
3Adaptability or versatility
If large language models are used for code translation, then translation creativity and language adaptation are improved, but translation correctness deteriorates
Solution Approach 1:
The patent implements comprehensive feedback mechanisms including automated testing, formal verification, and comparison with source code behavior. This feedback loop ensures that language models produce correct translations while maintaining their creativity and language adaptation capabilities.
Solution Approach 2:
The system performs preliminary actions such as generating multiple translation variants and pre-testing them before final selection. This preliminary verification ensures correctness is maintained while preserving the language model's ability to adapt to different programming languages and styles.
4Reliability
If repeated translation with varied conditions is performed, then translation quality and correctness are improved, but translation time and computational resources deteriorate
Solution Approach 1:
The patent applies partial action by performing a limited number of repeated translations with varied conditions rather than exhaustive repetition. This partial approach achieves sufficient correctness without the time cost of complete exhaustion, balancing quality and efficiency.
Solution Approach 2:
The system changes parameters such as temperature, max tokens, and other model settings to generate diverse translation variants. By strategically adjusting these parameters, the system achieves high correctness through repeated translation while minimizing the time and computational resources required.
Data Source
AI summary
A method for automatically translating program code from a source language to a target language. The method includes: translating a source program code in a source language into a target program code in a target language by means of a language model; repeating the translation with changed conditions, such as changing one or more hyperparameters such as a temperature parameter of the language model, transformations in the source program code, and/or changes in the input to the language model; comparing the source program code and the target program code or codes with a test harness, wherein the test harness is generated automatically; and evaluating the target program code based on code quality metrics, test quality metrics and/or the number of tests.

