Inductive learning-based regularization acceleration methods, systems, devices, and storage media
Through the method based on inductive learning, graph convolutional neural network and clustering model are used to perform inductive learning and reasoning on non-deterministic finite automata, which solves the problem of low regular acceleration efficiency when NFA changes dynamically, and realizes the problem of low efficiency of regular acceleration in dynamic scenarios. Efficient regular expression matching.
Patent Information
- Application Number
- CN202410757381.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-06-13
AI Technical Summary
In the existing technology, in regular expression matching, neural networks are only suitable for static non-deterministic finite automata (NFA), and it is difficult to effectively accelerate when the NFA changes dynamically, resulting in low regular expression acceleration efficiency.
Using methods based on inductive learning, graph convolutional neural networks and clustering models are used to conduct inductive learning and reasoning on non-deterministic finite automata, and generate graph convolutional neural networks and clustering models for use in dynamically changing scenarios of NFA. Perform parallel analysis and filtering.
In the scenario of dynamic changes in NFA, the regularization acceleration efficiency is significantly improved, avoiding the cumbersome process of model retraining, and achieving efficient capture and processing of dynamic topology changes.
Smart Images

Figure CN118332369B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a regularization acceleration method, system, device and storage medium based on inductive learning. Background Art
[0002] Regular Expression Match (REM) is an important mechanism used by popular intrusion detection systems such as Snort and Bro. Due to the large number of patterns to be scanned and the increasing bandwidth of network traffic, regular expression matching has become a bottleneck. Field Programmable Gate Array (FPGA) has long been used to accelerate regular expressions in networks.
[0003] Since regular expressions are often long and numerous, they often need to be modified. However, in related technologies, neural networks are only applicable to static non-deterministic finite automata (NFAs). When NFAs change dynamically, graph convolutional neural networks need to be retrained to adapt to NFA updates, which makes it difficult to apply to scenarios where NFAs change dynamically, resulting in low regular acceleration efficiency. Summary of the invention
[0004] The purpose of this application is to provide a regularization acceleration method, system, device and storage medium based on inductive learning, which is used to improve the efficiency of regularization acceleration in scenarios where NFA changes dynamically.
[0005] The present application provides a regularization acceleration method based on inductive learning, which is applied to a regularization acceleration system based on inductive learning. The regularization acceleration system based on inductive learning includes a first local hardware device, a second local hardware device, and a heterogeneous device. The first local hardware device is respectively connected to the second local hardware device and the heterogeneous device for communication. The method includes:
[0006] The first local hardware device acquires a data control flow, and generates a non-deterministic finite automaton according to a regular expression, wherein the non-deterministic finite automaton is used to characterize the regular expression to analyze and filter the data control flow;
[0007] The heterogeneous device receives the data control flow and the non-deterministic finite automaton;
[0008] The second local hardware device performs inductive learning on the initial batch of the non-deterministic finite automata based on the initial graph convolutional neural network and the initial clustering model, calculates a comprehensive loss value based on the inductive learning result, and jointly trains the initial graph convolutional neural network and the initial clustering model based on the comprehensive loss value to obtain a graph convolutional neural network and a clustering model; wherein the inductive learning includes undirected graph conversion, neighbor sampling, aggregation operation, feature fusion and clustering processing;
[0009] The second local hardware device performs inductive reasoning on other batches of the non-deterministic finite automata based on the graph convolutional neural network and the clustering model. When the non-deterministic finite automata are in a matching relationship with the regular expressions they represent, the non-deterministic finite automata are configured on the corresponding regular engine to perform parallel analysis and filtering on the data control flow.
[0010] Optionally, the undirected graph conversion is performed by the following steps:
[0011] For each of the non-deterministic finite automata of the initial batch, the non-deterministic finite automata are converted into an undirected graph of non-deterministic finite automata.
[0012] Optionally, converting the non-deterministic finite automaton into a non-deterministic finite automaton undirected graph comprises:
[0013] Obtaining a state machine topology structure of the non-deterministic finite automaton;
[0014] Using an edge from one node to another node in the state machine topology as an edge node in an undirected graph of a non-deterministic finite automation;
[0015] In a non-deterministic finite automaton undirected graph, when two edge nodes are connected by a state in the state machine topology, an undirected edge is created between the two edge nodes;
[0016] The non-deterministic finite automaton undirected graph is generated based on a plurality of edge nodes and a plurality of undirected edges.
[0017] Optionally, a label is set on the edge from each node to another node in the state machine topology structure;
[0018] The step of using an edge from one node to another node in the state machine topology structure as an edge node in an undirected graph of a non-deterministic finite automation machine comprises:
[0019] If there are multiple edges in the state machine topology structure that have the same label and are connected to the same state, the multiple edges in the state machine topology structure are used as an edge node of the state machine undirected graph structure.
[0020] Optionally, the neighbor sampling is performed by the following steps:
[0021] Obtaining a non-deterministic finite automaton undirected graph after converting the undirected graph;
[0022] Obtaining a label for each node in the non-deterministic finite automaton undirected graph;
[0023] Inputting the labeled non-deterministic finite automaton undirected graph into the initial graph convolutional neural network;
[0024] Neighbor sampling is performed on the labeled non-deterministic finite automaton undirected graph to obtain a local subgraph set.
[0025] Optionally, the performing neighbor sampling on the labeled non-deterministic finite automaton undirected graph to obtain a local subgraph set includes:
[0026] Randomly select a preset number of nodes from the non-deterministic finite automaton undirected graph with labels as root nodes;
[0027] For each of the root nodes, randomly select a first number of neighbor nodes from a neighbor list of the root node to generate a first-layer local subgraph;
[0028] For each neighbor node in the first-layer local subgraph, randomly select a second number of neighbor nodes from the neighbor list of the neighbor node to generate a second-layer local subgraph;
[0029] The local subgraph set is constructed based on each of the first-layer local subgraphs and each of the second-layer local subgraphs.
[0030] Optionally, obtaining the label of each node in the non-deterministic finite automaton undirected graph includes:
[0031] For each node in the non-deterministic finite automaton undirected graph, obtaining the frequency of occurrence of characters of the node;
[0032] When the frequency of occurrence of the character is higher than a preset high-frequency threshold, determining the label of the node as a positive sample label;
[0033] When the occurrence frequency of the character is lower than a preset low-frequency threshold, the label of the node is determined to be a negative sample label.
[0034] Optionally, the polymerization operation is performed by the following steps:
[0035] Obtaining a set of local subgraphs after sampling the neighbors;
[0036] For each node in each local subgraph in the local subgraph set, an aggregation operation is performed on the feature vectors of each neighboring node of the node to obtain an aggregated feature vector.
[0037] Optionally, the aggregating the feature vectors of each neighboring node of the node to obtain an aggregated feature vector includes:
[0038] Adding the feature vectors of each neighboring node of the node to obtain a target feature vector;
[0039] The target feature vector is divided by the number of each neighboring node of the node to obtain the aggregated feature vector.
[0040] Optionally, the aggregating the feature vectors of each neighboring node of the node to obtain an aggregated feature vector includes:
[0041] For each neighbor node of the node, linearly transform the feature vector of the neighbor node to obtain a first feature vector;
[0042] Processing the first feature vector based on a nonlinear activation function to obtain a second feature vector;
[0043] The maximum eigenvalue of each of the second eigenvectors in each dimension is selected as the aggregated eigenvector.
[0044] Optionally, the aggregating the feature vectors of each neighboring node of the node to obtain an aggregated feature vector includes:
[0045] The feature vectors of neighboring nodes of the node are summed to obtain the aggregated feature vector.
[0046] Optionally, the aggregating the feature vectors of each neighboring node of the node to obtain an aggregated feature vector includes:
[0047] Initialize the hidden state and cell state of the long short-term memory network;
[0048] For each neighbor node of the node, the feature vectors of the neighbor node are sequentially input into the long short-term memory network, and for each input, a forget gate, an input gate and an output gate are calculated to update the hidden state and the cell state;
[0049] After the long short-term memory network has processed the feature vectors of all neighboring nodes of the node, the final hidden state of the long short-term memory network is determined as the aggregated feature vector.
[0050] Optionally, the aggregating the feature vectors of each neighboring node of the node to obtain an aggregated feature vector includes:
[0051] Assign different weights to the feature vectors of each neighbor node of the node through the attention mechanism to obtain a weight matrix, and calculate the attention coefficient of the node to each neighbor node;
[0052] The cumulative sum of the products of the attention coefficients, the weight matrices, and the feature vectors of each neighboring node of the node is calculated to obtain the aggregated feature vector.
[0053] Optionally, the feature fusion is performed through the following steps:
[0054] After the aggregation operation, an aggregate feature vector and a feature vector of a node are obtained;
[0055] Perform feature fusion on the aggregated feature vector and the feature vector of the node.
[0056] Optionally, the performing feature fusion on the aggregated feature vector and the feature vector of the node includes:
[0057] A concatenation operation or an element-wise addition operation is performed on the aggregated feature vector and the feature vector of the node.
[0058] Optionally, the clustering process is performed by the following steps:
[0059] After the features are fused, a fused feature vector and a feature vector of a node are obtained;
[0060] Based on the fused feature vector, the feature vector of the node is updated to obtain an embedding vector of the node;
[0061] The embedding vector of each node is input into the initial clustering model for clustering processing to obtain a plurality of regular character clusters.
[0062] Optionally, the embedding vector of each node is input into the initial clustering model for clustering processing to obtain a plurality of regular character clusters, including:
[0063] The embedding vector of each node is input into the initial clustering model, and based on the distance between the embedding vector of each node and the cluster center, each node is respectively assigned to the nearest cluster class to obtain the multiple regular character clusters.
[0064] Optionally, generating a non-deterministic finite automaton according to a regular expression includes:
[0065] For each unique character in the regular expression, counting the frequency of occurrence of the unique character in a plurality of regular expressions;
[0066] normalizing the occurrence frequency;
[0067] The non-deterministic finite automaton is generated based on the normalized occurrence frequency of each of the unique characters.
[0068] Optionally, the comprehensive loss function includes a classification loss of a node, a clustering loss, and a regularization term of a Laplacian matrix.
[0069] Optionally, the performing inductive reasoning on other batches of the non-deterministic finite automata based on the graph convolutional neural network and the clustering model includes:
[0070] For each of the non-deterministic finite automata in the other batches, convert the non-deterministic finite automata into a non-deterministic finite automata undirected graph;
[0071] Inputting the non-deterministic finite automaton undirected graph into the graph convolutional neural network;
[0072] Performing neighbor sampling on the non-deterministic finite automaton undirected graph to obtain a local subgraph set;
[0073] For each node in each local subgraph in the local subgraph set, performing an aggregation operation on the feature vectors of each neighboring node of the node to obtain an aggregated feature vector;
[0074] Performing feature fusion on the aggregated feature vector and the feature vector of the node;
[0075] Based on the fused feature vector, the feature vector of the node is updated to obtain an embedding vector of the node;
[0076] The embedding vector of each node is input into the clustering model for clustering processing to obtain multiple regular character clusters.
[0077] The present application also provides a regular acceleration system based on inductive learning, comprising:
[0078] A first local hardware device is used to obtain a data control flow and generate a non-deterministic finite automaton according to a regular expression, wherein the non-deterministic finite automaton is used to characterize the regular expression to analyze and filter the data control flow;
[0079] a heterogeneous device, which is communicatively connected to the first local hardware device and is used to receive the data control flow and the non-deterministic finite automaton;
[0080] A second local hardware device is communicatively connected to the first local hardware device, and is used to perform inductive learning on an initial batch of the non-deterministic finite automata based on an initial graph convolutional neural network and an initial clustering model, and calculate a comprehensive loss value based on the inductive learning result, and jointly train the initial graph convolutional neural network and the initial clustering model based on the comprehensive loss value to obtain a graph convolutional neural network and a clustering model; wherein the inductive learning includes undirected graph conversion, neighbor sampling, aggregation operation, feature fusion and clustering processing; and, based on the graph convolutional neural network and the clustering model, perform inductive reasoning on other batches of the non-deterministic finite automata, and when the non-deterministic finite automata are in a matching relationship with the regular expression represented by them, configure the non-deterministic finite automata to the corresponding regular engine, and perform parallel analysis and filtering on the data control flow.
[0081] The present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the regularized acceleration method based on inductive learning as described above are implemented.
[0082] The present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described regularized acceleration methods based on inductive learning.
[0083] The present application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of any of the regularized acceleration methods based on inductive learning described above.
[0084] The present application provides a regular acceleration method, system, device and storage medium based on inductive learning. The method is applied to a regular acceleration system based on inductive learning. The regular acceleration system based on inductive learning includes a first local hardware device, a second local hardware device and a heterogeneous device. The first local hardware device is respectively connected to the second local hardware device and the heterogeneous device for communication. The method includes: first, the first local hardware device obtains a data control flow, and generates a non-deterministic finite automaton according to a regular expression, the non-deterministic finite automaton is used to characterize the regular expression to analyze and filter the data control flow; then, the heterogeneous device receives the data control flow and the non-deterministic finite automaton; then, the second local hardware device performs inductive learning on the first batch of non-deterministic finite automata based on an initial graph convolutional neural network and an initial clustering model, and calculates a comprehensive loss value based on the inductive learning result, and calculates the comprehensive loss value based on the comprehensive loss value. The initial graph convolutional neural network and the initial clustering model are jointly trained with the combined loss value to obtain the graph convolutional neural network and the clustering model; wherein, the inductive learning includes undirected graph conversion, neighbor sampling, aggregation operation, feature fusion and clustering processing; that is, the graph convolutional neural network and the clustering model can be obtained in advance through inductive learning; finally, based on the graph convolutional neural network and the clustering model, inductive reasoning is performed on other batches of non-deterministic finite automata, and when the non-deterministic finite automata are matched with the regular expressions represented by them, the non-deterministic finite automata are configured to the corresponding regular engine, and the data control flow is analyzed and filtered in parallel; that is, for other batches of dynamically changing non-deterministic finite automata, there is no need to train the model, and the trained graph convolutional neural network and clustering model are directly used for inductive reasoning, which can improve the regular acceleration efficiency in the scenario where the non-deterministic finite automata change dynamically. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] In order to more clearly illustrate the technical solutions in the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0086] Figure 1 It is a schematic diagram of the hardware composition of the regular acceleration system based on inductive learning provided in an embodiment of the present application.
[0087] Figure 2 It is a flowchart of a regular acceleration method based on inductive learning provided in an embodiment of the present application.
[0088] Figure 3 It is a schematic diagram of the principle of the regularized acceleration method based on inductive learning provided in an embodiment of the present application.
[0089] Figure 4It is a schematic diagram of the topological structure of a non-deterministic finite automaton provided in an embodiment of the present application.
[0090] Figure 5 It is a schematic diagram of an undirected graph of a non-deterministic finite automaton provided in an embodiment of the present application.
[0091] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0092] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0093] The terms "first", "second", etc. in the specification of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are usually a class, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0094] The following is a detailed description of the regularized acceleration method based on inductive learning provided by the embodiment of the present application through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0095] Please refer to Figure 1 , Figure 1 Schematic diagram of the hardware composition of the regular acceleration system based on inductive learning provided in the embodiment of the present application. Figure 1 As shown, the system includes: a first local hardware device, a second local hardware device and a heterogeneous device, and the first local hardware device is respectively connected to the second local hardware device and the heterogeneous device. The first local hardware device can be a CPU, such as an Intel i7 CPU. The second local hardware device can be a graphics processing unit (Graphics Processing Unit, GPU), such as an NVIDIA A100 GPU. The heterogeneous device can be a field programmable gate array (Field Programmable Gate Array, FPGA), such as an F37X FPGA.
[0096] Optionally, the system further includes a database and a client. The database may adopt PostgreSQL 11.2 version.
[0097] Specifically, the PostgreSQL 11.2 version of the database can exchange data with other system components through the PCIE interface, thereby ensuring the real-time processing capability of regular expression queries. The Intel i7 CPU includes a state machine generation module, a data processing module, and a decision module. Among them, the state machine generation module can generate a non-deterministic finite automaton based on a regular expression. The data processing module can obtain data from the undirected graph of the non-deterministic finite automaton through feature extraction technology for use in graph convolutional neural network training. The decision module can determine whether the generated non-deterministic finite automaton matches the client's regular query based on the graph convolutional neural network obtained by inductive learning, and trigger the heterogeneous computing process of the FPGA if it matches.
[0098] NVIDIA A100 GPU supports inductive learning and inductive reasoning, such as using graph convolutional neural networks for reasoning and using clustering models to analyze regular character clusters to verify the accuracy of the state machine and assist the decision-making module in deciding whether to activate the FPGA's computational offload process.
[0099] It should be noted that the Intel i7 CPU and NVIDIA A100 GPU can be components of the NF5468M6 server, but this embodiment is not limited thereto.
[0100] The F37X FPGA routes data at high speed through a crossbar switch and integrates a series of computing units (CUs) running at 250MHz, demonstrating the platform's ability to perform optimized parallel processing. The system integrates the FPGA as a user-defined function (HUDF) into the PostgreSQL 11.2 version of the database, leveraging its parallel processing capabilities and high-speed memory access to significantly improve response time and processing throughput for SQL strings such as LIKE and REGEXP_LIKE.
[0101] The following is based on Figure 1 The regular acceleration system based on inductive learning shown in the figure explains the regular acceleration method based on inductive learning in detail.
[0102] Please refer to Figure 2 , Figure 2 is a flow chart of a regular acceleration method based on inductive learning provided in an embodiment of the present application. The method is applied to the regular acceleration system based on inductive learning, such as Figure 2 As shown, the method may include the following steps 201-204.
[0103] Step 201: A first local hardware device obtains a data control flow, and generates a non-deterministic finite automaton according to a regular expression, wherein the non-deterministic finite automaton is used to characterize the regular expression to analyze and filter the data control flow.
[0104] In one embodiment, generating a non-deterministic finite automaton based on a regular expression in step 201 includes: for each unique character in the regular expression, counting the frequency of occurrence of the unique character in a number of regular expressions; normalizing the frequency of occurrence; and generating a non-deterministic finite automaton based on the normalized frequency of occurrence of each unique character.
[0105] Specifically, the regular record document includes several regular expressions, all unique characters in the regular expressions are extracted, and the high-frequency and low-information characters in all the unique characters are filtered, so as to filter out the characters that contribute less to the understanding of the regular law. And the N most important characters are selected from all the unique characters, which can avoid the problem of sparse vector representation when the number of characters is very large. The occurrence frequencies of the N most important characters in several regular expressions are counted. The occurrence frequencies are normalized, and a non-deterministic finite automaton is generated based on the normalized occurrence frequencies.
[0106] Step 202: The heterogeneous device receives the data control flow and the non-deterministic finite automaton.
[0107] Step 203: The second local hardware device performs inductive learning on the initial batch of non-deterministic finite automata based on the initial graph convolutional neural network and the initial clustering model, calculates a comprehensive loss value based on the inductive learning result, and jointly trains the initial graph convolutional neural network and the initial clustering model based on the comprehensive loss value to obtain the graph convolutional neural network and the clustering model; wherein the inductive learning includes undirected graph conversion, neighbor sampling, aggregation operation, feature fusion and clustering processing.
[0108] Specifically, the initial batch of non-deterministic finite automata are used as sample training sets, and the sample training sets are inductively learned using the initial graph convolutional neural network and the initial clustering model, and the comprehensive loss value is calculated based on the inductive learning result, and the initial graph convolutional neural network and the initial clustering model are jointly trained based on the comprehensive loss value to obtain the graph convolutional neural network and the clustering model. That is, the graph convolutional neural network and the clustering model can be obtained in advance through inductive learning.
[0109] like Figure 3As shown in the figure, for inductive learning, in the training loop, the model calculates the feature representation of the node through forward propagation in each training cycle (epoch). Specifically, first, the non-deterministic finite automaton is converted into the required undirected graph structure; then, the neighbors of each training node are sampled, for example, each node has at most 2 neighbors in the first layer and at most 2 neighbors in the second layer; then, in training, each node can perceive the structure around it within a limited range, and by aggregating the nodes in the training set, their embedding vectors can be generated. Aggregation operations usually include summarizing the information of neighboring nodes, such as calculating the average, maximum or sum of neighboring nodes, so as to capture the correlation characteristics between nodes. Then, based on these representations, the comprehensive loss value is calculated, and the model parameters are updated through backpropagation and optimizer.
[0110] In addition, the performance of the model on the test set was evaluated after training. This joint training method enables the model to effectively learn node feature representations and perform node clustering at the same time, providing a powerful and flexible tool for graph data analysis. Not only is a high-quality embedding representation of each non-deterministic finite automaton undirected graph node in the graph obtained, but the nodes are also effectively assigned to different clusters based on these representations. This method allows the use of deep node features learned by graph convolutional neural networks and the clustering ability of clustering models to achieve more refined and meaningful clustering analysis on graph data.
[0111] Optionally, the Adam optimizer is used during training, which is used to adaptively adjust the learning rate during each training iteration.
[0112] Step 204: The second local hardware device performs inductive reasoning on other batches of non-deterministic finite automata based on the graph convolutional neural network and the clustering model. When the non-deterministic finite automata are matched with the regular expressions they represent, the non-deterministic finite automata are configured to the corresponding regular engine to perform parallel analysis and filtering on the data control flow.
[0113] Specifically, for other batches of dynamically changing non-deterministic finite automata, there is no need to train the model. Graph convolutional neural networks and clustering models can be directly used for inductive reasoning. When the non-deterministic finite automaton matches the regular expression it represents, the non-deterministic finite automaton is configured on the corresponding regular engine, and the data control flow is analyzed and filtered in parallel. This can improve the regular acceleration efficiency in scenarios where non-deterministic finite automata change dynamically.
[0114] like Figure 3As shown in Figure 1, for inductive reasoning, when debugging the NFA generation algorithm, slight algorithm changes often cause changes in the graph model structure. In this regard, the previous model needs to be retrained, which is time-consuming and cumbersome. However, this embodiment can capture such topological changes without retraining, thereby obtaining the corresponding node representation. Specifically, it can be observed that Figure 3 The connection relationship between the nodes of the undirected graph has changed due to the change of the algorithm. Through neighbor sampling, this change in topology can be well captured, thereby generating different vector aggregation methods, and then obtaining vector representations different from inductive learning. The newly obtained vectors have both the experience gained from previous training and the changes in the regularization algorithm, so as to better perform the subsequent correlation analysis.
[0115] Exemplarily, the CPU and GPU are deployed on the NF5266M6 server, and the F37X FPGA acceleration card is used to achieve heterogeneous acceleration. The workflow is as follows: First, the CPU transfers the data of the database to the double data rate synchronous dynamic random access memory (Double Data Rate, DDR) of the FPGA board through direct memory access (Direct Memory Access, DMA). At the same time, the CPU generates the NFA of the regular expression, and forms the information of the NFA into a frame containing multiple regular expressions, each frame can contain multiple regular expressions, and then transmits it to the DDR of the FPGA board. The CPU sends the necessary control instructions to the FPGA through registers, including control start, reset, address offset, etc. Subsequently, the initial batch of non-deterministic finite automata is used as the sample training set, and the sample training set is inductively learned using the initial graph convolutional neural network and the initial clustering model, and the comprehensive loss value is calculated based on the inductive learning result, and the initial graph convolutional neural network and the initial clustering model are jointly trained based on the comprehensive loss value to obtain the graph convolutional neural network and the clustering model. Next, for other batches of dynamically changing non-deterministic finite automata, there is no need to train the model, and the graph convolutional neural network and clustering model are directly used for inductive reasoning. When the non-deterministic finite automata match the regular expressions they represent, the frame data is parsed and different NFAs are configured to different regular engines according to the configuration information. Once the regular engine configuration is completed, the system begins to analyze and filter the data frames in parallel, and finally summarizes the results, achieving hardware acceleration by processing the data frames in parallel.
[0116] In general, compared with the scenarios of static graph and full graph training, the inductive learning and inductive reasoning scheme of this embodiment can be directly applied to scenarios where the graph structure changes. For example, when a new topological structure is generated in the NFA state machine due to algorithm changes, the graph structure can be efficiently learned without retraining.
[0117] The regular acceleration method based on inductive learning provided by the embodiment of the present application is as follows: first, a first local hardware device obtains a data control flow, and generates a non-deterministic finite automaton according to a regular expression, and the non-deterministic finite automaton is used to characterize the regular expression to analyze and filter the data control flow; then, a heterogeneous device receives the data control flow and the non-deterministic finite automaton; then, a second local hardware device performs inductive learning on the first batch of non-deterministic finite automata based on an initial graph convolutional neural network and an initial clustering model, and calculates a comprehensive loss value based on the inductive learning result, and jointly trains the initial graph convolutional neural network and the initial clustering model based on the comprehensive loss value to obtain a graph convolutional neural network and a clustering model; wherein the inductive learning includes undirected graph conversion, Neighbor sampling, aggregation operation, feature fusion and clustering processing; that is, the graph convolutional neural network and clustering model can be obtained in advance through inductive learning; finally, the second local hardware device performs inductive reasoning on other batches of non-deterministic finite automata based on the graph convolutional neural network and clustering model. When the non-deterministic finite automata are matched with the regular expressions they represent, the non-deterministic finite automata are configured to the corresponding regular engine to perform parallel analysis and filtering on the data control flow; that is, for other batches of dynamically changing non-deterministic finite automata, there is no need to train the model, and the trained graph convolutional neural network and clustering model can be directly used for inductive reasoning, which can improve the regular acceleration efficiency in scenarios where non-deterministic finite automata change dynamically.
[0118] In one embodiment, undirected graph conversion is performed by the following sub-steps:
[0119] Step 20300: For each non-deterministic finite automaton in the initial batch, convert the non-deterministic finite automaton into a non-deterministic finite automaton undirected graph.
[0120] Optionally, step 20300 includes:
[0121] Step 203001: Obtain the state machine topology structure of the non-deterministic finite automaton.
[0122] For example, the expression p(at) (r|n) as an example, get Figure 4 The state machine topology of the non-deterministic finite automaton shown in the figure, where Si is the initial state, S0 to S4 are intermediate states, Sf is the final acceptance state, and ε represents an arbitrary character.
[0123] Step 203002: Use the edge from one node to another node in the state machine topology structure as an edge node in the non-deterministic finite automaton undirected graph.
[0124] Optionally, a label is set on the edge from each node to another node in the state machine topology structure; step 203002 includes: if there are multiple edges in the state machine topology structure with the same label and connected to the same state, then the multiple edges in the state machine topology structure are used as an edge node of the state machine undirected graph structure.
[0125] For example, Figure 4 As shown, the nodes of the state topology structure include:
[0126] From Si to S0: an edge with an empty string (ε);
[0127] From S0 to S1: edge with label 'p';
[0128] From S1 to S2: edge with label 'a';
[0129] From S2 to S3: edge with label 't';
[0130] From S3 to Sf: edge with label 'r';
[0131] From S0 to S3: an edge with label 'p';
[0132] From S0 to S4: an edge with label 'p';
[0133] From S2 to S4: edge with label 'n';
[0134] From S4 to Sf: edge with label 'n'.
[0135] It can be seen that from S0 to S1, S0 to S3, S0 to S4 these are all edges with label ‘p’, indicating that there are multiple transition paths between these states.
[0136] In this state topology, the ε transition (i.e., the empty string transition) allows the automaton to move from Si to S0 without input. The characters on the other edges (p, a, t, r, n) represent possible state transitions when receiving a specific input. In addition, Figure 4 A cycle in means that the automaton can stay in the same state when receiving a specific input in a given state.
[0137] If there are multiple edges in the state machine topology with the same label and connected to the same state, they can be considered as the same node. For example, if there are two edges with the label 'p' connected to state S1, then there is only one p node in the new graph. Then, the edge nodes in the final non-deterministic finite automaton undirected graph include: ε, p, a, t, r, n.
[0138] Step 203003: In the non-deterministic finite automaton undirected graph, when two edge nodes are connected by a state in the state machine topology, an undirected edge is created between the two edge nodes.
[0139] For example, ε and p are connected through S0 in the state machine topology, and an undirected edge is created between ε and p, that is, ε is connected to p; p and a are connected through S1 in the state machine topology, and an undirected edge is created between p and a, that is, p is connected to a, and so on. Then, the undirected edges in the final non-deterministic finite automaton undirected graph include: ε is connected to p, p is connected to a, p is connected to t, p is connected to r, t is connected to n, and r is connected to n.
[0140] Step 203004: Generate a non-deterministic finite automaton undirected graph based on multiple edge nodes and multiple undirected edges.
[0141] For example, based on multiple edge nodes (ε, p, a, t, r, n) and multiple undirected edges (ε is connected to p, p is connected to a, p is connected to t, p is connected to r, t is connected to n, r is connected to n) Figure 5 The nondeterministic finite automaton undirected graph shown.
[0142] In this embodiment, the non-deterministic finite automaton can be converted into a non-deterministic finite automaton undirected graph.
[0143] In one embodiment, neighbor sampling is performed by the following steps:
[0144] Step 20301, obtaining a non-deterministic finite automaton undirected graph after the undirected graph is converted;
[0145] Step 20302: Obtain the label of each node in the non-deterministic finite automaton undirected graph.
[0146] Optionally, step 20302 includes: for each node in the non-deterministic finite automaton undirected graph, obtaining the frequency of occurrence of characters of the node; when the frequency of occurrence of characters is higher than a preset high-frequency threshold, determining the label of the node as a positive sample label; when the frequency of occurrence of characters is lower than a preset low-frequency threshold, determining the label of the node as a negative sample label. The high-frequency threshold is the same as the low-frequency threshold, or the low-frequency threshold is lower than the high-frequency threshold.
[0147] Step 20303: Input the labeled non-deterministic finite automaton undirected graph into the initial graph convolutional neural network.
[0148] Specifically, the initial graph convolutional neural network includes a first convolutional layer, a fusion layer, and a second convolutional layer. The first convolutional layer is used for neighbor sampling and aggregation operations, the fusion layer is used to fuse the aggregated feature vector and the feature vector of the node, and the second convolutional layer is used to update the feature vector of the node.
[0149] Step 20304: Perform neighbor sampling on the labeled non-deterministic finite automaton undirected graph to obtain a local subgraph set.
[0150] Optionally, step 20304 includes: randomly selecting a preset number of nodes from a labeled non-deterministic finite automaton undirected graph as root nodes; for each root node, randomly selecting a first number of neighbor nodes from the neighbor list of the root node to generate a first-layer local subgraph; for each neighbor node in the first-layer local subgraph, randomly selecting a second number of neighbor nodes from the neighbor list of the neighbor node to generate a second-layer local subgraph; and constructing a local subgraph set based on each first-layer local subgraph and each second-layer local subgraph.
[0151] Exemplarily, 16 nodes are randomly selected from a labeled non-deterministic finite automaton undirected graph as root nodes. For each root node, up to 5 neighbor nodes are randomly selected from the neighbor list of the root node, and these neighbor nodes constitute the first-level local subgraph. For each neighbor node in the first-level local subgraph, up to 10 neighbor nodes are randomly selected from the neighbor list of the neighbor node to generate a second-level local subgraph, and the local subgraph can be expanded to include more distant nodes. These first-level local subgraphs and second-level local subgraphs together constitute a local subgraph set.
[0152] In this embodiment, a local subgraph set may be obtained through neighbor sampling.
[0153] In one embodiment, the polymerization operation is performed by the following steps:
[0154] Step 20305: Obtain a local subgraph set after neighbor sampling;
[0155] Step 20306: For each node in each local subgraph in the local subgraph set, perform an aggregation operation on the feature vectors of each neighboring node of the node to obtain an aggregated feature vector.
[0156] For the aggregation operation, the following implementation methods can be included:
[0157] 1) Add the feature vectors of each neighboring node of the node to obtain the target feature vector; divide the target feature vector by the number of neighboring nodes of the node to obtain the aggregated feature vector.
[0158] Specifically, the mean aggregation operation can be performed using expression (1):
[0159] (1)
[0160] in, Represents a node, Representation Node The neighbor nodes of Representation Node The set of neighbor nodes of Representation Node The number of neighbor nodes, Represents neighbor nodes The characteristic vector of represents the aggregate feature vector.
[0161] 2) For each neighbor node of the node, perform a linear transformation on the feature vector of the neighbor node to obtain a first feature vector; process the first feature vector based on a nonlinear activation function to obtain a second feature vector; select the maximum eigenvalue of each second feature vector in each dimension as the aggregated feature vector.
[0162] Specifically, the maximum pooling aggregation operation can be performed through expression (2):
[0163] (2)
[0164] in, represents a nonlinear activation function, represents the weight matrix.
[0165] The maximum pooling aggregation operation helps to ignore the noise in the neighborhood by extracting the most significant feature signals. In many cases, important information is often reflected in the extreme values of the feature values, and maximum pooling is an effective way to capture these extreme values. Compared with some aggregation methods that require complex calculations, the maximum pooling aggregation operation only involves simple comparison and selection operations and has lower computational complexity.
[0166] 3) Sum the feature vectors of each neighboring node of the node to obtain the aggregated feature vector.
[0167] Specifically, the summation aggregation operation can be performed using expression (3):
[0168] (3)
[0169] The summation operation is simple and direct, and is suitable for scenarios where the sum of the feature vectors of neighbor nodes can provide useful information. In addition, the summation operation is very intuitive, and can simply add the feature vectors of all neighbor nodes together without considering the order between neighbor nodes or other complex interaction mechanisms, making the implementation and understanding of the model easy.
[0170] 4) Initialize the hidden state and cell state of the Long Short-Term Memory (LSTM) network; for each neighbor node of the node, input the feature vector of the neighbor node into the LSTM network in sequence order, calculate the forget gate, input gate and output gate for each input, and update the hidden state and cell state; after the LSTM network processes the feature vectors of all neighbor nodes of the node, determine the final hidden state of the LSTM network as the aggregated feature vector.
[0171] Specifically, the LSTM aggregation operation can be performed through expression (4), which can take into account the order of neighbor nodes:
[0172] (4)
[0173] in, Represents a long short-term memory network.
[0174] Here, the LSTM processes the feature vectors of neighbor nodes in some order (maybe random or sorted according to node features), which allows the model to capture potential sequential dependencies between neighbors.
[0175] LSTM includes a forget gate, an input gate, a cell state update, and an output gate. Each step uses a specific weight matrix, bias term, and activation function to process the input data and the state of the previous time step, dynamically deciding which information to keep, discard, or update.
[0176] The following is a detailed description of the LSTM calculation process:
[0177] 1. Forgetting Gate
[0178] The forget gate determines what information needs to be forgotten or discarded from the cell state. It receives the hidden state of the previous time step. and the input of the current time step , a sigmoid function is used to output a forgetting factor between 0 and 1 , where 0 means completely discarded and 1 means completely retained.
[0179] (5)
[0180] in, represents the sigmoid function, represents the weight matrix of the forget gate, Represents the bias term of the forget gate.
[0181] 2. Input Gate
[0182] The input gate determines the current input What new information will be stored in the cell state. It consists of two parts: one is a sigmoid layer output , determines the importance of the updated value; the other part is a tanh layer that generates a new candidate value , can be added to the state.
[0183] (6)
[0184] (7)
[0185] in, Represents the weight matrix of the input gate, which controls the transition from the previous hidden state and the current input Activation value to the input gate information flow; represents the bias term of the input gate, which is added to the weight matrix On the processed input, it can help adjust the activation threshold of the gate; Represents the state used to generate candidate cells The weight matrix of the previous hidden state is also applied to the connection and the current input ; Represents the bias term used when generating candidate cell states.
[0186] 3. Cell State
[0187] Cell state It is the component used for long-term memory in LSTM. It combines the output of the forget gate to discard no longer needed information and add new candidate values from the input gate , these new candidate values are given by Determines the extent of its joining status.
[0188] (8)
[0189] 4. Output Gate
[0190] The output gate controls the cell state To hidden state First, a sigmoid layer is used to determine which parts of the cell state will be output. Then, the cell state is passed through tanh (to get a value between -1 and 1) and multiplied by the output of the sigmoid gate to determine the final output. .
[0191] (9)
[0192] (10)
[0193] in, represents the activation value of the output gate, represents the weight matrix of the input gate, Represents the bias term of the input gate.
[0194] The following is a detailed description of the process of LSTM aggregation operation:
[0195] 1. Initialization: initial hidden state of LSTM and cell status Usually initialized to a zero vector.
[0196] 2. Sequence processing: for nodes Each neighbor node of , its characteristics Input the LSTM sequentially in sequence order. For each input, the LSTM updates its hidden state and cell state according to the calculation steps described above (forget gate, input gate, cell state update, and output gate).
[0197] 3. Aggregate neighbor features: After processing all neighbor features, the final hidden state of LSTM (where T is the number of neighbors) contains the combined information about all neighbors of node v. This final state Can be used directly as a node Aggregation features .
[0198] Through the above steps, LSTM is able to dynamically update its internal state and output at each time step, which makes it very suitable for processing sequence data with complex time dependencies. The forget gate allows LSTM to discard information that is no longer needed, the input gate allows it to update the internal state to incorporate new information, and the output gate controls which information will be used as the output of the current time step. These dynamic adjustment capabilities make LSTM particularly good at capturing long-term dependencies, avoiding the gradient disappearance or explosion problems that traditional recurrent neural networks (RNNs) are prone to.
[0199] 5) Assign different weights to the feature vectors of each neighbor node of the node through the attention mechanism, obtain the weight matrix, and calculate the attention coefficient of the node to each neighbor node; calculate the cumulative sum of the product of the attention coefficient, weight matrix and feature vector of each neighbor node of the node to obtain the aggregated feature vector.
[0200] Specifically, the graph attention aggregation operation can be performed through expression (11):
[0201] (11)
[0202] in, represents the attention coefficient, represents the weight matrix.
[0203] For the attention coefficient, first calculate the node The eigenvector of Through the weight matrix Transformed feature vectors and neighbor nodes The eigenvector of Through the weight matrix The similarity between the transformed feature vectors; similarity can be calculated by point multiplication, cosine similarity, etc. Then the similarity score is standardized to obtain the attention coefficient .
[0204] The attention coefficient can be calculated by expression (12):
[0205] (12)
[0206] in, Represents the scoring function, used to calculate and The similarity between .
[0207] The graph attention aggregation operation allows the model to dynamically focus on more important neighbor nodes.
[0208] It should be noted that the various implementations of the above-mentioned aggregation operation are suitable for different scenarios and needs, and the selection of which implementation depends on the objectives of the specific task and the characteristics of the graph data.
[0209] In one embodiment, feature fusion is performed by the following steps:
[0210] Step 20307, obtaining the aggregate feature vector and the feature vector of the node after the aggregation operation;
[0211] Step 20308: perform feature fusion on the aggregated feature vector and the feature vector of the node.
[0212] Optionally, step 20308 includes: performing a concatenation operation or an element-wise summation operation on the aggregated feature vector and the feature vector of the node. Since the neighbor nodes contain important context information, it can help improve the understanding and representation of the nodes.
[0213] In this embodiment, feature fusion is performed on the aggregated feature vector and the feature vector of the node, which can help improve the understanding and representation of the node.
[0214] In one embodiment, clustering is performed by the following steps:
[0215] Step 20309: After feature fusion, obtain the fused feature vector and the feature vector of the node.
[0216] Step 20310: Update the feature vector of the node based on the fused feature vector to obtain the embedding vector of the node.
[0217] Step 20311: Input the embedding vector of each node into the initial clustering model for clustering processing to obtain multiple regular character clusters.
[0218] Optionally, step 20311 includes: inputting the embedding vector of each node into the initial clustering model, and assigning each node to the nearest cluster based on the distance between the embedding vector of each node and the cluster center, so as to obtain multiple regular character clusters.
[0219] Exemplarily, the initial clustering model is the KMeans algorithm. The number of clusters K in the KMeans algorithm is determined according to the application scenario and data characteristics. The KMeans algorithm can be used to assign each node to the nearest cluster based on the distance between the embedding vector of each node and the cluster center, and obtain K regular character clusters. Each regular character cluster contains similar nodes.
[0220] In this embodiment, multiple regular character clusters can be obtained through clustering processing.
[0221] Optionally, the comprehensive loss function includes node classification loss, clustering loss and Laplace matrix regularization term, and the combination of these three takes into account both the accuracy of node classification and the compactness of clustering, while maintaining the integrity of the graph structure through the Laplace regularization term.
[0222] Specifically, the cross entropy loss function is used to calculate the difference between the node's embedding vector and the node's label; the regularization term of the Laplacian matrix is used to exploit the structural information of the non-deterministic finite automaton undirected graph to encourage adjacent nodes in unlabeled nodes to have similar feature representations; the clustering loss function is used to calculate the average distance from each node to its nearest cluster center.
[0223] In one embodiment, step 204 may include the following sub-steps:
[0224] Step 2041: For each non-deterministic finite automaton in other batches, convert the non-deterministic finite automaton into a non-deterministic finite automaton undirected graph.
[0225] Specifically, first, for each non-deterministic finite automaton of other batches, a state machine topology structure of the non-deterministic finite automaton is obtained; then, an edge from one node to another node in the state machine topology structure is used as an edge node in the non-deterministic finite automaton undirected graph; then, in the non-deterministic finite automaton undirected graph, when two edge nodes are connected by a state in the state machine topology structure, an undirected edge is created between the two edge nodes; finally, a non-deterministic finite automaton undirected graph is generated based on multiple edge nodes and multiple undirected edges.
[0226] Step 2042: input the non-deterministic finite automaton undirected graph into the graph convolutional neural network.
[0227] Step 2043: Perform neighbor sampling on the non-deterministic finite automaton undirected graph to obtain a local subgraph set.
[0228] Exemplarily, 16 nodes are randomly selected from a non-deterministic finite automaton undirected graph as root nodes. For each root node, up to 5 neighbor nodes are randomly selected from the neighbor list of the root node, and these neighbor nodes constitute the first-level local subgraph. For each neighbor node in the first-level local subgraph, up to 10 neighbor nodes are randomly selected from the neighbor list of the neighbor node to generate a second-level local subgraph, and the local subgraph can be expanded to include more distant nodes. These first-level local subgraphs and second-level local subgraphs together constitute a local subgraph set.
[0229] Step 2044: for each node in each local subgraph in the local subgraph set, perform an aggregation operation on the feature vectors of each neighboring node of the node to obtain an aggregated feature vector.
[0230] Aggregation operations may include: mean aggregation, maximum pooling, summation, LSTM, and graph attention. You can choose a suitable aggregation operation based on the goals of a specific task and the characteristics of the graph data.
[0231] Step 2045: perform feature fusion on the aggregated feature vector and the feature vector of the node.
[0232] Specifically, the aggregate feature vector and the feature vector of the node are concatenated or element-wise added. Since neighbor nodes contain important contextual information, they can help improve the understanding and representation of nodes.
[0233] Step 2046: Update the feature vector of the node based on the fused feature vector to obtain the embedding vector of the node.
[0234] Step 2047: Input the embedding vector of each node into the clustering model for clustering processing to obtain multiple regular character clusters.
[0235] Exemplarily, the clustering model is the KMeans algorithm. The number of clusters K in the KMeans algorithm is determined according to the application scenario and data characteristics. The KMeans algorithm can be used to assign each node to the nearest cluster based on the distance between the embedding vector of each node and the cluster center, and obtain K regular character clusters. Each regular character cluster contains similar nodes.
[0236] After obtaining a plurality of regular character clusters, when the correlations between each regular character cluster and each character in the regular expression are consistent, it is determined that the non-deterministic finite automaton is in a matching relationship with the regular expression represented by the cluster.
[0237] In this embodiment, for other batches of dynamically changing non-deterministic finite automata, there is no need to train the model. The trained graph convolutional neural network and clustering model can be directly used for inductive reasoning, which can improve the regular acceleration efficiency in the scenario of dynamic changes in non-deterministic finite automata.
[0238] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the regular acceleration method based on inductive learning provided in any of the above embodiments, which will not be described in detail here.
[0239] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0240] On the other hand, the present application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the regular acceleration method based on inductive learning provided in any of the above embodiments, which will not be repeated here.
[0241] On the other hand, the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the regularized acceleration method based on inductive learning provided in any of the above embodiments, which will not be described in detail here.
[0242] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0243] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A regular acceleration method based on inductive learning, characterized in that: Applied to a regular acceleration system based on inductive learning, the regular acceleration system based on inductive learning includes a first local hardware device, a second local hardware device and a heterogeneous device, the first local hardware device is respectively communicated with the second local hardware device and the heterogeneous device, and the method includes: The first local hardware device acquires a data control flow, and generates a non-deterministic finite automaton according to a regular expression, wherein the non-deterministic finite automaton is used to characterize the regular expression to analyze and filter the data control flow; The heterogeneous device receives the data control flow and the non-deterministic finite automaton; The second local hardware device performs inductive learning on the initial batch of the non-deterministic finite automata based on the initial graph convolutional neural network and the initial clustering model, calculates a comprehensive loss value based on the inductive learning result, and jointly trains the initial graph convolutional neural network and the initial clustering model based on the comprehensive loss value to obtain a graph convolutional neural network and a clustering model; wherein the inductive learning includes undirected graph conversion, neighbor sampling, aggregation operation, feature fusion and clustering processing; The second local hardware device performs inductive reasoning on the non-deterministic finite automata of other batches based on the graph convolutional neural network and the clustering model, and when the non-deterministic finite automata are in a matching relationship with the regular expressions represented by them, configures the non-deterministic finite automata to the corresponding regular engine, and performs parallel analysis and filtering on the data control flow; The step of generating a non-deterministic finite automaton according to a regular expression includes: For each unique character in the regular expression, counting the frequency of occurrence of the unique character in a plurality of regular expressions; normalizing the occurrence frequency; generating the non-deterministic finite automaton based on the normalized occurrence frequency of each of the unique characters; The performing inductive reasoning on other batches of the non-deterministic finite automata based on the graph convolutional neural network and the clustering model includes: For each of the non-deterministic finite automata in the other batches, convert the non-deterministic finite automata into a non-deterministic finite automata undirected graph; Inputting the non-deterministic finite automaton undirected graph into the graph convolutional neural network; Performing neighbor sampling on the non-deterministic finite automaton undirected graph to obtain a local subgraph set; For each node in each local subgraph in the local subgraph set, performing an aggregation operation on the feature vectors of each neighboring node of the node to obtain an aggregated feature vector; Performing feature fusion on the aggregated feature vector and the feature vector of the node; Based on the fused feature vector, the feature vector of the node is updated to obtain an embedding vector of the node; The embedding vector of each node is input into the clustering model for clustering processing to obtain multiple regular character clusters.
2. The regular acceleration method based on inductive learning according to claim 1, characterized in that: The undirected graph conversion is performed by the following steps: For each of the non-deterministic finite automata of the initial batch, the non-deterministic finite automata are converted into an undirected graph of non-deterministic finite automata.
3. The regular acceleration method based on inductive learning according to claim 2, characterized in that: The converting the non-deterministic finite automaton into a non-deterministic finite automaton undirected graph comprises: Obtaining a state machine topology structure of the non-deterministic finite automaton; Using an edge from one node to another node in the state machine topology as an edge node in an undirected graph of a non-deterministic finite automation; In a non-deterministic finite automaton undirected graph, when two edge nodes are connected by a state in the state machine topology, an undirected edge is created between the two edge nodes; The non-deterministic finite automaton undirected graph is generated based on a plurality of edge nodes and a plurality of undirected edges.
4. The regular acceleration method based on inductive learning according to claim 3, characterized in that: A label is set on the edge from each node to another node in the state machine topology structure; The step of using an edge from one node to another node in the state machine topology structure as an edge node in an undirected graph of a non-deterministic finite automation machine comprises: If there are multiple edges in the state machine topology structure that have the same label and are connected to the same state, the multiple edges in the state machine topology structure are used as an edge node of the state machine undirected graph structure.
5. The regular acceleration method based on inductive learning according to claim 1, characterized in that: The neighbor sampling is performed by the following steps: Obtaining a non-deterministic finite automaton undirected graph after the undirected graph is converted; Obtaining a label of each node in the non-deterministic finite automaton undirected graph; Inputting the labeled non-deterministic finite automaton undirected graph into the initial graph convolutional neural network; Neighbor sampling is performed on the labeled non-deterministic finite automaton undirected graph to obtain a local subgraph set.
6. The regular acceleration method based on inductive learning according to claim 5, characterized in that: The performing of neighbor sampling on the non-deterministic finite automaton undirected graph with labels to obtain a local subgraph set includes: Randomly select a preset number of nodes from the non-deterministic finite automaton undirected graph with labels as root nodes; For each of the root nodes, randomly select a first number of neighbor nodes from a neighbor list of the root node to generate a first-layer local subgraph; For each neighbor node in the first-layer local subgraph, randomly select a second number of neighbor nodes from the neighbor list of the neighbor node to generate a second-layer local subgraph; The local subgraph set is constructed based on each of the first-layer local subgraphs and each of the second-layer local subgraphs.
7. The regular acceleration method based on inductive learning according to claim 5, characterized in that: The step of obtaining the label of each node in the non-deterministic finite automaton undirected graph includes: For each node in the non-deterministic finite automaton undirected graph, obtaining the frequency of occurrence of characters of the node; When the frequency of occurrence of the character is higher than a preset high-frequency threshold, determining the label of the node as a positive sample label; When the occurrence frequency of the character is lower than a preset low-frequency threshold, the label of the node is determined to be a negative sample label.
8. The regular acceleration method based on inductive learning according to claim 1, characterized in that: The polymerization operation is carried out by the following steps: Obtaining a set of local subgraphs after sampling the neighbors; For each node in each local subgraph in the local subgraph set, an aggregation operation is performed on the feature vectors of each neighboring node of the node to obtain an aggregated feature vector.
9. The regular acceleration method based on inductive learning according to claim 8, characterized in that: The aggregating the feature vectors of the neighboring nodes of the node to obtain an aggregated feature vector includes: Adding the feature vectors of each neighboring node of the node to obtain a target feature vector; The target feature vector is divided by the number of each neighboring node of the node to obtain the aggregated feature vector.
10. The regular acceleration method based on inductive learning according to claim 8, characterized in that: The aggregating the feature vectors of the neighboring nodes of the node to obtain an aggregated feature vector includes: For each neighbor node of the node, linearly transform the feature vector of the neighbor node to obtain a first feature vector; Processing the first feature vector based on a nonlinear activation function to obtain a second feature vector; The maximum eigenvalue of each of the second eigenvectors in each dimension is selected as the aggregated eigenvector.
11. The regular acceleration method based on inductive learning according to claim 8, characterized in that: The aggregating the feature vectors of the neighboring nodes of the node to obtain an aggregated feature vector includes: The feature vectors of neighboring nodes of the node are summed to obtain the aggregated feature vector.
12. The regular acceleration method based on inductive learning according to claim 8, characterized in that: The aggregating the feature vectors of the neighboring nodes of the node to obtain an aggregated feature vector includes: Initialize the hidden state and cell state of the long short-term memory network; For each neighbor node of the node, the feature vectors of the neighbor node are sequentially input into the long short-term memory network, and for each input, a forget gate, an input gate and an output gate are calculated to update the hidden state and the cell state; After the long short-term memory network has processed the feature vectors of all neighboring nodes of the node, the final hidden state of the long short-term memory network is determined as the aggregated feature vector.
13. The regular acceleration method based on inductive learning according to claim 8, characterized in that: The aggregating the feature vectors of the neighboring nodes of the node to obtain an aggregated feature vector includes: Assign different weights to the feature vectors of each neighbor node of the node through the attention mechanism to obtain a weight matrix, and calculate the attention coefficient of the node to each neighbor node; The cumulative sum of the products of the attention coefficients, the weight matrices, and the feature vectors of each neighboring node of the node is calculated to obtain the aggregated feature vector.
14. The regular acceleration method based on inductive learning according to claim 1, characterized in that: The feature fusion is performed by the following steps: After the aggregation operation, an aggregate feature vector and a feature vector of a node are obtained; Perform feature fusion on the aggregated feature vector and the feature vector of the node.
15. The regular acceleration method based on inductive learning according to claim 14, characterized in that: The performing feature fusion on the aggregated feature vector and the feature vector of the node includes: A concatenation operation or an element-wise addition operation is performed on the aggregated feature vector and the feature vector of the node.
16. The regular acceleration method based on inductive learning according to claim 1, characterized in that: The clustering process is performed by the following steps: After the features are fused, a fused feature vector and a feature vector of a node are obtained; Based on the fused feature vector, the feature vector of the node is updated to obtain an embedding vector of the node; The embedding vector of each node is input into the initial clustering model for clustering processing to obtain a plurality of regular character clusters.
17. The regular acceleration method based on inductive learning according to claim 16, characterized in that: The embedding vector of each node is input into the initial clustering model for clustering processing to obtain multiple regular character clusters, including: The embedding vector of each node is input into the initial clustering model, and based on the distance between the embedding vector of each node and the cluster center, each node is respectively assigned to the nearest cluster class to obtain the multiple regular character clusters.
18. The regular acceleration method based on inductive learning according to claim 1, characterized in that: The comprehensive loss function includes the node classification loss, clustering loss, and the regularization term of the Laplace matrix.
19. A regular acceleration system based on inductive learning, characterized in that: include: A first local hardware device is used to obtain a data control flow and generate a non-deterministic finite automaton according to a regular expression, wherein the non-deterministic finite automaton is used to characterize the regular expression to analyze and filter the data control flow; a heterogeneous device, which is communicatively connected to the first local hardware device and is used to receive the data control flow and the non-deterministic finite automaton; A second local hardware device, which is communicatively connected to the first local hardware device, is used to perform inductive learning on an initial batch of the non-deterministic finite automata based on an initial graph convolutional neural network and an initial clustering model, calculate a comprehensive loss value based on the inductive learning result, and jointly train the initial graph convolutional neural network and the initial clustering model based on the comprehensive loss value to obtain a graph convolutional neural network and a clustering model; wherein the inductive learning includes undirected graph conversion, neighbor sampling, aggregation operation, feature fusion and clustering processing; and, based on the graph convolutional neural network and the clustering model, perform inductive reasoning on other batches of the non-deterministic finite automata, and when the non-deterministic finite automata are in a matching relationship with the regular expression represented by them, configure the non-deterministic finite automata to a corresponding regular engine, and perform parallel analysis and filtering on the data control flow; Wherein, the first local hardware device is specifically used for: For each unique character in the regular expression, counting the frequency of occurrence of the unique character in a plurality of regular expressions; normalizing the occurrence frequency; generating the non-deterministic finite automaton based on the normalized occurrence frequency of each of the unique characters; The second local hardware device is specifically used for: For each of the non-deterministic finite automata in the other batches, convert the non-deterministic finite automata into a non-deterministic finite automata undirected graph; Inputting the non-deterministic finite automaton undirected graph into the graph convolutional neural network; Performing neighbor sampling on the non-deterministic finite automaton undirected graph to obtain a local subgraph set; For each node in each local subgraph in the local subgraph set, performing an aggregation operation on the feature vectors of each neighboring node of the node to obtain an aggregated feature vector; Performing feature fusion on the aggregated feature vector and the feature vector of the node; Based on the fused feature vector, the feature vector of the node is updated to obtain an embedding vector of the node; The embedding vector of each node is input into the clustering model for clustering processing to obtain multiple regular character clusters.
20. An electronic device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the regularized acceleration method based on inductive learning as described in any one of claims 1 to 18 are implemented.
21. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the regularized acceleration method based on inductive learning as described in any one of claims 1 to 18 are implemented.
Citation Information
Patent Citations
Neural network structure search method and device, electronic equipment and storage medium
CN111612134A
Atlas embedding system and device
CN116848535A
Equipment clustering method, device, equipment, system and medium based on heterogeneous data
CN117806838A
Heterogeneous acceleration method and device based on end-to-end learning, equipment and storage medium
CN117971354A
Heterogeneous acceleration method and device based on semi-supervised learning, equipment and storage medium
CN117971356A
