Source Code Retrieval via Semantic Vector Mapping

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current code searching systems are ineffective in providing relevant source code results to users due to the mismatch between high-level user intent and low-level implementation, as they rely on information retrieval methods that fail to account for the semantic differences between programming languages and natural languages.

Innovation Solution

A deep neural network-based code analysis system that extracts features from training code, maps them to natural language code vectors, and compares these vectors with user-generated search queries to suggest relevant source code, utilizing techniques like joint embedding to improve the accuracy and relevance of search results.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If traditional information retrieval methods are used for code searching, then the system complexity remains low, but the search accuracy and relevance deteriorate due to semantic mismatch between natural language and programming languages

Engineering Contradiction:
Improvesearch accuracyVSAvoidsystem complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent introduces natural language code vectors as an intermediary representation that bridges the semantic gap between user queries in natural language and source code in programming languages. The deep neural network transforms both the user query and code features into this shared vector space, enabling accurate semantic matching without requiring complex traditional information retrieval systems

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent replaces traditional mechanical information retrieval mechanisms (keyword matching, indexing) with a deep neural network-based semantic embedding system. This substitution uses learned representations in a continuous vector space to capture semantic relationships, achieving higher search accuracy while the neural network handles the complexity internally

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

2Measurement precision

If deep neural network-based semantic mapping is implemented, then search result relevance improves, but computational resource consumption increases

Engineering Contradiction:
Improvesearch result relevanceVSAvoidcomputational resource consumption
Core Design Contradiction:
Measurement precisionVSUse of energy by moving object

Solution Approach 1:

The patent performs preliminary action by pre-computing and storing natural language code vectors for training code during an offline training phase. This pre-processing creates a ready-to-use vector representation that can be quickly compared against user queries without requiring intensive real-time computation, thus improving search efficiency while maintaining high relevance

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent changes the parameter representation from raw code text to compressed vector embeddings. By transforming code features into condensed vector representations that capture essential semantic information, the system reduces the dimensionality and computational complexity of subsequent search operations while preserving search result relevance

Inventive Principle:
Principle #35Parameter changes

3Reliability

If detailed feature extraction from training code is performed, then the quality of code vectors improves, but the processing time and computational load increase

Engineering Contradiction:
Improvecode vector qualityVSAvoidprocessing time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent applies extraction by selectively identifying and extracting key features from training code (code snippets, software documentation, code comments) that are most relevant to semantic understanding. This targeted extraction focuses computational resources on the most informative elements, improving code vector quality without requiring exhaustive analysis of all code components

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent uses partial action by extracting and processing only the essential features needed for effective code representation (such as documentation, comments, and key code snippets) rather than analyzing every aspect of the codebase. This partial extraction achieves sufficient vector quality for accurate search while significantly reducing processing time and computational load

Inventive Principle:
Principle #16Partial or excessive action

Data Source

PatentUS11651014B2Source code retrieval
Publication Date: 2023.05.16 FUJITSU LTD
  • US11651014B2 patent drawing
  • US11651014B2 patent drawing
  • US11651014B2 patent drawing

AI summary

A method may include obtaining training code and extracting features from the training code. The extracted features of the training code may be mapped to natural language code vectors by a deep neural network. A natural language search query requesting source-code suggestions may be received, and the natural language search query may be mapped to a natural language search vector by the deep neural network. The method may include mapping the natural language search query to the natural language search vector in the same or a similar method as mapping the extracted features of the training code to natural language code vectors, and the natural language search vector may be compared to the natural language code vectors. Source code responsive to the natural language search query may be suggested based on the comparison between the natural language search vector and the natural language code vectors.