Data query method and system, electronic device, storage medium, and program product
By generating target code through a natural language model and combining it with a parameter database and knowledge graph, we can overcome the high threshold of traditional SQL query methods and the inability of NL2SQL to meet complex question-answering requirements, thus achieving efficient and accurate data query without SQL knowledge.
Patent Information
- Application Number
- PCT/IB2025/051239
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-28
- Filing Date
- 2025-02-06
- Publication Date
- 2025-10-02
AI Technical Summary
Traditional data query methods using structured query language (SQL) have high business and technical capability thresholds and are inefficient. Existing natural language to structured query language (NL2SQL) technology cannot meet the data processing requirements of complex questions and answers, and it is difficult to identify and correct ambiguous conditions, support fuzzy questions and answers, and generate correct and accurate answers.
Generate target code through natural language models, query data directly in the target database, use parameter database to store data query parameters, combine knowledge graph and time enhancement model to rewrite the problem, generate code that can extract target data in the target database, execute the code to output response information, lower the user's business and technical ability threshold, and simplify the user's interaction with data.
It enables users to intelligently extract data from the target database without having to master SQL knowledge, lowering the business and technical capability threshold for queries, simplifying user interaction with data, and improving the efficiency and accuracy of data queries.
Smart Images

Figure IB2025051239_02102025_PF_FP_ABST
Abstract
Description
[0001] Data Query Method, System, Electronic Device, Storage Medium, and Program Product This disclosure claims priority to Chinese patent application number 202410373569.6, filed with the China Patent Office on March 28, 2024, the entire contents of which are incorporated herein by reference. Technical Field This disclosure relates to the field of artificial intelligence technology, and more particularly to a data query method, a data query system, an electronic device, a computer-readable storage medium, and a computer program product. Background In the current era of big data and informatization, businesses across all industries generate massive amounts of data in their operations. Cleaning up high-quality data to assist business decision-making is a common need. However, traditional data information is typically extracted manually by specialized data engineers using Structured Query Language (SQL), which has certain business and technical requirements and is inefficient. SUMMARY OF THE INVENTION Embodiments of the present disclosure provide a data query method, a data query system, an electronic device, a computer-readable storage medium, and a computer program product to alleviate or resolve one or more technical problems existing in the prior art. In a first aspect, embodiments of the present disclosure provide a data query method, comprising receiving input information; retrieving data query parameters related to the input information from a parameter database; generating target code based on the data query parameters; executing the target code to query a target database for target data corresponding to the data query parameters and outputting a response message containing the target data. In a second aspect, embodiments of the present disclosure provide a data query method, comprising: sending input information to a server; receiving a response message containing the target data returned by the server; wherein the server is configured to retrieve data query parameters related to the input information from a parameter database, generate target code based on the data query parameters, and execute the target code to query a target database for target data corresponding to the data query parameters. In a third aspect, embodiments of the present disclosure provide a data query system, comprising: a client, configured to send input information to a server; a server, configured to implement any method of embodiments of the present disclosure to query a target database for target data corresponding to data query parameters, and return a reply message carrying the target data to the client; a target database, configured to store the target data; and a parameter database, configured to store the data query parameters.In a fourth aspect, embodiments of the present disclosure provide an electronic device comprising a memory, a processor, and a computer program stored in the memory. When executing the computer program, the processor implements any of the methods of the embodiments of the present disclosure. In a fifth aspect, embodiments of the present disclosure provide a computer-readable storage medium storing a computer program. When executed by the processor, the computer program implements any of the methods of the embodiments of the present disclosure. In a sixth aspect, embodiments of the present disclosure provide a computer program product comprising the computer program. When executed by the processor, the computer program implements any of the methods of the embodiments of the present disclosure. Based on the data query method of the embodiments of the present disclosure, by obtaining data query parameters related to input information (e.g., table names, rows, and columns in a target database), code is generated that can extract target data from the target database based on the data query parameters. Executing the code can perform data processing and directly output a reply message containing the target data. This facilitates intelligent data extraction from the target database in a question-and-answer format for users, lowering the business and technical requirements for data querying, simplifying user interaction with data, and improving data query efficiency. The above description is merely an overview of the technical solutions of the present disclosure. To better understand the technical solutions of the present disclosure, implementations may be made in accordance with the contents of this specification. To further enhance the understanding of the above and other objectives, features, and advantages of the present disclosure, specific embodiments of the present disclosure are described below. In the accompanying drawings, unless otherwise specified, identical reference numerals throughout the various figures denote identical or similar components or elements. The drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments of the present disclosure and should not be construed as limiting the scope of the present disclosure. Figure 1 is a schematic diagram of the architecture of a data query system provided in an embodiment of the present disclosure; Figure 2 is a flowchart of a data query method in an embodiment of the present disclosure; Figure 3 is a schematic diagram of a framework for implementing the data query method in an embodiment of the present disclosure; Figure 4 is a flowchart of a data query method in an embodiment of the present disclosure; Figure 5 is a schematic diagram of a data query device in an embodiment of the present disclosure; and Figure 6 is a block diagram of an electronic device for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS The following briefly describes certain exemplary embodiments. As will be appreciated by those skilled in the art, the described embodiments may be modified in various ways without departing from the spirit or scope of the present disclosure. Therefore, the drawings and descriptions are to be considered illustrative in nature and not restrictive. To facilitate understanding of the technical solutions of the embodiments of the present disclosure, the following describes the relevant technologies of the embodiments of the present disclosure.The following related technologies are optional solutions that can be combined with the technical solutions of the embodiments of the present disclosure in any manner and are all within the scope of protection of the embodiments of the present disclosure. Generally, data can be stored in a database. A database is a warehouse that organizes, stores, and manages data according to a data structure. Structurally, a database is typically divided into different areas to store data of different subjects. Large amounts of data are stored in the form of data tables, classified into different categories. A data table is a structured file. A data table is labeled with a table name, which should be unique within the same database. In other words, the combination of the database name and the table name should be unique. Furthermore, a data table consists of one or more columns. Each column stores specific information, which is also called a field. For example, in an order information table, one column stores the order number and another column stores the order date. Both the order number and the order date are fields. In some databases, data is stored in rows, with each row representing a record. For example, in an order information table, each row stores information related to a single order. Structured Query Language (SQL) is a simple database query and programming language used to access data, as well as query, update, and manage relational database systems. However, using SQL presents certain business and technical requirements. Simultaneously, the development of Large Language Models (LLMs) is rapidly progressing. These models can handle a variety of natural language tasks, such as text classification, question answering, and conversation, and are a key path toward artificial intelligence. Therefore, how to intelligently extract data or perform data question answering through natural language question answering is a hot research topic. To address this, the Natural Language to Structured Query Language (NL2SQL) project has emerged. NL2SQL converts user-entered natural language into executable SQL statements, and relevant applications are already available. However, a technical approach based solely on SQL for question answering cannot meet the data processing requirements of complex question answering, and therefore has certain limitations. Furthermore, current NL2SQL technology cannot identify and correct ambiguous conditions in questions during the question-answering process. This results in an inability to support ambiguous questions and answers, making it difficult to meet user questioning habits and generate correct and accurate answers. Figure 1 is a schematic diagram of the architecture of a data query system provided by an embodiment of the present disclosure. As shown in Figure 1, the data query system may include a client, a server, a target database, and a parameter database.The target database is used to store target data, and the parameter database is used to store data query parameters related to the target data. In an exemplary application scenario, a user wishes to query the target data from the target database. For example, the target data may be an indicator stored in the target database. Generally, querying an indicator in the target database requires querying based on parameters related to the indicator. For example, an indicator such as a deposit interest rate may be queried based on parameters such as time, bank name, and deposit type. The parameter database can be used to store data query parameters related to the target data, such as those related to the aforementioned indicators. In the application scenario shown in Figure 1, according to an embodiment of the present disclosure, a user can interact with a server through a client to query the target data in the target database. First, the user can enter data query information into the server through the client. The server is configured to access the parameter database to obtain data query parameters related to the input information and use the data query parameters to query the target data in the target database. The server can then return the target data to the client in natural language. In other words, the server can output a reply message containing the target data to the client. Specifically, after obtaining data query parameters, the server can use a natural language model to generate target code based on the data query parameters. This target code is used to process the target data into response information after searching the target database based on the data query parameters. The server then executes the target code to obtain the response information. In other words, the server leverages the capabilities of the natural language model to generate code that can convert data query parameters into response information. No SQL statements are generated during this process; simply executing the code can yield the response information carrying the target data. Optionally, the parameter database can be constructed based on the target database. For example, the target database includes multiple data tables. The parameter database can be constructed by extracting metadata such as table names, row information (e.g., record indexes), and column information (e.g., field names) from the data tables, and / or extracting searchable value information from the data tables. Thus, the information in the parameter database can be used as parameters for querying indicators in the target database. It should be noted that the aforementioned application scenarios or application examples of the data query method provided in the embodiments of the present disclosure are provided for ease of understanding, and the embodiments of the present disclosure do not specifically limit the application of the data query method.In addition, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, storage, and display) involved in this disclosure are all authorized by the user or fully authorized by all parties. The collection, use, and processing of the relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation portals are provided for users to select, edit, authorize, or reject. The following describes in detail the technical solutions of this disclosure and how they address the aforementioned technical issues using specific embodiments. The specific embodiments listed above may be combined with each other, and identical or similar concepts or processes may not be described in detail in certain embodiments. Figure 2 shows a flow chart of a data query method according to an embodiment of this disclosure. This data query method can be applied to the server shown in Figure 1, but is not limited thereto. As shown in Figure 2, the data query method may include: Step S201: Receive input information. Exemplarily, the input information may be a query entered by the user. Optionally, the input information is in natural language, or in a colloquial manner. Alternatively, the input information may be in any form that conforms to user input habits. In other words, users do not need to master SQL-related knowledge to construct SQL statements. For example, users can send input information to the server through the client. Step S202: Retrieve data query parameters related to the input information from the parameter database. For example, the input information can be matched with information in the parameter database, for example, by performing a similarity calculation, thereby retrieving data query parameters related to the input information. The parameter database can be a preconfigured database for storing multiple data query parameters. Optionally, the information in the parameter database is obtained based on metadata and partial value information of data in the target database. Step S203: Generate target code based on the data query parameters. Optionally, the target code can be generated using a natural language model. A natural language model (LLM) can also be called a large language model, large language model, or large model. Natural language models have natural language processing capabilities. Based on this, natural language statements can be processed based on the data query parameters. These natural language statements are then input into the natural language model to guide the natural language model in generating target code. Optionally, the natural language statement may include code generation step instructions, code generation rule conventions, code generation examples, etc., so that the natural language model can accurately generate target code based on natural language processing capabilities, reducing the requirements for the code generation business capabilities of the natural language model.Here, the target code, when executed by the processor, is configured to: query the target database for target data corresponding to the data query parameters and output a response message containing the target data. In other words, the target code is configured to query (or extract) the target data. Step S204: Execute the target code to query the target database for the target data corresponding to the data query parameters and output a response message containing the target data. Because the target code, when executed by the processor, implements the aforementioned functions, the data query device can output a response message containing the target data. Here, the response message containing the target data refers to a natural language response statement containing the target data information. In this way, when the user retrieves the response message, they can obtain the target data. The data query method according to the embodiments of the present disclosure obtains data query parameters related to input information (e.g., table names, rows, and columns in a target database) and generates code capable of extracting target data from the target database based on the data query parameters. This allows for intelligent data extraction from the target database, thereby lowering the business and technical requirements for users performing data queries, simplifying user interaction with data, and improving data query efficiency. In one embodiment, in step S202, retrieving data query parameters related to the input information from a parameter database may include: obtaining enhanced information related to the input information; rewriting the input information based on the enhanced information to obtain an enhanced question; and retrieving data query parameters related to the input information from the parameter database based on the enhanced question. The enhanced information may be information that expands or interprets the input information. For example, the enhanced information may include descriptive information and professional knowledge about each entity in the input information, as well as temporal and spatial information related to the input information. Rewriting the input information based on the enhanced information may include standardizing a portion of the description in the input information, expanding the input information, or adding enhanced information to the input information. Therefore, the enhanced question obtained through rewriting contains more precise and comprehensive information than the input information. According to the above-described embodiment, based on the enhanced question, relevant data query parameters can be more accurately and comprehensively matched in the parameter database. In one embodiment, the enhanced information includes professional knowledge information. Accordingly, obtaining enhanced information related to the input information may include: searching for knowledge nodes related to the input information in a knowledge graph based on the input information; and obtaining professional knowledge information based on the knowledge nodes. The knowledge graph is used to visually display various knowledge within the scientific discipline system. Each knowledge node in the knowledge graph is associated with a rich set of professional knowledge.In the above embodiment, named entity recognition can be performed based on the input information to obtain each entity in the input information. The knowledge graph then searches for knowledge nodes that match each entity. It is understood that the matched knowledge nodes are related to the input information. Thus, the professional knowledge associated with each knowledge node can be used as part of the enhanced information. For example, assuming the input information received is "What was the passenger flow at Scenic Area A yesterday?", the knowledge nodes associated with this question in the knowledge graph include "Scenic Area A" and "Passenger flow." The professional knowledge associated with "Scenic Area A" includes "Scenic Area A is a famous natural scenic area in coastal City C, equipped with facilities such as electric tour buses and yacht docks." The professional knowledge associated with "Passenger flow" includes "Passenger flow refers to the number of people entering a location per unit time, which can be understood as the number of travelers flowing, or as the number of people, person-times, etc." By rewriting the input information based on the aforementioned professional knowledge, the input information can be expanded into an enhanced question: "What was the passenger flow at Scenic Area A yesterday? Here, Scenic Area A is a famous natural scenic area in coastal City C, equipped with facilities such as electric tour buses and yacht docks. Passenger flow refers to the number of people entering a certain location per unit time. It can be understood as the number of tourists moving around, and can also be referred to as passenger flow, person-times, etc." In this way, when searching the parameter database based on the enhanced question, even if the accurate data query parameters cannot be matched based on information such as Scenic Area A and passenger flow, the data query parameters can still be matched based on information such as the description of Scenic Area A and the nicknames for passenger flow. This can also help the natural language model accurately understand the question during subsequent processing. As can be seen, according to the above embodiment, by expanding the question with professional knowledge information, the accuracy of parsing the input information can be improved, as can the accuracy of data queries and natural language responses to questions. In one embodiment, the enhanced information includes time information. Accordingly, obtaining enhanced information related to the input information can include: reasoning on the input information using a time enhancement model to obtain the time information. The time enhancement model is used to normalize or standardize time information. For example, assuming the input information received is "What was the visitor volume of scenic spot A yesterday?", the time enhancement model can infer yesterday's date based on the current date and output normalized time information such as the date. This can then be rewritten as "What was the visitor volume of scenic spot A on a certain date in a certain year?" The above implementation facilitates obtaining enhanced information with normalized time information, thereby facilitating the retrieval of accurate data query parameters from the parameter database. It will be appreciated that one or more of the aforementioned embodiments or implementations may be implemented in combination.For example, enhanced information can include both professional knowledge information and time information, and have corresponding technical effects. In one embodiment, before receiving input information, the data query method further includes: obtaining multiple data query parameters based on the metadata and / or value information of the target database; and storing the multiple data query parameters in a parameter database. For example, the target database may include multiple databases, each of which may include multiple data tables, each of which may include multiple rows and columns. According to the above embodiment, database names, table names, row information, column information, etc. can be used as data query parameters, and the data query parameters can be stored in the parameter database. In this way, using the parameter database, parameters that can accurately match data in the target database can be obtained. Optionally, the metadata and / or value information can be segmented or embedded into vectors and then stored in the parameter database. In one embodiment, the parameter database includes a vector database and an ES (Elastic Search) database. Accordingly, searching the parameter database for data query parameters related to the input information may include: retrieving M data query parameters from the vector database, where M is a positive integer; retrieving N data query parameters from the ES database, where N is a positive integer; and determining the data query parameters related to the input information from the M data query parameters and the N data query parameters by sorting them. M and N may be equal or unequal. M and / or N may be pre-set values or values determined based on the search results. For example, M is a pre-set value, and the search in the vector database is performed by extracting M data query parameters with the highest similarity scores to the input information or enhanced question. For another example, M is a value determined based on the search results, and the search in the vector database is performed by extracting data query parameters with a similarity score greater than X to the input information or enhanced question. In this case, the number M of data query parameters is not a fixed value and may vary depending on different practical applications. Optionally, the above embodiment can also be implemented in conjunction with the aforementioned embodiment for storing data query parameters. That is, the vector database and / or the Elastic Search ES database can be used to store multiple data query parameters obtained based on the metadata and / or value information of the target database. For example, the M data query parameters and the N data query parameters can be sorted based on the similarity score between each data query parameter and the input information or the enhanced question.For example, weights can be set separately for the search results from the vector database and the ES database. Based on these weights, a weighted similarity score is calculated for each retrieved data query parameter and sorted from high to low. The data query parameters related to natural language can be one or more data query parameters with the highest similarity scores, or one or more data query parameters with similarity scores above a preset value. In the relevant technical field, ES database searches excel at word-by-word matching, while vector database searches match from a semantic perspective. These two search methods offer different advantages, and by combining the strengths of both, the rationality of the search results can be more accurately ensured. In one embodiment, generating target code using a natural language model based on data query parameters includes: determining model prompt information based on the data query parameters and a preset prompt template; the model prompt information is used to instruct the natural language model to generate code based on examples in the prompt template; and inputting the model prompt information into the natural language model to generate target code. In the above embodiment, the prompt template can include one or more code generation examples. Optionally, the prompt template can also include content indicating code generation steps and code generation precautions. In practical applications, data query parameters can be entered into corresponding positions in the prompt template to generate model prompt information for input into the natural language model. The natural language model can learn to generate target code by understanding the code generation examples in the model prompt information. According to the above embodiment, code generation based on the capabilities of the natural language model allows precise extraction of target data related to the question through code execution, supporting complex data logic processing to generate a response message containing a correct and precise answer. To facilitate understanding of the above technical solution, a specific application example is provided below. Figure 3 shows a schematic diagram of a framework for implementing the data query method of the embodiment of the present disclosure. In this application example, the data query method is implemented based on this framework. Specifically, the framework's preprocessing process stores metadata related to the indicator (or data) and certain value information in the ES and vector databases as a data preparation prerequisite for information retrieval of the question (i.e., the above-mentioned input information). Specifically, indicator metadata and value information are stored in two ways: The indicator description and searchable value are segmented and stored in the ES database, and embedded vectors are calculated and stored in the vector database. In the question-answering process, the framework has the following processing steps:
[0002] 5301. Query Enhancement. First, the query's professional knowledge nodes are combined with the input question to expand the question's professional knowledge information, facilitating accurate understanding of the question by the subsequent natural language model. The question is then rewritten using the time enhancement model to standardize the question's time information. Specifically, the knowledge graph is traversed, query-related knowledge nodes are found, and these are rewritten and enhanced into the query. The time information inferred by the time enhancement model is then rewritten into the query.
[0003] 5302. Information Retrieval. To ensure accurate matching between questions, indicators, and indicator values, the framework utilizes stored indicator-related information to perform two-way recall and comprehensive weighted ranking of ES and vectors. It also corrects the indicator values associated with the question to ensure the accuracy of database data retrieval. Specifically, indicator metadata and value retrieval are performed from the stored vector database and ES for subsequent processing. This step utilizes an advanced embedding algorithm to calculate similarity and a rerank algorithm to sort the recall results, ensuring more accurate and reasonable recall results. From the retrieval results, recall results are filtered based on similarity scores to construct the indicator query parameters.
[0004] 5303. Code Generation. Based on the recall information, a natural language model prompt for code generation is constructed. The natural language model infers the prompt, parses, and cleanses the inference results to generate executable code. Specifically, based on the search results, a preset prompt template is populated to construct a real prompt. The constructed prompt is then fed into the natural language model, and the code is parsed from the inference results.
[0005] 5304. Answer generation. Based on the retrieved indicator information, the framework uses a Python executor to execute the model-generated code to obtain the final answer to the question. Specifically, based on the input indicator query parameters, the indicator database is queried, the corresponding data is loaded, and the code is executed to process the corresponding query logic on the data to obtain the final answer. As can be seen, in the above technical solution, through indicator retrieval, indicator value retrieval, indicator embedding, capability code generation based on the LLM natural language model, and a code executor, the relevant indicators and data for the question are accurately retrieved, and complex data logic processing is supported to generate correct and accurate answers. Figure 4 shows a flowchart of the data query method of an embodiment of the present disclosure. This data query method can be applied to the client shown in Figure 1, but is not limited thereto. As shown in FIG4 , the data query method may include: Step S401: sending input information to a server; Step S402: receiving a reply message containing target data returned by the server; wherein the server is configured to retrieve data query parameters related to the input information from a parameter database, generate target code based on the data query parameters, and execute the target code to query the target database for target data corresponding to the data query parameters. Relevant implementation methods and technical effects can be found in the corresponding introduction to the server, and will not be elaborated here. Corresponding to the application scenarios and data query methods provided in the embodiments of the present disclosure, the embodiments of the present disclosure also provide a data query device 500 oAs shown in Figure 5 , the apparatus 500 may include: a receiving module 501 for receiving input information; a parameter retrieval module 502 for retrieving data query parameters related to the input information from a parameter database; a code generation module 503 for generating target code based on the data query parameters; and a code execution module 504 for executing the target code to query the target database for target data corresponding to the data query parameters and output a response message containing the target data. In one embodiment, the parameter retrieval module 502 is specifically configured to: obtain enhanced information related to the input information; rewrite the input information based on the enhanced information to obtain an enhanced question; and retrieve data query parameters related to the input information from the parameter database based on the enhanced question. In one embodiment, the enhanced information includes professional knowledge information. Accordingly, the parameter retrieval module 502 is configured to: search for knowledge nodes related to the input information in a knowledge graph based on the input information; and obtain professional knowledge information based on the knowledge nodes. In one embodiment, the enhanced information includes time information. Accordingly, the parameter retrieval module 502 is configured to: infer the input information using a time enhancement model to obtain the time information. In one embodiment, the data query device 500 further includes a database configuration module configured to: obtain multiple data query parameters based on metadata and / or value information of a target database; and store the multiple data query parameters in a parameter database. In one embodiment, the parameter database includes a vector database and an elastic search database. Accordingly, the parameter retrieval module 502 is specifically configured to: retrieve M data query parameters from the vector database, where M is a positive integer; retrieve N data query parameters from the elastic search database, where N is a positive integer; and determine, from the M and N data query parameters, data query parameters relevant to the input information. In one embodiment, the code generation module 503 is specifically configured to: determine model prompt information based on the data query parameters and a preset prompt template; the model prompt information is used to instruct a natural language model to generate code based on examples in the prompt template; and input the model prompt information into the natural language model to generate target code.Corresponding to the application scenarios and data query methods provided in the embodiments of the present disclosure, the embodiments of the present disclosure also provide a data query device. The device may include: a sending module for sending input information to a server; and a reply information receiving module for receiving a reply information carrying target data returned by the server. The server is configured to retrieve data query parameters related to the input information from a parameter database, generate target code based on the data query parameters, and execute the target code to query the target database for target data corresponding to the data query parameters. The functions of each module in each device of the embodiments of the present disclosure can be found in the corresponding descriptions of the above-mentioned methods, and they have corresponding beneficial effects, so they are not further described here. Figure 6 is a block diagram of an electronic device for implementing the embodiments of the present disclosure. As shown in Figure 6, the electronic device includes a memory 601 and a processor 602. The memory 601 stores a computer program executable by the processor 602. When the processor 602 executes the computer program, the method of the above-mentioned embodiments is implemented. The number of the memory 601 and the processor 602 can be one or more. The electronic device also includes a communication interface 603 for communicating with external devices and exchanging data. If the memory 601, processor 602, and communication interface 603 are implemented independently, the memory 601, processor 602, and communication interface 603 may be interconnected via a bus and communicate with each other. This bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. This bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, FIG5 shows only one thick line, but this does not mean that there is only one bus or only one type of bus. Optionally, in a specific implementation, if the memory 601, processor 602, and communication interface 603 are integrated on a single chip, the memory 601, processor 602, and communication interface 603 may communicate with each other via an internal interface. An embodiment of the present disclosure provides a computer-readable storage medium storing a computer program, which implements the method provided in the embodiment of the present disclosure when the program is executed by a processor.Embodiments of the present disclosure provide a computer program product, including a computer program. When executed by a processor, the computer program implements the methods provided in the embodiments of the present disclosure. Embodiments of the present disclosure also provide a chip, including a processor, configured to retrieve and execute instructions stored in a memory, thereby causing a communication device equipped with the chip to perform the methods provided in the embodiments of the present disclosure. Embodiments of the present disclosure also provide a chip, including an input interface, an output interface, a processor, and a memory. The input interface, the output interface, the processor, and the memory are connected via an internal connection path. The processor is configured to execute code in the memory. When the code is executed, the processor performs the methods provided in the embodiments of the present disclosure. It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting the Advanced Reduced Instruction Set Machine (ARM) architecture. Optionally, the memory may include a read-only memory and a random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. Among them, non-volatile memory may include read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available.For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM RAM (DR RAM). In the above embodiments, all or part of them can be implemented through software, hardware, firmware, or any combination thereof. When implemented using software, they can be implemented in whole or in part in the form of a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the present disclosure are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. Computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. In the description of this disclosure, reference to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with that embodiment or example are included in at least one embodiment or example of this disclosure. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and integrate different embodiments or examples described in this disclosure, as well as features from different embodiments or examples, unless otherwise specified. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed to indicate or imply relative importance or implicitly specify the number of technical features indicated. Therefore, features specified as "first" or "second" may explicitly or implicitly include at least one of those features. In the description of this disclosure, "plurality" means two or more, unless otherwise specifically defined.Any process or method described in a flowchart or otherwise herein can be understood to represent a module, segment, or portion of code comprising one or more executable instructions for implementing a specific logical function or process step. Furthermore, the scope of the preferred embodiments of the present disclosure includes alternative implementations in which functions may be performed out of the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved. The logic and / or steps described in a flowchart or otherwise herein, for example, can be considered a sequenced list of executable instructions for implementing the logical function and can be embodied in any computer-readable medium for use by an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device), or in conjunction with such an instruction execution system, apparatus, or device. It should be understood that various aspects of the present disclosure may be implemented using hardware, software, firmware, or a combination thereof. In the aforementioned embodiments, multiple steps or methods may be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. All or part of the steps of the method embodiments described above can be completed by instructing the relevant hardware through a program. This program can be stored in a computer-readable storage medium. When executed, the program includes one or a combination of the steps of the method embodiments. Furthermore, the functional units in the various embodiments of the present disclosure can be integrated into a single processing module, each unit can exist physically separately, or two or more units can be integrated into a single module. These integrated modules can be implemented in either hardware or software functional modules. If these integrated modules are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. This storage medium can be a read-only memory, a magnetic disk, or an optical disk. The above are merely exemplary embodiments of the present disclosure, but the scope of protection of the present disclosure is not limited thereto. Anyone skilled in the art can easily conceive of various variations and substitutions within the technical scope of this disclosure, and such variations and substitutions are intended to be encompassed by the scope of protection of this disclosure. Therefore, the scope of protection of the present disclosure shall be subject to the scope of protection of the claims.
Claims
Claims 1. A data query method, comprising: Receive input information; Retrieving data query parameters related to the input information in a parameter database; Based on the data query parameters, generating target code; The target code is executed to query the target database for target data corresponding to the data query parameter, and output reply information carrying the target data.
2. The method according to claim 1, wherein: The retrieving the data query parameters related to the input information in the parameter database includes: obtaining enhanced information related to the input information; rewriting the input information based on the enhanced information to obtain an enhanced question; and retrieving the data query parameters related to the input information in the parameter database using the enhanced question.
3. The method according to claim 2, wherein: The enhanced information includes professional knowledge information; the obtaining of enhanced information related to the input information includes: based on the input information, searching for knowledge nodes related to the input information in a knowledge graph; and obtaining the professional knowledge information according to the knowledge nodes.
4. The method according to claim 2, wherein: The enhanced information includes time information; the acquiring of the enhanced information related to the input information includes: reasoning the input information using a time enhancement model to obtain the time information.
5. The method according to any one of claims 1 to 4, wherein: Before receiving the input information, the method further includes: obtaining a plurality of data query parameters based on the meta information and / or value information of the target database; and storing the plurality of data query parameters in the parameter database.
6. The method according to any one of claims 1 to 5, wherein: The parameter database includes a vector database and an elastic search database; searching the parameter database for data query parameters related to the input information includes: retrieving M data query parameters from the vector database, where M is a positive integer; retrieving N data query parameters from the elastic search database, where N is a positive integer; and determining the data query parameter related to the input information from the M data query parameters and the N data query parameters by sorting the M data query parameters and the N data query parameters.
7. The method according to any one of claims 1 to 6, wherein: Generating the target code based on the data query parameters includes: determining model prompt information based on the data query parameters and a preset prompt template; wherein the model prompt information is used to instruct a natural language model to generate code with reference to an example in the prompt template; and inputting the model prompt information into the natural language model to obtain the target code.
8. A data query method, comprising: Send input information to the server; receiving a reply message carrying target data returned by the server; wherein the server is configured to retrieve data query parameters related to the input information from a parameter database, generate target code based on the data query parameters, and execute the target code to query the target database for target data corresponding to the data query parameters.
9. A data query system, comprising: Client, used to send input information to the server; A server, configured to implement the method according to any one of claims 1 to 7, to query a target database for target data corresponding to a data query parameter, and to return a reply message carrying the target data to the client; A target database, used to store the target data; A parameter database is used to store the data query parameters.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory, wherein the processor implements the method according to any one of claims 1 to 8 when executing the computer program.
11. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, wherein when executed by a processor, the computer program implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Table data processing method based on natural language dialogue
CN116737909A
Data processing instruction generation method and device, large model training method and device and electronic equipment
CN117112572A
System and method for querying a data repository
US20230376536A1
Cited By
Database table retrieval method and device, storage medium, product and electronic equipment
CN121166696A