Data query method and system based on big language model and metadata collaboration
By using a large language model and metadata collaboration approach, efficient data querying without the need for a structured query language is achieved, solving the problem of high data query thresholds in enterprise management systems. It is particularly suitable for scenarios where metadata changes dynamically, improving query efficiency and result readability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ANHUI GUOKE QUANTUM NETWORK CO LTD
- Filing Date
- 2025-11-27
- Publication Date
- 2026-04-24
AI Technical Summary
In enterprise management systems, data querying is difficult and inefficient, especially in scenarios where metadata changes dynamically. Business personnel need to have knowledge of structured query languages or perform specific development configurations.
By employing a collaborative approach of large language models and metadata, query intent information is obtained through parsing natural language data query requests, query suggestion words are generated, and database query instructions are generated using large language models, thus achieving efficient data querying without the need for structured query language.
It lowers the threshold for data querying, improves query efficiency, is suitable for enterprise management systems with dynamically changing metadata, and can process query results to improve readability.
Smart Images

Figure CN121919232A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of natural language processing technology, and in particular to a data query method and system based on the collaboration of a large language model and metadata. Background Technology
[0002] An Enterprise Management System (EMS) is a comprehensive management system designed to help enterprises achieve efficient management, optimize resource allocation, and improve operational efficiency. By integrating and managing internal and external resources (such as human resources, finance, customers, and supply chain), it provides enterprises with comprehensive business support, data analysis, and decision support, thereby enhancing their core competitiveness. Some commonly used EMS systems include Customer Relationship Management (CRM) systems and Enterprise Resource Planning (ERP) systems. CRM systems primarily handle customer information management, customer service support, customer-oriented data analysis, and decision support; ERP systems primarily handle financial management, human resource management, production and supply chain management, sales and distribution management, and project management.
[0003] In practical applications, to obtain information about a company's actual operations and management, business personnel often need to query various enterprise management systems to obtain data, such as the number of currently active customers or the monthly sales data of the three highest-priced products. This data querying process requires business personnel to have some knowledge of Structured Query Language (SQL), or the enterprise management system may need to perform specific development configurations to accommodate these queries. This is particularly problematic in scenarios where the database structure of the enterprise management system may dynamically change due to company development or changes in business scenarios, leading to high barriers to entry and low efficiency in data querying. Summary of the Invention
[0004] The purpose of this disclosure is to provide a data query method and system based on the collaboration of a large language model and metadata, which can perform accurate and efficient data queries based on the user's data query requirements in natural language form.
[0005] To address the aforementioned technical problems, the first aspect of this disclosure provides a data query method based on the collaboration of a large language model and metadata. Specifically, this method may include: acquiring an input natural language data query request; parsing the natural language data query request to obtain query intent information; retrieving metadata corresponding to the query intent information from a database based on the query intent information; generating query suggestions based on the query intent information and metadata; generating a database query instruction based on the query suggestions and a preset large language model; and retrieving the corresponding data query results from the database based on the database query instruction.
[0006] In one possible implementation of the first aspect described above, the process of generating a database query instruction based on query suggestions and a large language model includes the following steps: providing query suggestions to the large language model and receiving the original query instruction from the large language model; if the original query instruction passes database syntax verification and database security verification, using the original query instruction as the database query instruction; if the original query instruction fails database syntax verification or database security verification, feeding back the original query instruction and the verification result of failing database syntax verification or database security verification to the large language model; receiving the updated original query instruction from the large language model; repeating the above steps until the updated original query instruction passes database syntax verification and database security verification, and using the updated original query instruction as the database query instruction.
[0007] In one possible implementation of the first aspect above, the process of obtaining data query results from the database based on a database query instruction includes the following steps: obtaining the corresponding original query data item from the database based on the database query instruction; performing structured processing on the original query data item to obtain the original query result, wherein the data query result includes the original query result.
[0008] In one possible implementation of the first aspect above, the process of obtaining data query results from the database based on the database query command further includes the following steps: providing the original query results and query intent information to the large language model, and obtaining the processed query results corresponding to the original query results based on the large language model, wherein the data query results include the processed query results; and presenting the original query results and / or the processed query results based on a visualization interface; wherein the processed query results include at least one or any combination of the following: the visualization chart corresponding to the original query results, the data change trend analysis corresponding to the original query results, the abnormal data annotation corresponding to the original query results, and the natural language interpretation text corresponding to the original query results.
[0009] In one possible implementation of the first aspect above, the process of parsing a natural language data query request to obtain query intent information includes the following steps: performing a preprocessing operation on the natural language data query request to obtain standardized encoded user query information; and identifying and generating query intent information from the user query information based on semantic recognition and / or named entity recognition of the user query information.
[0010] In one possible implementation of the first aspect above, the process of generating query suggestions based on query intent information and metadata includes the following steps: generating data structure description information based on metadata; supplementing query intent information and data structure description information into a preset suggestion template to generate query suggestions; wherein, the suggestion template includes at least one or any combination of multiple of the following: preset identity settings of the large language model, database query instruction generation requirements, and database query instruction generation examples.
[0011] The second aspect of this disclosure relates to a data query system based on a large language model and metadata collaboration, specifically including: a request acquisition module for acquiring an input natural language data query request; a request parsing module for parsing the natural language data query request to obtain query intent information; a metadata extraction module for retrieving metadata corresponding to the query intent information from a database based on the query intent information; a prompt word generation module for generating query prompt words based on the query intent information and metadata; a query instruction acquisition module for generating a database query instruction based on the query prompt words and a preset large language model; and a query acquisition module for retrieving the corresponding data query results from the database based on the database query instruction.
[0012] In one possible implementation of the second aspect above, the query acquisition module is further configured to: acquire the corresponding original query data item from the database based on the database query instruction; perform structured processing on the original query data item to obtain the original query result; and provide the original query result and query intent information to the large language model, acquire the processed query result corresponding to the original query result based on the large language model, and present the original query result and / or processed query result based on the visualization interface.
[0013] Some embodiments of this disclosure also provide a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the above-described data query method based on the collaboration of a large language model and metadata.
[0014] Some embodiments of this disclosure also provide a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described data query method based on the collaboration of a large language model and metadata.
[0015] In the technical solution provided in this disclosure, because the entire data query process relies on a large language model and the extraction of real-time updated metadata from the database, users can directly query the required data content using natural language without needing knowledge of structured query language. This lowers the data query threshold and improves data query efficiency, making it particularly suitable for data query applications in scenarios such as enterprise management systems where database metadata changes dynamically. In some embodiments of this disclosure, the data query results can be further processed based on the large language model. This fully utilizes the data processing capabilities of the large language model to further analyze and interpret the raw data query results extracted from the database, improving the readability of the data query results, lowering the threshold for data understanding and analysis, and meeting the data query needs of different user groups. Attached Figure Description
[0016] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0017] Figure 1 This is an exemplary flowchart of a data query method based on the collaboration of a large language model and metadata, provided according to an embodiment of this disclosure; Figure 2 This is an exemplary flowchart of obtaining query intent information according to an embodiment of the present disclosure; Figure 3 This is an exemplary flowchart of obtaining metadata according to an embodiment of the present disclosure; Figure 4 This is an exemplary flowchart of generating query suggestions according to an embodiment of the present disclosure; Figure 5 This is an exemplary flowchart of obtaining a database query instruction according to an embodiment of the present disclosure; Figure 6 This is an exemplary flowchart of obtaining data query results according to an embodiment of the present disclosure; Figure 7 This is an exemplary structural diagram of a data query system based on the collaboration of a large language model and metadata, provided according to embodiments of this disclosure; Figure 8 This is an exemplary structural diagram of a data query device based on the collaboration of a large language model and metadata, provided according to embodiments of this disclosure; Figure 9 This is a schematic diagram of data transmission for a user to perform a data query through a data query device, according to an embodiment of the present disclosure. Detailed Implementation
[0018] As can be understood from the background description, in specific business scenarios such as enterprise management systems, users need to possess certain knowledge of structured query languages or perform specific development configurations for their queries, resulting in high barriers to entry and low efficiency in data querying. To address these technical problems, this disclosure provides a data query method, system, storage medium, and program product capable of performing accurate and efficient data queries based on user-provided natural language data query requests.
[0019] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the various embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details are presented in the various embodiments of this disclosure to facilitate a better understanding of the disclosure. However, the technical solutions claimed in this disclosure can be implemented even without these technical details and various variations and modifications based on the following embodiments. The division of the various embodiments below is for ease of description and should not constitute any limitation on the specific implementation of this disclosure. The various embodiments can be combined with and referenced by each other without contradiction.
[0020] In some embodiments of this disclosure, Figure 1 An exemplary flowchart of a data query method based on the collaboration of a large language model and metadata is shown, such as... Figure 1 As shown, the specific steps may include the following: Step 110: Obtain the input natural language data query request. In some embodiments, a natural language data query request refers to a data query request represented in natural language form. Users can freely input and represent data query requests based on an interactive human-computer display interface, thereby improving the user's query freedom and query experience during the data query process.
[0021] Step 120: Parse the natural language data query request to obtain query intent information. In some embodiments, the query intent information may specifically include the query target entity and the query target content corresponding to the query target entity. Taking the user-input natural language data query request as "Please show the top 10 sales product categories and their growth rates last year" as an example, the corresponding query target entity may specifically include "sales amount", "sales product category", etc., and the query target content may specifically include "sort by 'last year's sales amount'", "calculate 'growth rate'", etc., without limitation. In some embodiments, based on the foregoing embodiments, it can be concluded that at least a part of the components of the query target entity and / or query target content exist in the natural language data query request. That is, the query target entity and / or query target content are based on the natural language data query request, from which a part of the natural language expression is extracted and extended and interpreted to a certain extent based on semantic understanding, without limitation. The specific acquisition of query intent information will be explained in detail later and will not be elaborated here.
[0022] Step 130: Based on the query intent information, retrieve the metadata corresponding to the query intent information from the database. In some embodiments, metadata refers to data in the database used to describe data, providing structured information about the stored / managed data itself. In some embodiments, to perform data queries based on user-provided natural language data query requests, a large language model or other natural language processing methods can be used to parse the user-input query request, and then generate corresponding database query instructions based on preset templates and static metadata mappings, ultimately obtaining the data query results based on the database query instructions. However, preset templates and static metadata mappings are difficult to handle different natural language query requests from different users, especially in scenarios where the metadata information in the database changes frequently (for example, metadata in an enterprise management system is prone to significant changes as the enterprise's business scenarios change). This requires maintenance personnel to frequently maintain preset templates and static metadata mapping relationships, resulting in poor generalization capabilities, high maintenance costs, and a poor user experience. To overcome the aforementioned problems, the solution provided in this disclosure executes an independent metadata extraction process for each natural language data query request from a user. This metadata extraction process targets the real-time updated metadata information of the database to be queried, requiring no manual maintenance or configuration intervention. It adapts to scenarios where database metadata changes dynamically, improving the automation and generalization capabilities of data queries. Simultaneously, it can clearly define the scope of the data structure to be queried based on the user's query intent, thereby effectively improving the accuracy and overall efficiency of data queries. The metadata extraction process will be described in detail later and will not be elaborated upon here.
[0023] Step 140: Generate query suggestions based on query intent information and metadata. It is understood that the query suggestions provided in Step 140 combine the user's query intent with the scope of metadata queries under real-time database updates, effectively helping the large language model generate database query instructions that meet the user's needs in subsequent processes. The specific process of generating query suggestions will be explained in detail later and will not be elaborated here.
[0024] Step 150: Generate database query instructions based on query prompts and a preset large language model. In some embodiments, the database query instruction can be a coded structured instruction for querying data from a database. For example, if the database to be queried by the user is a relational database, the database query instruction can be a structured query statement such as an SQL (Structured Query Language) query statement; if the database to be queried by the user is a non-relational database, the database query instruction can also be other unstructured or semi-structured query statements, which are not limited here. In some embodiments, the database query instructions involved in this disclosure are automatically generated by the large language model based on query prompts, and are appropriately optimized and adjusted by the large language model. This avoids problems such as low query performance and excessive query time that may occur during the manual writing of database query instructions. That is, the database query instructions generated by the large language model can effectively improve the overall efficiency of data query. The specific generation process of the database query instructions will be described in detail later and will not be repeated here.
[0025] Step 160: Based on the database query command, retrieve the corresponding data query results from the database. In some embodiments, the data query results may include data query content directly obtained from the database based on the database query command; in other embodiments, the data query results may also include processed data content obtained after the original data query content has undergone a series of visualization processing and analysis (e.g., data distribution ratio chart, data change trend chart, etc., which are not limited here). The specific generation and presentation format of the data query results will be described in detail later and will not be elaborated here.
[0026] It is understandable that, based on steps 110 to 160 above, it is possible to generate a natural language data query request based on user input and obtain the corresponding data query results. Specifically, the user's query intent can be obtained by parsing the natural language data query request, and dynamically changing metadata can be extracted from the database. Then, the user's query intent and the extracted metadata are combined to generate query hints required by the large language model, and the text processing capabilities of the large language model are used to generate corresponding database query instructions based on the query hints. Finally, based on the execution of the database query instructions, data query results that meet the user's query requirements are obtained from the database. It is understandable that, since the entire data query process relies on the large language model and the extraction of real-time updated metadata from the database, users can directly query the required data content using natural language without needing structured query language knowledge, which lowers the threshold for data querying and improves data query efficiency. This is particularly suitable for data query applications in scenarios such as enterprise management systems where database metadata changes dynamically. The specific implementation of steps 110 to 160 above will be further explained below with reference to specific embodiments.
[0027] In some embodiments of this disclosure, in the specific implementation of the aforementioned step 120, Figure 2 An exemplary flowchart for obtaining query intent information is shown, such as Figure 2 As shown, the specific steps may include the following: Step 210: Perform preprocessing on the natural language data query request to obtain standardized encoded user query information. In some embodiments, since the user's input of the natural language data query request is not restricted by the preset query template structure, the user is allowed to use a more colloquial input form to input the query request, such as "Please show the top 10 selling product categories and their growth rates last year". Before parsing the user's query intent, the received natural language data query request needs to be preprocessed for standardization. In some embodiments, the preprocessing operation may include text cleaning and standardized encoding. Text cleaning may include cleaning and removing special characters, extra spaces, and other content irrelevant to the query request that may appear in the natural language data query request. Standardized encoding may be to use a unified UTF-8 (8-bit Unicode Transformation Format) encoding format to uniformly encode the text-cleaned natural language data query request, which is not limited here. In some embodiments, to prevent improper data query requests provided by users from affecting the data storage security of the database, the preprocessing operation may also include compliance review and / or security review of natural language data query requests. Specifically, a preset sensitive word library and compliance rules may be used to match the input data query request text, thereby filtering out query content that may contain database attack characteristics, sensitive information, and other non-compliant query content. By proactively intercepting these illegal query contents and providing users with a query request violation warning, the security of the use and query in database scenarios such as enterprise management systems can be further guaranteed.
[0028] Step 220: Based on semantic recognition and / or named entity recognition of the user query information, identify and generate the query target entity and query target content from the user query information, and use the query target entity and query target content as query intent information. In some embodiments, during the natural language processing (NLP) process such as semantic recognition on the user query information that has completed preprocessing operations, named entity recognition (NER) can be used to identify key entities appearing in the user query information. Specifically, taking the user's natural language data query request as "Please show the top 10 sales product categories and their growth rates last year" as an example, key entity recognition of the user query information obtained from the preprocessing operation can yield query target entities that specifically include "sales amount" and "sales product category", and query target content that specifically includes "sorted by 'last year's sales amount'" and "calculate 'growth rate'". It is understood that those skilled in the art can also use other suitable semantic recognition algorithms, such as semantic analysis based on distributed word vectors or semantic analysis based on deep learning, to generate the target entity and the target content of the query, and use the combination of the target entity and the target content of the query as the user's query intent information, without any limitation.
[0029] In some embodiments of this disclosure, in the specific implementation of the aforementioned step 130, Figure 3 An exemplary flowchart for retrieving metadata is shown, such as... Figure 3 As shown, the specific steps may include the following: Step 310: Generate metadata request information associated with the query intent information. In some embodiments, based on the obtained query intent information, the metadata request information can be generated through a metadata engine. The metadata engine, as a system or set of modules specifically designed for managing and manipulating metadata, includes a metadata scheduler that can determine the scope of metadata to be extracted based on the query intent information and generate corresponding metadata request information, triggering the metadata extraction process. Those skilled in the art can also choose other feasible technical means to generate the above-mentioned metadata request information, which are not limited here.
[0030] Step 320: Based on the database's feedback on the metadata request information, obtain the metadata, which includes at least one or any combination of multiple of the following: the database's real-time updated data storage structure, primary key constraint information, foreign key constraint information, and field annotation information. In some embodiments, the metadata engine can be relied upon to directly interact with the database to query the database's system tables (e.g., system views in Oracle databases (DBA_TABLES, used to display information about all tables in the database), system table repositories in MySQL databases (INFORMATION_SCHEMA, used to describe database, table, column, index, constraint, etc., etc., without limitation), and extract the required metadata from them. It is understood that, in this embodiment of the disclosure, considering that the metadata information in the database may change according to changes in the actual business scenario, an independent real-time metadata extraction is performed during each user data query request, thereby achieving automatic adaptation to changes in the database structure. There is no need for manual updating and maintenance of the metadata configuration during the data query process, which is particularly suitable for the data query needs of enterprise management systems, and takes into account the application advantages of high automation, strong versatility, and low maintenance cost.
[0031] In some embodiments, the data storage structure included in the metadata may include real-time updated table names, field names, field types, and other content in the database. In some embodiments, the primary key constraint information included in the metadata can be used to uniquely identify each record in the table structure. A data storage / management table structure can only have one primary key. The foreign key constraint information is used to establish the relationship between two table structures, ensuring the validity of the relationship between table structures and preventing the insertion or updating of invalid data. Primary key and foreign key constraints can clearly define the relationship between table structures, ensuring the integrity and consistency of data in the database. In some embodiments, the field annotation information included in the metadata can be used to annotate the specific form of data storage, such as field names and field types, in the data storage structure, facilitating subsequent processing of the metadata by the large language model. Those skilled in the art can also select other suitable metadata content as components of the metadata according to the user's actual query needs; this is not limited here.
[0032] In some embodiments of this disclosure, in the specific implementation of the aforementioned step 140, Figure 4 An exemplary flowchart for generating query suggestions is shown, such as... Figure 3 As shown, the specific steps may include the following: Step 410: Generate data structure description information for the query range based on metadata. In some embodiments, the data content in the metadata can be directly concatenated to serve as the data structure description information for the query range; in other embodiments, when the user's query intent includes two or more independent query objects, the data content in the metadata can be concatenated separately according to the different query objects to generate two or more different data structure description information for the query range, which is not limited here.
[0033] Step 420: Supplement the query intent information and data structure description information to the preset prompt word template to generate query prompt words. In some embodiments, the prompt word template may specifically include at least one or any combination of the following: the preset identity setting of the large language model, the database query instruction generation requirements, and the database query instruction generation examples. The preset identity setting of the large language model can clearly define the large language model as a "database query instruction generation expert"; the database query instruction generation requirements can limit the large language model to generate database query instructions that conform to preset standards and are legal and compliant; the generation examples can provide several examples of converting natural language data query requests into database query instructions. Through machine learning with a very small number of training samples, the output results of the large language model are made closer to the database query instructions required by the user.
[0034] The following example illustrates a prompt word template: "As a senior data analyst, please generate an SQL query to answer the user's question based on the following database table structure: {'Data structure description information to be supplemented'}. Please only output the SQL query statement, without any additional explanation. Example 1: The user's question is 'Query the total number of customers', and the generated SQL query statement is 'SELECT COUNT() FROM customers'; Example 2: The user's question is 'Display the top 3 products with the highest prices', and the generated SQL query statement is 'SELECT productName, productPriceFROM products ORDER BY productPrice DESC LIMIT 3'; Now, please generate an SQL query statement for the following user question: {'Query intent information to be supplemented'}." It can be understood that by supplementing the corresponding data structure description information and query intent information in the above prompt word template, prompt words that conform to the current database structure and the user's actual query intent can be generated. This provides the large language model with an accurate database logical structure definition context, enabling the large language model to generate accurate database query instructions based on the user's actual query intent.
[0035] In some embodiments of this disclosure, in the specific implementation of the aforementioned step 150, Figure 5 An exemplary flowchart for obtaining a database query instruction is shown, such as... Figure 5 As shown, the specific steps may include the following: Step 510: Provide query suggestions to the large language model and receive the original query instruction from the large language model. In some embodiments, the large language model can leverage its powerful natural language understanding and code generation capabilities to integrate the database metadata information contained in the query suggestions with the user's query intent information to generate an original query instruction that can be executed efficiently and accurately. The original query instruction may specifically be an SQL (Structured Query Language) query statement, which is not limited here.
[0036] Step 520: Perform database syntax verification and database security verification. In some embodiments, although large language models have powerful code generation capabilities, they cannot completely rule out the possibility of syntax errors or other potential risks that may affect the secure operation of the database in query instructions generated based on artificial intelligence. It is necessary to perform database syntax verification and database security verification on the generated original query instructions. In some embodiments, during the aforementioned database syntax verification process, an SQL parser can be used to parse the generated SQL query statement to verify its legality. In a specific instance, the SQL parser can be the Apache Calcite dynamic data management framework, which performs syntax verification on the SQL query statement by parsing it into an abstract syntax tree. In some embodiments, during the aforementioned database security verification process, it may include query security checks, such as avoiding high-risk operations that may affect database storage security, such as DELETE (delete database data) and DROP (delete database objects) in the SQL query statement; performance optimization verification, such as proactively adding necessary index hints to the SQL query statement based on the actual data storage situation of the database; and resource overflow verification, such as detecting whether the SQL query statement is too long, which may cause system overload anomalies in the database. It is understood that those skilled in the art can freely set the specific verification content of database syntax verification and database security verification according to actual query needs, and no restrictions are imposed here.
[0037] Step 530: If the original query command fails the database syntax check or database security check, the original query command and the check results for the failed database syntax check or database security check are fed back to the large language model. It is understood that if either the database syntax check or the database security check fails, it means that the original query command generated by the large language model may affect the normal and secure use of the database, or may prevent the completion of the complete data query process. In this case, the information about the failed check and the specific reasons can be fed back to the large language model along with the original query command to trigger the automatic correction mechanism, allowing the large language model to further update and optimize the original query command to address any issues.
[0038] Step 540: Receive the updated original query command from the large language model and return to step 520. It is understandable that the updated original query command can be repeatedly executed along with the database syntax and security checks described above. If the checks fail, the large language model's automatic correction mechanism will be repeatedly triggered until a valid, secure, and efficient query command is generated.
[0039] Step 550: If the original query instruction or the updated original query instruction passes the database syntax check and database security check, then the original query instruction or the updated original query instruction is used as the database query instruction. It can be understood that if all query instructions output by the large language model pass the database syntax check and database security check, then the query instructions currently output by the large language model can be considered to meet the requirements for legal, secure, and efficient instruction generation, and can be used as database query instructions to execute subsequent specific data query operations.
[0040] In some embodiments of this disclosure, in the specific implementation of the aforementioned step 160, Figure 6 An exemplary flowchart for retrieving data query results is shown, such as... Figure 6 As shown, the specific steps may include the following: Step 610: Based on the database query instruction, retrieve the corresponding original query data item from the database. In some embodiments, based on the database query instruction (e.g., SQL query statement) obtained in the foregoing embodiments, the database query instruction can be executed through a communication connection with the database to obtain the corresponding original query data item. In some embodiments, furthermore, during the execution of the database query instruction, the execution process can be monitored in real time based on preset monitoring indicators. These monitoring indicators may specifically include query execution time thresholds, which can prevent some database query instructions from experiencing long timeouts during actual queries, thus avoiding abnormal situations where the database's normal data processing channels are occupied. Those skilled in the art can set the monitoring indicators according to actual needs, and no limitations are imposed here.
[0041] Step 620: Perform structuring processing on the original query data items to obtain the original query results. In some embodiments, the original query data items reflect the original storage structure of the query data required by the user in the database, typically represented as continuous string / numerical content. To facilitate the user's understanding of the specific meaning of each data item in the original query data items, structuring processing can be used to convert the original query data items into a structured JSON (JavaScript Object Notation) format. This format includes information such as field names, field values, and field comments for each original query data item, enabling the user to understand the meaning of each data item and facilitating further processing of the original query results. In some embodiments, the data query results obtained by the user may include the original query results, which are presented directly to the user through a visual interface. Considering that the original query results are biased towards the underlying data content stored in the database, the original query results may be set to be accessible only to system maintenance personnel with appropriate permissions; this is not limited here.
[0042] Step 630: Provide the original query results and query intent information to the large language model, and obtain the processed query results corresponding to the original query results based on the large language model. It is understood that the original query results often only list the specific content of the data the user needs to query, and the presentation format is relatively simple. Users find it difficult to intuitively obtain the changing trends, representational meanings, and other deeper data representations behind the data, requiring additional data analysis processes. Considering that the large language model is applied in the process of generating database query instructions in this embodiment, the aforementioned large language model can be reused to refine and process the original query results to generate processed query results. In some embodiments, the refinement processing operations performed by the large language model on the original query results may include business contextual interpretation, such as interpreting the original query results using natural language to transform them into business-friendly descriptions that can be understood and intuitively viewed by users in specific business scenarios; the refinement processing operations may also include visual chart interpretation, such as selecting appropriate visual charts to transform the presentation format based on the data items in the original query results, allowing users to obtain the data query results more intuitively through chart styles; the refinement processing operations may also include anomaly labeling operations, such as identifying and labeling abnormal data situations in the original query results that significantly deviate from the normal data range; the refinement processing operations may also include trend analysis operations, such as analyzing the potential trend changes of data items in the original query results, or the data change trends of strongly correlated data items in the original query results, and representing them using multimedia forms such as trend charts, dynamic change diagrams, and natural language descriptions. In some embodiments, the processed query results may, according to the refinement processing operations performed by the large language model, include at least one or any combination of the following: visual charts corresponding to the original query results, data change trend analysis corresponding to the original query results, anomaly data labeling corresponding to the original query results, and natural language interpretation text corresponding to the original query results. In some embodiments, the data query results obtained by the user may include both the original query results and the processed query results, which is not limited here.
[0043] Step 640: Present the original query results and / or processed query results through a visual interface. In some embodiments, the user's natural language data query request can be input through a visual interface, and correspondingly, the original query results and processed query results corresponding to the natural language data query request can also be presented and fed back through the same visual interface. In some embodiments, the original query results and processed query results can be presented selectively in the visual interface; in other embodiments, the original query results and processed query results can be presented simultaneously in the same visual interface. For example, in a specific instance, the original query results can be presented in a table format, supporting sliding pagination and sorting, hiding, and adjusting table items, used to display the intuitive query results of the database query command, mainly for operation and maintenance users; the processed query results can be presented in multimedia such as tables, pie charts, bar charts, trend charts, and interpretive text, which can form the data query intelligent analysis results required by the user based on the user's natural language data query request, mainly for operation users. Through the visual presentation provided in step 640 above, users can obtain the required data query results more intuitively and specifically, and can meet the different data query needs of different users, greatly improving the user's data query experience.
[0044] Some embodiments of this disclosure also relate to a data query system based on the collaboration of a large language model and metadata. Figure 7 An exemplary structural diagram of a data query system based on the collaboration of a large language model and metadata is shown, such as... Figure 7 As shown, it may specifically include a request acquisition module 710, a request parsing module 720, a metadata extraction module 730, a prompt word generation module 740, a query instruction generation module 750, and a query acquisition module 760.
[0045] In some embodiments, the request acquisition module 710 can be used to acquire the input natural language data query request. In some embodiments, the request parsing module 720 can be used to parse the natural language data query request to obtain query intent information. In some embodiments, the metadata extraction module 730 can be used to extract the metadata corresponding to the query intent information from the database based on the query intent information. In some embodiments, the prompt word generation module 740 can be used to generate query prompt words based on the query intent information and metadata. In some embodiments, the query instruction generation module 750 can be used to generate a database query instruction based on the query prompt words and a preset large language model. In some embodiments, the query acquisition module 760 can be used to acquire the corresponding data query result from the database based on the database query instruction. In some embodiments, the query processing module 760 can also be used to acquire the corresponding original query data item from the database based on the database query instruction; perform structured processing on the original query data item to obtain the original query result; and provide the original query result and query intent information to the large language model, acquire the processed query result corresponding to the original query result based on the large language model, and present the original query result and / or the processed query result based on a visual interface. It is understood that the specific functional implementation of the above-mentioned request acquisition module 710 to query acquisition module 760 can refer to the execution implementation of steps 110 to 160 in the aforementioned embodiments, and will not be repeated here.
[0046] Some embodiments of this disclosure also relate to a data query device based on the collaboration of a large language model and metadata. Figure 8 An exemplary structural diagram of a data query device based on the collaboration of a large language model and metadata is shown, such as Figure 8 As shown, this data query device 800 may specifically include a human-computer interaction module 810 and a query processing module 820. The human-computer interaction module 810 provides a human-computer interaction interface through which users can input natural language data query requests and perform interactive operations such as viewing, editing, and storing visualized data query results. In some embodiments, such as... Figure 8As shown, the query processing module 820 may further include a query parsing engine 821, a metadata engine 822, a large language model processing engine 823, and a data query engine 824. The query parsing engine 821 parses the natural language data query requests received by the human-computer interaction module 810 to obtain the user's query intent information. The metadata engine 822, based on the user's query intent information, interacts with the external or built-in query target database 830 of the data query device 800 to obtain the corresponding metadata. The large language model processing engine 823 generates database query instructions based on the metadata and the user's query intent information through the external or built-in large language model 840 of the data query device 800. The data query engine 824 obtains data query results based on the database query instructions by interacting with the external or built-in query target database 830 of the data query device 800. In some embodiments, the data query engine 824 can also provide the data query results provided by the target database 830 to the large language model processing engine 823, which then calls an external or built-in large language model 840 to further analyze and interpret the query results, and presents the final data query results through the human-computer interaction module 810. In some embodiments, such as Figure 8 The data query device 800 shown may be a user terminal device, including but not limited to desktop computers, smartphones, laptops, VR (Virtual Reality) devices, and tablets, etc., without limitation.
[0047] For more information on each unit, please refer to [link / reference]. Figures 1 to 7 The relevant explanations will not be repeated here. It should be understood that, as... Figure 8 The data query device and its units shown can be implemented in various ways. For example, in some embodiments, they can be implemented by hardware, software, or a combination of both. The hardware portion can be implemented using dedicated logic; the software portion can be stored in memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated hardware. Those skilled in the art will understand that the methods, devices, and systems described above can be implemented using computer-executable instructions and / or included in the control code of a processor, such as on a media such as a disk, CD, or DVD-ROM, or in the memory of a programmable device. The devices and modules described in this specification can be implemented not only by hardware circuits such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips or transistors, or programmable hardware devices such as field-programmable gate arrays or programmable logic devices, but also by software executed by various types of processors, or by a combination of the aforementioned hardware circuits and software (e.g., firmware).
[0048] It should be noted that the above description of the device and units is for ease of description only and should not be construed as limiting the technical solutions provided in this disclosure to the scope of the illustrated embodiments. It is understood that those skilled in the art, after understanding the principle of the device, can arbitrarily combine the various units without departing from this principle to form sub-devices connected to other units. Alternatively, some units can be split to obtain more units or multiple modules under a single unit. Such modifications are all within the scope of the technical solutions disclosed in this disclosure.
[0049] In some embodiments of this disclosure, Figure 9 This diagram illustrates a data transmission method where a user performs a data query using a data query device. For example... Figure 9 As shown, during the data query process, user 900 provides a natural language data query request to the human-computer interaction module 810 of the data query device 800. The human-computer interaction module 810 converts the received natural language data query request into a machine language query request and sends it to the query processing module 820. The query processing module 820 can perform preprocessing operations such as data cleaning and security filtering on the query request, and then identify the query intent information corresponding to the query request. Based on the obtained query intent information, the query processing module 820 sends a metadata request to the target database 830, receives the metadata returned by the target database 830, and assembles the metadata with the query intent information to generate query prompts.
[0050] In some embodiments, such as Figure 9 As shown, the query processing module 820 sends query prompts to the large language model 840 and receives the database query instruction returned by the large language model 840. The query processing module 820 further performs database syntax validation and database security validation on the database query instruction: if either the database syntax validation or database security validation fails, the query processing module 820 feeds back the validation failure result and the database query instruction to the large language model 840, which then regenerates and returns the updated database query instruction; if both the database syntax validation and database security validation pass, the query processing module 820 executes the database query instruction on the target database 830 and receives the original query data items returned by the target database 830. The query processing module 820 further performs structured processing on the original query data items to obtain the original query results.
[0051] In some embodiments, such as Figure 9As shown, the query processing module 820 is also used to provide the original query results and query intent information to the large language model 840, request the large language model 840 to refine and process the original query results, and obtain the processed query results returned by the large language model 840. Based on this, the query processing module 820 provides the original query results and / or processed query results to the human-computer interaction module 810, and the human-computer interaction module 810 displays the original query results and / or processed query results and provides them to the user 900, so as to realize the complete data query and data transmission process.
[0052] Some embodiments of this disclosure also relate to a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the data query method provided in the foregoing embodiments. In some embodiments, the computer-readable storage medium may include flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the computer-readable storage medium may be an internal storage unit of a computer device, such as the hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium may also be an external storage device of a computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., provided on the computer device. Of course, the computer-readable storage medium may also include both internal storage units and external storage devices of a computer device. In this embodiment, the computer-readable storage medium is typically used to store the operating system and various application software installed on the computer device, such as the program code of the service access method and / or service invocation method in this embodiment. Furthermore, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or will be output.
[0053] Some embodiments of this disclosure also relate to a computer program product, including a computer program that, when executed by a processor, implements the steps of the data query method provided in the foregoing embodiments.
[0054] In some embodiments, the computer program product may involve only a computer program, which may be carried on a storage medium or processing device. In other embodiments, the computer program product may also be a storage medium or processing device containing the aforementioned computer program. The processing device may include one or more processors, and the storage medium. Those skilled in the art will understand that all or part of the steps in the data query method provided in the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this disclosure.
[0055] The basic concepts have been described above. It is obvious that the detailed disclosure above is merely illustrative and does not constitute a limitation of this specification. Although not explicitly stated herein, various modifications, improvements, and corrections may be made to this specification by those skilled in the art. Such modifications, improvements, and corrections are taught in this specification and therefore remain within the spirit and scope of the exemplary embodiments described herein.
Claims
1. A data query method based on the collaboration of a large language model and metadata, characterized in that, include: Obtain the input natural language data query request; The natural language data query request is parsed to obtain query intent information; Based on the query intent information, retrieve the metadata corresponding to the query intent information from the database; Based on the query intent information and the metadata, query suggestion words are generated; Generate database query instructions based on query suggestions and a pre-defined large language model; Based on the database query command, the corresponding data query results are obtained from the database.
2. The data query method based on large language model and metadata collaboration according to claim 1, characterized in that, The process of generating the database query instruction based on the query suggestion words and the large language model includes the following steps: Provide the query suggestions to the large language model and receive the original query instructions from the large language model; If the original query instruction passes the database syntax check and database security check, the original query instruction will be used as the database query instruction. If the original query command fails the database syntax check or database security check, the original query command and the check result of failing the database syntax check or database security check will be fed back to the large language model. Receive the update command for the original query from the large language model; Repeat the above steps until the original update query instruction passes the database syntax check and the database security check, and then use the original update query instruction as the database query instruction.
3. The data query method based on the collaboration of a large language model and metadata as described in claim 1 or 2, characterized in that, The process of retrieving the data query results from the database based on the database query instruction includes the following steps: Based on the database query instruction, the corresponding original query data item is obtained from the database; The original query data items are structured to obtain the original query results, which include the original query results.
4. The data query method based on the collaboration of a large language model and metadata as described in claim 3, characterized in that, The process of retrieving the data query results from the database based on the database query instruction also includes the following steps: The original query results and the query intent information are provided to the large language model, and the processed query results corresponding to the original query results are obtained based on the large language model. The data query results include the processed query results. as well as The original query results and / or the processed query results are presented through a visual interface. The processed query results include at least one or any combination of the following: a visualization chart corresponding to the original query results, a data change trend analysis corresponding to the original query results, an annotation of abnormal data corresponding to the original query results, and a natural language interpretation text corresponding to the original query results.
5. The data query method based on large language model and metadata collaboration according to claim 1, characterized in that, The process of parsing the natural language data query request to obtain the query intent information includes the following steps: Perform preprocessing operations on the natural language data query request to obtain standardized encoded user query information; Based on semantic recognition and / or named entity recognition of the user query information, the query intent information is identified and generated from the user query information.
6. The data query method based on the collaboration of a large language model and metadata as described in claim 1, characterized in that, The process of generating the query suggestion words based on the query intent information and the metadata includes the following steps: Based on the aforementioned metadata, data structure description information is generated; The query intent information and the data structure description information are supplemented into a preset prompt word template to generate the query prompt words; The prompt word template includes at least one or any combination of the following: the preset identity setting of the large language model, the generation requirements of the database query instruction, and the generation examples of the database query instruction.
7. A data query system based on the collaboration of a large language model and metadata, characterized in that, include: The request retrieval module is used to retrieve the input natural language data query request; The request parsing module is used to parse the natural language data query request to obtain query intent information; The metadata extraction module is used to retrieve the metadata corresponding to the query intent information from the database based on the query intent information. The prompt word generation module is used to generate query prompt words based on the query intent information and the metadata; The query instruction acquisition module is used to generate database query instructions based on query suggestion words and a preset large language model; The query retrieval module is used to retrieve corresponding data query results from the database based on database query commands.
8. The data query system based on large language model and metadata collaboration according to claim 7, characterized in that, The query acquisition module is also used to retrieve the corresponding original query data item from the database based on the database query instruction; and to perform structured processing on the original query data item to obtain the original query result; as well as The original query results and the query intent information are provided to the large language model. Based on the large language model, the processed query results corresponding to the original query results are obtained, and the original query results and / or the processed query results are presented on a visual interface.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions, which, when executed by a processor, implement the steps of the data query method based on the collaboration of a large language model and metadata as described in any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the data query method based on the collaboration of a large language model and metadata as described in any one of claims 1 to 6.