Code Recommendation Model Using Dependency Data

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing code recommendation tools lack accuracy in predicting codes, as they rely solely on previous or current code segments without considering code dependence information, leading to inefficient development processes.

Innovation Solution

A method and apparatus for code recommendation that acquires relevant code segments and code dependence information to utilize a pre-trained code recommendation model, enhancing prediction accuracy by referencing both context and dependency data.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Device complexity

If code recommendation tools rely solely on previous or current code segments for prediction, then the device complexity is reduced, but the manufacturing precision (code recommendation accuracy) deteriorates

Engineering Contradiction:
Improvesystem complexityVSAvoidcode recommendation accuracy
Core Design Contradiction:
Device complexityVSManufacturing precision

Solution Approach 1:

The patent segments the code recommendation input into two distinct parts: relevant code segments (local context) and code dependence information (global dependencies). This segmentation allows the system to process different types of code information separately and feed them into the recommendation model, improving accuracy without overwhelming system complexity.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent adds a new dimension to code recommendation by incorporating code dependence information alongside traditional code segments. This transforms the recommendation from a single-dimensional approach (only code text) to a multi-dimensional approach that includes both code content and dependency relationships, significantly improving prediction accuracy.

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

2Loss of energy

If code recommendation tools use only current code segments, then the loss of information is minimized in terms of processing overhead, but the reliability of code prediction deteriorates

Engineering Contradiction:
Improveprocessing overheadVSAvoidcode prediction reliability
Core Design Contradiction:
Loss of energyVSReliability

Solution Approach 1:

The patent performs preliminary action by extracting and organizing code dependence information before feeding it into the recommendation model. Dependencies such as imports, class hierarchies, and method calls are pre-processed and structured, allowing the model to efficiently utilize this information without excessive processing overhead during code generation.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces an intermediary processing layer that bridges the gap between raw code segments and the recommendation model. This intermediary extracts and structures code dependence information, transforming it into a format that the model can effectively utilize, thereby improving reliability without directly increasing processing overhead.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Manufacturing precision

If code recommendation considers both relevant code segments and code dependence information, then the manufacturing precision (recommendation accuracy) is improved, but the device complexity increases

Engineering Contradiction:
Improverecommendation accuracyVSAvoidsystem architecture complexity
Core Design Contradiction:
Manufacturing precisionVSDevice complexity

Solution Approach 1:

The patent merges relevant code segments and code dependence information into a unified input structure for the recommendation model. By combining these two types of information in a coordinated manner, the system achieves high recommendation accuracy while managing complexity through integrated processing rather than separate independent systems.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The patent creates a universal code recommendation framework that can handle both code segments and dependence information through a single multi-functional model. This universal approach improves accuracy by considering multiple factors simultaneously while avoiding the complexity of multiple specialized systems.

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

Data Source

PatentUS20240403001A1Code recommendation method and apparatus, electronic device and storage medium
Publication Date: 2024.12.05 BEIJING BAIDU NETCOM SCI & TECH CO LTD
  • US20240403001A1 patent drawing
  • US20240403001A1 patent drawing
  • US20240403001A1 patent drawing

AI summary

There is provided a code recommendation method and apparatus, an electronic device and a storage medium, which relates to the field of software development technologies, artificial intelligence technologies, or the like. A specific implementation includes: acquiring a relevant code segment required by a recommended code from a current code file; acquiring code dependence information required by the recommended code; and performing code recommendation based on the relevant code segment, the code dependence information and a pre-trained code recommendation model.