Knowledge graph optimization method and device, electronic device and storage medium
By generating entity similarity and confidence through a large language model, merging entities of the same type and deleting triplets with low credibility, the knowledge graph structure is optimized, solving the problems of large noise influence and high computational cost in the knowledge graph, and achieving efficient knowledge graph optimization.
Patent Information
- Application Number
- CN202410599900.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-15
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2044-05-15
AI Technical Summary
Existing knowledge graph optimization methods are greatly affected by noise when faced with overly long query paths, resulting in reduced model prediction accuracy, high computational costs, and low manual calibration efficiency.
Generate entity similarity and confidence through a large language model, merge entities of the same type, delete triplets with low credibility, and optimize the knowledge graph structure.
It improves the optimization efficiency of knowledge graphs, reduces the impact of noise on model performance, reduces computational complexity, and improves query and training efficiency.
Smart Images

Figure CN118536584B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a knowledge graph optimization method and device, an electronic device, and a storage medium. Background Art
[0002] In recent years, the rapid development of knowledge graph technology and large language models, such as GPT, has demonstrated tremendous potential in diverse scientific fields, including biology, healthcare, and physics. By integrating existing knowledge, knowledge graphs not only derive new knowledge points but also enable queries using abstract logical expressions, enabling deep relational reasoning and a high degree of interpretability. In specific fields, such as biology, this technology offers new solutions for addressing the lack of direct relational data. Furthermore, the development of large language models has significantly promoted innovation in human-computer interaction, enabling users to interact with machines in natural language and receive accurate and relevant responses. These models not only excel in language processing but also assist in knowledge graph construction and reasoning by parsing unstructured data, such as natural language. This provides new perspectives and methods for knowledge reasoning and discovery within scientific fields.
[0003] The emergence of complex logical query technology for knowledge graphs has overcome the limitation of knowledge graph completion tasks, which can only predict known relationships. It enables long-path reasoning between arbitrary entity types in the knowledge graph, making it possible to further mine implicit knowledge. However, excessively long query paths amplify the impact of knowledge graph noise on model performance, inevitably leading to a decrease in model prediction accuracy and a significant increase in computational costs. Manual calibration is time-consuming for large knowledge graphs, resulting in low efficiency in knowledge graph optimization. Summary of the Invention
[0004] The main purpose of the embodiments of this application is to propose a knowledge graph optimization method and device, electronic device and storage medium, aiming to improve the optimization efficiency of the knowledge graph and reduce the impact of knowledge graph noise on model performance.
[0005] To achieve the above objectives, the first aspect of the embodiments of the present application proposes a knowledge graph optimization method based on a large language model, the method comprising:
[0006] Inputting a first question about a first entity and a second question about a second entity into the large language model to obtain a first semantic description and a second semantic description, respectively; wherein the first entity and the second entity are nodes in a knowledge graph;
[0007] determining a first similarity between the first entity and the second entity based on the first semantic description and the second semantic description;
[0008] Obtaining a triple to be checked from the knowledge graph;
[0009] Generate a head entity semantic representation, a head entity structural representation, a tail entity semantic representation, a tail entity structural representation, and a relationship representation based on the head entity, the tail entity, and the entity relationship between the head entity and the tail entity contained in the triple to be checked;
[0010] Determining the confidence of the to-be-checked triple according to the head entity semantic representation, the head entity structural representation, the tail entity semantic representation, the tail entity structural representation, and the relationship representation;
[0011] The first entity and the second entity corresponding to the knowledge graph are merged according to the first similarity, and the target relationship link corresponding to the corresponding triple to be checked in the knowledge graph is updated according to the confidence to obtain a target knowledge graph.
[0012] In some embodiments, determining a first similarity between the first entity and the second entity based on the first semantic description and the second semantic description includes:
[0013] Performing embedding representation processing on the first semantic description and the second semantic description respectively to obtain a first entity semantic representation and a second entity semantic representation;
[0014] A cosine similarity calculation is performed on the first entity semantic representation and the second entity semantic representation to obtain the first similarity between the first entity and the second entity.
[0015] In some embodiments, performing entity merging processing on the first entity and the second entity corresponding to the first entity in the knowledge graph according to the first similarity includes:
[0016] Obtaining a preset first threshold; wherein the first threshold represents a critical value for determining that entities corresponding to two entity semantic representations are entities of the same type;
[0017] When the first similarity is greater than or equal to the first threshold, merging the first entity and the second entity to form a merged entity, and determining a relationship link of the merged entity based on the relationship link between the first entity and the second entity;
[0018] Update the data structure of the knowledge graph based on the relationship links of the merged entities.
[0019] In some embodiments, generating a head entity semantic representation, a head entity structural representation, a tail entity semantic representation, a tail entity structural representation, and a relationship representation based on a head entity, a tail entity, and an entity relationship between the head entity and the tail entity contained in the triple to be checked includes:
[0020] Performing embedding representation processing on the head entity, entity relationship, and tail entity of the triple to be checked, respectively, to obtain the head entity semantic representation, tail entity semantic representation, and relationship representation;
[0021] Acquire a first neighboring entity of the head entity and a second neighboring entity of the tail entity;
[0022] Obtaining a first neighborhood semantic representation and a first neighborhood relationship representation based on a triple consisting of the head entity and the first neighborhood entity, and obtaining a second neighborhood semantic representation and a second neighborhood relationship representation based on a triple consisting of the tail entity and the second neighborhood entity;
[0023] The first neighborhood semantic representation and the first neighborhood relationship representation are aggregated to determine the head entity structure representation, and the second neighborhood semantic representation and the second neighborhood relationship representation are aggregated to determine the tail entity structure representation.
[0024] In some embodiments, determining the confidence of the triple to be checked based on the head entity semantic representation, the head entity structural representation, the tail entity semantic representation, the tail entity structural representation, and the relationship representation includes:
[0025] Calculating a head entity aggregate representation based on the head entity semantic representation and the relationship representation, and calculating a tail entity aggregate representation based on the tail entity semantic representation and the relationship representation;
[0026] Obtaining a second similarity based on the head entity aggregation representation and the tail entity structure representation;
[0027] Obtaining a third similarity based on the tail entity aggregation representation and the head entity structure representation;
[0028] The confidence level of the to-be-checked triple is determined according to the second similarity and the third similarity.
[0029] In some embodiments, determining the confidence level of the to-be-checked triplet based on the second similarity and the third similarity includes:
[0030] Obtaining a preset first weight and a second weight;
[0031] The confidence level of the to-be-checked triple is determined according to the product of the first weight and the second similarity, and the product of the second weight and the third similarity.
[0032] In some embodiments, updating the target relationship link corresponding to the triple to be checked in the knowledge graph according to the confidence level includes:
[0033] Obtaining a preset second threshold; wherein the second threshold represents a critical value for the triple to be checked to be a credible triple;
[0034] When the confidence level is less than the second threshold, the relationship link of the triple to be checked in the knowledge graph is deleted, and the data structure of the knowledge graph is updated.
[0035] In some embodiments, after the step of obtaining the target knowledge graph, the method further includes:
[0036] Performing initial training on a preset graph model according to the triples in the target knowledge graph to obtain an initial graph model;
[0037] Obtain the training head entity fuzzy set and training multi-hop query path;
[0038] Converting the training multi-hop query path into a training logical expression, and inputting the training head entity fuzzy set and the training logical expression into a logical query model based on the initial graph model to obtain a training tail entity fuzzy set;
[0039] A first training loss is determined based on the training tail entity fuzzy set and the training true value set, and parameters of the logical query model are adjusted based on the first training loss until the first training loss meets a preset condition, thereby obtaining the target logical query model.
[0040] In some embodiments, the initial training of a preset graph model based on the triples in the target knowledge graph to obtain the initial graph model includes:
[0041] Obtaining training triples from the target knowledge graph;
[0042] Inputting the head entity and entity relationship of the training triple into a preset graph model to obtain a training tail entity, inputting the head entity and tail entity of the training triple into the preset graph model to obtain a training entity relationship, and inputting the entity relationship and tail entity of the training triple into the preset graph model to obtain a training head entity;
[0043] A second training loss is determined based on the training triples, the training head entity, the training entity relationship, and the training tail entity, and the parameters of the preset graphical model are preliminarily adjusted based on the second training loss until the second training loss meets a preset condition to obtain an initial graphical model.
[0044] To achieve the above objectives, a third aspect of the embodiments of the present application proposes a knowledge graph optimization device based on a large language model, the device comprising:
[0045] An input unit, configured to input a first question about a first entity and a second question about a second entity into the large language model to obtain a first semantic description and a second semantic description, respectively; wherein the first entity and the second entity are nodes in a knowledge graph;
[0046] a first calculating unit, configured to determine a first similarity between the first entity and the second entity based on the first semantic description and the second semantic description;
[0047] An acquisition unit, configured to acquire a triple to be checked from the knowledge graph;
[0048] a conversion unit, configured to generate a head entity semantic representation, a head entity structural representation, a tail entity semantic representation, a tail entity structural representation, and a relationship representation based on a head entity, a tail entity, and an entity relationship between the head entity and the tail entity contained in the triple to be checked;
[0049] a second computing unit, configured to determine the confidence of the to-be-checked triple based on the head entity semantic representation, the head entity structural representation, the tail entity structural representation, the tail entity structural representation, and the relationship representation;
[0050] An optimization unit is used to perform entity merging processing on the first entity and the second entity corresponding to the knowledge graph according to the first similarity, and to update the target relationship link corresponding to the corresponding triple to be checked in the knowledge graph according to the confidence level to obtain a target knowledge graph.
[0051] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the method described in the first aspect when executing the computer program.
[0052] To achieve the above-mentioned purpose, the fourth aspect of the embodiments of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the method described in the first aspect.
[0053] The knowledge graph optimization method and device, electronic device and storage medium based on the large language model proposed in the present application collect entity information in the knowledge graph and generate corresponding questions for each entity, input the first question of the first entity and the second question of the second entity into the large language model, and obtain a first semantic description and a second semantic description respectively. By comparing the first semantic description and the second semantic description, a first similarity between the two is generated, and the first similarity can directly reflect the degree of similarity between the first entity and the second entity. If the similarity between the first entity and the second entity is high, the first entity and the second entity can be merged to optimize the knowledge graph; on the other hand, a triple to be checked is obtained from the knowledge graph, and a head entity semantic representation, a head entity structural representation, a tail entity semantic representation, a tail entity structural representation and a relationship representation are generated from the head entity, the relationship and the tail entity of the triple to be checked. These representations can be vectors, matrices or other forms, and the confidence of the triple to be checked is calculated by the above five representations. The credibility of the triple to be checked can be reflected from the confidence, thereby optimizing the relationship link of the knowledge graph and finally obtaining the target knowledge graph. By merging entities of the same type and optimizing triples with lower credibility, the optimization efficiency of the knowledge graph is improved, the impact of knowledge graph noise on model performance is reduced, the complexity of the knowledge graph is reduced, and the query and training efficiency is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 This is a flow chart of the knowledge graph optimization method based on a large language model provided in an embodiment of the present application;
[0055] Figure 2 yes Figure 1 Flowchart of step S120 in FIG.
[0056] Figure 3 yes Figure 1 Flowchart of step S160 in FIG.
[0057] Figure 4 yes Figure 1 Flowchart of step S140 in FIG.
[0058] Figure 5 yes Figure 1 Flowchart of step S150 in FIG.
[0059] Figure 6 yes Figure 5 Flowchart of step S540 in FIG.
[0060] Figure 7 yes Figure 1 Flowchart of step S160 in FIG.
[0061] Figure 8 yes Figure 1 Flowchart after step S160 in FIG.
[0062] Figure 9 yes Figure 8 Flowchart of step S810 in FIG.
[0063] Figure 10 This is a schematic diagram of the structure of a knowledge graph optimization device based on a large language model provided in an embodiment of the present application;
[0064] Figure 11 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0066] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. The terms "first," "second," and so on, in the specification, claims, and drawings, are used to distinguish similar items and are not necessarily used to describe a specific sequence or precedence.
[0067] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0068] First, let’s analyze some of the terms used in this application:
[0069] Artificial intelligence (AI) is a new technical discipline that studies and develops theories, methods, technologies, and application systems for simulating, extending, and expanding human intelligence. A branch of computer science, AI seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing, and expert systems. AI can simulate the information processes of human consciousness and thinking. It also encompasses the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results.
[0070] Natural language processing (NLP): NLP uses computers to process, understand, and apply human languages (such as Chinese and English). NLP is a branch of artificial intelligence and an interdisciplinary subject between computer science and linguistics, often referred to as computational linguistics. Natural language processing includes grammatical analysis, semantic analysis, and discourse understanding. Natural language processing is commonly used in technical fields such as machine translation, handwritten and printed character recognition, speech recognition and text-to-speech conversion, information intent recognition, information extraction and filtering, text classification and clustering, public opinion analysis, and opinion mining. It involves data mining related to language processing, machine learning, knowledge acquisition, knowledge engineering, artificial intelligence research, and linguistic research related to language computing.
[0071] Large Language Model (LLM): A deep learning model trained on massive amounts of text data. It not only generates natural language text but also deeply understands the meaning of the text and can handle various natural language tasks such as text summarization, question answering, and translation.
[0072] Knowledge Graph: Known as knowledge domain visualization or knowledge domain mapping map in the library and information science community, it is a series of various graphs that show the development process and structural relationship of knowledge. It uses visualization technology to describe knowledge resources and their carriers, and to mine, analyze, construct, draw and display knowledge and their interrelationships.
[0073] A triple is typically composed of three elements: a head entity, a relation, and a tail entity. The relationship between them can be expressed as: head entity-relationship-tail entity. Triples in a knowledge graph are the foundation of the entire knowledge graph. Using large amounts of triple data, we can construct a vast and complex knowledge network, enabling a comprehensive description and understanding of various entities and relationships in the real world.
[0074] The BERT model (Bidirectional Encoder Representations from Transformers) is a pre-trained language model based on the Transformer architecture. It captures deep bidirectional representations of language through pre-training on large-scale text data, and then fine-tunes it for different natural language processing tasks. The BERT model has a wide range of applications in natural language processing, providing a powerful pre-trained model foundation for various language understanding tasks.
[0075] The CompGCN model (Composition-Based Multi-Relational Graph Convolutional Networks) is a neural network model specifically designed for processing graph-structured data, specifically a heterogeneous graph representation algorithm for multi-relational graphs. It combines graph convolutional networks (GCNs) with knowledge graph embedding technology to embed nodes and relationships into a relational graph. The CompGCN model is capable of learning representations of nodes and relationships and has achieved remarkable results in node classification, link prediction, and graph classification tasks. In CompGCN, each molecule is represented as a graph with atoms as nodes and chemical bonds as edges. Through multi-layer information transfer, GCN can learn high-level representations of nodes, thereby capturing the overall characteristics of the molecule.
[0076] In recent years, the rapid development of knowledge graph technology and large language models, such as GPT, has demonstrated tremendous potential in diverse scientific fields, including biology, healthcare, and physics. By integrating existing knowledge, knowledge graphs not only derive new knowledge points but also enable queries using abstract logical expressions, enabling deep relational reasoning and a high degree of interpretability. In specific fields, such as biology, this technology offers new solutions for addressing the lack of direct relational data. Furthermore, the development of large language models has significantly promoted innovation in human-computer interaction, enabling users to interact with machines in natural language and receive accurate and relevant responses. These models not only excel in language processing but also assist in knowledge graph construction and reasoning by parsing unstructured data, such as natural language. This provides new perspectives and methods for knowledge reasoning and discovery within scientific fields.
[0077] The emergence of complex logical query technology for knowledge graphs has overcome the limitation of knowledge graph completion tasks, which can only predict known relationships. It enables long-path reasoning between arbitrary entity types in the knowledge graph, making it possible to further mine implicit knowledge. However, excessively long query paths amplify the impact of knowledge graph noise on model performance, inevitably leading to a decrease in model prediction accuracy and a significant increase in computational costs. Manual calibration is time-consuming for large knowledge graphs, resulting in low efficiency in knowledge graph optimization.
[0078] Based on this, the embodiments of the present application provide a knowledge graph optimization method and device, an electronic device and a storage medium, aiming to improve the optimization efficiency of the knowledge graph and reduce the impact of knowledge graph noise on model performance.
[0079] The knowledge graph optimization method and the training method of the large language model provided in the embodiments of the present application relate to the field of artificial intelligence technology. The knowledge graph optimization method and the training method of the large language model provided in the embodiments of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the knowledge graph optimization method and the training method of the large language model, etc., but is not limited to the above forms.
[0080] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0081] It should be noted that in each specific embodiment of the present application, when it comes to the need to perform relevant processing based on data related to the user's identity or characteristics, such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of such data will comply with the relevant laws, regulations, and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0082] Figure 1 This is an optional flowchart of the knowledge graph optimization method provided in the embodiment of the present application. Figure 1The method may include but is not limited to steps S110 to S160.
[0083] Step S110: Input a first question about the first entity and a second question about the second entity into the large language model to obtain a first semantic description and a second semantic description respectively; wherein the first entity and the second entity are nodes in the knowledge graph.
[0084] Step S120: determining a first similarity between the first entity and the second entity according to the first semantic description and the second semantic description.
[0085] Step S130: Obtain the triples to be checked from the knowledge graph.
[0086] Step S140: Generate a head entity semantic representation, a head entity structural representation, a tail entity semantic representation, a tail entity structural representation and a relationship representation according to the head entity, the tail entity and the entity relationship between the head entity and the tail entity contained in the triple to be checked.
[0087] Step S150: Determine the confidence level of the triple to be checked based on the head entity semantic representation, the head entity structural representation, the tail entity semantic representation, the tail entity structural representation, and the relationship representation.
[0088] Step S160: Perform entity merging processing on the corresponding first entity and second entity in the knowledge graph according to the first similarity, and update the target relationship link corresponding to the corresponding triple to be checked in the knowledge graph according to the confidence to obtain the target knowledge graph.
[0089] In steps S110 to S160 shown in the embodiment of the present application, by collecting entity information in the knowledge graph and generating corresponding questions for each entity, the first question of the first entity and the second question of the second entity are input into the large language model to obtain a first semantic description and a second semantic description respectively, and by comparing the first semantic description and the second semantic description, a first similarity between the two is generated. The first similarity can directly reflect the degree of similarity between the first entity and the second entity. If the similarity between the first entity and the second entity is high, the first entity and the second entity can be merged to optimize the knowledge graph; on the other hand, the triple to be checked is obtained from the knowledge graph, and the head entity semantic representation, head entity structural representation, tail entity semantic representation, tail entity structural representation and relationship representation are generated from the head entity, relationship and tail entity of the triple to be checked. These representations can be vectors, matrices or other forms, and the confidence of the triple to be checked is calculated by the above five representations. The credibility of the triple to be checked can be reflected from the confidence, thereby optimizing the relationship link of the knowledge graph and finally obtaining the target knowledge graph. By merging entities of the same type and optimizing triples with lower credibility, the optimization efficiency of the knowledge graph is improved, the impact of knowledge graph noise on model performance is reduced, the complexity of the knowledge graph is reduced, and the query and training efficiency is improved.
[0090] In step S110 of some embodiments, the first question and the second question can be input texts directly provided by the user, and the user can conceive and input the questions or texts they want the model to answer. Questions can also be generated by a specific method or algorithm, such as using a preset semantic similarity retrieval algorithm to perform a similar text search on the initial question text input by the user to obtain a corresponding similar text set, and then using a preset policy gradient algorithm to train the policy network to obtain a trained policy network, and finally determining the most semantically relevant question text corresponding to the initial question text from the similar text set, but the present application is not limited to this. For example, the medicinal material Panax notoginseng has many aliases such as blood ginseng, Panax notoginseng, and Coptis chinensis. The first entity is Panax notoginseng, and the second entity is Panax notoginseng. The first question "Can you give a detailed introduction to the medicinal effects and usage of Panax notoginseng?" and the second question "Can you give a detailed introduction to the medicinal effects and usage of Panax notoginseng?" are generated.
[0091] See also Figure 2 In some embodiments, step S120 may include but is not limited to the following steps:
[0092] Step S210 : performing embedding representation processing on the first semantic description and the second semantic description respectively to obtain a first entity semantic representation and a second entity semantic representation.
[0093] Step S220 , performing cosine similarity calculation on the first entity semantic representation and the second entity semantic representation to obtain a first similarity between the first entity and the second entity.
[0094] In step S210, the generated first semantic description and second semantic description are input into the pre-trained BERT model for embedding representation processing, which converts each word into a vector representation of a fixed dimension while also considering the position information of the word in the sentence, thereby converting the first semantic description and the second phonetic description in text form into the first entity semantic representation and the second entity semantic representation such as a vector or matrix representation.
[0095] In step S220, a cosine similarity calculation is performed on the first entity semantic representation and the second entity semantic representation. Specifically, a first similarity between the first entity and the second entity is calculated according to the following formula:
[0096] ;
[0097] In the formula, A represents the semantic representation of the first entity, B represents the semantic representation of the second entity, and cossimilarity(A,B) represents the cosine similarity between A and B. The cosine similarity can reflect the similarity between the first entity and the second entity.
[0098] See also Figure 3 In some embodiments, the step of optimizing the knowledge graph according to the first similarity in step S160 may include but is not limited to the following steps:
[0099] Step S310: Obtain a preset first threshold; wherein the first threshold represents a critical value for determining that entities corresponding to two entity semantic representations are entities of the same type;
[0100] Step S320: When the first similarity is greater than or equal to a first threshold, the first entity and the second entity are merged to form a merged entity, and a relationship link of the merged entity is determined based on the relationship link between the first entity and the second entity;
[0101] Step S330: Update the data structure of the knowledge graph based on the relationship links of the merged entities.
[0102] In steps S310 to S330, a preset first threshold is obtained. When the first similarity is greater than or equal to the first threshold, the first entity and the second entity are considered to be entities of the same type. In an embodiment of the present application, the first threshold is 0.98, that is, when the first similarity cos similarity(A, B) ≥ 0.98, the first entity and the second entity are considered to be entities of the same type, and the attributes of the first entity and the second entity are merged, deduplicated and / or fused to form a merged entity. The merged entity can be one of the first entity or the second entity, which is not limited in this application. In a knowledge graph, each entity is usually connected to other entities through a relationship link. For example, if two entities share similar relationship links, these relationships can be retained and applied to the merged entity. If they have different relationship links, further analysis may be required to determine which relationships are the most important, and the relationship links of the merged entity are updated accordingly. The form of merging relationship links is not specifically limited in this application. The data structure of the knowledge graph is updated according to the relationship links of the merged entity, such as updating the attributes of the entity, deleting duplicate relationships, merging related nodes and edges, etc. In addition, after updating the data structure, consistency and integrity checks must be performed to ensure that the knowledge graph remains logically coherent and accurate.
[0103] See also Figure 4 In some embodiments, step S140 may include but is not limited to the following steps:
[0104] Step S410: performing embedding representation processing on the head entity, tail entity, and entity relationship of the triple to be checked, respectively, to obtain the semantic representation of the head entity, the semantic representation of the tail entity, and the relationship representation;
[0105] Step S420: Acquire the first neighboring entity of the head entity and the second neighboring entity of the tail entity;
[0106] Step S430: obtaining a first neighborhood semantic representation and a first neighborhood relationship representation based on the triple consisting of the head entity and the first neighborhood entity, and obtaining a second neighborhood semantic representation and a second neighborhood relationship representation based on the triple consisting of the tail entity and the second neighborhood entity;
[0107] Step S440: Aggregate the first neighborhood semantic representation and the first neighborhood relationship representation to determine a head entity structure representation, and aggregate the second neighborhood semantic representation and the second neighborhood relationship representation to determine a tail entity structure representation.
[0108] In step S410, the head entity, entity relationship and tail entity of the triple to be tested are respectively input into the pre-trained BERT model for embedding representation processing. The process of this step is similar to step S210, and finally the semantic representation of the head entity is obtained. , tail entity semantic representation and relational representation .
[0109] In steps S420 to S440, for the structural representation of entities, the CompGCN model is selected in this application, which improves the information transfer and aggregation process on the graph by introducing the combination operation of relations. At the same time, unlike traditional GNN models, information transfer and aggregation usually only consider the connections between nodes, while ignoring the type or nature of these connections. CompGCN overcomes this limitation by explicitly modeling the combination properties of relations, thereby improving the model's ability to process heterogeneous graphs. Specifically, in the message passing stage, each entity s in the graph will receive messages from its neighborhood N(t), and each entity in N(t) is connected to s with a specific relationship such as w. Then the message from entity t to s can be expressed as:
[0110] ;
[0111] ;
[0112] represents a combinatorial function (which could be vector addition, Hadamard product, or neural network), Semantic vector representation representing domain entities, A vector representation representing entity relationships, Represents the semantic vector representation of the original entity. For example, when calculating the head entity structure representation, is the semantic representation of the head entity, is the first domain semantic representation, is the first domain relationship representation; when calculating the tail entity structure representation, is the semantic representation of the tail entity, is the second domain semantic representation, Representation of the relationship in the second domain; is the activation function, and are the parameters of the aggregation stage, The entity structure representation captures the position, connection relationship and other structural information of the first entity in the knowledge graph, providing support for reasoning and analysis. Through the above steps, the head entity structure representation is calculated. and tail entity structure representation .
[0113] Please refer to Figure 5 In some embodiments, step S150 may include but is not limited to the following steps:
[0114] Step S510: Calculate a head entity aggregate representation based on the head entity semantic representation and the relationship representation, and calculate a tail entity aggregate representation based on the tail entity semantic representation and the relationship representation;
[0115] Step S520: Obtain a second similarity based on the head entity aggregation representation and the tail entity structure representation;
[0116] Step S530: Obtain a third similarity based on the tail entity aggregation representation and the head entity structure representation;
[0117] Step S540: Determine the confidence level of the triplet to be checked based on the second similarity and the third similarity.
[0118] In steps S510 to S540, the head entity structure representation and the tail entity structure representation take into account not only the characteristics of a single entity, but also the information of the related neighboring entities and relationships, which helps to more accurately evaluate the similarity between entities. The head entity aggregate representation and the tail entity aggregate representation focus on the information between single entities and relationships. In addition, by respectively calculating the second similarity between the head entity aggregate representation and the tail entity structure representation, and the third similarity between the tail entity aggregate representation and the head entity structure representation, a multi-angle evaluation of the similarity of the triples is provided, thereby confirming the confidence of the triples to be tested.
[0119] Please refer to Figure 6 In some embodiments, step S540 may include but is not limited to the following steps:
[0120] Step S610: Obtaining a preset first weight and a second weight;
[0121] Step S620: Determine the confidence level of the triplet to be checked based on the product of the first weight and the second similarity, and the product of the second weight and the third similarity.
[0122] In steps S610 to S620, the introduction of the first weight and the second weight provides additional flexibility and adjustability for the calculation of the confidence. The user can adjust the weight to reflect different importance or preferences according to different application scenarios or data set characteristics. The confidence is obtained by multiplying the second similarity and the third similarity by the corresponding weights and adding them together. The specific confidence formula is:
[0123] ;
[0124] In this embodiment, the sum of the first weight and the second weight is 1, that is, λ is the first weight, and correspondingly, (1-λ) is the second weight. is the aggregate representation of the head entity, It is the aggregation representation of the tail entity.
[0125] See also Figure 7 In some embodiments, the step of optimizing the knowledge graph according to the confidence level in step S160 may include but is not limited to the following steps:
[0126] Step S710: Obtain a preset second threshold; wherein the second threshold represents a critical value for determining whether the triple to be checked is a credible triple;
[0127] Step S720: When the confidence level is less than the second threshold, the relationship link of the triple to be checked in the knowledge graph is deleted, and the data structure of the knowledge graph is updated.
[0128] In step S710 to step S720, a preset second threshold is obtained. When the confidence is greater than or equal to the second threshold, the triple to be checked is considered to be a credible triple. When the confidence is less than the second threshold, the triple to be checked is considered to be an ambiguous triple, that is, the entity structure information and the entity semantic information cannot be interactively verified. For ambiguous triples, since the error of a triple may affect multiple paths, the noise is amplified during the training process, and the reasoning results are often contrary to objective facts. Therefore, it is necessary to delete or mark the relationship link of the triple in the knowledge graph, and update the data structure of the knowledge graph at the same time. Through the above steps, the triples with lower credibility can be optimized, the optimization efficiency of the knowledge graph is improved, and the impact of the knowledge graph noise on the model performance is reduced. For example, if the second threshold is 0.95 and the confidence is greater than or equal to 0.95, the triple to be checked is judged to be a credible triple. Otherwise, the triple to be checked is judged to be an ambiguous triple and the triple is adjusted.
[0129] Please refer to Figure 8 In some embodiments, step S160 may further include but is not limited to steps S810 to S840:
[0130] Step S810: Initially train the preset graph model according to the triples in the target knowledge graph to obtain an initial graph model;
[0131] Step S820: Obtain the training head entity fuzzy set and the training multi-hop query path;
[0132] Step S830: converting the training multi-hop query path into a training logical expression, and inputting the training head entity fuzzy set and the training logical expression into a logical query model based on the initial graph model to obtain a training tail entity fuzzy set;
[0133] Step S840: Determine a first training loss based on the training tail entity fuzzy set and the training true value set, and adjust the parameters of the logical query model based on the first training loss until the first training loss meets the preset conditions to obtain the target logical query model.
[0134] In steps S820 to S830, the accuracy and completeness of the knowledge graph are improved by optimizing the knowledge graph, providing a more reliable data foundation for subsequent logical reasoning and training processes. The multi-hop query path represents multiple paths from the head entity to the tail entity. Converting the training multi-hop query path into a training logical expression helps the model understand the relationship between entities. For example, the training multi-hop query path is , after being converted into a training logical expression, the training logical expression is , Represents the fuzzy set of the tail entity measured by the relation r1 and the fuzzy set u of the head entity. Based on the input training logical expression, we predict the fuzzy set of the tail entity according to the fuzzy set of the head entity x and the relation r. Specifically, the fuzzy set of the head entity in each round of training is aggregated with the relation embedding vector, and the aggregated vector is used as the entity representation for message passing. Unlike traditional message passing that is performed in the complete neighborhood, we split the neighborhood into multiple paths and only perform message passing in the corresponding paths. In the message aggregation stage, the node information of multiple paths is aggregated, and the vectors of the same nodes are averaged. Finally, the entity vector is passed to a two-layer fully connected network to generate a new fuzzy set as the head entity fuzzy set of the next relation. It is iterated multiple times to obtain the training tail entity fuzzy set (Note: A fuzzy set is a probability set, each element represents an independent probability between 0 and 1. The tail entity fuzzy set here is the tail entity probability set inferred from the head entity through the current path).
[0135] In step S840, the first training loss is calculated based on the loss training model by comparing the difference between the training tail entity fuzzy set and the training true value set. The graph model is iteratively trained and the parameters in the graph model are adjusted according to the first training loss until the first training loss meets the preset conditions. After the training is completed, complex logical queries can be performed by any head entity through a given path. The specific loss training model is:
[0136] ;
[0137] represents the true training set, represents the training tail entity fuzzy set, Represents the probability of i in the training tail entity fuzzy set.
[0138] It should be noted that, exemplarily, the initial graph model may be a CompLEX model, and the logical query model may be a GNN-QE model, which is not limited in this application.
[0139] Please refer to Figure 9 In some embodiments, step S810 further includes the following steps:
[0140] Step S910: Obtain training triples from the target knowledge graph;
[0141] Step S920: inputting the head entity and entity relationship of the training triple into the preset graph model to obtain the training tail entity, inputting the head entity and tail entity of the training triple into the preset graph model to obtain the training entity relationship, and inputting the entity relationship and tail entity of the training triple into the preset graph model to obtain the training head entity;
[0142] Step S930: Determine the second training loss based on the training triples, the training head entity, the training entity relationship, and the training tail entity, and preliminarily adjust the parameters of the preset graph model based on the second training loss until the second training loss meets the preset conditions to obtain the initial graph model.
[0143] Because complex logical queries require processing vast amounts of data, algorithms often only select a subset of paths for message passing to improve efficiency. This can reduce the accuracy of model predictions. Therefore, to improve model performance, we replaced the algorithm's random initialization of entity features with a pre-training process. The knowledge graph completion task was chosen as a pre-training task because it can fully capture the semantic and structural information of the graph.
[0144] In steps S910 to S930, the CompLEX model is used to perform a pre-training process on the pruned knowledge graph due to its high performance in the knowledge graph completion task. In order to more fully integrate the knowledge in the graph, we combine entity prediction and relationship prediction as training tasks. Unlike other methods, for the training triple (u, r, v), the goal of ComplEX is to combine any two of the three elements to predict the third one at the same time. That is, as mentioned in step S920, predict the tail entity v: obtain the training tail entity through the head entity and entity relationship of the training triple; predict the entity relationship r: obtain the training entity relationship through the head entity and tail entity of the training triple; predict the head entity u: obtain the training head entity through the entity relationship and tail entity of the training triple. According to the head entity and training head entity of the training triple, the entity relationship and training entity relationship of the training triple, and the tail entity and training tail entity of the training triple, the prediction probabilities of the three are calculated, and the sum of the three prediction probabilities is used as the second training loss. The second training loss is specifically: The parameters of the graph model are initially adjusted through the second training loss until the second training loss meets the preset conditions. After pre-training is completed, the representations of entities and relationships are extracted as the initial representations for the next complex logical query.
[0145] Specifically, its goal is to maximize the prediction probability of a combined optimization equation, which includes three tasks: predicting the head entity u, the tail entity v, and the relation r.
[0146] See also Figure 10 The present application also provides a knowledge graph optimization device 1000 based on a large language model, which can implement the above-mentioned knowledge graph optimization method based on a large language model. The device includes:
[0147] An input unit 1010 is configured to input a first question about a first entity and a second question about a second entity into the large language model to obtain a first semantic description and a second semantic description, respectively; wherein the first entity and the second entity are nodes in a knowledge graph;
[0148] A first calculation unit 1020 is configured to determine a first similarity between the first entity and the second entity based on the first semantic description and the second semantic description;
[0149] An acquisition unit 1030 is used to acquire a triple to be checked from the knowledge graph;
[0150] A conversion unit 1040 is configured to generate a semantic representation of the head entity, a structural representation of the head entity, a semantic representation of the tail entity, a structural representation of the tail entity, and a relationship representation based on the head entity, the tail entity, and the entity relationship between the head entity and the tail entity contained in the triple to be checked;
[0151] A second calculation unit 1050 is used to determine the confidence of the triple to be checked based on the semantic representation of the head entity, the structural representation of the head entity, the structural representation of the tail entity, the structural representation of the tail entity, and the relationship representation;
[0152] The optimization unit 1060 is used to perform entity merging processing on the corresponding first entity and second entity in the knowledge graph according to the first similarity, and to update the target relationship link corresponding to the corresponding triple to be checked in the knowledge graph according to the confidence level to obtain the target knowledge graph.
[0153] The specific implementation of the knowledge graph optimization device based on a large language model is basically the same as the specific embodiment of the knowledge graph optimization method based on a large language model mentioned above, and will not be repeated here.
[0154] The present application also provides an electronic device comprising a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned large language model-based knowledge graph optimization method. The electronic device can be any intelligent terminal, including a tablet computer and an in-vehicle computer.
[0155] See also Figure 11 , Figure 11 The hardware structure of an electronic device according to another embodiment is shown. The electronic device includes:
[0156] The processor 1101 can be implemented as a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0157] The memory 1102 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1102 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1102 and is called by the processor 1101 to execute the knowledge graph optimization method based on a large language model in the embodiments of this application.
[0158] Input / output interface 1103, used to implement information input and output;
[0159] Communication interface 1104, used to implement communication interaction between this device and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WiFi, Bluetooth, etc.);
[0160] Bus 1105 , which transmits information between various components of the device (e.g., processor 1101 , memory 1102 , input / output interface 1103 , and communication interface 1104 );
[0161] The processor 1101 , the memory 1102 , the input / output interface 1103 and the communication interface 1104 are connected to each other in communication within the device via a bus 1105 .
[0162] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned knowledge graph optimization method based on a large language model.
[0163] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0164] The embodiments of the present application provide a knowledge graph optimization method and device based on a large language model, an electronic device, and a storage medium. The method collects entity information in the knowledge graph and generates a corresponding question for each entity. The first question of the first entity and the second question of the second entity are input into the large language model to obtain a first semantic description and a second semantic description respectively. By comparing the first semantic description and the second semantic description, a first similarity between the two is generated. The first similarity can directly reflect the degree of similarity between the first entity and the second entity. If the similarity between the first entity and the second entity is high, the first entity and the second entity can be merged to optimize the knowledge graph. On the other hand, a triple to be checked is obtained from the knowledge graph, and a head entity semantic representation, a head entity structural representation, a tail entity semantic representation, a tail entity structural representation, and a relationship representation are generated from the head entity, the relationship, and the tail entity of the triple to be checked. These representations can be vectors, matrices, or other forms. The confidence of the triple to be checked is calculated through the above five representations. The credibility of the triple to be checked can be reflected from the confidence, thereby optimizing the relationship links of the knowledge graph. By merging entities of the same type and optimizing triples with lower credibility, the optimization efficiency of the knowledge graph is improved, the impact of knowledge graph noise on model performance is reduced, and the complexity of the knowledge graph is reduced, improving query and training efficiency.
[0165] The embodiments described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0166] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0167] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.
[0168] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0169] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0170] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0171] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0172] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0173] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0174] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: various media that can store programs, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0175] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
Claims
1. A knowledge graph optimization method based on a large language model, characterized in that: The method comprises: Inputting a first question about a first entity and a second question about a second entity into a large language model to obtain a first semantic description and a second semantic description, respectively; wherein the first entity and the second entity are nodes in a knowledge graph, and the first question and the second question are input text provided by a user; determining a first similarity between the first entity and the second entity based on the first semantic description and the second semantic description; Obtaining a triple to be checked from the knowledge graph; According to the head entity, tail entity and the entity relationship between the head entity and the tail entity contained in the triple to be checked, a head entity semantic representation, a head entity structural representation, a tail entity semantic representation, a tail entity structural representation and a relationship representation are generated, including: respectively performing embedding representation processing on the head entity, tail entity and entity relationship of the triple to be checked to obtain the head entity semantic representation, tail entity semantic representation and relationship representation; obtaining the first neighborhood entity of the head entity and the second neighborhood entity of the tail entity; according to the triple formed by the head entity and the first neighborhood entity, obtaining a first neighborhood semantic representation and a first neighborhood relationship representation, and, according to the triple formed by the tail entity and the second neighborhood entity, obtaining a second neighborhood semantic representation and a second neighborhood relationship representation; aggregating the first neighborhood semantic representation and the first neighborhood relationship representation to determine the head entity structural representation, and aggregating the second neighborhood semantic representation and the second neighborhood relationship representation to determine the tail entity structural representation; Determining the confidence of the to-be-checked triple based on the head entity semantic representation, the head entity structural representation, the tail entity semantic representation, the tail entity structural representation, and the relationship representation, including: calculating a head entity aggregate representation based on the head entity semantic representation and the relationship representation, and calculating a tail entity aggregate representation based on the tail entity semantic representation and the relationship representation; obtaining a second similarity based on the head entity aggregate representation and the tail entity structural representation; obtaining a third similarity based on the tail entity aggregate representation and the head entity structural representation; and determining the confidence of the to-be-checked triple based on the second similarity and the third similarity; The first entity and the second entity corresponding to the knowledge graph are merged according to the first similarity, and the target relationship link corresponding to the corresponding triple to be checked in the knowledge graph is updated according to the confidence to obtain a target knowledge graph.
2. The knowledge graph optimization method based on a large language model according to claim 1 is characterized in that: The determining, based on the first semantic description and the second semantic description, a first similarity between the first entity and the second entity includes: Performing embedding representation processing on the first semantic description and the second semantic description respectively to obtain a first entity semantic representation and a second entity semantic representation; A cosine similarity calculation is performed on the first entity semantic representation and the second entity semantic representation to obtain the first similarity between the first entity and the second entity.
3. The knowledge graph optimization method based on a large language model according to claim 2 is characterized in that: The performing entity merging processing on the first entity and the second entity corresponding to the knowledge graph according to the first similarity includes: Obtaining a preset first threshold; wherein the first threshold represents a critical value for determining that entities corresponding to two entity semantic representations are entities of the same type; When the first similarity is greater than or equal to the first threshold, merging the first entity and the second entity to form a merged entity, and determining a relationship link of the merged entity based on the relationship link between the first entity and the second entity; Update the data structure of the knowledge graph based on the relationship links of the merged entities.
4. The knowledge graph optimization method based on a large language model according to claim 1, characterized in that: Determining the confidence of the to-be-checked triplet according to the second similarity and the third similarity includes: Obtaining a preset first weight and a second weight; The confidence level of the to-be-checked triple is determined according to the product of the first weight and the second similarity, and the product of the second weight and the third similarity.
5. The knowledge graph optimization method based on a large language model according to claim 4 is characterized in that: The updating of the target relationship link corresponding to the triple to be checked in the knowledge graph according to the confidence level includes: Obtaining a preset second threshold; wherein the second threshold represents a critical value for the triple to be checked to be a credible triple; When the confidence level is less than the second threshold, the relationship link of the triple to be checked in the knowledge graph is deleted, and the data structure of the knowledge graph is updated.
6. The knowledge graph optimization method based on a large language model according to claim 1, characterized in that: After the step of obtaining the target knowledge graph, the method further includes: Performing initial training on a preset graph model according to the triples in the target knowledge graph to obtain an initial graph model; Obtain the training head entity fuzzy set and training multi-hop query path; Converting the training multi-hop query path into a training logical expression, and inputting the training head entity fuzzy set and the training logical expression into a logical query model based on the initial graph model to obtain a training tail entity fuzzy set; A first training loss is determined based on the training tail entity fuzzy set and the training true value set, and parameters of the logical query model are adjusted based on the first training loss until the first training loss meets a preset condition, thereby obtaining the target logical query model.
7. The knowledge graph optimization method based on a large language model according to claim 6 is characterized in that: The initial training of the preset graph model according to the triples in the target knowledge graph to obtain the initial graph model includes: Obtaining training triples from the target knowledge graph; Inputting the head entity and entity relationship of the training triple into a preset graph model to obtain a training tail entity, inputting the head entity and tail entity of the training triple into the preset graph model to obtain a training entity relationship, and inputting the entity relationship and tail entity of the training triple into the preset graph model to obtain a training head entity; A second training loss is determined based on the training triples, the training head entity, the training entity relationship, and the training tail entity, and the parameters of the preset graphical model are preliminarily adjusted based on the second training loss until the second training loss meets a preset condition to obtain an initial graphical model.
8. A knowledge graph optimization device based on a large language model, characterized in that: The device comprises: an input unit, configured to input a first question about a first entity and a second question about a second entity into the large language model to obtain a first semantic description and a second semantic description, respectively; wherein the first entity and the second entity are nodes in a knowledge graph, and the first question and the second question are input text provided by a user; a first calculating unit, configured to determine a first similarity between the first entity and the second entity based on the first semantic description and the second semantic description; An acquisition unit, configured to acquire a triple to be checked from the knowledge graph; a conversion unit, configured to generate a head entity semantic representation, a head entity structural representation, a tail entity semantic representation, a tail entity structural representation, and a relationship representation based on a head entity, a tail entity, and an entity relationship between the head entity and the tail entity contained in the triple to be checked; a second computing unit, configured to determine the confidence of the to-be-checked triple based on the head entity semantic representation, the head entity structural representation, the tail entity semantic representation, the tail entity structural representation, and the relationship representation; an optimization unit, configured to perform entity merging processing on the first entity and the second entity corresponding to the knowledge graph according to the first similarity, and to update the target relationship link corresponding to the corresponding triple to be checked in the knowledge graph according to the confidence level, to obtain a target knowledge graph; The conversion unit is specifically configured to: Performing embedding representation processing on the head entity, tail entity, and entity relationship of the triple to be checked, respectively, to obtain the head entity semantic representation, tail entity semantic representation, and relationship representation; Acquire a first neighboring entity of the head entity and a second neighboring entity of the tail entity; Obtaining a first neighborhood semantic representation and a first neighborhood relationship representation based on a triple consisting of the head entity and the first neighborhood entity, and obtaining a second neighborhood semantic representation and a second neighborhood relationship representation based on a triple consisting of the tail entity and the second neighborhood entity; Aggregating the first neighborhood semantic representation and the first neighborhood relationship representation to determine the head entity structure representation, and aggregating the second neighborhood semantic representation and the second neighborhood relationship representation to determine the tail entity structure representation; The second computing unit is specifically configured to: Calculating a head entity aggregate representation based on the head entity semantic representation and the relationship representation, and calculating a tail entity aggregate representation based on the tail entity semantic representation and the relationship representation; Obtaining a second similarity based on the head entity aggregation representation and the tail entity structure representation; Obtaining a third similarity based on the tail entity aggregation representation and the head entity structure representation; The confidence level of the to-be-checked triple is determined according to the second similarity and the third similarity.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, it implements the knowledge graph optimization method based on a large language model as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the knowledge graph optimization method based on a large language model according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Knowledge graph completion method and device, storage medium and electronic equipment
CN112836064A
Storage method and system of common sense knowledge graph
CN116910276A