Knowledge graph completion method and system based on entity description and soft prompt enhancement

Through the method of entity description encoding and soft prompt enhancement, the problem of lack of semantic information in the knowledge graph completion method in the existing technology is solved, and the prediction accuracy of entity relationships and link prediction performance are improved.

CN118536588APending Publication Date: 2024-08-23QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES)

Patent Information

Application Number
CN202410828574.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing knowledge graph completion methods rely on language model parameters and lack semantic information and contextual information, resulting in fuzzy descriptions of entities and relationships, resulting in noise and ambiguity.

Method used

Adopt a method based on entity description and soft hints, adjust the attention weight of words through entity description encoding and soft attention mechanism, combine with the soft hint generator to add additional trainable embeddings for entities and relationships, and use the T5 model for cross-entropy loss training To improve the accuracy of knowledge graph completion.

Benefits of technology

The model improves the prediction accuracy of entity-related information in the knowledge graph, enhances the ability to distinguish similar entity relationships, and improves the performance of link prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118536588A
    Figure CN118536588A
Patent Text Reader

Abstract

The invention belongs to the technical field of knowledge graph completion, and provides a knowledge graph completion method and system based on entity description and soft prompt enhancement, and the method comprises the steps: obtaining a to-be-completed knowledge graph triple, and converting the to-be-completed knowledge graph triple into a text sequence; encoding the entity description in the text sequence, and dynamically adjusting the attention weight of each word in the entity description by using a soft attention mechanism to obtain the encoded entity description; the entity relation in the text sequence is converted into a relation embedding matrix, and a soft prompt is generated through the relation embedding matrix and the token sequence; and connecting the encoded entity description and soft prompt with a text sequence to obtain an entity representation, and training a language model by using the entity representation to minimize the cross entropy loss. According to the method, entity description and soft prompt are introduced to help the model to better understand and infer entities and relationships in the knowledge graph, so that the prediction accuracy of the model on entity related information in the knowledge graph is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of knowledge graph completion, and in particular to a knowledge graph completion method and system based on entity description and soft prompt enhancement. Background Art

[0002] The statements in this section merely provide background information related to the present disclosure and do not necessarily constitute prior art.

[0003] A knowledge graph is a relational network that connects all different kinds of information. Limited by the technical difficulty of constructing a knowledge graph, knowledge graphs are generally incomplete. Existing knowledge graph completion methods include traditional knowledge graph embedding methods and methods based on pre-trained language models. The key idea of ​​traditional knowledge graph embedding methods is to embed knowledge graph components containing entities and relationships in a continuous vector space to simplify operations while retaining the inherent structure of the knowledge graph. Methods based on pre-trained language models attempt to acquire knowledge from language models. By encoding and understanding text, they can more effectively capture rich contextual information about entities and relationships.

[0004] In recent years, applying pre-trained language models to knowledge graph completion tasks has become a promising direction. However, current methods based on pre-trained language models only rely on information extracted from language model parameters. For some specific relations and entities, due to the lack of sufficient semantic information and contextual information, the description is relatively vague, resulting in noise and ambiguity. Summary of the invention

[0005] In response to the above-mentioned defects, the present disclosure proposes a knowledge graph completion method and system based on entity description and soft prompt enhancement, which introduces entity description and soft prompts to help the model better understand and reason about entities and relationships in the knowledge graph, thereby improving the model's prediction accuracy for entity-related information in the knowledge graph and helping the model better distinguish similar entity relationships in the knowledge graph.

[0006] In order to achieve the above objectives, the present disclosure adopts the following technical solutions: The first aspect of the present disclosure provides a knowledge graph completion method based on entity description and soft prompt enhancement, comprising the following steps: Get the knowledge graph triples to be completed and convert them into text sequences; Encode the entity description in the text sequence, and use the soft attention mechanism to dynamically adjust the attention weight of each word in the entity description to obtain the encoded entity description; Convert entity relations in text sequences into relation embedding matrices, and generate soft prompts using relation embedding matrices and token sequences; Connect the encoded entity description and soft prompt with the text sequence to obtain the entity representation, and use the entity representation to train the language model to minimize the cross entropy loss; Use the trained model to complete the knowledge graph.

[0007] As a further implementation method, the entity description in the text sequence is encoded, specifically: The entity description in the text sequence is converted into a word embedding matrix, the word embedding matrix is ​​combined with the position embedding matrix to obtain a first vector representation, and the first vector representation is operated to obtain a second vector representation.

[0008] As a further implementation, the first vector representation is operated, specifically: The degree of association between each token in the first vector representation and other tokens in the sequence is calculated, and the representation of the token is adjusted according to this association, and an independent fully connected neural network calculation is performed for the token at each position.

[0009] As a further implementation method, the soft attention mechanism is used to dynamically adjust the attention weight of each word in the entity description, specifically: The correlation between each input vector and the query vector is calculated through a scoring function. The attention variable is used to represent the index position of the selected variable. The attention weight distribution under a given query vector and input vector is calculated. Each input vector is multiplied by the corresponding weight and the results are added to obtain the encoded entity description.

[0010] As a further implementation, the soft prompts are a set of trainable embeddings that can be embedded into text sequences to add additional trainable prompts for entities and relations.

[0011] As a further implementation, the soft prompts are concatenated with the relation embeddings to obtain a concatenated matrix, which is then concatenated with the input sequence again.

[0012] As a further implementation, the cross entropy loss is the cross entropy loss of the output result of the language model relative to the training data vector.

[0013] The second aspect of the present disclosure provides a knowledge graph completion system based on entity description and soft prompt enhancement, including: The data acquisition module is configured to: acquire the knowledge graph triples to be completed and convert them into text sequences; The entity encoding module is configured to: encode the entity description in the text sequence, and use the soft attention mechanism to dynamically adjust the attention weight of each word in the entity description to obtain the encoded entity description; The soft prompt generation module is configured to: convert entity relations in the text sequence into a relation embedding matrix, and generate soft prompts using the relation embedding matrix and the token sequence; The model training module is configured to: connect the encoded entity description and soft prompt with the text sequence to obtain the entity representation, and use the entity representation to train the language model to minimize the cross entropy loss; The output module is configured to complete the knowledge graph using the trained model.

[0014] The third aspect of the present disclosure provides a medium on which a program is stored. When the program is executed by a processor, the steps in the knowledge graph completion method based on entity description and soft prompt enhancement described in the first aspect of the present disclosure are implemented.

[0015] The fourth aspect of the present disclosure provides an electronic device, including a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, the steps in the knowledge graph completion method based on entity description and soft prompt enhancement described in the first aspect of the present disclosure are implemented.

[0016] Compared with the prior art, the present invention has the following beneficial effects: The present invention discloses a knowledge graph completion method based on entity description and soft hint enhancement. It introduces entity description, encodes the entity description through the T5 model, and then uses the soft attention mechanism to assign different attention weights to different parts of the description, so that the model can more effectively capture the important information in the description, thereby improving the performance of the model. Soft hints are added, and the hint generator is used to generate soft hints. Then, the relationship embedding of the entity is connected with the soft hints. The soft hints help the model distinguish similar entity relationships by providing additional guiding information. The triple information, entity description information and soft hint information are combined and trained using the T5 model to improve the accuracy of link prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings constituting a part of the present disclosure are used to provide a further understanding of the present disclosure. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure.

[0018] Figure 1 It is an overall flow chart of the knowledge graph completion method based on entity description and soft prompt enhancement disclosed in the present invention; Figure 2 It is a structural diagram of the entity description representation model disclosed in the present invention; Figure 3 It is a structural schematic diagram of the soft prompt representation model disclosed in the present invention. DETAILED DESCRIPTION

[0019] The present disclosure is further described below in conjunction with the accompanying drawings and embodiments.

[0020] It should be noted that the following detailed descriptions are all illustrative and are intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present disclosure belongs.

[0021] In the absence of conflict, the embodiments in the present disclosure and the features in the embodiments may be combined with each other.

[0022] Embodiment 1 like Figure 1 As shown, the first embodiment of the present disclosure provides a knowledge graph completion method based on entity description and soft prompt enhancement, including the following steps: S1 obtains the knowledge graph triples to be completed and converts them into text sequences; S2 encodes the entity description in the text sequence and uses the soft attention mechanism to dynamically adjust the attention weight of each word in the entity description to obtain the encoded entity description; S3 converts the entity relations in the text sequence into a relation embedding matrix and generates soft prompts using the relation embedding matrix and token sequence; S4 connects the encoded entity description and soft prompt with the text sequence to obtain the entity representation, and uses the entity representation to train the language model to minimize the cross entropy loss; S5 uses the trained model to complete the knowledge graph.

[0023] As an independent source of information, entity description contains semantic information related to the entity, such as the entity's attributes, features, and relationships. By adding entity description, the model can better understand the meaning and semantics of the entity, thereby improving the prediction accuracy of entity-related information in the knowledge graph. Entity descriptions that contain rich feature information can make up for the lack of information extracted by pre-trained language models. Soft hints, as an effective information guidance mechanism, can guide the model to pay more attention to task-related entity relationships, thereby improving the accuracy of predictions. Soft hints can provide some implicit information to guide the model to make predictions from different angles or dimensions. This implicit information may come from domain knowledge, text context, probability distribution, etc., helping the model to better distinguish similar entity relationships in the knowledge graph. Inspired by this, we propose a sequence-to-sequence model (ESKG) for knowledge graph completion.

[0024] We use the Transformer encoder-decoder model based on T5 to complete the knowledge graph completion task. The model framework can be expressed as:

[0025] Among them, X represents the input sequence of the encoder, Y represents the output sequence generated by autoregression, and i and n represent the position in the current output sequence and the length of the sequence respectively.

[0026] The link prediction task is as follows: For each triple (s, r, o) from the knowledge graph, we predict the tail of the query (s, r, ?) and the head of (?, r, o). To generate the input sequence X for the model, we first convert these queries into text sequence forms of "predict tail: subject mention | relation mention |" and "predict head: | relation mention | object mention". Then we concatenate the encoded entity descriptions and soft prompts with the text sequence, and finally input them into the model, and train the model to generate the true answer as the output sequence Y. To predict the results, we sample a fixed number of sequences from the decoder and map them to their entity ids. The final outputs corresponding to the input sequences are "object mention" and "subject mention", respectively. ESKG is trained with teacher forcing and cross entropy loss.

[0027] The following is a detailed description of each step: Step 1: Entity description.

[0028] Traditional methods based on pre-trained language models rely on information extracted from language model parameters. Therefore, for certain types of entities, such as names of people and places, they may point to multiple real-world entities in the training set, which introduces noise ambiguity to the model. To solve this problem, we introduce the idea of ​​multi-source information fusion to improve the performance of knowledge graph completion tasks. In existing datasets, entity text description information is very rich, which provides great support for us. Take the knowledge graph embedding model DKRL with entity description proposed by Xie et al. as an example. The model uses a continuous bag of words model or a convolutional neural network to embed entity text description information. However, we believe that the DKRL model has insufficient fusion when integrating entity description text and structured knowledge graph information. For example, convolutional neural networks usually tend to capture local information, while there may be importance of global context information in entity description, which may lead to limitations in the model's understanding of entity description. To address this problem, we designed a representation model for entity description, which can dynamically adjust the attention weight according to the entity description information in the input sequence, so as to more accurately capture the semantic differences between entities, and can consider the global information in the entity description, not just the local information, which helps to better understand the relationship and semantics between entities.

[0029] The representation model of entity description is as follows Figure 2 As shown in the figure, it consists of three layers: input layer, T5 Encoder layer and soft attention layer.

[0030] (1) Input layer The input layer is the embedding matrix of the input sequence, which is obtained by combining the embedding of the entity description and the position embedding, and is used as the input information of the model. First, the input sequence is trained using word2vec. This step converts each token in the input sequence into a corresponding word embedding vector, thereby obtaining the word embedding matrix For position embedding, we use relative position encoding, that is, each position encoding is a scalar, which is added to the score value to calculate the attention weight. The position embedding matrix is ​​combined with the word embedding matrix to obtain the input vector representation of the T5 Encoder layer (i.e. the first vector representation).

[0031] (2) T5 Encoder layer The T5 Encoder layer is composed of 6 stacked Transformer encoder layers, each of which contains the following sublayers: Self-attention layer: It is used to calculate how much each token is associated with other tokens in the sequence and adjust the representation of the token based on this association.

[0032] Feedforward neural network layer: An independent fully connected neural network calculation is performed on the token at each position to enhance the expressiveness of the representation.

[0033] Residual connection layer: After each sub-layer, we use residual connection to add the input to the output of the sub-layer to alleviate the problem of gradient disappearance.

[0034] T5 Encoder processes the input vector V and finally generates each token and its context-aware representation (i.e. the second vector representation).

[0035] (3) Soft Attention Layer In order to obtain a more representative entity description, we use a soft attention mechanism to calculate the weight of each word in the entity description. The calculation process is as follows: Select a query vector q from the n input vectors, and then use a scoring function to calculate the correlation between each input vector and the query vector q. To indicate the index position of the selected variable. Calculate the attention weight distribution under given q and T :

[0036]

[0037]

[0038] in, For the attention scoring function, i represents a specific index position in the sequence, j represents another specific position, and i is used together to represent different positions in the sequence. Here we use the dot product model to calculate:

[0039] Multiply the vector representation of each word by the corresponding weight and add the results to obtain the final weighted representation of the entity description, that is, the encoded entity description:

[0040]

[0041] Finally, on the encoder side, we concatenate the processed entity description with the entity name as the entity representation. On the decoder side, we also add entity descriptions to the true answers, and then train the model to jointly predict entity names and entity descriptions under cross entropy loss, which effectively improves the model's ability to model entity descriptions.

[0042] Step 2: Soft Tips Entities and relations in traditional knowledge graph embedding models (e.g., TransE) are represented using separate embeddings, while methods based on pre-trained language models use model parameters to represent entities and relations, which may cause some similar relations or entities (e.g., "country of citizenship" and "country of origin") to be mixed together, introducing noise and ambiguity. To address this issue, and inspired by the concept of soft hints by Lester et al., we design a soft hint representation model. Soft hints are a set of trainable embeddings that can add additional trainable hints to the input sequence for entities and relations. Current soft hint generation methods may be limited by algorithms or models, resulting in the generated hints not matching user needs or context, causing misleading results. Therefore, we design a hint generator that automatically analyzes data and models according to the needs of specific tasks and the characteristics of the data, generates relevant soft hints, and guides the model to model similar entities or relations more effectively through soft hints.

[0043] Since entities have entity descriptions and soft hints introduce a large number of parameters, we choose to only apply soft hints to entity relations. Figure 3As shown in Figure 1, the essence of prompts is to add some additional information to the model. We use the prompt generator to generate soft prompts related to entity relationships. We first extract the entity relationships in the input sequence X and use word2vec training to obtain the relationship embedding matrix The prompt generator receives R and a special token sequence As input, output soft prompt , where P is a placeholder for generating soft prompts, is the soft hint, k is the length of the soft hint, and d is the hidden layer dimension. The hint generator can be any sequence-to-sequence model. Here we use the T5 model as the backbone of the hint generator. Specifically, let R′ be the concatenation of R and P, and let T5 be the function f. We take the hidden state of T5 as the output, which is a sequence of length n + k. We take the subsequence of the output sequence corresponding to P as the soft hint, that is:

[0044]

[0045]

[0046] Among them, || is the splicing operation, represents a subsequence of elements from n+1 to n+k, that is, f corresponds to the hidden state of P.

[0047] We concatenate the soft hints S with the relation embedding R to form a larger matrix that contains the embeddings of the original input tokens and the information of the soft hints. The concatenated matrix is ​​concatenated with the input sequence X and fed into the encoder-decoder part of the model. The encoder is responsible for understanding the semantic content of the input, while the decoder is responsible for generating the output Y.

[0048] We selected three public knowledge graph datasets and conducted comparative experiments on them. We found that ESKG outperformed several other competitive baseline models, including graph-based and pre-trained language model-based methods, and achieved good performance on all settings. We also conducted an ablation study to show the effectiveness of the proposed components.

[0049] We pre-trained ESKG on the Wikidata5M dataset, which is a dataset containing 5 million entities. These entities represent various categories such as people, places, events, organizations, etc. The dataset also contains attribute information related to these entities, such as entity descriptions, categories, relations, and attribute values. By using the Wikidata5M dataset, extensive data analysis and research can be carried out to reveal the associations and characteristics between various entities. Then, by continuously training the pre-trained model, we tested ESKG on two standard knowledge graph completion benchmarks (FB15K-237 and WN18RR). FB15k-237 is extracted from Freebase, and the relations in it are renumbered in the original FB15k dataset to ensure better data balance and more effective experiments. WN18RR is a subset of WordNet. The purpose of this dataset is to better test and evaluate the performance of knowledge graph embedding models, especially for the reasoning ability of relations. The dataset statistics are summarized in Table 1.

[0050] Table 1 Dataset statistics

[0051] For link prediction on Wikidata5M, we compared the ESKG model with two sets of baselines: (1) traditional knowledge graph embedding methods, including TransE, ComplEx, SimpIE, and RotatE. These methods store entity embeddings in a large lookup table and use simple relation-aware scoring functions to calculate the similarity between entities. (2) combined knowledge representation methods, including KEPLER, MLMLM, and KGT5. KEPLER improves the performance and effect on knowledge-driven tasks by enhancing the ability of pre-trained language models to incorporate information from external knowledge bases into text understanding. MLMLM uses self-supervised learning to learn language representations from unlabeled data by using the training objective of a masked language model. The experimental results are shown in Table 2.

[0052] We can see that ESKG has achieved excellent results in all indicators on Wikidata5M, establishing a new state-of-the-art result. Compared with the standard knowledge graph embedding models TransE, ComplEx, SimplE and RotatE, ESKG is relatively good in the three evaluation indicators of MRR, Hits@1 and Hits@3. Compared with the large ComplEx, Hits@10 dropped by 0.003, which shows the difficulty of using pre-trained language models to handle knowledge graph completion tasks. Some performance indicators may still not surpass traditional knowledge graph embedding models. Compared with the combined knowledge representation model, ESKG outperforms all models in all indicators. Compared with the baseline model KGT5, ESKG improved by 0.034 in MRR, 0.038 in hits@1, 0.030 in hits@3, and 0.030 in Hits@10. From this, it can be seen that by combining the T5 encoder with the soft attention mechanism to process entity descriptions and using the soft hint generator to add hints to entity relationships, the model's ability to understand link prediction tasks can be enhanced and more context and background information can be introduced.

[0053] Table 2 Link prediction results on Wikidata5M

[0054] For link prediction on FB15k-237 and WN18RR, we compare the results with various graph-based methods (e.g., TransE, ComplEx, RotatE) and pre-trained language model-based methods (e.g., KG-BERT, StAR, GenKGC). The experimental results are shown in Table 3.

[0055] On both FB15K-237 and WN18RR, ESKG achieves competitive performance. On FB15K-237, ESKG outperforms all graph-based methods on Hits@1 and Hits@3, but does not surpass RotatE in MRR and Hits@10. Among the methods based on pre-trained language models, ESKG performs well on MRR, Hits@1, and Hits@3, and Hits@10 drops by 0.031 compared to StAR. On WN18RR, ESKG outperforms all models on MRR, Hits@1, and Hits@3, and Hits@10 is lower than StAR. From this, we can analyze that adding entity descriptions and soft prompts does provide more contextual information, making it easier for the model to understand and correctly match the key content of the query, but it may also cause the model to pay more attention to these specific entity descriptions and prompts when generating sequences, thereby affecting the model's overall understanding and processing. Therefore, the model performs better on MRR, Hits@1, and Hits@3 because the model may correctly match entity descriptions and prompts in the input sequence, but performs worse on Hits@10 because the model may not fully consider broader contextual information, resulting in a lower overall matching rate.

[0056] Table 3 Link prediction results on FB15k-237 and WN18RR

[0057] To better understand the design choices we made and their impact on performance, we further provide ablation experiments. Table 4 shows the impact of each component on the model experiments.

[0058] As shown in Table 4, adding source description and target description can improve MRR (from 0.276 to 0.307) and Hit@10 (from 0.414 to 0.443) respectively. After using T5 encoder combined with soft attention mechanism to process entity description, MRR is increased to 0.310 and Hit@10 is increased to 0.449. This shows that soft attention mechanism can better obtain the semantic representation of entity description information. Therefore, it is necessary to inject entity description into both encoder and decoder of ESKG. At the same time, soft prompts are generated by soft prompt generator and added to the input sequence. It can be seen from the table that soft prompts successfully improve MRR from 0.276 to 0.287 and Hit@10 from 0.414 to 0.428. Adding relation prompts on the basis of adding entity descriptions can improve MRR to 0.313 and Hit@10 to 0.451. It can be seen that adding relation soft prompts to the model input sequence can help the model to better reason and make decisions.

[0059] Table 4 Ablation experiment of ESKG on FB15K-237

[0060] Embodiment 2 Embodiment 2 of the present disclosure provides a knowledge graph completion system based on entity description and soft prompt enhancement, including: The data acquisition module is configured to: acquire the knowledge graph triples to be completed and convert them into text sequences; The entity encoding module is configured to: encode the entity description in the text sequence, and use the soft attention mechanism to dynamically adjust the attention weight of each word in the entity description to obtain the encoded entity description; The soft prompt generation module is configured to: convert entity relations in the text sequence into a relation embedding matrix, and generate soft prompts using the relation embedding matrix and the token sequence; The model training module is configured to: connect the encoded entity description and soft prompt with the text sequence to obtain the entity representation, and use the entity representation to train the language model to minimize the cross entropy loss; The output module is configured to complete the knowledge graph using the trained model.

[0061] Embodiment 3 Embodiment 3 of the present disclosure provides a medium on which a program is stored. When the program is executed by a processor, the steps in the knowledge graph completion method based on entity description and soft prompt enhancement as described in Embodiment 1 of the present disclosure are implemented.

[0062] The more detailed steps are the same as those in the first embodiment and will not be repeated here.

[0063] Embodiment 4 Embodiment 4 of the present disclosure provides an electronic device, including a memory, a processor, and a program stored in the memory and executable on the processor. When the processor executes the program, the steps in the knowledge graph completion method based on entity description and soft prompt enhancement as described in Embodiment 1 of the present disclosure are implemented.

[0064] The more detailed steps are the same as those in the first embodiment and will not be repeated here.

[0065] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. For those skilled in the art, the present disclosure may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. Knowledge graph completion method based on entity description and soft prompt enhancement, It is characterized in that The following steps are involved: Get the knowledge graph triples to be completed and convert them into text sequences; Encode the entity description in the text sequence, and use the soft attention mechanism to dynamically adjust the attention weight of each word in the entity description to obtain the encoded entity description; Convert entity relations in text sequences into relation embedding matrices, and generate soft prompts using relation embedding matrices and token sequences; Connect the encoded entity description and soft prompt with the text sequence to obtain the entity representation, and use the entity representation to train the language model to minimize the cross entropy loss; Use the trained model to complete the knowledge graph.

2. The knowledge graph completion method based on entity description and soft prompt enhancement as described in claim 1, It is characterized in that Encode the entity description in the text sequence, specifically: The entity description in the text sequence is converted into a word embedding matrix, the word embedding matrix is ​​combined with the position embedding matrix to obtain a first vector representation, and the first vector representation is operated to obtain a second vector representation.

3. The knowledge graph completion method based on entity description and soft prompt enhancement as described in claim 2, It is characterized in that The first vector representation is operated as follows: The degree of association between each token in the first vector representation and other tokens in the sequence is calculated, and the representation of the token is adjusted according to this association, and an independent fully connected neural network calculation is performed for the token at each position.

4. The knowledge graph completion method based on entity description and soft prompt enhancement as described in claim 2, It is characterized in that The soft attention mechanism is used to dynamically adjust the attention weight of each word in the entity description, specifically: The correlation between each input vector and the query vector is calculated through a scoring function. The attention variable is used to represent the index position of the selected variable. The attention weight distribution under a given query vector and input vector is calculated. Each input vector is multiplied by the corresponding weight and the results are added to obtain the encoded entity description.

5. The knowledge graph completion method based on entity description and soft prompt enhancement as described in claim 1, It is characterized in that The soft hints are a set of trainable embeddings that can be embedded into text sequences to add additional trainable hints for entities and relations.

6. The knowledge graph completion method based on entity description and soft prompt enhancement as described in claim 5, It is characterized in that Concatenate the soft prompts with the relation embeddings to get the concatenated matrix, which is then concatenated with the input sequence again.

7. The knowledge graph completion method based on entity description and soft prompt enhancement as described in claim 1, It is characterized in that The cross entropy loss is the cross entropy loss of the output result of the language model relative to the training data vector.

8. Knowledge graph completion system based on entity description and soft prompt enhancement, It is characterized in that include: The data acquisition module is configured to: acquire the knowledge graph triples to be completed and convert them into text sequences; The entity encoding module is configured to: encode the entity description in the text sequence, and use the soft attention mechanism to dynamically adjust the attention weight of each word in the entity description to obtain the encoded entity description; The soft prompt generation module is configured to: convert entity relations in the text sequence into a relation embedding matrix, and generate soft prompts using the relation embedding matrix and the token sequence; The model training module is configured to: connect the encoded entity description and soft prompt with the text sequence to obtain the entity representation, and use the entity representation to train the language model to minimize the cross entropy loss; The output module is configured to complete the knowledge graph using the trained model.

9. A medium having a program stored thereon, It is characterized in that When the program is executed by a processor, the steps in the knowledge graph completion method based on entity description and soft prompt enhancement are implemented as described in any one of claims 1 to 7.

10. An electronic device comprising a memory, a processor, and a program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps in the knowledge graph completion method based on entity description and soft prompt enhancement are implemented as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Entity description and topological structure information enhanced knowledge graph completion method

    CN117725228A

Cited By

  • Knowledge graph link prediction method and system based on double coding and decoding models

    CN118709772A

  • A knowledge graph link prediction method and system based on dual encoding and decoding model

    CN118709772B

  • Text named entity recognition model and method

    CN119204014A

  • Knowledge graph completion method based on pre-training language model

    CN120578769A

  • A knowledge graph completion method based on a pre-trained language model

    CN120578769B