IP Library › Granted Patent US 12,602,206
Granted Patent B2
US 12,602,206 · App. 18/485,666 · Granted Apr 14, 2026

Systems and methods for code generation

Inventors: Anahita Havewala (Hayward, CA); Jesus Manuel Sanchez Martinez (San Francisco, CA)
Assignee: SAP SE
G06F8/30
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,602,206
App. No.
18/485,666
Granted
Apr 14, 2026
Kind
B2
Abstract

Embodiments of the present disclosure include techniques for generating code. Input code is received from a user. The code may not be conforming to a particular policy. The input code may be used to retrieve corresponding policies relevant for the code. In some embodiments, the input code may have a particular version, and a schema corresponding to the code version may be retrieved. The input code, policy, and schema may be input to a large language model to generate modified code conforming to the policy and the schema, for example.

Claims (42)

1 . A method of generating code comprising:

receiving a first program code;

based on at least a portion of the first program code, retrieving a first schema associated with the first program code;

generating a query to a data store based on the first program code, the data store comprising a plurality of policies governing the structure of the first program code, the query returning at least one policy associated with the first program code;

inputting the first program code, the first schema, and the at least one policy to a large language model; and

generating, by the large language model, second program code conforming to the first schema and conforming to the at least one policy,

wherein the policies are embeddings generated by a second large language model based on text based policies, the method further comprising inputting one or more elements of the first program code into the second large language model, the second large language model returning a plurality of tokens associated with the one or more elements of the first program code, wherein the query comprises a plurality of tokens.

2 . The method of claim 1 , wherein the large language model is not trained with the first schema.

3 . The method of claim 1 , wherein the first program code does not conform with the at least one policy.

4 . The method of claim 1 , wherein the first program code is infrastructure code to specify infrastructure in a cloud computing environment.

5 . The method of claim 4 , wherein the one or more elements of the first program code are one or more technical resources of the cloud computing environment.

6 . The method of claim 5 , wherein the plurality of tokens is a plurality of words corresponding to the one or more technical resources.

7 . The method of claim 1 , wherein the plurality of policies are security policies, wherein the plurality of security policies governing the structure of the first program code are stored in the data store as security policy embeddings, and wherein, prior to receiving the first program code, the method further comprising:

receiving a plurality of security policies for an organization;

converting the plurality of security policies into a plurality of security policy embeddings; and

storing the plurality of security policy embeddings in the data store.

8 . The method of claim 7 , wherein the plurality of security policies is converted into the plurality of security policy embeddings by the large language model.

9 . The method of claim 8 , wherein the plurality of security policies converted into the plurality of security policy embeddings are second level headings of a text based security policy.

10 . The method of claim 1 , wherein the first schema is retrieved from a data store comprising structured schema documents describing a particular version of the first program code.

11 . The method of claim 10 , wherein the structured schema documents are in a mark down file format.

12 . The method of claim 1 , wherein the data store is a vector data store.

13 . A computer system comprising:

at least one processor;

at least one non-transitory computer-readable medium storing computer-executable instructions that, when executed by the at least one processor, cause the computer system to perform a method of connecting computer systems comprising:

receiving first infrastructure-as-code (IaC) program code;

based on at least a portion of the first IaC program code, retrieving a first schema associated with the first program code;

generating a query to a data store based on the first IaC program code, the data store comprising a plurality of security policy embeddings, the query returning text based security policies corresponding to security policy embeddings associated with the first IaC program code, wherein the first program code does not conform with the text based security policies; and

inputting the first IaC program code, the first schema, and the at least one text based security policy to a large language model;

generating, by the large language model, second IaC program code conforming to the first schema and conforming to the at least one text based security policy,

wherein the security policy embeddings are generated by a second large language model based on the text based security policies, the method further comprising inputting one or more resource descriptors from the first IaC program code into the second large language model, the second large language model returning a plurality of tokens associated with the one or more resource descriptors of the first IaC program code, wherein the query comprises a plurality of tokens.

14 . A non-transitory computer-readable medium storing computer-executable instructions that, when executed by at least one processor, perform a method of connecting computer systems, the method comprising:

receiving first program code;

based on at least a portion of the first program code, retrieving a first schema associated with the first program code;

generating a query to a data store based on the first program code, the data store comprising a plurality of policies governing the structure of the first program code, the query returning at least one policy associated with the first program code;

inputting the first program code, the first schema, and the at least one policy to a large language model; and

generating, by the large language model, second program code conforming to the first schema and conforming to the at least one policy,

wherein the large language model is not trained with the first schema,

wherein the first program code does not conform with the at least one policy,

wherein the policies are embeddings generated by a second large language model based on text based policies, the method further comprising inputting one or more elements of the first program code into the second large language model, the second large language model returning a plurality of tokens associated with the one or more elements of the first program code, wherein the query comprises a plurality of tokens.

15 . The non-transitory computer-readable medium of claim 14 , wherein the first program code is infrastructure code to specify infrastructure in a cloud computing environment.

16 . The non-transitory computer-readable medium of claim 15 , wherein the one or more elements of the first program code are one or more technical resources of the cloud computing environment.

17 . The non-transitory computer-readable medium of claim 16 , wherein the plurality of tokens is a plurality of words corresponding to the one or more technical resources.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Oct 12, 2023
From: HAVEWALA, ANAHITA; SANCHEZ MARTINEZ, JESUS MANUEL
To: SAP SE
Reel/Frame 065200/0890 →
Continuity (1)
Related Publication 20250123810A1 · Apr 17, 2025
References Cited (8)
US 10785128B1 · Bawcom · 2020 [cited by examiner]
US 12367337B2 · Gutierrez · 2025 [cited by examiner]
US 20180152370A1 · Hartley · 2018 [cited by examiner]
US 20230004431A1 · Lee · 2023 [cited by examiner]
US 20240385818A1 · Silverstein · 2024 [cited by examiner]
US 20250005260A1 · Mansour · 2025 [cited by examiner]
US 20250111323A1 · Epstein Koch · 2025 [cited by examiner]
WO WO2024205899A1 · 2024 [cited by examiner]