Knowledge graph enhancement method and device based on large language model and storage medium
By using pre-trained large language models to generate multi-dimensional description information in the knowledge graph, the shortcomings of knowledge graph completion in the existing technology are solved, more comprehensive data enhancement and completion effects are achieved, and the representation ability of entities and relationships is improved.
Patent Information
- Application Number
- CN202410054681.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-12
- Publication Date
- 2025-07-18
AI Technical Summary
The existing knowledge graph completion method based on description text is difficult to achieve high-performance completion when faced with insufficient text data and structural incompleteness, especially in the learning and relationship understanding of long-tail entities.
By using a pre-trained large language model, target description information is generated from multiple dimensions, data enhancement of the original knowledge graph, including entity description, relationship description and structural improvement, the inference and summary ability of the large language model generates auxiliary text, and enriches the knowledge graph data.
It achieves a comprehensive completion of the knowledge graph, improves the integrity of entity description and the clarity of relational semantics, enhances the link prediction and classification capabilities of the knowledge graph, and explores more potential knowledge.
Smart Images

Figure CN120336538A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a method, apparatus, electronic device, computer storage medium, and computer program product for enhancing a knowledge graph based on a large language model. Background Art
[0002] A knowledge graph (KG) is a graph-based structured semantic knowledge base that uses a graph model to describe knowledge and model concepts in the physical world and their interrelationships. In a knowledge graph, nodes are called entities, and edges are called relationships. The "entity - relationship - entity" triple is the basic unit that constitutes a knowledge graph. Among them, knowledge graph completion (KGC) is a technology that solves the problem of missing relationships in a graph, predicting and supplementing potential relationships that may exist between nodes in the knowledge graph.
[0003] The methods in the field of knowledge graph completion can be mainly divided into structure-based completion algorithms and description text-based completion algorithms. Existing knowledge graph completion methods based on description text face difficulties caused by insufficient text data and incomplete structures. Their effectiveness is limited by the quality of text crawled from the Internet and structural incompleteness. Relying only on "relationships" easily leads to a vague understanding of entity types. At the same time, for long-tail entities, it is challenging to learn structural patterns from known graphs. These limitations make it difficult for KGC to achieve high performance in practical applications involving insufficient and incomplete knowledge graphs. Summary of the Invention
[0004] Embodiments of this application provide a method, apparatus, electronic device, computer-readable storage medium, and computer program product for enhancing a knowledge graph based on a large language model, which can improve the completion effect of the knowledge graph.
[0005] A method for enhancing a knowledge graph based on a large language model includes:
[0006] Obtaining a plurality of triples to be processed from an original knowledge graph;
[0007] Generating target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model;
[0008] Performing data enhancement processing on the original knowledge graph according to the target description information to obtain a data-enhanced knowledge graph.
[0009] Correspondingly, an embodiment of the present application further provides a knowledge graph enhancement device based on a large language model, including:
[0010] An acquisition unit, configured to acquire a plurality of triples to be processed from an original knowledge graph;
[0011] A generation unit, configured to generate target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model;
[0012] A processing unit, configured to perform data enhancement processing on the original knowledge graph according to the target description information to obtain an enhanced knowledge graph.
[0013] Optionally, in some embodiments, the generation unit is configured to:
[0014] For each triple to be processed, query the large language model based on preset prompting word strategies in multiple different dimensions to obtain the target description information of the triple to be processed in each dimension.
[0015] Optionally, in some embodiments, when querying the large language model based on preset prompting word strategies in multiple different dimensions for each triple to be processed to obtain the target description information of the triple to be processed in each dimension, the generation unit is specifically configured to:
[0016] For each triple to be processed, query the large language model based on the preset prompting word strategy in the entity description dimension to obtain the first description information of the triple to be processed in the entity description dimension;
[0017] For each triple to be processed, query the large language model based on the preset prompting word strategy in the relationship description dimension to obtain the second description information of the triple to be processed in the relationship description dimension;
[0018] Determine the target description information according to the first description information and the second description information.
[0019] Optionally, in some embodiments, when querying the large language model based on the preset prompting word strategy in the relationship description dimension to obtain the second description information of the triple to be processed in the relationship description dimension, the generation unit is specifically configured to:
[0020] Query the large language model based on the preset prompting word strategy in the relationship description dimension to obtain the first semantic information of the relationship in the original knowledge graph of the triple to be processed, the second semantic information of the relationship in the triple to be processed, and the verb form and passive voice of the relationship in the triple to be processed, so as to obtain the second description information.
[0021] Optionally, in some embodiments, the triple to be processed includes: entity - relationship - entity; the processing unit is configured to:
[0022] According to the target description information, update the description knowledge of the entities and the description knowledge of the relationships in the triple to be processed respectively;
[0023] According to the updated description knowledge of the entities, update the relationship structure between the entities in the multiple triples to be processed;
[0024] Based on the updated description knowledge of the entities, the updated description knowledge of the relationships, and the updated relationship structure, perform data enhancement processing on the original knowledge graph.
[0025] Optionally, in some embodiments, when updating the relationship structure between the entities in the multiple triples to be processed according to the updated description knowledge of the entities, the processing unit is configured to:
[0026] According to the updated description knowledge of the entities, determine the matching degree between the entities in the multiple triples to be processed;
[0027] Obtain at least one pair of matching target entity pairs according to the matching degree;
[0028] Establish the association relationship between the entities in the target entity pair, and construct a new target triple based on the association relationship and the target entity pair;
[0029] Based on the target triple, update the relationship structure between the entities in the multiple triples to be processed.
[0030] Optionally, in some embodiments, when determining the matching degree between the entities in the multiple triples to be processed according to the updated description knowledge of the entities, the processing unit specifically is configured to:
[0031] Extract multiple keywords from the updated description knowledge of the entities to obtain multiple keywords corresponding to each entity in the triple to be processed;
[0032] Based on the multiple keywords corresponding to each entity, calculate the matching degree between the entities in the multiple triples to be processed.
[0033] Optionally, in some embodiments, when constructing a new target triple based on the association relationship and the target entity pair, the processing unit specifically is configured to:
[0034] Obtain the entity types corresponding to the two entities in the target entity pair respectively;
[0035] According to the entity types corresponding to the two entities respectively, generate the description knowledge of the association relationship;
[0036] A new target triple is constructed according to the association relationship, the description knowledge of the association relationship and the target entity pair.
[0037] Optionally, in some embodiments, the device further comprises:
[0038] An extraction unit is used to perform data enhancement processing on the original knowledge graph according to the target description information to obtain a data-enhanced knowledge graph, and then extract multiple triples from the data-enhanced knowledge graph, wherein the triples include: head entity-relationship-tail entity;
[0039] A construction unit, configured to determine the head entity and the relationship between the head entity and the tail entity as training data, determine the tail entity as a label corresponding to the training data, and construct a training set;
[0040] A training unit is used to train the basic knowledge graph completion model based on the training set to obtain a target knowledge graph completion model.
[0041] An embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores an application, and the processor is used to run the application in the memory to execute the steps in any of the above-mentioned knowledge graph enhancement methods.
[0042] An embodiment of the present application also provides a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for a processor to load to execute the steps in any of the above-mentioned knowledge graph enhancement methods.
[0043] An embodiment of the present application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps in any of the above-mentioned knowledge graph enhancement methods.
[0044] In this application, multiple triples to be processed are obtained from the original knowledge graph, and then the target description information of the triples to be processed in multiple different dimensions is generated based on the pre-trained large language model, and the original knowledge graph is data enhanced according to the target description information to obtain the knowledge graph after data enhancement. This solution uses the reasoning, interpretation and summarization capabilities of the large language model to prompt the large language model to generate auxiliary text, improve the knowledge graph data from multiple different dimensions, thereby mining more potential but missing knowledge and achieving the effect of knowledge graph completion. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those skilled in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0046] Figure 1 is a schematic diagram of the scenario of the knowledge graph enhancement method provided by the embodiments of the present application;
[0047] Figure 2 is a schematic flowchart of the knowledge graph enhancement method provided by the embodiments of the present application;
[0048] Figure 3 is another schematic flowchart of the knowledge graph enhancement method provided by the embodiments of the present application;
[0049] Figure 4 is a schematic flowchart of the knowledge graph enhancement method based on a large language model provided by the embodiments of the present application;
[0050] Figure 5 is a schematic diagram of the visualization interface of the knowledge graph application provided by the embodiments of the present application;
[0051] Figure 6 is a schematic diagram of the comparison before and after the enhancement of the local knowledge graph provided by the embodiments of the present application;
[0052] Figure 7 is a schematic diagram of the structure of the knowledge graph enhancement device provided by the embodiments of the present application;
[0053] Figure 8 is a schematic diagram of the structure of the electronic device provided by the embodiments of the present application. Detailed implementation manners
[0054] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.
[0055] The embodiments of the present application provide a knowledge graph enhancement method, device, electronic device, computer-readable storage medium and computer program product based on a large language model, which can build a general multi-dimensional knowledge graph data enhancement method (Multi-Perspective Improvement of Knowledgegraph Completion, MPIKGC) on the existing KGC model based on descriptive text. By utilizing the reasoning, interpretation and summarization capabilities of the large language model (LLM), the knowledge graph data is improved from three dimensions: entity, relationship and structure, so as to enhance the performance of the KGC model under the knowledge graph data. Among them, the knowledge graph enhancement device can be integrated in an electronic device, which can be a server, a terminal or other equipment.
[0056] Among them, the server can be an independent physical server, or a server cluster or 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, network acceleration services, and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0057] For example, see Figure 1 Taking the knowledge graph enhancement device integrated in an electronic device as an example, the electronic device obtains multiple triples to be processed from the original knowledge graph; generates target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model; performs data enhancement processing on the original knowledge graph according to the target description information to obtain a knowledge graph after data enhancement.
[0058] Among them, the knowledge graph enhancement method provided in the embodiment of the present application involves the direction of natural language processing technology (Natural Language processing, NLP). The embodiment of the present application utilizes the reasoning, interpretation and summarization capabilities of the large language model to prompt the large language model to generate auxiliary text, improve the knowledge graph data from multiple different dimensions, thereby mining more potential but missing knowledge and achieving the effect of knowledge graph completion.
[0059] Among them, Artificial Intelligence (AI) is a theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines, enabling machines to have the functions of perception, reasoning, and decision-making.
[0060] Artificial intelligence technology is an interdisciplinary subject that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, large image processing technology, operation / interaction systems, and mechatronics. The software technologies of artificial intelligence mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0061] Among them, natural language processing is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can enable effective communication between humans and computers in natural language. Natural language processing involves natural language, that is, the language people use in daily life, and is closely related to linguistics research; at the same time, it involves computer science and mathematics. The pre-trained model, an important technology for model training in the field of artificial intelligence, is developed from the large language model in the field of natural language processing. The large language model is trained on a large amount of text data. After fine-tuning, the large language model can be widely applied to downstream tasks, usually including text processing, semantic understanding, machine translation, robot question answering, knowledge graphs, and so on.
[0062] A pre-trained model (PTM), also known as a foundation model or a large model, refers to a deep neural network (DNN) with a large number of parameters. It is trained on a vast amount of unlabeled data, and by leveraging the function approximation ability of the large-parameter DNN, the PTM extracts common features from the data. Through techniques such as fine-tuning, parameter-efficient fine-tuning (PEFT), and prompt-tuning, it is applicable to downstream tasks. Therefore, the pre-trained model can achieve ideal results in few-shot or zero-shot scenarios. PTMs can be classified into language models (ELMO, BERT, GPT), vision models (swin-transformer, ViT, V-MOE), speech models (VALL-E), multi-modal models (ViBERT, CLIP, Flamingo, Gato), etc. according to the data modalities they process. Among them, multi-modal models refer to models that establish feature representations of two or more data modalities. The pre-trained model is an important tool for outputting artificial intelligence-generated content (AIGC) and can also serve as a general interface connecting multiple specific task models.
[0063] Among them, it can be understood that in the specific implementation of this application, related data such as attribute data, attribute sets, and attribute subsets are involved. When the following embodiments of this application are applied to specific products or technologies, permission or consent is required, and the collection, use, and processing of related data need to comply with the relevant laws, regulations, and standards of relevant countries and regions.
[0064] The following will be described in detail respectively. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.
[0065] This embodiment will be described from the perspective of the angular information of the knowledge graph enhancement device. The knowledge graph enhancement device can be specifically integrated in an electronic device, which can be a server or a terminal device, etc.; among them, the terminal can include a tablet computer, a notebook computer, and a personal computer (PC) or other intelligent devices that can process data.
[0066] An embodiment of this application provides a knowledge graph enhancement method based on a large language model, including: obtaining a plurality of triples to be processed from an original knowledge graph; generating target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model; and performing data enhancement processing on the original knowledge graph according to the target description information to obtain an enhanced knowledge graph.
[0067] As Figure 2 shown, the specific process of this knowledge graph enhancement method is as follows:
[0068] 101. Obtain multiple triples to be processed from the original knowledge graph.
[0069] In this embodiment, the original knowledge graph is a structured semantic knowledge base, and its basic component unit is the "entity-relationship-entity" triple. Among them, an entity refers to a distinguishable and independent thing. All things in the world are composed of specific things, such as a certain person, a certain city, a certain plant, a certain commodity, etc. An entity is the most basic element in the knowledge graph, and the knowledge points in the knowledge graph are represented as entities. A relationship is a directed and semantic representation between entities. In the knowledge graph, the association and connection between knowledge points are manifested as relationships, and different relationships exist between different entities.
[0070] Specifically, in one implementation, in order to more comprehensively improve the data representation ability of the entire knowledge graph, all triples in the original knowledge graph can be determined as triples to be processed. In another implementation, in order to reduce device consumption and calculation amount, triples that are needed can also be determined as triples to be processed. For example, triples in the original graph that contain long-tail entities (such as entities with low occurrence frequency and few connected neighbors) can be determined as triples to be processed.
[0071] 102. Generate target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model.
[0072] In this embodiment, an auxiliary text will be generated through a pre-trained large language model to improve the original knowledge graph data, so as to enhance the representation ability of entities and relationships in the knowledge graph. Specifically, the data of the triples to be processed can be improved from multiple different dimensions. For each triple, generate its target description information in multiple different dimensions as auxiliary text to achieve the improvement of the original knowledge graph data.
[0073] In specific implementation, a prompting strategy can be designed for each different dimension, and the generation of this auxiliary text can be achieved by querying the large language model based on this prompting strategy. That is, in one implementation, when generating the target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model, specifically, for each triple to be processed, the large language model can be queried based on the preset prompting strategies in multiple different dimensions to obtain the target description information of the triple to be processed in each dimension.
[0074] In practical applications, the inference, interpretation, and summarization capabilities of large language models can be utilized to improve knowledge graph data from the entity dimension and the relationship dimension respectively. That is, in one embodiment, the step of "for each triple to be processed, query the large language model based on preset prompting strategies on multiple different dimensions to obtain the target description information of the triple to be processed in each dimension" may include the following processes:
[0075] (11) For each triple to be processed, query the large language model based on the preset prompting strategy on the entity description dimension to obtain the first description information of the triple to be processed in the entity description dimension;
[0076] (12) For each triple to be processed, query the large language model based on the preset prompting strategy on the relationship description dimension to obtain the second description information of the triple to be processed in the relationship description dimension;
[0077] (13) Determine the target description information according to the first description information and the second description information.
[0078] Specifically, to solve the problem of incomplete entity description information, in this embodiment, the large language model will be queried from the dimension of entity description to expand the knowledge of entity description. Specifically, it can be implemented by designing a chain-of-thought prompt. The large language model can decompose the query text into multiple different directions and gradually generate descriptions to obtain the first description information in the entity description dimension.
[0079] In practical applications, the template based on the preset prompting strategy on the entity description dimension can be designed as: "Please provide all information about {entity name}. Before answering, please give reasons:", which decomposes the query text into two levels: providing a comprehensive entity description and giving reasons corresponding to the relevant entity description. Taking the entity name {Michael Bay} as an example, the constructed chain-of-thought prompt is: "Please provide all information about {Michael Bay}. Before answering, please give reasons:". For example, based on this preset prompting strategy, the large language model will generate the target description information of {Michael Bay} as: "Michael Bay is a famous American film director and producer. Reason: Michael Bay is a prolific film producer who has directed many successful films, including "Transformers" and "Armageddon"; Fact: 1. Early life: Michael Bay was born on September 17, 1965, in Los Angeles, California. Reason: This fact provides some background information for Michael Bay's personal life and growth." It can be seen that the large language model generates a description containing personal information and attaches reasons to each answer to enhance the description of the large language model.
[0080] To solve the problem of ambiguous relational semantics, in this embodiment, multiple prompting strategies will be used on the dimension of relational description to query the large language model, capture the associations between relations, and facilitate better reverse prediction, improving the understanding of the relational meaning by the knowledge graph completion model.
[0081] Specifically, when implementing, three prompting strategies such as the global prompting strategy, the local prompting strategy, and the reverse prompting strategy can be used to query the large language model. Among them, the global prompting strategy, that is, considering the meaning of the relation in the entire knowledge graph, inferring the importance of the relation from the perspective of the entire knowledge graph, thereby promoting better association between two relations. For example, in the knowledge graph, the relation "location country form_of_government" represents the governance form followed by a specific country, which helps to classify countries according to the system, thus providing a more comprehensive understanding of the world. The local prompting strategy, that is, considering the meaning of the relation in the triple. For example, the triple to be processed includes the head entity, the location country, and the tail entity. The head entity is the main subject of the data, while the location country and the tail entity provide additional information about the location. A triple may include the country where a specific movie was filmed, the city where the movie was produced, and the date and time of the movie's release. The reverse prompting strategy, that is, considering the passive form of the relation, thereby enhancing understanding and achieving better reverse prediction. For example, the "location-country-form_of_government" relation in the active voice is "the country has a location". In the passive voice, it describes "a country is located in a specific location". That is, in one implementation manner, the step "query the large language model based on the preset prompting strategy on the relational description dimension to obtain the second description information of the triple to be processed on the relational description dimension" may include the following process:
[0082] Query the large language model based on the preset prompting strategy on the relational description dimension, and obtain the first semantic information of the relation in the original knowledge graph of the triple to be processed, the second semantic information of the relation in the triple to be processed, and the verb form and passive voice of the relation in the triple to be processed, to obtain the second description information.
[0083] Specifically, the preset prompting strategy on the relational description dimension is divided into three dimensions of prompting strategies: global prompting, local prompting, and reverse prompting, to query the large language model. When implementing, the first semantic information of the relation in the original knowledge graph of the triple to be processed can be obtained based on the global prompting strategy on the relational description dimension; the second semantic information of the relation in the triple to be processed can be obtained based on the local prompting strategy on the relational description dimension; based on the reverse prompting strategy on the relational description dimension, the verb form and passive voice of the relation in the triple to be processed can be obtained.
[0084] In practical applications, the template of the global prompt word strategy can be designed as: "Please explain the meaning of the relationship {relationship name} in the knowledge graph in one sentence:"; the template of the local prompt word strategy can be designed as: "Please explain the meaning of this triple (head entity, {relationship name}, tail entity) and rewrite it into a sentence:"; the template of the reverse prompt word strategy can be designed as: "Please convert the relationship {relationship name} into a verb form and give a passive voice description:".
[0085] 103. Perform data enhancement processing on the original knowledge graph according to the target description information to obtain the data enhanced knowledge graph.
[0086] Specifically, based on the target description information obtained in multiple different dimensions, data enhancement processing is performed on the original knowledge graph to improve and complete the original knowledge graph data from multiple angles, thereby solving problems such as incomplete entity description information and ambiguous relationship semantics in the knowledge graph.
[0087] As can be seen from the above, the knowledge graph enhancement method provided in the embodiment of the present application obtains multiple triples to be processed from the original knowledge graph, generates target description information of the triples to be processed in multiple different dimensions based on the pre-trained large language model, and performs data enhancement processing on the original knowledge graph according to the target description information to obtain the knowledge graph after data enhancement. In this solution, the reasoning, interpretation and summarization capabilities of the large language model are used to prompt the large language model to generate auxiliary text, improve the knowledge graph data from multiple different dimensions, thereby mining more potential but missing knowledge and achieving the effect of knowledge graph completion.
[0088] In the implementation of this application, the triples to be processed include: entity-relationship-entity. In one implementation, the step of "performing data enhancement processing on the original knowledge graph according to the target description information to obtain a knowledge graph after data enhancement" may include the following process:
[0089] (21) Based on the target description information, the description knowledge of the entities and the description knowledge of the relationships in the triples to be processed are updated respectively.
[0090] In this embodiment, the target description information includes: the first description information of the triple to be processed in the entity description dimension, and the second description information of the triple to be processed in the relationship description dimension. Specifically, according to the first description information of the triple to be processed in the entity description dimension, the description knowledge of the entity in the triple to be processed is updated; according to the second description information of the triple to be processed in the relationship description dimension, the description knowledge of the relationship in the triple to be processed is updated. Among them, the operation of updating the description knowledge can specifically include replacement, overwriting, supplementation, etc.
[0091] (22) Update the relationship structure of entities among multiple triples to be processed according to the descriptive knowledge of the updated entities.
[0092] In practical applications, a "person" entity working as a producer or director is likely to be related to a "movie" entity. However, learning patterns from the graph structure is restricted by sparsity, especially for long-tail entities (e.g., an entity representing a person with low frequency and few connected neighbors in the knowledge graph). In the embodiments of the present application, to solve the problem of sparse graph links, the relationship structure of entities among different triples will be updated according to the descriptive knowledge of each updated entity.
[0093] Specifically, in this embodiment, additional structural information will be generated by querying a large language model to enrich the knowledge graph, the keywords summarized by the large language model will be used to measure the similarity between entities, and new triples will be created to build associations between related entities, so that the knowledge graph completion model forms a new structural pattern. That is, in one implementation manner, the step of "updating the relationship structure of entities among multiple triples to be processed according to the descriptive knowledge of the updated entities" includes the following processes:
[0094] (221) Determine the matching degree of entities among multiple triples to be processed according to the descriptive knowledge of the updated entities.
[0095] Specifically, keyword extraction can be performed on the descriptive knowledge of the updated entities, and the matching degree between two entities can be measured by the extracted keywords. That is, in one implementation manner, when determining the matching degree of entities among multiple triples to be processed according to the descriptive knowledge of the updated entities, the following processes can be included:
[0096] Extract multiple keywords from the descriptive knowledge of the updated entities to obtain multiple keywords corresponding to each entity in the triple to be processed;
[0097] Based on the multiple keywords corresponding to each entity, calculate the matching degree of entities among multiple triples to be processed.
[0098] Among them, the number of keywords can be set by those skilled in the art. For example, the keywords can be set to 5, 10, etc. For entities with insufficient vocabulary in the descriptive knowledge, as many keywords as possible can be extracted. It should be noted that for the head entity and the tail entity in the existing triples in the original knowledge graph, there is no need to calculate the matching degree between the two.
[0099] In specific implementation, the matching degree between two entities can be determined by calculating the keyword matching score. The specific formula is as follows:
[0100] s = len(m) / min(len(k h), len(k t ))
[0101] m = interscection(k h , k t )
[0102] where len() represents the text length, s represents the matching score; k t represents the keywords of the head entity, k h represents the keywords of the tail entity, and m represents the intersection between the keywords of the head entity and the keywords of the tail entity. For example, for text 1: Messi is an Argentine professional footballer, and text 2: Ronaldo is a Portugal professional footballer, then the intersection m = (is, professional, footballer), there are 3 common keywords, so the matching score s = 3 / 6 = 0.5.
[0103] (222) Obtain at least one pair of matching target entity pairs according to the matching degree.
[0104] Specifically, the relevant entity pairs (i.e., the two entities for which the matching degree has been calculated) can be sorted according to the size of the matching degree, and the top K pairs of entity pairs with larger matching degrees are selected as the matching target entity pairs.
[0105] (223) Establish the association relationship between the entities in the target entity pair, and construct a new target triple based on the association relationship and the target entity pair.
[0106] In this embodiment, the association between the two entities in the target entity pair can be established in the form of (head entity, Similar (Same As), tail entity) to construct a new target triple.
[0107] Specifically in implementation, it can be further divided into multiple types of "Same As" relationship according to entity characteristics to construct a more fine-grained data enhancement method. That is, in one implementation manner, when constructing a new target triple based on the association relationship and the target entity pair, the following process can be included:
[0108] Obtain the entity types corresponding to the two entities in the target entity pair respectively;
[0109] Generate the descriptive knowledge of the association relationship according to the entity types corresponding to the two entities respectively;
[0110] Construct a new target triple according to the association relationship, the descriptive knowledge of the association relationship and the target entity pair.
[0111] For example, if both the head entity and the tail entity are entities of the "person" type, the "similar" relationship can be further refined into the "person_similar" relationship as the descriptive knowledge of the association relationship. Another example is that if the head entity and the tail entity are entities of the "movie" type, the "similar" relationship can be further refined into the "movie_similar" relationship as the descriptive knowledge of the association relationship. By making a more fine-grained division of the relationship, it is possible to make a differential distinction of the similarity between different entities based on the entity characteristics, so as to learn more diverse representations and promote the model to better understand the meaning of the newly added relationship.
[0112] (224) Update the relationship structure between entities among multiple triples to be processed based on the target triple.
[0113] Specifically, based on the newly constructed target triple above, update the relationship structure between entities among multiple triples to be processed in the original knowledge graph to form a new structural pattern. For example, there is a triple to be processed 1 (entity A, relationship 1, entity B), a triple to be processed 2 (entity C, relationship 2, entity D), and a target triple (entity A, similar, entity C). Then, based on the processing of triple to be processed 1 and triple to be processed 2, the "similar" relationship between entity A and entity C is added to the original knowledge graph.
[0114] (23) Perform data augmentation processing on the knowledge graph based on the descriptive knowledge of the updated entities, the descriptive knowledge of the updated relationships, and the updated relationship structure.
[0115] Specifically, based on the descriptive knowledge of the updated entities, the descriptive knowledge of the updated relationships, and the updated relationship structure, perform replacement, coverage, supplementation, etc. on the relevant knowledge in the entire original knowledge graph to achieve the data augmentation effect.
[0116] In practical applications, the knowledge graph after data augmentation can be used for the knowledge graph completion model to learn, so as to enhance the link prediction and classification capabilities of the knowledge graph completion model. That is, in one implementation, referring to Figure 3 , after performing data augmentation processing on the original knowledge graph according to the target description information to obtain the knowledge graph after data augmentation, the following process can also be included:
[0117] 104. Extract multiple triples from the knowledge graph after data augmentation, and the triple includes: head entity - relationship - tail entity.
[0118] Specifically, extracting multiple triples from the knowledge graph after data augmentation includes the newly constructed target triple and the original triples to be processed.
[0119] 105. Determine the head entity and the relationship between the head entity and the tail entity as training data, and determine the tail entity as the label corresponding to the training data to construct a training set.
[0120] Specifically, obtain the head entity and the relationship between the head entity and the tail entity from each extracted triple as a training data, and use the tail entity in the triple as the label of the training data to construct a training set. It should be noted that the training data in the training set includes all information of the entity and all information of the relationship. Among them, all information of the entity includes the entity name and the descriptive knowledge of the entity; all information of the relationship includes the relationship name and the descriptive knowledge of the relationship.
[0121] 106. Train the basic knowledge graph completion model based on the training set to obtain the target knowledge graph completion model.
[0122] Specifically, use the training data in the training set as the input of the basic knowledge graph completion model, and predict an output through the model as the tail entity. In this embodiment, a target function needs to be constructed to guide the optimization direction of the model. During the training process, compare the output of the model with the corresponding label, and calculate the model loss to guide the adjustment of the model parameters until the model can correctly predict the corresponding label.
[0123] In this embodiment, by learning the knowledge graph after data augmentation, the performance of the knowledge graph completion model under common knowledge graph data can be improved, more potential but missing knowledge can be mined, and the effect of knowledge graph completion can be achieved.
[0124] According to the method described in the above embodiment, the following will be further described in detail with examples. In another embodiment of the present application, as Figure 4 shown, a flowchart of another knowledge graph enhancement method based on a large language model is provided. Next, the knowledge graph enhancement method in this solution will be described in detail with examples.
[0125] Step 1: Obtain the original knowledge graph, which includes multiple triple information.
[0126] As Figure 4 shown, the original knowledge graph may include triples (Transformers: The Dark of the Moon, produced by, Ian Bryon), triples (Michael Bay, birthplace, United States), triples (Michael Bay, director of, Transformers: The Dark of the Moon), and triples (Transformers: The Dark of the Moon, release place, United States).
[0127] Step 2: Use the original knowledge graph as the input of the large language model, and ask the large language model based on a preset prompt word strategy in multiple dimensions to obtain the outputs of the large language model in multiple dimensions.
[0128] In this embodiment, a new technical framework is constructed on the KGC model based on descriptive text: Multi-Perspective Improvement of Knowledge graph Completion (MPIKGC), which improves the performance of the KGC model by prompting the large language model to generate auxiliary text. In this embodiment, to solve the problem of incomplete entity description information, it is proposed to query the large language model to expand the knowledge of entity description. Specifically, it is achieved by designing a chain-of-thought prompt, which allows the large language model to decompose the query text into different aspects and gradually generate descriptions.
[0129] To further solve the problem of ambiguous relation semantics, a solution is proposed to improve the KGC model's understanding of the meaning of relations. Among them, three prompt strategies (global prompt strategy, local prompt strategy, and reverse prompt strategy) are involved in querying the large language model to capture the associations between relations and promote better reverse prediction.
[0130] In addition, to solve the problem of sparse graph links, especially for long-tail entities, the large language model will be queried to extract additional structural information, use the keywords summarized by the large language model to measure the similarity between entities, and create new triples to build the associations between related entities, so that the KGC model forms a new structural pattern.
[0131] In this embodiment, the prompts used to interact with the large language model need to follow three basic principles: clarity, generality, and diversity. Among them, regarding clarity, the large language model needs to strictly follow the instructions, and overly complex instructions may lead to misunderstandings; regarding generality, the designed prompts should be compatible with various large language models, and the text generated by the large language model should also improve the effect on multiple KGC models (including link prediction and triple classification tasks); regarding diversity, the prompt design should show diversity from various perspectives (including entities, relations, and structures) to enrich the KG data. The prompts can improve the learning of the KGC model and present a synergistic effect when combined. Refer to the prompt template designed in Table 1 below:
[0132]
[0133]
[0134] In this embodiment, regarding the chain-of-thought prompting strategy for entity description enhancement, it enables the large language model to break down complex query texts into different directions and gradually generate descriptions without explicit manual input. It instructs the large language model to implicitly query relevant information by itself, thus generating more efficient and extensive answers. As shown in the template MPIKGC-E in Table 1, the large language model is required to provide comprehensive entity descriptions, and by designing prompts, the large language model can give reasons for the answers, enhancing the interpretability of the answers and improving the recall rate of the KGC model. Refer to Figure 4 , an example of a celebrity "Michael Bay" is shown, where the large language model generates a description containing personal information and attaches reasons to each answer to enhance the statements of the large language model.
[0135] In this embodiment, regarding relation understanding enhancement, the existence of heterogeneous relations in the knowledge graph plays a crucial role in distinguishing two entities. However, relying solely on relation names may lead to ambiguous interpretations, especially for complex relation categories (such as many-to-many and many-to-one). In addition, the link prediction task requires additional reverse prediction, that is, predicting the head entity based on (?, relation, tail entity). Therefore, three prompting strategies are proposed, namely Global, Local, and Reverse prompting strategies, as shown in MPIKGC-R in Table 1. Specifically, MPIKGC-R Global aims to infer the importance of relations from the perspective of the entire KG, thereby promoting better association between two relations. By allowing the large model to provide more detailed text explanations for relations, additional information can be obtained. For example, both "produced by" and "directed by" are related to the film industry, while "release location" and "birthplace" are related to the names of countries or regions. Avoid misinterpreting "produced by" as "manufactured" or "produced". On the other hand, MPIKGC-R Local aims to infer the meaning of relations from the perspective of triples, thereby enhancing the understanding of possible head / tail entity types in missing facts. As Figure 2 shown, when asking the large language model about the meaning of "(head entity, release location, tail entity)", the large language model indicates that this relation may be related to movies and regions. In addition, MPIKGC-R Reverse requires representing the relation as a verb and converting it to the passive voice. For example, "produce" can be converted to "produced by", thus enhancing understanding and achieving better reverse prediction.
[0136] Step 3: Perform data enhancement processing on the original knowledge graph according to the output of the large language model to obtain an improved knowledge graph.
[0137] Refer to Figure 2, in this embodiment, data augmentation is performed on the original knowledge graph, including data augmentation of entities (such as the descriptive knowledge added to "Michael Bay"), data augmentation of relationships (such as the descriptive knowledge added to "was produced by"), and data augmentation of the structure (such as constructing the "similar" relationship between "Michael Bay" and "Transformers: The Dark of the Moon").
[0138] Step 4: Train the KGC model according to the improved knowledge graph.
[0139] In this embodiment, regarding structure extraction enhancement, the KGC model can learn structure patterns from the known graph and generalize them to the test triples for link prediction. For example, a "person" entity whose job is a producer or a director is likely to be related to a "movie" entity. However, learning patterns from the graph structure is limited by sparsity, especially for long-tail entities. Based on this, this solution proposes MPIKGC-S, which enriches the knowledge graph by asking the large language model to generate additional structure information. To convert the generated text of the large language model into graph-based data, the generalization ability of the large language model will be used to extract text keywords from the description, and then the matching score between entities will be calculated according to the number of matching keywords. After sorting the matching scores, the top k pairs of matches are selected and new triples are created in the form of (head entity, Same As, tail entity), and then added to the training set. The enhanced knowledge graph is stored in the form of a triple (h, r, t). Among them, h represents the head entity, t represents the tail entity, and r represents the relationship between the head entity and the tail entity. The model training process is to input h and r into the KGC model and predict a most suitable t: t = KGCModel(h, r).
[0140] Among them, the KGC model can be any text-based knowledge graph completion model. Since the knowledge graph enhancement strategy of this solution is universal and is an enhancement at the data level, it can be applied to various knowledge graph completion methods. During the KGC test, h and r are input, and similarity calculations are performed with all entities in the knowledge graph. The tail entity with the highest score is the result to be predicted.
[0141] In this embodiment, four representative description text-based KGC models are selected to verify the effectiveness of the enhanced method of this solution in two tasks: link prediction and triple classification. At the same time, six structure-based KGC models are also compared. Among them, the selected datasets for the experiment are FB15k237 and WN18RR, and the model effects are measured by indicators such as MRR, MR, and HITS@n. Among them, MRR represents the mean reciprocal rank. The larger the MRR value, the better the knowledge graph embedding effect; MR represents the mean rank. The smaller the MR value, the better the knowledge graph embedding effect; HITS@n represents the average proportion of triples with a rank less than or equal to n in link prediction. The larger the HITS@n indicator, the better the knowledge graph embedding effect.
[0142] In this embodiment, the values of n in HITS@n are taken as 1, 3, and 10 to evaluate the model effect. Specifically, refer to Tables 1 to 4 below. Table 1 shows the evaluation index data of the structure-based KCG model in the link prediction task; Table 2 shows the evaluation index data of the description text-based KCG model in the link prediction task; Table 3 shows the evaluation index data of the structure-based KCG model in the triple classification task; Table 4 shows the evaluation index data of the description text-based KCG model in the triple classification task.
[0143] Table 1
[0144]
[0145] Table 2
[0146]
[0147]
[0148] Table 3
[0149]
[0150] Table 4
[0151]
[0152]
[0153] As can be seen from the above, based on the description text-based KGC model, after adding the methods proposed in this solution (MPIKGC-E, MPIKGC-R, MPIKGC-S), the effect can be significantly improved, and it is also significantly better than the performance of the structure-based KGC model.
[0154] In practical applications, the medical knowledge graph is an important tool that helps doctors and researchers better understand and utilize medical data. However, in the field of healthcare, there is a large amount of information describing entities such as diseases, genes, and drugs, but the descriptions and naming methods of these entities vary, resulting in fragmented and chaotic information. Due to the complexity and diversity of medical data, the entities and relationships in the medical knowledge graph are often incomplete. Therefore, this solution can be applied to the healthcare field. By proposing a knowledge graph enhancement method based on large language models in this solution, more potential but missing knowledge can be mined from the existing large-scale medical knowledge graph network structure to achieve the effect of complementing the medical knowledge graph.
[0155] Reference Figure 5 , Figure 5 shows the visualization of the subgraph related to the "hypertensive disease" entity in the medical knowledge graph for link prediction by the KGC model after using the knowledge graph data enhancement method based on large language models provided by this solution. As Figure 5 shown, by inputting the keyword "hypertension", multiple different entities and their types can be linked, such as hypertension, hypertensive disease, blood pressure, H-type hypertension, pregnancy-induced hypertension, etc. Specifically, when linking to the subgraph related to the "hypertensive disease" entity, entities with different relationships to this "hypertensive disease" entity can be displayed on the page. For example, the entity "Nilvitol tablets" with the relationship "disease taboo" to this "hypertensive disease" entity is displayed; another example is that the entity "hypertrophic cardiomyopathy" with the relationship "complication" to this "hypertensive disease" entity is also displayed.
[0156] Reference Figure 6 , Figure 6 shows a comparison diagram before and after the enhancement of the local knowledge graph with hypertension as an example. As Figure 6 shown, there are two triples in the original knowledge graph, namely the triple (hypertensive disease, risk factor, high-salt diet) and the triple (hypertensive disease, disease taboo, greasy diet).
[0157] Specifically, for the triple (hypertensive disease, risk factor, high-salt diet), the large language model is queried based on the above MPIKGC-E strategy to obtain all the information of the "hypertensive disease" entity and all the information of the "high-salt diet" entity as the description information of this triple (hypertensive disease, risk factor, high-salt diet) in the entity description dimension. For example, for "hypertensive disease", the obtained description information is as follows:
[0158] Hypertension, also known as hypertensive disease, is a common chronic disease mainly characterized by persistent high blood pressure. Blood pressure is the force exerted by blood on the blood vessel walls. When this force is continuously too high, various health problems may occur;
[0159] Types of hypertension: There are mainly primary hypertension and secondary hypertension. Primary hypertension accounts for the majority of hypertension cases, with unknown causes, and may be related to factors such as genetics, environment, and lifestyle. Secondary hypertension is caused by other diseases or conditions;
[0160] Symptoms of hypertension: Hypertension usually has no obvious symptoms, so it is called the "silent killer". However, some people may experience headaches, dizziness, or vision problems;
[0161] Risk factors for hypertension: Age, family history, obesity, unhealthy diet (such as high-salt diet), lack of exercise, excessive alcohol consumption, smoking, long-term stress, etc. may all increase the risk of developing hypertension;
[0162] Complications of hypertension: If not controlled, hypertension may lead to serious health problems such as heart disease, stroke, and kidney disease;
[0163] Treatment of hypertension: Includes lifestyle changes (such as a healthy diet, increased exercise, limiting alcohol and nicotine intake) and drug treatment;
[0164] The importance of understanding hypertension lies in that it is a major risk factor for heart disease, stroke, and other serious health problems. By understanding hypertension, appropriate preventive measures can be taken, such as changing lifestyle and regularly checking blood pressure, to reduce the risk of disease...
[0165] For another example, for the "high-salt diet" entity, the following descriptive information is obtained:
[0166] A high-salt diet refers to a diet with daily salt intake exceeding 6 grams, including the amount of salt ingested through various condiments such as soy sauce, pickles, and monosodium glutamate. Studies have found that excessive salt intake (more than 10 grams per day) is directly related to the occurrence of hypertension, heart disease, kidney disease, and the induction of cerebral hemorrhage. In the population that eats 15 grams of salt per day, the incidence of hypertension is about 10%. A high-salt diet is an important risk factor for hypertension.
[0167] A high-salt diet has an impact on diseases such as hypertension, osteoporosis, gastritis and gastric cancer, diabetes, bronchial asthma, and upper respiratory tract infections...
[0168] Similarly, for the triple (hypertensive disease, disease taboos, greasy diet), the large language model is queried based on the above MPIKGC-E strategy to obtain all the information of the "hypertensive disease" entity and all the information of the "greasy diet" entity, which are used as the description information of this triple (hypertensive disease, disease taboos, greasy diet) in the entity description dimension. Then, the description information in the entity description dimension of the two triples obtained is updated to the original knowledge graph to perform data augmentation processing on the original knowledge graph from the entity description dimension.
[0169] Specifically, for the triple (hypertensive disease, disease taboos, greasy diet), the large language model is queried based on the above MPIKGC-R global strategy, MPIKGC-R local strategy, and MPIKGC-R reverse hint strategy respectively to obtain the meaning of the relationship "disease taboos" in the knowledge graph, the meaning of the triple (hypertensive disease, disease taboos, greasy diet), and the verb form and passive voice statement of "disease taboos", which are used as the description information of this triple (hypertensive disease, disease taboos, greasy diet) in the relationship description dimension. For example, for the MPIKGC-R global strategy, the following description information can be obtained:
[0170] The relationship of "disease taboos" in the knowledge graph refers to the behaviors, activities, or foods that patients with a certain disease should avoid because these may exacerbate the condition, cause complications, or interfere with the treatment effect;
[0171] For example, for the MPIKGC-R local strategy, the following description information can be obtained:
[0172] The meaning of the triple (hypertensive disease, disease taboos, greasy diet) is that patients with hypertensive disease cannot eat overly greasy foods. Rewriting this triple into a sentence gives: Hypertensive patients are taboo from eating greasy foods.
[0173] For example, for the MPIKGC-R reverse hint strategy, the following description information can be obtained:
[0174] The relationship "disease taboos" can be transformed into the verb form "prohibit", and the passive voice statement is "due to the disease... (certain activities or foods) are prohibited".
[0175] Specifically, for the entity description knowledge after data augmentation processing, the large language model is queried based on the MPIKGC-S strategy to extract five most representative keywords from the updated entity description knowledge. For example, for the "hypertensive disease" entity after data augmentation processing, five keywords can be extracted from its entity description knowledge as follows: hypertension, symptoms, risk factors, complications, treatment. In the knowledge graph, the extracted keywords can also be marked and displayed, such as in bold, highlighted, etc.
[0176] Then, based on the keywords corresponding to each extracted entity, calculate the matching scores between entities, and determine the matching degree between two entities according to this. When the matching degree meets the requirements, establish a "similar" relationship between the two entities to perform data enhancement processing on the knowledge graph in terms of the relationship structure dimension. For example, for "greasy diet" and "high-salt diet", assuming that the matching degree between these two entities meets the requirements, a "similar" relationship between the two can be established. Further, the "similar" relationship can be classified, such as refined into "eating habit_similar" to construct a more fine-grained data enhancement method in the relationship structure dimension.
[0177] As can be seen from the above, this solution can be applied to the knowledge completion of medical graphs. In the scenario of medical knowledge graphs, graph completion has extensive applications and significance. First, it can help doctors and researchers better understand and utilize medical data, thereby improving the level of disease diagnosis and treatment; second, it can help medical institutions better manage and utilize medical data, improving the quality and efficiency of medical services.
[0178] To better implement the above method, an embodiment of the present application also provides a knowledge graph enhancement device based on a large language model. This knowledge graph enhancement device can be integrated in an electronic device, such as a server or a terminal, etc. The terminal can include a tablet computer, a laptop computer, and / or a personal computer, etc.
[0179] For example, as Figure 7 shown, this knowledge graph enhancement device may include: an acquisition unit 301, a generation unit 302, and a processing unit 303, as follows:
[0180] The acquisition unit 301 is used to obtain a plurality of triples to be processed from the original knowledge graph;
[0181] The generation unit 302 is used to generate target description information of the triple to be processed in multiple different dimensions through a pre-trained large language model;
[0182] The processing unit 303 is used to perform data enhancement processing on the original knowledge graph according to the target description information to obtain a data-enhanced knowledge graph.
[0183] Optionally, in some embodiments, the generation unit 302 is used to:
[0184] For each triple to be processed, query the large language model based on preset prompting word strategies in multiple different dimensions to obtain the target description information of the triple to be processed in each dimension.
[0185] Optionally, in some embodiments, when, for each of the triples to be processed, the large language model is queried based on the preset prompting word strategies in multiple different dimensions to obtain the target description information of the triple to be processed in each dimension, the generating unit 302 is specifically configured to:
[0186] For each of the triples to be processed, query the large language model based on the preset prompting word strategy in the entity description dimension to obtain the first description information of the triple to be processed in the entity description dimension;
[0187] For each of the triples to be processed, query the large language model based on the preset prompting word strategy in the relationship description dimension to obtain the second description information of the triple to be processed in the relationship description dimension;
[0188] Determine the target description information according to the first description information and the second description information.
[0189] Optionally, in some embodiments, when querying the large language model based on the preset prompting word strategy in the relationship description dimension to obtain the second description information of the triple to be processed in the relationship description dimension, the generating unit 302 is specifically configured to:
[0190] Query the large language model based on the preset prompting word strategy in the relationship description dimension to obtain the first semantic information of the relationship in the original knowledge graph of the triple to be processed, the second semantic information of the relationship in the triple to be processed, and the verb form and passive voice of the relationship in the triple to be processed, so as to obtain the second description information.
[0191] Optionally, in some embodiments, the triple to be processed includes: entity - relationship - entity; the processing unit 303 is configured to:
[0192] According to the target description information, update the description knowledge of the entities and the description knowledge of the relationship in the triple to be processed respectively;
[0193] According to the updated description knowledge of the entities, update the relationship structure between the entities in multiple triples to be processed;
[0194] Based on the updated description knowledge of the entities, the updated description knowledge of the relationship, and the updated relationship structure, perform data augmentation processing on the original knowledge graph.
[0195] Optionally, in some embodiments, when updating the relationship structure between the entities in multiple triples to be processed according to the updated description knowledge of the entities, the processing unit 303 is configured to:
[0196] Determine the matching degree between the entities in multiple triples to be processed according to the updated description knowledge of the entities;
[0197] Obtain at least one pair of matching target entity pairs according to the matching degree;
[0198] Establish the association relationship between the entities in the target entity pair, and construct a new target triple based on the association relationship and the target entity pair;
[0199] Based on the target triple, update the relationship structure of the entities among multiple triples to be processed.
[0200] Optionally, in some embodiments, when determining the matching degree of the entities among multiple triples to be processed according to the descriptive knowledge of the updated entities, the processing unit 303 is specifically configured to:
[0201] Extract multiple keywords from the descriptive knowledge of the updated entities to obtain multiple keywords corresponding to each entity in the triple to be processed;
[0202] Based on the multiple keywords corresponding to each entity, calculate the matching degree of the entities among multiple triples to be processed.
[0203] Optionally, in some embodiments, when constructing a new target triple based on the association relationship and the target entity pair, the processing unit 303 is specifically configured to:
[0204] Obtain the entity types corresponding to the two entities in the target entity pair respectively;
[0205] Generate the descriptive knowledge of the association relationship according to the entity types corresponding to the two entities respectively;
[0206] Construct a new target triple according to the association relationship, the descriptive knowledge of the association relationship and the target entity pair.
[0207] Optionally, in some embodiments, the device further includes:
[0208] An extraction unit, configured to extract multiple triples from the knowledge graph after data augmentation processing of the original knowledge graph according to the target description information, where the triple includes: head entity - relationship - tail entity;
[0209] A construction unit, configured to determine the head entity and the relationship between the head entity and the tail entity as training data, and determine the tail entity as the label corresponding to the training data, and construct a training set;
[0210] A training unit, configured to train a basic knowledge graph completion model based on the training set to obtain a target knowledge graph completion model.
[0211] As can be seen from the above, the knowledge graph enhancement device provided in the embodiment of the present application obtains multiple triples to be processed from the original knowledge graph, generates target description information of the triples to be processed in multiple different dimensions based on the pre-trained large language model, and performs data enhancement processing on the original knowledge graph according to the target description information to obtain the knowledge graph after data enhancement. In this solution, the reasoning, interpretation and summarization capabilities of the large language model are used to prompt the large language model to generate auxiliary text, improve the knowledge graph data from multiple different dimensions, thereby mining more potential but missing knowledge and achieving the effect of knowledge graph completion.
[0212] The present application also provides an electronic device, such as Figure 8 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:
[0213] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0214] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.
[0215] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and knowledge graph enhancement by running the software programs and modules stored in the memory 402. The memory 402 mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the electronic device. In addition, the memory 402 can include high-speed random access memory and can also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices. Correspondingly, the memory 402 can also include a memory controller to provide the processor 401 with access to the memory 402.
[0216] The electronic device further includes a power supply 403 for powering each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 403 can also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0217] The electronic device may further include an input unit 404, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0218] Although not shown, the electronic device may further include a display unit, etc., which will not be elaborated here. Specifically, in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402 to implement various functions as follows:
[0219] Obtain multiple triples to be processed from the original knowledge graph; generate target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model; perform data enhancement processing on the original knowledge graph according to the target description information to obtain a data-enhanced knowledge graph.
[0220] In one implementation, when generating the target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model, the processor 401 is specifically configured to: for each triple to be processed, query the large language model based on a preset prompt word strategy in multiple different dimensions to obtain the target description information of the triple to be processed in each dimension.
[0221] In one embodiment, when, for each of the triples to be processed, the large language model is queried based on the preset prompting word strategies in multiple different dimensions to obtain the target description information of the triple to be processed in each dimension, the processor 401 is specifically configured to: for each of the triples to be processed, query the large language model based on the preset prompting word strategy in the entity description dimension to obtain the first description information of the triple to be processed in the entity description dimension; for each of the triples to be processed, query the large language model based on the preset prompting word strategy in the relationship description dimension to obtain the second description information of the triple to be processed in the relationship description dimension; and determine the target description information according to the first description information and the second description information.
[0222] In one embodiment, when querying the large language model based on the preset prompting word strategy in the relationship description dimension to obtain the second description information of the triple to be processed in the relationship description dimension, the processor 401 is specifically configured to: query the large language model based on the preset prompting word strategy in the relationship description dimension to obtain the first semantic information of the relationship in the original knowledge graph in the triple to be processed, the second semantic information of the relationship in the triple to be processed, and the verb form and passive voice of the relationship in the triple to be processed, so as to obtain the second description information.
[0223] In one embodiment, the triple to be processed includes: entity - relationship - entity; when performing data augmentation processing on the original knowledge graph according to the target description information to obtain the knowledge graph after data augmentation, the processor 401 is specifically configured to: update the description knowledge of the entity and the description knowledge of the relationship in the triple to be processed respectively according to the target description information; update the relationship structure between the entities in multiple triples to be processed according to the updated description knowledge of the entity; and perform data augmentation processing on the original knowledge graph based on the updated description knowledge of the entity, the updated description knowledge of the relationship, and the updated relationship structure.
[0224] In one embodiment, when updating the relationship structure between the entities in multiple triples to be processed according to the updated description knowledge of the entity, the processor 401 is specifically configured to: determine the matching degree between the entities in multiple triples to be processed according to the updated description knowledge of the entity; obtain at least one pair of matching target entity pairs according to the matching degree; establish the association relationship between the entities in the target entity pairs, and construct new target triples based on the association relationship and the target entity pairs; and update the relationship structure between the entities in multiple triples to be processed based on the target triples.
[0225] In one embodiment, when determining the matching degree of entities between multiple triples to be processed according to the description knowledge of the updated entity, the processor 401 is specifically configured to: extract multiple keywords from the description knowledge of the updated entity to obtain multiple keywords corresponding to each entity in the triple to be processed; calculate the matching degree of entities between multiple triples to be processed based on the multiple keywords corresponding to each entity.
[0226] In one embodiment, when constructing a new target triple based on the association relationship and the target entity pair, the processor 401 is specifically configured to: obtain the entity types corresponding to the two entities in the target entity pair respectively; generate the description knowledge of the association relationship according to the entity types corresponding to the two entities respectively; construct a new target triple according to the association relationship, the description knowledge of the association relationship and the target entity pair.
[0227] In one embodiment, after performing data augmentation processing on the original knowledge graph according to the target description information to obtain a data-augmented knowledge graph, the processor 401 may further be configured to: extract multiple triples from the data-augmented knowledge graph, where the triple includes: head entity - relationship - tail entity; determine the head entity and the relationship between the head entity and the tail entity as training data, and determine the tail entity as the label corresponding to the training data to construct a training set; train a basic knowledge graph completion model based on the training set to obtain a target knowledge graph completion model.
[0228] For the specific implementation of each of the above operations, reference may be made to the previous embodiments, which will not be elaborated here.
[0229] As can be seen from the above, in the embodiments of the present application, the electronic device obtains multiple triples to be processed from the original knowledge graph, then generates target description information of the triples to be processed in multiple different dimensions based on a pre-trained large language model, and performs data augmentation processing on the original knowledge graph according to the target description information to obtain a data-augmented knowledge graph. In this solution, by utilizing the reasoning, interpretation, and summarization capabilities of the large language model, the large language model is prompted to generate auxiliary text to improve the knowledge graph data from multiple different dimensions, thereby mining more potential but missing knowledge and achieving the effect of knowledge graph completion.
[0230] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions or by controlling related hardware through instructions. The instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0231] To this end, an embodiment of the present application provides a computer-readable storage medium storing multiple instructions that can be loaded by a processor to execute the steps in any of the knowledge graph enhancement methods provided by the embodiments of the present application. For example, the instructions can perform the following steps:
[0232] Obtain multiple triples to be processed from the original knowledge graph; generate target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model; perform data enhancement processing on the original knowledge graph according to the target description information to obtain an enhanced knowledge graph.
[0233] For the specific implementation of each of the above operations, reference can be made to the previous embodiments and will not be elaborated here.
[0234] Among them, the computer-readable storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.
[0235] Since the instructions stored in the computer-readable storage medium can execute the steps in any of the knowledge graph enhancement methods provided by the embodiments of the present application, the beneficial effects achievable by any of the knowledge graph enhancement methods provided by the embodiments of the present application can be realized. For details, reference can be made to the previous embodiments and will not be elaborated here.
[0236] Among them, according to one aspect of the present application, a computer program product or a computer program is provided. The computer program product or the computer program includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to enable the computer device to execute the methods provided in various alternative implementation manners of the above knowledge graph enhancement aspect.
[0237] The above has introduced in detail a knowledge graph enhancement method, device, electronic device, computer-readable storage medium, and computer program product based on a large language model provided by the embodiments of the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A method for enhancing a knowledge graph based on a large language model, characterized in that, Including: Obtain multiple triples to be processed from the original knowledge graph; Generate target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model; Perform data augmentation processing on the original knowledge graph according to the target description information to obtain an enhanced knowledge graph.
2. The knowledge graph enhancement method according to claim 1, wherein The step of generating target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model includes: For each triple to be processed, query the large language model based on preset prompting strategies in multiple different dimensions to obtain the target description information of the triple to be processed in each dimension.
3. The knowledge graph enhancement method according to claim 2, characterized in that The step of querying the large language model based on preset prompting strategies in multiple different dimensions for each triple to be processed to obtain the target description information of the triple to be processed in each dimension includes: For each triple to be processed, query the large language model based on the preset prompting strategy in the entity description dimension to obtain the first description information of the triple to be processed in the entity description dimension; For each triple to be processed, query the large language model based on the preset prompting strategy in the relationship description dimension to obtain the second description information of the triple to be processed in the relationship description dimension; Determine the target description information according to the first description information and the second description information.
4. The knowledge graph enhancement method according to claim 3, wherein The step of querying the large language model based on the preset prompting strategy in the relationship description dimension to obtain the second description information of the triple to be processed in the relationship description dimension includes: Query the large language model based on the preset prompting strategy in the relationship description dimension to obtain the first semantic information of the relationship in the original knowledge graph of the triple to be processed, the second semantic information of the relationship in the triple to be processed, and the verb form and passive voice of the relationship in the triple to be processed, so as to obtain the second description information.
5. The knowledge graph enhancement method according to claim 1, characterized in that The triple to be processed includes: entity - relationship - entity; the step of performing data augmentation processing on the original knowledge graph according to the target description information to obtain an enhanced knowledge graph includes: Update the description knowledge of the entities and the description knowledge of the relationships in the triples to be processed respectively according to the target description information; Update the relationship structure of the entities among the multiple triples to be processed according to the updated description knowledge of the entities; Perform data augmentation processing on the original knowledge graph based on the updated description knowledge of the entities, the updated description knowledge of the relationships, and the updated relationship structure.
6. The knowledge graph enhancement method according to claim 5, characterized in that The step of updating the relationship structure of the entities among the multiple triples to be processed according to the updated description knowledge of the entities includes: Determine the matching degree of the entities among the multiple triples to be processed according to the updated description knowledge of the entities; Obtain at least one pair of matching target entity pairs according to the matching degree; Establish the association relationship between the entities in the target entity pair, and construct a new target triple based on the association relationship and the target entity pair. Update the relationship structure of entities among multiple triples to be processed based on the target triple.
7. The knowledge graph enhancement method according to claim 6, wherein Determine the matching degree of entities among multiple triples to be processed according to the description knowledge of the updated entities, including: Extract multiple keywords from the description knowledge of the updated entities to obtain multiple keywords corresponding to each entity in the triple to be processed; Calculate the matching degree of entities among multiple triples to be processed based on the multiple keywords corresponding to each entity.
8. The knowledge graph enhancement method according to claim 7, wherein Construct a new target triple based on the association relationship and the target entity pair, including: Obtain the entity types corresponding to the two entities in the target entity pair respectively; Generate the description knowledge of the association relationship according to the entity types corresponding to the two entities respectively; Construct a new target triple according to the association relationship, the description knowledge of the association relationship, and the target entity pair.
9. The knowledge graph enhancement method according to claim 1, wherein After performing data augmentation processing on the original knowledge graph according to the target description information to obtain a data-augmented knowledge graph, it further includes: Extract multiple triples from the data-augmented knowledge graph, where the triple includes: head entity - relationship - tail entity; Determine the head entity and the relationship between the head entity and the tail entity as training data, and determine the tail entity as the label corresponding to the training data to construct a training set; Train the basic knowledge graph completion model based on the training set to obtain a target knowledge graph completion model.
10. A knowledge graph enhancement device based on a large language model, characterized in that, It includes: An acquisition unit for acquiring multiple triples to be processed from the original knowledge graph; A generation unit for generating target description information of the triples to be processed in multiple different dimensions through a pre-trained large language model; A processing unit for performing data augmentation processing on the original knowledge graph according to the target description information to obtain a data-augmented knowledge graph.
11. The knowledge graph enhancement device according to claim 10, wherein The generation unit is used for: For each triple to be processed, query the large language model based on a preset prompting word strategy in multiple different dimensions to obtain the target description information of the triple to be processed in each dimension.
12. The knowledge graph enhancement device according to claim 10, wherein The triple to be processed includes: entity - relationship - entity; the processing unit is used for: Update the description knowledge of the entities and the description knowledge of the relationship in the triple to be processed respectively according to the target description information; Update the relationship structure of entities among multiple triples to be processed according to the description knowledge of the updated entities; Perform data augmentation processing on the original knowledge graph based on the description knowledge of the updated entities, the description knowledge of the updated relationship, and the updated relationship structure.
13. An electronic device, characterized in that, It includes a processor and a memory, the memory stores an application program, and the processor is used to run the application program in the memory to execute the steps in the knowledge graph enhancement method according to any one of claims 1-9.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the knowledge graph enhancement method according to any one of claims 1-9.
15. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instruction is executed by a processor, it implements the steps in the knowledge graph enhancement method according to any one of claims 1-9.