A method for constructing a knowledge representation learning model based on the knowledge graph of smart device vulnerabilities

By building the ontology of the vulnerability knowledge graph of smart devices and integrating entity structure and description information, the problem of inaccurate knowledge representation is solved, effective prediction of vulnerability threats and correction of vulnerability library errors is achieved, and the accuracy of knowledge representation and the Internet of Things is improved. Safety analysis capability.

CN118316662BActive Publication Date: 2024-11-26ZHEJIANG UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410367115.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-28
Publication Date
2024-11-26
Estimated Expiration
2044-03-28

AI Technical Summary

Technical Problem

In the prior art, the knowledge representation of the smart device vulnerability knowledge graph is inaccurate, and it is impossible to effectively predict the hidden threat of the vulnerability and correct the error information in the vulnerability library. Moreover, traditional models ignore the characteristics of the entity itself and multi-source heterogeneous content information.

Method used

Build a knowledge graph ontology based on intelligent device vulnerabilities, combine entity structure information and description information, obtain entity embedding vectors through the Doc2vec model, and integrate them into the TransE model. Pytorch is used to initialize and update the embedded vectors, enhancing the knowledge representation ability of the model.

Benefits of technology

It improves the accuracy of knowledge representation, can effectively predict hidden threats of vulnerabilities and corrects error information in the vulnerability library, and enhances the IoT security analysis capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118316662B_ABST
    Figure CN118316662B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for constructing a knowledge representation learning model based on a knowledge graph of smart device vulnerabilities, wherein the steps are: constructing a knowledge graph of smart device vulnerabilities to generate a training set, a positive triple set and a negative triple set; calculating the similarity between entities according to the structural neighborhood between entities, and training the training set through a Doc2vec model to obtain an embedding vector of entity description information; inputting the positive and negative triple pairs into a TransE model to obtain an embedding vector of entities and relationships, and calculating the embedding vector of the positive and negative triples with the embedding vector of the entity description information; calculating the loss function using the scoring function and the similarity between entities, and back-propagating the loss function to continuously update the embedding vectors of entities and relationships. The present invention can effectively predict the hidden threats of vulnerabilities and correct erroneous information in a vulnerability library.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of representation learning of knowledge graphs, and in particular to a method for constructing a knowledge representation learning model based on a smart device vulnerability knowledge graph. Background Art

[0002] The IoT ecosystem is complex, and vulnerability information in massive heterogeneous devices is difficult to collect and manage in a timely and accurate manner, resulting in inaccurate and incomplete information in the vulnerability database, which seriously restricts the improvement of the security level of smart devices. The traditional translation model usually only focuses on the local structural information of triples for the smart device vulnerability knowledge graph, while ignoring the rich content information of other multi-source heterogeneous content in the knowledge graph, resulting in inaccurate knowledge representation of entities and relationships, and unable to well predict the hidden threats of vulnerabilities and correct erroneous information in the vulnerability database.

[0003] At present, knowledge graph representation learning is mainly divided into three categories. The first is representation learning based on translation, such as the TransE model, which maps entities and relationships to the same continuous vector space, and represents the relationship between entities as a translation operation between entity vectors, which greatly reduces the computational complexity. However, there are complex relationships in the knowledge graph, such as one-to-many, many-to-one, and even many-to-many. To solve this problem, improved methods based on translation models such as the TransH model, the TransD model, and the TransR model have been proposed one after another, using vector space projection and matrix mapping to improve the modeling effect of the translation model on complex relationships. The second is representation learning based on tensor decomposition, such as the RESCAL model and the DistMult model, which convert the knowledge graph into a third-order tensor and perform representation learning on entities and relationships through tensor decomposition. The third is representation learning based on deep learning, such as the ConvE model, which first concatenates the head entity and relationship and embeds them into a two-dimensional vector, then passes this two-dimensional vector through the convolution layer and the fully connected layer to obtain its features, and finally uses the weight matrix and the tail entity to calculate the score of the entire triple.

[0004] However, current research does not take into account the characteristics of the entities in the knowledge graph, and some models have too many parameters and cannot take into account both efficiency and effectiveness, making them unsuitable for large-scale knowledge graphs. Summary of the invention

[0005] The purpose of the embodiment of the present application is to provide a method for constructing a knowledge representation learning model based on a smart device vulnerability knowledge graph, so as to solve technical problems existing in related technologies such as inaccurate knowledge representation, inability to effectively predict hidden threats of vulnerabilities, and inability to effectively correct erroneous information in the vulnerability library.

[0006] According to a first aspect of an embodiment of the present application, a method for constructing a knowledge representation learning model based on a smart device vulnerability knowledge graph is provided, comprising:

[0007] According to the characteristics of smart device vulnerabilities, a smart device vulnerability knowledge graph ontology is constructed. According to the ontology, corresponding entity, attribute and relationship information are obtained from each vulnerability library, so as to generate a smart device vulnerability knowledge graph dataset. The dataset is used to determine a training set, a positive triple set and a negative triple set, and these sets are used to train the embedding vectors of entities and relationships.

[0008] Calculating similarity values ​​between entities according to structural neighborhoods between entities, and using the training set to train the Doc2vec model to obtain an embedding vector of entity description information;

[0009] The positive triplet set and the corresponding negative triplet set are combined into positive and negative triplet pairs and input into the TransE model. The embedding vectors of entities and relations are initialized by Pytorch's Embedding module, and the scoring function scores of positive and negative triplet are calculated together with the embedding vectors of the entity description information.

[0010] The similarity values ​​between entities are integrated into the loss function of the TransE model, and the loss function is calculated using the scores of the scoring function and the similarity values ​​between entities. The loss function is then back-propagated to continuously update the embedding vectors of entities and relationships, and the final TransE model that integrates entity structure information and description information is obtained.

[0011] According to a second aspect of an embodiment of the present application, a knowledge representation learning model construction device based on a smart device vulnerability knowledge graph is provided, comprising:

[0012] A data set generation module is used to construct a smart device vulnerability knowledge graph ontology according to the characteristics of smart device vulnerabilities, obtain corresponding entity, attribute and relationship information from each vulnerability library according to the ontology, and thus combine and generate a smart device vulnerability knowledge graph data set, use the data set to determine a training set, a positive triple set and a negative triple set, and use these sets to train the embedding vectors of entities and relationships;

[0013] An embedding vector acquisition module is used to calculate the similarity value between entities according to the structural neighborhood between the entities, and obtain the embedding vector of the entity description information by training the Doc2vec model using the training set;

[0014] A scoring calculation module, which is used to combine the positive triplet set and the corresponding negative triplet set into positive and negative triplet pairs and input them into the TransE model, initialize the embedding vectors of entities and relationships through the Embedding module of Pytorch, and calculate the scoring function scores of the positive and negative triplet together with the embedding vectors of the entity description information;

[0015] The model generation module is used to integrate the similarity values ​​between entities into the loss function of the TransE model, calculate the loss function using the scores of the scoring function and the similarity values ​​between entities, and then back-propagate the loss function to continuously update the embedding vectors of entities and relationships to obtain the final TransE model that integrates entity structure information and description information.

[0016] According to a third aspect of an embodiment of the present application, there is provided an electronic device, including:

[0017] one or more processors;

[0018] A memory for storing one or more programs;

[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in the first aspect.

[0020] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the first aspect are implemented.

[0021] The technical solution provided by the embodiments of the present application may have the following beneficial effects:

[0022] It can be seen from the above embodiments that the present application integrates entity structure information and entity description information into the TransE model to better learn the multi-source heterogeneous content information in the smart device vulnerability knowledge graph, improve the knowledge representation ability of the TransE model, effectively predict the hidden threats of vulnerabilities, and correct erroneous information in the vulnerability library.

[0023] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0025] Figure 1 It is a flowchart of a method for constructing a knowledge representation learning model based on a smart device vulnerability knowledge graph according to an exemplary embodiment.

[0026] Figure 2 It is a flowchart of a method for constructing a knowledge representation learning model based on a smart device vulnerability knowledge graph according to an exemplary embodiment.

[0027] Figure 3It is a structural diagram of a device for constructing a knowledge representation learning model based on a smart device vulnerability knowledge graph according to an exemplary embodiment. DETAILED DESCRIPTION

[0028] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0029] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0030] Figure 1 and Figure 2 is a flowchart of a method for constructing a knowledge representation learning model based on a smart device vulnerability knowledge graph according to an exemplary embodiment. Figure 1 and Figure 2 As shown, the method is applied in a terminal and may include the following steps:

[0031] S1: Construct a smart device vulnerability knowledge graph ontology based on the characteristics of smart device vulnerabilities, obtain corresponding entity, attribute and relationship information from each vulnerability library based on the ontology, and combine to generate a smart device vulnerability knowledge graph dataset, use the dataset to determine the training set, positive triple set and negative triple set, and use these sets to train the embedding vectors of entities and relationships;

[0032] Specifically, different versions of smart devices will be affected by different vulnerabilities, and vulnerabilities will also have corresponding attributes, such as vulnerability patch links, vulnerability description information, vulnerability severity, etc. Based on these characteristics, the smart device vulnerability knowledge graph ontology is constructed. According to the ontology, corresponding entities (such as vulnerability CVE numbers, product names and versions, etc.), attributes (such as vulnerability severity, vulnerability patch links, etc.) and relationship information (such as the relationship between products and versions affected by the vulnerability, the relationship between the threat types that the vulnerability may cause, etc.) are collected from vulnerability libraries such as the China National Vulnerability Database (CVND), the China National Vulnerability Database of Information Security (CNNVD), the National Vulnerability Database (NVD), the Common Vulnerabilities & Exposures (CVE), the Common Weakness Enumeration (CWE), and the IoT vulnerabilities and exploits databases (VARIoT) to generate a smart device vulnerability knowledge graph dataset. The data set is used to determine a training set, a positive triplet set, and a negative triplet set, and these sets are used to train embedding vectors of entities and relations.

[0033] By building an ontology, we can define and organize knowledge about smart device vulnerabilities. This structured approach makes the information more systematic and consistent, making it easier to understand and retrieve. Collecting information from multiple vulnerability libraries can integrate data from multiple sources and improve the comprehensiveness and diversity of the data.

[0034] Among them, using the smart device vulnerability knowledge graph dataset to determine the training set, the positive triple set and the negative triple set may include the following sub-steps:

[0035] S11: Generate triple data from the data obtained from each vulnerability library according to the smart device vulnerability knowledge graph ontology, in the form of (head entity, relationship, tail entity), save these triple data into a file, and obtain a positive triple set, where each line of the file is a positive triple;

[0036] Specifically, these triple data are saved in a txt format file to obtain a set of positive triples. Each line of the file is a positive triple. For example, (CVE-2017-6341, has_problem_type, CWE-200), indicating that the product affected by the vulnerability CVE-2017-6341 has the weakness CWE-200, where "CVE-2017-6341" is the head entity, "has_problem_type" is the relationship, and "CWE-200" is the tail entity. This design allows the data to be easily read and processed by various programming languages ​​and scripts, ensuring compatibility with different systems and tools. The triple structure is easy to understand and operate, providing a clear and concise way to represent information, and is very effective for describing complex relationships and attributes.

[0037] S12: extracting a portion from the positive example triple set as a training set;

[0038] Specifically, 80% of the data in the positive triple set is randomly extracted as the training set, and the remaining data is used to verify and test the model. The processes of calculating the loss function and updating the parameters are all operated on the triples in the training set.

[0039] Allocating 80% of the data to the training set ensures that the model has enough data to learn and recognize complex patterns, and the remaining data is used to validate and test the model. This split method can prevent the model from overfitting and evaluate the performance of the model.

[0040] S13: According to the positive example triple set, a corresponding negative example triple set is constructed, where the negative example triple set is obtained by randomly replacing the head entity or the tail entity of the positive example triples, and is different from any triple in the positive example triples.

[0041] Specifically, the set of negative triples is obtained by randomly replacing the head entity or tail entity of the positive triple, which is different from any triple in the positive triple, such as the one generated by randomly replacing the tail entity (CVE-2017-6341, has_problem_type, CWE-78), indicating that this is an incorrect triple. The parameters of the model can be better trained through positive and negative triples.

[0042] S2: Calculate the similarity between entities according to the structural neighborhood between entities, and use the training set to train the Doc2vec model to obtain the embedding vector of the entity description information; this may include the following sub-steps:

[0043] S21: Calculate the similarity value sim(e1, e2) between entity e1 and entity e2 based on the structural domain set of the entity:

[0044]

[0045] Where N(e1) represents the set of structural neighborhoods of entity e1, N(e2) represents the set of structural neighborhoods of entity e2, and H(θ) represents the number of entities in the knowledge graph that have structural neighborhood θ.

[0046] Specifically, in the knowledge graph, each entity has its structural neighborhood, which refers to other entities and relationships that are directly connected to the entity. These adjacent entities and relationships usually represent things that have a certain connection or association with the entity. Entities with similar structural neighborhoods often have something in common, so the structural neighborhood of the entity can be used to represent the similarity of the entity. In theory, the more identical structural neighborhoods two entities have, the more similar the two entities are. However, it is not enough to calculate the similarity simply by the number of identical structural neighborhoods, as the similarity is not defined within a range. In the knowledge graph, many entities have the same common structural neighborhood. For example, the entities of electronic products have a structural domain with a relationship of "status" and a tail entity of "closed". Such a common structural domain is not enough to reflect the similarity of the entity, and its weight should be reduced. Therefore, the weight of the structural neighborhood is calculated according to the number of entities that meet the structural neighborhood. The similarity value sim(e1, e2) between entity e1 and entity e2 is as follows:

[0047]

[0048] Among them, H(θ) represents the number of entities with structural neighborhood θ in the knowledge graph. The larger the value, the smaller the corresponding weight 1 / (H(θ)-1), which effectively controls its influence on the similarity value.

[0049] This design can effectively quantify the similarities between entities, laying the foundation for retaining the structural information of the knowledge graph when embedding the entities and relationships in the knowledge graph into vectors.

[0050] S22: Obtain description texts of entities in the smart device vulnerability knowledge graph, and perform preprocessing operations on all texts respectively; the preprocessing operations include removing stop words, special characters, and converting the texts to lowercase.

[0051] Specifically, for example, the description text of entity CWE-190 "The product performs a calculation that can produce an integer overflow." becomes "product performs calculation produce integer overflow" after the above steps.

[0052] Stop words usually do not carry important information about the main content of the text. Removing stop words can reduce the size of the dataset, which helps reduce the consumption of computing resources and improves processing speed. Removing special characters helps reduce noise in the data, which can simplify the learning process of the model and improve its generalization ability to new data. Converting all text to lowercase ensures data consistency and avoids data duplication caused by different letter cases. For example, "CWE-190" and "cwe-190" may be considered different entities in different capitalizations, and unifying to lowercase can eliminate this ambiguity.

[0053] S23: Divide the preprocessed text into independent words;

[0054] Specifically, for example, the description text of entity CWE-190 "The product performs acalculation that can produce an integer overflow." becomes "product performs calculation produce integer overflow" after preprocessing. The preprocessed text is divided into independent words, and becomes "product", "performs", "calculation", "produce", "integer", "overflow".

[0055] By segmenting text into words, complex text data can be simplified into more easily processable units. In this way, the model can focus on understanding and analyzing the meaning of individual words and their role in the text, rather than the complex structure of the entire sentence or paragraph. This design also applies to standardization algorithms, because most natural language processing algorithms, including models such as Doc2vec, are designed to operate on words, and breaking text into words is a basic prerequisite for these algorithms to operate effectively.

[0056] S24: Use the Doc2vec model to train the divided words. After the model training is completed, the model is used to obtain the embedding vector of the entity description information. The length of all embedded vectors is a fixed value.

[0057] Specifically, all description texts are divided into words and then input into the Doc2vec model, and the model parameters such as embedding vector size, window size, minimum word frequency, learning rate, etc. are set for training. The Doc2vec model is a model based on a neural network that converts text into a fixed-dimensional vector representation, which can efficiently vectorize text data. For each entity description information, the model generates an embedding vector that captures the semantic characteristics of the entity description, and all generated embedding vectors have the same length, which is set during the model training phase.

[0058] This design is because Doc2vec is a neural network-based model that can learn contextual information about words in a text, thereby capturing the semantic connection between word meanings. Compared to the Word2vec model that only targets a single word, the Doc2vec model can represent the vectorized representation of the entire document (or a longer text fragment), which is essential for capturing more complex text features. This design approach using the Doc2vec model is both efficient and flexible when dealing with complex natural language tasks, and can generate rich and meaningful feature representations.

[0059] S3: The positive triplet set and the corresponding negative triplet set are combined into positive and negative triplet pairs and input into the TransE model. The embedding vectors of entities and relations are initialized by Pytorch's Embedding module, and the scoring function scores of the positive and negative triplet are calculated together with the embedding vectors of the entity description information.

[0060] Specifically, for example, the positive triples (CVE-2017-6341, has_problem_type, CWE-200) in the positive triple set and the negative triples (CVE-2017-6341, has_problem_type, CWE-78) in the corresponding negative triple set are combined into positive and negative triple pairs, and are input into the TransE model. An initial random embedding vector is created for each unique entity and relationship through the Embedding module of Pytorch called in the TransE model. For example, for the entities "CVE-2017-6341", "CWE-200", "CWE-78" and the relationship "has_problem_type", there will be their own embedding vectors. Then, together with the embedding vector of the entity description information, the scoring function score of the positive and negative triples is calculated according to the expression of the scoring function.

[0061] This design can integrate entity description information into the TransE model. Combining traditional knowledge graphs and entity description information can provide more comprehensive information, which helps to understand and represent entities and relationships more accurately. Using structured triples alone may not be able to fully capture the complexity of entities and relationships, while combining entity description information can increase the semantic richness of the embedding vector and help the model learn and predict the relationship between entities more accurately.

[0062] The TransE model is a knowledge representation learning model based on translation. The core idea is to represent entities and relations as embedding vectors and represent the relationship between entities through translation operations. The model assumes that each entity can be represented as an embedding vector, and the relationship can be represented as the embedding vector distance between two entities. For a triple (h, r, t), the TransE model regards the relationship embedding vector r as the embedding vector from the head entity embedding vector h to the tail entity embedding vector t, and hopes that the entity embedding vector and the relationship embedding vector in a positive triple are relationship.

[0063] The scoring function score of the positive and negative example triples is calculated together with the embedding vector of the entity description information, including:

[0064] The scoring function of the positive example triple is:

[0065]

[0066] The scoring function of the negative example triple is:

[0067]

[0068] The entity embedding vector and the relationship embedding vector are initialized and subsequently updated by the Embedding module of Pytorch. h represents the head entity in the positive triple, r represents the relationship in the triple, and t represents the tail entity in the positive triple. h represents the head entity embedding vector in the positive triple, r represents the relationship embedding vector, t represents the tail entity embedding vector in the positive triple, and h D and t D They represent the description information embedding vectors of the head entity and the tail entity in the positive triplet, respectively; h′ represents the head entity in the negative triplet, t′ represents the tail entity in the negative triplet, and h′ D and t′ D They represent the description information embedding vectors of the head entity and the tail entity in the negative example triplet respectively; λ is a hyperparameter for controlling the weight, and L1 and L2 represent the L1 norm and L2 norm respectively.

[0069] S4: Integrate the similarity values ​​between entities into the loss function of the TransE model, use the scores of the scoring function and the similarity values ​​between entities to calculate the loss function, and then back-propagate the loss function to continuously update the embedding vectors of entities and relationships, and obtain the final TransE model that integrates entity structure information and description information.

[0070] Specifically, based on the idea that similar entities in the knowledge graph should be as close as possible in the vector space so as to maintain the original structural features in the vector space, the original loss function of the TransE model can be optimized and calculated based on the scoring function and the similarity value between entities, and the entity structure information can also be integrated into the TransE model, so that the entities and relationships in the knowledge graph can be embedded as vectors while retaining the structural information of the knowledge graph. The loss function is then back-propagated, and the embedding vectors of entities and relationships are continuously updated according to the gradient of the loss function until the training is completed or the model converges. Finally, the model outputs accurate embedding vectors of entities and relationships after training, uses verification and test data to evaluate the effectiveness of the model, and performs entity prediction tasks based on the scores of the triple scoring function to predict the hidden threats of vulnerabilities and improve the data information of the smart device vulnerability knowledge graph. This is the final TransE model that integrates entity structure information and entity description information.

[0071] This design can integrate both entity structure information and entity description information into the TransE model. The similarity value is calculated through the structural neighborhood of the entity, which reflects the semantic similarity of the entity to a certain extent; the knowledge is supplemented by the entity description text, because the entity description contains rich text information. These entity structure information and description information can help build a more accurate knowledge representation, so it can more effectively predict the hidden threats of vulnerabilities and correct the wrong information in the vulnerability library.

[0072] The loss function is calculated using the scoring function score and the similarity value between entities, including:

[0073] The loss function is calculated using the scoring function scores of the positive and negative example triples and the similarity values ​​between entities.

[0074]

[0075] Where S and S′ represent the set of positive triples and the set of negative triples respectively, n represents the number of all entities in the training set, and e i 、e j Entity e i 、e jThe embedding vector representation of ; μ is a hyperparameter used to adjust the proportion of the structural features of the entity in the loss function; γ is also a hyperparameter, which represents the minimum interval between the scoring function scores of the positive triplet and the scoring function scores of the negative triplet.

[0076] As can be seen from the above embodiments, the present application first constructs the ontology structure of the smart device vulnerability knowledge graph for the relevant information of smart device vulnerabilities, and extracts the information required by the ontology from the semi-structured data of each vulnerability library, and combines this information into triples according to the ontology structure to construct the smart device vulnerability knowledge graph, thereby ensuring the comprehensiveness and diversity of the data. The traditional knowledge representation learning model TransE only considers the structural information of the knowledge graph, that is, the structural information of the triples, and does not utilize the multivariate information of the entity. However, the present application considers the entity structure information and entity description information, introduces the structural neighborhood of the entity to calculate the similarity between entities, and generates a text embedding vector through the entity description text, and proposes a TransE model that integrates the entity structure information and entity description information. The entity embedding vector trained by this model is used to predict on the basis of the original smart device vulnerability knowledge graph, and hidden threats that do not exist in the vulnerability library but exist in the real world can be mined, providing auxiliary analysis for the security of the Internet of Things. This new model can improve the accuracy of entity prediction, better learn the multi-source heterogeneous content information in the smart device vulnerability knowledge graph, improve the knowledge representation ability of the TransE model, effectively predict the hidden threats of vulnerabilities, and correct the erroneous information in the vulnerability library.

[0077] Corresponding to the aforementioned embodiment of the method for constructing a knowledge representation learning model based on the smart device vulnerability knowledge graph, the present application also provides an embodiment of a device for constructing a knowledge representation learning model based on the smart device vulnerability knowledge graph.

[0078] Figure 3 The present invention is a block diagram of a device for constructing a knowledge representation learning model based on a knowledge graph of smart device vulnerabilities according to an exemplary embodiment. Figure 3 , the device comprises:

[0079] The data set generation module 1 is used to construct a smart device vulnerability knowledge graph ontology according to the characteristics of smart device vulnerabilities, obtain corresponding entity, attribute and relationship information from each vulnerability library according to the ontology, and thus combine and generate a smart device vulnerability knowledge graph data set, use the data set to determine a training set, a positive triple set and a negative triple set, and use these sets to train the embedding vectors of entities and relationships;

[0080] Embedding vector acquisition module 2, used to calculate the similarity value between entities according to the structural neighborhood between entities, and obtain the embedding vector of entity description information through Doc2vec model training using the training set;

[0081] Scoring calculation module 3, used to combine the positive triplet set and the corresponding negative triplet set into positive and negative triplet pairs and input them into the TransE model, initialize the embedding vectors of entities and relationships through the Embedding module of Pytorch, and calculate the scoring function scores of the positive and negative triplet together with the embedding vectors of the entity description information;

[0082] Model generation module 4 is used to integrate the similarity values ​​between entities into the loss function of the TransE model, calculate the loss function using the score of the scoring function and the similarity values ​​between entities, and then back-propagate the loss function to continuously update the embedding vectors of entities and relationships to obtain the final TransE model that integrates entity structure information and description information.

[0083] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0084] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present application scheme. A person of ordinary skill in the art can understand and implement it without paying any creative work.

[0085] Correspondingly, the present application also provides an electronic device, including: one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned knowledge representation learning model construction method based on the smart device vulnerability knowledge graph.

[0086] Correspondingly, the present application also provides a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, the method for constructing a knowledge representation learning model based on the smart device vulnerability knowledge graph as described above is implemented.

[0087] Those skilled in the art will readily appreciate other embodiments of the present application after considering the description and practicing the contents disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The description and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the claims.

[0088] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A method for constructing a knowledge representation learning model based on a smart device vulnerability knowledge graph, characterized in that: include: According to the characteristics of smart device vulnerabilities, a smart device vulnerability knowledge graph ontology is constructed. According to the ontology, corresponding entity, attribute and relationship information are obtained from each vulnerability library, so as to generate a smart device vulnerability knowledge graph dataset. The dataset is used to determine a training set, a positive triple set and a negative triple set, and these sets are used to train the embedding vectors of entities and relationships. The similarity between entities is calculated according to the structural neighborhood between entities, and the embedding vector of entity description information is obtained by training the Doc2vec model using the training set; the structural neighborhood between entities means that in the knowledge graph, each entity has its structural neighborhood, which refers to other entities and relationships directly connected to the entity; The positive triplet set and the corresponding negative triplet set are combined into positive and negative triplet pairs and input into the TransE model. The embedding vectors of entities and relations are initialized by Pytorch's Embedding module, and the scoring function scores of positive and negative triplet are calculated together with the embedding vectors of the entity description information. Integrate the similarity value between entities into the loss function of the TransE model, use the score of the scoring function and the similarity value between entities to calculate the loss function, and then back-propagate the loss function to continuously update the embedding vectors of entities and relationships, so as to obtain the final TransE model that integrates entity structure information and description information; The scoring function score of the positive and negative example triples is calculated together with the embedding vector of the entity description information, including: The scoring function of the positive example triple is: The scoring function of the negative example triple is: Where h represents the head entity in the positive triple, r represents the relationship in the triple, and t represents the tail entity in the positive triple; h represents the embedding vector of the head entity in the positive triple, r represents the embedding vector of the relationship, t represents the embedding vector of the tail entity in the positive triple, and h D and t D They represent the description information embedding vectors of the head entity and the tail entity in the positive triplet, respectively; h′ represents the head entity in the negative triplet, t′ represents the tail entity in the negative triplet, and h′ D and t′ D They represent the description information embedding vectors of the head entity and the tail entity in the negative example triplet respectively; λ is a hyperparameter for controlling the weight, L1 and L2 represent the L1 norm and the L2 norm respectively; the head entity embedding vector, the tail entity embedding vector and the relationship embedding vector are initialized and subsequently updated by the Embedding module of Pytorch; Among them, the loss function is calculated using the scoring function score and the similarity value between entities, including: The loss function is calculated using the scoring function scores of the positive and negative example triples and the similarity values ​​between entities. Where S and S′ represent the set of positive triples and the set of negative triples respectively, n represents the number of all entities in the training set, and e i 、e j Entity e i 、e j The embedding vector representation of ; μ is a hyperparameter used to adjust the proportion of the structural features of the entity in the loss function; γ is also a hyperparameter, which represents the minimum interval between the scoring function scores of the positive triplet and the scoring function scores of the negative triplet.

2. The method according to claim 1, characterized in that The smart device vulnerability knowledge graph dataset is used to determine the training set, positive triple set, and negative triple set, including: The data obtained from each vulnerability library is used to generate triple data in the form of (head entity, relationship, tail entity) according to the smart device vulnerability knowledge graph ontology. These triple data are saved in a file to obtain a positive triple set, where each line of the file is a positive triple; Extracting a portion from the positive example triple set as a training set; According to the positive example triple set, a corresponding negative example triple set is constructed, where the negative example triple set is obtained by randomly replacing the head entity or the tail entity of the positive example triples, and is different from any triple in the positive example triples.

3. The method according to claim 1, characterized in that The similarity between entities is calculated based on their structural neighborhoods, including: Calculate the similarity value sim(e1, e2) between entity e1 and entity e2 based on the entity's structural domain set: Where N(e1) represents the set of structural neighborhoods of entity e1, N(e2) represents the set of structural neighborhoods of entity e2, and H(θ) represents the number of entities in the knowledge graph that have structural neighborhood θ.

4. The method according to claim 1, characterized in that The training set is used to obtain the embedding vector of entity description information through the Doc2vec model, including: Obtain the description text of the entity in the smart device vulnerability knowledge graph, and perform preprocessing operations on all the texts separately; Divide the preprocessed text into individual words; The Doc2vec model is used to train the divided words. After the model training is completed, the model is used to obtain the embedding vector of the entity description information. The length of all embedded vectors is a fixed value.

5. The method according to claim 4, characterized in that The pre-processing operations include removing stop words, special characters, and converting the text to lower case.

6. A knowledge representation learning model construction device based on the smart device vulnerability knowledge graph, characterized in that: include: A data set generation module is used to construct a smart device vulnerability knowledge graph ontology according to the characteristics of smart device vulnerabilities, obtain corresponding entity, attribute and relationship information from each vulnerability library according to the ontology, and thus combine and generate a smart device vulnerability knowledge graph data set, use the data set to determine a training set, a positive triple set and a negative triple set, and use these sets to train the embedding vectors of entities and relationships; An embedding vector acquisition module is used to calculate the similarity value between entities according to the structural neighborhood between entities, and obtain the embedding vector of entity description information by training the Doc2vec model using the training set; the structural neighborhood between entities means that in the knowledge graph, each entity has its structural neighborhood, which refers to other entities and relationships directly connected to the entity; A scoring calculation module, which is used to combine the positive triplet set and the corresponding negative triplet set into positive and negative triplet pairs and input them into the TransE model, initialize the embedding vectors of entities and relationships through the Embedding module of Pytorch, and calculate the scoring function scores of the positive and negative triplet together with the embedding vectors of the entity description information; A model generation module is used to integrate the similarity values ​​between entities into the loss function of the TransE model, calculate the loss function using the score of the scoring function and the similarity values ​​between entities, and then back-propagate the loss function to continuously update the embedding vectors of entities and relationships, so as to obtain the final TransE model that integrates entity structure information and description information; The scoring function score of the positive and negative example triples is calculated together with the embedding vector of the entity description information, including: The scoring function of the positive example triple is: The scoring function of the negative example triple is: Where h represents the head entity in the positive triple, r represents the relationship in the triple, and t represents the tail entity in the positive triple; h represents the embedding vector of the head entity in the positive triple, r represents the embedding vector of the relationship, represents the embedding vector of the tail entity in the positive triple, and h D and t D They represent the description information embedding vectors of the head entity and the tail entity in the positive triplet, respectively; h′ represents the head entity in the negative triplet, t′ represents the tail entity in the negative triplet, and h′ D and t′ D They represent the description information embedding vectors of the head entity and the tail entity in the negative example triplet respectively; λ is a hyperparameter for controlling the weight, L1 and L2 represent the L1 norm and the L2 norm respectively; the head entity embedding vector, the tail entity embedding vector and the relationship embedding vector are initialized and subsequently updated by the Embedding module of Pytorch; Among them, the loss function is calculated using the scoring function score and the similarity value between entities, including: The loss function is calculated using the scoring function scores of the positive and negative example triples and the similarity values ​​between entities. Where S and S′ represent the set of positive triples and the set of negative triples respectively, n represents the number of all entities in the training set, and e i 、e j Entity e i 、e j The embedding vector representation of ; μ is a hyperparameter used to adjust the proportion of the structural features of the entity in the loss function; γ is also a hyperparameter, which represents the minimum interval between the scoring function scores of the positive triplet and the scoring function scores of the negative triplet.

7. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instruction is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.