Intermediate Representation Pipeline for Reliable AI Code Generation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Large language models (LLMs) face limitations in generating correct and properly formatted compilable computer code, especially for proprietary and complex formats, due to their training data constraints, leading to erroneous outputs.

Innovation Solution

Generate an intermediate representation using an LLM and then use a programmatic component to compile it into final computer code, leveraging the strengths of both LLMs for creativity and programmatic components for reliability.

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 output correctness deteriorates due to limitations in training data

Engineering Contradiction:
Improvecode generation speedVSAvoidoutput correctness
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The patent introduces an intermediate representation (IR) as a mediator between the LLM and the final compilable code. The LLM generates IR instead of direct code, which is then transformed into compilable code through a programmatic component. This intermediary step allows the system to leverage the LLM's generative speed while ensuring code correctness through structured validation and transformation processes.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The code generation process is segmented into distinct stages: (1) LLM generates intermediate representation from natural language, (2) programmatic component transforms IR to compilable code, (3) validation and repair processes ensure correctness. This segmentation allows each component to specialize in its strength - the LLM in creative generation and the programmatic component in structural correctness.

Inventive Principle:
Principle #1Segmentation

2Reliability

If LLM is fine-tuned on proprietary code formats, then code generation accuracy is improved, but training cost and time increase

Engineering Contradiction:
Improvecode generation accuracyVSAvoidtraining time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The intermediate representation serves as a format-agnostic intermediary that decouples the LLM from proprietary code format requirements. The LLM learns to generate IR using standard, well-defined schemas rather than requiring fine-tuning on proprietary formats. The transformation from IR to proprietary code is handled by programmatic components, eliminating the need for expensive LLM fine-tuning on specific code formats.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The system performs preliminary structuring of code generation by defining a standardized intermediate representation format beforehand. This preliminary action establishes a clear contract between the LLM and the code generation process, allowing the LLM to be trained on general programming concepts rather than specific proprietary formats, significantly reducing training requirements.

Inventive Principle:
Principle #10Preliminary action

3Ease of operation

If LLM generates direct compilable code, then development simplicity is maintained, but error rate increases due to inability to validate before compilation

Engineering Contradiction:
Improvedevelopment simplicityVSAvoiderror rate
Core Design Contradiction:
Ease of operationVSReliability

Solution Approach 1:

The intermediate representation acts as a validation-friendly intermediary format. Before generating final compilable code, the IR can be validated against schemas, type systems, and logical constraints. This validation occurs in a controlled environment where errors can be detected and repaired without affecting the simplicity of the development workflow, as the validation is automated and transparent to developers.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The system performs preliminary validation and repair of code structure at the intermediate representation stage, before final code generation. This preliminary action catches errors early in the process when they are easier to fix, preventing defective code from reaching the compilation stage and reducing overall error rates while maintaining development simplicity.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS12632650B2Fine-tunable distilled intermediate representation for generative artificial intelligence
Publication Date: 2026.05.19 SAP SE
  • US12632650B2 patent drawing
  • US12632650B2 patent drawing
  • US12632650B2 patent drawing

AI summary

In an example embodiment, rather than use large language model (LLM) to directly generate desired computer code, an intermediate representation is generated by the LLM. The LLM is used to generate the portion of the computer code that cannot be computed programmatically (which may be called the “creative” part for purposes of the present disclosure). The intermediate representation can then be fed into a separate programmatic component that compiles the intermediate representation into compilable computer code. This fine-tuning may involve, for example, sanitizing the intermediate representation, enhancing the intermediate representation, and formatting the intermediate file, as well as modifying the intermediate representation based on a feature set.