Code Analysis via Natural Language Practice Embeddings

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing automated code analysis systems face challenges in scaling to accommodate the increasing number of programming languages and best practices, as they require rigorous modeling of program data and control flows, manual analysis of code examples, and crafting of static and dynamic analysis rules, making it difficult to efficiently detect coding issues and promote best practices.

Innovation Solution

A machine learning-based approach using deep learning techniques to analyze code according to natural language descriptions of coding practices, where a machine learning model is trained to learn fine-grained bimodal embeddings of code and text, enabling automated detection of conforming or violating code snippets, even when rich program behavior signals are not available, and can be fine-tuned with pre-training and fine-tuning on auxiliary datasets.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If automated code analysis systems use traditional rule-based approaches with manual analysis of code examples, then they can detect coding issues with reasonable accuracy, but they face challenges in scaling to accommodate the increasing number of programming languages and best practices

Engineering Contradiction:
Improveability to accommodate new programming languages and best practicesVSAvoidcomplexity of modeling program data and control flows, manual analysis, and rule crafting
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent replaces the mechanical system of manual rule-based code analysis with a neural network-based automated system. The neural network model learns coding practices and detects violations automatically without requiring manual crafting of analysis rules for each programming language, thereby reducing the complexity of scaling to new languages and best practices.

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

Solution Approach 2:

The patent uses fine-tuned neural network models that can be copied and adapted across different programming languages. Once a model is trained on one language, it can be fine-tuned for other languages by providing auxiliary datasets, enabling rapid scaling without recreating the entire analysis system from scratch for each new language.

Inventive Principle:
Principle #26Copying

2Reliability

If automated code analysis systems manually craft static and dynamic analysis rules for each coding practice, then they can provide detailed code review feedback, but the process becomes time-consuming and difficult to maintain

Engineering Contradiction:
Improveaccuracy of coding practice detectionVSAvoidtime required for manual analysis and rule crafting
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent performs preliminary training of neural network models on large datasets of code examples that embody various coding practices. This pre-learning process enables the model to automatically detect coding issues without requiring manual rule crafting at the time of code analysis, significantly reducing the time required while maintaining high detection accuracy.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The neural network model serves itself by automatically learning coding practices from training data and applying this knowledge to detect violations in new code. The system does not require continuous manual intervention for rule creation and maintenance, as it can autonomously adapt to new programming languages and best practices through fine-tuning on auxiliary datasets.

Inventive Principle:
Principle #25Self-service

3Measurement precision

If code analysis tools require rich program behavior signals for accurate analysis, then they can detect subtle coding issues, but they cannot analyze code when such signals are not available

Engineering Contradiction:
Improveprecision of coding issue detectionVSAvoidability to analyze code without rich program behavior signals
Core Design Contradiction:
Measurement precisionVSAdaptability or versatility

Solution Approach 1:

The patent changes the input parameters accepted by the code analysis system. Instead of requiring rich program behavior signals, the neural network model can operate with simpler inputs such as code text alone or with minimal metadata. The model learns to detect coding practices and issues from the code structure and patterns directly, enabling analysis in scenarios where comprehensive program behavior data is unavailable.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS11604626B1Analyzing code according to natural language descriptions of coding practices
Publication Date: 2023.03.14 AMAZON TECH INC
  • US11604626B1 patent drawing
  • US11604626B1 patent drawing
  • US11604626B1 patent drawing

AI summary

Code may be analyzed according to natural language descriptions of coding practices. A practice for code written in a natural language description may be received. An embedding of the natural language description may be generated using a machine learning model trained to detect examples of practices. The embedding may be compared with embeddings of code portions stored in an index to detect one or more portions of code that satisfy a facet of the practice. The detected portions of code may be identified.