Context-Aware Code Generation Through Automatic Prompt Extraction

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing code generation methods rely heavily on manual input of prompt description text, leading to potential human error and reduced accuracy and efficiency in software development.

Innovation Solution

A method that extracts context code information from the target generation position to generate code prompt information automatically, using a pre-trained code generation model to improve accuracy and efficiency.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If manual input of prompt description text is used for code generation, then developers can provide detailed requirements, but human error increases and accuracy decreases

Engineering Contradiction:
Improveaccuracy of code prompt informationVSAvoidcorrectness of code prompt information
Core Design Contradiction:
Measurement precisionVSReliability

Solution Approach 1:

The system enables automatic extraction of context code information from the codebase itself to generate code prompt information, eliminating reliance on manual developer input. The extraction module automatically identifies and extracts relevant context code based on the target generation position, and the code generation model automatically generates accurate prompt information from this extracted context,实现ing self-service code generation that improves both accuracy and reliability

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The system performs preliminary extraction of context code information before code generation occurs. By pre-extracting and organizing relevant context code from the codebase at the target generation position, the system prepares accurate input data for the code generation model in advance, ensuring that the subsequent code generation process is based on reliable and precise context information

Inventive Principle:
Principle #10Preliminary action

2Productivity

If manual input of prompt description text is used, then developers can specify code requirements, but development efficiency is reduced

Engineering Contradiction:
Improvesoftware development efficiencyVSAvoidtime spent on manual prompt input
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The system automatically extracts context code information and generates code prompt information without requiring manual developer intervention. The extraction module and code generation model work together to autonomously produce the necessary prompt information, eliminating the time developers would spend manually writing and refining prompt descriptions, thus significantly improving development efficiency

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The system replaces the mechanical process of manual prompt input with an automated information extraction and generation process. Instead of developers manually typing and adjusting prompt text, the system uses the extraction module to automatically retrieve context code and the code generation model to automatically generate prompt information, substituting human mechanical input with an automated computational process that saves time and improves efficiency

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

Data Source

PatentUS20250265048A1Code generation method and apparatus, computer device, and storage medium
Publication Date: 2025.08.21 BEIJING VOLCANO ENGINE TECH CO LTD
  • US20250265048A1 patent drawing
  • US20250265048A1 patent drawing
  • US20250265048A1 patent drawing

AI summary

The present disclosure relates to the field of computer technology, and discloses a code generation method and apparatus, a computer device, and a storage medium. The method includes: obtaining a target generation position of a code to be generated; extracting context code information corresponding to the target generation position, and generating code prompt information matching the context code information; and inputting the code prompt information into a preset code generation model, and generating, by the preset code generation model, target code corresponding to the target generation position. The preset code generation model is pre-trained based on a prompt information sample.