Data query method and device, equipment, storage medium and product
By combining pre-defined domain knowledge bases with large language models to construct prompt information, the problem of inaccurate query results in specific domains by large language models is solved, and efficient and accurate data query and question answering are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING ZITIAO NETWORK TECH CO LTD
- Filing Date
- 2024-11-12
- Publication Date
- 2026-05-12
AI Technical Summary
Existing large language models struggle to obtain high-quality query results in specific domain data queries, and the retraining process is time-consuming, labor-intensive, and inefficient.
The initial query results are determined by using a pre-set large language model. Prompt information is constructed by combining the target pre-set domain knowledge in the pre-set domain knowledge base. The target query results are generated through the pre-set large language model, thus avoiding retraining.
It improves the accuracy of data query and question answering, and enhances the timeliness of large language models in specific fields.
Smart Images

Figure CN122019739A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, and in particular to data query methods, apparatus, devices, storage media, and products. Background Technology
[0002] With the rapid development of artificial intelligence technology, artificial intelligence models have been widely used in various application fields.
[0003] Large Language Models (LLMs) are a class of deep learning models with a large number of parameters that can be used to process and generate natural language text. By training on large-scale datasets, LLMs can perform a variety of Natural Language Processing (NLP) tasks, such as text understanding, generation, translation, and question answering.
[0004] In some application scenarios, large language models can be used to understand users' natural language, convert it into data query language, and present the query results. However, large language models are inherently general, making it difficult to obtain high-quality query results specific to a particular domain. To address this issue, current technologies commonly retrain large language models using training sample sets from the desired application domain. However, both the construction of training sample sets and the retraining process consume significant time and manpower, resulting in low efficiency. Summary of the Invention
[0005] This disclosure provides data query methods, apparatus, devices, storage media, and products, which can optimize existing data query schemes based on large language models.
[0006] In a first aspect, embodiments of this disclosure provide a data query method, including:
[0007] The initial query results for the target data query problem are determined using a pre-defined large language model, wherein the target data query problem is a data query problem expressed in natural language for a target knowledge domain;
[0008] Based on the target query parameters of the target data query question, target preset domain knowledge that matches the target query parameters is obtained from a preset domain knowledge base, wherein the preset domain knowledge base includes preset domain knowledge of the target knowledge domain;
[0009] Target prompt information is constructed based on the target preset domain knowledge and the initial query results;
[0010] Using the preset large language model, the target query result for the target data query question is determined based on the target prompt information and the target data query question.
[0011] Secondly, embodiments of this disclosure also provide a data query device, including:
[0012] The initial query result determination module is used to determine the initial query result of the target data query problem using a preset large language model, wherein the target data query problem is a data query problem expressed in natural language for the target knowledge domain;
[0013] The domain knowledge acquisition module is used to acquire target preset domain knowledge that matches the target query parameters from a preset domain knowledge base based on the target query parameters of the target data query question, wherein the preset domain knowledge base includes preset domain knowledge of the target knowledge domain;
[0014] The prompt information construction module is used to construct target prompt information based on the target preset domain knowledge and the initial query results;
[0015] The target query result determination module is used to determine the target query result of the target data query question based on the preset large language model, the target prompt information, and the target data query question.
[0016] Thirdly, embodiments of this disclosure also provide an electronic device, the electronic device comprising:
[0017] One or more processors;
[0018] Storage device for storing one or more programs.
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the data query method provided in the embodiments of this disclosure.
[0020] Fourthly, embodiments of this disclosure also provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the data query method provided in embodiments of this disclosure.
[0021] Fifthly, embodiments of this disclosure also provide a computer program product, including a computer program that, when executed by a processor, implements the data query method provided in embodiments of this disclosure.
[0022] The data query scheme provided in this disclosure utilizes a preset large language model to determine the initial query results for a target data query question. The target data query question is a data query question expressed in natural language for a target knowledge domain. Based on the target query parameters of the target data query question, target preset domain knowledge matching the target query parameters is obtained from a preset domain knowledge base. Target prompt information is constructed based on the target preset domain knowledge and the initial query results. Finally, the preset large language model is used to determine the target query results for the target data query question based on the target prompt information and the target data query question. By adopting the above technical solution, the accuracy of data query and question answering can be improved, as well as the timeliness of large language model application can be enhanced. Attached Figure Description
[0023] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0024] Figure 1 This is a flowchart illustrating a data query method provided in an embodiment of the present disclosure;
[0025] Figure 2 This is a flowchart illustrating another data query method provided in an embodiment of the present disclosure;
[0026] Figure 3 This is a schematic diagram of the structure of a data query device provided in an embodiment of the present disclosure;
[0027] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0028] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0029] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0030] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0031] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0032] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0033] Figure 1 This is a flowchart illustrating a data query method provided in an embodiment of the present disclosure. This embodiment is applicable to situations where data queries are performed in a specified knowledge domain using a large language model. The method can be executed by a data query device, which can be implemented in software and / or hardware. Optionally, it can be implemented by an electronic device, such as a mobile terminal like a mobile phone, smartwatch, tablet computer, or personal digital assistant, or a device like a personal computer (PC) or server.
[0034] like Figure 1 As shown, the method includes:
[0035] Step 101: Determine the initial query results of the target data query problem using a preset large language model, wherein the target data query problem is a data query problem expressed in natural language for the target knowledge domain.
[0036] For example, the sample data volume and model parameters of a Large Language Model (LLM) can be on the massive scale, for example, having billions or even hundreds of billions of parameters. It is trained on large-scale text data or other modal data and can be used for various natural language processing tasks. It has good text generation capabilities and can be applied to language translation and question answering systems. A Large Language Model can, for example, employ an N-layer Transformer network structure with an encoder and decoder, or a Unified Pre-trained Language Model (UniLM) network structure. It is understood that the Large Language Model can also be other neural network models based on Transformer network structures, and this is not limited thereto. The preset Large Language Model in the embodiments of this disclosure can be any Large Language Model, and is not specifically limited.
[0037] For example, the target data query question is a data query question expressed in natural language for a target knowledge domain. The target knowledge domain is the knowledge domain for which the data query is currently performed; the specific domain is not limited, such as the fields of software development, social networking, instant messaging, media content playback, news push, e-commerce, agriculture, transportation, education, or healthcare, etc. Users can input the data query question in natural language, either text or voice, through a preset client. The currently input data query question is denoted as the target data query question. The preset client is a client running on an electronic device, which can be a preset application or a web client, etc. Before receiving the target data query question, the preset client can be configured to answer data query questions in the target knowledge domain. Taking the software development domain as an example, the target data query question could be "Inquire about the delivery cycle for the second quarter and explain how this calculation method works?" or "What is the meaning behind the capacity utilization rate indicator?" etc.
[0038] For example, the specific process of determining the initial query result of the target data query problem using a preset large language model is not limited. For example, the target data query problem is understood using the preset large language model, and the query function to be used is determined. The corresponding data query operation is executed by calling the determined query function to obtain the initial query result of the target data query problem.
[0039] Step 102: Based on the target query parameters of the target data query question, obtain target preset domain knowledge that matches the target query parameters from the preset domain knowledge base, wherein the preset domain knowledge base includes preset domain knowledge of the target knowledge domain.
[0040] For example, a target data query question may include multiple query parameters. Query parameters can be understood as the parameters required when performing a data query. They can be the original text of the target data query question, or parameters obtained by mapping or transforming the original text of the target data query question. Target query parameters can be domain-related query parameters, such as query objects, which can be data metrics or data parameters, etc. As in the example above, query parameters may include "second quarter," "delivery cycle," and "calculation method." If the query object is "delivery cycle," then the target query parameter can be "delivery cycle."
[0041] For example, the preset domain knowledge base is the knowledge base corresponding to the target knowledge domain, which includes preset domain knowledge of the target knowledge domain. The preset domain knowledge can be knowledge related to the target knowledge domain that is stored in the preset domain knowledge base in advance, such as the relevant introduction, calculation method, background, data source, usage method and relationship between different entities of the target knowledge domain (such as special terms or data indicators). The specific knowledge content of the preset domain knowledge can be set according to actual needs and can be dynamically updated.
[0042] For example, the similarity between the target query parameter and each preset domain knowledge in the preset domain knowledge base can be calculated, and the preset domain knowledge that meets the similarity requirement can be identified as the target preset domain knowledge that matches the target query parameter. As in the example above, assuming that the preset domain knowledge base stores preset domain knowledge related to "delivery cycle", such as the definition and calculation method of the R&D and testing cycle, "delivery cycle" is similar to this preset domain knowledge and can be identified as the target preset domain knowledge.
[0043] Step 103: Construct target prompt information based on the target preset domain knowledge and the initial query results.
[0044] For example, the target preset domain knowledge and the initial query results can be merged to obtain the target prompt information. The specific fusion method is not limited. For example, the target preset domain knowledge and the initial query results can be concatenated, or the target preset domain knowledge and the initial query results can be filled into a preset prompt template.
[0045] Step 104: Using the preset large language model, determine the target query result of the target data query question based on the target prompt information and the target data query question.
[0046] For example, both the target prompt information and the target data query question are input into the preset large language model, so that the preset large language model can refer to the target preset domain knowledge and the initial query results to more accurately understand the target data query question, understand the domain background and specific requirements of the data query task, and thus output more accurate query results that conform to the target knowledge domain.
[0047] For example, as illustrated above, the target query result may include: the indicator name is "from requirement preparation completion to test completion (product development and testing cycle)" in the cycle category; according to the query result, the product development and testing cycle for the second quarter is...; the calculation method for this indicator is... It should be noted that in this disclosure, "..." is used to replace the specific text content in the actual application of the technical solution.
[0048] The data query method provided in this embodiment utilizes a preset large language model to determine the initial query result of a target data query question. The target data query question is a data query question expressed in natural language for a target knowledge domain. Based on the target query parameters of the target data query question, target preset domain knowledge matching the target query parameters is obtained from a preset domain knowledge base. Target prompt information is constructed based on the target preset domain knowledge and the initial query result. Finally, the target query result of the target data query question is determined using the preset large language model based on the target prompt information and the target data query question. By adopting the above technical solution, in the application scenario of answering data query questions in a target knowledge domain using a preset large language model, the initial query results are first determined using the preset large language model. Then, based on the target query parameters of the target data query question, matching target preset domain knowledge is obtained from the preset domain knowledge base. The initial query results and the obtained target preset knowledge domain are combined to construct prompt information for input into the preset large language model. This allows the preset large language model to obtain relevant knowledge of the target knowledge domain from the prompt information as reference information, thereby providing targeted, high-quality answers that conform to the target knowledge domain. This approach can improve the accuracy of data query and question answering, as well as the timeliness of large language model applications, without requiring retraining of the preset large language model for the target knowledge domain.
[0049] In some embodiments, constructing target prompt information based on the target preset domain knowledge and the initial query result includes: obtaining a preset prompt template, wherein the preset prompt template includes a preset prompt text sub-template, a knowledge sub-template, and a data sub-template with a preset concatenation relationship; filling the preset domain knowledge into preset empty spaces in the knowledge sub-template, and filling the initial query result into preset empty spaces in the data sub-template to obtain the target prompt information. This improves the efficiency and accuracy of constructing target prompt information.
[0050] For example, the preset prompt template may include three template fragments, namely the preset prompt text sub-template, the knowledge sub-template, and the data sub-template. The preset splicing relationship may be, for example, splicing them sequentially from front to back, such as the preset prompt text sub-template, the knowledge sub-template, and the data sub-template in the order of front to back.
[0051] For example, the preset prompt text sub-template may include preset text content. This preset text content can be set according to actual needs. For instance, the preset text content may include task definition information, generation guidance information, output format requirements, or output text content requirements. Task definition information could be, for example, "You are now a data query tool; your task is to query data and then answer user questions." Generation guidance information could be, for example, "When performing the task, please provide accurate and useful information to the best of your ability. Always remain objective and professional, ensuring that all information provided is based on data and facts." Output format requirements could be, for example, "Use Markdown as much as possible to write the content," where Markdown is a lightweight markup language that enhances readability. Output text content requirements could be, for example, "Keep the text as concise as possible when answering questions."
[0052] For example, a knowledge sub-template may include knowledge identifiers (such as knowledge names or knowledge types) that may be retrieved from a preset domain knowledge base, as well as preset empty slots corresponding to each knowledge identifier. The number of knowledge identifiers can be set according to the actual needs of the corresponding knowledge domain. Knowledge identifiers may include, for example, the data object name (or indicator name), object unit, object calculation method, object background, and object usage, etc. There can be a one-to-one relationship between knowledge identifiers and preset empty slots. After obtaining the target preset domain knowledge from the preset domain knowledge base, the target preset domain knowledge is filled into the corresponding preset empty slots according to the knowledge identifiers.
[0053] For example, a data sub-template may include data identifiers for data that can be retrieved through a query function, as well as preset empty spaces corresponding to each data identifier. The number of data identifiers can be set according to actual needs. Data identifiers may include, for example, trend data or data summary results. The relationship between data identifiers and preset empty spaces can be one-to-one, with the initial query results being filled into the corresponding preset empty spaces based on the data identifiers.
[0054] For example, after filling the preset empty spaces in the knowledge sub-template of the preset prompt template with the target preset domain knowledge and filling the preset empty spaces in the data sub-template of the preset prompt template with the initial query results, the resulting filled preset prompt template can be used as the target prompt information. That is, the target prompt information includes a preset prompt text sub-template with a preset splicing relationship, a knowledge sub-template filled with the target preset domain knowledge, and a data sub-template filled with the initial query results.
[0055] In some embodiments, the preset domain knowledge base is a vector database, and the preset domain knowledge is a preset text fragment vector. The step of obtaining target preset domain knowledge matching the target query parameters from the preset domain knowledge base based on the target query parameters of the target data query question includes: converting the target query parameters of the target data query question into a target query parameter vector; calculating the similarity between the target query parameter vector and the preset domain knowledge in the preset domain knowledge base; and determining the target preset domain knowledge matching the target query parameters based on the preset domain knowledge whose similarity meets preset similarity requirements. Therefore, by using a vector database to store preset domain knowledge in the form of preset text fragment vectors, the efficient indexing, support for multiple similarity measures, and good horizontal scalability of vector databases can be utilized to improve the efficiency of obtaining target preset domain knowledge, adapt to the rapid development of knowledge domains, and improve the accuracy of data query results.
[0056] For example, the Text2Vec technique can be used to convert the target query parameters into a vector form to obtain the target query parameter vector. Then, the preset domain knowledge that meets the similarity requirement with the target query parameter vector can be searched from the preset domain knowledge base to determine the target preset domain knowledge that matches the target query parameters.
[0057] Figure 2 This is a flowchart illustrating a data query method provided in an embodiment of the present disclosure. The embodiments of the present disclosure optimize the various optional solutions described above, refining the steps related to determining the initial query results for the target data query problem using a preset large language model. Specifically, the method includes the following steps:
[0058] Step 201: Use a pre-defined large language model to convert the target data query problem into target DSL data corresponding to the target knowledge domain, and determine the function parameter data based on the target DSL data.
[0059] For example, prior to this step, the process may include obtaining the target data query question input by the user. For instance, the target data query question might be "What was the capacity utilization rate for the first half of the year?".
[0060] For example, a Domain Specific Language (DSL) is a computer programming language designed for a specific domain, typically used to solve specific types of problems within that domain. Since the target data query problem is a data query problem expressed in natural language, it can first be converted into DSL format data (denoted as target DSL data). Then, based on the target DSL data, the input parameter data required by the function used for data querying can be determined, denoted as function parameter data. The specific form of the DSL language is not limited; for example, it can include Natural Language to JSON (NL2JSON), Natural Language to API (NL2API), or Natural Language to SQL (NL2SQL), etc.
[0061] Optionally, this step may include: inputting preset input data and the target data query question into the preset large language model to obtain target DSL data corresponding to the target knowledge domain output by the preset large language model; determining function parameter names based on the key names in the target DSL data; determining function parameter values for the function parameter names based on the key values corresponding to the key names in the target DSL data; and obtaining function parameter data.
[0062] The preset input data is input data preset for the target knowledge domain. The preset input data includes preset prompt text, preset data structure, and example DSL data that satisfies the preset data structure. The preset data structure is a structure in which key names and key values correspond.
[0063] For example, the preset prompt text can be set according to actual needs. For instance, the preset text content may include task definition information, generation guidance information, output format requirements, or output text content requirements. The preset text content could include: "Your task now is to understand the user's data query question and return data in the specified format. You need to fully utilize AI parsing capabilities to capture the user's true query intent to the greatest extent possible and convert it into query conditions. If the user's query does not explicitly specify a time range, you need to complete the query with reasonable time information based on the context or general logic. When providing options, you need to consider referencing option information from the historical context."
[0064] For example, the preset data structure is the data structure that the target DSL data needs to satisfy. It can be set according to the actual needs of the target knowledge domain and can be in JSON string format. The preset data structure is a structure with corresponding key names and key values. The key name may include, for example, the query object (such as a data metric, which can be denoted as metric_key), the aggregation method of the query object (such as calculating the average or sum, which can be denoted as aggregate), the data query filtering conditions (which can be denoted as filter), and the data query aggregation fields (which can be denoted as group_by), etc. It may also include more granular subkey names, such as function identifiers, category lists, classification lists, priority lists, and workload names in the data query filtering conditions. The sample DSL data that meets the preset data structure can be defined by the developers according to the actual application scenario of the target knowledge domain, thereby helping the preset large language model to generate DSL data with the preset data structure without retraining. The sample DSL data may include key names and key values as example values.
[0065] For example, as described above, the output target DSL data may include a query object (key name) with a fixed capacity rate (key value).
[0066] For example, after obtaining the target DSL data, it can be interpreted as a JSON string to obtain a hash data structure in the corresponding programming language, such as a Python Dict or a Golang Map. The hash data structure includes keys and values. The key names in the target DSL data correspond to the keys in the hash data structure, and the key-value pairs in the target DSL data correspond to the values in the hash data structure. The keys in the hash data structure are set as the parameter names of a preset query function, and the values in the hash data structure are set as the parameter values of the preset query function. That is, the key names in the target DSL data correspond to the parameter names of the preset query function, and the key-value pairs corresponding to a specific key name in the target DSL data correspond to the parameter values of the parameter names in the preset query function. For example, if the key name in the target DSL data queries an object, and the corresponding key value is a delivery period, the parameter name in the preset query function is the query object represented in the programming language, and the corresponding parameter value is the delivery period represented in the programming language.
[0067] For example, as described above, the function parameter data includes a function parameter name that is a query object represented in a programming language, and a corresponding parameter value that is a capacities represented in a programming language.
[0068] Step 202: Using the preset large language model, determine the target query function based on the target data query question, the preset query function set, and the description information of the preset query functions in the preset query function set. The target query function is a preset query function in the preset query function set.
[0069] For example, the preset query function set includes multiple preset query functions, specifically including function names. Different preset query functions can implement different data query functions. The description information of the preset query functions can include information describing the data query function of the preset query function, such as function declaration information. The preset query functions and their corresponding description information can be pre-defined according to actual needs. The target data query question, the preset query function set, and the description information of the preset query functions in the preset query function set are input into the preset large language model, enabling the preset large language model to understand the target data query question and select an appropriate preset query function as the target query function based on the description information.
[0070] For example, the preset large language model may include a function call interface. By inputting the target data query question, a preset set of query functions, and descriptions of the preset query functions in the preset set into the function call interface, the target query function can be obtained. As exemplified above, the preset large language model can filter out query functions related to the fixed capacity ratio, such as preset query functions for querying the fixed capacity ratio, the number of fixed capacity numerators, and the number of fixed capacity denominators, as the target query function.
[0071] Step 203: Based on the function parameter data, perform data query by calling the target query function to obtain the initial query results for the target data query problem.
[0072] It should be noted that the specific execution order of steps 201 and 202 is not limited. For example, step 202 can be executed before step 201, and steps 201 and 202 can be executed in parallel.
[0073] For example, after obtaining the function parameter data and the target query function through steps 201 and 202 respectively, the target query function can be called, using the function parameter data as its input. This allows the target query function to perform the corresponding data query operation based on the function parameter data, obtaining the initial query result for the target data query problem. For instance, data related to the fixed capacity ratio can be retrieved as the initial query result.
[0074] Step 204: Convert the target query parameters of the target data query problem into a target query parameter vector.
[0075] Step 205: Calculate the similarity between the target query parameter vector and the preset domain knowledge in the preset domain knowledge base.
[0076] Step 206: Based on the preset domain knowledge that meets the preset similarity requirements, determine the target preset domain knowledge that matches the target query parameters.
[0077] Optionally, the target query parameter is the query object, and the preset domain knowledge in the preset domain knowledge base that is associated with the same preset object carries the same preset tags. This step may include: determining the preset domain knowledge whose similarity meets the preset similarity requirement as initial preset domain knowledge; obtaining the target preset tags carried by the initial preset domain knowledge; and determining the preset domain knowledge carrying the target preset tags as target preset domain knowledge that matches the target query parameter. Therefore, for multiple preset domain knowledge items associated with the same preset object, if one of them meets the similarity requirement with the target query parameter, the remaining preset domain knowledge items can be quickly obtained based on the preset tags, effectively improving the efficiency and comprehensiveness of obtaining target preset domain knowledge.
[0078] For example, when the vector length in the vector database is limited, domain knowledge associated with the same preset object can be stored in different text fragment vectors carrying the same preset label to meet the requirements of the vector database, and the preset labels can be used to establish the connection between preset domain knowledge associated with the same preset object. For cases where different preset objects are associated with the same preset domain knowledge, for example, if two different preset objects (denoted as A and B) have the same project background, then the introduction of preset object A, the calculation method of preset object A, and the project background can be associated with label 'a', and the introduction of preset object B, the calculation method of preset object B, and the project background can be associated with label 'b'. That is, the project background is associated with both label 'a' and label 'b', eliminating the need to repeatedly store the text fragment vectors corresponding to the project background.
[0079] For example, in the preset domain knowledge base, five text fragment vectors are used to store the data object description, object unit, object calculation method, object background, and object usage corresponding to the seven-day demand capacity rate (preset object). The data object description contains "seven-day demand capacity rate" and meets the similarity requirement with the capacity rate. It can be identified as the initial preset domain knowledge. Then, preset domain knowledge that is associated with the same preset tag as the data object description is identified as the target preset domain knowledge, which is how the above five text fragment vectors are obtained.
[0080] Step 207: Obtain a preset prompt template, wherein the preset prompt template includes a preset prompt text sub-template, a knowledge sub-template, and a data sub-template that have preset splicing relationships.
[0081] Step 208: Fill the preset empty spaces in the knowledge sub-template with the target preset domain knowledge, and fill the preset empty spaces in the data sub-template with the initial query results to obtain the target prompt information.
[0082] For example, as illustrated above, the filled-in knowledge sub-template could be: Indicator name: Seven-day demand capacity ratio. Indicator unit: Percentage. Indicator calculation method: ... Indicator background: ..., main purpose: ... Indicator results objectively reflect: ... Usage: ...
[0083] For example, as in the example above, the populated data sub-template could be: Summary results: ...; Trend data as follows: ...
[0084] Step 209: Using the preset large language model, determine the target query result for the target data query question based on the target prompt information and the target data query question.
[0085] For example, the target prompt information and the target data query question are input into a preset large language model, which then outputs the target query results. It should be noted that the preset large language model used in each step of this disclosure can be the same preset large language model, in order to further reduce model usage costs and improve model application efficiency.
[0086] For example, as illustrated above, the target query result could be: Your query object is capacity limit rate, the query range is from January 1, 2024 to June 30, 2024, the corresponding indicator name is seven-day demand capacity limit rate, according to the query results, the seven-day demand capacity limit rate is…, the retrieved trend data is as follows:…. The calculation method for this indicator is…, this indicator is a data indicator of…, which can help us understand…, objectively reflecting….
[0087] The data query method provided in this disclosure, in an application scenario where a preset large language model is used to answer data query questions in a target knowledge domain, converts the target data query question into target DSL data corresponding to the target knowledge domain using the preset large language model, determines function parameter data based on the target DSL data, and uses the preset large language model to determine the target query function based on the target data query question, a preset query function set, and the description information of the preset query functions in the preset query function set. Based on the function parameter data, the target query function is called to perform a data query, obtaining the initial query result of the target data query question. Then, the target query parameters of the target data query question are converted into a target query parameter vector. Based on the similarity between the vectors, target preset domain knowledge is recalled to obtain the target preset domain knowledge. The initial query result and the obtained target preset knowledge domain are filled into a preset prompt template to quickly and accurately construct prompt information for input into the preset large language model. This allows the preset large language model to efficiently and accurately obtain relevant knowledge of the target knowledge domain from the prompt information as reference information, further improving the accuracy and efficiency of question answering and enhancing the timeliness of the large language model application.
[0088] Figure 3 This is a schematic diagram of the structure of a data query device provided in an embodiment of the present disclosure, as shown below. Figure 3 As shown, the device includes:
[0089] The initial query result determination module 301 is used to determine the initial query result of the target data query problem using a preset large language model, wherein the target data query problem is a data query problem expressed in natural language for the target knowledge domain;
[0090] The domain knowledge acquisition module 302 is used to acquire target preset domain knowledge that matches the target query parameters from a preset domain knowledge base based on the target query parameters of the target data query question, wherein the preset domain knowledge base includes preset domain knowledge of the target knowledge domain;
[0091] The prompt information construction module 303 is used to construct target prompt information based on the target preset domain knowledge and the initial query results;
[0092] The target query result determination module 304 is used to determine the target query result of the target data query question based on the target prompt information and the target data query question using the preset large language model.
[0093] The data query device provided in this embodiment, in an application scenario where a preset large language model is used to answer data query questions in a target knowledge domain, first uses the preset large language model to determine the initial query result, then obtains matching target preset domain knowledge from a preset domain knowledge base according to the target query parameters of the target data query question, and combines the initial query result and the obtained target preset knowledge domain to construct prompt information for input into the preset large language model. This allows the preset large language model to obtain relevant knowledge of the target knowledge domain from the prompt information as reference information, thereby providing a targeted and high-quality answer that conforms to the target knowledge domain. This improves the accuracy of data query and question answering and enhances the timeliness of large language model application without requiring retraining of the preset large language model for the target knowledge domain.
[0094] Optionally, the prompt information construction module includes:
[0095] The prompt template acquisition unit is used to acquire a preset prompt template, wherein the preset prompt template includes a preset prompt text sub-template, a knowledge sub-template, and a data sub-template that have a preset splicing relationship;
[0096] The template filling unit is used to fill the preset empty spaces in the knowledge sub-template with the target preset domain knowledge, and to fill the preset empty spaces in the data sub-template with the initial query results to obtain target prompt information.
[0097] Optionally, the preset domain knowledge base is a vector database, and the preset domain knowledge is a preset text fragment vector;
[0098] The domain knowledge acquisition module includes:
[0099] A vector conversion unit is used to convert the target query parameters of the target data query problem into a target query parameter vector.
[0100] A similarity calculation unit is used to calculate the similarity between the target query parameter vector and the preset domain knowledge in the preset domain knowledge base;
[0101] The target domain knowledge determination unit is used to determine the target preset domain knowledge that matches the target query parameters based on the preset domain knowledge that meets the preset similarity requirements.
[0102] Optionally, the target query parameter is the query object, and the preset domain knowledge in the preset domain knowledge base that is associated with the same preset object carries the same preset tag;
[0103] The target domain knowledge determination unit includes:
[0104] The initial knowledge determination subunit is used to determine the preset domain knowledge whose similarity meets the preset similarity requirements as the initial preset domain knowledge;
[0105] The tag acquisition subunit is used to acquire the target preset tags carried by the initial preset domain knowledge;
[0106] The target knowledge determination subunit is used to determine the preset domain knowledge carrying the target preset label as the target preset domain knowledge that matches the target query parameters.
[0107] Optionally, the initial query result determination module includes:
[0108] The parameter data determination unit is used to convert the target data query problem into target domain-specific language DSL data corresponding to the target knowledge domain using a preset large language model, and to determine function parameter data based on the target DSL data;
[0109] The function determination unit is used to determine the target query function by utilizing the preset large language model, based on the target data query question, the preset query function set, and the description information of the preset query functions in the preset query function set, wherein the target query function is a preset query function in the preset query function set;
[0110] The function call unit is used to perform data query by calling the target query function based on the function parameter data, and obtain the initial query result of the target data query problem.
[0111] Optionally, the parameter data determination unit includes:
[0112] The language conversion subunit is used to input preset input data and the target data query question into the preset large language model to obtain the target DSL data corresponding to the target knowledge domain output by the preset large language model. The preset input data is preset input data for the target knowledge domain. The preset input data includes preset prompt text, preset data structure and example DSL data that satisfy the preset data structure. The preset data structure is a structure in which key names and key values correspond.
[0113] The parameter determination subunit is used to determine the function parameter name based on the key name in the target DSL data, and to determine the function parameter value of the function parameter name based on the key value corresponding to the key name in the target DSL data, thereby obtaining function parameter data.
[0114] The data query device provided in this disclosure can execute the data query method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0115] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this disclosure.
[0116] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Reference is made below. Figure 4 It illustrates an electronic device suitable for implementing embodiments of the present disclosure (e.g., Figure 4 The diagram below shows the structure of the terminal device or server 400. The terminal device in this embodiment may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and vehicle terminals (e.g., vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 4 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0117] like Figure 4 As shown, electronic device 400 may include a processing unit (e.g., central processing unit, graphics processor, etc.) 401, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 402 or a program loaded from storage device 408 into random access memory (RAM) 403. The RAM 403 also stores various programs and data required for the operation of electronic device 400. The processing unit 401, ROM 402, and RAM 403 are interconnected via bus 404. An edit / output (I / O) interface 405 is also connected to bus 404.
[0118] Typically, the following devices can be connected to I / O interface 405: input devices 406 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 407 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 408 including, for example, magnetic tapes, hard disks, etc.; and communication devices 409. Communication device 409 allows electronic device 400 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 4 An electronic device 400 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0119] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 409, or installed from storage device 408, or installed from ROM 402. When the computer program is executed by processing device 401, it performs the functions defined in the methods of embodiments of this disclosure.
[0120] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0121] The electronic device provided in this embodiment and the data query method provided in the above embodiments belong to the same inventive concept. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0122] This disclosure provides a computer storage medium storing a computer program that, when executed by a processor, implements the data query method provided in the above embodiments.
[0123] This disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the data query method provided in the above embodiments.
[0124] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0125] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0126] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: determine an initial query result for a target data query problem using a preset large language model, wherein the target data query problem is a data query problem expressed in natural language for a target knowledge domain; obtain target preset domain knowledge matching the target query parameters from a preset domain knowledge base, wherein the preset domain knowledge base includes preset domain knowledge of the target knowledge domain; construct target prompt information based on the target preset domain knowledge and the initial query result; and determine the target query result for the target data query problem using the preset large language model, based on the target prompt information and the target data query problem.
[0127] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0128] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0129] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a module does not necessarily limit the module itself; for example, a prompt information construction module can also be described as "a module that constructs target prompt information based on the target preset domain knowledge and the initial query results".
[0130] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0131] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0132] According to one or more embodiments of this disclosure, a data query method is provided, comprising:
[0133] The initial query results for the target data query problem are determined using a pre-defined large language model, wherein the target data query problem is a data query problem expressed in natural language for a target knowledge domain;
[0134] Based on the target query parameters of the target data query question, target preset domain knowledge that matches the target query parameters is obtained from a preset domain knowledge base, wherein the preset domain knowledge base includes preset domain knowledge of the target knowledge domain;
[0135] Target prompt information is constructed based on the target preset domain knowledge and the initial query results;
[0136] Using the preset large language model, the target query result for the target data query question is determined based on the target prompt information and the target data query question.
[0137] According to one or more embodiments of this disclosure, constructing target prompt information based on the target preset domain knowledge and the initial query results includes:
[0138] Obtain a preset prompt template, wherein the preset prompt template includes a preset prompt text sub-template, a knowledge sub-template, and a data sub-template that have a preset splicing relationship;
[0139] The target preset domain knowledge is filled into the preset empty space in the knowledge sub-template, and the initial query result is filled into the preset empty space in the data sub-template to obtain the target prompt information.
[0140] According to one or more embodiments of this disclosure, the preset domain knowledge base is a vector database, and the preset domain knowledge is a preset text fragment vector;
[0141] The step of obtaining target preset domain knowledge matching the target query parameters from a preset domain knowledge base based on the target query parameters of the target data query question includes:
[0142] Convert the target query parameters of the target data query problem into a target query parameter vector;
[0143] Calculate the similarity between the target query parameter vector and the preset domain knowledge in the preset domain knowledge base;
[0144] Based on the preset domain knowledge whose similarity meets the preset similarity requirements, the target preset domain knowledge that matches the target query parameters is determined.
[0145] According to one or more embodiments of this disclosure, the target query parameter is a query object, and the preset domain knowledge in the preset domain knowledge base that is associated with the same preset object carries the same preset tag;
[0146] Specifically, determining the target preset domain knowledge that matches the target query parameters based on preset domain knowledge whose similarity meets preset similarity requirements includes:
[0147] The preset domain knowledge whose similarity meets the preset similarity requirements is determined as the initial preset domain knowledge;
[0148] Obtain the target preset tags carried by the initial preset domain knowledge;
[0149] Preset domain knowledge carrying the target preset label is identified as target preset domain knowledge that matches the target query parameters.
[0150] According to one or more embodiments of this disclosure, determining the initial query result for the target data query problem using a preset large language model includes:
[0151] The target data query problem is converted into target domain-specific language DSL data corresponding to the target knowledge domain using a pre-defined large language model, and the function parameter data is determined based on the target DSL data;
[0152] Using the preset large language model, the target query function is determined based on the target data query question, the preset query function set, and the description information of the preset query functions in the preset query function set, wherein the target query function is a preset query function in the preset query function set;
[0153] Based on the function parameter data, the target query function is called to perform a data query, and the initial query result for the target data query problem is obtained.
[0154] According to one or more embodiments of this disclosure, the target data query problem is converted into target DSL data corresponding to the target knowledge domain using the preset large language model, and function parameter data is determined based on the target DSL data, including:
[0155] The preset input data and the target data query question are input into the preset large language model to obtain the target DSL data corresponding to the target knowledge domain output by the preset large language model. The preset input data is preset input data for the target knowledge domain. The preset input data includes preset prompt text, preset data structure and example DSL data that satisfy the preset data structure. The preset data structure is a structure in which key names and key values correspond.
[0156] The function parameter name is determined based on the key name in the target DSL data, and the function parameter value of the function parameter name is determined based on the key value corresponding to the key name in the target DSL data, thus obtaining the function parameter data.
[0157] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0158] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0159] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A data query method, characterized in that, include: The initial query results for the target data query problem are determined using a pre-defined large language model, wherein the target data query problem is a data query problem expressed in natural language for a target knowledge domain; Based on the target query parameters of the target data query question, target preset domain knowledge that matches the target query parameters is obtained from a preset domain knowledge base, wherein the preset domain knowledge base includes preset domain knowledge of the target knowledge domain; Target prompt information is constructed based on the target preset domain knowledge and the initial query results; Using the preset large language model, the target query result for the target data query question is determined based on the target prompt information and the target data query question.
2. The method according to claim 1, characterized in that, The step of constructing target prompt information based on the target preset domain knowledge and the initial query results includes: Obtain a preset prompt template, wherein the preset prompt template includes a preset prompt text sub-template, a knowledge sub-template, and a data sub-template that have a preset splicing relationship; The target preset domain knowledge is filled into the preset empty space in the knowledge sub-template, and the initial query result is filled into the preset empty space in the data sub-template to obtain the target prompt information.
3. The method according to claim 1, characterized in that, The preset domain knowledge base is a vector database, and the preset domain knowledge is a preset text fragment vector; The step of obtaining target preset domain knowledge matching the target query parameters from a preset domain knowledge base based on the target query parameters of the target data query question includes: Convert the target query parameters of the target data query problem into a target query parameter vector; Calculate the similarity between the target query parameter vector and the preset domain knowledge in the preset domain knowledge base; Based on the preset domain knowledge whose similarity meets the preset similarity requirements, the target preset domain knowledge that matches the target query parameters is determined.
4. The method according to claim 3, characterized in that, The target query parameter is the query object, and the preset domain knowledge in the preset domain knowledge base that is associated with the same preset object carries the same preset tag; Specifically, determining the target preset domain knowledge that matches the target query parameters based on preset domain knowledge whose similarity meets preset similarity requirements includes: The preset domain knowledge whose similarity meets the preset similarity requirements is determined as the initial preset domain knowledge; Obtain the target preset tags carried by the initial preset domain knowledge; Preset domain knowledge carrying the target preset label is identified as target preset domain knowledge that matches the target query parameters.
5. The method according to claim 1, characterized in that, The process of determining the initial query results for the target data query problem using a pre-set large language model includes: The target data query problem is converted into target domain-specific language DSL data corresponding to the target knowledge domain using a pre-defined large language model, and the function parameter data is determined based on the target DSL data; Using the preset large language model, the target query function is determined based on the target data query question, the preset query function set, and the description information of the preset query functions in the preset query function set, wherein the target query function is a preset query function in the preset query function set; Based on the function parameter data, the target query function is called to perform a data query, and the initial query result for the target data query problem is obtained.
6. The method according to claim 5, characterized in that, The target data query problem is transformed into target DSL data corresponding to the target knowledge domain using the preset large language model, and function parameter data is determined based on the target DSL data, including: The preset input data and the target data query question are input into the preset large language model to obtain the target DSL data corresponding to the target knowledge domain output by the preset large language model. The preset input data is preset input data for the target knowledge domain. The preset input data includes preset prompt text, preset data structure and example DSL data that satisfy the preset data structure. The preset data structure is a structure in which key names and key values correspond. The function parameter name is determined based on the key name in the target DSL data, and the function parameter value of the function parameter name is determined based on the key value corresponding to the key name in the target DSL data, thus obtaining the function parameter data.
7. A data query device, characterized in that, include: The initial query result determination module is used to determine the initial query result of the target data query problem using a preset large language model, wherein the target data query problem is a data query problem expressed in natural language for the target knowledge domain; The domain knowledge acquisition module is used to acquire target preset domain knowledge that matches the target query parameters from a preset domain knowledge base based on the target query parameters of the target data query question, wherein the preset domain knowledge base includes preset domain knowledge of the target knowledge domain; The prompt information construction module is used to construct target prompt information based on the target preset domain knowledge and the initial query results; The target query result determination module is used to determine the target query result of the target data query question based on the preset large language model, the target prompt information, and the target data query question.
8. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the data query method as described in any one of claims 1-6.
9. A storage medium containing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the data query method as described in any one of claims 1-6.
10. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the data query method as described in any one of claims 1-6.