Data query method and device, equipment and medium
By deploying smart contracts on the blockchain and using large language models to generate query statements, the problem of data theft and leakage is solved, the transparency and flexibility of data circulation are achieved, and data security and compliance are enhanced.
Patent Information
- Application Number
- CN202410901634.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-10-18
AI Technical Summary
There are risks of data theft and leakage in the existing data element circulation technology, and it cannot meet the flexible and changing needs. Especially in the environment of multiple third-party platforms, it is difficult to achieve unified management and control, authorization, traceability and violation blocking of APIs.
Use blockchain technology to deploy smart contracts, combine with large-scale language models to generate query statements, ensure data security and compliance through built-in restrictive prompts in smart contracts, and use session managers to optimize the query process and achieve transparency in data queries. and auditability.
It effectively reduces the risk of data theft and leakage, enhances trust between data users and providers, reduces compliance costs, improves the flexibility and adaptability of data circulation, and ensures compliance with data privacy and security.
Smart Images

Figure CN118797723A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data element circulation technology, and in particular to a data query method, device, equipment and medium. Background Art
[0002] The circulation of data elements is the process of transmitting, sharing or exchanging data as a factor of production between different entities.
[0003] In related technologies, the circulation of data elements is mainly achieved through data packet transmission and API (Application Programming Interface) calls. However, although the data packet transmission method is simple, its subsequent use is difficult to control and can easily lead to data leakage, theft or damage. Although the API call method provides a convenient data service interface, it has the risk of data theft and cannot meet flexible and changing needs. Especially in a platform environment facing multiple third parties, unified management, authorization, traceability and violation blocking of APIs have become challenges.
[0004] How to reduce the risk of data theft and leakage in data element circulation technology, and how to meet the flexible and changing needs in data element circulation are urgent issues that need to be addressed. Summary of the invention
[0005] The present invention provides a data query method, device, equipment and medium to solve the problems of data theft and leakage in related technologies, as well as the defect of being unable to meet the flexible and changeable requirements in the circulation of data elements.
[0006] The present invention provides a data query method, comprising: In response to a query request sent by a data user, calling a smart contract to generate a query prompt, the smart contract being deployed on a blockchain including the data user and the data provider, the query prompt including the query request and a restrictive prompt in the smart contract for protecting data; Based on the large language model, generate a query sentence corresponding to the query prompt; Based on the query statement, access the data source of the data provider to obtain the query result; The query result is returned to the data user.
[0007] According to a data query method provided by the present invention, generating a query statement corresponding to the query prompt based on a large language model includes: Based on the session manager, the query prompt is input into the large language model to obtain the query statement output by the large language model.
[0008] According to a data query method provided by the present invention, based on the session manager, the query prompt is input into the large language model to obtain the query statement output by the large language model, including: Based on the conversation manager, the query prompt and the structural information of the data source are input into the large language model to obtain the query statement output by the large language model.
[0009] According to a data query method provided by the present invention, based on the session manager, the query prompt is input into the large language model to obtain the query statement output by the large language model, including: Based on the session manager, determining whether there is a historical query prompt that is consistent with the query prompt; When it is determined that there is no historical query prompt that is consistent with the query prompt, based on a session manager, inputting the query prompt into the large language model to obtain the query statement output by the large language model; When it is determined that there is a historical query prompt that is consistent with the query prompt, the historical query result corresponding to the historical query prompt is used as the query result.
[0010] According to a data query method provided by the present invention, the data source of the data provider is accessed based on the query statement to obtain the query result, including: Based on the query statement, access the data source of the data provider to obtain the original query result; Based on the session manager, the original query result is verified, and if the verification result is qualified, the original query result is determined as the query result.
[0011] According to a data query method provided by the present invention, the step of accessing the data source of the data provider based on the query statement to obtain the query result further includes: If the verification result is unqualified, the query prompt is updated based on the conversation manager, and the updated query prompt is input into the large language model.
[0012] According to a data query method provided by the present invention, the verifying the original query result based on the session manager includes: Based on the large language model, sorting the original query results; Based on the session manager, the sorted original query results are verified.
[0013] A data query method provided by the present invention also includes: After obtaining the query result, the transaction is completed based on the smart contract.
[0014] The present invention also provides a data query device, comprising the following units: A blockchain unit, configured to, in response to a query request sent by a data user, call a smart contract to generate a query prompt, wherein the smart contract is deployed on a blockchain including the data user and the data provider, and the query prompt includes the query request and a restrictive prompt in the smart contract for protecting data; A large model unit, used to generate a query statement corresponding to the query prompt based on a large language model; A query execution unit, configured to access the data source of the data provider based on the query statement to obtain a query result; The result returning unit is used to return the query result to the data user.
[0015] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned data query methods is implemented.
[0016] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the data query method described above is implemented.
[0017] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned data query methods.
[0018] The data query method, device, equipment and medium provided by the present invention use blockchain technology to provide transparent transaction records, ensure that all query requests and data queries are traceable, increase the auditability of data element circulation, and thus enhance the trust between data users and data providers. At the same time, the restrictive prompts built into the smart contract can pre-process the query request to ensure that any query complies with data privacy and security regulations, avoid the risk of data leakage, and strengthen the control of subsequent use of data. In addition, smart contracts can automatically execute predefined rules to reduce compliance costs. Using the semantic understanding ability of large language models to directly analyze data also reduces the risk of data leakage, effectively lowers the threshold for blockchain to circulate data elements, and increases the flexibility to adapt to query needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the present invention or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 This is one of the flow charts of the data query method provided by the present invention.
[0021] Figure 2 It is a schematic diagram of an example of the query prompt consistency check process provided by the present invention.
[0022] Figure 3 This is the second flow chart of the data query method provided by the present invention.
[0023] Figure 4 It is an example schematic diagram of the data query system provided by the present invention.
[0024] Figure 5 It is a structural schematic diagram of the data query device provided by the present invention.
[0025] Figure 6 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] The circulation of data elements refers to the process of exchanging, sharing and utilizing data among different entities.
[0028] In related technologies, the circulation of data elements is mainly achieved through data packet transmission and API calls.
[0029] Data packet delivery refers to packaging a data set into a specific format and transmitting it to the recipient over the network. However, after the data packet is delivered, its use cannot be effectively controlled, making it extremely difficult to ensure that the data is only used for the specified purpose, and the risk of data theft, leakage or damage is increased.
[0030] Although the use of API calls can provide data services more conveniently, on the one hand, data theft is highly concealed and the cost is low; on the other hand, new interfaces need to be developed to meet new needs, which cannot meet flexible and changing needs.
[0031] In view of the above problems, an embodiment of the present invention provides a data query method. Figure 1 This is one of the flow charts of the data query method provided by the present invention. Figure 1 As shown, the method can be applied to a data query system, and the method includes: Step 110, in response to a query request sent by a data user, calling a smart contract to generate a query prompt, wherein the smart contract is deployed on a blockchain including the data user and the data provider, and the query prompt includes the query request and a restrictive prompt in the smart contract for protecting data.
[0032] The query request here is a request initiated by the data user, the purpose of which is to retrieve or obtain specific data from the data provided by the data provider. The query request can be initiated by the data user on the front end through a chat dialogue or a single-export API, and usually includes the specific data details that the data user wants to query, such as the type of data, specific data fields, etc. The specific content depends on the application scenario and data structure.
[0033] Data users can send query requests to the data query system. After receiving the query request, the data query system can call the smart contract on the blockchain to generate a query prompt.
[0034] Here, a smart contract is an automatically executed, self-verifying computer protocol in blockchain technology, which is used to promote, verify or execute contractual agreements between different parties. In an embodiment of the present invention, a smart contract is deployed on a blockchain including a data user and a data provider, and the smart contract contains provisions for protecting data, so that when the smart contract is executed under the trigger of a query request, the provisions for protecting data in the smart contract can take effect.
[0035] It is understandable that for all parties involved in data query, including data users and data providers, once the smart contract is deployed on the blockchain, the data user only has the right to call the smart contract but not the right to modify it; if the data provider needs to modify the smart contract, it needs to obtain the permission of other data providers and users through a voting mechanism before it can modify the smart contract. This immutability of smart contracts for data users strengthens the control over data use.
[0036] After the smart contract is triggered, query prompts can be generated according to the preset logic in the smart contract. The query prompts generated here not only include the query request of the data user, but also attach restrictive prompts designed to protect data security. Restrictive prompts can be a set of rules or conditions defined in the smart contract that need to be followed when performing data queries and are described in natural language. They may include but are not limited to: data access rights, data usage conditions, data processing restrictions, filtering and compliance of query results, etc. Restrictive prompts can ensure that all necessary data protection and security measures are followed during the execution of data queries, thereby protecting data from abuse or leakage during circulation. The query prompts generated by the combination of query requests and restrictive prompts can ensure accurate query of data required by data users under the premise of security, legality and transparency.
[0037] Step 120: Generate a query statement corresponding to the query prompt based on the large language model.
[0038] Specifically, a large language model (LLM) is a natural language processing (NLP) model with a large number of parameters. The number of model parameters and / or the complexity of the model structure exceeds the preset threshold. The model processes large amounts of text data during training and has the ability to understand and generate natural language. For example, large language models can include the Spark large model.
[0039] After obtaining the query prompt generated by the smart contract according to the built-in rules, the query prompt can be input into the large language model, which interprets the meaning and instructions and generates an accurate query statement that is executable for the data provider's data source. Here, the query statement is a further analysis and concretization of the query prompt, and is an executable query command formed by the large language model.
[0040] It should be noted that the large language model used in step 120 must be trusted by the data provider to ensure data security.
[0041] Step 130: Based on the query statement, access the data source of the data provider to obtain the query result.
[0042] Specifically, after obtaining the query statement, the data source provided by the data provider can be queried based on the query statement to obtain the query result. Here, the query statement output by the large language model is the direct basis for querying the data source of the data provider. The query statement specifies in detail the type and conditions of the data to be retrieved. At the data provider's data source, data query operations can be performed based on these detailed information in the query statement.
[0043] The data source of the data provider here may include pre-stored structured data and / or unstructured data. Among them, the structured data can be put into the database after being sorted, and provide information such as database type, table field name, etc. for easy query. For unstructured data, it is put into the database after being processed in different ways. The processing method of unstructured data includes structuring it and processing it in accordance with the structured data processing method, or vectorizing or using fine-tuning to integrate the corresponding information into a large language model patch. The processing method of unstructured data is not limited to at least one of the above methods.
[0044] The query results here refer to the data obtained from the data provider's data source, that is, the data that meets the query request of the data user and strictly abides by the restrictive instructions for protecting data. It usually includes data sets that meet the conditions specified in the query statement. These data sets may cover a variety of forms and structures, depending on the content of the query statement and the nature of the data source.
[0045] Step 140: Return the query result to the data user.
[0046] Specifically, after obtaining the query result based on the query statement generated by the large language model, the query result needs to be returned to the data user. In this way, the data user can obtain the query result that meets the query request issued by itself and has no risk of information leakage under the constraints of the restrictive prompts built into the smart contract.
[0047] The method provided by the embodiment of the present invention uses blockchain technology to provide transparent transaction records, ensures that all query requests and data queries are traceable, increases the auditability of data element circulation, and thus enhances the trust between data users and data providers. At the same time, the restrictive prompts built into the smart contract can pre-process the query request to ensure that any query complies with data privacy and security regulations, avoid the risk of data leakage, and strengthen the control of subsequent use of data. In addition, the smart contract can automatically execute the rules predefined by the data provider and the data user, reducing compliance costs. Moreover, by utilizing the semantic understanding ability of a large language model, a query statement that meets expectations is directly generated to realize data query, which effectively lowers the threshold for the circulation of data elements and increases the flexibility to adapt to query needs.
[0048] Based on the above embodiment, in step 120, generating a query statement corresponding to the query prompt based on a large language model includes: Based on the session manager, the query prompt is input into the large language model to obtain the query statement output by the large language model.
[0049] The session manager here is a key intermediary system for coordinating the interaction process between the blockchain and the large language model. It can be understood that in an embodiment of the present invention, the session manager is an interface that calls the large language model. The session manager receives the query prompts generated by the smart contract and can pass the query prompts to the large language model to generate specific query statements. The use of the session manager helps to maintain the consistency and coherence of the context and ensure the accurate transmission of information in the multi-step query process. In addition, the session manager can monitor and handle errors in the data query system, provide an effective recovery mechanism, and enhance the reliability of the system. Through load balancing and request optimization, the session manager can also improve the performance and response speed of the data query system. In addition, the session manager can record the log information of all query requests and responses, which is convenient for problem diagnosis and system performance tuning. Therefore, the session manager plays a vital role in the data query system, ensuring the stability, security and efficient operation of the system.
[0050] Specifically, the query prompts generated by the smart contract are sent to the session manager. After receiving the query prompts, the session manager sends the prompts to the large language model to generate specific query statements.
[0051] In the method provided in the embodiment of the present invention, the call of the large language model is implemented through the session manager, thereby preventing the operating environment of the large language model from external interference, thereby further ensuring the information security of data query generated based on the large language model.
[0052] Based on the above embodiment, in step 120, based on the session manager, inputting the query prompt into the large language model to obtain the query statement output by the large language model includes: Based on the conversation manager, the query prompt and the structural information of the data source are input into the large language model to obtain the query statement output by the large language model.
[0053] Specifically, the session manager not only needs to input the query prompts generated by the smart contract into the large language model, but also needs to input the structural information of the data source at the same time to optimize the query performance. For structured data, the structural information of the data source refers to the organization and relationship of the data in the data source, including detailed descriptions of the table structure, field name, data type, relationship between fields, indexes, constraints, etc. For unstructured data, it is preprocessed before being stored in the data source, including but not limited to structuring it and processing it in accordance with the structured data processing method, or vectorizing or, using fine-tuning to integrate the corresponding information into the large language model patch, the corresponding structural information may include the preprocessed form, and may also include the data structure after preprocessing.
[0054] The structural information of the data source can help large language models accurately generate query statements for the data source. Large language models can generate effective query statements that match the structural information of the data source and are targeted at the data source through the structural information of the input data source. In addition, understanding the structural information of the data source can help large language models generate optimized query statements and improve query efficiency. That is, for different types of data sources, the query statement can be a database query statement, a text fuzzy matching query statement, or an API call statement for a specific data set.
[0055] Based on the above embodiment, in step 120, based on the session manager, inputting the query prompt into the large language model to obtain the query statement output by the large language model includes: Based on the session manager, determining whether there is a historical query prompt that is consistent with the query prompt; When it is determined that there is no historical query prompt that is consistent with the query prompt, based on a session manager, inputting the query prompt into the large language model to obtain the query statement output by the large language model; When it is determined that there is a historical query prompt that is consistent with the query prompt, the historical query result corresponding to the historical query prompt is used as the query result.
[0056] Specifically, the session manager can store the query prompts used for historical data queries and the query results obtained by the queries, that is, the historical query prompts and the historical query results. In this way, after receiving a new query prompt, the session manager can first determine the consistency between the new query prompt and the historical query prompt, thereby determining whether the query request has been initiated before.
[0057] There are many methods for determining whether there is a historical query prompt that is consistent with the query prompt. The present invention provides an example to illustrate that this can be achieved by determining whether the hash value of the newly received query prompt is consistent with the hash value of the historical query prompt.
[0058] Figure 2 : This is a schematic diagram of an example of the query prompt consistency check process provided by the present invention. Specifically, the session manager receives the query prompt generated by the smart contract, and performs hash processing on the prompt to generate a unique hash value. The session manager uses the generated hash value to query its internal cache or database to find out whether there is a historical record that matches the current query prompt hash value.
[0059] If it is determined that there is no historical query prompt that is consistent with the query prompt, the session manager inputs the query prompt and the data source structure information into the large language model. The large language model uses its powerful natural language processing capabilities to generate a corresponding query statement. At the same time, the session manager records the query prompt and the corresponding query result, as well as the generated hash value, for future query use.
[0060] When it is determined that there is a historical query prompt that is consistent with the query prompt, the session manager directly retrieves the corresponding historical query result from its internal cache or database. The session manager returns the historical query result as the result of the current query to the data user. This process does not require re-requesting the large language model to generate query statements or accessing data sources, thereby significantly improving query response speed and system efficiency.
[0061] Based on the above embodiment, in step 130, accessing the data source of the data provider based on the query statement to obtain the query result includes: Based on the query statement, access the data source of the data provider to obtain the original query result; Based on the session manager, the original query result is verified, and if the verification result is qualified, the original query result is determined as the query result.
[0062] Specifically, the session manager first sends the query statements that have passed security and compliance checks to the executor. The executor can be part of a large language model agent, whose main responsibility is to execute query statements and interact with various data sources. The executor has the ability to connect and access multiple data sources. This multi-source access capability enables the executor to handle complex data requirements and obtain more comprehensive and diverse query results.
[0063] After receiving the query statement, the executor will perform query operations on the corresponding data source according to the specific query content. These operations may include but are not limited to sending SQL (Structured Query Language) queries to relational databases, sending API requests to Web services, or executing other types of data access commands. In this way, the executor can flexibly collect the required information from different types of data sources and summarize them into complete query results, ensuring that the system can efficiently and accurately meet data requirements.
[0064] After the data source returns the original query results, the executor aggregates these results as the original query results and returns them to the session manager, which verifies the original query results. The specific verification content includes: Data integrity verification checks whether the data contains all expected fields and records to ensure that no important information is missing.
[0065] Data accuracy verification to verify whether the data meets the query conditions and business rules.
[0066] Data consistency check ensures the consistency between data, checks whether there are redundant or conflicting data records, and ensures the logical correctness of the data.
[0067] Data compliance verification ensures that data meets security and compliance requirements, does not contain sensitive or unauthorized data, and prevents data leakage and illegal use.
[0068] If the verification result is qualified, the session manager determines the sorted original query result as the query result. This means that the original query result has passed all necessary verification steps and meets the expected standards and requirements. Finally, the session manager returns the processed query result to the data user. After receiving the query result, the data user can make further analysis and decisions based on the query result.
[0069] Based on the above embodiment, in step 130, the step of accessing the data source of the data provider based on the query statement to obtain the query result further includes: If the verification result is unqualified, the query prompt is updated based on the conversation manager, and the updated query prompt is input into the large language model.
[0070] Specifically, when the session manager detects an execution error or the result does not meet expectations, that is, when the verification result is unqualified, the correction and optimization mechanism will be activated. First, the session manager analyzes the cause of the error and the result deviation to determine the specific factors that cause the problem. This may involve but is not limited to query statement errors, data source connection problems, data format mismatch, etc. Based on the results of the problem analysis, the session manager adjusts and optimizes the original query prompt. For example, add more filtering conditions, clearer data fields, or modify the query logic to improve the accuracy and relevance of the query. The session manager inputs the updated query prompt into the large language model again. The large language model uses the updated prompt to generate a new query statement. The new query statement undergoes security and compliance checks to ensure that it complies with the security policies and compliance requirements of the system. The executor receives the new query statement, accesses the data source again to perform the query operation, and obtains the updated query result. The session manager verifies the new query result again. If the result is still unqualified, repeat the above steps to further optimize the query prompt until a query result that passes the verification is obtained.
[0071] Based on the above embodiment, in step 130, verifying the original query result based on the session manager includes: Based on the large language model, sorting the original query results; Based on the session manager, the sorted original query results are verified.
[0072] Specifically, the large language model will organize the original query results and then send them to the session manager for verification. The process of organization includes multiple data processing tasks, such as the large language model cleaning the original query results, removing redundant, repeated or invalid data, and ensuring the purity and availability of the data. Format the original query results into a standardized format for subsequent processing and verification. This may include converting data types, standardizing date formats, etc. Labeling key data, adding necessary metadata and annotations to improve the readability and comprehension of the data. For example, marking important transaction records or abnormal data points. Organizing and arranging data according to logical relationships to ensure that the data structure is reasonable and easy to analyze. This may include operations such as grouping, sorting or aggregating data. After organization, the original query results become neater, more orderly, and have higher usability and analytical value.
[0073] Next, the original query results after sorting are verified based on the session manager. The verification operation mainly includes data integrity verification, data accuracy verification, data consistency verification and data compliance verification. That is, check whether the returned data is complete, verify whether the data meets the query conditions, ensure data consistency and non-repetition, and ensure that the returned data meets the restrictive prompt requirements of the smart contract.
[0074] Based on the above embodiment, it also includes: After obtaining the query result, the transaction is completed based on the smart contract.
[0075] When the session manager verifies that the query result is qualified, the session manager determines the sorted original query result as the final query result and returns it to the data user. At the same time, once the session manager determines that the query result is qualified, the smart contract is triggered. The smart contract predefines the conditions and rules of the transaction and is automatically executed according to the query result. The smart contract verifies whether the transaction conditions are met based on the query results. If the transaction conditions are met, the smart contract automatically executes the transaction operation. After the smart contract executes the transaction, the detailed information of the transaction is recorded on the blockchain. After the smart contract completes the transaction, the system notifies the parties involved in the transaction. Through these steps, the system can not only query data efficiently, but also automatically complete transactions based on the query results, improving the automation and reliability of the business process.
[0076] Based on any of the above embodiments, Figure 3 This is the second flow chart of the data query method provided by the present invention, such as Figure 3 As shown, the method includes: Step 310: data preprocessing and blockchain establishment.
[0077] Specifically, the raw data is preprocessed, including structured data processing and unstructured data processing, and the processed data is stored in the data source. At the same time, a blockchain is established between the data user and the data provider, and a smart contract is deployed on the blockchain. The smart contract contains restrictive prompts for large language models.
[0078] Step 320: The user initiates a query request.
[0079] The user initiates a query request through the front end, which calls the smart contract, combines the query request with the restrictive prompt to generate a query prompt, and passes it to the session manager.
[0080] Step 330: The session manager determines whether the query prompt is consistent with the historical query prompt.
[0081] The session manager determines whether there is a historical query prompt at the query prompt. If so, it directly calls the historical query result; if not, it requests to use a large language model trusted by the data user to generate a query statement based on the query prompt, and passes the generated query statement to the executor of the large model agent, while recording the query prompt.
[0082] Step 340: The executor accesses the data source to obtain the query result.
[0083] The executor accesses multiple data sources based on the query statement to obtain the query results, returns the query results to the large language model for analysis and collation, and then passes the results to the session manager.
[0084] Step 350: The session manager verifies the query result.
[0085] The session manager verifies the query result, and if the verification result is qualified, determines the query result as the final query result and returns it to the user. If the verification result is unqualified, the query prompt is updated, input into the large language model, and the data query operation is re-executed until a qualified query result is obtained.
[0086] Step 360, complete the transaction.
[0087] After the user gets the query result, the smart contract completes the transaction.
[0088] Based on any of the above embodiments, Figure 4 Schematic diagram of an example of a data query system provided by the present invention. Figure 4As shown, the data user U initiates a data query request. The smart contract on the blockchain BC, the blockchain query contract BCC module combines the query request and the restrictive prompt to generate a query prompt and passes it to the session manager SM module. The session manager SM module will compare the query prompt with the historical query prompt for consistency. If it is determined that there is no consistent historical query prompt, the query prompt will be passed to the trusted large model CLLM module. This module contains a large language model that is trusted by the data providers DPA and DPB. The large language model generates a query statement based on the query prompt and passes the generated query statement to the large model agent executor E module. Executor E accesses the data provider DPA and DPB based on the query statement. The data provider DPA contains unstructured data Data-A1 that has undergone an embedded operation and structured data Data-A2 that has undergone a text-to-SQL operation; the data provider DPB contains unstructured data Data-B1 that has undergone an embedded operation. After executor E queries the data from the data provider DPA and DPB, it passes the data back to the large language model and the session manager for verification. The verified data will be returned to the data user U.
[0089] The data query device provided by the present invention is described below. The data query device described below and the data query method described above can be referenced to each other.
[0090] Figure 5 is a schematic diagram of the structure of the data query device provided by the present invention, such as Figure 5 As shown, the device comprises: The blockchain unit 510 is used to call a smart contract to generate a query prompt in response to a query request sent by a data user, wherein the smart contract is deployed on a blockchain including the data user and the data provider, and the query prompt includes the query request and a restrictive prompt in the smart contract for protecting data.
[0091] The large model unit 520 is used to generate a query statement corresponding to the query prompt based on a large language model.
[0092] The query execution unit 530 is used to access the data source of the data provider based on the query statement to obtain the query result.
[0093] The result returning unit 540 is used to return the query result to the data user.
[0094] The device provided by the embodiment of the present invention responds to the query request of the data user through the smart contract deployed on the blockchain, generates a query prompt, and generates a corresponding query statement based on the high semantic understanding ability of the large language model. The execution unit accesses the data source of the data provider according to the generated query statement, executes the query operation, and obtains the original query result. The original query result is returned to the large language model for processing and transmitted to the session management unit for verification. If the verification result is unqualified, the session management unit analyzes the cause of the problem, updates the query prompt and inputs it into the large language model again to generate a new query statement, and re-executes the query until a qualified result is obtained. The query result that has been verified and qualified is returned to the data user in an appropriate format. After obtaining the query result, the transaction is automatically completed based on the smart contract. By combining blockchain technology and large language models, the risk of data leakage in the circulation of data elements is greatly reduced, the auditability of the circulation of data elements is enhanced, and the flexibility to adapt to query needs is increased.
[0095] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the data query method, which includes: In response to a query request sent by a data user, calling a smart contract to generate a query prompt, the smart contract being deployed on a blockchain including the data user and the data provider, the query prompt including the query request and a restrictive prompt in the smart contract for protecting data; Based on the large language model, generate a query sentence corresponding to the query prompt; Based on the query statement, access the data source of the data provider to obtain the query result; The query result is returned to the data user.
[0096] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the relevant technology or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0097] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the data query method provided by the above methods, the method includes: In response to a query request sent by a data user, calling a smart contract to generate a query prompt, the smart contract being deployed on a blockchain including the data user and the data provider, the query prompt including the query request and a restrictive prompt in the smart contract for protecting data; Based on the large language model, generate a query sentence corresponding to the query prompt; Based on the query statement, access the data source of the data provider to obtain the query result; The query result is returned to the data user.
[0098] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the data query method provided by the above methods is implemented, and the method includes: In response to a query request sent by a data user, calling a smart contract to generate a query prompt, the smart contract being deployed on a blockchain including the data user and the data provider, the query prompt including the query request and a restrictive prompt in the smart contract for protecting data; Based on the large language model, generate a query sentence corresponding to the query prompt; Based on the query statement, access the data source of the data provider to obtain the query result; The query result is returned to the data user.
[0099] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0100] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.
[0101] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data query method, characterized in that: include: In response to a query request sent by a data user, calling a smart contract to generate a query prompt, the smart contract being deployed on a blockchain including the data user and the data provider, the query prompt including the query request and a restrictive prompt in the smart contract for protecting data; Based on the large language model, generate a query sentence corresponding to the query prompt; Based on the query statement, access the data source of the data provider to obtain the query result; The query result is returned to the data user.
2. The data query method according to claim 1, characterized in that: The generating a query statement corresponding to the query prompt based on the large language model includes: Based on the session manager, the query prompt is input into the large language model to obtain the query statement output by the large language model.
3. The data query method according to claim 2, characterized in that: The step of inputting the query prompt into the large language model based on the conversation manager to obtain the query statement output by the large language model includes: Based on the conversation manager, the query prompt and the structural information of the data source are input into the large language model to obtain the query statement output by the large language model.
4. The data query method according to claim 2, characterized in that: The step of inputting the query prompt into the large language model based on the conversation manager to obtain the query statement output by the large language model includes: Based on the session manager, determining whether there is a historical query prompt that is consistent with the query prompt; When it is determined that there is no historical query prompt that is consistent with the query prompt, based on a session manager, inputting the query prompt into the large language model to obtain the query statement output by the large language model; When it is determined that there is a historical query prompt that is consistent with the query prompt, the historical query result corresponding to the historical query prompt is used as the query result.
5. The data query method according to claim 2, characterized in that: The step of accessing the data source of the data provider based on the query statement to obtain the query result includes: Based on the query statement, access the data source of the data provider to obtain the original query result; Based on the session manager, the original query result is verified, and if the verification result is qualified, the original query result is determined as the query result.
6. The data query method according to claim 5, characterized in that: The step of accessing the data source of the data provider based on the query statement to obtain the query result further includes: If the verification result is unqualified, the query prompt is updated based on the conversation manager, and the updated query prompt is input into the large language model.
7. The data query method according to claim 5, characterized in that: The verifying the original query result based on the session manager includes: Based on the large language model, sorting the original query results; Based on the session manager, the sorted original query results are verified.
8. The data query method according to any one of claims 1 to 7, characterized in that: Also includes: After obtaining the query result, the transaction is completed based on the smart contract.
9. A data query device, characterized in that: include: A blockchain unit, configured to, in response to a query request sent by a data user, call a smart contract to generate a query prompt, wherein the smart contract is deployed on a blockchain including the data user and the data provider, and the query prompt includes the query request and a restrictive prompt in the smart contract for protecting data; A large model unit, used to generate a query statement corresponding to the query prompt based on a large language model; A query execution unit, configured to access the data source of the data provider based on the query statement to obtain a query result; The result returning unit is used to return the query result to the data user.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the data query method according to any one of claims 1 to 8 is implemented.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data query method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the data query method according to any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Data processing method and device and large language model fine tuning method and device
CN119576964A
Data processing method and device, large language model fine-tuning method and device
CN119576964B
Data query method and device, equipment and storage medium
CN121029819A
