Source Code Vector Representation for Error Detection

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Deep learning architectures fail to accurately detect errors in source code, such as duplicate code or software bugs, as they do not consider the latent variables present in the code.

Innovation Solution

The method involves parsing source code into an abstract syntax tree, constructing token embeddings, and using an autoencoder with an encoder and decoder neural network to represent the code in a high-dimensional vector space, maintaining latent variables with high fidelity for error detection.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If deep learning architectures are applied to analyzing source code, then results comparable to or superior to human experts are achieved in general code analysis, but error detection accuracy deteriorates due to failure to consider latent variables

Engineering Contradiction:
Improveerror detection accuracyVSAvoidlatent variables in code
Core Design Contradiction:
Measurement precisionVSLoss of information

Solution Approach 1:

The patent transforms source code into a high-dimensional vector space representation using autoencoders with multiple hidden layers. This dimensional transformation allows the model to capture latent variables that are not apparent in the original code structure, thereby improving error detection accuracy while preserving information about code semantics and relationships.

Inventive Principle:
Principle #17Another dimension (Dimensionality change)

Solution Approach 2:

The patent introduces an autoencoder as an intermediary system between the raw source code and the error detection process. The autoencoder learns to compress and reconstruct code, creating a latent space representation that preserves important semantic information and latent variables, which then serves as input for more accurate error detection.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Loss of information

If source code is represented in vector space using autoencoders, then latent variables are maintained with high fidelity, but computational complexity increases due to encoder-decoder architecture

Engineering Contradiction:
Improvelatent variables preservationVSAvoidencoder-decoder neural network structure
Core Design Contradiction:
Loss of informationVSDevice complexity

Solution Approach 1:

The patent extracts the essential latent variables from source code through the encoder portion of the autoencoder, separating the complex transformation process from the final error detection task. The encoder captures the critical features in a compressed representation, while the decoder reconstructs the code to verify information preservation, thereby managing computational complexity.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent transforms the source code from its original textual form into vector representations through learned parameter transformations in the neural network. By adjusting the dimensions and structure of the vector space representation, the model optimizes the balance between preserving latent variables and managing computational complexity.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS11334467B2Representing source code in vector space to detect errors
Publication Date: 2022.05.17 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US11334467B2 patent drawing
  • US11334467B2 patent drawing
  • US11334467B2 patent drawing

AI summary

A computer-implemented method, system and computer program product for representing source code in vector space. The source code is parsed into an abstract syntax tree, which is then traversed to produce a sequence of tokens. Token embeddings may then be constructed for a subset of the sequence of tokens, which are inputted into an encoder artificial neural network (“encoder”) for encoding the token embeddings. A decoder artificial neural network (“decoder”) is initialized with a final internal cell state of the encoder. The decoder is run the same number of steps as the encoding performed by the encoder. After running the decoder and completing the training of the decoder to learn the inputted token embeddings, the final internal cell state of the encoder is used as the code representation vector which may be used to detect errors in the source code.