Language Model Prompt Engineering for Code Generation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing language models face challenges in generating effective prompts for software development, particularly in determining relevant content for inclusion in prompts, due to the vast amount of information associated with software development projects, size constraints, subjective relevance assessment, and concerns over intellectual property and privacy.

Innovation Solution

A computing system engineers language model prompts by ascertaining relationships between code development information and potential contexts, computing a prompt inclusion score, and determining whether to include the context in the prompt based on the score, thereby objectively selecting relevant content.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If all available code development information is included in the prompt, then the language model has comprehensive context for accurate code generation, but the prompt exceeds size constraints and includes irrelevant information

Engineering Contradiction:
Improveaccuracy of code generationVSAvoidprompt size
Core Design Contradiction:
ReliabilityVSQuantity of substance

Solution Approach 1:

The patent segments the large set of available code development information into smaller, manageable chunks or files. Each segment is evaluated individually for relevance to the current coding task, allowing the system to select only necessary portions while maintaining comprehensive context within size constraints.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system extracts and selects only the most relevant code development information from the available data using automated relevance assessment. This extraction process removes unnecessary or irrelevant content while preserving essential context needed for accurate code generation.

Inventive Principle:
Principle #2Taking out (Extraction)

2Ease of operation

If automated relevance assessment is implemented, then objective content selection is achieved, but system complexity increases

Engineering Contradiction:
Improveobjectivity of content selectionVSAvoidsystem complexity
Core Design Contradiction:
Ease of operationVSDevice complexity

Solution Approach 1:

The system performs self-service by automatically assessing the relevance of code development information without requiring manual intervention. The automated relevance assessment mechanism evaluates and selects appropriate content independently, maintaining objectivity while reducing operational complexity.

Inventive Principle:
Principle #25Self-service

3Manufacturing precision

If comprehensive code development information is provided to the language model, then better code generation quality is achieved, but intellectual property and privacy risks increase

Engineering Contradiction:
Improvequality of generated codeVSAvoidintellectual property and privacy risks
Core Design Contradiction:
Manufacturing precisionVSObject-affected harmful factors

Solution Approach 1:

The system extracts and removes sensitive or proprietary information from the code development data before providing it to the language model. This extraction process preserves the technical context needed for quality code generation while eliminating intellectual property and privacy risks.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The system applies different quality treatments to different portions of the input data. Sensitive information is filtered or anonymized, while non-sensitive technical context is preserved in full detail, allowing the model to generate high-quality code without exposure to harmful or proprietary content.

Inventive Principle:
Principle #3Local quality

Data Source

PatentUS20250123814A1Software development language model prompt engineering
Publication Date: 2025.04.17 MICROSOFT TECHNOLOGY LICENSING LLC
  • US20250123814A1 patent drawing
  • US20250123814A1 patent drawing
  • US20250123814A1 patent drawing

AI summary

Some embodiments engineer a prompt for submission to a language model, such as a software development large language model. Some embodiments ascertain a relationship between code development information and potential context. Code development information includes static analysis results, project settings, development tool history or status data, and other software development data which augments training data previously embedded in the language model. Some embodiments compute a prompt inclusion score of the potential context, based on at least the relationship, and use the inclusion score to determine whether to include the potential context in the language model prompt. In some scenarios, an embodiment determines where to place the context in the prompt. Scoring is performed by a formula, statistical scoring model, or machine learning scoring model. Some embodiments reduce context inclusion false positives and false negatives that were based on the use of embedding similarity scores alone.