Knowledge editing method, device, medium and electronic device based on knowledge graph
By collaborative editing between the knowledge graph and the language model, the problem of insufficient knowledge update and management efficiency in traditional technologies is solved, and the optimization and conflict reduction of knowledge representation are achieved.
Patent Information
- Application Number
- CN202411094137.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-08-09
AI Technical Summary
Traditional knowledge graphs and large language models have shortcomings in knowledge updates, precision handling, and prevention of knowledge conflicts and harmful knowledge attacks, and existing knowledge editing technologies have not fully resolved these problems.
By combining the knowledge graph with the language model, extracting the knowledge triplets corresponding to the pending statements, and performing checksum editing in the knowledge graph of the language model, the collaborative editing of symbolized knowledge and parameterized knowledge is realized, and knowledge management is improved efficiency and accuracy.
It effectively reduces the risks of knowledge conflicts and harmful knowledge attacks, improves the efficiency and accuracy of knowledge management, and realizes complementary and optimization of knowledge representation.
Smart Images

Figure CN118626660B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer and communication technology, and more specifically, to a knowledge editing method, device, medium and electronic device based on a knowledge graph. Background Art
[0002] In the field of artificial intelligence (AI), knowledge representation and management have always been the key to promoting technological development. Traditional knowledge graphs (KGs) provide highly accurate and clear knowledge representation methods through structured entities, relationships, and semantic descriptions. However, KGs face challenges in scalability and reasoning portability, especially when faced with large-scale and dynamically changing knowledge systems. On the other hand, large language models (LLMs), as representatives of neural networks, have accumulated rich "modal knowledge" through training on massive text data, forming a parametric representation of the world. However, although the knowledge representation form of LLMs is flexible and extensive, it has shortcomings in terms of real-time and accurate processing of knowledge updates, and prevention of knowledge conflicts and harmful knowledge attacks. In this context, although the knowledge editing technology proposed in related technologies has improved the efficiency of knowledge representation and management to a certain extent, it has not yet perfectly solved the above technical problems. Summary of the invention
[0003] The embodiments of the present application provide a knowledge editing method, device, medium and electronic device based on a knowledge graph, which realizes the collaborative editing of symbolic knowledge in the knowledge graph and parameterized knowledge of the language model, makes up for the shortcomings of a single knowledge representation form, and improves the efficiency and accuracy of knowledge management.
[0004] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0005] According to one aspect of an embodiment of the present application, a knowledge editing method based on a knowledge graph is provided, including: obtaining a sentence to be processed; extracting a knowledge triple corresponding to the sentence to be processed, the knowledge triple being used to represent entities and entity relationships contained in the sentence to be processed; verifying the knowledge triple in a knowledge graph corresponding to a language model to determine whether the knowledge triple conflicts with existing knowledge in the knowledge graph; and performing knowledge editing processing on the knowledge graph and the language model based on the verification result of the knowledge triple.
[0006] According to one aspect of an embodiment of the present application, a knowledge editing device based on a knowledge graph is provided, comprising: an acquisition unit, configured to acquire a sentence to be processed; an extraction unit, configured to extract a knowledge triple corresponding to the sentence to be processed, wherein the knowledge triple is used to represent entities and entity relationships contained in the sentence to be processed; a verification unit, configured to verify the knowledge triple in a knowledge graph corresponding to a language model to determine whether the knowledge triple conflicts with existing knowledge in the knowledge graph; and a processing unit, configured to perform knowledge editing processing on the knowledge graph and the language model according to the verification result of the knowledge triple.
[0007] In some embodiments of the present application, based on the aforementioned scheme, the knowledge editing device also includes: an identification unit configured to identify the intention of the statement to be processed; the extraction unit is configured to: if the intention of the statement to be processed is the knowledge editing intention, then execute the process of extracting the knowledge triples corresponding to the statement to be processed; the processing unit is also configured to: if the intention of the statement to be processed is the dialogue response intention, then the language model generates a response statement for the statement to be processed.
[0008] In some embodiments of the present application, based on the aforementioned scheme, the knowledge triple includes subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; wherein, the processing unit is configured as follows: if triple data containing subject data identical to the subject data in the knowledge triple and containing relationship data identical to the relationship data in the knowledge triple is not detected in the knowledge graph, then the knowledge triple is used to perform knowledge editing processing on the knowledge graph and the language model.
[0009] In some embodiments of the present application, based on the aforementioned scheme, the knowledge triple includes subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; wherein the processing unit is configured as follows: if a target triple data is detected in the knowledge graph, which contains subject data that is the same as the subject data in the knowledge triple, contains relationship data that is the same as the relationship data in the knowledge triple, but contains object data that is different from the object data in the knowledge triple, then the knowledge triple is used to overwrite the target triple data in the knowledge graph, and the editing parameters related to the target triple data in the language model are deleted; after deleting the editing parameters related to the target triple data in the language model, the knowledge triple is used to perform knowledge editing processing on the language model.
[0010] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is configured as follows: if triple data identical to the knowledge triple is detected in the knowledge graph, the process of using the knowledge triple to perform knowledge editing processing on the knowledge graph and the language model is skipped.
[0011] In some embodiments of the present application, based on the aforementioned scheme, the knowledge triple includes subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; the processing unit is also configured to: if the entity relationship represented by the relationship data in the knowledge triple is reversible, then generate reverse triple data for representing the reverse relationship between the subject data and the object data according to the knowledge triple; verify the reverse triple data as a new knowledge triple in the knowledge graph, and perform knowledge editing processing on the knowledge graph and the language model based on the verification result.
[0012] In some embodiments of the present application, based on the aforementioned scheme, the knowledge triples include subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; the processing unit is also configured to: after performing knowledge editing processing on the knowledge graph and the language model according to the knowledge triples, search for at least one node data with the subject data as the center from the knowledge graph; generate new knowledge triples based on the at least one node data obtained from the search, and use the new knowledge triples to perform knowledge editing processing on the language model.
[0013] In some embodiments of the present application, based on the aforementioned scheme, the knowledge editing device also includes: a storage unit, configured to store editing parameters corresponding to the language model after each knowledge editing process is performed on the language model, and the editing parameters are used to represent parameter information modified each time the knowledge editing process is performed on the language model.
[0014] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is further configured to: when it is necessary to roll back the knowledge editing operation of the language model using the specified triple data, obtain the target editing parameters stored in the knowledge editing process of the language model using the specified triple data; and roll back the knowledge editing operation of the language model based on the target editing parameters.
[0015] In some embodiments of the present application, based on the aforementioned solution, the processing unit is further configured to: if an abnormal editing process of the language model is identified, determine that the knowledge editing operation of the language model needs to be rolled back.
[0016] In some embodiments of the present application, based on the aforementioned solution, the storage unit is configured to: associate and store the editing parameters corresponding to the language model and the triple data used for knowledge editing processing of the language model.
[0017] In some embodiments of the present application, based on the aforementioned scheme, the processing unit is configured to: edit the symbolic knowledge in the knowledge graph and the parameterized knowledge in the language model according to the verification results of the knowledge triples, so that the symbolic knowledge in the knowledge graph matches the parameterized knowledge in the language model.
[0018] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the knowledge editing method based on the knowledge graph as described in the above embodiment is implemented.
[0019] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more computer programs, wherein when the one or more computer programs are executed by the one or more processors, the electronic device implements the knowledge editing method based on the knowledge graph as described in the above embodiments.
[0020] According to one aspect of an embodiment of the present application, a computer program product is provided, the computer program product including a computer program stored in a computer-readable storage medium. A processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device executes the knowledge graph-based knowledge editing method provided in the above various optional embodiments.
[0021] In the technical solutions provided in some embodiments of the present application, when a statement to be processed is obtained, the knowledge triples corresponding to the statement to be processed are extracted, and then the knowledge graph corresponding to the language model is verified based on the knowledge triples to determine whether the knowledge triples conflict with the existing knowledge in the knowledge graph, and then the knowledge graph and the language model are subjected to knowledge editing processing based on the verification results of the knowledge triples. It can be seen that the technical solutions of the embodiments of the present application can combine the knowledge graph and the language model for knowledge editing processing, and then the complementarity and optimization of knowledge representation can be achieved by integrating the symbolic knowledge of the knowledge graph and the parameterized knowledge of the language model, and the collaborative editing of the symbolic knowledge in the knowledge graph and the parameterized knowledge of the language model is achieved to make up for the shortcomings of a single knowledge representation form, improve the efficiency and accuracy of knowledge management, and at the same time, the verification of the knowledge graph can effectively reduce the risk of knowledge conflicts and harmful knowledge attacks.
[0022] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A schematic diagram of an exemplary system architecture to which the technical solution of the embodiments of the present application can be applied is shown.
[0024] Figure 2 A flowchart of a knowledge editing method based on a knowledge graph according to an embodiment of the present application is shown.
[0025] Figure 3 A schematic diagram of a platform for editing knowledge using natural language according to an embodiment of the present application is shown.
[0026] Figure 4 A schematic diagram of the structure of a knowledge editing platform according to an embodiment of the present application is shown.
[0027] Figure 5 A schematic diagram showing the relationship between the number of triplets and the accuracy of a single-hop metric according to an embodiment of the present application is shown.
[0028] Fig. 6A A schematic diagram of the processing flow of a knowledge editing platform according to an embodiment of the present application is shown.
[0029] Figure 6B A schematic diagram of the processing flow of a knowledge editing platform according to an embodiment of the present application is shown.
[0030] Figure 7 A block diagram of a knowledge editing device based on a knowledge graph according to an embodiment of the present application is shown.
[0031] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0032] The exemplary embodiments are now described in a more comprehensive manner with reference to the accompanying drawings. However, the exemplary embodiments can be implemented in various forms and should not be understood as being limited to these examples; on the contrary, the purpose of providing these embodiments is to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
[0033] In addition, the features, structures or characteristics described in the present application may be combined in one or more embodiments in any suitable manner. In the following description, there are many specific details so that the embodiments of the present application can be fully understood. However, those skilled in the art will appreciate that when implementing the technical scheme of the present application, all the detailed features in the embodiments may not be needed, one or more specific details may be omitted, or other methods, elements, devices, steps, etc. may be adopted.
[0034] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0035] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0036] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0037] It should be noted that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0038] It is understandable that this application can display a prompt interface or pop-up window before collecting relevant data (such as relevant data such as pending statements issued by users) and during the process of collecting relevant data. The prompt interface or pop-up window is used to prompt the user that its relevant data is currently being collected, so that this application only starts to execute the relevant steps of obtaining relevant data after obtaining the user's confirmation operation on the prompt interface or pop-up window, otherwise (that is, when the user's confirmation operation on the prompt interface or pop-up window is not obtained), the relevant steps of obtaining relevant data are terminated, that is, no relevant data is obtained. In other words, all data collected by this application are collected with the user's consent and authorization, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0039] The technical solution of the embodiment of the present application relates to the field of artificial intelligence technology. Since the birth of artificial intelligence, knowledge representation has always been its core goal. Over the years, researchers have been committed to various methods that enable machines to acquire knowledge, thereby supporting a wide range of task processing, such as information retrieval, question answering, dialogue, reasoning, information recommendation, and applications in specific fields. In other words, knowledge updating and management are important capabilities for machines to adapt to new environments and tasks, which enables machines to conduct continuous learning and improve the accuracy of machine processing.
[0040] In the early days, knowledge graphs, as a symbolic form of knowledge representation, attracted great interest in academia and industry. Specifically, knowledge graphs are semantic networks that reveal the relationships between entities and formally describe things in the real world and their relationships. Knowledge graphs can be used to refer to various large-scale knowledge bases. They have powerful semantic processing capabilities and open interconnection capabilities, and have shown great potential in natural language processing, artificial intelligence and other fields. Knowledge graphs provide a more effective way to express, organize, manage and utilize massive, heterogeneous and dynamic big data on the Internet, making the network more intelligent and closer to human cognitive thinking. To form high-quality knowledge, it is also necessary to evaluate the quality of knowledge graphs. The significance of this is to effectively ensure the quality of knowledge by quantifying the credibility of knowledge, retaining those with higher confidence and discarding those with lower confidence. However, knowledge graphs face challenges in scalability and portability of reasoning.
[0041] On the other hand, as a representative of neural networks, the Large Language Model (LLM) has accumulated rich "modal knowledge" through training on massive text data, forming a parameterized representation of the world. Based on the above assumptions, researchers have tried to generate knowledge in LLM and introduce knowledge editing to add, modify or delete parameterized knowledge to keep the knowledge representation in the model consistent with the latest world knowledge. However, LLM incurs huge training costs and has difficulties in precise knowledge processing. These limitations lead to a series of serious side effects, including decreased general ability, poor generalization ability, knowledge conflicts, and the risk of harmful knowledge attacks.
[0042] Therefore, a more effective knowledge editing solution is needed to provide more comprehensive, reliable and controllable guarantees for knowledge representation and management. It is based on these problems that the embodiment of the present application proposes a technical solution that combines the knowledge graph with the language model for knowledge editing processing, and then can achieve complementarity and optimization of knowledge representation by integrating the symbolic knowledge of the knowledge graph and the parameterized knowledge of the language model, and realize the collaborative editing of the symbolic knowledge in the knowledge graph and the parameterized knowledge of the language model to make up for the shortcomings of a single knowledge representation form, improve the efficiency and accuracy of knowledge management, and at the same time, through the verification of the knowledge graph, it can also effectively reduce the risk of knowledge conflicts and harmful knowledge attacks.
[0043] Specifically, if Figure 1 As shown, in a system architecture 100 applying the technical solution of the embodiment of the present application, a terminal device 110, a network 120 and a server 130 may be included. The terminal device 110 may include a smart phone, a tablet computer, a laptop computer, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc. The server 130 may be a server that provides various services, which may be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Among them, the network 120 may be a medium that provides a communication connection between the terminal device 110 and the server 130, such as a wired communication link or a wireless communication link.
[0044] According to implementation requirements, the system architecture in the embodiment of the present application may have any number of terminal devices 110, networks 120, and servers 130. For example, the server 130 may be a server group composed of multiple server devices.
[0045] In one embodiment of the present application, a user may use a terminal device 110 to send a statement to be processed to a server 130 via a network 120. The statement to be processed may be, for example, "Company X's headquarters is in Region A". After receiving the statement to be processed, the server 130 may extract the knowledge triple corresponding to the statement to be processed. The knowledge triple is used to represent the entities and entity relationships contained in the statement to be processed. For example, for the above example, the knowledge triple may be (Company X, headquarters, Region A). Then, the server 130 may verify the knowledge graph corresponding to the language model based on the extracted knowledge triple to determine whether the knowledge triple conflicts with the existing knowledge in the knowledge graph, and then perform knowledge editing processing on the knowledge graph and the language model based on the verification result of the knowledge triple.
[0046] Optionally, after receiving the sentence to be processed, the server 130 may first identify the intention of the sentence to be processed. If the intention of the sentence to be processed is the knowledge editing intention, then the knowledge triples may be extracted and the subsequent knowledge editing may be processed; if the intention of the sentence to be processed is the dialogue response intention, for example, the sentence to be processed is "What is the highest mountain in the world?", then the intention of the sentence is the dialogue response intention, and then the server 130 may generate a response statement for the sentence to be processed by the language model, and return the response statement to the terminal device 110 through the network 120.
[0047] The implementation details of the technical solution of the embodiment of the present application are described in detail below:
[0048] Figure 2 A flow chart of a knowledge editing method based on a knowledge graph according to an embodiment of the present application is shown. The knowledge editing method based on a knowledge graph can be executed by an electronic device, which can be a server. Figure 2 As shown, the knowledge graph-based knowledge editing method includes at least steps S210 to S240, which are described in detail as follows:
[0049] In step S210, a statement to be processed is obtained.
[0050] In some optional embodiments, the sentence to be processed may include only one sentence, or may include a paragraph consisting of multiple sentences, or even an article consisting of multiple paragraphs. The sentence to be processed may be obtained from the Internet, input by a local input device, or read from a memory. For example, the text to be processed may be automatically searched and captured from the Internet, or Figure 1 The data is input by the user through the terminal device and sent to the server.
[0051] In step S220, the knowledge triples corresponding to the sentence to be processed are extracted, and the knowledge triples are used to represent the entities and entity relationships contained in the sentence to be processed.
[0052] In some optional embodiments, the knowledge triple corresponding to the sentence to be processed may include subject data, relation data and object data, and the relation data is used to represent the relationship between the subject data and the object data. For example, if the sentence to be processed is "The person in charge of group A is Zhang San", then the knowledge triple extracted from the sentence to be processed may be (group A, person in charge, Zhang San); for another example, if the sentence to be processed is "Zhang San's wife is Wang Wu", then the knowledge triple extracted may be (Zhang San, wife, Wang Wu).
[0053] Optionally, a trained machine learning model can be used to extract knowledge triples corresponding to the sentence to be processed. For example, a trained machine learning model can be used to identify the entity data and relationship data contained in the sentence to be processed, and then generate knowledge triples based on the identified entity data and relationship data.
[0054] In some optional embodiments, before extracting the knowledge triples corresponding to the sentence to be processed, the intent of the sentence to be processed can also be identified. For example, the intent of the sentence to be processed can be identified through an intent recognition model. The principle of intent recognition (Intent Detection) is mainly implemented through machine learning or deep learning models. The intent recognition model learns a large amount of annotated text data, extracts features from the text, and builds a classifier that can recognize different intents. When the intent recognition model obtains the sentence to be processed, it analyzes the features in the sentence to be processed and matches them with the learned intent categories to identify the intent of the sentence to be processed.
[0055] Optionally, if it is identified that the intention of the sentence to be processed is the intention of knowledge editing, then the solution involved in the above embodiment for extracting the knowledge triples corresponding to the sentence to be processed can be performed. If it is identified that the intention of the sentence to be processed is the intention of dialogue response, then the language model can directly generate a response statement for the sentence to be processed without performing the knowledge editing process. The technical solution of this embodiment can not only optimize the intelligent level of natural language processing by identifying the intention of the sentence to be processed, but also improve the responsiveness to user needs and overall performance.
[0056] Specifically, by identifying the intent of the sentence to be processed, the processing logic of the sentence to be processed can be selected more intelligently. For example, for sentences with knowledge editing intent, the focus is on extracting knowledge triples and performing subsequent processing; while for sentences with dialogue response intent, the response sentence can be directly generated through the language model, avoiding unnecessary resource consumption and processing time, and improving the overall processing efficiency. At the same time, by identifying the intent of the sentence to be processed, user needs can be understood more accurately, thereby ensuring that user needs can be responded to quickly and appropriately.
[0057] In step S230, a check is performed in the knowledge graph corresponding to the language model based on the knowledge triple to determine whether the knowledge triple conflicts with existing knowledge in the knowledge graph.
[0058] In some optional embodiments, since the knowledge graph contains known knowledge data, before knowledge editing, the knowledge graph can be used to verify whether the extracted knowledge triples conflict with the existing knowledge.
[0059] For example, the knowledge triple extracted from the sentence to be processed is (Group A, Person in Charge, Zhang San). If the existing knowledge in the knowledge graph is (Group A, Person in Charge, Li Si), it means that the knowledge triple extracted from the sentence to be processed conflicts with the existing knowledge in the knowledge graph. In this case, new knowledge (that is, the knowledge triple extracted from the sentence to be processed) may be needed to cover the old knowledge in the knowledge graph.
[0060] If the existing knowledge in the knowledge graph is (Group A, Person in charge, Zhang San), then it means that the knowledge triples extracted from the sentence to be processed are repeated with the existing knowledge in the knowledge graph. In this case, there is no need to use the knowledge triples extracted from the sentence to be processed to perform knowledge editing on the knowledge graph and language model.
[0061] If there is no knowledge related to the person in charge of group A in the knowledge graph, it means that the knowledge triples extracted from the sentence to be processed are new knowledge for the existing knowledge in the knowledge graph. Then, the knowledge triples extracted from the sentence to be processed can be used to perform knowledge editing on the knowledge graph and language model.
[0062] The technical solution of this embodiment compares the knowledge triples extracted from the sentence to be processed with the existing knowledge in the knowledge graph, so that potential conflicts can be discovered and handled in a timely manner, thereby ensuring the accuracy and consistency of the data in the knowledge graph and effectively avoiding wrong decisions or misleading information due to inconsistent data.
[0063] In step S240, knowledge editing is performed on the knowledge graph and language model based on the verification results of the knowledge triples.
[0064] In some optional embodiments, when performing knowledge editing on the knowledge graph and the language model, the symbolic knowledge in the knowledge graph and the parameterized knowledge in the language model are mainly edited simultaneously, so that the symbolic knowledge in the knowledge graph matches the parameterized knowledge in the language model, that is, they are consistent with the data in the real world.
[0065] In some optional embodiments, if it is found based on the verification results of the knowledge triples that: no triple data is detected in the knowledge graph whose subject data is the same as the subject data in the knowledge triples and whose relationship data is the same as the relationship data in the knowledge triples, then it means that the knowledge triples extracted from the sentence to be processed are new knowledge for the existing knowledge in the knowledge graph, and then the knowledge triples can be used to perform knowledge editing on the knowledge graph and the language model. The technical solution of this embodiment can enrich and expand the coverage and content depth of the knowledge graph by adding the newly extracted knowledge triples as new knowledge to the knowledge graph when there are no newly extracted knowledge triples in the knowledge graph, which helps to improve the practical value and application scope of the knowledge graph, and then after the language model is knowledge edited through the knowledge graph, the integrity and comprehensiveness of the content generated by the language model can be improved, which is conducive to improving the performance of the language model.
[0066] In some optional embodiments, if it is found according to the verification result of the knowledge triples: the subject data contained in the knowledge graph is the same as the subject data in the knowledge triples, the relationship data contained is the same as the relationship data in the knowledge triples, but the target triples contained are different from the object data in the knowledge triples, then it means that the knowledge triples extracted from the sentence to be processed conflict with the existing knowledge in the knowledge graph, and then the target triples in the knowledge graph can be covered with the knowledge triples, and the editing parameters related to the target triples in the language model can be deleted. At the same time, after deleting the editing parameters related to the target triples in the language model, the knowledge triples are used to perform knowledge editing on the language model. In this embodiment, the editing parameters can be used to represent the parameter information modified by each knowledge editing process on the language model, and then the rollback process of the language model can be conveniently realized by editing the parameters, and the old knowledge in the language model that conflicts with the knowledge triples can also be avoided to affect the expression of the knowledge by the language model. The technical solution of this embodiment, when it is found that the newly extracted knowledge triples conflict with the old knowledge in the knowledge graph, uses the processing method of overwriting the old knowledge with the new knowledge, so that the knowledge can be dynamically updated and optimized, and the accuracy of the content generated by the language model can be avoided from being affected by the existence of the old knowledge. After deleting the editing parameters related to the target triple data in the language model, the knowledge triples are used to perform knowledge editing processing on the language model, so that the rollback processing of the language model can be conveniently implemented based on the editing parameters, thereby improving the knowledge editing efficiency of the language model without affecting the performance of the language model.
[0067] Optionally, in an embodiment of the present application, the editing parameters corresponding to the language model can be stored after each knowledge editing process is performed on the language model. Furthermore, when it is necessary to roll back the knowledge editing operation of the language model using the specified triple data, the target editing parameters stored when the knowledge editing operation of the language model using the specified triple data is performed can be obtained, so as to roll back the knowledge editing operation of the language model based on the target editing parameters. The technical solution of this embodiment can retain historical editing records and construct a complete editing history line by storing the editing parameters each time the knowledge editing process is performed on the language model, so as to quickly locate and obtain the relevant editing parameters when necessary, so as to accurately and conveniently trace back to a specific state based on the acquired editing parameters, thereby improving the flexibility and controllability when facing complex editing requirements, ensuring the accuracy and predictability of the editing operation, and simplifying the process of error repair and version control, thereby improving the processing efficiency of the language model.
[0068] Optionally, in order to facilitate the search for editing parameters generated by each triple data's knowledge editing operation on the language model, the editing parameters generated when the language model is knowledge edited and the triple data used for the knowledge editing process on the language model may be stored in association.
[0069] In some optional embodiments, during the process of knowledge editing of the language model, it is possible to identify whether there is an abnormal editing process (such as malicious editing). If an abnormal editing process of the language model is identified, the abnormal editing operation of the language model can be rolled back by editing parameters.
[0070] In some optional embodiments, if it is found based on the verification results of the knowledge triples that: the same triple data as the knowledge triples are detected in the knowledge graph, then it means that the knowledge triples extracted from the sentence to be processed are repeated with the existing knowledge in the knowledge graph, and the process of using the knowledge triples to perform knowledge editing processing on the knowledge graph and language model can be skipped, that is, there is no need to use the knowledge triples extracted from the sentence to be processed to perform knowledge editing processing on the knowledge graph and language model. The technical solution of this embodiment avoids unnecessary repeated additions to the duplicate knowledge that already exists in the knowledge graph, maintains the simplicity of the knowledge graph, and also avoids unnecessary calculations and resource consumption caused by processing duplicate knowledge, thereby improving overall processing efficiency.
[0071] In some optional embodiments, if the entity relationship represented by the relational data in the knowledge triples extracted from the to-be-processed sentences is reversible, then the reverse triple data for representing the reverse relationship between the subject data and the object data can be generated based on the knowledge triples, and then the reverse triple data is used as a new knowledge triple for verification in the knowledge graph, and the knowledge graph and the language model are subjected to knowledge editing processing based on the verification results. The technical solution of this embodiment automatically generates reverse triple data, so that the reverse relationship information that may be missing in the knowledge graph can be automatically detected and supplemented, which not only improves work efficiency, but also enhances the integrity and accuracy of the knowledge graph, making the relationship expression in the graph more comprehensive and detailed. At the same time, knowledge editing processing based on reverse triple data enables the language model to grasp the relationship between entities more comprehensively, and then can be more accurate and rich in understanding and generating natural language, thereby improving the authenticity and credibility of the generated content.
[0072] For example, if the sentence to be processed is "Zhang San's wife is Wang Wu", then the extracted knowledge triplet can be (Zhang San, wife, Wang Wu). Since "wife" and "husband" have an inverse relationship, reverse triplet data can be generated, that is, (Wang Wu, husband, Zhang San). This method can link the knowledge in the knowledge base (such as the knowledge graph), which not only expands the knowledge base, but also can use the above-mentioned verification scheme to realize the verification processing of the reverse triplet data.
[0073] In some optional embodiments, after the knowledge graph and language model are edited according to the knowledge triples, at least one node data with the subject data as the center can be searched from the knowledge graph, and then a new knowledge triple is generated according to the at least one node data obtained by the search, and the new knowledge triple is used to edit the language model. The technical solution of this embodiment searches and generates new knowledge triples around the subject data, so that more detailed information and associations about the subject data can be obtained, so that the language model can more accurately reflect the characteristics and context of the subject when generating text or performing semantic analysis, and improve the richness and accuracy of the generated content. At the same time, the process of searching and generating new knowledge triples actually establishes and strengthens the connection between different nodes in the knowledge graph, which not only enriches the structure of the knowledge graph, but also improves the connectivity of the knowledge graph, so that the information between different entities in the knowledge graph can be circulated and shared more smoothly, and the availability of the knowledge graph is enhanced. The language model can also be edited based on a wider and deeper knowledge triple, which provides more possibilities and flexibility for subsequent reasoning and application, and helps to improve the generalization ability of the model.
[0074] For example, if the sentence to be processed is "Zhang San is the boss of Company A", then the extracted knowledge triple may be (Zhang San, Company A, boss), where the main data is "Zhang San". Then, at least one node data can be searched in the knowledge graph with "Zhang San" as the center, such as (Zhang San, wife, Wang Wu). Then, new knowledge triples can be generated, such as (Wang Wu, Company A, boss's wife). In this way, more new knowledge triples can be obtained to perform knowledge editing processing on the knowledge graph and language model.
[0075] It can be seen that the technical solution of the embodiment of the present application can combine the knowledge graph with the language model for knowledge editing, and then can realize the complementarity and optimization of knowledge representation by integrating the symbolic knowledge of the knowledge graph and the parameterized knowledge of the language model, and realize the collaborative editing of the symbolic knowledge in the knowledge graph and the parameterized knowledge of the language model. Figures 3 to 6B , taking the language model as LLM as an example, the implementation details of the technical solution of the embodiment of the present application are elaborated in detail:
[0076] First refer to Figure 3 As shown, the technical solution of the embodiment of the present application can provide a platform for knowledge editing using natural language. The platform can provide an interface for natural language interaction with users. After receiving the user's natural language, it determines whether the knowledge graph and the large language model need to be processed for knowledge editing by understanding the user's intention. If it is necessary to perform knowledge editing on the knowledge graph and the large language model, the conflict problem can be resolved by extracting knowledge triples from the natural language, and then using the knowledge graph to resolve the conflict, and knowledge can be added, and then the knowledge graph and the large language model can be edited by the extracted knowledge triples and the added knowledge. Optionally, the entire system platform can adopt a modular design to support and customize multi-purpose knowledge graphs and various large language models.
[0077] In one embodiment of the present application, Figure 4 As shown, the knowledge editing platform in the embodiment of the present application may include three main components: an interpreter, a controller, and an editor. As an interface for interacting with the user, the interpreter is responsible for receiving the user's natural language and understanding the user's intention. The controller manages editing requests from different users, uses KG to resolve conflict problems, and can add knowledge, and then pass the relevant knowledge to the editor. The editor mainly uses the knowledge triples from the controller to edit KG and LLM.
[0078] The following first introduces the knowledge editing process of LLM, and then describes in detail the technical details of each major component included in the knowledge editing platform in the embodiment of the present application.
[0079] In the embodiments of the present application, knowledge editing aims to enable LLM to be modified quickly and accurately, thereby producing more accurate and relevant outputs. Formally speaking, the purpose of knowledge editing of LLM can be expressed as the following formula (1):
[0080] Formula (1)
[0081] In the above formula (1), represents the original model, i.e. the model before editing; k Indicates knowledge that needs to be changed; E represents the knowledge editing function; represents the edited model; k' Representation and Knowledge k Other irrelevant knowledge. The above formula (1) indicates that based on the original model and knowledge that needs to change k , through the knowledge editing function E , you can get the edited model , the model Should cover previous knowledge k false memory, i.e. At the same time, for any not equivalent to knowledge k Other knowledge k' , there should be no impact before and after model editing, i.e. In other words, knowledge editing hopes to be able to accurately and universally operate the knowledge that needs to be modified in the LLM without affecting irrelevant knowledge.
[0082] In the embodiments of the present application, the symbolic knowledge in the knowledge graph KG and the parametric knowledge (or neural knowledge) in the LLM can be updated simultaneously, such as neural-symbolic knowledge editing, thereby allowing different types of knowledge to complement each other and compensate for the challenges brought by parametric knowledge editing. Formally, KG can be represented as ,in, Represents a collection of subject data. Represents a collection of relation type data (relationtype), Represents a collection of object data. Each knowledge triple in t You can use ( s, r, o ) in the form of s ∈ , r ∈ , o ∈ .
[0083] For neural-symbolic knowledge editing, the knowledge to be edited can be defined as k = ( p , y ),in p It is a hint to express knowledge. y is the desired goal. Formally speaking, the task of the knowledge editing platform in the embodiment of the present application can be defined as shown in the following formula (2):
[0084] Formula (2)
[0085] In formula (2), and Respectively represent LLM and KG before editing; function I (·) represents the interpreter, which is responsible for converting knowledge sentences k Convert to knowledge triples; function C (·) represents a series of edit triples derived by the controller based on the knowledge graph KG and rollback triples , to solve the problem of knowledge conflict. In addition, the controller can also generate some knowledge, called enhanced triples , in order to enhance the knowledge of the editor and prevent the knowledge distortion caused by knowledge editing. , and Afterwards, they can be used to edit and modify LLM and KG, which can be specifically expressed as shown in the following formula (3) to ensure that the parameterized knowledge of LLM and the symbolic knowledge of KG are consistent with the knowledge in the real world:
[0086] Formula (3)
[0087] In formula (3), Indicates the edited LLM; represents the edited KG; E Represents the knowledge editing function.
[0088] In one embodiment of the present application, referring to Figure 4 As shown, the interpreter acts as an interface between the user and the controller and is responsible for receiving the user's natural language (e.g. Figure 4 The interpreter can extract knowledge triples suitable for the knowledge graph from the natural language input by the user and send them to the controller. If the user's intention is to answer, the interpreter can pass the natural language input by the user to the large language model to generate a response sentence.
[0089] In some optional embodiments, instructions on MiniCPM-2B (a language model) can be fine-tuned to enable it to serve as an interpreter that distinguishes between editing intent and answering intent. Unlike traditional information extraction tasks that are only used to extract knowledge triples, the interpreter in the embodiment of the present application is not only used to extract triples, but also to identify user intent. To this end, the vocabulary size of the MiniCPM-2B model can be expanded, and two special tags can be added <edit>and <generate>, to enhance the model's ability to identify intent, where the label <edit>Used to indicate editorial intent; mark <generate>It is used to indicate the intention of answering. It can be specifically expressed by the following formula (4):
[0090] Formula (4)
[0091] In formula (4), if it is editing intention, then the output can be <edit>( s , r , o ); if it is a response intention, then you can output <generate> S .
[0092] Optionally, the model can be fine-tuned on the Alpaca dataset (an open source, large-scale text dataset) to enhance its ability to identify generative intent. At the same time, in order to identify editorial intent, the model can also be trained using data generated by other machine learning models (such as GPT-4).
[0093] In a specific example, if the user inputs the natural language "change the headquarters of X company to region A", the interpreter recognizes that the user intends to edit, and then outputs the editing command <edit>(Company X, Headquarters, Region A), and forwards it to the controller. On the contrary, if the user inputs the natural language "What is the highest mountain in the world?", the interpreter recognizes that the user intends to answer, then the interpreter outputs "generate" and directly prompts the large language model to provide an answer.
[0094] In one embodiment of the present application, referring to Figure 4 As shown, the input received in the controller is a knowledge triple, and the controller can use a KG as a knowledge base to judge and resolve conflicts between input knowledge and model knowledge. After resolving the conflict, the KG can be used to expand the edited knowledge in the LLM parameters.
[0095] Among them, the conflict between input knowledge and model knowledge can be divided into two types: coverage conflict and reverse conflict, which is the most common situation in knowledge base management.
[0096] It should be noted that coverage conflict means that factual knowledge will develop dynamically with the changes in the real world. If the original old knowledge is not covered, multiple versions of the same knowledge will appear. For example, the answer to "Who is the company with the highest market value in the world?" may vary greatly in the short term. In order to maintain consistency with the evolving real-world knowledge, the model needs to be covered and edited multiple times. Specifically, this situation can be formalized as a pair of continuous editing processes containing the same subject data and relationship data, as shown in formula (5):
[0097] Formula (5)
[0098] In formula (5), in the first edit (i.e. E 1), using knowledge triples ( s , r , o 1) Covering knowledge triples ( s , r , o ); in the second edit (i.e. E 2), using knowledge triples ( s , r , o 2) Covering knowledge triples ( s , r , o 1).
[0099] However, relevant studies have shown that when model parameters are modified, the basic performance of the model will inevitably degrade as the number of edits increases. In addition, most current knowledge editing methods, such as FT, ROME, and MEMIT, leave residual knowledge from previous edits when repeatedly modifying the same knowledge. This causes the model's parameters to store multiple conflicting versions of the knowledge, ultimately leading to knowledge distortion and affecting the model's representation of that knowledge.
[0100] In order to solve this problem, the concept of edit rollback is provided in the embodiment of the present application. When a user performs knowledge editing on the LLM, the controller will s , r , o ) is put into KG for evaluation. If there is no ( s , r , o' ), then ( s , r , o ) is written into KG, and the corresponding knowledge editing process is continued on LLM, and the corresponding editing parameters are stored in the editing buffer (for details, please refer to the following embodiment of the editor); if KG already exists ( s , r , o ), no action will be taken on LLM, that is, the knowledge editing process is skipped; if there is ( s , r , o' ), then search for s , r , o' ) and then delete the previous edits in LLM, rolling back the edits associated with ( s , r , o' ) related edits and re-edited to ( s , r , o ), and update KG accordingly. The rollback operation of LLM can be expressed by the following formula (6):
[0101] Formula (6)
[0102] In formula (6), Indicates the edited LLM; E represents the knowledge editing function; It means LLM before editing; θ i Indicates the use of i The editing parameters stored by the knowledge triples for knowledge editing of LLM; θ k Indicates the use of k The editing parameters stored by the knowledge triplet for the LLM knowledge editing, that is, the editing parameters corresponding to the editing that needs to be rolled back; n Indicates the number of knowledge triples used for knowledge editing of LLM.
[0103] Furthermore, in the context of crowdsourced editing, if the LLM model is maliciously edited to produce harmful content, the embodiments of the present application can identify and roll back these specific edits. s , r , o ) performs an edit once and completely eliminates previous edits, effectively reducing performance loss in the model.
[0104] In one embodiment of the present application, if people know that the headquarters of Company X is not in Region B, then they will naturally understand that the headquarters of Company X is in Region A, but the existing LLM does not perform well in this regard, and this phenomenon can be called the "reverse curse". The reverse curse also exists in knowledge editing. For example, when editing the knowledge in the LLM and overwriting old information with new information, such as overwriting "Li Si is the head of Group A" with "Zhang San is the head of Group A", the model may correctly answer that Zhang San is the current head of Group A. However, when asked "Who is the head of Group A?", the model may still respond with outdated knowledge, saying "Li Si is the head of Group A." This shows that the model has not completely erased the old knowledge, resulting in a reverse conflict.
[0105] In addition, consider a more complex example: if you edit the fact that Zhang San's wife is Wang Wu, and then edit the fact that Wang Wu's husband is Ding Er, the traditional knowledge base may treat the facts (Zhang San, wife, Wang Wu) and (Wang Wu, husband, Ding Er) as isolated pieces of knowledge. This approach ignores the inherent connection between these facts, especially the inverse relationship that "wife" is "husband". This situation can also lead to more complex forms of reverse conflicts. Therefore, it is difficult for traditional knowledge editing methods to discover such fact conflicts, and this situation is classified as a reverse conflict in the embodiments of the present application.
[0106] In order to solve the problem of reverse conflict, the embodiment of the present application can use the knowledge graph to solve it. Specifically, in the process of knowledge editing, the relational database is first queried. If the relationship in the knowledge triple is reversible, the reverse relationship knowledge (or reverse relationship knowledge) can be constructed, and both the original knowledge and the reverse relationship knowledge are inserted into the KG to check for conflicts. If no conflict is detected, the original knowledge and the reverse relationship knowledge are used to perform knowledge editing on the LLM model.
[0107] The process of inserting both the original knowledge and the reverse relationship knowledge into KG to resolve the reverse conflict can be expressed by the following formula (7):
[0108] Formula (7)
[0109] In formula (7), in the first edit (i.e. E 1), using knowledge triples ( s , r , o 1) Covering knowledge triples ( s , r , o ); and can increase the reverse relationship knowledge triples ( o 1, r r , s ),in r r express r The inverse relationship; if there is o 1 and r r The same knowledge can then be used in the second edit (i.e. E 2), using knowledge triples ( o 1, r r , s 2) Covering knowledge triples ( o 1, r r , s ).
[0110] In a specific example, for example, "Zhang San's wife is Wang Wu", the triple of the original knowledge can be (Zhang San, wife, Wang Wu). Since "wife" and "husband" have an inverse relationship, a triple of inverse relationship knowledge can be generated, namely (Wang Wu, husband, Zhang San). If there is a new knowledge (Wang Wu, husband, Ding Er), a conflict check will be performed in the KG.
[0111] The technical solution of the above embodiment of the present application allows to seamlessly solve the problem of inversion curse by merging the original knowledge and the reverse relationship knowledge into the model at the same time during the editing process. In addition, any hidden knowledge conflicts or inconsistencies in the LLM can also be detected.
[0112] In some optional embodiments, editing a piece of knowledge may cause knowledge distortion of related parameterized knowledge in the language model. For example, after using "Zhang San is the boss of X Company" to cover the knowledge "Li Si is the boss of X Company", when asked about the boss's wife of X Company, the model may still answer "The boss's wife of X Company is Zhao Liu" (Zhao Liu is Li Si's wife). Therefore, the embodiment of the present application proposes to enhance the edited knowledge to maintain the original knowledge structure in the model to solve such problems. Specifically, the knowledge graph can be used to search for n nodes centered on the editing subject, and these nodes can be used to generate enhanced triples. , which is then passed to the editor.
[0113] In one embodiment of the present application, even when performing knowledge editing on the 7B model (an artificial intelligence model), the current major editing methods such as ROME, MEND, and GRACE require at least 30GB of video random access memory (VRAM) and considerable editing time. In contrast, the memory overhead of storing model parameters after each edit is negligible. Based on this reality, the embodiment of the present application proposes an editing strategy of exchanging space for time, that is, storing editing parameters after each knowledge edit. Then, the editing parameters can be used for subsequent editing or rollback, thereby significantly reducing VRAM and time overhead. Among them, the rollback operation on the model can be expressed by the following formula (8):
[0114] Formula (8)
[0115] In formula (8), Indicates the edited LLM; It means LLM before editing; θ i Indicates the use of i The editing parameters stored by the knowledge triples for knowledge editing of LLM; θ j Indicates the use of j The editing parameters stored by the knowledge triplet for the LLM knowledge editing, that is, the editing parameters corresponding to the editing that needs to be rolled back; m and n They respectively represent the number of knowledge triples used for knowledge editing of LLM.
[0116] In some optional embodiments, the editor can be divided into two parts: an editor and an editor cache. In the editor part, EasyEdit can be used, which provides a rich set of knowledge editing methods, supports multiple models, and meets the needs of knowledge editing. In the editor cache part, the editor cache can be integrated into EasyEdit. During each edit, a unique edit keyword is generated based on the knowledge and its corresponding editing parameters. Specifically, when using a method such as ROME that directly modifies model parameters, the parameters before editing and the difference after editing can be stored as editing parameters. For adapter-based methods such as GRACE, the hidden state after each edit can be recorded as editing parameters. If the rollback mentioned in the aforementioned embodiment occurs, the editing parameters stored in the cache can be used directly to quickly apply edits or rollbacks by increasing or decreasing them. This method can reduce VRAM and time overhead.
[0117] When verifying the effect of the knowledge editing platform mentioned in the embodiments of this application, GPT2-XL and GPT-j-6B can be selected as the base models. GPT2-XL is a 1.5B parameter version of GPT-2, and GPT-j-6B is a transformer-based language model created and released by OpenAI. Both models are pre-trained on the English language using the causal language modeling (CLM) objective. The baseline includes methods for continuous learning and model editing, and the knowledge editing platform in this application is compared with direct fine-tuning (FT) as well as ROME, MEMIT, and GRACE models.
[0118] Optionally, in order to evaluate the effectiveness of the editing method, three aspects of indicators can be mainly considered: reliability, locality, and portability.
[0119] Among them, reliability refers to the Prompt information for knowledge p Provide edited target answer y ', it means that the editing is successful, that is, reliability refers to the average accuracy of the edited cases. Locality (also known as specificity) means that the editing should be achieved locally, which means that the model after editing Out-of-scope collections should not be mutated O ( p , y ), so locality is achieved through the edited model Prediction and pre-editing model The transferability is evaluated by comparing the probability of remaining unchanged. The transferability is divided into three parts: subject replacement, single jump and reverse. Transferability is used to comprehensively measure the effectiveness of model editing in transferring knowledge to related content, which can be called robust generalization ability. Transferability refers to the ability to transfer the edited model to related content. Application P ( p ,y) during inference.
[0120] Since the experiments in the embodiments of the present application need to combine the knowledge editing dataset with the knowledge graph, a specific field can be selected to demonstrate the feasibility of the knowledge editing platform in the embodiments of the present application, and an experimental dataset can be constructed based on Wikidata, zsRE and GPT-4. Specifically, 200 relevant entities can be extracted from the network, relevant data can be filtered from the zsRE dataset based on these entities, and prompt information can be written using GPT-4 to expand these data into the available editing dataset. Finally, these entities are used to build a knowledge graph, and their adjacent nodes are expanded using Wikidata to obtain a knowledge graph containing more than 400 entities as an external knowledge base for the model. Since the dataset constructed in this application mainly evaluates changes in portability indicators, corresponding reverse, single-hop and subject replacement tests can be designed for each type of data.
[0121] The main experimental conclusions in the single-user knowledge editing scenario are shown in Table 1. Referring to the data in Table 1, it can be seen that the performance of the knowledge editing platform in the embodiment of the present application in terms of reliability is comparable to other advanced methods. In terms of locality, the knowledge editing platform in the embodiment of the present application has been significantly improved over methods such as ROME and FT that directly modify model parameters. Its performance is similar to GRACE (GRACE is a method known for its high locality in model editing). This may be because the knowledge editing platform in the embodiment of the present application, like GRACE, does not change the parameters of the model, thereby maintaining the performance of the original model on irrelevant queries. In terms of portability, the knowledge editing platform in the embodiment of the present application exceeds our baseline in all three sub-indicators. For reverse metrics, the model's understanding of the original knowledge is enhanced by merging automatically constructed reverse relationship knowledge edits. In single-hop metrics, the knowledge editing platform in the embodiment of the present application also shows significant advantages, enhancing the model's understanding of multi-hop knowledge by directly writing multi-hop knowledge into model parameters with KG constraints.
[0122] Table 1
[0123]
[0124] The multi-user knowledge editing scenario simulates a scenario in which multiple users collaborate to update a model. To achieve this, a sequential editing setting is used in the embodiments of the present application to simulate the process of multiple users updating the model. Specifically, consider how to resolve conflicts when multiple users sequentially edit the same knowledge and obtain different results. The experiments in this application focus on scenarios with two and three users because these situations are most common in real-world applications. As shown in Table 2, the results of FT and ROME on locality decrease as the number of users increases. This is due to the limitations of the method that needs to modify model parameters in sequential editing scenarios. Each edit introduces limited information and significantly changes the model parameters, which inevitably leads to a decrease in the basic performance of the model.
[0125] Table 2
[0126]
[0127] The most important parameter that the knowledge editing platform in the embodiment of the present application relies on is the number of triples passed from the controller to the editor. Figure 5 As shown in Figure 1, in the actual test process, the accuracy change diagram of the single-hop metric is drawn by changing the number of triplets. Figure 5 It can be observed that when the number of triples is small, the accuracy of the single-hop metric is almost zero. This phenomenon occurs because the knowledge editing platform in the embodiment of the present application adopts the nearest neighbor strategy, which causes the single-hop knowledge to be used in the later stage of generating triples. As the number of triples increases, the accuracy of the single-hop metric increases, indicating that the generalized knowledge from the KG has been successfully integrated into the model. However, once the number of triples reaches a certain threshold, the accuracy no longer increases. If it is assumed that this is a performance bottleneck caused by the coverage of the knowledge in the KG and the extraction ability of the interpreter, then the effectiveness of the knowledge editing platform in the embodiment of the present application is mainly limited by the extraction performance of the interpreter and the coverage of the KG. When the KG does not cover the relevant knowledge for portability, or when the interpreter incorrectly extracts the knowledge triples, the performance of the knowledge editing platform in the embodiment of the present application will decrease. Therefore, in the embodiment of the present application, the coverage of the KG can be expanded as much as possible through the knowledge of the relevant fields, and the ability of the interpreter to extract triple data can be enhanced by obtaining more training data, so that the performance of the knowledge editing platform in the embodiment of the present application can be improved as much as possible.
[0128] In a specific example of this application, Fig. 6A As shown in the figure, if Zhang San was the head of group A in the previous year, and Li Si is the head of group A in the current year, then in the controller, the knowledge parameter representing "Zhang San is the head of group A" needs to be deleted and updated with the new information "The head of group A is Li Si". However, if Zhang San is the head of group A again in the next year, the knowledge of "Zhang San is the head of group A" can be directly restored to the model. This approach reduces the number of edits required for the model and maintains the baseline performance.
[0129] In another specific example of the present application, Figure 6B As shown, Zhang San's wife is Wang Wu. After Zhang San and Wang Wu divorced, Wang Wu married Ding Er. If the model is only edited to reflect "Wang Wu's husband is Ding Er", it will lead to conflicts such as "Wang Wu's husband is Ding Er" and "Zhang San's wife is Wang Wu". However, based on the technical solution of the embodiment of the present application, the controller module will automatically construct a reverse relationship for such reversible scenarios, that is, construct the knowledge "Wang Wu's husband is Zhang San". When "Wang Wu's husband is Ding Er" appears again, it conflicts with the relationship "Wang Wu's husband is Zhang San" automatically constructed in the controller, which will prompt the model to roll back the invalid knowledge and correctly update the new knowledge.
[0130] The technical solutions of the above-mentioned embodiments of the present application can combine the knowledge graph and the language model to perform knowledge editing processing, and further can realize the complementarity and optimization of knowledge representation by integrating the symbolic knowledge of the knowledge graph and the parameterized knowledge of the language model, thereby realizing the collaborative editing of the symbolic knowledge in the knowledge graph and the parameterized knowledge of the language model to make up for the shortcomings of a single knowledge representation form, improve the efficiency and accuracy of knowledge management, and at the same time, through the verification of the knowledge graph, it can also effectively reduce the risks of knowledge conflicts and harmful knowledge attacks.
[0131] The following describes an embodiment of the device of the present application, which can be used to execute the knowledge editing method based on the knowledge graph in the above embodiment of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the knowledge editing method based on the knowledge graph in the above embodiment of the present application.
[0132] Figure 7 A block diagram of a knowledge editing device based on a knowledge graph according to an embodiment of the present application is shown, and the device can be applied to electronic devices such as servers, etc.
[0133] Reference Figure 7 As shown, a knowledge graph-based knowledge editing device 700 according to an embodiment of the present application includes: an acquisition unit 702, an extraction unit 704, a verification unit 706 and a processing unit 708.
[0134] Among them, the acquisition unit 702 is configured to acquire the sentence to be processed; the extraction unit 704 is configured to extract the knowledge triples corresponding to the sentence to be processed, and the knowledge triples are used to represent the entities and entity relationships contained in the sentence to be processed; the verification unit 706 is configured to verify the knowledge triples in the knowledge graph corresponding to the language model to determine whether the knowledge triples conflict with the existing knowledge in the knowledge graph; the processing unit 708 is configured to perform knowledge editing processing on the knowledge graph and the language model according to the verification results of the knowledge triples.
[0135] In some embodiments of the present application, based on the aforementioned solution, the knowledge editing device 700 further includes: an identification unit configured to identify the intention of the sentence to be processed;
[0136] The extraction unit 704 is configured to: if the consciousness of the sentence to be processed is the knowledge editing intention, execute the process of extracting the knowledge triple corresponding to the sentence to be processed;
[0137] The processing unit 708 is further configured to: if the intention of the statement to be processed is a dialogue response intention, generate a response statement for the statement to be processed by the language model.
[0138] In some embodiments of the present application, based on the aforementioned scheme, the knowledge triple includes subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; wherein, the processing unit 708 is configured as follows: if triple data containing subject data identical to the subject data in the knowledge triple and containing relationship data identical to the relationship data in the knowledge triple is not detected in the knowledge graph, then the knowledge triple is used to perform knowledge editing processing on the knowledge graph and the language model.
[0139] In some embodiments of the present application, based on the aforementioned scheme, the knowledge triple includes subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; wherein the processing unit 708 is configured as follows: if a target triple data is detected in the knowledge graph, which contains subject data that is the same as the subject data in the knowledge triple, contains relationship data that is the same as the relationship data in the knowledge triple, but contains object data that is different from the object data in the knowledge triple, then the knowledge triple is used to overwrite the target triple data in the knowledge graph, and the editing parameters related to the target triple data in the language model are deleted; after deleting the editing parameters related to the target triple data in the language model, the knowledge triple is used to perform knowledge editing processing on the language model.
[0140] In some embodiments of the present application, based on the aforementioned scheme, the processing unit 708 is configured as follows: if triple data identical to the knowledge triple is detected in the knowledge graph, the process of using the knowledge triple to perform knowledge editing processing on the knowledge graph and the language model is skipped.
[0141] In some embodiments of the present application, based on the aforementioned scheme, the knowledge triple includes subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; the processing unit 708 is also configured to: if the entity relationship represented by the relationship data in the knowledge triple is reversible, then generate reverse triple data for representing the reverse relationship between the subject data and the object data according to the knowledge triple; verify the reverse triple data as a new knowledge triple in the knowledge graph, and perform knowledge editing processing on the knowledge graph and the language model based on the verification result.
[0142] In some embodiments of the present application, based on the aforementioned scheme, the knowledge triples include subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; the processing unit 708 is also configured to: after performing knowledge editing processing on the knowledge graph and the language model according to the knowledge triples, search for at least one node data with the subject data as the center from the knowledge graph; generate new knowledge triples based on the at least one node data obtained from the search, and use the new knowledge triples to perform knowledge editing processing on the language model.
[0143] In some embodiments of the present application, based on the aforementioned scheme, the knowledge editing device also includes: a storage unit, configured to store editing parameters corresponding to the language model after each knowledge editing process is performed on the language model, and the editing parameters are used to represent parameter information modified each time the knowledge editing process is performed on the language model.
[0144] In some embodiments of the present application, based on the aforementioned scheme, the processing unit 708 is further configured to: when it is necessary to roll back the knowledge editing operation of the language model using the specified triple data, obtain the target editing parameters stored in the knowledge editing process of the language model using the specified triple data; and roll back the knowledge editing operation of the language model based on the target editing parameters.
[0145] In some embodiments of the present application, based on the aforementioned solution, the processing unit 708 is further configured to: if an abnormal editing process of the language model is identified, determine that the knowledge editing operation of the language model needs to be rolled back.
[0146] In some embodiments of the present application, based on the aforementioned solution, the storage unit is configured to: associate and store the editing parameters corresponding to the language model and the triple data used for knowledge editing processing of the language model.
[0147] In some embodiments of the present application, based on the aforementioned scheme, the processing unit 708 is configured to: edit the symbolic knowledge in the knowledge graph and the parameterized knowledge in the language model according to the verification results of the knowledge triples, so that the symbolic knowledge in the knowledge graph matches the parameterized knowledge in the language model.
[0148] Figure 8 A schematic diagram of the structure of a computer system of an electronic device suitable for implementing an embodiment of the present application is shown, and the electronic device may be the server in the aforementioned embodiment.
[0149] It should be noted that Figure 8 The computer system 800 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0150] like Figure 8 As shown, the computer system 800 may include a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the storage part 808 to the random access memory (RAM) 803, such as executing the method described in the above embodiment. In the RAM 803, various programs and data required for system operation are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other through the bus 804. The input / output (I / O) interface 805 is also connected to the bus 804.
[0151] The following components can be connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed so that a computer program read therefrom is installed into the storage section 808 as needed.
[0152] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program is used to perform the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 809, and / or installed from a removable medium 811. When the computer program is executed by a central processing unit (CPU) 801, various functions defined in the system of the present application are executed.
[0153] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a computer program, which may be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier, which carries a computer-readable computer program. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0154] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of the boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and a computer program.
[0155] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0156] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more computer programs, and when the above one or more computer programs are executed by an electronic device, the electronic device implements the method described in the above embodiment.
[0157] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0158] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation method of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable an electronic device to execute the method according to the implementation method of the present application. For example, the electronic device can execute Figure 2 The knowledge editing method based on knowledge graph is shown.
[0159] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.
[0160] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.< / edit> < / generate> < / edit> < / generate> < / edit> < / generate> < / edit>
Claims
1. A knowledge editing method based on knowledge graph, characterized in that: include: Get pending statements; Extracting knowledge triples corresponding to the sentence to be processed, wherein the knowledge triples are used to represent entities and entity relationships contained in the sentence to be processed; When it is necessary to perform knowledge editing processing on the language model and the knowledge graph corresponding to the language model according to the sentence to be processed, firstly verify the knowledge graph according to the knowledge triple to determine whether the knowledge triple conflicts with the existing knowledge in the knowledge graph; After verifying the knowledge triples in the knowledge graph, according to the verification results of the knowledge triples, collaborative knowledge editing processing is performed on the knowledge graph and the language model to match the symbolic knowledge in the knowledge graph with the parameterized knowledge in the language model; After each knowledge editing process is performed on the language model, the editing parameters corresponding to the language model and the triplet data used for the knowledge editing process of the language model are stored in association; wherein the editing parameters are used to represent the parameter information modified each time the knowledge editing process is performed on the language model; When it is necessary to roll back the knowledge editing operation of the language model by the specified triple data, acquiring the stored target editing parameters associated with the specified triple data according to the specified triple data; The target editing parameter is deleted in the language model to roll back the knowledge editing operation on the language model through the specified triple data.
2. The knowledge editing method based on knowledge graph according to claim 1 is characterized in that: Before extracting the knowledge triples corresponding to the to-be-processed sentences, the method further includes: identifying the intent of the statement to be processed; If the consciousness of the sentence to be processed is the knowledge editing intention, then executing the process of extracting the knowledge triple corresponding to the sentence to be processed; If the intention of the statement to be processed is a dialogue response intention, the language model generates a response statement for the statement to be processed.
3. The knowledge editing method based on knowledge graph according to claim 1 is characterized in that: The knowledge triplet includes subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; According to the verification result of the knowledge triples, the knowledge graph and the language model are collaboratively edited, including: If no triple data is detected in the knowledge graph that contains subject data that is identical to the subject data in the knowledge triples and contains relationship data that is identical to the relationship data in the knowledge triples, the knowledge triples are used to perform collaborative knowledge editing processing on the knowledge graph and the language model.
4. The knowledge editing method based on knowledge graph according to claim 1 is characterized in that: The knowledge triplet includes subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; According to the verification result of the knowledge triples, the knowledge graph and the language model are collaboratively edited, including: If triple data containing subject data identical to the subject data in the knowledge triples and containing relation data identical to the relation data in the knowledge triples but containing object data different from the object data in the knowledge triples is detected in the knowledge graph, the target triple data in the knowledge graph is overwritten with the knowledge triples, and the editing parameters related to the target triple data in the language model are deleted; After deleting the editing parameters related to the target triplet data in the language model, the language model is subjected to knowledge editing processing using the knowledge triplet.
5. The knowledge editing method based on knowledge graph according to claim 1 is characterized in that: According to the verification result of the knowledge triples, collaborative knowledge editing processing is performed on the knowledge graph and the language model, including: If triple data identical to the knowledge triple is detected in the knowledge graph, the process of using the knowledge triple to perform knowledge editing processing on the knowledge graph and the language model is skipped.
6. The knowledge editing method based on knowledge graph according to claim 1 is characterized in that: The knowledge triplet includes subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; The method further comprises: If the entity relationship represented by the relationship data in the knowledge triple is reversible, generating reverse triple data for representing the reverse relationship between the subject data and the object data according to the knowledge triple; The reverse triple data is verified as a new knowledge triple in the knowledge graph, and based on the verification result, the knowledge graph and the language model are collaboratively edited.
7. The knowledge editing method based on knowledge graph according to claim 1 is characterized in that: The knowledge triplet includes subject data, relationship data and object data, and the relationship data is used to represent the relationship between the subject data and the object data; The method further comprises: After performing knowledge editing processing on the knowledge graph and the language model according to the knowledge triples, searching the knowledge graph for at least one node data with the subject data as the center; A new knowledge triple is generated according to the at least one node data obtained by the search, and the new knowledge triple is used to perform knowledge editing processing on the language model.
8. The knowledge editing method based on knowledge graph according to claim 1 is characterized in that: The method further comprises: If an abnormal editing process of the language model is identified, it is determined that the knowledge editing operation of the language model needs to be rolled back.
9. The knowledge editing method based on knowledge graph according to any one of claims 1 to 8, characterized in that: According to the verification result of the knowledge triples, collaborative knowledge editing processing is performed on the knowledge graph and the language model, including: Based on the verification results of the knowledge triples, collaborative editing is performed on the symbolic knowledge in the knowledge graph and the parameterized knowledge in the language model.
10. A knowledge editing device based on knowledge graph, characterized in that: include: An acquisition unit configured to acquire statements to be processed; An extraction unit configured to extract a knowledge triple corresponding to the sentence to be processed, wherein the knowledge triple is used to represent entities and entity relationships contained in the sentence to be processed; A verification unit, configured to first verify the knowledge triple in the knowledge graph corresponding to the language model according to the knowledge triple when it is necessary to perform knowledge editing processing on the language model and the knowledge graph corresponding to the language model according to the sentence to be processed, so as to determine whether the knowledge triple conflicts with the existing knowledge in the knowledge graph; a processing unit configured to, after verifying the knowledge triples in the knowledge graph, perform collaborative knowledge editing processing on the knowledge graph and the language model according to the verification results of the knowledge triples, so as to match the symbolic knowledge in the knowledge graph with the parameterized knowledge in the language model; A storage unit configured to associate and store the editing parameters corresponding to the language model and the triplet data used for the knowledge editing process for the language model after each knowledge editing process is performed on the language model; wherein the editing parameters are used to represent parameter information modified each time the knowledge editing process is performed on the language model; The processing unit 708 is also configured to: when it is necessary to roll back the knowledge editing operation of the language model by the specified triple data, obtain the stored target editing parameters associated with the specified triple data according to the specified triple data; and delete the target editing parameters in the language model to roll back the knowledge editing operation of the language model by the specified triple data.
11. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the knowledge graph-based knowledge editing method described in any one of claims 1 to 9 is implemented.
12. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more computer programs, which, when executed by the one or more processors, enables the electronic device to implement the knowledge graph-based knowledge editing method described in any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product includes a computer program, which is stored in a computer-readable storage medium. The processor of the electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device executes the knowledge editing method based on the knowledge graph as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Knowledge migration method, device and equipment, readable storage medium and program product
CN117453925A
Auditing knowledge mapping system based on digital auditing platform
CN117932074A
Method and system for checking and relieving hallusion of large language model by using external knowledge base
CN117932086A
