Pre-Trained Diffusion Code Generation for Syntax and Diversity

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current autoregressive code generation tools suffer from low diversity and syntactic errors due to their inability to reconsider earlier tokens, while diffusion models struggle with syntactic correctness in code generation, limiting their widespread adoption.

Innovation Solution

A code generating system combining an encoder-decoder architecture with a diffusion process, using a denoiser to iteratively denoise code snippet embeddings and a transformer decoder with full self-attention to generate syntactically correct and diverse code.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If autoregressive architecture is used for code generation, then code quality is improved, but code generation diversity deteriorates

Engineering Contradiction:
Improvecode qualityVSAvoidcode generation diversity
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The patent combines autoregressive and diffusion architectures into a hybrid model where the diffusion process generates diverse code variations while the autoregressive component ensures syntactic correctness and quality, resolving the trade-off between diversity and quality

Inventive Principle:
Principle #5Merging (Combining)

2Adaptability or versatility

If diffusion architecture is used for code generation, then code generation diversity is improved, but syntactic correctness deteriorates

Engineering Contradiction:
Improvecode generation diversityVSAvoidsyntactic correctness
Core Design Contradiction:
Adaptability or versatilityVSReliability

Solution Approach 1:

The patent introduces a syntax verification module as an intermediary that checks and corrects code generated by the diffusion process, ensuring syntactic correctness while preserving the diversity benefits of diffusion modeling

Inventive Principle:
Principle #24Intermediary (Mediator)

3Reliability

If traditional autoregressive tools are used, then code quality is maintained, but ability to reconsider earlier tokens is lost

Engineering Contradiction:
Improvecode qualityVSAvoidtoken reconsideration capability
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The patent implements a dynamic generation process where previously generated tokens can be reconsidered and modified through the diffusion process, allowing the model to adapt and improve code quality by revisiting earlier decisions

Inventive Principle:
Principle #15Dynamics

Data Source

PatentUS20250278249A1Code generation system using pre-trained diffusion model
Publication Date: 2025.09.04 MICROSOFT TECHNOLOGY LICENSING LLC
  • US20250278249A1 patent drawing
  • US20250278249A1 patent drawing
  • US20250278249A1 patent drawing

AI summary

A code generating system is configured to receive a code description prompt which includes a natural language description of a code snippet for the code generating system to generate via a user interface. The system encodes the prompt to generate a code description embedding that embeds the natural language prompt into a continuous space using an encoder. A noisy code snippet embedding is then iteratively denoised conditioned on the code description embedding to generate a denoised code snippet embedding. The denoised code snippet embedding is decoded using a pre-trained decoder having full self-attention and cross-attention with the code snippet embedding to generate a final predicted code snippet embedding. The final predicted code snippet embedding is then projected to discrete code tokens using a classification head that computes a probability distribution over code tokens and selects code tokens for a predicted code snippet based on the probability distribution.