# US 2025/0094165 A1 · System and method for reducing context length in processing codebase using large language model

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2025/0094165 A1
- Document ID: US20250094165A1
- Status: Published application
- Kind: A1
- Application number: 18/370,575
- Filed: 2023-09-20
- Published: 2025-03-20
- Earliest claimed: 2023-09-20
- Assignees: JPMorgan Chase Bank, N.A.
- Applicants: JPMorgan Chase Bank, N.A.
- Inventors: Ran ZMIGROD; Vali TAWOSI; Salwa Husam ALAMIR; Sameena SHAH
- Web page: https://patentgrep.com/patent/US20250094165A1

## CPC

- G06F 8/70: Software maintenance or management
- G06F 8/73: Program documentation
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method and system for reducing context length in processing a codebase using large language model (LLM) are disclosed. The method includes receiving the codebase including multiple files for processing, generating, via the LLM, summaries based on the multiple files, and subsequently organizing the summaries based on a structure of the codebase. The method further includes determining a downstream task, determining whether the downstream task requires a summary of a code or the code itself, and transmitting the summary or the code to the downstream task for executing the downstream task.

## Claims

### Claim 1

A method for reducing context length in processing a codebase using a large language model (LLM), the method comprising:
receiving, the codebase via a network, for processing by the LLM, the codebase including a plurality of files;
determining, by the LLM executed by a processor, a presence of one or more docstrings within at least one file among the plurality of files;
when the one or more docstrings are determined to be included in the at least one file,
determining whether the one or more docstrings are suitable to be used as a summary; and
generating at least one first summary using the one or more docstrings;
for at least one file among the plurality of files without the one or more docstrings, generating, by the LLM executed by the processor, at least one second summary;
after the at least one first summary and the at least one second summary are generated, organizing, by the LLM executed by the processor, the at least one first summary and the at least one second summary based on a structure of the codebase;
determining, by the processor, a downstream task to be executed;
determining, by the processor, whether the downstream task requires a summary of a code or the code itself;
transmitting, by the processor, the summary or the code to the downstream task; and
executing, by the processor, the downstream task using the summary or the code.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the one or more docstrings are determined to be suitable when each of the one or more docstrings is below a reference length.

### Claim 3 (depends on 1)

The method according to claim 1, wherein the one or more docstrings are determined to be suitable when each of the one or more docstrings is below a reference data size.

### Claim 4 (depends on 1)

The method according to claim 1, wherein the one or more docstrings are determined to be suitable when each of the one or more docstrings is below a reference complexity.

### Claim 5 (depends on 1)

The method according to claim 1, wherein each of the at least one first summary and the at least one second summary is below a reference length or size.

### Claim 6 (depends on 1)

The method according to claim 1, wherein a structural organization of the at least one first summary or the at least one second summary corresponds to the structure of the codebase.

### Claim 7 (depends on 1)

The method according to claim 1, wherein the downstream task is sprint planning.

### Claim 8 (depends on 1)

The method according to claim 1, wherein the downstream task is code generation.

### Claim 9 (depends on 1)

The method according to claim 1, wherein the downstream task is code testing.

### Claim 10 (depends on 1)

The method according to claim 1, wherein at least one of the at least one first summary and the at least one second summary includes a file summary.

### Claim 11 (depends on 1)

The method according to claim 1, wherein the at least one first summary and the at least one second summary includes a function summary.

### Claim 12 (depends on 6)

The method according to claim 6, wherein the structural organization of the at least one first summary or the at least one second summary organizes at least one function summary with a corresponding file summary.

### Claim 13 (depends on 6)

The method according to claim 6, wherein the structural organization of the at least one first summary and the at least one second summary includes dependencies between the at least one first summary and the at least one second summary.

### Claim 14 (depends on 1)

The method according to claim 1, wherein, when the executing of the downstream task is performed using the code, the code is modified or a new code is generated.

### Claim 15 (depends on 14)

The method according to claim 14, wherein at least one third summary is generated in response to the modified code or the new code.

### Claim 16 (depends on 15)

The method according to claim 15, wherein a structure of the at least one third summary corresponds to a structure of the modified code or the new code.

### Claim 17 (depends on 1)

The method according to claim 1, wherein, in the transmitting, only the summary is transmitted to the downstream task.

### Claim 18 (depends on 1)

The method according to claim 1, wherein the summary generates a smaller context length than the codebase when processed by the LLM.

### Claim 19

A system for reducing context length in processing a codebase using a large language model (LLM), the system comprising:
a memory; and
a processor,
wherein the system is configured to perform:
receiving, the codebase via a network, for processing by the LLM, the codebase including a plurality of files;
determining, by the LLM executed by the processor, a presence of one or more docstrings within at least one file among the plurality of files;
when the one or more docstrings are determined to be included in the at least one file,
determining whether the one or more docstrings are suitable to be used as a summary; and
generating at least one first summary using the one or more docstrings;
for at least one file among the plurality of files without the one or more docstrings, generating, by the LLM executed by the processor, at least one second summary;
after the at least one first summary and the at least one second summary are generated, organizing, by the LLM executed by the processor, the at least one first summary and the at least one second summary based on a structure of the codebase;
determining a downstream task to be executed;
determining whether the downstream task requires a summary of a code or the code itself;
transmitting the summary or the code to the downstream task; and
executing the downstream task using the summary or the code.

### Claim 20

A non-transitory computer readable storage medium that stores a computer program for reducing context length in processing a codebase using a large language model (LLM), the computer program, when executed by a processor, causing a system to perform a plurality of processes comprising:
receiving, the codebase via a network, for processing by the LLM, the codebase including a plurality of files;
determining, by the LLM executed by the processor, a presence of one or more docstrings within at least one file among the plurality of files;
when the one or more docstrings are determined to be included in the at least one file,
determining whether the one or more docstrings are suitable to be used as a summary; and
generating at least one first summary using the one or more docstrings;
for at least one file among the plurality of files without the one or more docstrings, generating, by the LLM executed by the processor, at least one second summary;
after the at least one first summary and the at least one second summary are generated, organizing, by the LLM executed by the processor, the at least one first summary and the at least one second summary based on a structure of the codebase;
determining a downstream task to be executed;
determining whether the downstream task requires a summary of a code or the code itself;
transmitting the summary or the code to the downstream task; and
executing the downstream task using the summary or the code.
