LLM Intermediate Representation Refinement for Compilable Code

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Large language models (LLMs) struggle with generating correct and formatted compilable computer code, particularly for proprietary and complex code types, due to limited training data and lack of awareness of code generated by programmatic components, leading to repetitive and erroneous outputs.

Innovation Solution

A framework that uses LLMs to generate intermediate representations, which are refined through natural language feedback, utilizing a cache to persist representations and modify system prompts for subsequent iterations, combined with programmatic components to ensure correct compilation.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If LLMs are used to directly generate compilable computer code, then generation speed is improved, but code correctness and formatting accuracy deteriorate

Engineering Contradiction:
Improvecode generation speedVSAvoidcode formatting accuracy
Core Design Contradiction:
ProductivityVSManufacturing precision

Solution Approach 1:

The code generation process is segmented into two distinct stages: (1) LLM generates an intermediate representation that captures semantic meaning without requiring immediate formatting correctness, and (2) a programmatic component translates this intermediate representation into properly formatted compilable code. This segmentation allows each component to optimize for its specific function - the LLM for semantic understanding and the programmatic component for syntactic correctness.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

An intermediate representation is introduced as a mediator between the LLM's natural language generation capabilities and the requirements of compilable code. This intermediate format serves as a bridge that the LLM can generate more easily while the programmatic component can reliably convert to the target code format, thereby resolving the contradiction between generation speed and formatting accuracy.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Device complexity

If LLMs generate code without awareness of programmatic component output, then generation simplicity is improved, but reliability of code compilation deteriorates

Engineering Contradiction:
Improvegeneration process simplicityVSAvoidcode compilation reliability
Core Design Contradiction:
Device complexityVSReliability

Solution Approach 1:

The system implements feedback mechanisms where the programmatic component's translation of the intermediate representation provides implicit feedback to the LLM about what constitutes valid code structure. Over multiple iterations, this feedback loop enables the LLM to learn from successful compilations and improve its generation reliability without requiring explicit complexity in the generation process itself.

Inventive Principle:
Principle #23Feedback

3Adaptability or versatility

If LLMs are trained on extensive code datasets, then code generation capability is improved, but training data limitations and bias worsen

Engineering Contradiction:
Improvecode generation capabilityVSAvoidtraining data limitations
Core Design Contradiction:
Adaptability or versatilityVSLoss of information

Solution Approach 1:

The training and generation process is segmented into two parts: (1) The LLM is trained on extensive diverse datasets to learn broad programming concepts and patterns, and (2) The programmatic component applies domain-specific knowledge and constraints to ensure the generated code meets precise requirements. This allows the system to leverage the versatility of large datasets while mitigating their limitations through specialized post-processing.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system changes the parameter of code representation from direct compilable code to an intermediate representation format. This parameter change allows the LLM to operate with broader training data while the programmatic component transforms the output to meet specific compilation requirements, thereby overcoming training data limitations for proprietary or highly specialized code types.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS20250306874A1Iterative generation of intermediate representations with large language models
Publication Date: 2025.10.02 SAP SE
  • US20250306874A1 patent drawing
  • US20250306874A1 patent drawing
  • US20250306874A1 patent drawing

AI summary

In an example embodiment, a framework is provided to allow an LLM to regenerate an intermediate representation based on natural language feedback that is provided on the compilable computer code that was generated using the programmatic component from an earlier intermediate representation. The user is able to provide this feedback without having any knowledge of the intermediate representation and the framework is designed to allow the LLM to incorporate this feedback into future generation requests without the LLM being aware of the compilable computer code that was created from its prior iterations.