# US 2025/0156407 A1 · Query processing method based on large language model, prompt construction method, 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/0156407 A1
- Document ID: US20250156407A1
- Status: Published application
- Kind: A1
- Application number: 18/749,175
- Filed: 2024-06-20
- Published: 2025-05-15
- Earliest claimed: 2023-11-13
- Assignees: Beijing Baidu Netcom Science Technology Co., Ltd.
- Applicants: Beijing Baidu Netcom Science Technology Co., Ltd.
- Inventors: Shaozhen GENG; Jun ZHANG
- Web page: https://patentgrep.com/patent/US20250156407A1

## CPC

- G06F 16/2425: {Iterative querying; Query formulation based on the results of a preceding query}
- G06F 16/24575: {using context}
- G06F 16/3329: Natural language query formulation
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Provided are a query processing method based on a large language model, a prompt construction method, an electronic device, and a storage medium. The query processing method includes acquiring a to-be-processed target query; acquiring a data field in a target data model and acquiring target format information of a specified data format; constructing a prompt based on the data field in the target data model, the target format information, and the target query; and inputting the prompt into the large language model to obtain a target format result outputted by the large language model.

## Claims

### Claim 1

A query processing method based on a large language model, comprising:
acquiring a to-be-processed target query;
acquiring a data field in a target data model and acquiring target format information of a specified data format;
constructing a prompt based on the data field in the target data model, the target format information, and the to-be-processed target query; and
inputting the prompt into the large language model to obtain a target format result outputted by the large language model.

### Claim 2 (depends on 1)

The query processing method based on the large language model of claim 1, wherein the target format result is configured for establishment of a relationship between the to-be-processed target query and the data field in the target data model, and the target format result is a serialized result.

### Claim 3 (depends on 1)

The query processing method based on the large language model of claim 1, wherein the target format information comprises a preset dimension field, a preset measure field, and a preset filtering condition, and the target format information is configured for placing a target dimension hit by the to-be-processed target query in the target data model into the preset dimension field, placing a target measure hit by the to-be-processed target query in the target data model into the preset measure field, and placing a to-be-filtered field in the to-be-processed target query into the preset filtering condition.

### Claim 4 (depends on 3)

The query processing method based on the large language model of claim 3, wherein the preset filtering condition uses an array structure, and the preset filtering condition comprises a preset first subfield, a preset second subfield, and a preset third subfield, wherein the preset first subfield is configured to represent the to-be-filtered field, the preset second subfield is configured to represent a filtering value of the to-be-filtered field, and the preset third subfield is configured to represent an operator of the preset filtering condition.

### Claim 5 (depends on 1)

The query processing method based on the large language model of claim 1, further comprising:
acquiring at least one data record from the target data model;
generating sample data for the data field based on the at least one data record; and
adding the sample data of the data field to the prompt.

### Claim 6 (depends on 1)

The query processing method based on the large language model of claim 1, wherein the prompt further comprises sample queries and sample answers in at least two small samples, wherein the sample answers are in the specified data format.

### Claim 7 (depends on 6)

The query processing method based on the large language model of claim 6, wherein fields in the sample answers are randomly selected from data fields of the target data model.

### Claim 8 (depends on 6)

The query processing method based on the large language model of claim 6, wherein at least one of the sample answers comprises a dimension field, a measure field, and a filtering condition; and at least one of the sample answers lacks at least one of the dimension field, the measure field, or the filtering condition.

### Claim 9 (depends on 6)

The query processing method based on the large language model of claim 6, wherein:
in response to the target data model comprising a data dimension of a date type, a first subfield in a filtering condition of at least one of the sample answers is of the date type.

### Claim 10 (depends on 6)

The query processing method based on the large language model of claim 6, wherein:
in response to the target data model comprising a data dimension of a geographic location type, a first subfield in a filtering condition of at least one of the sample answers is of the geographic location type.

### Claim 11 (depends on 1)

The query processing method based on the large language model of claim 1, wherein the prompt comprises at least one of following policies:
a time policy configured for, in response to the to-be-processed target query comprising time description information, processing the time description information into target time according to current time and placing the target time into a filtering condition of the target format result;
a sample data policy configured for, in response to a filtering condition of the target format result comprising sample data of a data field and the sample data of the data field being absent from the to-be-processed target query, removing the sample data of the data field from the filtering condition of the target format result by filtration; or
a field policy configured for controlling a to-be-filtered field of a filtering condition in the target format result to be same as the data field in the target data model.

### Claim 12

A prompt construction method, comprising:
acquiring a to-be-processed target query;
acquiring a data field in a target data model, and acquiring target format information of a specified data format; and
constructing a prompt based on the data field in the target data model, the target format information, and the to-be-processed target query.

### Claim at position 13

13-24. (canceled)

### Claim 25

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 to enable the at least one processor to perform the following:
acquiring a to-be-processed target query;
acquiring a data field in a target data model and acquiring target format information of a specified data format;
constructing a prompt based on the data field in the target data model, the target format information, and the to-be-processed target query; and
inputting the prompt into a large language model to obtain a target format result outputted by the large language model.

### Claim 26 (depends on 1)

A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are configured to cause a computer to perform the method of claim 1.

### Claim 27 (depends on 25)

The electronic device of claim 25, wherein the target format result is configured for establishment of a relationship between the to-be-processed target query and the data field in the target data model, and the target format result is a serialized result.

### Claim 28 (depends on 25)

The electronic device of claim 25, wherein the target format information comprises a preset dimension field, a preset measure field, and a preset filtering condition, and the target format information is configured for placing a target dimension hit by the to-be-processed target query in the target data model into the preset dimension field, placing a target measure hit by the to-be-processed target query in the target data model into the measure field, and placing a to-be-filtered field in the to-be-processed target query into the preset filtering condition.

### Claim 29 (depends on 28)

The electronic device of claim 28, wherein the preset filtering condition uses an array structure, and the preset filtering condition comprises a preset first subfield, a preset second subfield, and a preset third subfield, wherein the preset first subfield is configured to represent the to-be-filtered field, the preset second subfield is configured to represent a filtering value of the to-be-filtered field, and the preset third subfield is configured to represent an operator of the preset filtering condition.

### Claim 30 (depends on 25)

The electronic device of claim 25, wherein the at least one processor is enabled to further perform:
acquiring at least one data record from the target data model;
generating sample data for the data field based on the at least one data record; and
adding the sample data of the data field to the prompt.

### Claim 31 (depends on 25)

The electronic device of claim 25, wherein the prompt further comprises sample queries and sample answers in at least two small samples, wherein the sample answers are in the specified data format.

### Claim 32 (depends on 31)

The electronic device of claim 31, wherein fields in the sample answers are randomly selected from data fields of the target data model.
