Data query method and system based on large language model

Through the data query method based on the large language model, the problem of low data query efficiency and inability to meet the user's diversity needs in the prior art is solved, and more accurate and efficient data query is achieved, which improves the user experience.

CN119557330APending Publication Date: 2025-03-04CTRIP TRAVEL NETWORK TECH SHANGHAI0
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202411742396.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

In the prior art, data query efficiency is not high and cannot meet the query needs of users' diversity, affecting the user experience.

Method used

The data query method based on the large language model is adopted to obtain unstructured target query text, perform semantic analysis to generate structured analysis results, and call the indicator query interface to obtain the corresponding query data.

Benefits of technology

It improves the accuracy of query data, meets the diverse query needs of users, and improves query efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557330A_ABST
    Figure CN119557330A_ABST
Patent Text Reader

Abstract

The invention provides a data query method and system based on a large language model. The method comprises the following steps: obtaining an unstructured target query text for querying an index; inputting the target query text into a large language model for semantic analysis, and generating a structured analysis result; and calling an index query interface according to an analysis result to obtain query data corresponding to the target query text. According to the method, the target query text is subjected to deep semantic analysis by utilizing the large language model, so that the analysis result which is more in line with the query intention of the user is generated, the finally obtained query data is more in line with the actual query demand of the user, and the accuracy of the query data is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence and data analysis, and in particular to a data query method and system based on a large language model. Background Art

[0002] The traditional indicator query method relies on users to manually select necessary query conditions such as specific indicators and dimensions on the platform, and perform data queries according to preset calculation logic. This data query method does not support natural language queries, that is, users cannot express their query intentions through simple text, and must clearly specify query conditions through operations such as clicking or filtering on the platform. This not only requires users to have some understanding of the platform's operating procedures, but also requires users to perform a series of tedious operations during the query process, resulting in low query efficiency and difficulty in meeting users' diverse query needs, thus affecting user experience. Summary of the invention

[0003] The technical problem to be solved by the present disclosure is to overcome the defects of the prior art that data query efficiency is low and cannot meet the diverse query needs of users, and to provide a data query method and system based on a large language model.

[0004] The present invention solves the above technical problems through the following technical solutions:

[0005] A first aspect of the present disclosure provides a data query method based on a large language model, the data query method comprising:

[0006] Obtaining unstructured target query text for querying indicators;

[0007] Inputting the target query text into a large language model for semantic parsing to generate a structured parsing result;

[0008] The index query interface is called according to the analysis result to obtain query data corresponding to the target query text.

[0009] Optionally, the large language model is used to perform semantic analysis on the query text according to the target prompt word template, and the data query method further includes:

[0010] Acquire an initial prompt word template and indicator data; the initial prompt word template is composed of an indicator semantic module and a guide sentence module; the indicator data includes at least one business name and business data corresponding to the business name;

[0011] The target prompt word template is generated by filling the indicator semantic module of the initial prompt word template according to the business name of the indicator data and filling the guide sentence module of the initial prompt word template according to the business data of the indicator data.

[0012] Optionally, the indicator semantic module of the initial prompt word template includes: a start time, an end time, and a time granularity;

[0013] and / or;

[0014] The business name of the indicator data includes: business segment, indicator name, dimension name and dimension enumeration value.

[0015] Optionally, the data query method further includes: in response to the lack of data corresponding to the business segment or the indicator name in the analysis result, generating prompt information, wherein the prompt information is used to prompt the user to re-enter the target query text.

[0016] Optionally, the data query method further includes: visualizing the query data and / or the parsing result.

[0017] Optionally, the large language model is specifically used to perform semantic analysis on the target query text according to historical query texts and corresponding analysis results.

[0018] A second aspect of the present disclosure provides a data query system based on a large language model, the data query system comprising:

[0019] An acquisition module, used for acquiring an unstructured target query text for querying an indicator;

[0020] A parsing module, used for inputting the target query text into a large language model for semantic parsing and generating a structured parsing result;

[0021] The query module is used to call the indicator query interface according to the analysis result to obtain the query data corresponding to the target query text.

[0022] Optionally, the large language model is used to perform semantic analysis on the query text according to a target prompt word template, and the data query system also includes a generation module for obtaining an initial prompt word template and indicator data; the initial prompt word template is composed of an indicator semantic module and a guide sentence module; the indicator data includes at least one business name and business data corresponding to the business name one by one; the indicator semantic module of the initial prompt word template is filled in according to the business name of the indicator data, and the guide sentence module of the initial prompt word template is filled in according to the business data of the indicator data, so as to generate a target prompt word template.

[0023] Optionally, the indicator semantic module of the initial prompt word template includes: a start time, an end time, and a time granularity;

[0024] and / or;

[0025] The business name of the indicator data includes: business segment, indicator name, dimension name and dimension enumeration value.

[0026] Optionally, the data query system further includes a response module for generating a prompt message when it is determined that data corresponding to the business segment or the indicator name is missing in the analysis result, wherein the prompt message is used to prompt the user to re-enter the target query text.

[0027] Optionally, the data query system further includes a processing module for visualizing the query data and / or the parsing result.

[0028] Optionally, the large language model is specifically used to perform semantic analysis on the target query text according to historical query texts and corresponding analysis results.

[0029] A third aspect of the present disclosure provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and used to run on the processor, wherein the processor implements the data query method as described in the first aspect when executing the computer program.

[0030] A fourth aspect of the present disclosure is a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the data query method as described in the first aspect.

[0031] A fifth aspect of the present disclosure provides a computer program product, including a computer program, wherein when the computer program is executed by a processor, the data query method as described in the first aspect is implemented.

[0032] On the basis of being in accordance with the common sense in the art, the above-mentioned optional conditions can be arbitrarily combined to obtain the preferred embodiments of the present disclosure.

[0033] The positive progressive effect of the present disclosure is that a large language model is used to perform in-depth semantic analysis of the target query text to generate a parsing result that is more in line with the user's query intention, and then the corresponding indicator query interface is called according to the parsing result, so that the query data finally obtained is more in line with the user's actual query needs, thereby improving the accuracy of the query data. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A flowchart of a data query method based on a large language model provided in Embodiment 1 of the present disclosure;

[0035] Figure 2 A schematic diagram of a module of a data query system based on a large language model provided in Embodiment 2 of the present disclosure;

[0036] Figure 3A schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present disclosure. DETAILED DESCRIPTION

[0037] The present disclosure is further described below by way of examples, but the present disclosure is not limited to the scope of the examples.

[0038] Prefixes such as "first" and "second" are used in the embodiments of the present disclosure only to distinguish different description objects, and have no limiting effect on the position, order, priority, quantity or content of the described objects. The use of prefixes such as ordinal numbers to distinguish description objects in the embodiments of the present disclosure does not constitute a limitation on the described objects. For the statement of the described objects, please refer to the description in the context of the claims or embodiments, and no unnecessary limitation should be constituted due to the use of such prefixes. In addition, in the description of the present embodiment, unless otherwise specified, the meaning of "plurality" is two or more.

[0039] In the embodiments of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0040] Example 1

[0041] This embodiment provides a data query method based on a large language model. Figure 1 As shown, the data query method includes:

[0042] S1, obtaining an unstructured target query text for querying indicators;

[0043] In specific implementations, unstructured target query text refers to text content output by users in natural language. Users can express specific query requirements by inputting text content similar to daily conversations. For example, the target query text input by users to query the "indicator" of order submission volume can be "How many orders were submitted by Shanghai hotels during the National Day in 2024". Users can express the data information they want to query the order submission volume through simple and intuitive text descriptions.

[0044] S2, inputting the target query text into a large language model for semantic analysis to generate a structured analysis result;

[0045] In the specific implementation, the large language model performs semantic analysis on the target query text input by the user and outputs a structured analysis result with a standardized format. By parsing the unstructured target query text into an analysis result that meets the requirements of the standardized format, it provides clear guidance for subsequent data queries and improves the accuracy of data queries. Specifically, the structured analysis result can be data in JSON format.

[0046] S3. Calling an index query interface according to the parsing result to obtain query data corresponding to the target query text.

[0047] In the specific implementation, the parsing result is obtained based on the large language model, and then the corresponding indicator query interface is called. The indicator query interface uses the parsing result as a specific input parameter to perform a corresponding data query operation to obtain data that matches the user's query intention.

[0048] In a specific example, the target query text input by the user is "How many orders were submitted by hotels in Shanghai from October 1 to 7, 2024?" The above query text is input into the big language model, and the parsing result obtained after big language semantic parsing is: {"Business segment": "Accommodation", "Indicator name": "Daily hotel orders", "City": "Shanghai", "Start date": "2024-10-01", "End date": "2024-10-07", "Time granularity": "Day"}. The natural language query text input by the user is converted into data in JSON format to achieve formal normalization of the target query text. The indicator query interface is called according to the above parsing result to obtain the daily order submission data of all hotels in Shanghai from October 1, 2024 to October 7, 2024.

[0049] Based on the application of Large Language Model (LLM) technology, users can directly express their query requirements through natural language. LLM converts the text input by the user into structured indicator statements, and then calls the interface to convert it into query statements that can be recognized by the database, and finally obtains query data that meets the user's query requirements.

[0050] In an optional embodiment, the large language model is used to perform semantic analysis on the query text according to the target prompt word template, and the data query method also includes: obtaining an initial prompt word template and indicator data; the initial prompt word template is composed of an indicator semantic module and a guide sentence module; the indicator data includes at least one business name and business data corresponding to the business name one by one; filling the indicator semantic module of the initial prompt word template according to the business name of the indicator data, and filling the guide sentence module of the initial prompt word template according to the business data of the indicator data, to generate a target prompt word template.

[0051] In the specific implementation, the initial prompt word template is used to guide the large language model to perform semantic analysis on the target query text input by the user. The initial prompt word template consists of two parts: the indicator semantic module and the guide sentence module. First, it is necessary to identify the business name included in the indicator data, and further identify the business data corresponding to the business name, and then fill the identified business name into the indicator semantic module of the initial prompt word template to ensure that the name in the template matches the actual business, and fill the business data into the guide sentence module of the initial prompt word template to construct a more specific and detailed guide sentence. The generated target prompt word template contains specific business information, which will provide clearer semantic analysis guidance for the large language model. The large language model can more accurately identify the business name and related data in the query text, thereby improving the accuracy of the query results.

[0052] In a specific example, the indicator data includes the business name "hotel" and the business data "order volume". The indicator semantic module in the initial prompt word template is: {business data} of {business name}; the guiding sentence module is: What is the {business data} of {business name} in {time range}? The target prompt word template after filling in according to the business name and business data in the indicator data is: indicator semantic module: "hotel's order volume"; guiding sentence module: "What is the hotel's order volume?" The filled target prompt word template will guide the large language model to more accurately parse the user's data query about the hotel's order volume, thereby improving the accuracy of the data query.

[0053] In an optional embodiment, the indicator semantic module of the initial prompt word template includes: start time, end time and time granularity; and / or; the business name of the indicator data includes: business segment, indicator name, dimension name and dimension enumeration value.

[0054] In a specific implementation, the indicator semantic module in the initial prompt word template includes not only the business name in the indicator data, but also the start time, end time and time granularity, wherein the start time and end time can limit the time range of the data query, and the time granularity is used to indicate the level of detail of data aggregation, and the queried data can be aggregated by day, week, month or year according to the time granularity. Specifically, if it is impossible to obtain relevant information about the start time, end time or time granularity from the target query text entered by the user, data can be filled in according to the set default value to ensure the smooth progress of the data query.

[0055] In a specific example, the start time defaults to 7 days before the current date, the end time defaults to the current date, and the time granularity defaults to "day". When the user query text lacks time information, the start time, end time, and time granularity in the indicator semantic module are filled in according to the default values.

[0056] In another specific example, the indicator data can be a pre-set data table, in which the business name and the data corresponding to the business name are set, and the mapping relationship between the business data can be limited in the data table, so as to standardize the filling content in the target prompt word template, and the target prompt word template can be updated by changing the data content in the data table. Specifically, the indicator data is composed of the business indicator table shown in Table 1 and the business dimension table shown in Table 2. As shown in Table 1, the business indicator table mainly includes three columns, business sector, indicator name and dimension name. The business indicator table not only contains the mapping relationship between the business sector and the indicator, that is, which indicators each business sector has, but also contains the mapping relationship between the indicator and the dimension, that is, which dimensions each indicator has; as shown in Table 2, the business dimension enumeration value table mainly includes three columns, business sector, dimension name and dimension enumeration value, which contains the mapping relationship between the business sector and the dimension and its enumeration value. In actual applications, the business name of the indicator data refers to the header name in the business indicator table and the business dimension table, and the business data in the indicator data refers to the specific data represented by each column in the table.

[0057] Table 1

[0058]

[0059] Table 2

[0060]

[0061] In an optional implementation, the data query method further includes: in response to the lack of data corresponding to the business segment or the indicator name in the analysis result, generating a prompt message, wherein the prompt message is used to prompt the user to re-enter the target query text.

[0062] In a specific implementation, after the large language model parses the target query text, if the parsed result lacks business data corresponding to the business segment, or lacks business data corresponding to the indicator name, it indicates that the target query text entered by the user lacks key information required for the query. At this time, a prompt message will be generated to prompt the user to re-enter the target query text.

[0063] In a specific example, the parsing result obtained after the large language model is parsed is: {"Business sector":"","Indicator name":"Daily order volume submitted by the hotel"}. Since the parsing result lacks data corresponding to the business sector, a prompt message will be immediately generated to inform the user that the query text currently entered lacks information related to the business sector and needs to re-enter the query text.

[0064] In an optional implementation, the data query method further includes: visualizing the query data and / or the analysis result.

[0065] In the specific implementation, in order to enable users to intuitively understand and verify the query results, the query data and analysis results can be displayed through visualization means, and users can confirm whether the analysis results meet the query intention based on the displayed results. Specifically, the data obtained by the query can be displayed as charts or graphs so that users can intuitively understand the data trend and distribution. Through intuitive visualization, users can more conveniently understand and verify the query results, which helps to improve the overall satisfaction of users with the query service.

[0066] In an optional implementation, the large language model is specifically used to perform semantic analysis on the target query text according to the historical query texts and the corresponding analysis results.

[0067] In specific implementations, the large language model will store the query text and its parsing results of each round of conversation to provide a reference for subsequent semantic parsing. When the user enters a new target query text, the large language model will use the stored historical data and historical parsing results to deeply understand the semantic content of the new target query text. By associating the newly input target query text with the historical query text, the large language model can capture the contextual information of multiple user conversations, more accurately parse the user's query intentions, and provide a more coherent, accurate and personalized conversation experience, so that every user interaction can be better understood and responded to.

[0068] Example 2

[0069] Corresponding to the data query method embodiment based on a large language model in the aforementioned embodiment 1, the present disclosure also provides an embodiment of a data query system based on a large language model, such as Figure 2 As shown, the data query system based on the large language model includes:

[0070] An acquisition module 101 is used to acquire an unstructured target query text for querying an index;

[0071] The parsing module 102 is used to input the target query text into a large language model for semantic parsing and generate a structured parsing result;

[0072] The query module 103 is used to call the index query interface according to the analysis result to obtain the query data corresponding to the target query text.

[0073] In an optional embodiment, the large language model is used to perform semantic analysis on the query text according to the target prompt word template, and the data query system also includes a generation module, which is used to obtain an initial prompt word template and indicator data; the initial prompt word template is composed of an indicator semantic module and a guide sentence module; the indicator data includes at least one business name and business data corresponding to the business name one by one; the indicator semantic module of the initial prompt word template is filled in according to the business name of the indicator data, and the guide sentence module of the initial prompt word template is filled in according to the business data of the indicator data, so as to generate a target prompt word template.

[0074] In an optional embodiment, the indicator semantic module of the initial prompt word template includes: start time, end time and time granularity; and / or; the business name of the indicator data includes: business segment, indicator name, dimension name and dimension enumeration value.

[0075] In an optional embodiment, the data query system also includes a response module for generating a prompt message when it is determined that the analysis result lacks data corresponding to the business segment or the indicator name, wherein the prompt message is used to prompt the user to re-enter the target query text.

[0076] In an optional implementation, the data query system further includes a processing module for visualizing the query data and / or the analysis results.

[0077] In an optional implementation, the large language model is specifically used to perform semantic analysis on the target query text according to the historical query texts and the corresponding analysis results.

[0078] As for the system embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The system embodiment described above is only illustrative, wherein the units described as separate components may or may not be physically separated, and the components as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the disclosed solution.

[0079] Example 3

[0080] This embodiment provides an electronic device, including a processor, a memory, and a computer program stored in the memory and used to run on the processor. When the computer program is executed by the processor, it implements the data query method based on the large language model as described in Example 1.

[0081] Figure 3 The structure diagram of an electronic device provided in this embodiment. The electronic device includes a memory, a processor, and a computer program stored in the memory and used to run on the processor. When the processor executes the program, the data query method based on the large language model of embodiment 1 is implemented. Figure 3 The electronic device 90 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0082] The electronic device 90 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 90 may include, but are not limited to: at least one processor 91, at least one memory 92, and a bus 93 connecting different system components (including the memory 92 and the processor 91).

[0083] The bus 93 includes a data bus, an address bus, and a control bus.

[0084] The memory 92 may include a volatile memory, such as a random access memory (RAM) 921 and / or a cache memory 922 , and may further include a read-only memory (ROM) 923 .

[0085] The memory 92 may also include a program / utility 925 having a set (at least one) of program modules 924, such program modules 924 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include an implementation of a network environment.

[0086] The processor 91 executes various functional applications and data alignment by running the computer program stored in the memory 92, such as the data query method based on the large language model in the first embodiment of the present disclosure.

[0087] The electronic device 90 may also communicate with one or more external devices 94 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 95. Furthermore, the model-generated device 90 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 96. As shown, the network adapter 96 communicates with other modules of the model-generated device 90 via a bus 93. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the model-generated device 90, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.

[0088] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules to be embodied.

[0089] Example 4

[0090] The embodiment of the present disclosure also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the data query method based on a large language model of embodiment 1 is implemented.

[0091] The readable storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device or any suitable combination of the above.

[0092] Example 5

[0093] The present disclosure also provides a computer program product, including a computer program, which implements the data query method based on the large language model of embodiment 1 when executed by a processor.

[0094] Among them, the program code for executing the computer program product of the present disclosure can be written in any combination of one or more programming languages, and the program code can be executed completely on the user device, partially on the user device, as an independent software package, partially on the user device and partially on a remote device, or completely on the remote device.

[0095] Although the specific embodiments of the present disclosure are described above, those skilled in the art should understand that this is only an example, and the protection scope of the present disclosure is defined by the appended claims. Those skilled in the art may make various changes or modifications to these embodiments without departing from the principles and essence of the present disclosure, but these changes and modifications all fall within the protection scope of the present disclosure.

Claims

1. A data query method based on a large language model, characterized in that: The data query method comprises: Obtaining unstructured target query text for querying indicators; Inputting the target query text into a large language model for semantic parsing to generate a structured parsing result; The index query interface is called according to the analysis result to obtain query data corresponding to the target query text.

2. The data query method according to claim 1, characterized in that: The large language model is used to perform semantic analysis on the query text according to the target prompt word template, and the data query method further includes: Acquire an initial prompt word template and indicator data; the initial prompt word template is composed of an indicator semantic module and a guide sentence module; the indicator data includes at least one business name and business data corresponding to the business name; The target prompt word template is generated by filling the indicator semantic module of the initial prompt word template according to the business name of the indicator data and filling the guide sentence module of the initial prompt word template according to the business data of the indicator data.

3. The data query method according to claim 2, characterized in that: The indicator semantic module of the initial prompt word template includes: start time, end time and time granularity; and / or; The business name of the indicator data includes: business segment, indicator name, dimension name and dimension enumeration value.

4. The data query method according to claim 3, characterized in that: The data query method further includes: In response to the lack of data corresponding to the business sector or the indicator name in the parsing result, a prompt message is generated, wherein the prompt message is used to prompt the user to re-enter the target query text.

5. The data query method according to claim 1, characterized in that: The data query method further includes: visualizing the query data and / or the parsing result.

6. The data query method according to any one of claims 1 to 5, characterized in that: The large language model is specifically used to perform semantic analysis on the target query text according to the historical query text and the corresponding analysis results.

7. A data query system based on a large language model, characterized in that: The data query system comprises: An acquisition module, used for acquiring an unstructured target query text for querying an indicator; A parsing module, used for inputting the target query text into a large language model for semantic parsing and generating a structured parsing result; The query module is used to call the indicator query interface according to the analysis result to obtain the query data corresponding to the target query text.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and used to run on the processor, characterized in that: When the processor executes the computer program, the data query method according to any one of claims 1 to 7 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data query method according to any one of claims 1 to 7 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the data query method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Code generation method and device, storage medium and electronic equipment

    CN120447880A

  • Code generation method and device, storage medium and electronic device

    CN120447880B

  • Market index data query method, system and terminal based on large language model

    CN120849475A

  • Query method and device based on large language model, equipment and medium

    CN120910097A

  • A query method, device and equipment based on a large language model and a medium

    CN120910097B