Network threat intelligence relation extraction method based on attention context mapping and relation matching
Through a deep neural network model based on attention context mapping and relationship matching, the problems of complexity and weak correlation in network threat intelligence are solved, and more accurate relationship extraction and classification are achieved.
Patent Information
- Application Number
- CN202411019755.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-07-26
AI Technical Summary
The network threat intelligence relationship extraction technology faces the problems of complex entity words, semantic abstraction, large density of single sentence entities, easy confusion of entity characteristics, and weak correlation between entities, resulting in insufficient accuracy of relationship classification.
Using a deep neural network model based on attention context mapping and relationship matching, text encoding and entity label depth encoding are performed through the BERT model, and entity representation and relationship characteristics are enhanced by the attention mechanism, and information fusion and interaction are used by multi-layer perceptrons to achieve Relationship matching and classification.
It improves the accuracy and classification accuracy of network threat intelligence relationship extraction, which is significantly better than traditional neural network-based models, and can better identify complex and abstract entity relationships.
Smart Images

Figure CN119003785A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network security technology, and more specifically, to a network threat intelligence relationship extraction method based on attention context mapping and relationship matching. Background Art
[0002] As the complexity of cyberspace increases, cyber attacks such as phishing, deception, and extortion are also increasing, and are becoming more complex and diverse. This poses a great threat to the cyberspace security of countries and enterprises. These cyberspaces often involve a large amount of private data and even state secrets. Once they are maliciously invaded and the system cannot respond in time, the consequences will be disastrous. The existing cyberspace defense technology can be divided into two parts: 1) Using intrusion detection technology, when the system detects a cyber attack event, it will take timely defense to respond to the attack. 2) Based on historical attack records, develop and deploy new security solutions. However, attackers always try new attack techniques, attack strategies, and malware, so it is impossible to update relevant defense strategies in a timely manner.
[0003] The knowledge graph is very suitable for tracing and tracing cyber attacks and mining potential threats due to its structured storage method, efficient search capability, and simple and clear visualization. At the same time, with the explosion of big data technology, mining threat information from massive cyber threat intelligence data and building a cyber threat intelligence knowledge graph can be used as a new cyberspace security solution. However, cyber threat intelligence is presented in the form of unstructured data and cannot be directly stored as a knowledge graph. Therefore, it is necessary to convert massive cyber threat intelligence data from unstructured form to structured form through natural language processing technologies such as named entity recognition, relationship extraction, and entity disambiguation. Relation extraction is the key step in data conversion.
[0004] Cyber threat intelligence relationship extraction is also called relationship classification. The main process is to identify and determine the relationship between two known entities. The main task is to extract relationships by deeply mining and analyzing entity information and the context information of the entities. Finally, the classified relationship triples are stored.
[0005] Compared with the relationship extraction technology in general fields, the network threat intelligence relationship extraction technology has the following difficulties due to the different entities and relationship forms it focuses on: (a) The entity words of network threat intelligence are more complex and more abstract in semantics. (b) The entity density of a single sentence in network threat intelligence is usually high, and the entity features are easily confused, so it is necessary to deeply mine fine-grained features. (c) Indirect associations are likely to occur between pairs of network threat intelligence entities, resulting in weak correlation between entities and the inability to accurately determine the relationship category.
[0006] Therefore, a network threat intelligence relation extraction method based on attention context mapping and relation matching is desired. Summary of the invention
[0007] In view of the above problems, the present invention proposes a network threat intelligence relationship extraction method based on attention context mapping and relationship matching. The model is based on a deep neural network and adopts the following technical solutions: (a) Use the BERT model pre-trained with large-scale general text data to vector encode the input text to obtain a preliminary text vector representation. The BERT model pre-trained with large-scale general text data has acquired some potential semantic information of the text, so the vector representation obtained by encoding the threat intelligence text already contains rich general prior knowledge and potential semantics. (b) The problem of entity semantic abstraction and easy confusion of entity features is alleviated through the attention-based context mapping method. (c) The problem of weak correlation between entities is alleviated through the relationship matching mechanism.
[0008] Accordingly, according to one aspect of the present application, a network threat intelligence relationship extraction method based on attention context mapping and relationship matching is provided, which includes:
[0009] Construct the encoding layer of the network threat intelligence relationship extraction model;
[0010] Constructing an attention-based context mapping layer for the network threat intelligence relation extraction model;
[0011] Construct the relationship matching layer of the network threat intelligence relationship extraction model;
[0012] Train the model using the HACKER dataset;
[0013] Feed massive amounts of cyber threat intelligence into the model.
[0014] In the above-mentioned network threat intelligence relationship extraction method based on attention context mapping and relationship matching, the encoding layer of the network threat intelligence relationship extraction model is constructed, including:
[0015] Given a sentence Seq as input;
[0016] Each word in the sentence Seq is further decomposed into a series of finer word segmentation units, and the word segmentation set sequence representation E = {e1, e2, ..., e n}, where e i represents the number of each participle, and n represents the length of the participle of the sentence;
[0017] Use the BERT model to encode it and obtain a new sentence representation sequence where d s Indicatesi The dimension is as follows:
[0018] S=BERT(E)={s1,s2,…,s n}.
[0019] In the above-mentioned network threat intelligence relationship extraction method based on attention context mapping and relationship matching, an attention-based context mapping layer of the network threat intelligence relationship extraction model is constructed, including: using a pre-trained BERT model to deeply encode entity and relationship labels to obtain an entity label word embedding matrix Pe and a relationship label word embedding matrix Pr rich in semantic information; taking entity pairs whose relationships need to be identified as a whole to integrate potential entity association information, enhance the difference representation between entity pairs, and obtain a new entity pair representation sequence ef'; combining the relationship label word embedding matrix Pr with the context feature vector ct to obtain a new relationship context feature matrix Cr'; using the attention mechanism to combine the entity pair representation sequence ef' with the relationship context feature matrix Cr' to obtain a relationship context enhanced sequence representation Cp specific to the entity pair.
[0020] In the above-mentioned network threat intelligence relationship extraction method based on attention context mapping and relationship matching, the pre-trained BERT model is used to deeply encode the entity and relationship labels to obtain the entity label word embedding matrix Pe and the relationship label word embedding matrix Pr rich in semantic information, which are used to: obtain the entity and relationship type word embedding, input the entity label set el and the relationship label set rl into the pre-trained BERT model for semantic encoding, and obtain the entity label word embedding matrix And the relationship label word embedding matrix The formula is as follows:
[0021] Pe=BERT(el)={pe1,pe2,...,pe z}
[0022] Pr=BERT(rl)={pr1,pr2,...,pr r}
[0023] Among them, d e is the embedding dimension of entity type label words, z represents the number of entity type label words, and d r is the embedding dimension of the relationship type label word, and r is the number of relationship type label words.
[0024] In the above-mentioned network threat intelligence relationship extraction method based on attention context mapping and relationship matching, the entity pairs whose relationships need to be identified are taken as a whole to integrate the potential entity association information, enhance the difference representation between the entity pairs, and obtain a new entity pair representation sequence ef', which is used to: generate the initial head entity span size embedding vector s_h and the tail entity span size embedding vector s_t through a random initialization method. In the multi-layer nonlinear transformation process of the multi-layer perceptron, the span size information can be deeply integrated with the original span representation, so as to generate an enhanced entity representation for the two entities that contains both the original text information and rich in size feature information, where the head entity is represented as eh and the tail entity is represented as et. The formula is as follows:
[0025] eh=[s h ; s_h]·W h +b h
[0026] eh'=tanh(eh)
[0027] et=[s t ; s_t]·W t +b t
[0028] et'=tanh(et)
[0029] in, and is a learnable parameter, d se is the dimension of the stride embedding, [;] represents the vector concatenation operation, tanh represents the hyperbolic tangent activation function, s h is the header entity encoding vector obtained from the previous layer, s t The tail entity encoding vector obtained from the previous layer;
[0030] The entity pair is regarded as an indivisible whole unit. By introducing a multi-layer perceptron as a fusion mechanism, the sequence representations of the head entity and the tail entity are deeply integrated to capture the interaction and dependency between them, thereby generating a first entity label pair sequence ep'; the head entity label encoding vector and the tail entity label encoding vector are fused to generate a second entity label pair sequence elp'; the third multi-layer perceptron is used to fuse the entity pair sequence representation ep' with the entity label pair sequence representation elp' to generate an entity label pair enhanced entity pair sequence es' that contains both sequence information and semantic knowledge; the distance between the two entities is randomly initialized to obtain an embedded sequence epe; through the fourth multi-layer perceptron, the distance information of the two entities is fused into the entity label pair enhanced entity pair sequence es' to generate the final entity pair representation sequence ef'; the formula is as follows:
[0031] ep=[e h ;e t ]·W ht +b ht
[0032] ep'=tanh(ep)
[0033] elp=[pe h ;pe t ]·W pl +b pl
[0034] elp'=tnnh(elp
[0035] es=[ep';elp']·W el +b el
[0036] es'=tanh(es)
[0037] ef=[es';epe]·W ef +b ef
[0038] ef'=tanh(ef
[0039] in, and is a learnable parameter, d pe is the dimension of entity pair spacing embedding, pe h Encode the vector for the head entity label, pe t Encode the vector for the tail entity label.
[0040] In the above-mentioned network threat intelligence relationship extraction method based on attention context mapping and relationship matching, the relationship label word embedding matrix Pr is combined with the context feature vector ct to obtain a new relationship context feature matrix Cr', which is used to: embed all the relationship label words into the matrix They are respectively combined with the context feature vector, and the information interaction and fusion between the two are realized through the multi-layer nonlinear transformation of the multi-layer perceptron to generate a context representation matrix Cr' specific to the relationship. The formula is as follows:
[0041] Cr=[ct;Pr]·W cr +b cr
[0042] Cr'=tanh(Cr)
[0043] in, and are learnable parameters.
[0044] In the above-mentioned network threat intelligence relationship extraction method based on attention context mapping and relationship matching, the entity pair representation sequence ef' is combined with the relationship context feature matrix Cr' using the attention mechanism to obtain the entity pair-specific relationship context enhanced sequence representation Cp, which is used to: measure the importance of each context element for the current entity pair relationship recognition by calculating the attention weight, and accordingly perform weighted adjustment on the relationship-based context sequence representation, and after enhancement by the attention mechanism, obtain the entity pair-specific relationship context enhanced sequence representation Cp, the formula is as follows:
[0045]
[0046] Cp=score·Cr'
[0047] in, and is a learnable parameter and softmax represents the softmax activation function.
[0048] In the above-mentioned network threat intelligence relationship extraction method based on attention context mapping and relationship matching, a relationship matching layer of the network threat intelligence relationship extraction model is constructed, including:
[0049] The cosine similarity calculation is performed on the relationship label word embedding matrix Pr and the entity-specific relationship context enhanced sequence representation Cp to obtain a similarity score The formula is as follows:
[0050]
[0051] Among them, |||| represents the bi-norm of the vector, and i represents the i-th relationship label;
[0052] The cosine similarity calculation is performed on the relationship label word embedding matrix Pr and the entity pair sequence representation ep' to obtain a similarity score The formula is as follows:
[0053]
[0054] Among them, j represents the jth relationship label
[0055] The similarity score and similarity score Adaptive weighted fusion is performed to obtain the final relationship classification score sc', and finally the relationship with the largest classification score is output. The formula is as follows:
[0056]
[0057] sc'=softmax(sc
[0058] Among them, α is a trainable adaptive fusion parameter.
[0059] In the above-mentioned network threat intelligence relationship extraction method based on attention context mapping and relationship matching, the HACKER dataset is used to train the model, which is used to: input the HACKER dataset into the network threat intelligence relationship extraction model for 50 iterations of training, select the parameter setting when the best effect is achieved, and obtain the best network threat intelligence relationship extraction model. The Label Smoothing Loss loss function is selected as the loss function used in training. The formula is as follows:
[0060]
[0061] Where L is the loss function, is the label distribution of the i-th category after smoothing, ε is the smoothing parameter (a small constant), y is the label of the true category, sc i is the probability of the i-th category predicted by the model.
[0062] In the above-mentioned network threat intelligence relationship extraction method based on attention context mapping and relationship matching, massive network threat intelligence is input into the model for: dividing the massive network threat intelligence into sentences, and after completing entity extraction, inputting the network threat intelligence relationship extraction model to obtain the final relationship triples.
[0063] Compared with the prior art, the present invention proposes a network threat intelligence relationship extraction model based on attention context mapping and relationship matching. The model is designed to address the existing difficulties in relationship extraction technology in the field of network threat intelligence. By deeply mining the potential information of entities and enhancing the interaction between entities and the surrounding text environment, the problem of complex entity words and abstract semantics is alleviated. Using an attention-based context mapping mechanism, entity pairs are directly regarded as a whole to interact with context information, alleviating the problem of high entity density in a single sentence and easy confusion of entity features. Using a relationship matching mechanism, relationship label information is fused and interacted with context information and entity pair information, and at the same time, the classification accuracy is improved by collaboratively processing relationship classification, alleviating the problem that indirect associations are easy to occur between entity pairs, resulting in weak correlation between entities and inability to accurately judge relationship categories. In the field of network threat intelligence, compared with traditional neural network-based relationship extraction models, the recognition effect of the present invention has significant advantages. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 This is an overall flow chart of a network threat intelligence relationship extraction method based on attention context mapping and relationship matching according to an embodiment of the present application. DETAILED DESCRIPTION
[0065] Various exemplary embodiments, features and aspects of the present application will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0066] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0067] In addition, in order to better illustrate the present application, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present application can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present application.
[0068] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0069] Figure 1 The figure shows an overall flow chart of a network threat intelligence relationship extraction method based on attention context mapping and relationship matching according to an embodiment of the present application. Figure 1 As shown, according to the network threat intelligence relationship extraction method based on attention context mapping and relationship matching according to the embodiment of the present application, the specific steps include: constructing an encoding layer of a network threat intelligence relationship extraction model; constructing an attention-based context mapping layer of a network threat intelligence relationship extraction model; constructing a relationship matching layer of a network threat intelligence relationship extraction model; training the model using the HACKER dataset; and inputting massive network threat intelligence into the model.
[0070] In the steps of the embodiment of the present application, the coding layer of the network threat intelligence relationship extraction model is constructed. It should be understood that the core function of the coding layer is to convert the input network threat intelligence text data into a vectorized representation form that the computer can effectively recognize and process. This process is intended to not only retain the structural characteristics of the text data, but also to dig deep and capture the deep semantic information contained in the sentence and word level, thereby laying a solid foundation for subsequent threat analysis and identification tasks. The coding layer usually uses a deep learning model, such as BERT (Bidirectional Encoder Representations from Transformers), to capture contextual information in the text. This is crucial for understanding the semantics of words in sentences. Accordingly, the network threat intelligence sentence sequence is input into the BERT model for encoding to obtain the context feature vector sequence ct and the word segmentation feature matrix S of the sentence.
[0071] Specifically, in one embodiment of the present application, the encoding layer of the network threat intelligence relationship extraction model is constructed, including: given a sentence Seq as input; each word in the sentence Seq is further decomposed into a series of finer word segmentation units to obtain a word segmentation set sequence representation E = {e1, e2, ..., e m}, where e i represents the number of each word segmentation, and n represents the word segmentation length of the sentence; it is encoded using the BERT model to obtain a new sentence representation sequence where d s Indicates i The dimension is as follows:
[0072] S=BERT(E)={s1,s2,…,s n}.
[0073] In the steps of the embodiment of the present application, the attention-based context mapping layer of the network threat intelligence relationship extraction model is constructed. It should be understood that the purpose of the attention-based context mapping layer is to obtain the subtle differences between entity pairs, as well as the interactive information between entity pairs and various relationship labels in the corresponding context, and to enhance the model's ability to capture the intrinsic connection between entity pairs and relationship labels. Provide rich feature support and powerful decision-making basis for subsequent relationship classification or identification. In network threat intelligence, the relationship between entities may be very subtle and complex. The attention mechanism can help the model identify and emphasize the specific connection between entities. Compared with traditional recurrent neural networks (RNNs), attention mechanisms usually have fewer parameters, which can reduce the computational complexity and resource consumption of the model. In the relationship extraction task, it is crucial to correctly identify the exact relationship between entities. The attention mechanism can improve the model's ability to identify these relationships, especially when the relationship is not obvious or ambiguous. When processing long texts or complex sentence structures, the attention mechanism can effectively capture long-distance dependencies, which is particularly important for understanding long-distance entity relationships in texts.
[0074] Specifically, in one embodiment of the present application, an attention-based context mapping layer of a network threat intelligence relationship extraction model is constructed, including: using a pre-trained BERT model to deeply encode entity and relationship labels to obtain an entity label word embedding matrix Pe and a relationship label word embedding matrix Pr that are rich in semantic information; integrating potential entity association information as a whole based on entity pairs whose relationships need to be identified, enhancing the difference representation between entity pairs, and obtaining a new entity pair representation sequence ef'; combining the relationship label word embedding matrix Pr with a context feature vector ct to obtain a new relationship context feature matrix Cr'; using an attention mechanism to combine the entity pair representation sequence ef' with the relationship context feature matrix Cr' to obtain a relationship context enhanced sequence representation Cp specific to entity pairs.
[0075] Accordingly, in a specific example of the present application, a pre-trained BERT model is used to deeply encode entity and relationship labels to obtain an entity label word embedding matrix pe and a relationship label word embedding matrix Pr that are rich in semantic information. It should be understood that the BERT model can capture rich semantic information and contextual relationships by training on a large-scale corpus. This enables it to provide deep semantic encoding for entity and relationship labels and enhance the model's ability to understand text. The pre-trained BERT model has been trained on a wide range of text data and has good generalization capabilities. This means that it can handle various types of text, including specific terms and expressions in network threat intelligence. Specifically, it includes: obtaining entity and relationship type word embeddings, inputting the entity label set el and the relationship label set rl into the pre-trained BERT model for semantic encoding, and obtaining the entity label word embedding matrix And the relationship label word embedding matrix The formula is as follows:
[0076] Pe=BERT(el)={pe1,pe2,…,pe z}
[0077] Pr=BERT(rl)={pr1,pr2,…,pr r}
[0078] Among them, d e is the embedding dimension of entity type label words, z represents the number of entity type label words, and d r is the embedding dimension of the relationship type label word, and r is the number of relationship type label words.
[0079] Accordingly, in a specific example of the present application, the entity pairs whose relationships need to be identified are used as a whole to integrate potential entity association information, enhance the difference representation between entity pairs, and obtain a new entity pair representation sequence ef'. It should be understood that in order to enrich and enhance the expressive power of the entity span representation sequence, a multi-layer perceptron is used to seamlessly integrate the span size information of the entity into its span representation. Specifically, the initial head entity span size embedding vector s_h and the tail entity span size embedding vector s_t are generated by a random initialization method. In the multi-layer nonlinear transformation process of the multi-layer perceptron, the span size information is deeply integrated with the original span representation, thereby generating an enhanced entity representation for the two entities that contains both the original text information and rich in size feature information, where the head entity is represented as eh and the tail entity is represented as et. The formula is as follows:
[0080] eh=[s h ; s_h]·W h +b h
[0081] eh'=tanh(eh)
[0082] et=[s t ; s_t]·W t +b t
[0083] et'=tanh(et)
[0084] in, and is a learnable parameter, d se is the dimension of the stride embedding, [;] represents the vector concatenation operation, tanh represents the hyperbolic tangent activation function, s h is the header entity encoding vector obtained from the previous layer, s tIt is the tail entity encoding vector obtained from the previous layer.
[0085] Furthermore, in order to deeply explore the intrinsic connection between the two entities and improve the model's ability to identify fine-grained differences between entity pairs, an overall fusion and enhancement strategy is adopted. Specifically, first, the entity pair is regarded as an indivisible whole unit. By introducing a multi-layer perceptron as a fusion mechanism, the sequence representations of the head entity and the tail entity are deeply integrated to capture the interaction and dependency between them, thereby generating a new entity pair sequence representation ep'. This process effectively integrates the feature information of the head and tail entities, laying the foundation for subsequent analysis. Then, in order to further enhance the semantic richness of the entity pair representation, we again use the multi-layer perceptron to fuse the head entity label and the tail entity label, aiming to integrate the semantic knowledge contained in the label information into the entity pair representation and generate a new entity label pair sequence representation elp'. This step not only retains the category information of the label, but also enhances the discriminative power of the entity pair representation through the fusion process. Subsequently, in order to combine the advantages of the entity pair sequence representation ep' and the entity label pair sequence representation elp', a third multi-layer perceptron is used to fuse the entity pair sequence representation ep' with the entity label pair sequence representation elp'. This fusion process aims to combine the sequential features of entity pairs with the semantic features of label pairs to generate an entity pair sequence representation es' enhanced by entity label pairs that contains both sequential information and rich semantic knowledge. This representation not only strengthens the feature expression within the entity pair, but also improves the generalization ability of the model in complex scenarios. Finally, in order to more comprehensively characterize the spatial relationship between entity pairs, the spacing information is introduced as an additional feature input, and the spacing between the two entities is randomly initialized to obtain the embedded sequence representation epe. Through the fourth multi-layer perceptron, the spacing information of the two entities is fused into the entity pair sequence representation es' enhanced by the entity label pair to generate the final entity pair representation sequence ef'. This process not only enhances the spatial sensitivity of the entity pair representation, but also enables the model to more accurately capture the subtle differences and intrinsic connections between entity pairs, providing more accurate and rich feature support for subsequent relationship extraction. The formula is as follows:
[0086] ep=[e h ;e t ]·W ht +b ht
[0087] ep'=tanh(ep)
[0088] elp=[pe h ;pe t ]·W pl +b pl
[0089] elp'=tanh(elp)
[0090] es=[ep';elp']·W el +b el
[0091] es'=tanh(es)
[0092] ef=[es';epe]·W ef +b ef
[0093] ef'=tanh(ef
[0094] in, and is a learnable parameter, d pe is the dimension of entity pair spacing embedding, pe h Encode the vector for the head entity label, pe t Encode the vector for the tail entity label.
[0095] Accordingly, in a specific example of the present application, the relationship label word embedding matrix Pr is combined with the context feature vector ct to obtain a new relationship context feature matrix Cr'. It should be understood that in order to construct a context representation specific to the relationship type, a multi-layer perceptron is used as a fusion mechanism to deeply integrate the relationship label information into the context feature vector. Specifically, all the relationship label word embedding matrices They are respectively combined with the context feature vector, and the information interaction and fusion between the two are realized through the multi-layer nonlinear transformation of the multi-layer perceptron to generate a context representation matrix Cr' specific to the relationship. The formula is as follows:
[0096] Cr=[ct;Pr]·W cr +b cr
[0097] Cr'=tanh(Cr)
[0098] in, and are learnable parameters.
[0099] Accordingly, in a specific example of the present application, the entity pair representation sequence ef' is combined with the relationship context feature matrix Cr' using the attention mechanism to obtain the relationship context enhanced sequence representation Cp specific to the entity pair. It should be understood that in order to enhance the interaction between the entity pair and the relationship-based context, the attention mechanism is used to guide the model to adaptively focus on the relationship context information that is more closely related to the entity pair. Specifically, the importance of each context element to the current entity pair relationship recognition is measured by calculating the attention weight, and the relationship-based context sequence representation is weighted and adjusted accordingly. After being enhanced by the attention mechanism, the relationship context enhanced sequence representation Cp specific to the entity pair is obtained, and the formula is as follows:
[0100]
[0101] Cp=score·Cr'
[0102] in, and is a learnable parameter and softmax represents the softmax activation function.
[0103] In the steps of the embodiment of the present application, a relationship matching layer of the network threat intelligence relationship extraction model is constructed. It should be understood that the purpose of the relationship matching layer is to combine the features obtained in the above steps, maximize the accuracy of the model extraction relationship, and finally classify the relationship between entity pairs. Specifically, it includes: in order to achieve a quantitative evaluation of the similarity between the relationship label and the entity pair relationship context, and provide a basis for the final relationship classification, the cosine similarity calculation is performed on the relationship label word embedding matrix Pr and the entity pair-specific relationship context enhanced sequence representation Cp to obtain a similarity score The formula is as follows:
[0104]
[0105] Among them, |||| represents the bi-norm of the vector, and i represents the i-th relationship label;
[0106] In order to achieve a quantitative evaluation of the similarity between the relationship label and the entity pair and provide a basis for the final relationship classification, the cosine similarity calculation is performed on the relationship label word embedding matrix Pr and the entity pair sequence representation ep' to obtain a similarity score The formula is as follows:
[0107]
[0108] Among them, j represents the jth relationship label
[0109] The similarity score and similarity score Adaptive weighted fusion is performed to obtain the final relationship classification score sc', and finally the relationship with the largest classification score is output. The formula is as follows:
[0110]
[0111] sc'=softmax(sc)
[0112] Among them, α is a trainable adaptive fusion parameter.
[0113] It should be understood that the purpose of the relationship matching layer is to combine the features obtained in the above steps, maximize the accuracy of the model in extracting relationships, and finally classify the relationships between entity pairs. The specific steps are as follows:
[0114] In the steps of the embodiment of the present application, the HACKER dataset is used to train the model, which is used to: input the HACKER dataset into the network threat intelligence relationship extraction model for 50 iterations of training, select the parameter setting when the best effect is achieved, and obtain the best network threat intelligence relationship extraction model. In order to alleviate the overfitting problem and the negative impact of noise labels, the Label Smoothing Loss loss function is selected as the loss function used in training, and the formula is as follows:
[0115]
[0116] Where L is the loss function, is the label distribution of the i-th category after smoothing, ε is the smoothing parameter (a small constant), y is the label of the true category, sc i is the probability of the i-th category predicted by the model.
[0117] In the steps of the embodiment of the present application, massive network threat intelligence is input into a model, which is used to: divide the massive network threat intelligence into sentences, and after completing entity extraction, input the network threat intelligence relationship extraction model to obtain the final relationship triples.
[0118] In summary, the network threat intelligence relationship extraction method based on attention context mapping and relationship matching based on the embodiment of the present application is designed to address the existing difficulties in relationship extraction technology in the field of network threat intelligence. By deeply mining the potential information of entities and enhancing the interaction between entities and the surrounding text environment, the problems of complex entity words and abstract semantics are alleviated. Using an attention-based context mapping mechanism, entity pairs are directly viewed as a whole to interact with context information, which alleviates the problem of high entity density in a single sentence and easy confusion of entity features. Using a relationship matching mechanism, relationship label information is fused and interacted with context information and entity pair information, and at the same time, the classification accuracy is improved by collaboratively processing relationship classification, which alleviates the problem that indirect associations are easy to occur between entity pairs, resulting in weak correlations between entities and inability to accurately judge relationship categories. In the field of network threat intelligence, the recognition effect of the present invention is significantly superior to that of traditional neural network-based relationship extraction models.
[0119] The preferred specific embodiments of the present invention are described in detail above. It should be understood that ordinary technicians in the field can make many modifications and changes based on the concept of the present invention without creative work. Therefore, all technical solutions that can be obtained by technicians in the technical field based on the concept of the present invention through logical analysis, reasoning or limited experiments on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A network threat intelligence relationship extraction method based on attention context mapping and relationship matching, characterized in that: include: Construct the encoding layer of the network threat intelligence relationship extraction model; Constructing an attention-based context mapping layer for the network threat intelligence relation extraction model; Construct the relationship matching layer of the network threat intelligence relationship extraction model; Train the model using the HACKER dataset; Feed massive amounts of cyber threat intelligence into the model.
2. According to claim 1, a network threat intelligence relationship extraction method based on attention context mapping and relationship matching is characterized in that: Construct the encoding layer of the network threat intelligence relationship extraction model, including: Given a sentence Seq as input; Each word in the sentence Seq is further decomposed into a series of finer word segmentation units, and the word segmentation set sequence representation E = {e1, e2, ..., e n }, where e i represents the number of each participle, and n represents the length of the participle of the sentence; Use the BERT model to encode it and obtain a new sentence representation sequence where d s Indicates i The dimension is as follows: S=BERT(E)={s1,s2,...,s n }。 3. According to claim 2, a network threat intelligence relationship extraction method based on attention context mapping and relationship matching is characterized in that: Construct an attention-based context mapping layer for the network threat intelligence relation extraction model, including: Use the pre-trained BERT model to deeply encode entity and relationship labels to obtain the entity label word embedding matrix Pe and the relationship label word embedding matrix Pr rich in semantic information; Taking the entity pairs whose relationships need to be identified as a whole, the potential entity association information is integrated to enhance the difference representation between entity pairs and obtain a new entity pair representation sequence ef′; The relationship label word embedding matrix Pr is combined with the context feature vector ct to obtain a new relationship context feature matrix Cr′; The entity pair representation sequence ef′ is combined with the relational context feature matrix Cr′ using an attention mechanism to obtain a relational context enhanced sequence representation Cp specific to the entity pair.
4. According to claim 3, a network threat intelligence relationship extraction method based on attention context mapping and relationship matching is characterized in that: The pre-trained BERT model is used to deeply encode entity and relationship labels to obtain the entity label word embedding matrix Pe and the relationship label word embedding matrix Pr rich in semantic information, which are used to: obtain entity and relationship type word embedding, input the entity label set el and the relationship label set rl into the pre-trained BERT model for semantic encoding, and obtain the entity label word embedding matrix And the relationship label word embedding matrix The formula is as follows: On = BERT(he) = {on1, on2,..., on z } Pr=BERT(rl)={pr1,pr2,…,pr r , Among them, d e is the embedding dimension of entity type label words, z represents the number of entity type label words, and d r is the embedding dimension of the relationship type label word, and r is the number of relationship type label words.
5. According to claim 4, a network threat intelligence relationship extraction method based on attention context mapping and relationship matching is characterized in that: Taking the entity pairs whose relationships need to be identified as a whole, the potential entity association information is integrated, and the difference representation between the entity pairs is enhanced to obtain a new entity pair representation sequence ef′, which is used to: generate the initial head entity span size embedding vector s_h and the tail entity span size embedding vector s_t through a random initialization method. In the multi-layer nonlinear transformation process of the multi-layer perceptron, the span size information is deeply integrated with the original span representation, thereby generating an enhanced entity representation for the two entities that contains both the original text information and rich in size feature information, where the head entity is represented as eh and the tail entity is represented as et. The formula is as follows: eh=[S h ;s_h]·W h +b h eh′=tanh(eh) and=[s t ;s_t]·W t +b t et′=tanh(et) in, and is a learnable parameter, d se is the dimension of the stride embedding, [;] represents the vector concatenation operation, tanh represents the hyperbolic tangent activation function, s h is the header entity encoding vector obtained from the previous layer, s t is the tail entity encoding vector obtained in the previous layer; The entity pair is regarded as an indivisible whole unit. By introducing a multi-layer perceptron as a fusion mechanism, the sequence representations of the head entity and the tail entity are deeply integrated to capture the interaction and dependency between them, thereby generating a first entity label pair sequence ep'; the head entity label encoding vector and the tail entity label encoding vector are fused to generate a second entity label pair sequence elp'; the third multi-layer perceptron is used to fuse the entity pair sequence representation ep' with the entity label pair sequence representation elp' to generate an entity label pair enhanced entity pair sequence es' that contains both sequence information and semantic knowledge; the distance between the two entities is randomly initialized to obtain an embedded sequence epe; through the fourth multi-layer perceptron, the distance information of the two entities is fused into the entity label pair enhanced entity pair sequence es' to generate the final entity pair representation sequence ef'; the formula is as follows: ep=[e h ;have been t ]·W ht +b ht ep′=tanh(ep) elp=[for h ;instead t ]·W pl +b pl elp′=tanh(elp) es=[ep′;elp′]·W el +b el es′=tanh(es) ef=[es′;epe]·W ef +b ef ef′=tanh(ef) in, and is a learnable parameter, d pe is the dimension of entity pair spacing embedding, pe h Encode the vector for the head entity label, pe t Encode the tail entity label vector.
6. According to claim 5, a network threat intelligence relationship extraction method based on attention context mapping and relationship matching is characterized in that: The relationship label word embedding matrix Pr is combined with the context feature vector ct to obtain a new relationship context feature matrix Cr', which is used to embed all relationship label words into the matrix They are respectively combined with the context feature vector, and the information interaction and fusion between the two are realized through the multi-layer nonlinear transformation of the multi-layer perceptron to generate a context representation matrix Cr′ specific to the relationship. The formula is as follows: Cr=[ct;Pr]·W cr +b cr Cr′=tanh(Cr) in, and are learnable parameters.
7. According to claim 6, a network threat intelligence relationship extraction method based on attention context mapping and relationship matching is characterized in that: The entity pair representation sequence ef′ is combined with the relational context feature matrix Cr′ by using the attention mechanism to obtain the relational context enhanced sequence representation Cp specific to the entity pair, which is used to: measure the importance of each context element to the current entity pair relationship recognition by calculating the attention weight, and accordingly perform weighted adjustment on the relation-based context sequence representation. After being enhanced by the attention mechanism, the relational context enhanced sequence representation Cp specific to the entity pair is obtained, and the formula is as follows: Cp=score·Cr′ in, and is a learnable parameter and softmax represents the softmax activation function.
8. According to claim 7, a network threat intelligence relationship extraction method based on attention context mapping and relationship matching is characterized in that: Construct the relationship matching layer of the network threat intelligence relationship extraction model, including: The cosine similarity calculation is performed on the relationship label word embedding matrix Pr and the entity pair-specific relationship context enhanced sequence representation Cp to obtain a similarity score The formula is as follows: Among them, || || represents the bi-norm of the vector, and i represents the i-th relationship label; The cosine similarity calculation is performed on the relationship label word embedding matrix Pr and the entity pair sequence representation ep′ to obtain a similarity score The formula is as follows: Among them, j represents the jth relationship label The similarity score and similarity score Adaptive weighted fusion is performed to obtain the final relationship classification score sc', and finally the relationship with the largest classification score is output. The formula is as follows: sc′=softmax(sc) Among them, α is a trainable adaptive fusion parameter.
9. A network threat intelligence relationship extraction method based on attention context mapping and relationship matching according to claim 8, characterized in that: The HACKER dataset is used to train the model. The HACKER dataset is input into the network threat intelligence relationship extraction model for 50 iterations of training. The parameter setting with the best effect is selected to obtain the best network threat intelligence relationship extraction model. The LabelSmoothing Loss loss function is selected as the loss function used in training. The formula is as follows: Where L is the loss function, is the label distribution of the oth category after smoothing, ε is the smoothing parameter (a small constant), y is the label of the true category, sc i is the probability of the i-th category predicted by the model.
10. A network threat intelligence relationship extraction method based on attention context mapping and relationship matching according to claim 9, characterized in that: The massive network threat intelligence is input into the model, which is used to: divide the massive network threat intelligence into sentences, and after completing the entity extraction, input the network threat intelligence relationship extraction model to obtain the final relationship triples.
Citation Information
Patent Citations
Document-level threat intelligence relation extraction method and system based on feature enhancement
CN116049343A
Network security named entity identification method based on threat intelligence
CN116611436A
Relation extraction method of prompt fine tuning based on context enhancement
CN116738994A
Cited By
Network threat intelligence information extraction method based on deep learning
CN119578538A
Threat intelligence triple extraction method and system based on double-pointer architecture
CN119938930A
