Transformer Encoder-Decoder for Code Repair

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Pretrained neural networks fail to effectively localize and repair 'smelly' code blocks due to their encoder-only architecture, which requires both encoder and decoder capabilities for precise syntactical and semantic understanding of buggy code.

Innovation Solution

The NSEDIT model employs a neural-symbolic edit-based architecture using a transformer encoder-decoder framework with a pointer network to predict editing sequences directly on source code, incorporating a finite state machine for beam search and reranking to improve accuracy.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If encoder-only models are used for code understanding tasks, then code classification and code search performance is improved, but code repair capability deteriorates due to lack of decoder functionality

Engineering Contradiction:
Improvecode understanding accuracyVSAvoidcode repair capability
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The model is segmented into distinct encoder and decoder components. The encoder processes the buggy code to generate contextual representations, while the decoder generates repair sequences. This segmentation allows each component to specialize in its function, resolving the contradiction between understanding accuracy and repair capability.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The transformer model is designed to perform multiple functions: the encoder handles code understanding tasks (classification, search) while the decoder handles code repair tasks. This multi-functionality allows a single model architecture to address both code understanding and code repair, eliminating the need to choose between them.

Inventive Principle:
Principle #6Universality (Multi-functionality)

2Productivity

If pretrained neural networks are used for code tasks, then code classification and code search performance is improved, but localization and repair of smelly code blocks remains unsatisfactory

Engineering Contradiction:
Improvecode understanding efficiencyVSAvoidbug localization accuracy
Core Design Contradiction:
ProductivityVSMeasurement precision

Solution Approach 1:

The model introduces an intermediary representation layer that bridges code understanding and bug localization. The encoder generates contextual embeddings that serve as intermediaries between the input code and the repair output, enabling precise localization of buggy code blocks while maintaining efficient processing.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent replaces traditional mechanical bug localization methods (manual inspection, static analysis) with a neural-based approach. The transformer model automatically localizes bugs through learned representations, achieving both high efficiency and precise localization without manual intervention.

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

3Reliability

If manual code review is performed, then code quality can be ensured, but time consumption and labor costs increase significantly

Engineering Contradiction:
Improvecode qualityVSAvoidcode review time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The system enables code to be self-diagnosed and self-repaired through the neural model. The model automatically identifies bugs and generates repair sequences without human intervention, allowing code to service itself and eliminating the need for time-consuming manual reviews while maintaining code quality.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The model incorporates feedback mechanisms where the decoder's repair suggestions can be evaluated and refined. This feedback loop ensures code quality by continuously improving repair accuracy based on evaluation results, while maintaining fast automated processing that eliminates manual review time.

Inventive Principle:
Principle #23Feedback

Data Source

PatentUS12079106B1Transformer-based bug fixing
Publication Date: 2024.09.03 AMAZON TECH INC
  • US12079106B1 patent drawing
  • US12079106B1 patent drawing
  • US12079106B1 patent drawing

AI summary

Techniques for determining buggy code are described. An encoder/decoder-based (e.g., transformer-based) model approach is described. In some embodiments, a service receives request to perform transformer-based bug fixing on code, performs bug fixing inference to the code by applying a trained encoder/decoder-based model, and reports out a result of the inference, wherein the output includes an indication of a location of a potential edit to be made in the code and the potential edit in the code.