Intermediate Representation Workflow for Dependency-Aware LLM Code Generation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Large language models (LLMs) face limitations in generating correct and formatted compilable computer code, particularly for proprietary or complex code types, and scaling issues arise due to token limits and increased processing time and costs.

Innovation Solution

Generate an intermediate representation using an LLM and a separate programmatic component to compile it into compilable code, breaking requests into smaller parts based on feature dependencies and using a feature tree to manage complexity.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

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

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

Solution Approach 1:

The code generation process is segmented into two distinct stages: first generating an intermediate representation (IR) that captures the logical structure, then separately compiling it into final compilable code. This segmentation allows the LLM to focus on creative logic generation while a dedicated compiler handles syntax correctness, resolving the contradiction between speed and accuracy.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

An intermediate representation (IR) is introduced as a mediator between the LLM's natural language understanding and the target compilable code. The IR serves as a structured bridge that preserves the LLM's generative speed while enabling precise syntactic transformation through programmatic compilation, thereby maintaining both productivity and manufacturing precision.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Adaptability or versatility

If LLM processes large complex requests with many features, then code coverage is improved, but processing time and costs increase

Engineering Contradiction:
Improvecode coverageVSAvoidprocessing time
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

Complex code generation requests are segmented into multiple independent intermediate representation files, each handling specific features or modules. This segmentation enables parallel processing of different code components, reducing overall processing time while maintaining comprehensive code coverage for large-scale projects.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system performs preliminary analysis to identify feature dependencies and generates a processing plan before actual code generation. By pre-organizing the generation sequence and identifying independent modules, the system can process complex requests more efficiently, reducing processing time while ensuring all features are covered.

Inventive Principle:
Principle #10Preliminary action

3Adaptability or versatility

If LLM generates code for proprietary or complex code types, then code functionality is improved, but formatting correctness deteriorates

Engineering Contradiction:
Improvecode functionalityVSAvoidformatting correctness
Core Design Contradiction:
Adaptability or versatilityVSManufacturing precision

Solution Approach 1:

The intermediate representation serves as a format-agnostic mediator that captures the functional logic independent of target code formatting requirements. This allows the LLM to generate correct functionality once in IR form, which can then be compiled into any proprietary or complex code type with proper formatting through dedicated compilation processes.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The formatting and syntax-specific requirements are extracted from the generation process and handled separately by the compilation stage. The LLM focuses solely on generating the functional logic in intermediate representation, while the compiler extracts and applies the specific formatting rules for the target code type, ensuring both functionality and formatting correctness.

Inventive Principle:
Principle #2Taking out (Extraction)

4Productivity

If LLM generates all code components in one pass, then generation speed is improved, but error rate increases

Engineering Contradiction:
Improvegeneration speedVSAvoiderror rate
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The code generation is segmented into intermediate representation generation and compilation phases. Errors are more easily detected and corrected in the structured IR phase before compilation, reducing the overall error rate while maintaining generation speed through the modular two-phase approach.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The compilation phase provides feedback on syntax and formatting errors that can be traced back to the intermediate representation. This feedback loop allows for systematic error detection and correction without requiring complete regeneration, maintaining productivity while improving reliability.

Inventive Principle:
Principle #23Feedback

Data Source

PatentUS20260064993A1Modular subsequent generations of dedicated intermediate representations
Publication Date: 2026.03.05 SAP SE
  • US20260064993A1 patent drawing
  • US20260064993A1 patent drawing
  • US20260064993A1 patent drawing

AI summary

In an example embodiment, a feature tree of all features in a request is generated. This feature tree describes interrelations between features that are dependent upon one another. The request is then broken into multiple, smaller requests. More particularly, each feature is included in its own dedicated request. Based on the dependencies, the smaller requests are then sent to the LLM in an order that preserve the dependency relationships. Intermediate results generated by the LLM in response to the multiple smaller request are then merged into a single intermediate result that can then be passed to the programmatic component for compiling.