A knowledge sharing method and system based on blockchain and knowledge graph
By combining blockchain technology with knowledge graphs, using smart contracts and large language models to achieve cross-domain integration and secure sharing of knowledge graphs, the data islands, inconsistent quality and copyright security problems of knowledge graph sharing in the existing technology are solved. , achieving efficient, secure sharing of knowledge graphs and improving application value.
Patent Information
- Application Number
- CN202411667232.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2044-11-21
AI Technical Summary
The existing knowledge graph construction and sharing methods have data silos, inconsistent quality, copyright and security issues, making it difficult to achieve knowledge sharing between different industries and fields.
Using blockchain technology and knowledge graphs, domain division and integration of knowledge graphs are used through smart contracts, and external inference services are used to interact with blockchain through oracles to realize cross-domain integration of knowledge graphs and Secure sharing.
It has achieved the interconnection of knowledge graphs between different industries and fields, improved the quality and application value of knowledge graphs, solved copyright and security issues, and promoted the dissemination and innovation of knowledge.
Smart Images

Figure CN119149508B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a knowledge sharing method and system based on blockchain and knowledge graph. Background Art
[0002] With the rapid development of information technology, knowledge graphs, as a structured knowledge representation method, have been widely used in various fields, such as semantic search, intelligent recommendation, natural language processing, etc. However, the existing knowledge graph construction and sharing methods have the following problems: data island phenomenon. There are often data islands between different industries and fields, which limits the construction and application of knowledge graphs. It is difficult for knowledge graphs owned by various industries to communicate with each other, which limits the sharing and innovation of knowledge; the quality of knowledge graphs varies greatly. Due to the lack of unified standards and specifications, the quality of knowledge graphs annotated by various industries varies greatly, which affects the effect of knowledge graphs in practical applications; knowledge graph copyright and security issues. In traditional knowledge sharing platforms, the copyright ownership and security issues of knowledge graphs are becoming increasingly prominent. Knowledge providers are worried about copyright disputes and data leakage, which affects the enthusiasm for knowledge sharing.
[0003] In response to the above problems, blockchain technology, as a decentralized, secure and reliable technical means, has gradually attracted attention. Blockchain technology has natural advantages in data sharing and copyright protection, and provides new ideas for sharing knowledge graphs. However, how to combine blockchain technology with knowledge graphs to achieve efficient and secure knowledge sharing is still a problem that needs to be solved. Summary of the invention
[0004] The purpose of the present invention is to solve the problems in the prior art.
[0005] The technical solution adopted by the present invention to solve the technical problem is: to provide a knowledge sharing method based on blockchain and knowledge graph, including the following steps:
[0006] The user uploads the knowledge graph to the blockchain, and the smart contract divides the newly added knowledge graph into fields and integrates it into the knowledge graph of the corresponding field. When receiving the reasoning request of the smart contract, the oracle requests an external reasoning service independent of the blockchain;
[0007] The external reasoning service receives the oracle request, uses a large language model to reason and improve the knowledge graph in the field, and transmits the reasoning results back to the smart contract, which records them on the chain. The external reasoning mines the potential rules in the knowledge graph through the prompt template, selects the final logical rules through the scoring mechanism, and applies them to the reasoning of the knowledge graph.
[0008] The smart contract receives the inference results and updates the knowledge graph of the field on the blockchain.
[0009] Preferably, the smart contract divides and integrates the knowledge graph uploaded by the user into different fields, including the following steps:
[0010] Smart contracts allow users to upload knowledge graph data and classify the uploaded knowledge graphs;
[0011] After determining the category of the knowledge graph, the smart contract integrates the knowledge graph into the knowledge graph collection of the corresponding field on the blockchain, records the request for this operation, and notifies the outside world that the knowledge graph has been successfully uploaded and divided and integrated.
[0012] Preferably, the external reasoning comprises the following steps:
[0013] Given a target relation, a set of seed triples is selected from the knowledge graph, and a breadth-first search algorithm is used to sample some closed paths from the knowledge graph as instances of logical rules;
[0014] Obtain rule samples based on instances of logical rules;
[0015] Design a prompt function to guide the large language model to generate logical rules based on rule samples;
[0016] The generated logical rules are filtered and the knowledge graph is inferred based on the filtered logical rules.
[0017] Preferably, the method of sampling some closed paths from the knowledge graph as instances of logical rules by using a breadth-first search algorithm comprises the following steps:
[0018] Load the knowledge graph and obtain the relationship dictionary and facts in the knowledge graph;
[0019] Extracting a closed relationship path from the knowledge graph based on the relationship dictionary and facts, wherein the closed relationship path refers to a path starting from an entity, passing through multiple intermediate entities and finally returning to the starting entity; the process of extracting the closed relationship path adopts multi-process technology, and before extraction, parameters including the maximum path length, the number of anchor point facts, the output path and the number of cores are set;
[0020] Output closed relationship paths as instances of logical rules.
[0021] Preferably, the example based on the logical rule obtains the rule sample, specifically: the actual entity in the rule instance is replaced by a variable to obtain the rule sample; the rule sample expresses the structural information of the knowledge graph in the form of a sequence, and this structural information is used to input into the large language model to promote the generation of logical rules.
[0022] Preferably, the prompt function contains four parameters:
[0023] Rule header, which represents the expected relationship for which logical rules need to be generated;
[0024] Candidate predicates are a set of predicates that can be selected;
[0025] Zero sample flag, indicating whether it is in zero sample learning mode. If the input rule sample is 0, it is in zero sample learning mode. If the input rule sample is not 0, it is in non-zero sample learning mode.
[0026] The number of rules determines the number of rules that should be generated.
[0027] Preferably, the large language model generates logic rules by executing the prompt function, comprising the following steps:
[0028] Establish basic instructions and explain the logical implication relationship between the rule head and the rule body; the rule body represents a series of prerequisites that make the rule head valid;
[0029] Construct prediction instructions to determine whether it is a zero-shot learning mode, and construct corresponding example contexts based on whether it is a zero-shot learning mode. In the zero-shot mode, provide a series of example contexts to guide the large language model to generate logical rules. In the non-zero-shot mode, use the provided rule samples as example contexts to guide the large language model to generate logical rules.
[0030] Integrate basic instructions, sample context, and predicted instructions to generate a comprehensive prompt text;
[0031] Generate logical rules under the guidance of prompt text.
[0032] Preferably, the process of selecting the final logic rules through the scoring mechanism comprises the following steps:
[0033] The support, coverage and confidence of the calculation rules are expressed as:
[0034] ;
[0035] ;
[0036] ;
[0037] in, Representation Rules The support of Representation Rules The coverage rate, Representation Rules Confidence level; : indicates that the specific expression formula of the parameter on the left side of the symbol is the formula on the right side of the symbol; "=" indicates the value calculated by the formula on the right side of the symbol; # is a representation of the rule head; Indicates the difference between e and Variables other than Indicates that the knowledge graph satisfies the rules A series of facts, Indicates that the rule header is met the fact that
[0038] Assign different weights to support, coverage, and confidence and add them together to get a comprehensive score;
[0039] Keep the rule that the comprehensive score is not lower than the preset score.
[0040] Preferably, the smart contract receives the inference result and updates the knowledge graph of the field on the blockchain, including the following steps:
[0041] The oracle sends the inference results back to the smart contract;
[0042] Smart contracts update the knowledge graph of the corresponding field based on the reasoning results;
[0043] The smart contract notifies the outside world that the reasoning process has been completed and the knowledge graph on the blockchain has been updated according to the new reasoning results.
[0044] The present invention also provides a knowledge sharing system based on blockchain and knowledge graph, comprising:
[0045] Upload module: users upload knowledge graphs to the blockchain. Smart contracts divide the newly added knowledge graphs into different fields and integrate them into the knowledge graphs of the corresponding fields. When receiving external reasoning requirements, they request external reasoning services independent of the blockchain through the oracle.
[0046] Inference module, the external reasoning service receives the oracle request, uses the large language model to mine the logical rules and improve the knowledge graph in the field, and returns the reasoning results to the smart contract; the external reasoning mines the potential rules in the knowledge graph through the prompt template, selects the final logical rules through the scoring mechanism, and applies the large language model to the reasoning of the knowledge graph;
[0047] In the update module, the smart contract receives the reasoning results and updates the knowledge graph of the field on the blockchain.
[0048] The present invention has the following beneficial effects:
[0049] (1) The present invention uses blockchain technology to achieve the interconnection of knowledge graphs in different industries and fields, promoting the dissemination and innovation of knowledge; the copyright protection and data security mechanism of blockchain also effectively solves the copyright disputes and data leakage problems of knowledge graphs;
[0050] (2) The present invention uses a large language model to mine high-quality logical rules, which improves the efficiency and accuracy of knowledge graph construction and improves the quality of knowledge graph;
[0051] (3) The present invention improves the scalability and flexibility of the solution by integrating steps through field division, and can be widely applied in multiple fields.
[0052] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments, but the present invention is not limited to the embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A method step diagram of an embodiment of the present invention;
[0054] Figure 2 It is a schematic diagram of a flow chart of an embodiment of the present invention;
[0055] Figure 3 4 is a system structure diagram of an embodiment of the present invention. DETAILED DESCRIPTION
[0056] The present invention proposes a knowledge sharing method based on blockchain and knowledge graph. The method realizes the cross-domain integration and secure sharing of knowledge graphs by introducing innovative technical means such as blockchain oracles and off-chain reasoning services, and provides strong support for the wide application and value creation of knowledge graphs. The present invention provides a knowledge sharing system based on blockchain and knowledge graph technology, which ensures the immutability and transparency of knowledge graphs; the knowledge sharing system consists of multiple nodes, each of which stores a copy of the knowledge graph to achieve data redundancy and reliability; the core smart contract module is responsible for processing operations such as uploading, classifying, fusion and downloading of knowledge graphs, and its code is deployed on the blockchain network to automatically execute preset logic; the oracle interface serves as a bridge for off-chain data interaction, allowing smart contracts to obtain external data or call external services; the off-chain reasoning service is independent of the blockchain, performs complex knowledge graph reasoning tasks, receives oracle requests and returns calculation results.
[0057] See also Figure 1 FIG. 1 is a diagram showing steps of a method according to an embodiment of the present invention, comprising the following steps:
[0058] S101, the user uploads the knowledge graph to the blockchain, the smart contract divides the newly added knowledge graph into fields and integrates it into the knowledge graph of the corresponding field, and requests external reasoning services independent of the blockchain through the oracle when receiving external reasoning requirements;
[0059] S102, the external reasoning service receives the oracle request, uses a large language model to reason and improve the knowledge graph in the field, and returns the reasoning result to the smart contract; the external reasoning mines the potential rules in the knowledge graph through the prompt template, selects the final logical rules through the scoring mechanism, and applies them to the reasoning of the knowledge graph;
[0060] S103, the smart contract receives the reasoning result and updates the knowledge graph of the field on the blockchain.
[0061] See also Figure 2 As shown, it is a flow chart of an embodiment of the present invention. After the user uploads the knowledge graph, the smart contract is called to perform step ① first, and then perform step ②. Step ① includes: classification through the domain division submodule of the smart contract, and the knowledge graphs in the same field are integrated through the knowledge fusion submodule; then, by designing a new reasoning scheme, the large language model is cleverly introduced into the reasoning process of the knowledge graph. Through the carefully designed prompt template and scoring mechanism, the large prediction model can deeply explore the potential rules in the knowledge graph, and these rules will then be sorted and screened through the scoring mechanism to ensure the accuracy and effectiveness of the rules; the high-scoring rules finally screened out will be applied to the reasoning update of the knowledge graph, thereby realizing efficient reasoning and in-depth utilization of the knowledge graph. Step ② includes: using the knowledge graph updated after reasoning to update the knowledge graph on the chain.
[0062] The following describes the important contents of the embodiments of the present invention in points.
[0063] (1) Design and deployment of smart contracts. The embodiments of the present invention use oracle technology in the process of data processing. It is an innovative solution that allows blockchain smart contracts to securely access and integrate information from external data sources. Through this technology, smart contracts can execute contract terms based on real-world events and conditions, thereby greatly expanding the scope and practicality of blockchain applications. Oracles retrieve, verify and transmit data through decentralized network nodes, ensuring the authenticity and reliability of data, while reducing the risk of single point failures, allowing blockchain to interact effectively with the outside world. Oracle technology is crucial in providing smart contracts with a trust-minimized data input mechanism. This technology not only enhances the functionality of smart contracts, enabling them to respond to a variety of complex external trigger conditions, but also maintains the closedness and security of the blockchain system, providing new application possibilities and business models for multiple fields such as finance, supply chain, and identity authentication.
[0064] The pseudo code of the smart contract is shown in Table 1.
[0065] Table 1 Smart contract pseudo code:
[0066]
[0067] The code consists of two parts. The first part is the initialization and inference request process: the smart contract KnowledgeGraphContract allows users to upload knowledge graph data and classify the uploaded knowledge graph through the function uploadAndClassifyGraph. Once the graph category graphCategory is determined, the contract will integrate the knowledge graph into the knowledge graph collection of the corresponding category on the blockchain and record the request for this operation. Subsequently, the contract notifies the outside world that the knowledge graph has been successfully uploaded and classified by triggering the GraphUploadedAndCategorized event. Next, users can request an external inference service by calling the requestInference function, which creates a request object, sets the necessary request parameters, and sends the request to the external adapter address. After the request is sent, the InferenceRequested event is triggered. The second part is the process of processing the inference result: when the external inference service completes the calculation, the oracle calls the fulfill callback function in the smart contract, passing in the request ID and the inference result. The fulfill function stores the inference result in the contract's state variable inferenceResults and updates the knowledge graph of the corresponding category according to the result. After completing these operations, the contract will trigger the InferenceCompleted event to notify the outside world that the inference process has been completed and the knowledge graph on the blockchain has been updated according to the new inference results. In this way, users and other contracts can obtain the updated knowledge graph by calling the getKnowledgeGraph function.
[0068] (2) Knowledge graph reasoning. Mining the logical rules of knowledge graphs based on large language models can significantly improve the efficiency and accuracy of building knowledge graphs. These models can automatically extract complex relationships and rules from large amounts of text without requiring a lot of manual intervention, reducing the time and cost required to build knowledge graphs. In addition, the powerful contextual understanding capabilities of large language models enable them to identify and express subtle logic in knowledge graphs, thereby generating more comprehensive and high-quality knowledge graphs.
[0069] Compared with traditional hand-built or rule-based methods, large language models have advantages in processing large-scale and diverse data. They can adapt to new data types and fields, reduce human bias, and support cross-language logic rule mining, making the knowledge graph construction process more flexible, consistent, and scalable. These features make large language models an efficient and powerful tool for mining knowledge graph logic rules.
[0070] In order to enable LLMs to understand the KGs structure for rule mining, the embodiment of the present invention adopts a breadth-first search algorithm (BFS) to sample some closed paths from KGs, which can be used as instances of logical rules. First, the data path and data set name are loaded, and the relationship dictionary and facts in the knowledge graph are obtained. Then, according to the set parameters such as the maximum path length, the number of anchor facts, the output path and the number of cores, a multi-process technology is used to extract closed relationship paths from the knowledge graph. A closed relationship path refers to a path that starts from an entity, passes through multiple intermediate entities, and finally returns to the starting entity. Finally, the extracted closed relationship path is saved in the output path. In this way, the program can efficiently generate path data from the knowledge graph to provide support for subsequent training or reasoning. For example: given a triple (Alice, Grandmother, Charlie), a closed path p can be found:
[0071] ;
[0072] Then we can get a rule instance Grandmather(Alice, Charlie)←Mother(Alice, Bob)∧Father(Bob, Charlie).
[0073] Given a target relation, we first select a set of seed triples from KGs , and then use BFS to sample a set of rule instances; then replace the actual entities in the rule instances with variables to obtain rule samples. The rule samples express the structural information of KGs in the form of sequences, which can be input into the large language model to facilitate the generation of rules.
[0074] Large language models trained on large corpora have demonstrated the ability to understand natural language semantics and can use common sense knowledge for complex reasoning. In order to integrate the structure and utilize the rule mining capabilities of LLMs, the embodiment of the present invention carefully designs a prompt structure. prompt is a function that generates a logical rule prompt; the large language model generates logical rules by executing prompt; thus, the knowledge graph can be inferred based on logical rules. For the inversion of all original relations, the embodiment of the present invention uses the method of adding the "inv" symbol to realize the verb expression. The embodiment of the present invention embeds the colloquial rule sample into the prompt template and submits it to LLMs to generate rules. The pseudocode structure of prompt is shown in Table 2.
[0075] Table 2 prompt structure:
[0076]
[0077] This function generates a logical rule prompt to build an accurate guidance prompt for a large language model, aiming to guide the model to generate logical rules that describe the relationship between entities X and Y. The function contains four parameters: the rule head represents the expected relationship of the rule to be generated, the candidate predicate is a set of predicates that can be selected, the zero-shot flag is used to indicate whether it is in zero-shot learning mode, and the rule number parameter determines the number of rules that the model should generate. The code first establishes the basic instructions and explains the constituent elements of the logical rule, that is, the logical implication relationship between the rule head on the left and the condition (rule body) on the right. The rule head is the conclusion part of the rule, which is used to represent the category or concept of the judgment target; the rule body is the premise part of the rule, which is a conjunction composed of multiple logical literals (that is, all conditions must be met); for example, in the rule "If X is the father of Y, then X is the grandfather of Y", "X is the grandfather of Y" is the rule head, and "X is the father of Y" is the rule body. Each logical literal in the rule body is a condition. When all these conditions are met, the rule head will be derived. Subsequently, depending on whether it is zero-shot learning mode, the function constructs the corresponding example context and prediction instructions respectively. In zero-shot mode, a series of example rules are provided for the model to learn; in few-shot mode, the provided examples are used to guide the generation of rules. Finally, the function integrates the basic instructions, example context, and prediction instructions, explicitly requiring the model to construct rules using only elements in the candidate predicate list, and emphasizing that the return result should only contain the rule itself. The output of this function is a comprehensive prompt text, which provides clear guidance for large language models to perform logical rule generation tasks.
[0078] Because large language models may experience hallucinations when generating content, resulting in errors in the output results. For example, in an embodiment of the present invention, in the logical rules generated by prompts, erroneous rules such as "husband (X, Y) ← husband (X, Z1) & brother (Z1, Y)" appear. In view of this, an embodiment of the present invention sorts and filters the generated rules, and evaluates the effectiveness of these rules based on the facts in the knowledge graph. The embodiment of the present invention uses three metrics - support, coverage, and confidence to filter and optimize the rules.
[0079] Support represents the number of facts in KG that satisfy rule ρ, which is defined as:
[0080] ;
[0081] in, Indicates that the KG satisfies the rule A series of facts, Indicates that the rule header is met fact.
[0082] Obviously, those rules with zero support can be easily removed from the candidate list without further optimization. However, support is an absolute value. For relations containing a large number of facts in the knowledge graph, the support may be high, which may cause the ranking results to be biased towards certain specific relations.
[0083] Coverage, which normalizes support by counting the number of facts per relation. It is defined as:
[0084] ;
[0085] As an indicator, coverage effectively quantifies the proportion of facts implied by rule ρ in the knowledge graph. In order to more comprehensively evaluate the misprediction of rules, the embodiment of the present invention introduces a confidence indicator to more accurately evaluate the quality of rules.
[0086] Confidence is defined as the ratio of the total number of facts that conform to rule ρ in the knowledge graph to the number of matches of the rule body (ρ). It is defined as:
[0087] .
[0088] The scheme of screening the logical rules mined from the knowledge graph using the large language model with three indicators is implemented through a comprehensive scoring method. First, the rules with high frequency in the knowledge graph are screened out according to the support index to ensure that these rules have sufficient data support. Then, the coverage index is used to further screen out the rules that can cover most of the relevant entities and relationships in the knowledge graph to ensure the applicability and extensiveness of the rules. Finally, the accuracy of the rules is evaluated by the confidence index, and those rules with accurate classification and few false predictions are selected. These three screening processes are assigned different weights to form a comprehensive score. Only when the rule has a comprehensive score of no less than 80, it is considered a high-quality rule and is selected for reasoning in the knowledge graph. The weight assignment and comprehensive score are shown in Table 3.
[0089] Table 3 Weight assignment and comprehensive score:
[0090]
[0091] For details, see Figure 3 FIG. 1 is a system structure diagram of an embodiment of the present invention, including:
[0092] Upload module 301, the user uploads the knowledge graph to the blockchain, the smart contract divides the newly added knowledge graph into fields and integrates it into the knowledge graph of the corresponding field, and requests external reasoning services independent of the blockchain through the oracle when receiving external reasoning requirements;
[0093] Inference module 302, the external reasoning service receives the oracle request, uses the large language model to reason and improve the knowledge graph in the field, and returns the reasoning result to the smart contract; the external reasoning mines the potential rules in the knowledge graph through the prompt template, selects the final logical rules through the scoring mechanism, and applies the large language model to the reasoning of the knowledge graph;
[0094] Update module 303, the smart contract receives the reasoning results and updates the knowledge graph of the field on the blockchain.
[0095] The present invention successfully constructs a knowledge sharing method based on blockchain and knowledge graph, realizes knowledge exchange and sharing between different industries and fields, and breaks the data island phenomenon. Through smart contracts and oracle technology, the secure storage, efficient reasoning and real-time updating of knowledge graphs are ensured, and the application value of knowledge graphs is improved. The logical rules of knowledge graphs are mined using large language models to improve the efficiency and accuracy of knowledge graph construction and maximize the value of knowledge graphs. Establish a complete copyright protection and data security mechanism to enhance user trust and increase the enthusiasm for knowledge sharing. The platform is highly scalable and flexible, and can be widely used in education, scientific research, corporate decision-making and other fields, providing new solutions for information circulation and value creation in the knowledge economy era.
[0096] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A knowledge sharing method based on blockchain and knowledge graph, characterized in that: The following steps are involved: The user uploads the knowledge graph to the blockchain, and the smart contract divides the newly added knowledge graph into fields and integrates it into the knowledge graph of the corresponding field. When receiving the reasoning request of the smart contract, the oracle requests an external reasoning service independent of the blockchain; The external reasoning service receives the oracle request, uses a large language model to reason and improve the knowledge graph in the field, and transmits the reasoning results back to the smart contract, which records them on the chain. The external reasoning service mines the logical rules in the knowledge graph through the prompt template, selects the final logical rules through the scoring mechanism, and applies them to the reasoning of the knowledge graph. The smart contract receives the inference results and updates the knowledge graph of the field on the blockchain; The large language model generates logic rules by executing the prompt function, including the following steps: Establish basic instructions, which describe the logical relationship between the rule header and the rule body; the rule body represents a series of prerequisites that make the rule header valid; Construct prediction instructions to determine whether it is a zero-shot learning mode, and construct corresponding example contexts based on whether it is a zero-shot learning mode. In the zero-shot learning mode, provide a series of example contexts to guide the large language model to generate logical rules. In the non-zero-shot learning mode, use the provided rule samples as example contexts to guide the large language model to generate logical rules. Integrate basic instructions, sample context, and predicted instructions to generate a comprehensive prompt text; Generate logical rules under the guidance of prompt text; The final logic rules are screened out through the scoring mechanism, including the following steps: The support, coverage and confidence of the calculation rules are expressed as: Among them, sup(ρ) represents the support of rule v, cov(v) represents the coverage of rule ρ, and con(ρ) represents the confidence of rule ρ; : represents that the specific expression formula of the parameter on the left side of the symbol is the formula on the right side of the symbol; "=" represents the value calculated by the formula on the right side of the symbol; # represents a representation of the rule head; represents variables other than e and e'; (e,r1,e2)∧,...,∧(e L-1 ,r L ,e') represents a series of facts in the knowledge graph that satisfy the rule body(ρ), (e,r h ,e') indicates that the rule head r is satisfied h the fact that Assign different weights to support, coverage, and confidence and add them together to get a comprehensive score; Keep the rule that the comprehensive score is not lower than the preset score.
2. The knowledge sharing method based on blockchain and knowledge graph according to claim 1 is characterized in that: The smart contract divides and integrates the knowledge graph uploaded by the user into different fields, including the following steps: Smart contracts allow users to upload knowledge graphs and classify the uploaded knowledge graphs; After determining the category of the knowledge graph, the smart contract integrates the knowledge graph into the knowledge graph collection of the corresponding field on the blockchain, records the request for this operation, and notifies the outside world that the knowledge graph has been successfully uploaded and divided and integrated.
3. The knowledge sharing method based on blockchain and knowledge graph according to claim 1 is characterized in that: The external reasoning service includes the following steps: Given a target relation, a set of seed triples is selected from the knowledge graph, and a breadth-first search algorithm is used to sample some closed relation paths from the knowledge graph as instances of logical rules; Obtain rule samples based on instances of logical rules; Design a prompt function to guide the large language model to generate logical rules based on rule samples; The generated logical rules are filtered and the knowledge graph is inferred based on the filtered logical rules.
4. The knowledge sharing method based on blockchain and knowledge graph according to claim 3 is characterized in that: The method of using a breadth-first search algorithm to sample some closed relationship paths from a knowledge graph as instances of logical rules includes the following steps: Load the knowledge graph and obtain the relationship dictionary and facts in the knowledge graph; Extracting a closed relationship path from the knowledge graph based on the relationship dictionary and facts, wherein the closed relationship path refers to a path starting from an entity, passing through multiple intermediate entities and finally returning to the starting entity; the process of extracting the closed relationship path adopts multi-process technology, and before extraction, parameters including the maximum path length, the number of anchor point facts, the output path and the number of cores are set; Output closed relationship paths as instances of logical rules.
5. The knowledge sharing method based on blockchain and knowledge graph according to claim 3 is characterized in that: The rule samples are obtained based on the instances of logical rules, specifically: actual entities in the rule instances are replaced with variables to obtain rule samples; the rule samples express the structural information of the knowledge graph in the form of sequences, and these structural information are used to input into the large language model to promote the generation of logical rules.
6. The knowledge sharing method based on blockchain and knowledge graph according to claim 3 is characterized in that: The prompt function contains four parameters: Rule header, which represents the expected relationship for which logic rules need to be generated; Candidate predicates are a set of predicates that can be selected; Zero sample flag, indicating whether it is in zero sample learning mode. If the input rule sample is 0, it is in zero sample learning mode. If the input rule sample is not 0, it is in non-zero sample learning mode. The number of rules determines the number of rules that should be generated.
7. The knowledge sharing method based on blockchain and knowledge graph according to claim 1 is characterized in that: The smart contract receives the inference result and updates the knowledge graph of the field on the blockchain, including the following steps: The oracle sends the inference results back to the smart contract; Smart contracts update the knowledge graph of the corresponding field based on the reasoning results; The smart contract notifies the outside world that the reasoning service has been completed and the knowledge graph on the blockchain has been updated according to the new reasoning results.
8. A knowledge sharing system based on blockchain and knowledge graph, used to implement the knowledge sharing method described in any one of claims 1 to 7, characterized in that: include: Upload module: users upload knowledge graphs to the blockchain. Smart contracts divide the newly added knowledge graphs into different fields and integrate them into the knowledge graphs of the corresponding fields. When receiving the reasoning request from the smart contract, the oracle requests an external reasoning service independent of the blockchain. Inference module, the external reasoning service receives the oracle request, uses the large language model to reason and improve the knowledge graph in the field, and transmits the reasoning result back to the smart contract, which is recorded on the chain by the smart contract; the external reasoning service mines the logical rules in the knowledge graph through the prompt template, selects the final logical rules through the scoring mechanism, and applies them to the reasoning of the knowledge graph; Update module, the smart contract receives the reasoning results and updates the knowledge graph of the field on the blockchain; The large language model generates logic rules by executing the prompt function, including the following steps: Establish basic instructions, which describe the logical relationship between the rule header and the rule body; the rule body represents a series of prerequisites that make the rule header valid; Construct prediction instructions to determine whether it is a zero-shot learning mode, and construct corresponding example contexts based on whether it is a zero-shot learning mode. In the zero-shot learning mode, provide a series of example contexts to guide the large language model to generate logical rules. In the non-zero-shot learning mode, use the provided rule samples as example contexts to guide the large language model to generate logical rules. Integrate basic instructions, sample context, and predicted instructions to generate a comprehensive prompt text; Generate logical rules under the guidance of prompt text; The final logic rules are screened out through the scoring mechanism, including the following steps: The support, coverage and confidence of the calculation rules are expressed as: Among them, sup(ρ) represents the support of rule v, cov(v) represents the coverage of rule ρ, and con(ρ) represents the confidence of rule ρ; : represents that the specific expression formula of the parameter on the left side of the symbol is the formula on the right side of the symbol; "=" represents the value calculated by the formula on the right side of the symbol; # represents a representation of the rule head; represents variables other than e and e'; (e,r1,e2)∧,…,∧(e L-1 ,r L ,e') represents a series of facts in the knowledge graph that satisfy the rule body(ρ), (e,r h ,e') indicates that the rule head r is satisfied h the fact that Assign different weights to support, coverage, and confidence and add them together to get a comprehensive score; Keep the rule that the comprehensive score is not lower than the preset score.
Citation Information
Patent Citations
Interpretable reasoning question-answering method and device
CN112597316A
Block chain cross-chain information interaction verification method and system based on knowledge graph
CN115659403A