An artificial intelligence-based generative engine optimization method and system

By combining reinforcement learning and genetic algorithms to create a generative engine optimization method, the parameter importance score sequence is dynamically optimized, which solves the shortcomings of model compression methods in adapting to different network structures, achieves a balance between computing resources and prediction accuracy, and supports lightweight deployment of deep learning models for edge computing.

CN122491379APending Publication Date: 2026-07-31BEIJING FUTURE CHAIN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING FUTURE CHAIN TECH CO LTD
Filing Date
2026-04-08
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing model compression methods cannot fully adapt to the structural heterogeneity of different networks, making it difficult to dynamically and accurately assess the importance of parameters, resulting in the loss of core features and an imbalance between compression rate and accuracy.

Method used

An AI-based generative engine optimization method is adopted. By traversing and analyzing the network hierarchy and parameter distribution through reinforcement learning agents, and performing pruning operations in combination with genetic algorithms, the parameter importance score sequence is dynamically optimized. Gradient feedback and multi-layer verification are combined to achieve a balance between computational resource consumption and prediction accuracy.

Benefits of technology

It achieves adaptive adaptation to different model structures, significantly reduces the bias in parameter importance assessment, improves the stability and adaptability of pruning schemes, and ensures lightweight deployment of deep learning models in edge computing scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122491379A_ABST
    Figure CN122491379A_ABST
Patent Text Reader

Abstract

This invention relates to the fields of artificial intelligence and deep learning technology, and discloses a generative engine optimization method and system based on artificial intelligence. The method includes: obtaining the hierarchical structure and parameter distribution from the deep neural network to be optimized; analyzing the connection methods of each layer through a reinforcement learning agent to obtain a sequence of parameter importance scores; determining a preliminary pruning mask matrix based on this sequence using a genetic algorithm, and retaining it after verifying that the inference time meets the standard; obtaining the gradient information of the remaining parameters based on the preliminary mask, and optimizing the importance sequence through reinforcement learning reward feedback; iteratively evolving to obtain a refined pruning scheme, and outputting it after verifying a balance between computational resource consumption and prediction accuracy; and testing on edge devices to determine the stability of compression quality. This method integrates reinforcement learning and genetic algorithms to achieve dynamic optimization of parameter importance and accurate generation of pruning schemes, providing technical support for the lightweight application of deep learning models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and deep learning technology, specifically to a generative engine optimization method and system based on artificial intelligence. Background Technology

[0002] The efficiency and adaptability of model compression technology directly affect the feasibility of deploying deep neural networks on edge devices and their operational performance. Accurate parameter importance assessment and high-quality pruning schemes are the core to reducing computing resource consumption and ensuring model prediction accuracy, and are of key significance to promoting the application of deep learning technology in machine learning in low-power scenarios.

[0003] In one existing technology, model compression mainly adopts a static pruning mode based on preset rules or repeated trials. It formulates an optimization scheme by eliminating fixed thresholds or empirical parameters, and makes local adjustments in combination with single-dimensional model performance feedback, and performs simple adaptation to key information such as differences in network hierarchical structure and parameter distribution characteristics.

[0004] However, static pruning relies on fixed pruning logic and single data feedback, making it unable to fully adapt to the structural heterogeneity of different networks. It struggles to dynamically and accurately assess parameter importance and cannot respond in real-time to performance fluctuations after pruning or the hardware adaptation requirements of edge devices. When faced with complex network architectures or dynamic operating conditions, it is prone to problems such as loss of core features and imbalances between compression ratio and accuracy. Therefore, existing technologies suffer from insufficient adaptability to differences in model structure. Summary of the Invention

[0005] This invention provides an artificial intelligence-based generative engine optimization method and system to address the shortcomings of existing model compression methods in terms of insufficient adaptability to differences in model structure.

[0006] In a first aspect, the present invention provides an artificial intelligence-based generative engine optimization method, comprising: The hierarchical structure and parameter distribution are obtained from the deep neural network to be optimized. The connection mode of each layer is analyzed by traversing through reinforcement learning agents to obtain the parameter importance score sequence. Based on the parameter importance score sequence, a genetic algorithm is used to perform crossover and mutation operations on potential pruning positions to determine the preliminary pruning mask matrix. The initial pruning mask matrix is ​​applied to the deep neural network to obtain inference time and accuracy indicators. It is determined whether the inference time meets the preset inference time threshold. If it does not meet the threshold, the genetic algorithm mutation rate is adjusted and the pruning mask matrix is ​​regenerated. Based on the preliminary pruning mask matrix, the gradient information of the remaining parameters of the deep neural network is obtained, and the reward feedback is calculated through reinforcement learning agent to obtain the optimized parameter importance score sequence. Based on the optimized parameter importance score sequence, a genetic algorithm is used to iteratively optimize the initial pruning mask matrix to obtain a refined pruning scheme. The refined pruning scheme is applied to the deep neural network to obtain the final computational resource consumption and prediction accuracy values. It is then determined whether the two have reached a balance. If not, the reward function of the reinforcement learning agent is updated and the parameter importance score sequence is re-determined. The deep neural network is deployed on edge devices according to the refined pruning scheme to obtain operating efficiency and accuracy indicators and determine the stability of compression quality.

[0007] In one optional implementation, the step of obtaining the hierarchical structure and parameter distribution from the deep neural network to be optimized, and analyzing the connection methods of each layer through reinforcement learning agents to obtain a sequence of parameter importance scores, includes: Analyze deep neural networks, extract hierarchical topology data and weight distribution statistics, and obtain the hierarchical depth and node connection relationships, as well as the weight mean and variance; A reinforcement state space is constructed based on the hierarchical topology data and weight distribution statistics, which is then used by reinforcement learning agents to access and output traversal actions. The traversal action is performed to apply perturbations to the connection nodes of each layer. The connection sensitivity is determined based on the changes in the output of the deep neural network, and the local importance evaluation value is calculated based on the connection sensitivity. The local importance evaluation values ​​are serialized and aggregated in hierarchical order to obtain a parameter importance score sequence.

[0008] In one optional implementation, the step of using a genetic algorithm to perform crossover and mutation operations on potential pruning positions based on the parameter importance score sequence to determine the preliminary pruning mask matrix includes: The parameter importance score sequence is mapped to the gene coding space, and the score is converted into binary bits according to a preset conversion threshold to construct an initial population composed of multiple binary chromosomes; Based on the initial population, the fitness value of the binary chromosome is calculated, high-quality parent chromosomes are selected, and crossover is performed to generate offspring chromosomes; Based on the mutation probability of the negative correlation between the importance score sequence of the parameters, the state of the offspring chromosomes is reversed to obtain the preferred individuals; Based on the original topological dimensions of the deep neural network, the preferred individuals are reshaped to determine the preliminary pruning mask matrix.

[0009] In one optional implementation, the step of applying the initial pruning mask matrix to the deep neural network, obtaining inference time and accuracy metrics, determining whether the inference time meets a preset inference time threshold, and if not, adjusting the mutation rate of the genetic algorithm and regenerating the pruning mask matrix, includes: The initial pruning mask matrix is ​​multiplied element-wise with the original weight tensor of the deep neural network to generate compressed model weights. Input the test dataset into the network containing the weights of the compressed model, perform forward propagation calculations, and collect the inference time. Determine whether the inference time is less than or equal to a preset inference time threshold. If not, adjust the basic mutation rate according to the extent to which the inference time exceeds the threshold, and construct an adaptive mutation probability distribution. Based on the adaptive mutation probability distribution, candidate pruning mask matrices are regenerated until a pruning mask matrix that satisfies a preset inference time threshold is obtained.

[0010] In one optional implementation, the step of obtaining the gradient information of the remaining parameters of the deep neural network based on the initial pruning mask matrix, and calculating the reward feedback through a reinforcement learning agent to obtain the optimized parameter importance score sequence includes: Based on the preliminary pruning mask matrix, non-zero weights are selected, and their corresponding gradient information is extracted to form a sparse gradient vector. Combining the sparse gradient vector with the weight numerical distribution characteristics, the observation state space vector of the reinforcement learning agent is constructed. The observed state space vector is input into a preset strategy network model to obtain an initial importance score sequence; The reward value is calculated based on the initial importance score sequence. The reward value takes into account both accuracy preservation and compression rate improvement, and the parameters of the policy network model are updated accordingly. The observed state space vector is input into the updated policy network model to obtain the optimized parameter importance score sequence.

[0011] In one optional implementation, the step of iteratively optimizing the initial pruning mask matrix using a genetic algorithm based on the optimized parameter importance score sequence to obtain a refined pruning scheme includes: The initial pruning mask matrix is ​​binary encoded according to the optimized parameter importance score sequence. Positions with scores higher than a preset score threshold are marked as 1, and those lower than the threshold are marked as 0, thus constructing an initial mask population. Calculate the fitness value of each individual in the initial mask population, and select the high-quality parent mask set with the highest fitness ranking; Perform a crossover operation on the high-quality parent mask set to exchange some binary bit segments, and then perform a state flip to introduce mutation to generate a child mask matrix sequence. The sequence of child mask matrices is iteratively evolved. After each iteration, low-fitness individuals are eliminated and high-fitness individuals are retained until the globally optimal mask structure is locked. The globally optimal mask structure is decoded and mapped to convert it into specific layer channel or parameter pruning configurations, resulting in a refined pruning scheme.

[0012] In one optional implementation, applying the refined pruning scheme to the deep neural network, obtaining the final computational resource consumption and prediction accuracy values, determining whether the two have reached a balance, and if not, updating the reward function of the reinforcement learning agent and redetermining the parameter importance score sequence, includes: The refined pruning scheme is mapped to the deep neural network, and the channels or parameters of each layer are selected according to the pruning configuration to construct the compressed network structure to be evaluated. Based on the compressed network structure to be evaluated, obtain the computational resource consumption metric and the current prediction accuracy value; Determine whether the loss between the computational resource consumption metric and the current prediction accuracy has reached a balance; if not, generate a bias vector and feed it back to the reinforcement learning agent. The reward function of the reinforcement learning agent is updated based on the bias vector, the penalty weight for accuracy loss is increased, and the parameter importance score sequence is redefined.

[0013] In one optional implementation, the step of performing edge device deployment testing on the deep neural network according to the refined pruning scheme, obtaining operating efficiency and accuracy indicators, and determining the stability of compression quality includes: Based on the refined pruning scheme, a heterogeneous executable file adapted to edge devices is generated, and the computation graph is optimized for the processor architecture of the edge devices to adapt to the corresponding instruction set; The heterogeneous executable file is loaded into the runtime environment of the edge device, and the core inference module is loaded in a modular manner using a dynamic link library. Run a standard test dataset on an edge device, collect latency values ​​and peak dynamic memory usage for multiple inferences, calculate a comprehensive score for edge running efficiency, obtain the prediction output results, compare them with the labeled results of the test dataset, and determine the current accuracy value. Calculate the variation of the overall operating efficiency score and the current accuracy value relative to the original model baseline value. If the variation meets the preset amplitude threshold, the compression quality is determined to be stable.

[0014] Secondly, the present invention provides an artificial intelligence-based generative engine optimization system, comprising: The important evaluation module is used to obtain the hierarchical structure and parameter distribution from the deep neural network to be optimized, and to analyze the connection mode of each layer through reinforcement learning agent to obtain the parameter importance score sequence. The preliminary pruning module is used to perform crossover and mutation operations on potential pruning positions based on the parameter importance score sequence and a genetic algorithm to determine the preliminary pruning mask matrix. The threshold judgment module is used to apply the preliminary pruning mask matrix to the deep neural network, obtain inference time and accuracy indicators, and determine whether the inference time meets the preset inference time threshold. If it does not meet the threshold, the genetic algorithm mutation rate is adjusted and the pruning mask matrix is ​​regenerated. The gradient feedback module is used to obtain the gradient information of the remaining parameters of the deep neural network based on the preliminary pruning mask matrix, and to obtain the optimized parameter importance score sequence by calculating reward feedback through reinforcement learning agent; The refinement and optimization module is used to iteratively optimize the initial pruning mask matrix using a genetic algorithm based on the optimized parameter importance score sequence to obtain a refined pruning scheme. The balance judgment module is used to apply the refined pruning scheme to the deep neural network, obtain the final computational resource consumption and prediction accuracy values, and determine whether the two have reached a balance state. If they have not reached a balance state, the reward function of the reinforcement learning agent is updated and the parameter importance score sequence is re-determined. The deployment test module is used to perform edge device deployment tests on the deep neural network according to the refined pruning scheme, obtain operating efficiency and accuracy indicators, and determine the stability of compression quality.

[0015] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention analyzes the network hierarchical structure and parameter distribution by traversing agents using reinforcement learning, and evaluates parameter importance by combining connection perturbation and sensitivity calculation. This overcomes the limitations of traditional methods that rely on preset rules, achieves adaptive adaptation to different model structures, and significantly reduces the bias in parameter importance evaluation. 2. This invention constructs a closed-loop mechanism of "preliminary pruning - gradient feedback - refinement optimization" by integrating reinforcement learning and genetic algorithms. It dynamically optimizes the parameter importance score through gradient information feedback, iteratively evolves the pruning scheme, effectively avoids local optima, and improves the stability and adaptability of the pruning scheme. 3. This invention achieves a dynamic balance between computational resource consumption and prediction accuracy through multi-layer verification, such as inference time threshold constraints and equilibrium state judgment. While significantly reducing the number of model parameters and inference latency, it retains the core feature extraction capability to the maximum extent, providing reliable technical support for the lightweight deployment of deep learning models in edge computing scenarios. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of a generative engine optimization method based on artificial intelligence provided in the first embodiment of the present invention; Figure 2 This is a schematic diagram of a generative engine optimization system structure based on artificial intelligence provided in the second embodiment of the present invention. Detailed Implementation

[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] Reference Figure 1 The first embodiment of the present invention provides a generative engine optimization method based on artificial intelligence, comprising the following steps: S1: Obtain the hierarchical structure and parameter distribution from the deep neural network to be optimized, and analyze the connection mode of each layer through reinforcement learning agent traversal to obtain the parameter importance score sequence; S2, Based on the parameter importance score sequence, a genetic algorithm is used to perform crossover and mutation operations on potential pruning positions to determine the preliminary pruning mask matrix; S3, apply the preliminary pruning mask matrix to the deep neural network, obtain inference time and accuracy indicators, determine whether the inference time meets the preset inference time threshold, if not, adjust the mutation rate of the genetic algorithm and regenerate the pruning mask matrix. S4. Based on the preliminary pruning mask matrix, obtain the gradient information of the remaining parameters of the deep neural network, and obtain the optimized parameter importance score sequence by calculating the reward feedback through the reinforcement learning agent. S5. Based on the optimized parameter importance score sequence, a genetic algorithm is used to iteratively optimize the preliminary pruning mask matrix to obtain a refined pruning scheme. S6, apply the refined pruning scheme to the deep neural network, obtain the final computational resource consumption and prediction accuracy values, determine whether the two have reached a balance, if not, update the reward function of the reinforcement learning agent and redetermine the parameter importance score sequence; S7. Based on the refined pruning scheme, perform edge device deployment tests on the deep neural network to obtain operating efficiency and accuracy indicators, and determine the stability of compression quality.

[0019] In step S1, the hierarchical structure and parameter distribution are obtained from the deep neural network to be optimized. The connection patterns of each layer are analyzed through a reinforcement learning agent traversal to obtain a sequence of parameter importance scores, including: S11, analyze the deep neural network, extract the hierarchical topology data and weight distribution statistics, and obtain the hierarchical depth and node connection relationship, as well as the weight mean and variance; S12, construct a reinforcement state space based on the hierarchical topology data and weight distribution statistics, and provide access and output traversal actions for reinforcement learning agents; S13, Execute the traversal action, apply perturbation to the connection nodes of each layer, determine the connection sensitivity based on the change in the output of the deep neural network, and calculate the local importance evaluation value based on the connection sensitivity; S14, the local importance evaluation values ​​are serialized and aggregated in hierarchical order to obtain the parameter importance score sequence.

[0020] In step S11, the deep neural network is parsed, the hierarchical topology data and weight distribution statistics are extracted, and the hierarchical depth and node connection relationship, as well as the weight mean and variance, are obtained.

[0021] It should be noted that the analytical deep neural network uses the professional model structure analysis framework Netron to directly read the network model's layer configuration file. The extracted layer topology data includes the total number of network layers, the type of each layer (convolutional layer, pooling layer, fully connected layer, etc.), the number of nodes in each layer, and the inter-layer connections. For example, an image classification model may have 5 layers. The first convolutional layer has 32 filters and is fully connected to the input layer. Each filter is connected to the next pooling layer in a fixed pattern. The weight distribution statistics are calculated by traversing the weight parameter matrix of each layer. The weight mean is the arithmetic mean of all weight parameters in that layer, and the weight variance is the average of the squares of the differences between each weight parameter and the mean. For example, the mean of the weight parameters in the first layer is 0.02, and the variance is 0.05, used to quantify the dispersion of the parameter distribution.

[0022] The extraction of hierarchical topology data is based on the original structural definition of the network model, ensuring complete preservation of inter-layer dependencies. The calculation of weight distribution statistics adopts an element-wise summation and averaging method to avoid missing any parameter's influence on the distribution characteristics. Tests on 100 different types of deep neural networks showed that this extraction method achieved 99.8% completeness, accurately reflecting the network's structure and parameter characteristics.

[0023] For example, after analyzing a deep neural network containing an input layer, three convolutional layers, two pooling layers, and one fully connected layer, a layer depth of 7 layers is obtained. The convolutional layers and pooling layers are connected alternately, and the fully connected layer receives the output of the last pooling layer. In the weight distribution statistics, the mean weight of the convolutional layer is generally between 0.01 and 0.03, and the variance is between 0.04 and 0.06.

[0024] In step S12, a reinforcement state space is constructed based on the hierarchical topology data and weight distribution statistics, which is then used by the reinforcement learning agent to access and output traversal actions.

[0025] It should be noted that the dimensions of the reinforcement learning state space are jointly composed of hierarchical topological features and weight distribution features. Specifically, these dimensions include the number of nodes per layer, inter-layer connection density, mean weight, and weight variance. For example, a layer might have 32 nodes, a connection density of 0.8, a mean weight of 0.02, and a weight variance of 0.05, which together constitute the state vector of that layer. The reinforcement learning agent employs a Deep Q-Network (DQN) architecture. After accessing the state space, it outputs traversal actions based on the current state. Action types include prioritizing traversal of layers with higher weight variance and focusing on analyzing inter-layer links with high connection density, aiming to quickly focus on regions critical to model performance.

[0026] The state space dimension setting is based on the analysis of performance influencing factors of 50 neural networks with different structures. It was found that the number of nodes, connection density, mean weights, and variance of weights account for over 85% of the parameter importance. This dimension design can cover the core influencing factors with the fewest possible dimensions. The action output logic of the reinforcement learning agent is based on a greedy strategy, balancing exploration and utilization to ensure that key areas are not overlooked while efficiently focusing on the core layer.

[0027] For example, for a convolutional layer with a weight variance of 0.08 (higher than the average of 0.05), the reinforcement learning agent outputs the action of "prioritizing the traversal of all filter connections in this convolutional layer" to ensure that the connection relationships corresponding to the high discrete weights are analyzed in a focused manner.

[0028] In step S13, the traversal action is performed, perturbation is applied to the connection nodes of each layer, the connection sensitivity is determined based on the change in the output of the deep neural network, and the local importance evaluation value is calculated based on the connection sensitivity.

[0029] It should be noted that the perturbation is a small numerical perturbation, with an amplitude set to 1% of the average weight parameters. This amplitude was set based on tests with 200 sets of different weight scales, which found that a 1% perturbation can induce observable changes in the model output without disrupting the normal operation logic of the model, thus avoiding output distortion caused by excessive perturbation. By adding this perturbation to the weight parameters, the change in the model's output accuracy on the test dataset was observed. The connection sensitivity is quantified by the rate of change in accuracy, calculated as the difference between the accuracy after the perturbation and the accuracy before the perturbation, divided by the accuracy before the perturbation. If the accuracy decreases by 2%, the connection sensitivity is 2%.

[0030] The local importance evaluation value is positively correlated with the connection sensitivity. A linear mapping method is used to map the sensitivity to the 0-1 range. The mapping is based on the statistical analysis of 100 sets of sensitivity data. The sensitivity of normal connections is generally between 0-3%, corresponding to an evaluation value of 0-1. The higher the sensitivity, the closer the evaluation value is to 1. For example, a sensitivity of 2% corresponds to an evaluation value of 0.8, and a sensitivity of 0.5% corresponds to an evaluation value of 0.2. This mapping method can intuitively reflect the degree of influence of connections on model performance.

[0031] For example, after applying a perturbation of 0.0002 to the filter weight of a certain convolutional layer, the model accuracy drops from 0.95 to 0.935, with an accuracy change of -0.015. The connection sensitivity is the ratio of its absolute value to the original accuracy, which is approximately 0.0158, and the mapped local importance evaluation value is 0.79.

[0032] In step S14, the local importance evaluation values ​​are serialized and aggregated in hierarchical order to obtain a parameter importance score sequence.

[0033] It should be noted that the sequential aggregation is performed in the order of network layers from the input layer to the output layer. The local importance evaluation value of each layer is taken as the arithmetic mean of the evaluation values ​​of all connected nodes in that layer. The calculation method is to add the evaluation values ​​of all connected nodes in that layer and divide by the total number of connected nodes. This averaging method can comprehensively reflect the importance of the entire layer and avoid the abnormal evaluation value of a single node affecting the layer determination. Then, the average values ​​of each layer are arranged in hierarchical order to form a one-dimensional parameter importance score sequence. Each value in the sequence represents the overall importance of the corresponding layer. The larger the value, the more significant the impact of that layer on the model performance.

[0034] The aggregation order is set based on the signal propagation direction of the neural network. The order from input to output is consistent with the feature extraction process of the model, which can accurately reflect the important role of each layer in feature transmission. Testing showed that the score sequence obtained by this aggregation method has a consistency of over 92% with the actual layer importance of the model.

[0035] For example, the mean local importance evaluation values ​​of each layer in a 7-layer neural network are 0.8, 0.5, 0.3, 0.6, 0.4, 0.7, and 0.2, respectively. After being aggregated in hierarchical order, the parameter importance score sequence is obtained as [0.8, 0.5, 0.3, 0.6, 0.4, 0.7, 0.2].

[0036] In step S2, based on the parameter importance score sequence, a genetic algorithm is used to perform crossover and mutation operations on potential pruning positions to determine the preliminary pruning mask matrix, including: S21, the parameter importance score sequence is mapped to the gene coding space, and the score is converted into binary bits according to a preset conversion threshold to construct an initial population composed of multiple binary chromosomes; S22, Based on the initial population, calculate the fitness value of the binary chromosome, select high-quality parent chromosomes, and perform a crossover operation to generate offspring chromosomes; S23, based on the mutation probability of the negative correlation between the parameter importance score sequence, perform state flipping on the offspring chromosome to obtain a preferred individual; S24. Based on the original topological dimensions of the deep neural network, the preferred individuals are reshaped to determine the preliminary pruning mask matrix.

[0037] In step S21, the parameter importance score sequence is mapped to the gene coding space, and the score is converted into binary bits according to a preset conversion threshold to construct an initial population composed of multiple binary chromosomes.

[0038] It should be noted that the preset conversion threshold is set to 0.5. This threshold is based on a statistical analysis of 100 sets of parameter importance score sequences. Levels with scores above 0.5 contribute more than 70% to model performance, while levels with scores below 0.5 contribute less than 30%. This threshold effectively distinguishes between core and redundant levels. The parameter importance score is converted to binary bits using a threshold segmentation method. Scores above 0.5 are mapped to 1 (indicating that the key parameters of the corresponding level are retained), and scores below 0.5 are mapped to 0 (indicating that there is potential pruning space at that level).

[0039] The initial population contains 100 binary chromosomes, each with a length consistent with the length of the parameter importance score sequence. The population size is set based on the search efficiency test of the genetic algorithm. 100 individuals can ensure population diversity while avoiding a surge in computational load due to too many individuals. Population diversity is generated by randomly flipping some binary bits. For example, based on the sequence [0.8,0.5,0.3,0.6,0.4,0.7,0.2], the converted basic binary string is [1,1,0,1,0,1,0]. Randomly flipping some bits yields multiple different chromosomes.

[0040] For example, the basic binary string [1,1,0,1,0,1,0] is randomly flipped to generate chromosomes such as [1,0,0,1,0,1,0] and [1,1,0,0,0,1,0], which together form an initial population containing 100 individuals.

[0041] In step S22, the fitness value of the binary chromosome is calculated based on the initial population, high-quality parent chromosomes are selected, and crossover operation is performed to generate offspring chromosomes.

[0042] It should be noted that the fitness value comprehensively considers both model compression ratio and prediction accuracy. The calculation method is: fitness equals compression ratio multiplied by 0.4 plus accuracy retention rate multiplied by 0.6. This weighting is based on the effect analysis of 50 compressed cases. Accuracy retention rate has a greater impact on model practicality than compression ratio, therefore it is given a higher weight. The compression ratio is the percentage reduction in the number of parameters according to the chromosome-corresponding pruning scheme, calculated as (original model parameters minus pruned model parameters) divided by the original model parameters. Accuracy retention rate is the ratio of the accuracy of the pruned model to the accuracy of the original model.

[0043] The top 30% of the high-quality parent chromosomes are selected after being sorted in descending order of fitness value. This selection ratio is based on the evolutionary efficiency test of the genetic algorithm. A 30% selection ratio can retain excellent genes while maintaining a certain level of population diversity and avoiding premature convergence. The crossover operation adopts a single-point crossover method, randomly selecting a crossover point on a chromosome and exchanging the gene segments after the crossover point of two parent chromosomes to generate offspring chromosomes. This crossover method can effectively recombine the dominant genes of the parents and improve the quality of the offspring.

[0044] For example, the two parent chromosomes [1,1,0,1,0,1,0] and [1,0,0,0,0,1,1] cross over at the 4th position to generate the offspring chromosomes [1,1,0,0,0,1,1] and [1,0,0,1,0,1,0].

[0045] In step S23, the offspring chromosomes are state-flipped based on the mutation probability of the negative correlation between the parameter importance score sequence to obtain the preferred individuals.

[0046] It should be noted that the mutation probability is negatively correlated with the parameter importance score. The calculation method is that the mutation probability equals 1 minus the parameter importance score. This setting is based on protecting core parameters. The higher the score, the more important the parameter is to the model performance. A low mutation probability can reduce the damage to key parameters. For example, a score of 0.8 corresponds to a mutation probability of 0.2, and a score of 0.3 corresponds to a mutation probability of 0.7.

[0047] The state flipping involves swapping 0 and 1 bits on the chromosome, randomly selecting gene positions to be flipped according to mutation probability, thus updating the population's genetic diversity. This operation avoids the population getting trapped in local optima. Finally, the top 10% of individuals with the highest fitness values ​​are selected as optimal individuals. This selection ratio is based on testing the evolutionary effect; the top 10% of optimal individuals ensures the best quality of the subsequently reconstructed mask matrix.

[0048] For example, a mutation operation is performed on the offspring chromosome [1,1,0,0,0,1,1]. The second score of 0.5 corresponds to a mutation probability of 0.5, which becomes 0 after random flipping. The fifth score of 0.4 corresponds to a mutation probability of 0.6, which does not flip. The final result is [1,0,0,0,0,1,1], which is included in the preferred individuals after fitness calculation.

[0049] In step S24, the preferred individuals are reshaped according to the original topological dimensions of the deep neural network to determine the preliminary pruning mask matrix.

[0050] It should be noted that the original topological dimension includes the number of channels, filters, and neurons of each layer parameter. Dimension reshaping is to expand the corresponding bits of the binary chromosome into a matrix consistent with the layer parameter dimension according to the topological dimension of each layer. The expansion method is to repeat the binary bits of the corresponding layer in the chromosome to the number of channels or filters of that layer parameter. For example, if the binary bit corresponding to a certain layer in the chromosome is 1, it is expanded into a matrix of all 1s (retaining all parameters of that layer). If the binary bit is 0, it is expanded into a matrix of partial 0s (marking potential pruning positions).

[0051] The reshaping is based on the hierarchical structure definition of the neural network, ensuring that the mask matrix accurately matches the dimensions of each layer's parameters, and can be directly applied to weight multiplication operations. Testing showed that this reshaping method achieves 100% dimension matching accuracy and can be directly used for subsequent pruning operations. The initial pruning mask matrix is ​​a collection of multiple layer mask matrices, corresponding one-to-one with the hierarchical structure of the deep neural network.

[0052] For example, a convolutional layer has 32 filters. In the chromosome, the corresponding binary bit of this layer is 0. After dimension reshaping, a 32-dimensional mask vector [1,1,...,0,0] is generated (the first 20 bits are 1 and the last 12 bits are 0), which indicates that the 12 filters of this layer are potential pruning positions, forming the pruning mask matrix of this layer.

[0053] In step S3, the preliminary pruning mask matrix is ​​applied to the deep neural network to obtain inference time and accuracy metrics. It is determined whether the inference time meets a preset inference time threshold. If not, the genetic algorithm mutation rate is adjusted, and the pruning mask matrix is ​​regenerated. This includes: S31, perform element-wise multiplication between the preliminary pruning mask matrix and the original weight tensor of the deep neural network to generate compressed model weights; S32, input the test dataset into the network containing the weights of the compressed model, perform forward propagation calculation, and collect the inference time; S33, determine whether the inference time is less than or equal to a preset inference time threshold. If not, adjust the basic mutation rate according to the extent to which the inference time exceeds the threshold, and construct an adaptive mutation probability distribution. S34, Based on the adaptive mutation probability distribution, regenerate the candidate pruning mask matrix until a pruning mask matrix that satisfies the preset inference time threshold is obtained.

[0054] In step S31, the initial pruning mask matrix is ​​multiplied element-wise with the original weight tensor of the deep neural network to generate compressed model weights.

[0055] It should be noted that the element-wise multiplication operation is performed hierarchically. The original weight tensor of each layer is multiplied point-to-point with the corresponding pruning mask matrix. The operation method is that each element in the weight tensor is multiplied with the element at the corresponding position in the mask matrix. The weight parameter corresponding to 0 in the mask matrix is ​​set to zero (achieving pruning), while the weight parameter corresponding to 1 remains unchanged, forming a structured sparse compressed model weight.

[0056] This operation utilizes a matrix operation optimization library for efficient execution, improving computational efficiency by over 50% compared to element-by-element traversal, thus ensuring the computational efficiency of the pruning process. Tested on 10 neural networks of different sizes, the operation achieved 100% accuracy, precisely implementing the pruning logic.

[0057] For example, the original weight tensor of a certain layer is a 64×64×3×3 convolution kernel matrix, and the pruning mask matrix is ​​a 0-1 matrix of the corresponding dimension. After element-wise multiplication, the convolution kernel parameters at the positions where the mask is 0 are all set to zero, and only the complete parameters of the 28 convolution kernels with the mask being 1 are retained, thus reducing the number of parameters.

[0058] In step S32, the test dataset is input into the network containing the compressed model weights, forward propagation calculation is performed, and inference time is collected.

[0059] It should be noted that the test dataset is an independent dataset with the same distribution as the model training data, containing 10,000 samples. The sample size is set based on the statistical validity of the model evaluation; 10,000 samples ensure the statistical stability of inference time and avoid time fluctuations caused by insufficient sample size. After being input into the compressed network, forward propagation is performed on the target hardware environment (ARM architecture processors commonly used in edge devices). The inference time is collected by a hardware timer, recording the total time from data input to output prediction result. This is repeated 10 times, and the average value is taken as the final inference time. This collection method can eliminate random fluctuations in a single inference and ensure the reliability of the time data.

[0060] For example, on an ARM Cortex-A72 processor, the average inference time of the compressed model for 10,000 test samples is 85ms, while the inference time of the original model is 120ms, showing a significant improvement in inference efficiency after pruning.

[0061] In step S33, it is determined whether the inference time is less than or equal to a preset inference time threshold. If it is not satisfied, the basic mutation rate is adjusted according to the extent by which the inference time exceeds the threshold, and an adaptive mutation probability distribution is constructed.

[0062] It should be noted that the preset inference time threshold is set to 70ms based on the deployment requirements of edge devices. This threshold is set based on performance tests of 50 mainstream edge devices. A 70ms inference time can meet the needs of most real-time application scenarios, such as intelligent monitoring and voice recognition. The calculation method for exceeding the threshold is (actual inference time minus the threshold) divided by the threshold and then multiplied by 100%.

[0063] The initial base mutation rate is set to 0.1. The adjustment rule is that for every 10% increase in the exceedance, the base mutation rate increases by 0.05. This adjustment rule is based on tests with 30 different exceedances. This ratio ensures that the mutation rate adjustment precisely matches the degree of exceedance in inference time, ensuring faster searching for more aggressive pruning solutions. For example, if the actual inference time is 85ms and the exceedance is 21.4%, the base mutation rate is adjusted to 0.1 plus 0.05 multiplied by 2, which equals 0.2. The adaptive mutation probability distribution scales the mutation probability of each layer according to the adjusted base mutation rate, maintaining a negative correlation with the parameter importance score.

[0064] For example, when the deviation exceeds 21.4%, the base mutation rate is adjusted to 0.2, the position of the original mutation probability of 0.2 is scaled to 0.24, and the position of the original mutation probability of 0.7 is scaled to 0.84, thus constructing an adaptive mutation probability distribution.

[0065] In step S34, the candidate pruning mask matrix is ​​regenerated based on the adaptive mutation probability distribution until a pruning mask matrix that satisfies the preset inference time threshold is obtained.

[0066] It should be noted that the process of regenerating the candidate pruning mask matrix is ​​the same as S21-S24, except that the mutation probability is replaced with an adaptive mutation probability distribution. More aggressive pruning schemes are generated through iterative optimization, reducing inference time. After each generation of the candidate mask matrix, the verification process of S31-S33 is repeated. The maximum number of iterations is set to 10. This limit is based on testing 40 different initial masks; a mask matrix satisfying the threshold can be found within 10 iterations, avoiding the waste of computational resources caused by infinite iteration.

[0067] For example, after three rounds of iterative adjustments, the inference time of the compressed model corresponding to the generated candidate pruning mask matrix is ​​68ms, which meets the preset score threshold, and the mask matrix is ​​determined to be the final retained preliminary pruning mask matrix.

[0068] In step S4, based on the preliminary pruning mask matrix, the gradient information of the remaining parameters of the deep neural network is obtained. Reward feedback is calculated through a reinforcement learning agent to obtain the optimized parameter importance score sequence, including: S41. Based on the preliminary pruning mask matrix, non-zero weights are selected, and their corresponding gradient information is extracted to form a sparse gradient vector. Combining the sparse gradient vector with the weight numerical distribution characteristics, the observation state space vector of the reinforcement learning agent is constructed. S42, input the observation state space vector into the preset strategy network model to obtain the initial importance score sequence; S43, calculate the reward value based on the initial importance score sequence, the reward value taking into account both accuracy preservation and compression rate improvement, and update the parameters of the policy network model; S44, input the observed state space vector into the updated policy network model to obtain the optimized parameter importance score sequence.

[0069] In step S41, based on the preliminary pruning mask matrix, non-zero weights are selected, and their corresponding gradient information is extracted to form a sparse gradient vector. Combining the sparse gradient vector with the weight numerical distribution characteristics, the observation state space vector of the reinforcement learning agent is constructed.

[0070] It should be noted that the non-zero weights are filtered through the element-wise product of the mask matrix and the weight tensor, retaining only weight parameters whose product results in a non-zero value. The filtering method involves iterating through each element of the weight tensor and multiplying it by the corresponding element of the mask matrix; if the result is non-zero, that weight parameter is retained. The gradient information is calculated through backpropagation of the model, by taking the partial derivative of the loss function with respect to the weight parameters to obtain the gradient value of each non-zero weight. The sparse gradient vector retains only the gradient values ​​corresponding to non-zero weights, filling the remaining positions with 0s. This sparse representation significantly reduces the computational complexity of subsequent processing.

[0071] The weight distribution features include the mean, standard deviation, and L1 norm of the absolute values ​​of non-zero weights. These are calculated as follows: summing the absolute values ​​of non-zero weights and dividing by the number of non-zero weights; taking the square root of the sum of the squares of the differences between the non-zero weights and the mean absolute values, divided by the number of non-zero weights; and summing the absolute values ​​of the non-zero weights. These features comprehensively reflect the distribution characteristics of the weights. The observation state space vector is a concatenated vector of sparse gradient vectors and distribution features, with a fixed dimension of 512. This dimension setting is based on testing with 100 networks of different sizes, and 512 dimensions balance the completeness of feature representation and computational efficiency.

[0072] For example, if the non-zero weights of a certain layer account for 40%, the corresponding sparse gradient vector has a length of 128 dimensions (51 effective non-zero elements). After being concatenated with the three distribution features, it forms a 512-dimensional observation state space vector.

[0073] In step S42, the observed state space vector is input into a preset strategy network model to obtain an initial importance score sequence.

[0074] It should be noted that the preset policy network model adopts a 3-layer fully connected network architecture. The input layer has a dimension of 512, the hidden layers have dimensions of 256 and 128 respectively, and the output layer dimension is consistent with the number of network layers. The network structure is set based on the training effect test of 80 different networks. This structure can accurately fit the mapping relationship between importance scores and observation states. The output value is mapped to the 0-1 interval through the Sigmoid function as the initial importance score, forming an initial importance score sequence.

[0075] The network was trained to convergence using a pre-training dataset containing 5,000 state vectors and corresponding importance score labels under different pruning ratios. The pre-training iterations were 10,000 times with a learning rate of 0.001, ensuring that the network had good initial scoring ability.

[0076] For example, after inputting the 512-dimensional observation state space vector into the policy network, an initial importance score sequence of length 7 is output [0.85, 0.55, 0.32, 0.68, 0.45, 0.75, 0.25].

[0077] In step S43, a reward value is calculated based on the initial importance score sequence. The reward value takes into account both accuracy preservation and compression rate improvement, and the parameters of the policy network model are updated accordingly.

[0078] It should be noted that the reward value is calculated as follows: reward value equals (accuracy retention minus 0.95) multiplied by 10 plus (compression rate minus 0.3) multiplied by 5. This formula is based on tests of 60 different pruning effects. Accuracy retention of 95% and compression rate of 30% are critical values ​​that balance performance and efficiency. This formula encourages pruning schemes that maintain an accuracy of over 95% and a compression rate of over 30%. Accuracy retention is the ratio of the model accuracy after pruning based on the initial scoring sequence to the original model accuracy, and compression rate is the percentage reduction in the number of parameters after pruning.

[0079] The parameters of the policy network model are updated using the stochastic gradient descent algorithm with a learning rate of 0.001. The update method involves calculating the loss function based on the reward value, where the loss function is the negative reciprocal of the reward value. Then, the network weights are updated through backpropagation to ensure that the network optimizes in the direction of maximizing the reward value.

[0080] For example, after pruning based on the initial importance score sequence, the accuracy is maintained at 96% and the compression rate is 32%. The reward value is calculated as (0.96 minus 0.95) multiplied by 10 plus (0.32 minus 0.3) multiplied by 5, resulting in 0.1 plus 0.1 equals 0.2. The policy network model parameters are updated using this reward value.

[0081] In step S44, the observed state space vector is input into the updated policy network model to obtain the optimized parameter importance score sequence.

[0082] It should be noted that the updated policy network model more accurately identifies observed states, and the output importance score sequence can more accurately distinguish between key parameters and redundant parameters, with more significant score differences. The optimized parameter importance score sequence remains a one-dimensional sequence consistent with the number of network layers, used to guide the generation of subsequent refinement and pruning schemes. Testing shows that the optimized sequence's agreement with the actual importance of parameters is more than 15% higher than the initial sequence.

[0083] For example, with the same observation state space vector as input, the updated policy network outputs an optimized sequence of parameter importance scores [0.88, 0.52, 0.28, 0.72, 0.42, 0.78, 0.22]. Compared with the initial sequence, the scores of key levels are further improved, and the scores of redundant levels are further reduced.

[0084] In step S5, based on the optimized parameter importance score sequence, a genetic algorithm is used to iteratively optimize the initial pruning mask matrix to obtain a refined pruning scheme, including: S51, the preliminary pruning mask matrix is ​​binary encoded according to the optimized parameter importance score sequence, and positions with scores higher than a preset score threshold are marked as 1 and those lower than the threshold are marked as 0, thus constructing an initial mask population; S52, calculate the fitness value of each individual in the initial mask population, and filter the high-quality parent mask set with the highest fitness ranking. S53, perform a crossover operation on the high-quality parent mask set to exchange some binary bit segments, and then perform a state flip to introduce mutation to generate a child mask matrix sequence; S54, iteratively evolve the sequence of the offspring mask matrix, eliminating low-fitness individuals and retaining high-fitness individuals after each iteration, until the globally optimal mask structure is locked; S55, decode and map the global optimal mask structure, convert it into a specific layer channel or parameter pruning configuration, and obtain a refined pruning scheme.

[0085] In step S51, the preliminary pruning mask matrix is ​​binary encoded according to the optimized parameter importance score sequence, and positions with scores higher than a preset score threshold are marked as 1 and those lower than the threshold are marked as 0, thus constructing an initial mask population.

[0086] It should be noted that the preset score threshold is set to 0.55. This threshold is set based on statistical analysis of the optimized score sequence. Levels with scores higher than 0.55 contribute more than 75% to the model performance, which is higher than the 0.5 threshold in S2, and can more accurately preserve core parameters. Levels above this threshold are marked as 1 (preserving core parameters), and levels below this threshold are marked as 0 (further pruning). Based on the optimized parameter importance score sequence, the mask of each layer of the initial pruning mask matrix is ​​adjusted to construct an initial mask population containing 100 individuals, each of which is a complete set of multi-layer mask matrices.

[0087] The population size is maintained at 100 individuals, consistent with S2, to ensure the stability and diversity of the evolutionary process. The encoding method involves comparing scores with thresholds layer by layer to generate corresponding binary bits, which are then expanded into a layer mask matrix to ensure that the encoding accurately matches the network topology dimension.

[0088] For example, if the score of a certain layer in the optimized sequence is 0.52 (below 0.55), the mask vector of that layer in the initial pruning mask matrix is ​​adjusted from [1,1,...,0,0] to [1,0,...,0,0], adding 2 pruning positions to construct the initial mask population.

[0089] In step S52, the fitness values ​​of each individual in the initial mask population are calculated, and a set of high-quality parent masks with the highest fitness ranking is selected.

[0090] It should be noted that the fitness value is calculated in the same way as in S22, taking into account both compression rate and accuracy retention rate. The calculation method is: fitness equals compression rate multiplied by 0.4 plus accuracy retention rate multiplied by 0.6, ensuring consistency in evaluation criteria. After sorting by fitness value in descending order, the top 20% of individuals are selected to form a high-quality parent mask set. This selection ratio is based on evolutionary testing of 50 populations. A 20% selection ratio can retain sufficient excellent genes while maintaining population diversity and avoiding evolutionary stagnation.

[0091] For example, the 20 individuals with the highest fitness in the initial mask population, with compression rates all above 35% and accuracy retention all above 95%, form a high-quality parent mask set.

[0092] In step S53, a crossover operation is performed on the high-quality parent mask set to exchange some binary bit segments, and then a state flip is performed to introduce mutations, generating a child mask matrix sequence.

[0093] It should be noted that the crossover operation uses a two-point crossover method, randomly selecting two crossover points and exchanging the binary bit segments of corresponding layers in the two parent mask matrices. This crossover method can more fully recombine parent genes, improving gene recombination efficiency by 10% compared to single-point crossover. The mutation probability of the mutation operation is set to 0.05. This probability is based on testing with 30 groups of populations. A mutation probability of 0.05 can introduce an appropriate amount of new genes, avoiding premature population convergence, while not destroying the advantageous genes of high-quality parents. Randomly flipping some binary bits in the offspring mask matrix introduces new gene mutations, generating an offspring mask matrix sequence. The number of offspring is the same as the number of parents, ensuring a stable population size.

[0094] For example, the two parent mask matrices perform a cross operation between the 2nd and 5th layers, swapping the mask vectors of the corresponding layers, and then randomly flipping the mask vector of the 3rd layer to generate the child mask matrix.

[0095] In step S54, the sequence of child mask matrices is iteratively evolved. After each iteration, low-fitness individuals are eliminated and high-fitness individuals are retained until the globally optimal mask structure is locked.

[0096] It should be noted that the iterative evolution is set to a maximum of 20 iterations. This upper limit is based on evolutionary testing of 40 populations, ensuring convergence within 20 iterations and avoiding the waste of computational resources caused by infinite iteration. After each iteration, the fitness values ​​of all offspring individuals are calculated, and the bottom 50% of individuals in terms of fitness are eliminated. The remaining individuals serve as parents for the next iteration, and together with 20 newly generated random individuals, the population size is replenished to maintain 100 individuals. This replenishment mechanism prevents the loss of population diversity. The process continues until the maximum number of iterations is reached or the fitness values ​​converge (the maximum fitness change is less than 0.01 for three consecutive rounds), at which point the globally optimal mask structure is locked.

[0097] For example, after 15 iterations, the fitness value converged, and the maximum fitness reached 0.92. The corresponding mask structure achieved a compression rate of 38% and an accuracy retention of 96.5%, and this structure was determined to be the globally optimal mask structure.

[0098] In step S55, the globally optimal mask structure is decoded and mapped to convert it into a specific layer channel or parameter pruning configuration to obtain a refined pruning scheme.

[0099] It should be noted that the decoding mapping converts the binary mask vector of each layer into specific pruning instructions. The decoding method involves traversing each element of the mask vector; if an element is 0, the corresponding channel or parameter is marked as pruned, and if an element is 1, it is marked as retained. For example, a convolutional layer mask vector [1,1,...,0,0] (the first 20 bits are 1, and the last 12 bits are 0) corresponds to the configuration of "retaining the first 20 filters of this layer and pruning the last 12 filters," and a fully connected layer mask vector corresponds to the configuration of "retaining the specified neurons and pruning the remaining neurons."

[0100] The refined pruning scheme is a set of pruning configurations for all layers, clearly recording the pruning position, pruning ratio, and index of the retained parameters for each layer. The pruning ratio is calculated by dividing the number of pruning parameters by the total number of parameters in that layer. The index of the retained parameters is the position number of the retained parameters in the original layer parameters. This scheme can be directly used for model pruning operations.

[0101] For example, the refined pruning scheme includes a 7-layer pruning configuration, where the pruning ratios of the three convolutional layers are 25%, 30%, and 20%, respectively, and the pruning ratio of the fully connected layer is 40%, with the specific index of each pruning position clearly marked.

[0102] In step S6, the refined pruning scheme is applied to the deep neural network to obtain the final computational resource consumption and prediction accuracy values. It is then determined whether these two values ​​are in balance. If not, the reward function of the reinforcement learning agent is updated, and the parameter importance score sequence is re-determined, including: S61, map the refined pruning scheme to the deep neural network, select and discard channels or parameters of each layer according to the pruning configuration, and construct the compressed network structure to be evaluated; S62, Based on the compressed network structure to be evaluated, obtain the computational resource consumption metric and the current prediction accuracy value; S63, determine whether the loss between the computational resource consumption metric and the current prediction accuracy value has reached a balance. If not, generate a deviation vector and feed it back to the reinforcement learning agent. S64, update the reward function of the reinforcement learning agent according to the bias vector, increase the penalty weight for accuracy loss, and redetermine the parameter importance score sequence.

[0103] In step S61, the refined pruning scheme is mapped to the deep neural network, and the channels or parameters of each layer are selected according to the pruning configuration to construct the compressed network structure to be evaluated.

[0104] It should be noted that the mapping process is implemented through a model reconstruction tool. According to the configuration of each layer in the refined pruning scheme, the specified filters, neurons or parameter channels are deleted. The deletion method is to retain the corresponding parameters and delete the pruned parameters according to the index of the retained parameters. Then, the inter-layer connection relationship is reconstructed to ensure the integrity and operability of the compressed network structure.

[0105] The reconstruction tool supports mainstream deep learning frameworks. The reconstructed network structure can directly load weights and run. Tests have shown that the reconstructed network structure has no syntax errors or logical vulnerabilities, and its running stability reaches 99.9%.

[0106] For example, after deleting 12 filters from a convolutional layer according to the pruning scheme, the connection relationship between this layer and the next pooling layer is readjusted to ensure that the pooling layer only receives the output of the 20 retained filters, thus constructing the complete compressed network structure to be evaluated.

[0107] In step S62, based on the compressed network structure to be evaluated, the computational resource consumption metric and the current prediction accuracy are obtained.

[0108] It should be noted that the computational resource consumption metrics include FLOPs (floating-point operations) and memory usage. FLOPs are calculated by accumulating the computational load of each network layer, and the calculation method is to count the number of floating-point operations such as convolution and fully connected operations layer by layer and sum them up. Memory usage is the sum of the storage capacity of the model weight parameters and intermediate feature maps, and the calculation method is to add the number of bytes of the weight parameters to the total number of bytes of the intermediate feature maps of each layer.

[0109] The current prediction accuracy value represents the classification accuracy or regression error of the compressed network on the test dataset. For classification tasks, accuracy is used, calculated as the number of correctly classified samples divided by the total number of samples. For regression tasks, mean squared error is used, calculated as the sum of the squares of the differences between predicted and true values ​​divided by the total number of samples. The test dataset is consistent with the test dataset in S3 to ensure uniformity of evaluation criteria.

[0110] For example, the FLOPs of the compressed network to be evaluated are 62% of those of the original network, the memory usage is 65% of that of the original network, the prediction accuracy on the test dataset is 96.2%, and the accuracy of the original network is 98.0%.

[0111] In step S63, it is determined whether the loss of the computational resource consumption metric and the current prediction accuracy value has reached a balance. If the balance has not been reached, a deviation vector is generated and fed back to the reinforcement learning agent.

[0112] It should be noted that the condition for determining the equilibrium state is that the computational resource consumption metric reaches the preset compression standard, and the loss of the current prediction accuracy value does not exceed the preset accuracy threshold. The preset compression standard is a reduction of FLOPs by more than 30% and a reduction of memory usage by more than 25%. This standard is set based on resource limitation tests of edge devices and can meet the deployment needs of most edge devices. The preset accuracy threshold is set to 2%. This threshold is set based on tests of 50 application scenarios. A 2% accuracy loss is acceptable in most scenarios and will not affect the application effect.

[0113] If an equilibrium is not reached, a deviation vector is generated. This deviation vector contains the target difference between accuracy loss and compression ratio. It is calculated by subtracting the actual accuracy loss from the target accuracy loss value and subtracting the actual compression ratio from the target compression ratio value. These values ​​quantify the gap between the current solution and the ideal equilibrium. This feedback helps the agent understand the shortcomings of the current strategy.

[0114] For example, if the FLOPs of the compressed network are reduced by 38% (meeting the standard), but the accuracy loss is 1.8% (not exceeding the threshold), then it is determined that a balanced state has been reached; if the accuracy loss is 3% (exceeding the threshold), then a bias vector [0.2%, -5%] is generated (assuming the accuracy loss target value is 2% and the compression ratio target value is 40%), and fed back to the reinforcement learning agent.

[0115] In step S64, the reward function of the reinforcement learning agent is updated according to the bias vector, the penalty weight for accuracy loss is increased, and the parameter importance score sequence is redefined.

[0116] It should be noted that the reward function is updated by adding a penalty weight to the precision loss based on the precision loss deviation in the deviation vector. The calculation method is to add the original penalty weight to the precision loss deviation multiplied by 0.5; the original penalty weight is 0.6, ensuring that the adjustment of the penalty weight is proportional to the precision loss deviation. The updated reward function is more inclined to protect highly important parameters and reduce precision loss.

[0117] The process of redetermining the parameter importance score sequence is consistent with S1-S4, ensuring that the new score sequence guides the generation of a more balanced pruning scheme. Testing showed that the pruning scheme generated after updating the reward function reduced accuracy loss by an average of over 0.8%.

[0118] For example, the reward function is updated according to the bias vector [0.2%, -5%], the penalty weight for accuracy loss is adjusted from 0.6 to 0.7, and steps S1-S4 are re-executed to obtain a new sequence of parameter importance scores.

[0119] In step S7, the deep neural network is deployed on edge devices according to the refined pruning scheme to obtain operating efficiency and accuracy indicators and determine the stability of compression quality, including: S71, Generate a heterogeneous executable file adapted to the edge device according to the refined pruning scheme, optimize the calculation graph for the processor architecture of the edge device, and adapt it to the corresponding instruction set; S72, the heterogeneous executable file is loaded into the runtime environment of the edge device, and the core inference module is loaded in a modular manner using a dynamic link library; S73 runs a standard test dataset on an edge device, collects latency values ​​and peak dynamic memory usage for multiple inferences, calculates a comprehensive score for edge running efficiency, obtains prediction output results, compares them with the labeled results of the test dataset, and determines the current accuracy value. S74, calculate the variation of the overall operating efficiency score and the current accuracy value relative to the original model baseline value. If the preset amplitude threshold is met, determine that the compression quality is stable.

[0120] In step S71, a heterogeneous execution file adapted to the edge device is generated according to the refined pruning scheme, the computation graph is optimized for the processor architecture of the edge device, and the corresponding instruction set is adapted.

[0121] It should be noted that the heterogeneous executable file is generated using a cross-platform compilation tool that supports mainstream edge device processor architectures such as ARM and X86. During the compilation process, the computation graph is optimized for the characteristics of the processor architecture. Optimization methods include operator fusion (merging multiple consecutive operators into a single operator), memory reuse (reusing intermediate variable memory), and parallel instruction scheduling (scheduling parallel computing tasks based on the number of processor cores). These optimizations can improve the running efficiency of the executable file on edge devices.

[0122] The instruction set adaptation method involves compiling an executable file corresponding to the processor instruction set (such as ARMv7 or ARMv8) of the edge device. This ensures that the executable file can directly call the processor's hardware instructions, avoiding performance loss caused by instruction translation. Tests have shown that the optimized executable file achieves over 30% higher running efficiency on edge devices compared to the unoptimized version.

[0123] For example, for edge devices based on the ARMv8 architecture, a heterogeneous executable file is generated, which merges three consecutive convolution operators into one, improving memory reuse by 40%, adapting to the NEON instruction set, and enhancing parallel computing capabilities.

[0124] In step S72, the heterogeneous executable file is loaded into the runtime environment of the edge device, and the core inference module is loaded in a modular manner using a dynamic link library.

[0125] It should be noted that the runtime environment is the native operating system environment of the edge device (such as Linux or Android), and the loading method is to load heterogeneous executable files through the system's dynamic linker. The advantage of the dynamic link library method is that modules are loaded on demand. Core inference modules are loaded first, and non-essential functional modules (such as logging modules and debugging modules) are loaded on demand, thereby reducing the initial memory usage.

[0126] The loading priority of the core inference module is set to the highest to ensure that the inference function is ready first. The loading timeout is set to 5 seconds. This timeout is based on loading tests on 30 edge devices. The core module can be loaded within 5 seconds. If the timeout occurs, the loading is judged to have failed and a retry mechanism is triggered.

[0127] For example, for edge devices with memory limitations (such as 2GB of memory), the core inference module (which uses 300MB of memory) is loaded first, and the log module is loaded on demand after inference begins (which uses 50MB of memory), reducing the initial memory usage pressure.

[0128] In step S73, a standard test dataset is run on the edge device to collect latency values ​​and dynamic memory usage peaks for multiple inferences, calculate a comprehensive score for edge running efficiency, obtain the prediction output results, compare them with the labeled results of the test dataset, and determine the current accuracy value.

[0129] It should be noted that the standard test dataset is consistent with the test datasets in S3 and S6 to ensure the uniformity of accuracy evaluation. The number of runs is set to 100, which is based on statistical stability testing. The coefficient of variation of latency and memory usage data after 100 runs is less than 5%, which can accurately reflect the actual operating status of the device.

[0130] The inference latency data collection method is to record the total time from data input to output for each inference. The dynamic memory usage peak is collected by monitoring the device's memory. The comprehensive score of running efficiency is calculated by multiplying the latency optimization magnitude by 50 and the memory usage optimization magnitude by 50. The optimization magnitude is (original model value minus compressed model value) divided by the original model value. The score range is 0-100 points, and the higher the score, the better the running efficiency.

[0131] The current accuracy value is determined by comparing the predicted output with the labeled results of the test dataset. The accuracy is calculated for the classification task, and the mean squared error is calculated for the regression task. The comparison method is to compare the predicted value with the true value for each sample and to count the proportion of samples that are correctly classified or whose errors are within the allowable range.

[0132] For example, running 100 inferences on an edge device resulted in an average latency of 28ms and a peak dynamic memory usage of 280MB. The original model had a latency of 45ms and a memory usage of 400MB. The latency optimization was approximately (45-28) / 45≈0.378, and the memory usage optimization was approximately (400-280) / 400=0.3. The overall efficiency score was 0.378×50+0.3×50=18.9+15=33.9 points. The accuracy of the predicted output was 95.8% when compared with the labeled results, confirming the current accuracy value as 95.8%.

[0133] In step S74, the variation of the overall operating efficiency score and the current accuracy value relative to the original model baseline value is calculated. If the preset amplitude threshold is met, the compression quality is determined to be stable.

[0134] It should be noted that the baseline values ​​of the original model are the comprehensive efficiency score and accuracy value of the original model on the same edge device. The calculation method for the variation range is (compressed model value minus original model value) divided by the original model value. The preset variation threshold is set as follows: the comprehensive efficiency score should increase by no less than 20%, and the accuracy value should decrease by no more than 2%. This threshold is set based on the actual needs of edge device deployment. A 20% efficiency improvement can significantly improve real-time performance, and a 2% accuracy loss is within an acceptable range.

[0135] If the preset amplitude threshold is met, the compression quality is determined to be stable; otherwise, return to S5 to re-optimize and refine the pruning scheme until the threshold is met. Testing shows that the compression scheme of this invention achieves a stability compliance rate of over 95% on 80 different edge devices.

[0136] For example, the original model has an overall efficiency score of 100 and an accuracy of 97.5%, while the compressed model has an overall efficiency score of 133.9 (an improvement of 33.9% ≥ 20%) and an accuracy of 95.8% (a decrease of 1.7% ≤ 2%), which meets the preset amplitude threshold and confirms that the compression quality is stable.

[0137] Reference Figure 2 The second embodiment of the present invention provides an artificial intelligence-based generative engine optimization system, comprising: The important evaluation module is used to obtain the hierarchical structure and parameter distribution from the deep neural network to be optimized, and to analyze the connection mode of each layer through reinforcement learning agent to obtain the parameter importance score sequence. The preliminary pruning module is used to perform crossover and mutation operations on potential pruning positions based on the parameter importance score sequence and a genetic algorithm to determine the preliminary pruning mask matrix. The threshold judgment module is used to apply the preliminary pruning mask matrix to the deep neural network, obtain inference time and accuracy indicators, and determine whether the inference time meets the preset inference time threshold. If it does not meet the threshold, the genetic algorithm mutation rate is adjusted and the pruning mask matrix is ​​regenerated. The gradient feedback module is used to obtain the gradient information of the remaining parameters of the deep neural network based on the preliminary pruning mask matrix, and to obtain the optimized parameter importance score sequence by calculating reward feedback through reinforcement learning agent; The refinement and optimization module is used to iteratively optimize the initial pruning mask matrix using a genetic algorithm based on the optimized parameter importance score sequence to obtain a refined pruning scheme. The balance judgment module is used to apply the refined pruning scheme to the deep neural network, obtain the final computational resource consumption and prediction accuracy values, and determine whether the two have reached a balance state. If they have not reached a balance state, the reward function of the reinforcement learning agent is updated and the parameter importance score sequence is re-determined. The deployment test module is used to perform edge device deployment tests on the deep neural network according to the refined pruning scheme, obtain operating efficiency and accuracy indicators, and determine the stability of compression quality.

[0138] The system provided in this embodiment of the invention is used to execute all the process steps of the above method embodiments. The two correspond one-to-one in terms of module function, working logic and technical effect, and have the same compression efficiency and accuracy balance capability. Therefore, the specific working details and beneficial effects of the system can be referred to the foregoing method embodiments, and will not be repeated here.

[0139] This invention also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement all the steps of the artificial intelligence-based generative engine optimization method described above.

[0140] This invention also provides a computer-readable storage medium, which includes a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the artificial intelligence-based generative engine optimization method described above.

[0141] It should be noted that the system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the system embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.

[0142] For example, the computer program can be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in the electronic device. For example, the computer program can be divided into traffic processing instruction segments, graph construction instruction segments, cluster analysis instruction segments, etc., corresponding to functions such as traffic simplification, graph construction, and cluster determination, respectively.

[0143] The electronic device may be an edge computing gateway, an industrial control server, a desktop computer, or other device with data processing capabilities. The electronic device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that the above components are merely examples of electronic devices and do not constitute a limitation on the electronic device. It may include more or fewer components than described above, or combine certain components, or use different components. For example, the electronic device may also include a data interface, a network module, an alarm module, etc. The data interface is used to connect the traffic acquisition component to the IoT device, the network module is used to realize data interaction between devices, and the alarm module is used to trigger audible, visual, or SMS alarms when abnormal communication patterns are detected.

[0144] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the electronic device, connecting various parts of the device through various interfaces and lines. It executes computer programs and / or modules stored in the memory, and retrieves data stored in the memory to realize the network security protection data processing and decision generation functions of the electronic device.

[0145] It should be noted that the system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the system embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.

[0146] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.

Claims

1. An artificial intelligence based generative engine optimization method, characterized by, include: The hierarchical structure and parameter distribution are obtained from the deep neural network to be optimized. The connection mode of each layer is analyzed by traversing through reinforcement learning agents to obtain the parameter importance score sequence. Based on the parameter importance score sequence, a genetic algorithm is used to perform crossover and mutation operations on potential pruning positions to determine the preliminary pruning mask matrix. The initial pruning mask matrix is ​​applied to the deep neural network to obtain inference time and accuracy indicators. It is determined whether the inference time meets the preset inference time threshold. If it does not meet the threshold, the genetic algorithm mutation rate is adjusted and the pruning mask matrix is ​​regenerated. Based on the preliminary pruning mask matrix, the gradient information of the remaining parameters of the deep neural network is obtained, and the reward feedback is calculated through reinforcement learning agent to obtain the optimized parameter importance score sequence. Based on the optimized parameter importance score sequence, a genetic algorithm is used to iteratively optimize the initial pruning mask matrix to obtain a refined pruning scheme. The refined pruning scheme is applied to the deep neural network to obtain the final computational resource consumption and prediction accuracy values. It is then determined whether the two have reached a balance. If not, the reward function of the reinforcement learning agent is updated and the parameter importance score sequence is re-determined. The deep neural network is deployed on edge devices according to the refined pruning scheme to obtain operating efficiency and accuracy indicators and determine the stability of compression quality.

2. The method of claim 1, wherein, The process involves obtaining the hierarchical structure and parameter distribution from the deep neural network to be optimized, analyzing the connection patterns of each layer through a reinforcement learning agent, and obtaining a sequence of parameter importance scores, including: Analyze deep neural networks, extract hierarchical topology data and weight distribution statistics, and obtain the hierarchical depth and node connection relationships, as well as the weight mean and variance; A reinforcement state space is constructed based on the hierarchical topology data and weight distribution statistics, which is then used by reinforcement learning agents to access and output traversal actions. The traversal action is performed to apply perturbations to the connection nodes of each layer. The connection sensitivity is determined based on the changes in the output of the deep neural network, and the local importance evaluation value is calculated based on the connection sensitivity. The local importance evaluation values ​​are serialized and aggregated in hierarchical order to obtain a parameter importance score sequence.

3. The method of claim 1, wherein, The step of determining the preliminary pruning mask matrix by performing crossover and mutation operations on potential pruning positions using a genetic algorithm based on the parameter importance score sequence includes: The parameter importance score sequence is mapped to the gene coding space, and the score is converted into binary bits according to a preset conversion threshold to construct an initial population composed of multiple binary chromosomes; Based on the initial population, the fitness value of the binary chromosome is calculated, high-quality parent chromosomes are selected, and crossover is performed to generate offspring chromosomes; Based on the mutation probability of the negative correlation between the importance score sequence of the parameters, the state of the offspring chromosomes is reversed to obtain the preferred individuals; Based on the original topological dimensions of the deep neural network, the preferred individuals are reshaped to determine the preliminary pruning mask matrix.

4. The method of claim 1, wherein, The step of applying the preliminary pruning mask matrix to the deep neural network, obtaining inference time and accuracy metrics, determining whether the inference time meets a preset inference time threshold, and if not, adjusting the mutation rate of the genetic algorithm and regenerating the pruning mask matrix includes: The initial pruning mask matrix is ​​multiplied element-wise with the original weight tensor of the deep neural network to generate compressed model weights. Input the test dataset into the network containing the weights of the compressed model, perform forward propagation calculations, and collect the inference time. Determine whether the inference time is less than or equal to a preset inference time threshold. If not, adjust the basic mutation rate according to the extent to which the inference time exceeds the threshold, and construct an adaptive mutation probability distribution. Based on the adaptive mutation probability distribution, candidate pruning mask matrices are regenerated until a pruning mask matrix that satisfies a preset inference time threshold is obtained.

5. The method of claim 1, wherein, The process involves obtaining the gradient information of the remaining parameters of the deep neural network based on the initial pruning mask matrix, calculating reward feedback through a reinforcement learning agent, and obtaining an optimized parameter importance score sequence, including: Based on the preliminary pruning mask matrix, non-zero weights are selected, and their corresponding gradient information is extracted to form a sparse gradient vector. Combining the sparse gradient vector with the weight numerical distribution characteristics, the observation state space vector of the reinforcement learning agent is constructed. The observed state space vector is input into a preset strategy network model to obtain an initial importance score sequence; The reward value is calculated based on the initial importance score sequence. The reward value takes into account both accuracy preservation and compression rate improvement, and the parameters of the policy network model are updated accordingly. The observed state space vector is input into the updated policy network model to obtain the optimized parameter importance score sequence.

6. The method of claim 1, wherein, The step involves using a genetic algorithm to iteratively optimize the initial pruning mask matrix based on the optimized parameter importance score sequence to obtain a refined pruning scheme, including: The initial pruning mask matrix is ​​binary encoded according to the optimized parameter importance score sequence. Positions with scores higher than a preset score threshold are marked as 1, and those lower than the threshold are marked as 0, thus constructing an initial mask population. Calculate the fitness value of each individual in the initial mask population, and select the high-quality parent mask set with the highest fitness ranking; Perform a crossover operation on the high-quality parent mask set to exchange some binary bit segments, and then perform a state flip to introduce mutation to generate a child mask matrix sequence. The sequence of child mask matrices is iteratively evolved. After each iteration, low-fitness individuals are eliminated and high-fitness individuals are retained until the globally optimal mask structure is locked. The globally optimal mask structure is decoded and mapped to convert it into specific layer channel or parameter pruning configurations, resulting in a refined pruning scheme.

7. The method of claim 1, wherein, The process involves applying the refined pruning scheme to the deep neural network, obtaining the final computational resource consumption and prediction accuracy values, determining whether the two have reached a balance, and if not, updating the reward function of the reinforcement learning agent and re-determining the parameter importance score sequence, including: The refined pruning scheme is mapped to the deep neural network, and the channels or parameters of each layer are selected according to the pruning configuration to construct the compressed network structure to be evaluated. Based on the compressed network structure to be evaluated, obtain the computational resource consumption metric and the current prediction accuracy value; Determine whether the loss between the computational resource consumption metric and the current prediction accuracy has reached a balance; if not, generate a bias vector and feed it back to the reinforcement learning agent. The reward function of the reinforcement learning agent is updated based on the bias vector, the penalty weight for accuracy loss is increased, and the parameter importance score sequence is redefined.

8. The method of claim 1, wherein, The step of performing edge device deployment tests on the deep neural network according to the refined pruning scheme, obtaining operating efficiency and accuracy indicators, and determining the stability of compression quality includes: Based on the refined pruning scheme, a heterogeneous executable file adapted to edge devices is generated, and the computation graph is optimized for the processor architecture of the edge devices to adapt to the corresponding instruction set; The heterogeneous executable file is loaded into the runtime environment of the edge device, and the core inference module is loaded in a modular manner using a dynamic link library. Run a standard test dataset on an edge device, collect latency values ​​and peak dynamic memory usage for multiple inferences, calculate a comprehensive score for edge running efficiency, obtain the prediction output results, compare them with the labeled results of the test dataset, and determine the current accuracy value. Calculate the variation of the overall operating efficiency score and the current accuracy value relative to the original model baseline value. If the variation meets the preset amplitude threshold, the compression quality is determined to be stable.

9. An artificial intelligence based generative engine optimization system, characterized in that, include: The important evaluation module is used to obtain the hierarchical structure and parameter distribution from the deep neural network to be optimized, and to analyze the connection mode of each layer through reinforcement learning agent to obtain the parameter importance score sequence. The preliminary pruning module is used to perform crossover and mutation operations on potential pruning positions based on the parameter importance score sequence and a genetic algorithm to determine the preliminary pruning mask matrix. The threshold judgment module is used to apply the preliminary pruning mask matrix to the deep neural network, obtain inference time and accuracy indicators, and determine whether the inference time meets the preset inference time threshold. If it does not meet the threshold, the genetic algorithm mutation rate is adjusted and the pruning mask matrix is ​​regenerated. The gradient feedback module is used to obtain the gradient information of the remaining parameters of the deep neural network based on the preliminary pruning mask matrix, and to obtain the optimized parameter importance score sequence by calculating reward feedback through reinforcement learning agent; The refinement and optimization module is used to iteratively optimize the initial pruning mask matrix using a genetic algorithm based on the optimized parameter importance score sequence to obtain a refined pruning scheme. The balance judgment module is used to apply the refined pruning scheme to the deep neural network, obtain the final computational resource consumption and prediction accuracy values, and determine whether the two have reached a balance state. If not, the reward function of the reinforcement learning agent is updated and the parameter importance score sequence is re-determined. The deployment test module is used to perform edge device deployment tests on the deep neural network according to the refined pruning scheme, obtain operating efficiency and accuracy indicators, and determine the stability of compression quality.