Code Completion Using Cross-File Dependency Signatures

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing code completion methods based on big models suffer from low accuracy when cross-file information is needed, leading to hallucinations and poor recommendation codes.

Innovation Solution

A code completion method that determines a second code element with a dependency relationship to the first code element, using a big model to generate target code based on the signature of the second code element, thereby considering cross-file information.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If only current code file information is used for code completion, then the simplicity of the completion process is maintained, but the accuracy of code completion deteriorates when cross-file information is needed

Engineering Contradiction:
Improvecode completion accuracyVSAvoidcompletion process complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent segments the code completion process into multiple stages: first analyzing the current code file to identify the first code element, then separately analyzing dependency relationships to identify second code elements from other files. This segmentation allows the system to handle cross-file dependencies systematically without overwhelming complexity, while improving accuracy by incorporating relevant external code information.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent performs preliminary analysis of code dependency relationships before generating completion suggestions. By pre-identifying the first code element in the current file and the second code element in dependent files, the system prepares relevant context information in advance, enabling accurate completion when needed without requiring complex real-time analysis.

Inventive Principle:
Principle #10Preliminary action

2Measurement precision

If cross-file information is incorporated to improve code completion accuracy, then the quality of recommendation codes improves, but the risk of hallucinations increases

Engineering Contradiction:
Improvecode completion accuracyVSAvoidrecommendation code reliability
Core Design Contradiction:
Measurement precisionVSReliability

Solution Approach 1:

The patent introduces code dependency relationships as an intermediary mechanism to connect the current code file with external files. This intermediary structure ensures that only relevant and properly connected code elements from other files are incorporated into completions, filtering out unrelated information that could cause hallucinations while maintaining access to necessary cross-file context.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The system uses code dependency relationships as feedback to guide the completion process. By analyzing how the current code file depends on other files, the system receives feedback about which external code elements are relevant, allowing it to make informed decisions about what information to incorporate and what to exclude, thereby reducing hallucinations.

Inventive Principle:
Principle #23Feedback

3Measurement precision

If code dependency analysis is performed to identify relevant second code elements, then the precision of code completion improves, but the processing time increases

Engineering Contradiction:
Improvecode completion precisionVSAvoidprocessing time
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The patent extracts only the essential dependency information needed for code completion, rather than analyzing entire external files. By identifying and extracting specifically the second code element that has a dependency relationship with the first code element, the system obtains necessary context without the overhead of processing complete external codebases, thus maintaining precision while reducing processing time.

Inventive Principle:
Principle #2Taking out (Extraction)

Data Source

PatentUS20250123812A1Code completion method based on big model, apparatus and electronic device
Publication Date: 2025.04.17 BEIJING BAIDU NETCOM SCI & TECH CO LTD
  • US20250123812A1 patent drawing
  • US20250123812A1 patent drawing
  • US20250123812A1 patent drawing

AI summary

The disclosure provides a code completion method based on a big model. The method includes: determining a first code element where a position to be completed is located in a first code file to be completed; determining a second code file having a dependency relationship with the first code file from a development project to which the first code file belongs; determining, according to the first code element, a second code element whose correlation with the first code element meets a preset condition, in which the second code element belongs to at least one of the first code file or the second code file; and generating a target code corresponding to the position to be completed through a big model based on a signature of the second code element.