IP Library Granted Patent US 12,393,405
Granted Patent B1
US 12,393,405 · App. 19/195,490 · Granted Aug 19, 2025

Enhance codegen efficiency by eliminating redundant contexts in lossless manifold optimization

Inventors: Sumangal Mandal (Kolkata, IN); Vaishali Gupta (New Delhi, IN); Amit Kaushal (Bengaluru, IN)
Assignee: Intuit Inc.
G06F8/35G06F8/36G06F11/3684G06F16/9024
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,393,405
App. No.
19/195,490
Granted
Aug 19, 2025
Kind
B1
Abstract

Certain aspects of the disclosure provide a method for code generation, including: selecting a code generation use case type; identifying the target entity in a graph knowledge base; extracting a graph segment of the graph knowledge base; identifying a set of methods in the graph segment; identifying a first method of the set of methods that has a largest context size of the set of methods; determining an overlapping context size between the first method and each other method of the set of methods, and selecting a maximum number of other methods of the set of methods in order of decreasing overlapping context size with respect to the first method, such that a total context size of the maximum number of other methods of the set of methods and the first method does not exceed a maximum context window size associated with a machine learning model.

Claims (84)

1. A method for curating source code contexts for response generation, comprising:

selecting a type of a code generation use case to generate for a target entity referenced in source code;

identifying the target entity in a graph knowledge base corresponding to the source code, the graph knowledge base comprising a set of nodes representing a set of entities identified in the source code and a set of edges indicating relationships between entities of the set of entities;

extracting a graph segment of the graph knowledge base by identifying one or more entities related to the target entity based on the type of the code generation use case to be generated;

identifying a set of methods in the graph segment;

determining at least one subset of methods from the set of methods in the graph segment, including:

identifying a first method of the set of methods that has a largest context size of the set of methods;

determining an overlapping context size between the first method and each other method of the set of methods; and

selecting a maximum number of other methods of the set of methods in order of decreasing overlapping context size with respect to the first method, such that a total context size of the maximum number of other methods of the set of methods and the first method does not exceed a maximum context window size associated with a machine learning model; and

providing the at least one subset of methods to the machine learning model to generate code for the code generation use case.

2. The method of claim 1 , further comprising:

determining that two or more other methods of the set of methods comprise a same overlapping context size with respect to the first method; and

determining a context size difference between the first method and each other method of the set of methods;

wherein the maximum number of other methods of the set of methods is selected in order of decreasing overlapping context size and in order of increasing context size difference with respect to the first method.

3. The method of claim 1 , further comprising:

providing the at least one subset of methods as context to a prompt builder; and

receiving a prompt from the prompt builder, the prompt configured to instruct the machine learning model on how to process the at least one subset of methods to generate the code generation use case based on the target entity and the type of the code generation use case.

4. The method of claim 1 , wherein providing the at least one subset of methods to the machine learning model to generate the code generation use case occurs in response to determining that every method of the set of methods is included in the at least one subset of methods.

5. The method of claim 1 , further comprising:

determining one or more remaining methods that were not included in the at least one subset of methods;

identifying a second method of the one or more remaining methods that has the largest context size of the one or more remaining methods;

determining the overlapping context size between the second method and each other method of the one or more remaining methods;

determine that a total context size of the second method and any other remaining method exceeds the maximum context window size associated with the machine learning model; and

providing the second method to the machine learning model to generate an additional portion of the code generation use case.

6. The method of claim 5 , further comprising continuing to generate subsets of methods until every method of the set of methods is selected to be part of a subset of methods.

7. The method of claim 1 , further comprising generating the graph knowledge base by:

identifying one or more classes within source code;

parsing the source code into one or more graph structures based on the one or more classes;

identifying dependencies between one or more entities of the one or more graph structures; and

linking the one or more graph structures based on the dependencies between the one or more entities of the one or more graph structures to generate the graph knowledge base.

8. The method of claim 1 , wherein:

the target entity is a target method,

the code generation use case is a unit test, and

extracting the graph segment of the graph knowledge base by identifying one or more entities related to the target entity based on the type of the code generation use case to be generated comprises identifying one or more neighbor entities of the target method, wherein the graph segment comprises the target entity and the one or more neighbor entities.

9. The method of claim 1 , wherein:

the target entity is a target method,

the code generation use case is an integration test, and

extracting the graph segment of the graph knowledge base by identifying one or more entities related to the target entity based on the type of the code generation use case to be generated comprises identifying one or more chains of methods related to the target method, wherein the graph segment comprises the target entity and the one or more chains of methods related to the target method.

10. The method of claim 1 , wherein:

the target entity is a target class,

the code generation use case is application programming interface (API) documentation, and

extracting the graph segment of the graph knowledge base by identifying one or more entities related to the target entity based on the type of the code generation use case to be generated comprises identifying a set of entities of the target class, the set of entities including one or more methods, one or more fields of the one or more methods, and one or more additional classes that refers to the one or more fields, wherein the graph segment comprises the set of entities of the target class.

11. A processing system, comprising: memory comprising computer-executable instructions; and one or more processors configured to execute the computer-executable instructions and cause the processing system to:

select a type of a code generation use case to generate for a target entity referenced in source code;

identify the target entity in a graph knowledge base corresponding to the source code, the graph knowledge base comprising a set of nodes representing a set of entities identified in the source code and a set of edges indicating relationships between entities of the set of entities;

extract a graph segment of the graph knowledge base by identifying one or more entities related to the target entity based on the type of the code generation use case to be generated;

identify a set of methods in the graph segment;

determine at least one subset of methods from the set of methods in the graph segment, including:

identifying a first method of the set of methods that has a largest context size of the set of methods;

determining an overlapping context size between the first method and each other method of the set of methods; and

selecting a maximum number of other methods of the set of methods in order of decreasing overlapping context size with respect to the first method, such that a total context size of the maximum number of other methods of the set of methods and the first method does not exceed a maximum context window size associated with a machine learning model; and

provide the at least one subset of methods to the machine learning model to generate the code generation use case.

12. The processing system of claim 11 , wherein the one or more processors are configured to execute the computer-executable instructions and cause the processing system to:

determine that two or more other methods of the set of methods comprise a same overlapping context size with respect to the first method; and

determine a context size difference between the first method and each other method of the set of methods, wherein the maximum number of other methods of the set of methods is selected in order of decreasing overlapping context size and in order of increasing context size difference with respect to the first method.

13. The processing system of claim 11 , wherein the one or more processors are configured to execute the computer-executable instructions and cause the processing system to:

provide the at least one subset of methods as context to a prompt builder; and

receive a prompt from the prompt builder, the prompt configured to instruct the machine learning model on how to process the at least one subset of methods to generate the code generation use case based on the target entity and the type of the code generation use case.

14. The processing system of claim 13 , wherein the one or more processors are configured to execute the computer-executable instructions and cause the processing system to:

continue to generate subsets of methods until every method of the set of methods is selected to be part of a subset of methods.

15. The processing system of claim 11 , wherein the one or more processors are configured to execute the computer-executable instructions and cause the processing system to provide the at least one subset of methods to the machine learning model to generate the code generation use case occurs in response to determining that every method of the set of methods is included in the at least one subset of methods.

16. The processing system of claim 11 , wherein the one or more processors are configured to execute the computer-executable instructions and cause the processing system to:

determine one or more remaining methods that were not included in the at least one subset of methods;

identify a second method of the one or more remaining methods that has the largest context size of the one or more remaining methods;

determine the overlapping context size between the second method and each other method of the one or more remaining methods;

determine that a total context size of the second method and any other remaining method exceeds the maximum context window size associated with the machine learning model; and

provide the second method to the machine learning model to generate an additional portion of the code generation use case.

17. The processing system of claim 11 , wherein the one or more processors are configured to execute the computer-executable instructions and cause the processing system to generate the graph knowledge base by:

identifying one or more classes within source code;

parse the source code into one or more graph structures based on the one or more classes;

identify dependencies between one or more entities of the one or more graph structures; and

link the one or more graph structures based on the dependencies between the one or more entities of the one or more graph structures to generate the graph knowledge base.

18. The processing system of claim 11 , wherein:

the target entity is a target method,

the code generation use case is a unit test, and

to cause the processing system to extract the graph segment of the graph knowledge base by identifying one or more entities related to the target entity based on the type of the code generation use case to be generated, the one or more processors are configured to execute the computer-executable instructions and cause the processing system to identify one or more neighbor entities of the target method, wherein the graph segment comprises the target entity and the one or more neighbor entities.

19. The processing system of claim 11 , wherein:

the target entity is a target method,

the code generation use case is an integration test, and

to cause the processing system to extract the graph segment of the graph knowledge base by identifying one or more entities related to the target entity based on the type of the code generation use case to be generated, the one or more processors are configured to execute the computer-executable instructions and cause the processing system to identify one or more chains of methods related to the target method, wherein the graph segment comprises the target entity and the one or more chains of methods related to the target method.

20. The processing system of claim 11 , wherein:

the target entity is a target class,

the code generation use case is application programming interface (API) documentation, and

to cause the processing system to extract the graph segment of the graph knowledge base by identifying one or more entities related to the target entity based on the type of the code generation use case to be generated, the one or more processors are configured to execute the computer-executable instructions and cause the processing system to identify a set of entities of the target class, the set of entities including one or more methods, one or more fields of the one or more methods, and one or more additional classes that refers to the one or more fields, wherein the graph segment comprises the set of entities of the target class.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jul 2, 2025
From: MANDAL, SUMANGAL; GUPTA, VAISHALI; KAUSHAL, AMIT
To: INTUIT INC.
Reel/Frame 071598/0480 →
References Cited (9)
US 20250133037A1 · Jensen · 2025 [cited by examiner]
CN 117271780A · 2023 [cited by examiner]
CN 118312153A · 2024 [cited by examiner]
CN 119848841A · 2025 [cited by examiner]
Dong, “Compressing Context to Enhance Inference Efficiency of Large Language Models”, 2023, arXiv (Year: 2023). [cited by examiner]
Pan, “Enhancing Repository-Level Code Generation with Integrated Contextual Information”, 2024, arXiv (Year: 2024). [cited by examiner]
Jiang et al., “LongLLMLingua: Accelerating and Enhancing LLMs in Long Context Scenarios via Prompt Compression”, arXiv:2310.06839v2, Aug. 12, 2024, 20 Pages. [cited by applicant]
Pan et al., “Enhancing Repository-Level Code Generation with Integrated Contextual Information”, arXiv:2406.03283v1, Jun. 5, 2024, 11 Pages. [cited by applicant]
Huang et al., “Recurrent Context Compression: Efficiently Expanding the Context Window of LLM”, arXiv:2406.06110v1, Jun. 10, 2024, 13 Pages. [cited by applicant]
Cited By (1)
US 12,699,556