# US 2025/0094139 A1 · Method of generating code based on large model, electronic device, and storage medium

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

- Number: US 2025/0094139 A1
- Document ID: US20250094139A1
- Status: Published application
- Kind: A1
- Application number: 18/965,152
- Filed: 2024-12-02
- Published: 2025-03-20
- Earliest claimed: 2024-06-19
- Assignees: Beijing Baidu Netcom Science Technology Co., Ltd.
- Applicants: Beijing Baidu Netcom Science Technology Co., Ltd.
- Inventors: Dianhai YU; Wei ZHOU; Xiang GAO; Tiezhu GAO
- Web page: https://patentgrep.com/patent/US20250094139A1

## CPC

- G06F 8/35: model driven
- G06F 8/10: Requirements analysis; Specification techniques
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method of generating a code based on a large model, an electronic device and a storage medium are provided, which relate to the field of artificial intelligence technology, in particular to the fields of deep learning technology and large model technology. The method includes: acquiring a first descriptive text input by a user, where the first descriptive text is configured to characterize a code requirement; searching for a positive code and a negative code matching the first descriptive text, where each of the positive code and the negative code is determined based on a preference operation of the user for a historical code output by the large model; generating a second descriptive text according to the first descriptive text, the positive code, and the negative code; and inputting the second descriptive text into the large model to output a target code matching the code requirement.

## Claims

### Claim 1

A method of generating a code based on a large model, comprising:
acquiring a first descriptive text input by a user, wherein the first descriptive text is configured to characterize a code requirement;
searching for a positive code matching the first descriptive text and a negative code matching the first descriptive text, wherein each of the positive code and the negative code is determined based on a preference operation of the user for a historical code output by the large model;
generating a second descriptive text according to the first descriptive text, the positive code, and the negative code; and
inputting the second descriptive text into the large model to output a target code matching the code requirement.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the searching for a positive code matching the first descriptive text and a negative code matching the first descriptive text comprises:
searching for at least one historical descriptive text similar to the first descriptive text from a personalized database associated with the user;
determining at least one initial positive code associated with the at least one historical descriptive text and at least one initial negative code associated with the at least one historical descriptive text; and
selecting at least one positive code and at least one negative code from the at least one initial positive code and the at least one initial negative code, respectively.

### Claim 3 (depends on 1)

The method according to claim 1, wherein the searching for a positive code matching the first descriptive text and a negative code matching the first descriptive text comprises:
searching for at least one positive sample similar to the first descriptive text and at least one negative sample similar to the first descriptive text from a personalized database associated with the user, according to a historical descriptive text and a code annotation text comprised in each of the positive sample and the negative sample; and
determining the positive code and the negative code according to a positive code comprised in each of the at least one positive sample and a negative code comprised in each of the at least one negative sample.

### Claim 4 (depends on 2)

The method according to claim 2, wherein the generating a second descriptive text according to the first descriptive text, the positive code, and the negative code comprises:
acquiring a first prompt word, a positive prompt word, and a negative prompt word; and
combining, based on a prompt template, the first prompt word, the positive prompt word, the negative prompt word, the first descriptive text, the positive code, and the negative code to obtain the second descriptive text.

### Claim 5 (depends on 4)

The method according to claim 4, further comprising:
searching for a text of code field knowledge matching the first descriptive text from the personalized database; and
updating the second descriptive text by using the text of code field knowledge and a second prompt word.

### Claim 6 (depends on 1)

The method according to claim 1, wherein the determining the positive code and the negative code comprises:
determining the historical code as the negative code associated with the historical code according to a first preference selection operation of the user for the historical code;
determining the historical code as the positive code associated with the historical code according to a second preference selection operation of the user for the historical code; and
storing the positive code or the negative code in a personalized database associated with the user.

### Claim 7 (depends on 6)

The method according to claim 6, further comprising:
determining the historical code determined based on the second preference selection operation as an initial positive historical code; and
determining an editing code according to an editing operation of the user for the initial positive historical code, and determining the editing code as the positive code.

### Claim 8 (depends on 7)

The method according to claim 7, wherein the determining an editing code according to an editing operation of the user for the initial positive historical code comprises:
determining an editing position where the editing operation begins and determining a code feature of the initial positive historical code after the editing position;
acquiring, in response to determining that the user ends the editing operation, an intermediate positive historical code at a time instant where the user ends the editing operation; and
determining the editing code according to the code feature and the intermediate positive historical code.

### Claim 9

An electronic device, comprising:
at least one processor; and
a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions, when executed by the at least one processor, cause the at least one processor to:
acquire a first descriptive text input by a user, wherein the first descriptive text is configured to characterize a code requirement;
search for a positive code matching the first descriptive text and a negative code matching the first descriptive text, wherein each of the positive code and the negative code is determined based on a preference operation of the user for a historical code output by the large model;
generate a second descriptive text according to the first descriptive text, the positive code, and the negative code; and
input the second descriptive text into the large model to output a target code matching the code requirement.

### Claim 10 (depends on 9)

The electronic device according to claim 9, wherein the at least one processor are further configured to:
search for at least one historical descriptive text similar to the first descriptive text from a personalized database associated with the user;
determine at least one initial positive code associated with the at least one historical descriptive text and at least one initial negative code associated with the at least one historical descriptive text; and
select at least one positive code and at least one negative code from the at least one initial positive code and the at least one initial negative code, respectively.

### Claim 11 (depends on 9)

The electronic device according to claim 9, wherein the at least one processor are further configured to:
search for at least one positive sample similar to the first descriptive text and at least one negative sample similar to the first descriptive text from a personalized database associated with the user, according to a historical descriptive text and a code annotation text comprised in each of the positive sample and the negative sample; and
determine the positive code and the negative code according to a positive code comprised in each of the at least one positive sample and a negative code comprised in each of the at least one negative sample.

### Claim 12 (depends on 10)

The electronic device according to claim 10, wherein the at least one processor are further configured to:
acquire a first prompt word, a positive prompt word, and a negative prompt word; and
combine, based on a prompt template, the first prompt word, the positive prompt word, the negative prompt word, the first descriptive text, the positive code, and the negative code to obtain the second descriptive text.

### Claim 13 (depends on 12)

The electronic device according to claim 12, wherein the at least one processor are further configured to:
search for a text of code field knowledge matching the first descriptive text from the personalized database; and
update the second descriptive text by using the text of code field knowledge and a second prompt word.

### Claim 14 (depends on 9)

The electronic device according to claim 9, wherein the at least one processor are further configured to:
determine the historical code as the negative code associated with the historical code according to a first preference selection operation of the user for the historical code;
determine the historical code as the positive code associated with the historical code according to a second preference selection operation of the user for the historical code; and
store the positive code or the negative code in a personalized database associated with the user.

### Claim 15 (depends on 14)

The electronic device according to claim 14, wherein the at least one processor are further configured to:
determine the historical code determined based on the second preference selection operation as an initial positive historical code; and
determine an editing code according to an editing operation of the user for the initial positive historical code, and determining the editing code as the positive code.

### Claim 16 (depends on 15)

The electronic device according to claim 15, wherein the at least one processor are further configured to:
determine an editing position where the editing operation begins and determining a code feature of the initial positive historical code after the editing position;
acquire, in response to determining that the user ends the editing operation, an intermediate positive historical code at a time instant where the user ends the editing operation; and
determine the editing code according to the code feature and the intermediate positive historical code.

### Claim 17

A non-transitory computer-readable storage medium having computer instructions stored thereon, wherein the computer instructions are configured to cause a computer to:
acquire a first descriptive text input by a user, wherein the first descriptive text is configured to characterize a code requirement;
search for a positive code matching the first descriptive text and a negative code matching the first descriptive text, wherein each of the positive code and the negative code is determined based on a preference operation of the user for a historical code output by the large model;
generate a second descriptive text according to the first descriptive text, the positive code, and the negative code; and
input the second descriptive text into the large model to output a target code matching the code requirement.

### Claim 18 (depends on 17)

The non-transitory computer-readable storage medium according to claim 17, wherein the computer instructions are further configured to cause the computer to:
search for at least one historical descriptive text similar to the first descriptive text from a personalized database associated with the user;
determine at least one initial positive code associated with the at least one historical descriptive text and at least one initial negative code associated with the at least one historical descriptive text; and
select at least one positive code and at least one negative code from the at least one initial positive code and the at least one initial negative code, respectively.

### Claim 19 (depends on 17)

The non-transitory computer-readable storage medium according to claim 17, wherein the computer instructions are further configured to cause the computer to:
search for at least one positive sample similar to the first descriptive text and at least one negative sample similar to the first descriptive text from a personalized database associated with the user, according to a historical descriptive text and a code annotation text comprised in each of the positive sample and the negative sample; and
determine the positive code and the negative code according to a positive code comprised in each of the at least one positive sample and a negative code comprised in each of the at least one negative sample.

### Claim 20 (depends on 18)

The non-transitory computer-readable storage medium according to claim 18, wherein the computer instructions are further configured to cause the computer to:
acquire a first prompt word, a positive prompt word, and a negative prompt word; and
combine, based on a prompt template, the first prompt word, the positive prompt word, the negative prompt word, the first descriptive text, the positive code, and the negative code to obtain the second descriptive text.
