Intelligent algorithm test method, system and device and storage medium
By comprehensively utilizing multiple granular coverage indicators to generate high-quality test samples, the problem that coverage testing methods in the prior art are difficult to adapt to the limitations of complex text tasks and single coverage indicators, and the more efficient and comprehensive results of intelligent algorithm testing are achieved.
Patent Information
- Application Number
- CN202510332500.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2045-03-20
AI Technical Summary
The existing neural network coverage testing methods are mainly concentrated in traditional fully connected networks and convolutional networks, and it is difficult to adapt to more complex text tasks. Especially the coverage testing methods in large language models are still an urgent area to be developed and studied. At the same time, there are limitations in a single coverage indicator, which is difficult to fully reflect the complexity of the model.
An intelligent algorithm testing method is proposed to generate high-quality test samples by comprehensively utilizing multiple granular coverage indicators (such as single-neuron coverage indicators, lateral neuron combination coverage indicators and longitudinal neuron combination coverage indicators), thereby improving the diversity and targeting of the tests. This method ensures that the test samples can fully cover the behavioral characteristics of the intelligent algorithm through iterative optimization of the seed library, combined with the calculation and screening of multi-grained coverage indicators.
Through the synergistic effect of multi-grained coverage indicators, a comprehensive capture of the behavioral characteristics of the intelligent algorithm is achieved, high-quality test samples are generated, which significantly improves the depth and breadth of the test, and enhances the security and reliability of the intelligent algorithm.
Smart Images

Figure CN119847943A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of neural network testing technology, and in particular to an intelligent algorithm testing method, system, device and storage medium. Background Art
[0002] As a core technology in the field of artificial intelligence, deep neural networks (DNNs) have been widely used in many key applications such as image recognition, natural language processing, and autonomous driving. With its popularity in real-world scenarios, the reliability and security requirements of models are increasing. However, due to the highly nonlinear and complex "black box" characteristics of deep neural networks, its internal decision-making mechanism is difficult to fully analyze. This complexity not only increases the difficulty of understanding the behavior of the model, but also brings severe challenges to model testing and verification, and further gives rise to specialized testing technologies for neural networks. The goal of neural network testing technology is to systematically evaluate the performance of the model in complex input scenarios, timely discover potential defects, and improve the generalization ability and robustness of the model by optimizing the network structure and training strategy, so as to better meet actual needs.
[0003] Neural network testing technology is committed to comprehensively evaluating the stability, accuracy and interpretability of the model's functional performance. This technology can not only reveal the internal operating mechanism of the neural network under specific inputs, but also deeply analyze the model's ability to respond to abnormal inputs or adversarial attacks. With the expansion of the complexity of deep learning models and the application scenarios, traditional software testing methods have been unable to meet their special needs, which has prompted researchers to develop new testing methods that are more suitable for intelligent algorithms. Among them, neuron coverage is the most widely used core testing method. Its concept is derived from the code coverage in traditional software testing, focusing on evaluating the activation degree of neurons. By analyzing the activation state in the network, neuron coverage can not only guide the generation of test samples, but also help identify potential defective inputs. This technology plays a key role in improving the reliability of models and maintaining security-sensitive applications.
[0004] Current neural network coverage testing mainly focuses on two aspects: the design of coverage indicators and the generation of test samples based on coverage indicators. The two complement each other and jointly promote the comprehensive testing and maintenance of deep learning models. In terms of coverage indicator design, researchers first proposed neuron coverage as a basic indicator to measure whether the test samples fully explore the model behavior. With the development of technology, more refined coverage indicators have been proposed, such as path-based coverage, neuron combination activation coverage, and adequacy coverage for functional modules. These coverage indicators can not only fully reflect the behavioral complexity within the model, but also adapt to different types of neural network architectures. For example, DeepXplore, as the first white-box testing framework, applied neuron coverage to neural network testing for the first time, automatically detecting potential defects in neural network models by generating difference-induced inputs; DeepGauge (a network deep testing framework) further proposed multi-granularity coverage indicators on this basis, including k-value activation coverage and interval coverage; and in response to the special needs of recurrent neural networks (RNNs), DeepCruiser (an automated testing method for neural network models that aims to discover potential errors and vulnerabilities by exploring the decision boundaries of the model) developed more adaptive coverage indicators and improved the testing capabilities of timing models. These studies have significantly promoted the application of coverage testing in different architectures and laid the foundation for neural network reliability assessment.
[0005] In terms of test sample generation, coverage-guided fuzz testing technology has gradually become a research hotspot in the field of neural network testing. The core idea of this type of technology is to generate new test samples while retaining the semantic consistency of the original samples by designing diverse sample mutation strategies to cover the behavioral areas that are not fully explored by the neural network. These generated samples can not only help reveal potential defects in the model, but also effectively expand the test space, providing important support for the robustness and reliability verification of the model. In specific implementation, fuzz testing frameworks usually use coverage indicators as feedback signals, and continuously improve the adaptability and coverage of test samples to the target model through iterative optimization of the generation process. Taking DeepHunter (a neural network testing framework based on fuzz testing, which improves the robustness and security of the model by generating diverse test cases) as an example, this framework generates new samples that meet the coverage requirements by introducing diverse mutation strategies, such as pixel perturbation, structural transformation, and semantic enhancement of input samples. At the same time, DeepHunter combines diversity and recency strategies to select test seeds to ensure that the generated samples not only have a wide coverage capability, but also maintain the representativeness and efficiency of the test sample set. Experimental results show that the test samples generated by DeepHunter are significantly better than traditional methods in terms of coverage improvement, defect detection and sample diversity. For example, in image classification tasks, DeepHunter can quickly locate the network's sensitivity to boundary samples, which are often difficult to find with traditional random generation methods. In addition, the coverage-based generation strategy can also help locate high-risk areas of adversarial samples in the model, thereby further guiding the improvement and optimization of the model.
[0006] There are still many deficiencies in the current work. Most of the existing coverage standards and their corresponding test sample generation techniques focus on traditional fully connected networks (FNNs) and convolutional networks (CNNs), mainly serving image-related tasks. Only a small number of coverage indicators have been applied to natural language processing tasks, and only preliminary tests have been conducted on recurrent neural networks (RNNs). Therefore, the applicability of these coverage indicators on more complex text tasks, especially large language models (LLMs), has not been verified, and related coverage testing methods are still an area that needs to be developed and studied.
[0007] In addition, existing single coverage metrics generally have limitations. Each coverage metric can only reflect a specific dimension of the behavior of the neural network, and it is difficult to fully characterize the complexity of the model, so it cannot be used independently as a complete test metric. For example, neuron coverage may focus on the activation of a single node, while path coverage focuses on the exploration of certain paths in the network, but neither of them can fully reflect the functional behavior and potential defects of the network. This limitation directly leads to the limited quality of test samples generated based on a single coverage metric, which may not effectively cover the key weak areas of the model.
[0008] Therefore, how to organically combine coverage indicators of multiple granularities so that they complement each other in the testing process is an important direction of current research.
[0009] In view of this, the present invention is proposed. Summary of the invention
[0010] The purpose of the present invention is to provide an intelligent algorithm testing method, system, device and storage medium, which can comprehensively utilize coverage indicators of multiple granularities for testing, which can not only make up for the shortcomings of a single coverage indicator, but also generate higher quality test samples, improve the diversity and pertinence of test samples, and provide more comprehensive support for the reliability and security verification of intelligent algorithms.
[0011] The objective of the present invention is achieved through the following technical solutions: An intelligent algorithm testing method, comprising: Step 1: Select the target intelligent model that meets the actual application scenario as the intelligent algorithm to be tested, collect the corresponding test data set, select the test samples from the test data set as seeds, form a seed library, and define the multi-granularity neuron coverage indicators during the test; Step 2: Calculate the comprehensive score of the seed based on the comprehensive distance of the seed on the multi-granularity neuron coverage index and the scheduling impact factor based on diversity and proximity. Select the seed from the seed library based on the comprehensive score of the seed, generate a new test sample through the metamorphosis strategy, and then input it into the intelligent algorithm to be tested for testing, and calculate the multi-granularity neuron coverage index; Step 3: Combine the calculated multi-granularity neuron coverage index to select a part of new test samples; Step 4: Add the selected new test samples to the seed library and go to step 2; continue to iterate until the set test termination condition is met.
[0012] An intelligent algorithm testing system, comprising: The intelligent algorithm and test data selection and indicator definition unit is used to select the target intelligent model that meets the actual application scenario as the intelligent algorithm to be tested, collect the corresponding test data set, screen out test samples from the test data set as seeds to form a seed library, and define the multi-granularity neuron coverage indicators during the test; A multi-granularity neuron coverage index calculation unit is used to calculate the comprehensive score of the seed based on the comprehensive distance of the seed on the multi-granularity neuron coverage index and the scheduling influence factor based on diversity and proximity, select the seed from the seed library based on the comprehensive score of the seed, and generate a new test sample through the metamorphosis strategy, and then input it into the intelligent algorithm to be tested for testing, and calculate the multi-granularity neuron coverage index; A test sample screening unit is used to screen out a part of new test samples by combining the calculated multi-granularity neuron coverage index; The iterative test unit is used to add the screened new test samples to the seed library, and perform iterative testing through the multi-granularity neuron coverage index calculation unit and test sample screening until the set test termination conditions are met.
[0013] A processing device, comprising: one or more processors; a memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the aforementioned method.
[0014] A readable storage medium stores a computer program, which implements the above method when the computer program is executed by a processor.
[0015] It can be seen from the technical solution provided by the present invention that by integrating multi-granularity coverage indicators, not only the efficiency of intelligent algorithm testing is improved, but also the depth and breadth of testing are significantly expanded from multiple dimensions, bringing new ideas and methods for model verification in complex tasks. In terms of efficiency improvement, the present invention can quickly analyze and evaluate the coverage of the model, reduce redundant testing by accurately locating test gaps and uncovered areas, and improve the utilization rate of test resources. In terms of test depth, by introducing a multi-level (multi-granularity) coverage indicator system, the present invention can deeply explore the internal behavior mechanism and complex decision-making logic of the model, revealing subtle problems and hidden defects that are difficult to capture by traditional methods. In terms of test breadth, it covers various types of network behaviors and scenarios, significantly enhancing the comprehensiveness of the test. In addition, based on multi-granularity coverage indicators, the complementarity of each coverage indicator can be fully utilized to generate test samples with both diversity and coverage. Through these test samples, the intelligent algorithm can be helped to discover more potential erroneous behaviors or abnormal decisions, thereby optimizing the security and reliability of the model and providing stronger protection for practical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0017] Figure 1 A flowchart of an intelligent algorithm testing method provided by an embodiment of the present invention; Figure 2 A schematic diagram of an intelligent algorithm coverage testing process provided by an embodiment of the present invention; Figure 3 A schematic diagram of a high-quality sample generation process provided by an embodiment of the present invention; Figure 4 A schematic diagram of an intelligent algorithm testing system provided by an embodiment of the present invention; Figure 5 A schematic diagram of a processing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0018] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of the present invention.
[0019] First, the terms that may be used in this article are explained as follows: The terms "include", "comprises", "contains", "has" or other descriptions with similar semantics should be interpreted as non-exclusive inclusion. For example, including certain technical feature elements (such as raw materials, components, ingredients, carriers, dosage forms, materials, dimensions, parts, components, mechanisms, devices, steps, procedures, methods, reaction conditions, processing conditions, parameters, algorithms, signals, data, products or products, etc.) should be interpreted as including not only certain technical feature elements explicitly listed, but also other technical feature elements known in the art that are not explicitly listed.
[0020] The term "consisting of..." means excluding any technical feature elements not explicitly listed. If this term is used in a claim, it will make the claim closed, so that it does not contain technical feature elements other than the technical feature elements explicitly listed, except for the conventional impurities related to them. If this term only appears in a clause of a claim, it only limits the elements explicitly listed in the clause, and the elements recorded in other clauses are not excluded from the overall claim.
[0021] The following is a detailed description of an intelligent algorithm testing method, system, device and storage medium provided by the present invention. The contents not described in detail in the embodiments of the present invention belong to the prior art known to professionals in the field. If the specific conditions are not specified in the embodiments of the present invention, they are carried out according to the conventional conditions in the field or the conditions recommended by the manufacturer. If the manufacturer is not specified in the reagents or instruments used in the embodiments of the present invention, they are all conventional products that can be purchased commercially.
[0022] Embodiment 1 The embodiment of the present invention provides an intelligent algorithm testing method, such as Figure 1 As shown, it mainly includes the following steps: Step 1: Select intelligent algorithms and test data, and define multi-granularity neuron coverage indicators.
[0023] Before starting the test, you need to prepare the model to be tested and the test dataset for testing, and initialize the seed library based on it.
[0024] In an embodiment of the present invention, a target intelligent model that meets the actual application scenario is selected as the intelligent algorithm to be tested, and a corresponding test data set is collected, and test samples are screened out from the test data set as seeds to form a seed library.
[0025] Exemplarily, the target intelligent models may include: convolutional neural networks for image processing, Transformer (transformation neural network) models for natural language processing, etc. At the same time, prepare test data sets covering the current application direction to ensure the diversity and representativeness of the data, and provide a basis for subsequent coverage index calculation and seed library initialization.
[0026] In the embodiment of the present invention, the multi-granularity neuron coverage index is defined to include: a single neuron coverage index, a horizontal neuron combination coverage index and a vertical neuron combination coverage index, and the specific calculation method will be introduced later.
[0027] Step 2: Calculate the comprehensive score of the seed based on the comprehensive distance of the seed in the multi-granularity neuron coverage index and the scheduling impact factor based on diversity and proximity. Select the seed from the seed library based on the comprehensive score of the seed, generate new test samples through the metamorphosis strategy, and then input them into the intelligent algorithm to be tested for testing to calculate the multi-granularity neuron coverage index.
[0028] In an embodiment of the present invention, a seed selection strategy is provided, including: Given a seed library, where a single seed is denoted as s, corresponding to a test sample, and a target coverage area Z during the test; let represents the set of semantic paths covered by seed s, any of which is denoted as ;make Represents a set of abstract semantic paths covering the target area Z, where any path is denoted as ; According to the path With path The similarity of the seed s is used to calculate the scheduling impact factor of the seed s based on the path similarity, and then combined with the coverage rate of the seed s on each multi-granularity neuron coverage index, the comprehensive distance of the seed s on the multi-granularity neuron coverage index is calculated. ; Combined with the minimum scheduling probability of the pre-assigned seed s and the number of scheduling of seed s, the scheduling influence factor of seed s based on diversity and proximity is calculated. ; By calculation , get the comprehensive score of seed s; the comprehensive scores of other seeds are calculated in the same way; A portion of seeds are selected from the seed bank based on their comprehensive scores.
[0029] Afterwards, for the selected seeds, the metamorphosis strategy is used to generate new test samples, and the samples are input into the intelligent algorithm to be tested, and the multi-granularity neuron coverage index is calculated according to the neuron activation in the intelligent algorithm; wherein, the multi-granularity neuron coverage index includes: single neuron coverage index (neuron coverage index), horizontal neuron combination coverage index (path coverage index) and vertical neuron combination coverage index (cross-layer coverage index); the single neuron coverage index is the coverage rate of activated neurons; the horizontal neuron combination coverage index is the coverage rate of triggered neuron combination activation in the same layer; the vertical neuron combination coverage index is the coverage rate of triggered neuron combination activation in different layers.
[0030] (1) Single neuron coverage index.
[0031] The single neuron coverage index mainly analyzes the activation of each neuron in the intelligent algorithm under specific input data, and evaluates the fine-grained response ability of the intelligent algorithm to the input data. By counting the number of activated neurons, the coverage of the test sample on the model behavior exploration is measured, and the basic behavioral characteristics of the model are revealed. Specifically, it can be obtained by calculating the coverage rate of activated neurons. The calculation method includes: calculating the ratio of activated neurons to the total number of neurons, expressed as: ; in, is the ratio of activated neurons to the total number of neurons, is the set of all neurons; For collection The number of elements of , that is, the total number of neurons; For neurons The activation value of is the threshold value; is the indicator function, when the condition is met , the output is 1, otherwise the output is 0.
[0032] (2) Horizontal neuron combination coverage index.
[0033] The horizontal neuron combination coverage index mainly examines the activation combination mode between neurons in the same layer, and evaluates the coverage of the test data on the interaction behavior of single-layer neurons. By comparing the triggered and untriggered combinations, the behavioral breadth of the intelligent algorithm is analyzed, and optimization direction is provided for subsequent test sample generation. It is obtained by calculating the coverage rate of the triggered neuron combination activation in the same layer, and the calculation method includes: For each layer, count the number of activated neuron combinations separately, summarize the number of activated neuron combinations of all layers, and count the number of triggered neuron combinations to obtain the number of all triggered neuron combinations activated; calculate the ratio of the number of all triggered neuron combinations activated to the number of activated combinations of all layers , as the coverage of the combined activation of triggered neurons in the same layer, is expressed as: ; in, is the set of combined activations of all fired neurons, is the set of combined activations of all layer neurons, symbol Indicates the number of elements in a collection.
[0034] (3) Longitudinal neuron combination coverage index.
[0035] The vertical neuron combination coverage index mainly analyzes the activation path of cross-layer neurons and reveals the synergy and dependency between different layers. By evaluating the coverage of cross-layer paths, we can find areas that are not fully explored by intelligent algorithms and provide a reference for optimizing test strategies. It can be obtained by the coverage of the triggered neuron combination activation in different layers. The calculation method includes: Count the number of cross-layer neuron combination activations, summarize the number of all cross-layer neuron combination activations, count the number of all triggered cross-layer neuron combination activations, and calculate the ratio of the number of all triggered cross-layer neuron combination activations to the number of all cross-layer neuron combination activations. As the coverage of combined activations of triggered neurons in different layers, it is expressed as: ; in, is the set of combined activations of all fired neurons across layers, is the set of combined activations of all neurons across layers, symbol Indicates the number of elements in a collection.
[0036] Step 3: Combine the calculated multi-granularity neuron coverage index to screen out a portion of new test samples.
[0037] In an embodiment of the present invention, the coverage of the test corresponding to the currently selected seed is evaluated in combination with the calculated multi-granularity neuron coverage index; based on the evaluated coverage, a disturbance is added to the seed or a mutation operation is performed to generate a new test sample.
[0038] Step 4: Add the selected new test samples to the seed library and go to step 2; continue to iterate until the set test termination condition is met.
[0039] The above solution provided by the embodiment of the present invention mainly achieves the following beneficial effects: (1) Organic combination of multi-granularity coverage indicators. The present invention achieves a comprehensive capture of the behavioral characteristics of intelligent algorithms by integrating and utilizing coverage indicators such as single neuron granularity, horizontal neuron combination granularity, and vertical neuron combination granularity. The synergistic effect of this multi-granularity coverage indicator not only effectively makes up for the shortcomings of a single coverage rate, but also expands the coverage of the test, and can accurately locate the weak points and untested areas of the intelligent algorithm. Compared with the traditional single coverage indicator, this method provides a more comprehensive characterization of the intelligent algorithm behavior, laying a solid foundation for the verification of intelligent algorithms for complex tasks.
[0040] (2) Generation of high-quality test samples. Through the comprehensive use of multiple indicators, the present invention proposes a method for generating high-quality test samples guided by multi-granularity coverage, which can generate new test samples in a targeted manner based on the feedback of different granularity coverage indicators. This generation strategy significantly improves the diversity and targeting of test samples, ensures that the key behavior areas of intelligent algorithms are covered, and helps discover more potential error examples, thereby further improving the depth and effectiveness of the test.
[0041] (3) Complementary application of coverage indicators. This invention emphasizes the complementary role of multiple coverage indicators, so that the test can take into account the structural characteristics, behavioral patterns and semantic output of the intelligent algorithm at the same time. This can not only evaluate the internal integrity of the intelligent algorithm, but also discover its anomalies at the input and output levels. This multi-level analysis method effectively avoids potential problems that may be overlooked by a single indicator, and provides strong technical support for improving the comprehensiveness of the test.
[0042] (4) Improved security and reliability of intelligent algorithms. By generating test samples with rich diversity and high coverage, the present invention can quickly reveal potential defects of the model in complex scenarios and provide precise guidance for the improvement and optimization of intelligent algorithms. This multi-indicator-driven testing method not only improves the efficiency of testing, but also significantly enhances the security and reliability of intelligent algorithms. It is particularly suitable for high-risk application scenarios such as autonomous driving, medical diagnosis, and task verification of large language intelligent algorithms.
[0043] In general, the present invention not only innovatively solves the limitation of insufficient single coverage by organically combining coverage indicators of multiple granularities, but also realizes a more efficient and comprehensive intelligent algorithm testing method, providing a new solution for the security verification and optimization of intelligent algorithms, which has important research value and broad application prospects.
[0044] In order to more clearly demonstrate the technical solution and technical effects provided by the present invention, the method provided by the embodiment of the present invention is described in detail with reference to specific embodiments below.
[0045] Considering the significant limitations of existing single coverage indicators and their test sample generation technologies, these indicators are usually difficult to fully reflect the complex behavior of neural networks, resulting in limited test sample quality, especially in discovering key weaknesses of intelligent algorithms and optimizing security. Therefore, it is urgent to develop a testing method based on multi-granularity coverage indicators to make up for the shortcomings of a single indicator and improve testing efficiency.
[0046] To this end, the embodiment of the present invention provides an intelligent algorithm testing method based on multi-granularity neural network coverage, which aims to generate high-quality test samples through the synergy of multi-granularity coverage indicators to achieve more efficient and comprehensive testing. Figure 1 The two core parts of the process shown are introduced in detail. One part is the coverage evaluation of multi-granularity coverage indicators, which is used to verify the effectiveness of different granularity coverage indicators on intelligent algorithms and clarify the ability of data sets to capture the behavioral characteristics of intelligent algorithms; the other part is high-quality sample generation, which uses these coverage indicators to generate test samples that are both diverse and targeted, helping intelligent algorithms to discover more potential erroneous behaviors or abnormal decisions, and improving the security and reliability of intelligent algorithms. This invention fills the gaps in existing coverage indicator testing methods and provides a theoretical basis and technical support for intelligent algorithm testing.
[0047] 1. Coverage evaluation of multi-granularity coverage indicators.
[0048] like Figure 2As shown in the figure, the evaluation process of multi-granularity coverage indicators of intelligent algorithms is demonstrated. First, prepare an appropriate data set and perform preprocessing to ensure that it can be used for testing; then, construct coverage indicators of different granularities, including single neuron granularity, horizontal neuron combination granularity, and vertical neuron combination granularity, to comprehensively evaluate the performance of intelligent algorithms at different levels; then, through reasoning, collect behavioral characteristics and calculate coverage, and analyze the performance of data sets under different coverage indicators; then, by analyzing the ability of different data sets to capture the behavioral characteristics of intelligent algorithms, evaluate the effectiveness of test data and identify test blind spots; finally, propose improvement suggestions based on the analysis results, optimize the intelligent algorithm and re-verify its performance. This method not only lays a theoretical foundation for the testing of intelligent algorithms, but also provides a clear direction for the optimization of intelligent algorithms.
[0049] 1. Determination of intelligent algorithms and data sets.
[0050] The selection of intelligent algorithms is the starting point of testing, and the appropriate target model should be determined based on the actual application scenarios and task requirements. Common intelligent algorithms include convolutional neural networks for image tasks, recurrent neural networks for sequence processing, and Transformer (transformer neural network) models based on self-attention mechanisms that have been widely used in multi-domain tasks in recent years. The design and training of these models are usually based on the characteristics of different tasks, such as classification, prediction, translation, etc., so it is necessary to ensure that the test target model can cover the main application directions of current research. When selecting intelligent algorithms, the complexity, application scope and task scenarios of the model should be considered. For example, for image recognition tasks, structures such as ResNet (residual network), VGG (visual geometry group network) or EfficientNet (efficient convolutional network) can be selected as test objects; for natural language processing tasks, language models such as BERT (bidirectional encoding representation from Transformer), GPT (generative pre-training model) or T5 (text to text model) can be selected. In multimodal tasks such as autonomous driving, it may be necessary to select deep learning models that integrate multiple perception capabilities. The characteristics of these intelligent algorithms determine the focus and difficulty of testing. The selection of the data set to be tested is also crucial. The test dataset should represent the diverse data distribution in real application scenarios and be challenging. The dataset usually contains a large number of input-output pairs, each of which can trigger a specific behavior pattern of the model.
[0051] 2. Calculation of single neuron coverage index.
[0052] The single neuron coverage index is the most basic coverage measurement method, which is used to evaluate the activation of each single neuron in the intelligent algorithm under a specific input data set. This coverage index reflects the fine-grained response ability of the intelligent algorithm to the input data, thereby revealing the basic behavioral characteristics of the intelligent algorithm. By counting the activation state of a single neuron on the data set, its coverage can be obtained, and the universality and robustness of the intelligent algorithm can be further analyzed. In the neural network model, the neuron is the smallest computing unit, and the activation value of each neuron is the result of the linear combination of its input weight and bias calculated by a nonlinear activation function. The single neuron coverage index aims to quantify how many neurons are activated in the intelligent algorithm under a specific input, that is, to measure whether the activation state of the neuron exceeds a preset threshold.
[0053] ; in, represents the total number of neurons, For neurons The activation value of Indicates the threshold for activation. The specific process is as follows: first, traverse the database, load and input the test samples into the intelligent algorithm in sequence. For each input sample, the processing of the intelligent algorithm will activate the neurons in the network layer by layer, and the activation behavior of these neurons needs to be recorded in detail. Specifically, in each layer of the network, the activation values of all neurons are recorded in real time, and a predefined activation threshold is set to determine whether the neuron is activated. For neurons whose activation values exceed the threshold, their number is counted and marked as valid activated neurons. After completing the input and statistics of all samples, the coverage of the network is calculated based on the recorded data. The definition of coverage is: the ratio of the number of activated neurons to the total number of neurons in the network, which is used to evaluate the degree of exploration of the intelligent algorithm structure by the test sample. Through this process, not only can we intuitively understand the coverage performance of the sample, but also provide data support for optimizing test sample generation and intelligent algorithm verification.
[0054] 3. Calculation of lateral neuron combination coverage index.
[0055] The lateral neuron combination coverage index is designed to analyze the activation patterns between neurons in the same layer. This coverage index reveals the behavioral characteristics of the intelligent algorithm in the interaction of neurons in the same layer by counting the coverage of different combination activation patterns. It is suitable for analyzing the synergy and complex activation patterns of a single layer.
[0056] ; in, is the set of combined activations of all fired neurons, is the set of combined activations of all layer neurons, symbol Represents the number of elements in a set. This indicator measures the coverage of the test data set on the activation patterns of neuron combinations in a specific layer. Furthermore, the activation state vector of each input sample is regarded as an independent combination pattern, and the combinations of all samples are recorded and counted. These activation state combinations can not only reflect the activation of the network by a single sample, but also calculate the coverage of the combination by horizontally comparing the activation patterns of different samples, that is, recording the proportion of the number of triggered activation combinations to the total number of possible combinations. Through this indicator, the breadth and depth of the test sample's exploration of neuron combination interactions in the target network layer can be evaluated.
[0057] In addition, by counting the distribution characteristics of these activation state combinations, we can further discover the untriggered combination patterns in the dataset and locate specific combination areas that are not fully activated. These untriggered areas usually represent the unexplored space of the network in this layer, providing a clear optimization direction for the generation of subsequent test samples, such as activating these uncovered combinations by designing more diverse input samples.
[0058] The calculation method and application scope of the combination coverage are relatively wide, and can be flexibly applied to different types of neural network structures, including fully connected networks, convolutional networks, and networks based on attention mechanisms. For fully connected networks, simple linear combinations between nodes can be captured; for convolutional networks, complex associations between convolution kernels and feature maps can be mined; for networks based on attention mechanisms, dynamic changes in attention weights under different inputs can be revealed. This analysis method is of great significance in the testing and optimization of complex intelligent algorithms, and can effectively improve the robustness and coverage of intelligent algorithms.
[0059] 4. Calculation of vertical neuron combination coverage index.
[0060] The vertical neuron combination coverage index is used to analyze the neuron activation paths across layers in a neural network, aiming to capture the collaborative behavior of neurons across multiple layers. Unlike horizontal neuron coverage, the vertical coverage index focuses on the combination of activation states across layers, which can more comprehensively characterize the global behavior characteristics of the network, especially the complex patterns in deep networks.
[0061] ; in, is the set of combined activations of all fired neurons across layers, is the set of combined activations of all neurons across layers, symbol Indicates the number of elements in a collection.
[0062] Similar to the calculation method of horizontal combination coverage, vertical coverage is also based on combination statistics and coverage calculation, but its focus extends from single-layer combination patterns to paths across multiple layers. In deep neural networks, each cross-layer combination can be regarded as a path, which is composed of the states of activated neurons in different layers and can reflect the layer-by-layer information transmission and interaction patterns from input to output. The core of vertical coverage is to capture the co-activation behavior between layers in deep networks. The vertical coverage can be calculated by counting the number of cross-layer paths triggered by all test samples and comparing it with the total number of theoretically possible paths. This indicator can not only reveal the distribution of inter-layer dependencies in deep neural networks, but also analyze the co-activation efficiency of intelligent algorithms between different levels, revealing the network's potential redundant connections or underutilized feature paths. By analyzing these cross-layer paths, it is possible to evaluate whether there are test blind spots in the data set. If most of the potential paths are not triggered, it means that the test sample coverage is limited and the global behavior of the intelligent algorithm is not fully explored. This finding is of great significance for optimizing test sample generation, which can guide the design of more diverse and challenging input data, trigger more potential cross-layer paths, and thus improve the comprehensiveness of testing.
[0063] In the above process, the test samples input into the intelligent algorithm are the seeds selected from the seed library. At the same time, diversified test samples are continuously generated based on the evaluation results to update the seed library. This process will be introduced in the next section.
[0064] 2. High-quality sample generation.
[0065] like Figure 3 As shown in the figure, the high-quality sample generation process guided by coverage indicators is demonstrated. By analyzing the coverage results, the test blind spots are located, and the behavioral characteristics of the intelligent algorithm are combined to generate new samples that can fill the coverage gap. First, the coverage indicators are defined and the coverage of the existing data set is evaluated; then, a scalable seed selection strategy is designed based on the coverage blind spots, and then targeted samples are generated through the metamorphosis strategy; finally, the samples are added to the test set to verify their improvement effect on coverage and intelligent algorithm performance, and the generation strategy is iteratively optimized. This process effectively improves the test coverage and the robustness of the intelligent algorithm, providing reliable support for the evaluation of intelligent algorithms.
[0066] In this section, coverage analysis is carried out by designing a reasonable seed selection strategy. This process aims to evaluate the quality of generated samples, optimize the generation mechanism based on this, promote the generation of new samples, and thus improve the comprehensiveness and effectiveness of the test.
[0067] 1. Scalable seed selection strategy.
[0068] In order to improve the efficiency and coverage of fuzz testing, a scalable seed selection strategy is designed, which can dynamically adjust the scheduling of test seeds to adapt to different types of neural networks and their complex application scenarios. By intelligently optimizing the selection and scheduling of seeds, this strategy can effectively improve the comprehensiveness and effectiveness of the test. The core of this strategy lies in three key technologies: progress awareness, random sorting, and frequency awareness: (1) Progress awareness: Dynamically adjust the seed selection strategy according to the test progress, give priority to seeds that can trigger new semantic features or cover unexplored areas at the current stage, ensure that the test process is balanced and efficient, and avoid resource waste; (2) Random sorting: Introduce random perturbation sorting in the candidate seed set to break the fixed selection mode, prevent local convergence of the test path, and improve the diversity of test inputs, thereby enhancing the ability to explore potential defects in neural networks; (3) Frequency awareness: Based on the historical frequency information of test execution, dynamically adjust the priority of seeds to avoid the reuse of inefficient seeds, and reasonably control the selection of high-frequency seeds to maximize test coverage and the ability to discover potential vulnerabilities. The specific selection and scheduling strategies are as follows:
[0069] First, define , and Respectively represent the coverage index of horizontal neuron combination, vertical neuron combination and single neuron (i.e. the aforementioned , , ). Given a seed library, where a single seed is denoted as s, which corresponds to a test sample, and Z is the target coverage area. On the three granularity coverage indicators, let represents the set of semantic paths covered by seed s, any of which is denoted as ;make Represents a set of abstract semantic paths covering the target area Z, where any path is denoted as ; For the path With path , its similarity It can be calculated as: ; in, and is a constant and ; For any and , which can produce three sets , and , expressed as: , and ; Scheduling impact factor for each seed s based on path similarity (Impact Factor) It can be defined as: ; in, Indicates the number of elements in the corresponding set, for example, Representing a collection The number of elements.
[0070] Taking the horizontal neuron combination coverage index as an example, the maximum and minimum historical coverage rates in the target coverage area are recorded as and , the current coverage rate of seed s in the target coverage area is recorded as , then the distance from the seed file s to the target coverage area Z It can be calculated as: ; The maximum and minimum values of the historical coverage in the above target coverage area take into account the seeds in the entire seed library (the seeds in the initial seed library will undergo a multi-granular neuron coverage index calculation), and the current coverage It mainly refers to the coverage of the lateral neuron combination coverage index of seed s in the target coverage area.
[0071] According to the above calculation steps, the distance from seed s to the target coverage area Z is calculated based on the longitudinal neuron combination and single neuron coverage indicators. and , and finally the comprehensive distance on the three granular neuron coverage indicators for: ; Among them, the coefficient , , The accuracy and effectiveness of the coverage indicators at each level need to be judged and regulated through the running results of the fuzzy test design layer. This topic will further study how to learn the optimal parameter configuration for multi-level distance functions.
[0072] In the embodiment of the present invention, the set of semantic paths covered by seed s is a general term in the field of intelligent algorithm testing, which mainly describes a set of processing steps or decision paths triggered by seed s when testing an intelligent algorithm. These steps or paths correspond to all possible situations or a part of the state space that the intelligent algorithm needs to cover; taking a single semantic path as an example, it includes but is not limited to: which nodes (or neurons) can be activated by seed s, which paths or channels the seed s passes through in different layers of the network, etc. Similarly, the target coverage area is a general term in the field of intelligent algorithm testing, which can be understood as all possible situations or parts of the state space that need to be covered when solving a problem. In simple terms, it refers to all different types of input data and their corresponding output result ranges that the intelligent algorithm should be able to touch when processing data. The abstract semantic path set it involves also has a similar meaning, so it will not be repeated.
[0073] Given a seed bank and the target coverage area Z, m is the number of seeds. In addition to the path-based seed scheduling influencing factors, the present invention also considers seed diversity and proximity. During the scheduling process, a minimum scheduling probability is assigned to each seed. , according to the scheduling times of seed s Calculate scheduling impact factors based on diversity and proximity , expressed as: ; Among them, the parameters Used to limit the rate at which scheduling probability decreases.
[0074] All seeds in the seed bank are calculated based on the above method to calculate the comprehensive distance and the scheduling impact factor based on diversity and proximity, and the product of the two is calculated (i.e. ), get the comprehensive score of the seeds, select the seeds based on the comprehensive score of the seeds, and generally select a specified number of seeds with the highest comprehensive scores.
[0075] The above seed selection strategy can achieve two key goals: one is to improve the overall value of multi-level coverage indicators, and the other is to locate more potential defective modules of neural networks.
[0076] 2. Transformation strategy.
[0077] After completing the seed selection, the target sample is determined. Then the mutation operation is performed on the sample using the metamorphosis strategy. A new set of mutated samples is generated by making small modifications (i.e. mutations) to the selected seeds. These mutated samples can simulate potential program errors or defects and help the test system discover untouched vulnerabilities. Mutation operations usually involve modifying specific parts of the input data, such as numerical changes, character replacements, logical adjustments, etc., to generate a series of test cases with different characteristics. These metamorphosis relationships can generate a variety of new test samples based on existing seed samples by adding perturbations or performing mutation operations, thereby exploring more model behavior space.
[0078] 3. Multi-granularity coverage indicator analysis.
[0079] After generating new test samples, we analyze their coverage and calculate the multi-granular neuron coverage index. That is, we input the new test samples into the intelligent algorithm and evaluate them according to the scheme in the first part. By comparing the multi-granular neuron coverage index, we select the test samples that can significantly improve the coverage and add them to the seed library. This incremental update mechanism can ensure the dynamic optimization of the seed library, so that each round of sample generation can further expand the model test space.
[0080] Based on the introduction in the above two parts, the test is continuously repeated until the preset termination condition is reached (for example, the test time is exceeded or the coverage index converges). This cyclic process can not only continuously improve the comprehensiveness of the test, but also efficiently locate the potential defect areas of the model. Through this dynamic iterative method, the test process achieves continuous optimization of the seed library and efficient generation of test samples, providing strong support for the robustness and defect discovery of deep neural networks.
[0081] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above embodiments can be implemented by software, or by means of software plus necessary general hardware platforms. Based on such understanding, the technical solutions of the above embodiments can be embodied in the form of software products, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0082] Embodiment 2 The present invention also provides an intelligent algorithm testing system, which is mainly used to implement the method provided in the above embodiment, such as Figure 4 As shown, the system mainly includes: The intelligent algorithm and test data selection and indicator definition unit is used to select the target intelligent model that meets the actual application scenario as the intelligent algorithm to be tested, collect the corresponding test data set, screen out test samples from the test data set as seeds to form a seed library, and define the multi-granularity neuron coverage indicators during the test; A multi-granularity neuron coverage index calculation unit is used to calculate the comprehensive score of the seed based on the comprehensive distance of the seed on the multi-granularity neuron coverage index and the scheduling influence factor based on diversity and proximity, select the seed from the seed library based on the comprehensive score of the seed, and generate a new test sample through the metamorphosis strategy, and then input it into the intelligent algorithm to be tested for testing, and calculate the multi-granularity neuron coverage index; A test sample screening unit is used to screen out a part of new test samples by combining the calculated multi-granularity neuron coverage index; The iterative test unit is used to add the screened new test samples to the seed library, and perform iterative testing through the multi-granularity neuron coverage index calculation unit and test sample screening until the set test termination conditions are met.
[0083] Considering that the specific technical details involved in the above system have been introduced in detail in the previous embodiments, they will not be repeated here.
[0084] Technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the system can be divided into different functional modules to complete all or part of the functions described above.
[0085] Embodiment 3 The present invention also provides a processing device, such as Figure 5 As shown, it mainly includes: one or more processors; a memory for storing one or more programs; wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the methods provided by the aforementioned embodiments.
[0086] Furthermore, the processing device also includes at least one input device and at least one output device; in the processing device, the processor, memory, input device, and output device are connected via a bus.
[0087] In the embodiment of the present invention, the specific types of the memory, input device and output device are not limited; for example: The input device may be a touch screen, an image acquisition device, a physical button or a mouse, etc.; The output device may be a display terminal; The memory may be a random access memory (RAM) or a non-volatile memory such as a disk storage.
[0088] Embodiment 4 The present invention also provides a readable storage medium storing a computer program, which implements the method provided in the above embodiment when the computer program is executed by a processor.
[0089] In the embodiment of the present invention, the readable storage medium as a computer-readable storage medium can be set in the aforementioned processing device, for example, as a memory in the processing device. In addition, the readable storage medium can also be a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk, etc., which can store program codes.
[0090] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed in the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims. The information disclosed in the background technology section of this article is only intended to deepen the understanding of the overall background technology of the present invention, and should not be regarded as an admission or in any form that the information constitutes prior art known to those skilled in the art.
Claims
1. An intelligent algorithm testing method, characterized in that: include: Step 1: Select the target intelligent model that meets the actual application scenario as the intelligent algorithm to be tested, collect the corresponding test data set, select the test samples from the test data set as seeds, form a seed library, and define the multi-granularity neuron coverage indicators during the test; Step 2: Calculate the comprehensive score of the seed based on the comprehensive distance of the seed on the multi-granularity neuron coverage index and the scheduling impact factor based on diversity and proximity. Select the seed from the seed library based on the comprehensive score of the seed, generate a new test sample through the metamorphosis strategy, and then input it into the intelligent algorithm to be tested for testing, and calculate the multi-granularity neuron coverage index; Step 3: Combine the calculated multi-granularity neuron coverage index to select a part of new test samples; Step 4: Add the selected new test samples to the seed library and go to step 2; continue to iterate until the set test termination condition is met.
2. The intelligent algorithm testing method according to claim 1, characterized in that: The comprehensive score of the seed is calculated based on the comprehensive distance of the seed on the multi-granular neuron coverage index and the scheduling impact factor based on diversity and proximity, and the seed is selected from the seed library based on the comprehensive score of the seed, including: Given a seed library, where a single seed is denoted as s, corresponding to a test sample, and a target coverage area Z during the test; let represents the set of semantic paths covered by seed s, any of which is denoted as ;make Represents a set of abstract semantic paths covering the target area Z, where any path is denoted as ; According to the path With path The similarity of the seed s is used to calculate the scheduling impact factor of the seed s based on the path similarity, and then combined with the coverage rate of the seed s on each multi-granularity neuron coverage index, the comprehensive distance of the seed s on the multi-granularity neuron coverage index is calculated. ; Combine the minimum scheduling probability of the pre-assigned seed s and the number of scheduling of seed s to calculate the scheduling influence factor of seed s based on diversity and proximity ; By calculation , get the comprehensive score of seed s; the comprehensive scores of other seeds are calculated in the same way; A portion of seeds are selected from the seed bank based on their comprehensive scores.
3. The intelligent algorithm testing method according to claim 2, characterized in that: The calculation seed s comprehensive distance on the multi-granularity neuron coverage index include: Calculate Path With path Similarity , expressed as: ; in, and is a constant and ; For any and , which can produce three sets , and , expressed as: , and ; Then the scheduling impact factor of each seed s based on path similarity is Defined as: ; in, Indicates the number of elements in the corresponding set; The definition of multi-granular neuron coverage indicators includes: single neuron coverage indicator, horizontal neuron combination coverage indicator and vertical neuron combination coverage indicator; for the horizontal neuron combination coverage indicator, the maximum and minimum values of the historical coverage rate in the target coverage area are recorded as and , the current coverage rate of seed s in the target coverage area is recorded as , then the distance from the seed file s to the target coverage area Z for: ; Based on the longitudinal neuron combination coverage index and single neuron coverage index, the distance from seed s to the target coverage area Z is calculated as and , the comprehensive distance of seed s on the multi-granularity neuron coverage index is calculated by the following formula : ; in, , , are three coefficients.
4. The intelligent algorithm testing method according to claim 1, characterized in that: The multi-granularity neuron coverage index includes: a single neuron granularity coverage index, a horizontal neuron combination coverage index and a vertical neuron combination coverage index; the single neuron granularity coverage index is the coverage rate of activated neurons; the horizontal neuron combination coverage index is the coverage rate of triggered neuron combination activations in the same layer; the vertical neuron combination coverage index is the coverage rate of triggered neuron combination activations in different layers.
5. The intelligent algorithm testing method according to claim 4, characterized in that: The calculation method of the coverage of activated neurons includes: Calculate the ratio of activated neurons to the total number of neurons, expressed as: ; in, is the ratio of activated neurons to the total number of neurons, is the set of all neurons; For collection The number of elements of , that is, the total number of neurons; For neurons The activation value of is the threshold value; is the indicator function, when the condition is met , the output is 1, otherwise the output is 0.
6. The intelligent algorithm testing method according to claim 4, characterized in that: The coverage of combined activations of triggered neurons in the same layer is calculated as follows: For each layer, count the number of activated neuron combinations separately, summarize the number of activated neuron combinations of all layers, and count the number of triggered neuron combinations to obtain the number of all triggered neuron combinations activated; calculate the ratio of the number of all triggered neuron combinations activated to the number of activated combinations of all layers , as the coverage of the combined activation of triggered neurons in the same layer, is expressed as: ; in, is the set of combined activations of all fired neurons, is the set of combined activations of all layer neurons, symbol Indicates the number of elements in a collection.
7. The intelligent algorithm testing method according to claim 4, characterized in that: The coverage of combined activations of triggered neurons in different layers is calculated as follows: Count the number of cross-layer neuron combination activations, summarize the number of all cross-layer neuron combination activations, count the number of all triggered cross-layer neuron combination activations, and calculate the ratio of the number of all triggered cross-layer neuron combination activations to the number of all cross-layer neuron combination activations. As the coverage of combined activations of triggered neurons in different layers, it is expressed as: ; in, is the set of combined activations of all fired neurons across layers, is the set of combined activations of all neurons across layers, symbol Indicates the number of elements in a collection.
8. An intelligent algorithm testing system, characterized in that: include: The intelligent algorithm and test data selection and indicator definition unit is used to select the target intelligent model that meets the actual application scenario as the intelligent algorithm to be tested, collect the corresponding test data set, screen out test samples from the test data set as seeds to form a seed library, and define the multi-granularity neuron coverage indicators during the test; A multi-granularity neuron coverage index calculation unit is used to calculate the comprehensive score of the seed based on the comprehensive distance of the seed on the multi-granularity neuron coverage index and the scheduling influence factor based on diversity and proximity, select the seed from the seed library based on the comprehensive score of the seed, and generate a new test sample through the metamorphosis strategy, and then input it into the intelligent algorithm to be tested for testing, and calculate the multi-granularity neuron coverage index; A test sample screening unit is used to screen out a part of new test samples by combining the calculated multi-granularity neuron coverage index; The iterative test unit is used to add the screened new test samples to the seed library, and perform iterative testing through the multi-granularity neuron coverage index calculation unit and test sample screening until the set test termination conditions are met.
9. A processing device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Deep neural network fuzzy test framework based on TensorFuzz and T deep neural network fuzzy test method based on TensorFuzz
CN111897729A
Model optimization method and device, computer equipment and storage medium
CN116306887A
Automatic test case generation method for fuzzy test of deep neural network
CN117093496A
Neural pathway coverage rate analysis system based on key neuron identification
CN117909209A
Large language model fuzzy test sample generation method and system based on coverage index
CN118363866A