Network threat intelligence full-text relation extraction method based on graph structure

By constructing a document graph based on graph structure and using graph convolutional neural network and self-attention model, the problem of data scarcity and complexity in full-text relationship extraction of network threat intelligence is solved, and high accuracy and robustness are achieved. The relationship extraction effect shows excellent performance, especially in few-sample scenarios.

CN118535786APending Publication Date: 2024-08-23SICHUAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410616759.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-17
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing technologies have problems such as lack of data, insufficient entity representation, long and complex relationship chains, and semantic ambiguity in the full-text relationship extraction of cyber threat intelligence. It is difficult to effectively extract cross-sentence relationships, especially in scenarios with less training data. Not good.

Method used

Adopt a method based on graph structure to construct a document graph and use graph convolutional neural network, combined with self-attention model and prototype representation mechanism, to extract intra-sentence contextual semantics and full-text relationships, and enhance inter-node information through graph convolution layer and prototype representation layer Characterize interactions and relationships to optimize the training and prediction of relationship extraction models.

Benefits of technology

It significantly improves the accuracy and robustness of full-text relationship extraction of network threat intelligence. It shows high performance and applicability especially in small-sample scenarios, can effectively handle complex relationships and long-range associations, and reduces labeling costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535786A
    Figure CN118535786A
Patent Text Reader

Abstract

The invention discloses a network threat intelligence full-text relation extraction method based on a graph structure, and relates to the technical field of network space security, threat intelligence processing and deep learning. The construction method of the relation extraction model comprises a sample collection step, a training set division step, a data processing step, an intra-sentence context presentation layer construction step, a document graph and representation node construction step, a full-text graph convolution layer construction step, a prototype presentation layer construction step, a relation classification layer construction step and a model training and optimization step. By adopting the method to construct the relationship extraction model, the intra-sentence, inter-sentence and even full-text relationships in the threat intelligence can be effectively extracted, and the method is suitable for a scene with less training data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of cyberspace security, threat intelligence processing and deep learning technology, and more specifically to a method for extracting full-text relations of network threat intelligence based on a graph structure. Background Art

[0002] With the rapid development of the Internet, the accompanying cyber threats have also evolved, and the weapons and technologies used have gradually upgraded, making them increasingly difficult to deal with. The persistent hidden nature of cyber attack behaviors, the intricate attack links, and the diversified backgrounds have greatly increased the difficulty of tracking and locating the source. Faced with the increasingly sophisticated trend of cyber threats, it is difficult to effectively respond to challenges by relying solely on passive defense measures. In order to improve the detection efficiency of attack activities and ensure rapid counterattacks, the adoption of active defense strategies has become an inevitable choice, which includes detailed description, precise positioning, and in-depth tracing of cyber attacks. Such active security defense mechanisms will provide more solid and powerful support for the network security defense line in the future.

[0003] Cyber ​​Threat Intelligence (CTI), as a form of cybersecurity knowledge based on deep accumulation, reveals in detail the existing or emerging potential risks and harmful behaviors in cyberspace. The content covers background information, operating mechanisms, specific threat indicators, possible impacts, and operational response strategies, providing key information resources for decision makers to formulate prevention and countermeasures. Global security vendors and teams such as Symantec and Qi'anxin will publish and share their own cyber threat intelligence based on their own analysis results. The key data content contained in these reports - Indicator Of Compromise (IOC) and Tactics, Techniques and Procedures (TTP), etc., have an invaluable value in accurately depicting the characteristics of attackers and fully reproducing the entire process of attack activities.

[0004] Network threat intelligence relation extraction is to extract the relationship between threat entities from unstructured documents. For the relation extraction task, it can be divided into intra-sentence relation extraction and inter-sentence relation extraction according to the relation distance. Intra-sentence relation extraction only extracts relations from entities that appear in the same sentence. However, threat intelligence documents are usually long, and the identification of many relations needs to consider the semantics of the entire text. The subject and object of the relation exist in different sentences. This cross-sentence relation extraction belongs to inter-sentence relation extraction. General intra-sentence relation extraction methods are difficult to deal with the problem of inter-sentence relation extraction. For inter-sentence relation extraction, the concept of mention is introduced. Mention is defined as a record of a specific entity that is explicitly referred to or indirectly mentioned. It represents the actual presentation of the entity in the text content and may be distributed in various paragraphs of the document. Entities are regarded as objects, concepts or actual existences with independent identification in the document. The general idea of ​​inter-sentence relation extraction is to vectorize entities through mentions and classify entities through pairwise classification methods.

[0005] At present, there are the following problems in extracting full-text relationships of network threat intelligence: 1) Data scarcity and insufficient entity representation: There is currently no complete and annotated threat intelligence relationship data available, and the cost of manual annotation makes it difficult to obtain sufficient feature representations for low-frequency threat entities; 2) The relationship chain is long and complex: The relationship between entities may be connected through multiple events in the document to form a long-span relationship chain; therefore, the model must have cross-paragraph understanding and reasoning capabilities in order to effectively track and parse these complex association paths; 3) The problem of semantic ambiguity is prominent: Given that threat intelligence documents are usually long, there may be missing information or inconsistent expressions inside; in addition, since entities may appear far away in the document, the referential relationship between them is easy to become unclear, which increases the difficulty for the model to accurately infer the connection between entities. Summary of the invention

[0006] In order to overcome the defects and deficiencies in the above-mentioned prior art, the present invention provides a method for extracting full-text relationships of network threat intelligence based on a graph structure. The purpose of the present invention is to solve the problems in the above-mentioned prior art. The present invention can effectively extract intra-sentence, inter-sentence and even full-text relationships in threat intelligence, and is suitable for scenarios with less training data.

[0007] In order to solve the above problems existing in the prior art, the present invention is implemented through the following technical solutions.

[0008] The present invention provides a method for extracting full-text relations of network threat intelligence based on a graph structure, comprising the following steps:

[0009] S1, sample collection step, collect a set amount of network threat intelligence, perform data cleaning, retain text content, define entity types and relationship models according to specific scenarios, manually annotate network threat intelligence and perform cross-validation, and store the annotated network threat intelligence in the sample database; divide the sample data in the sample database into training set and test set according to the set ratio;

[0010] S2, training set division step, classifying the samples in the training set according to the proportion of threat intelligence in each sample, and training the classified sample data according to the corresponding categories;

[0011] S3, data processing step, processing the network threat intelligence documents in the training samples, performing segmentation, sentence segmentation and word segmentation, splitting the words into subwords, and forming subword sequences; the obtained subword sequences are used as inputs of the relation extraction model to be trained;

[0012] S4: Construct the sentence context representation layer step, extract the sentence context semantics in units of sentences, use the embedding matrix to embed the subwords and their positions, and obtain the subword representation; then use the bidirectional encoder BERT based on the self-attention model to extract the context semantics; aggregate the subword sequence back to the word sequence in an average manner for all subwords of the same word;

[0013] S5. Construct a document graph and characterize nodes. The document graph includes four different types of nodes and six types of edges. The edges represent the relationship between nodes. The four different types of nodes are mention nodes, entity nodes, sentence nodes, and global nodes. The six types of edges are the relationship between global nodes and sentence nodes, the relationship between sentence nodes and sentence nodes, the relationship between mention nodes and sentence nodes, the relationship between mention nodes and mention nodes, the relationship between mention nodes and entity nodes, and the relationship between entity nodes and sentence nodes.

[0014] Among them, the mention node refers to the reference or specific occurrence of an entity, and the representation of the mention node is the average of all word representations contained in the mention; the entity node represents all occurrences of the same entity in the text, and the representation of the entity node is the average of the representations of all mention nodes of the entity; the sentence node represents a sentence in the threat intelligence, and the representation of all word representations in the sentence is integrated to obtain the representation of the sentence node; the representation of the global node is obtained by averaging the representations of all sentence nodes;

[0015] S6: construct the full-text graph convolution layer step, using a graph convolutional neural network to aggregate the features of adjacent nodes in the document graph to update the representation of the current node, ensuring the effective transmission and interaction of information between nodes;

[0016] S7, a step of constructing a prototype representation layer, after convolution of the full-text graph convolution layer, embedding and concatenating the vectors of the entity node pairs to be classified and their categories to obtain the initial representation vector of the entity pairs to be classified; constructing the initial representation vector into a prototype representation vector through linear transformation, and the space of the prototype representation vector is the prototype space;

[0017] If the number of relationship types to be extracted is R, the prototype space is divided into R regions, each region represents a relationship type, and the prototype center of each region is obtained by averaging all known relationship prototypes in the region;

[0018] During the training process, for a relation prototype, ensure that the relation prototype is closer to the center of the region to which it belongs in the prototype space and farther away from the centers of other regions;

[0019] S8, step of constructing a relation classification layer, wherein the relation classification layer adopts a multi-layer fully connected neural network, and for an entity node pair to be classified, embeds and concatenates the vectors of the two nodes of the entity node pair to be classified and their types to obtain an original vector of the entity pair to be classified; and uses the original vector as the input of the multi-layer fully connected neural network;

[0020] S9, model training and optimization step, extracting relations according to the training data obtained in step S3, the model calculates and extracts relations, and uses the cross entropy function to calculate the loss value of the predicted extracted relations and the true relations; at the same time, the normalized exponential loss value of the relation representation and the prototype center is calculated, and the back propagation algorithm and the optimizer are used to adjust the model parameters after the two are superimposed; the above steps are repeated until the loss value reaches a stable state or the maximum iteration round is reached; finally, a trained relation extraction model is obtained;

[0021] S10, a network threat intelligence processing step, segmenting, sentence segmenting, and word segmentation the network threat intelligence document, splitting the words into subwords to form a subword sequence;

[0022] S11. Based on the subword sequence obtained in step S10, the subword sequence is input into the relation extraction model obtained in step S9 to perform relation extraction.

[0023] Further preferably, the model parameters and fixed hyperparameters are initialized at the beginning of training, and the specific settings are as follows:

[0024] The representation dimension of graph nodes is 128 dimensions; the representation dimension of prototypes is 256 dimensions; the intra-sentence context representation layer BRET uses a 12-layer stack of multi-head self-attention layers, with input and output dimensions of 768 dimensions, an intermediate state of 3076 dimensions, and 12 attention heads; the graph convolutional neural network has 2 layers, the first layer neuron structure is 128×128, the second layer neuron structure is 128×64, and the activation function uses a linear rectification function; the relationship classification layer network has 3 layers, the first layer neuron structure is 128×64, the second layer neuron structure is 64×32; the third layer neuron structure is 32×k, and k is set according to the specific scenario.

[0025] More preferably, the learning rate of the sentence context representation layer is set to 0.00001, and the learning rates of the other layers are set to 0.001. An entire network threat intelligence document is trained at a time, and the maximum number of iterations is 100.

[0026] More preferably, when training the model, AdamW, Adam or SDG is used as the optimizer.

[0027] Further preferably, in step S3, the network threat intelligence document is segmented according to line breaks; the spacy tool is used for sentence segmentation; the words are segmented according to sentence spaces; and the Word Piece algorithm is used to split the words into subwords.

[0028] Further preferably, in step S4, the subword representation is specifically expressed as follows: for the subword sw i,j The word embedding matrix and the position embedding matrix are used to represent the position i, and the subword representation e is calculated. i,j ;

[0029] e i,j =E w (sw i,j )+E p (i);

[0030] In the formula, sw i,j Indicates the jth subword after the i-th word is split, such as sw 1,1 Indicates the first subword after the first word is split, e i,j Indicates the subword sw i,j Subword representation of E w represents the subword embedding matrix, E p Represents the position embedding matrix.

[0031] More preferably, in step S4, a bidirectional encoder BERT based on a self-attention model is used to extract context semantics, specifically:

[0032] set up represents the k-th hidden state sequence of the bidirectional encoder BERT, where n is the number of words and l is i is the number of subwords contained in the i-th word after splitting, for example, l1 is the number of subwords contained in the first word after splitting. In particular, The calculation formula for the attention value of the k+1th layer is as follows:

[0033]

[0034]

[0035] In the formula, Q k ,K k ,V k They are h k The vector obtained after linear transformation is is the weight matrix, d is the dimension of the three vectors, and T is the transpose operation;

[0036] All subwords of the same word are aggregated back to the word sequence in an average way. The calculation formula is as follows:

[0037]

[0038] Further preferably, in step S5, the initial representation calculation process of the four nodes is as follows:

[0039] Mention node, |M i |Indicates a mention of M i Number of words included:

[0040]

[0041] Entity node, |E i | represents entity E i Number of mentions included:

[0042]

[0043] Sentence node, |S i | indicates sentence S i Number of words included:

[0044]

[0045] Global node, |G| represents the number of sentences contained in the full text, and G is the set of sentences in the full text:

[0046]

[0047] Further preferably, in step S6, the calculation process of the graph convolutional neural network is as follows:

[0048]

[0049] Where W i and b i is the weight and bias of the i-th layer, |Z i | is the first-order neighbor set Z of node i i The size of , L is the number of layers of GCN, and relu is the linear rectification activation function.

[0050] Further preferably, in step S7, it is assumed that after the full-text graph convolution, the entity node f to be classified a and f b , embedding and concatenating the vectors of these two nodes and their types to obtain the original representation of the entity pair to be classified:

[0051] v=[f a ; E type (t a );f b ; E type (t b )]

[0052] In the formula, [;] is the vector concatenation symbol, E type is the entity type embedding matrix, t a For node f a The corresponding entity type; t b For node f b The corresponding entity type; v represents the initial representation vector of the entity pair to be classified; the initial representation vector is constructed into a prototype representation vector p through linear transformation:

[0053] p=Wv

[0054] In the formula, is the weight matrix.

[0055] More preferably, in step S7, if the number of relationship types to be extracted is R, the prototype space is divided into R regions, each region represents a relationship type, and the prototype center c of each region is i By averaging all known relationship prototypes in the region:

[0056]

[0057] In the formula, C i represents the prototype representation set of the i-th prototype space, |C i | is the size of the collection.

[0058] More preferably, the distance in step S7 is calculated using Euclidean distance:

[0059]

[0060]

[0061] In the formula, d(,) represents the Euclidean distance between two vectors, c′ is the center of the space to which the prototype representation p belongs, exp is the exponential function, and loss calculates the loss function corresponding to the prototype representation p.

[0062] More preferably, in step S8, for the entity node to be classified, a and f b , embed and concatenate the vectors of these two nodes and their types to obtain the original vector of the entity pair to be classified:

[0063] v=[f a ; E type (t a );f b ; E type (t b )]

[0064] The calculation formula of the multi-layer fully connected network is as follows:

[0065]

[0066] In the formula, and are the weight matrix and bias of each layer, L F is the number of layers in the fully connected network.

[0067] Compared with the prior art, the beneficial technical effects brought by the present invention are as follows:

[0068] 1. The technical solution proposed in the present invention focuses on deeply mining the contextual semantic information of the full text of network threat intelligence to ensure sufficient and detailed feature representation for each entity and mention. A prototype representation mechanism is specially introduced in the training stage to enhance the aggregation effect of relationship features of the same category to effectively deal with data-scarce problem situations. Compared with other existing methods for extracting threat intelligence relationships, this method performs better in dealing with complex relationship extraction tasks between sentences, significantly improves the extraction accuracy, and has good robustness. It can still show high performance and applicability with limited training samples.

[0069] 2. The present invention adds a training set division step, and classifies the samples in the training set according to the proportion of threat intelligence in each sample, taking 40%, 50%, 60%, 70%, and 80% divisions for experiments; the effectiveness of the relationship extraction model constructed by the present invention in the scenario of few samples can be verified. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1 Schematic diagram of the framework of the relationship extraction model in the present invention;

[0071] Figure 2 It is a schematic diagram of subword splitting in the present invention;

[0072] Figure 3 A schematic diagram for representing the mentioned nodes, entity nodes, sentence nodes, and full-text nodes in the present invention;

[0073] Figure 4 A schematic diagram for constructing a document graph in the present invention;

[0074] Figure 5 Schematic diagram of the graph convolutional neural network in the present invention;

[0075] Figure 6 It is a schematic diagram of parameter analysis of the embedded dimension in the present invention;

[0076] Figure 7 Schematic diagram of parameter analysis of the number of graph convolutional network layers in the present invention;

[0077] Figure 8 Schematic diagram of confusion matrix of each relationship in the present invention;

[0078] Fig. 9 Schematic diagram of the results of the present invention and other methods under different training data ratios. DETAILED DESCRIPTION

[0079] The following is an exemplary embodiment of the present invention that helps to fully understand the claims and their equivalents in conjunction with the accompanying drawings, wherein the specific details will be considered as exemplary only, and do not limit the scope of the present invention. Therefore, those of ordinary skill in the art can make various changes and modifications to the embodiments without departing from the scope and spirit of the present invention.

[0080] Example 1

[0081] As a preferred embodiment of the present invention, refer to Figure 1-2 As shown, this embodiment discloses a method for extracting full-text relations of network threat intelligence based on a graph structure, comprising the following steps:

[0082] S1, sample collection step, collect a set amount of network threat intelligence, perform data cleaning, retain text content, define entity types and relationship models according to specific scenarios, manually annotate network threat intelligence and perform cross-validation, and store the annotated network threat intelligence in the sample database; divide the sample data in the sample database into training set and test set according to the set ratio;

[0083] S2, training set division step, classifying the samples in the training set according to the proportion of threat intelligence in each sample, and training the classified sample data according to the corresponding categories;

[0084] S3, data processing step, processing the network threat intelligence documents in the training samples, performing segmentation, sentence segmentation and word segmentation, splitting the words into subwords, and forming subword sequences; the obtained subword sequences are used as inputs of the relation extraction model to be trained;

[0085] S4: Construct the sentence context representation layer step, extract the sentence context semantics in units of sentences, use the embedding matrix to embed the subwords and their positions, and obtain the subword representation; then use the bidirectional encoder BERT based on the self-attention model to extract the context semantics; aggregate the subword sequence back to the word sequence in an average manner for all subwords of the same word;

[0086] S5. Construct a document graph and characterize nodes. The document graph includes four different types of nodes and six types of edges. The edges represent the relationship between nodes. The four different types of nodes are mention nodes, entity nodes, sentence nodes, and global nodes. The six types of edges are the relationship between global nodes and sentence nodes, the relationship between sentence nodes and sentence nodes, the relationship between mention nodes and sentence nodes, the relationship between mention nodes and mention nodes, the relationship between mention nodes and entity nodes, and the relationship between entity nodes and sentence nodes.

[0087] Among them, the mention node refers to the reference or specific occurrence of an entity, and the representation of the mention node is the average of all word representations contained in the mention; the entity node represents all occurrences of the same entity in the text, and the representation of the entity node is the average of the representations of all mention nodes of the entity; the sentence node represents a sentence in the threat intelligence, and the representation of all word representations in the sentence is integrated to obtain the representation of the sentence node; the representation of the global node is obtained by averaging the representations of all sentence nodes;

[0088] S6: construct the full-text graph convolution layer step, using a graph convolutional neural network to aggregate the features of adjacent nodes in the document graph to update the representation of the current node, ensuring the effective transmission and interaction of information between nodes;

[0089] S7, a step of constructing a prototype representation layer, after convolution of the full-text graph convolution layer, embedding and concatenating the vectors of the entity node pairs to be classified and their categories to obtain the initial representation vector of the entity pairs to be classified; constructing the initial representation vector into a prototype representation vector through linear transformation, and the space of the prototype representation vector is the prototype space;

[0090] If the number of relationship types to be extracted is R, the prototype space is divided into R regions, each region represents a relationship type, and the prototype center of each region is obtained by averaging all known relationship prototypes in the region;

[0091] During the training process, for a relation prototype, ensure that the relation prototype is closer to the center of the region to which it belongs in the prototype space and farther away from the centers of other regions;

[0092] S8, step of constructing a relation classification layer, wherein the relation classification layer adopts a multi-layer fully connected neural network, and for an entity node pair to be classified, embeds and concatenates the vectors of the two nodes of the entity node pair to be classified and their types to obtain an original vector of the entity pair to be classified; and uses the original vector as the input of the multi-layer fully connected neural network;

[0093] S9, model training and optimization step, extracting relations according to the training data obtained in step S3, the model calculates and extracts relations, and uses the cross entropy function to calculate the loss value of the predicted extracted relations and the true relations; at the same time, the normalized exponential loss value of the relation representation and the prototype center is calculated, and the back propagation algorithm and the optimizer are used to adjust the model parameters after the two are superimposed; the above steps are repeated until the loss value reaches a stable state or the maximum iteration round is reached; finally, a trained relation extraction model is obtained;

[0094] S10, a network threat intelligence processing step, segmenting, sentence segmenting, and word segmentation the network threat intelligence document, splitting the words into subwords to form a subword sequence;

[0095] S11. Based on the subword sequence obtained in step S10, the subword sequence is input into the relation extraction model obtained in step S9 for relation extraction.

[0096] Example 2

[0097] As another preferred embodiment of the present invention, this embodiment is a further detailed elaboration and supplement to the technical solution of the present invention based on the above-mentioned embodiment 1. In this embodiment, the model parameters and fixed hyperparameters are initialized at the beginning of training, and the specific settings are as follows:

[0098] The representation dimension of graph nodes is 128 dimensions; the representation dimension of prototypes is 256 dimensions; the intra-sentence context representation layer BRET uses a 12-layer stack of multi-head self-attention layers, with input and output dimensions of 768 dimensions, an intermediate state of 3076 dimensions, and 12 attention heads; the graph convolutional neural network has 2 layers, the first layer neuron structure is 128×128, the second layer neuron structure is 128×64, and the activation function uses a linear rectification function; the relationship classification layer network has 3 layers, the first layer neuron structure is 128×64, the second layer neuron structure is 64×32; the third layer neuron structure is 32×k, and k is set according to the specific scenario.

[0099] Furthermore, in order to obtain the optimal settings of the graph embedding dimension and the number of graph convolutional network layers of the present invention, multiple groups of experiments were designed based on the control variables. The experimental results are as follows: Figure 6-7 As shown. Figure 6 In the example, the embedding dimension is {64, 128, 192, 256, 320}. When the embedding dimension increases from 64 to 128, both Macro F1 and Micro F1 increase, indicating that the accuracy of relation extraction has been improved. However, when the embedding dimension continues to increase, the effect is not significantly improved, and even decreases. This is because when the embedding dimension continues to increase but the amount of data remains unchanged, overfitting is inevitable, so the embedding dimension of 128 is the most appropriate.

[0100] like Figure 7 As shown, the present invention obtains the optimal settings of the graph convolutional neural network, and the number of layers is set to 1 layer, 2 layers and 3 layers. It can be seen that the relationship extraction effect is best when the layer is 2. This is because a 1-layer graph convolutional neural network can only aggregate the features of 1st-order neighbors, and the coverage of document graph information is insufficient. Due to the existence of global nodes in the present invention, information interaction can be achieved between any nodes at most 2 times, so a 2-layer graph convolutional network is the best. When the number of layers is 3, the characteristics of the nodes are weakened due to the over-smoothing problem, so the effect is reduced. Therefore, a 2-layer graph convolutional neural network is the best.

[0101] As an example, a network threat intelligence is input into the relationship extraction model. The model calculates and extracts the relationship, and uses the cross entropy function to calculate the loss value of the predicted relationship and the real relationship. At the same time, the normalized exponential loss value of the relationship representation and the prototype center is calculated. After adding the two, the back propagation algorithm and the optimizer are used to adjust the model parameters. This step is repeated until the loss value reaches a stable state or the maximum iteration round. When the model converges, a model with the best relationship extraction result under the current data is obtained.

[0102] The relevant hyperparameters for model training are set as:

[0103] AdamW is used as the optimizer for training; the learning rate of the sentence context representation layer is 0.00001, and the learning rate of the other layers is 0.001; the maximum iteration round is set to 100.

[0104] As another example of this embodiment, Adam or SDG may also be used as the optimizer.

[0105] Example 3

[0106] As another preferred embodiment of the present invention, this embodiment further supplements and elaborates on the technical solution of the present invention based on the above-mentioned embodiment 1 or embodiment 2. In this embodiment, in step S3, the network threat intelligence document is segmented according to line breaks; the spacy tool is used for sentence segmentation; the word segmentation is performed according to the sentence spaces; and the Word Piece algorithm is used to split the word into subwords.

[0107] In step S4, the subword representation is specifically expressed as follows: for the subword sw i,j The word embedding matrix and the position embedding matrix are used to represent the position i, and the subword representation e is calculated. i,j ;

[0108] e i,j =E w (sw i,j )+E p (i);

[0109] In the formula, sw i,j Indicates the jth subword after the i-th word is split, such as sw 1,1 Indicates the first subword after the first word is split, e i,j Indicates the subword sw i,j Subword representation of E w represents the subword embedding matrix, E p Represents the position embedding matrix.

[0110] In step S4, the bidirectional encoder BERT based on the self-attention model is used to extract contextual semantics, specifically:

[0111] set up represents the k-th hidden state sequence of the bidirectional encoder BERT, where n is the number of words and l is i is the number of subwords contained in the i-th word after splitting, for example, l1 is the number of subwords contained in the first word after splitting. In particular, The calculation formula for the attention value of the k+1th layer is as follows:

[0112]

[0113]

[0114] Among them, Q k ,K k ,V k They are h k The vector obtained after linear transformation is is the weight matrix, d is the dimension of the three vectors, and T is the transpose operation;

[0115] All subwords of the same word are aggregated back to the word sequence in an average way. The specific formula is as follows:

[0116]

[0117] Further preferably, in step S5, the initial representation calculation process of the four nodes is as follows:

[0118] Mention node, |M i |Indicates a mention of M i Number of words included:

[0119]

[0120] Entity node, |E i | represents entity E i Number of mentions included:

[0121]

[0122] Sentence node, |S i | indicates sentence S i Number of words included:

[0123]

[0124] Global node, |G| represents the number of sentences contained in the full text, and G is the set of sentences in the full text:

[0125]

[0126] In step S6, the calculation process of the graph convolutional neural network is as follows:

[0127]

[0128] Where W i and b i is the weight and bias of the i-th layer, |Z i | is the first-order neighbor set Z of node i i The size of , L is the number of layers of GCN, and relu is the linear rectification activation function.

[0129] In step S7, suppose that after the full-text graph convolution, there are entity nodes f to be classified a and f b , embedding and concatenating the vectors of these two nodes and their types to obtain the original representation of the entity pair to be classified:

[0130] v=[f a ; E type (t a );f b ; Etype (t b )]

[0131] In the formula, [;] is the vector concatenation symbol, E type is the entity type embedding matrix, t a For node f a The corresponding entity type; t b For node f b The corresponding entity type; v represents the initial representation vector of the entity pair to be classified; the initial representation vector is constructed into a prototype representation vector p through linear transformation:

[0132] p=Wv

[0133] In the formula, is the weight matrix.

[0134] More preferably, in step S7, if the number of relationship types to be extracted is R, the prototype space is divided into R regions, each region represents a relationship type, and the prototype center c of each region is i By averaging all known relationship prototypes in the region:

[0135]

[0136] In the formula, C i represents the prototype representation set of the i-th prototype space, |C i | is the size of the collection.

[0137] More preferably, the distance in step S7 is calculated using Euclidean distance:

[0138]

[0139]

[0140] In the formula, d(,) represents the Euclidean distance between two vectors, c′ is the center of the space to which the prototype representation p belongs, exp is the exponential function, and loss calculates the loss function corresponding to the prototype representation p.

[0141] More preferably, in step S8, for the entity node to be classified, a and f b , embed and concatenate the vectors of these two nodes and their types to obtain the original vector of the entity pair to be classified:

[0142] v=[f a ; E type (t a );f b ; E type (t b )]

[0143] The calculation formula of the multi-layer fully connected network is as follows:

[0144]

[0145] In the formula, and are the weight matrix and bias of each layer, L F is the number of layers in the fully connected network.

[0146] Example 4

[0147] In view of the limitations of existing technologies in dealing with long-distance dependencies, complex semantic structures, and ambiguous issues in the process of relation extraction, as well as the problem of reduced relation extraction performance when faced with limited training data, this paper proposes an innovative graph-based full-text relation extraction method for network threat intelligence. This method aims to effectively overcome the above challenges, accurately capture long-range associations and multi-dimensional semantic information, and optimize the extraction effect in small sample training scenarios.

[0148] like Figure 1 As shown, the specific framework of the network threat intelligence relationship extraction method provided in this embodiment includes the following four steps.

[0149] Step 1: Crawl a certain amount of network threat intelligence, perform data cleaning, and retain text content. Define entity types and relationship types according to specific scenarios, manually annotate network threat intelligence, and perform cross-checking. The annotated network threat intelligence is stored in the database.

[0150] Furthermore, this step crawls and uses 150 cyber threat intelligence articles published in recent years, and divides them into threat intelligence units. 120 articles are randomly selected as training sets, and the remaining 30 articles are used as test sets. This division can ensure the independence of training and test data. 8 major categories and 16 minor categories of entities are defined, as shown in Table 1, and 6 types of relationships are defined, as shown in Table 2.

[0151] Table 1 Entity types and quantity statistics

[0152]

[0153]

[0154] Table 2 Relationship types and quantity statistics

[0155]

[0156] Furthermore, in order to verify the effectiveness of the present invention in a small number of sample scenarios, the data set is further divided into 40%, 50%, 60%, 70%, and 80% according to the proportion of threat intelligence in the training set, and experiments are carried out.

[0157] Step 2: Construct a full-text relation extraction model for network threat intelligence. The present invention includes five modules: intra-sentence context representation layer, graph and node representation construction, full-text graph convolution layer, prototype representation layer, and relation classification layer. The structure of each module is as follows:

[0158] 1) First, process the unstructured network threat intelligence document, segment it into segments, sentences, and words, split the words into subwords, and form subword sequences Subword sequence splitting Figure 1 As shown, i, j are sequence subscripts, n is the number of words; sw i,j Indicates the jth subword after the i-th word is split, such as sw 1,1 Indicates the first subword after the first word is split; l i Represents the number of subwords of the i-th word, for example, l1 represents the number of subwords of the first word; the subword sequence S is the input of the relation extraction model;

[0159] 2) Intra-sentence context representation layer: This module extracts the context semantics of the sentence in units of sentences. i,j and its position i are respectively embedded using the embedding matrix to calculate the subword representation e i,j for:

[0160] e i,j =E w (sw i,j )+E p (i)

[0161] In the formula, E w and E p They represent word embedding matrix and position embedding matrix respectively, and “representation” means feature representation.

[0162] Then, the bidirectional encoder BERT based on the self-attention model is used to extract contextual semantics.

[0163] set up represents the k-th hidden state sequence of the bidirectional encoder BERT, where n is the number of words and l is i is the number of subwords contained in the i-th word after splitting, for example, l1 is the number of subwords contained in the 1st word after splitting. In particular, The calculation formula for the attention value of the k+1th layer is as follows:

[0164]

[0165]

[0166] In the formula, Q k ,K k ,V k They are h k The vector obtained after linear transformation is is the weight matrix, d is the dimension of the three vectors, and T is the transpose operation.

[0167] The hidden states of all subwords of the same word are then averaged to aggregate the subword sequence back to the word sequence, calculated as follows:

[0168]

[0169] 3) Construct graph and node representation, the process is as follows Figure 3 and Figure 4 As shown. This module innovatively designs a document graph prototype to handle the full-text semantic integration problem of long-text threat intelligence relationship extraction, integrating information from various parts, including but not limited to sentence-level semantic information, to more comprehensively and accurately capture the relationship between entities. The document graph prototype covers four different types of nodes, namely: Mention Node (M), Entity Node (E), Sentence Node (S), Global Node (G). And six types of edges: Global-Sentence (GS), Sentence-Sentence (SS), Mention-Sentence (MS), Mention-Mention (MM), Mention-Entity (ME), Entity-Sentence (ES).

[0170] A mention node is the smallest unit, which refers to a reference or specific occurrence of an entity. The representation of such a node is the average of all word representations contained in the mention, expressed as follows:

[0171]

[0172] In the formula, |M i |Indicates a mention of M i The number of words contained;

[0173] An entity node is a highly abstract concept mentioned, representing all occurrences of the same entity in a text. The representation of all mention nodes of the entity is averaged to form the representation of the entity node as follows:

[0174]

[0175] In the formula, |E i | represents entity E i the number of mentions included;

[0176] A sentence node represents a sentence in threat intelligence. The representation of all words in the sentence is integrated to obtain the representation of the sentence node as follows:

[0177]

[0178] In the formula, |S i | indicates sentence S i The number of words contained;

[0179] The global node not only directly integrates the full text information, but also alleviates the over-smoothing problem in the graph neural network. This node is obtained by averaging the representations of all sentence nodes, as follows:

[0180]

[0181] In the formula, |G| represents the number of sentences contained in the full text, and G is the set of sentences in the full text;

[0182] Based on the above definitions of nodes and edges, the present invention can construct a document graph for a piece of threat intelligence, in which nodes represent entities, mentions and sentences, and edges represent different relationships between them.

[0183] 4) Full-text graph convolution layer, such as Figure 5 As shown in the figure. This module uses a graph convolutional neural network (GCN) to aggregate the features of adjacent nodes to update the representation of the current node, ensuring the effective transmission and interaction of information between nodes. One layer of GCN can aggregate the information of first-order neighbors, while multiple layers of stacked GCN can aggregate the information of higher-order and more distant nodes. However, as the number of GCN layers increases, over-smoothing occurs, causing the features of each node in the graph to tend to be consistent and lose their uniqueness, so it is necessary to select an appropriate number of GCN layers.

[0184] For the input x of the full-text graph convolution layer j , the calculation process of multi-layer GCN is as follows:

[0185]

[0186]

[0187] Where W i and b i are the weight matrix and bias of the i-th layer, respectively, |Z i | is the first-order neighbor set Z of node i i The size of , L is the number of layers of GCN, and relu is the linear rectification activation function.

[0188] 5) Prototype representation layer: This module aggregates the representations of relations in the same category and disperses the representations of relations in different categories to improve the accuracy of relation classification in the case of few samples. After the full-text graph convolution layer, the entity node to be classified is represented as f a and f b , after embedding and concatenating the representations of these two nodes and their types, the original representation of the entity pair to be classified is as follows:

[0189] v=[f a ; E type (t a );f b ; E type (t b )]

[0190] In the formula, [;] is the vector concatenation symbol, E type is the entity type embedding matrix, t i represents the entity type corresponding to node i, and v represents the initial vector of the entity pair to be classified;

[0191] The initial vector is constructed into a prototype representation vector p through linear transformation:

[0192] p=Wv

[0193] In the formula, is the weight matrix;

[0194] If there are k types of relations, the prototype space will be divided into R regions, each region represents a type of relation, and the prototype center c of each region is i By averaging all known relationship prototypes in the region:

[0195]

[0196] Among them, C i represents the prototype representation set of the i-th prototype space, |C i | is the size of the collection.

[0197] During the training process, for the relationship prototype p, ensure that the relationship prototype is closer to the center of the region it belongs to in the prototype space, and away from the centers of other regions. The distance is calculated using the Euclidean distance:

[0198]

[0199]

[0200] In the formula, d(,) represents the Euclidean distance between two vectors, c′ is the center of the space to which the prototype representation p belongs, exp is the exponential function, and loss calculates the loss function corresponding to the prototype representation p.

[0201] 6) Relation classification layer: This module is implemented using a fully connected neural network. a and f b , embedding and concatenating the representations of these two nodes and their types to obtain the original representation of the entity pair to be classified:

[0202] v=[f a ; E type (t a );f b ; E type (t b )]

[0203] In the formula, [;] is the vector concatenation symbol, E type is the entity type embedding matrix, t i represents the entity type corresponding to node i, and v represents the initial vector of the entity pair to be classified;

[0204] The calculation formula of the multi-layer fully connected network is as follows:

[0205]

[0206] In the formula, and are the weight matrix and bias of each layer, L F is the number of layers in the fully connected network.

[0207] Furthermore, this step initializes the model parameters and fixes the hyperparameters at the beginning of training, and the specific settings are as follows:

[0208] 1) Segment the document based on line breaks, use spacy to segment sentences, use sentence spaces to segment words, and use the Word Piece algorithm to split words into subwords;

[0209] 2) The representation dimension of each node in the graph is 128 dimensions, and the prototype representation dimension is 256 dimensions;

[0210] 3) BERT uses a 12-layer stacked multi-head self-attention mechanism for the sentence context representation layer. The input and output dimensions are both 768 dimensions, the hidden state in the middle is 3076 dimensions, and there are 12 attention heads.

[0211] 4) The number of graph convolutional neural network layers of the full-text graph convolution layer is 2, the neuron structure of the first layer is 128×128, the neuron structure of the second layer is 128×64, and the activation function uses the linear rectification function relu;

[0212] 5) The number of fully connected neural network layers used in the relationship classification layer is 3, the first layer neuron structure is 128×64, the second layer neuron structure is 64×32, and the third layer neuron structure is 32×k, where k depends on the specific scenario;

[0213] 6) The learning rate of the sentence context representation layer of the relationship extraction model of the present invention is 0.00001, and the learning rates of the other layers are all 0.001. A whole threat intelligence document is trained at a time, and the maximum number of iterations is 100 rounds;

[0214] 7) When training the model, the loss values ​​of the relations and labels extracted by the relation extraction model of the present invention are calculated by the cross entropy function; prototype representation and distance calculation are performed for each pair of relations, and the normalized exponential loss value of the prototype representation for each center is calculated; the two loss functions are superimposed, the gradient of the model parameters is calculated by the back propagation algorithm, and the model parameters are updated using the AdamW optimizer to gradually optimize the model. The above operations are repeated until the loss value reaches a stable state or the maximum number of iterations is reached.

[0215] Furthermore, in order to obtain the optimal settings of the graph embedding dimension and the number of graph convolutional network layers of the present invention, multiple groups of experiments were designed based on the control variables. The experimental results are as follows: Figure 6-7 As shown. Figure 6 In the example, the embedding dimension is {64, 128, 192, 256, 320}. When the embedding dimension increases from 64 to 128, both Macro F1 and Micro F1 increase, indicating that the accuracy of relation extraction has been improved. However, when the embedding dimension continues to increase, the effect is not significantly improved, and even decreases. This is because when the embedding dimension continues to increase but the amount of data remains unchanged, overfitting is inevitable, so the embedding dimension of 128 is the most appropriate.

[0216] like Figure 7 As shown, the present invention obtains the optimal settings of the graph convolutional neural network, and the number of layers is set to 1 layer, 2 layers and 3 layers. It can be seen that the relationship extraction effect is best when the layer is 2. This is because a 1-layer graph convolutional neural network can only aggregate the features of 1st-order neighbors, and the coverage of document graph information is insufficient. Due to the existence of global nodes in the present invention, information interaction can be achieved between any nodes at most 2 times, so a 2-layer graph convolutional network is the best. When the number of layers is 3, the characteristics of the nodes are weakened due to the over-smoothing problem, so the effect is reduced. Therefore, a 2-layer graph convolutional neural network is the best.

[0217] Step 3: Input a piece of cyber threat intelligence into the relationship extraction model. The model calculates and extracts relationships, and uses the cross entropy function to calculate the loss value of the predicted relationship and the true relationship. At the same time, the normalized exponential loss value of the relationship representation and the prototype center is calculated. After adding the two, the model parameters are adjusted using the back propagation algorithm and optimizer. This step is repeated until the loss value reaches a stable state or the maximum iteration round. When the model converges, a model with the best relationship extraction results under the current data is obtained.

[0218] The relevant hyperparameters for model training are set as:

[0219] 1) AdamW is used as the optimizer for training;

[0220] 2) The learning rate of the sentence context representation layer is 0.00001, and the learning rate of the other layers is 0.001;

[0221] 3) The maximum number of iterations is set to 100.

[0222] Step 4: After training, the model is evaluated and compared with the test set to verify the effectiveness of the present invention. The evaluation and comparison of the model includes two parts: defining the evaluation index and comparing the model results.

[0223] 1) Define evaluation indicators:

[0224] For a relationship category that needs to be classified, there are two cases: positive (Positive, yes) and negative (Negative, no). The model's judgment on it is also divided into two cases: correct judgment (True) and wrong judgment (False), so the following four judgment cases are obtained:

[0225] (1) TP: The sample belongs to this category, which is the positive class. The model's prediction result is the positive class, and the judgment is correct;

[0226] (2) FP: The sample does not belong to this category, it is a negative class, but the model predicts it to be a positive class, which is a wrong judgment;

[0227] (3) FN: The sample belongs to this category, which is the positive class, but the model's judgment result is the negative class, which is a wrong judgment;

[0228] (4) TN: The sample does not belong to this category and is a negative class. The model’s judgment result is a negative class and the judgment is correct.

[0229] For a category, precision represents the "precision rate" of the model, which is the proportion of the true labels that are also positive examples among all the results judged as positive examples.

[0230]

[0231] Recall represents the "recall rate" of the model, which is the proportion of all positive examples that are correctly identified.

[0232]

[0233] The F1 value is equivalent to the harmonic mean of precision and recall, which combines the two indicators and can comprehensively express the recall and precision of the method.

[0234]

[0235] When the model needs to make judgments on multiple category labels, it is necessary to comprehensively consider the recognition results of each category. Different application scenarios have slightly different requirements for model performance, and the following two evaluation indicators are usually used:

[0236] The Micro metric considers all categories as a whole and comprehensively considers the overall performance. When facing an unbalanced category distribution, the Micro metric is relatively less affected by small categories. P represents precision and R represents recall.

[0237]

[0238] In the formula, i is a circular subscript, indicating the i-th category.

[0239] The Macro metric calculates the precision, recall, and F1 value for each category separately, and then takes the average of these values. If the model performs poorly in recognizing small categories, the Macro metric will be greatly affected. Therefore, the Macro metric is suitable for scenarios where the recognition requirements for samples in each category are high.

[0240]

[0241] In the formula, i is a circular subscript, indicating the i-th category, and n is the number of categories.

[0242] In the full-text relationship extraction of network threat intelligence, the number of relationship category samples varies greatly, and general scenarios require the model to have a good extraction accuracy for each category, so it is more appropriate to use the Macro indicator.

[0243] 2) Comparison of model results: After model construction in step 2 and model training in step 3, this step compares different methods using the test set. The final evaluation index values ​​are shown in Table 3.

[0244] Table 3 Relationship extraction effects of different methods

[0245]

[0246]

[0247] As shown in Table 3, the present invention is compared with other network threat intelligence relationship extraction methods, and the results show that the present invention has the best extraction effect. Compared with the best performance of other methods, the Macro P index of the present invention is improved by 2.3%, the MacroR index is improved by 2.9%, the Macro F1 index is improved by 4.2%, and the Micro F1 index is improved by 4%, which is more improved than other methods. The results fully demonstrate the superiority of the present invention. When processing longer threat intelligence texts, the present invention is more meticulous and strengthens the key information required for relationship extraction by constructing different types of nodes. In addition, the fused prototype representation is also better for the recognition of small categories. In Table 3, the recall rate (R) of all methods is higher than the precision (P). This is because for the threat intelligence relationship extraction task, there are a large number of unrelated entity pairs, and each method is prone to misjudgment of the relationship between these entity pairs.

[0248] Further, Figure 8 It is the confusion matrix of the extraction results for each relationship of the present invention. The sum of each row in the figure is 100%, and this value represents the probability distribution of a given category relationship being classified into all relationship categories. The higher the percentage on the diagonal, the higher the recognition accuracy of the corresponding method for the relationship type. Except for "none" (no relationship), the accuracy of the present invention for other relationship categories is above 80%, and the average accuracy is 90.76%. Since "none" (no relationship) has the largest number and complex features, there is still room for improvement in recognition accuracy.

[0249] Furthermore, under different proportions of training data, the results of the present invention compared with other methods are shown in the following line graph: Fig. 9 As shown in the figure, the recognition Macro F1 values ​​of various methods show a phenomenon of gradually decreasing as the amount of training set data decreases, which is in line with expectations. Among them, the decline trend of the present invention is the slowest, which shows that compared with other comparative methods, the present invention can more effectively maintain the relationship extraction ability when facing limited training data conditions and is less dependent on annotations.

[0250] It can be seen that the technical solution provided by the present invention has excellent network threat intelligence full-text relationship extraction capabilities and can effectively reduce annotation costs. Compared with other relationship extraction methods, this method has significantly improved prediction accuracy and is more practical.

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

Claims

1. A graph-based full-text relation extraction method for network threat intelligence. Features: The following steps are involved: S1, sample collection step, collect a set amount of network threat intelligence, perform data cleaning, retain text content, define entity types and relationship models according to specific scenarios, manually annotate network threat intelligence and perform cross-validation, and store the annotated network threat intelligence in the sample database; divide the sample data in the sample database into training set and test set according to the set ratio; S2, training set division step, classifying the samples in the training set according to the proportion of threat intelligence in each sample, and training the classified sample data according to the corresponding categories; S3, data processing step, processing the network threat intelligence documents in the training samples, performing segmentation, sentence segmentation and word segmentation, splitting the words into subwords, and forming subword sequences; the obtained subword sequences are used as inputs of the relation extraction model to be trained; S4: Construct the sentence context representation layer step, extract the sentence context semantics in units of sentences, use the embedding matrix to embed the subwords and their positions, and obtain the subword representation; then use the bidirectional encoder BERT based on the self-attention model to extract the context semantics; aggregate the subword sequence back to the word sequence in an average manner for all subwords of the same word; S5. Construct a document graph and characterize nodes. The document graph includes four different types of nodes and six types of edges. The edges represent the relationship between nodes. The four different types of nodes are mention nodes, entity nodes, sentence nodes, and global nodes. The six types of edges are the relationship between global nodes and sentence nodes, the relationship between sentence nodes and sentence nodes, the relationship between mention nodes and sentence nodes, the relationship between mention nodes and mention nodes, the relationship between mention nodes and entity nodes, and the relationship between entity nodes and sentence nodes. Among them, the mention node refers to the reference or specific occurrence of an entity, and the representation of the mention node is the average of all word representations contained in the mention; the entity node represents all occurrences of the same entity in the text, and the representation of the entity node is the average of the representations of all mention nodes of the entity; the sentence node represents a sentence in the threat intelligence, and the representation of all word representations in the sentence is integrated to obtain the representation of the sentence node; the representation of the global node is obtained by averaging the representations of all sentence nodes; S6: construct the full-text graph convolution layer step, using a graph convolutional neural network to aggregate the features of adjacent nodes in the document graph to update the representation of the current node, ensuring the effective transmission and interaction of information between nodes; S7, a step of constructing a prototype representation layer, after convolution of the full-text graph convolution layer, embedding and concatenating the vectors of the entity node pairs to be classified and their categories to obtain the initial representation vector of the entity pairs to be classified; constructing the initial representation vector into a prototype representation vector through linear transformation, and the space of the prototype representation vector is the prototype space; If the number of relationship types to be extracted is R, the prototype space is divided into R regions, each region represents a relationship type, and the prototype center of each region is obtained by averaging all known relationship prototypes in the region; During the training process, for a relation prototype, ensure that the relation prototype is closer to the center of the region to which it belongs in the prototype space and farther away from the centers of other regions; S8, step of constructing a relation classification layer, wherein the relation classification layer adopts a multi-layer fully connected neural network, and for an entity node pair to be classified, embeds and concatenates the vectors of the two nodes of the entity node pair to be classified and their types to obtain an original vector of the entity pair to be classified; and uses the original vector as the input of the multi-layer fully connected neural network; S9, model training and optimization step, extracting relations according to the training data obtained in step S3, the model calculates and extracts relations, and uses the cross entropy function to calculate the loss value of the predicted extracted relations and the true relations; at the same time, the normalized exponential loss value of the relation representation and the prototype center is calculated, and the back propagation algorithm and the optimizer are used to adjust the model parameters after the two are superimposed; the above steps are repeated until the loss value reaches a stable state or the maximum iteration round is reached; finally, a trained relation extraction model is obtained; S10, a network threat intelligence processing step, segmenting, sentence segmenting, and word segmentation the network threat intelligence document, splitting the words into subwords to form a subword sequence; S11. Based on the subword sequence obtained in step S10, the subword sequence is input into the relation extraction model obtained in step S9 to perform relation extraction.

2. A method for extracting full-text relationships of network threat intelligence based on a graph structure as claimed in claim 1, Features: Initialize the model parameters and fixed hyperparameters at the beginning of training. The specific settings are as follows: The representation dimension of graph nodes is 128 dimensions; the representation dimension of prototypes is 256 dimensions; the intra-sentence context representation layer BRET uses a 12-layer stack of multi-head self-attention layers, with input and output dimensions of 768 dimensions, an intermediate state of 3076 dimensions, and 12 attention heads; the graph convolutional neural network has 2 layers, the first layer neuron structure is 128×128, the second layer neuron structure is 128×64, and the activation function uses a linear rectification function; the relationship classification layer network has 3 layers, the first layer neuron structure is 128×64, the second layer neuron structure is 64×32; the third layer neuron structure is 32×k, and k is set according to the specific scenario.

3. A method for extracting full-text relationships of network threat intelligence based on a graph structure as described in claim 1 or 2, Features: The learning rate of the sentence context representation layer is set to 0.00001, and the learning rate of the other layers is set to 0.

001. An entire network threat intelligence document is trained at a time, and the maximum number of iterations is 100.

4. A method for extracting full-text relationships of network threat intelligence based on a graph structure as claimed in claim 1, Features: In step S3, the network threat intelligence document is segmented according to line breaks; the spacy tool is used to segment sentences; the words are segmented according to sentence spaces; and the Word Piece algorithm is used to split the words into subwords.

5. A method for extracting full-text relationships of network threat intelligence based on a graph structure as described in claim 1, 2 or 4, Features: In step S4, the subword representation is specifically expressed as follows: for the subword sw i,j The word embedding matrix and the position embedding matrix are used to represent the position i, and the subword representation e is calculated. i,j ; yes i,j =E w (sw i,j )+E p (i); In the formula, sw i,j Indicates the jth subword after the i-th word is split, such as sw 1,1 Indicates the first subword after the first word is split, e i,j Indicates the subword sw i,j Subword representation of E w represents the subword embedding matrix, E p Represents the position embedding matrix.

6. A method for extracting full-text relationships of network threat intelligence based on a graph structure as claimed in claim 5, Features: In step S4, the bidirectional encoder BERT based on the self-attention model is used to extract contextual semantics, specifically: represents the k-th hidden state sequence of the bidirectional encoder BERT, where n is the number of words and l is i is the number of subwords contained in the i-th word after splitting, for example l 1 is the number of subwords contained in the first word after splitting; in particular, Then the attention value of the k+1th layer is calculated as follows: In the formula, Q k , K k , V k They are h k The vector obtained after linear transformation is is the weight matrix, d is the dimension of the three vectors, and T is the transpose operation; All subwords of the same word are aggregated back to the word sequence in an average way. The calculation formula is as follows:

7. A method for extracting full-text relationships of network threat intelligence based on a graph structure as described in claim 1, 2 or 4, Features: In step S6, the graph convolutional neural network calculation formula is as follows: …… Where W i and b i is the weight and bias of the i-th layer, |Z i | is the first-order neighbor set Z of node i i The size of , L is the number of layers of GCN, and relu is the linear rectification activation function.

8. A method for extracting full-text relationships of network threat intelligence based on a graph structure as described in claim 1, 2 or 4, Features: In step S7, suppose that after the full-text graph convolution, there are entity nodes f to be classified a and f b , embedding and concatenating the vectors of these two nodes and their types to obtain the original representation of the entity pair to be classified. The calculation formula is as follows: v=[f a ;E type (t a );f b ;E type (t b )] In the formula, [; ] is the vector concatenation symbol, E type is the entity type embedding matrix, t a For node f a The corresponding entity type; t b For node f b The corresponding entity type; v represents the initial representation vector of the entity pair to be classified; the initial representation vector is constructed into a prototype representation vector p through linear transformation, and the calculation formula is as follows: p=Wv In the formula, is the weight matrix.

9. A method for extracting full-text relationships of network threat intelligence based on a graph structure as claimed in claim 8, Features: In step S7, if the number of relationship types to be extracted is R, the prototype space is divided into R regions, each region represents a relationship type, and the prototype center c of each region is i It is obtained by averaging all known relationship prototypes in the region. The calculation formula is as follows: In the formula, C i represents the prototype representation set of the i-th prototype space, |C i | is the size of the collection; In step S7, the distance is calculated using the Euclidean distance, and the calculation formula is as follows: In the formula, d(,) represents the Euclidean distance between two vectors, c′ is the center of the space to which the prototype representation p belongs, exp is the exponential function, and loss calculates the loss function corresponding to the prototype representation p.

10. A method for extracting full-text relations of network threat intelligence based on a graph structure as claimed in claim 9, Features: In step S8, for the entity node to be classified a and f b , embed and concatenate the vectors of these two nodes and their types to obtain the original vector of the entity pair to be classified. The calculation formula is as follows: v=[f a ;E type (t a );f b ;E type (t b )] The calculation formula of the multi-layer fully connected network is as follows: …… In the formula, and are the weight matrix and bias of each layer, L F is the number of layers in the fully connected network.