Black-box speech adversarial sample generation method based on enhanced neural predictor
The enhanced neural predictor-based method optimizes the search process for black-box speech adversarial samples by decomposing perturbations and using dynamic strategies, addressing inefficiencies in existing methods and achieving effective, stealthy attacks on ASR models.
Patent Information
- Application Number
- CN202411204364.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-08-30
AI Technical Summary
Existing black-box speech adversarial attack methods are inefficient, time-consuming, and require excessive queries due to complex training processes and high computing resource requirements, while maintaining the concealment of attacks is challenging.
A method using an enhanced neural predictor to generate black-box speech adversarial samples by decomposing perturbations into direction vectors and scalars, employing a coarse-grained and binary search, and optimizing the search process with dynamic step sizes and pruning strategies to efficiently find minimal perturbations.
The method efficiently determines the optimal disturbance direction vector, reducing search space and computational cost, ensuring effective and stealthy adversarial attacks on ASR models.
Smart Images

Figure CN118737130B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and in particular relates to a method for generating black-box speech adversarial samples based on an enhanced neural predictor. Background Art
[0002] In recent years, the research on speech adversarial sample generation methods has attracted much attention from academia and industry. How to design and generate speech adversarial samples with small perturbations remains a challenging task. Existing speech adversarial attack methods, such as those based on generative adversarial networks, perform well in learning speech features, but face complex training processes and high computing resource requirements; transfer-based methods generate adversarial samples on a known model and then apply them to the target black-box model, which is easy to operate but has limited success rate; genetic algorithm-based generation methods do not rely on gradient information and have strong search capabilities in global optimization problems, but converge slowly and require multiple searches. Existing black-box attack methods usually require a large number of queries to find effective attacks, which makes the attack process time-consuming and inefficient. It is a challenge to achieve efficient attacks while maintaining the concealment of attacks. It is difficult to achieve effective attacks without significantly changing the input samples. Summary of the invention
[0003] The purpose of the present invention is to provide a black-box speech counterattack method based on an enhanced neural predictor, which solves the problems of complex and inefficient search process and excessive generated disturbance in the prior art.
[0004] The technical solution adopted by the present invention is a method for generating black-box speech adversarial samples based on an enhanced neural predictor, which specifically includes the following steps:
[0005] Step 1: For Audio x Randomly generate n disturbance direction vectors , i=1,2…,n, for the disturbance direction vector Search and query using the ASR model to determine the minimum perturbation that causes the ASR model to misidentify, generating a dataset D;
[0006] Step 2: Design an enhanced neural predictor;
[0007] Step 3: Use dataset D to train the enhanced neural predictor to find the new optimal perturbation direction vector ;
[0008] Step 4: For the new optimal perturbation direction vector Use the optimized search process to search and use the ASR model query to determine the minimum perturbation that causes the ASR model to misidentify, thereby obtaining new samples and adding them to the dataset D;
[0009] Step 5: Repeat steps 3 and 4 until the query limit or perturbation threshold is reached and adversarial examples are found.
[0010] The present invention is also characterized in that:
[0011] The specific process in step 1 is as follows:
[0012] The perturbation is decomposed into a perturbation direction vector and a scalar, expressed as follows:
[0013] (2)
[0014] In the formula, represents disturbance, represents the disturbance direction vector, represents the disturbance direction vector The module length, Represents the distance from the audio to the decision boundary along the perturbation direction;
[0015] First, a coarse-grained search is performed to find the range of perturbations that cause the ASR model to misidentify:
[0016] Apply a coarse-grained algorithm to search, specifically: for the disturbance direction vector , set the step size , the coarse-grained search is performed by querying the sequence of points one by one Until the perturbation range that causes the ASR model to misidentify is found , j Indicates j Step length;
[0017] Secondly, the perturbation range determined by coarse-grained search Within, a binary search method is used to perform an exact search to find the minimum perturbation that the ASR model misrecognizes;
[0018] Thus, a series of sample pairs are obtained , generate a dataset .
[0019] The specific structure of the enhanced neural predictor designed in step 2 includes: a Normalize layer for normalizing the input data; the output of the Normalize layer is connected to the Mel-frequency spectrum layer for converting the audio waveform spectrum data obtained after short-time Fourier transform processing into Mel-frequency cepstrum coefficients to extract speech features; the output of the Mel-frequency spectrum layer is connected to a convolution layer for compressing the number of channels to 32; the output of the convolution layer is connected to four self-attention convolution blocks in sequence, each of which includes a LeakyReLU activation function, a convolution layer, and an average pooling layer with a kernel size of 2; the output of the last self-attention convolution block is connected to the global average pooling layer for eliminating the remaining time dimension; the output of the global average pooling layer is connected to the linear layer.
[0020] Step 3: The specific process is as follows:
[0021] Step 3.1: Use the dataset Train the enhanced neural predictor, expressed as follows:
[0022] (5)
[0023] Where: represents the enhanced neural predictor, Denoted as training parameters, represents the optimal parameters obtained through training, represents the disturbance direction vector In the parameters The impact on It means taking the parameters that make the objective function reach the optimal value;
[0024] Step 3.2: Freeze , find the new optimal perturbation direction :
[0025] (6).
[0026] During the training of the designed enhanced neural predictor, the mean square error loss function is adopted, which is expressed as:
[0027] (7)
[0028] In the formula, L represents the mean square error loss function, m is the total number of speech samples, It is k The actual value of the speech samples, For the k The predicted value of a speech sample.
[0029] The optimized search process in step 4 is to optimize the coarse-grained search algorithm and the binary search method, specifically:
[0030] For the coarse-grained search algorithm, a dynamic step-size strategy is introduced. The dynamic step-size strategy is based on the distance function The gradient information is used to adjust the step size, and the formula is expressed as:
[0031] (8)
[0032] In the formula, represents the distance between the current disturbance and the minimum disturbance, represents the minimum distance found, represents the disturbance direction vector The L2 norm of For the preset perturbation distance threshold of the adversarial sample, the step size update rule can be expressed as:
[0033] (9)
[0034] In the formula, represents the current disturbance direction vector, represents the step size adjustment function, >1 is the step size increase factor, when hour, The function value is 1, otherwise -1;
[0035] The pruning strategy is introduced for the binary search method. The pruning strategy formula is as follows:
[0036] (10)
[0037] In the formula, is the objective function, which represents the influence of the disturbance direction vector on the model. and are the lower and upper bounds of the perturbation direction vector range, u is the preset upper threshold of the distance to the decision boundary;
[0038] Pruning function , mapping the parameter vector to a pruned parameter subset, the update step can be expressed as:
[0039] (11)
[0040] In the formula, represents the new perturbation direction vector; is the learning rate, set to a constant; Represents the gradient of pruning.
[0041] The beneficial effects of the present invention are:
[0042] 1. The present invention designs an enhanced neural predictor based on a black-box speech adversarial sample generation method of an enhanced neural predictor, which can predict the optimal disturbance direction vector.
[0043] 2. The black-box speech adversarial sample generation method based on the enhanced neural predictor in this invention designs a pruning strategy for the search algorithm, which efficiently determines the minimum distance between the perturbed sample and the decision boundary, and quickly excludes samples that are too far from the boundary, thereby reducing the search space. This strategy improves the efficiency and accuracy of finding adversarial samples in adversarial attacks.
[0044] 3. The black-box speech adversarial sample generation method based on the enhanced neural predictor of the present invention introduces a dynamic step size strategy. This method of dynamically adjusting the step size accelerates the search when discovering the direction of the adversarial sample and dynamically determines the step size to avoid excessive disturbances, while ensuring the concealment and effectiveness of the attack. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is a flowchart of the black-box speech adversarial sample generation method based on the enhanced neural predictor of the present invention. DETAILED DESCRIPTION
[0046] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0047] Black-box speech adversarial sample generation method based on enhanced neural predictor, such as Figure 1 As shown, the following steps are included:
[0048] Step 1: For Audio x Randomly generate n disturbance direction vectors , i=1,2…,n, for the disturbance direction vector A search is performed and queried using the ASR model to determine the minimum perturbation that causes the ASR model to misidentify, generating a dataset D.
[0049] The ASR (Automatic Speech Recognition) model is an end-to-end transformer-based ASR model for SpeechBrain, which is trained on the LibriSpeech dataset. It supports a variety of speech tasks, including speech recognition, speech synthesis, speaker recognition, and speech conversion, and provides a series of pre-trained models and tools to support the latest deep learning technologies and algorithms. By using the PyTorch framework, SpeechBrain ensures high performance and flexibility while simplifying the model training and deployment process.
[0050] Consider the trained black-box ASR model as a function , for the function Input Audio Mapping to text records , the goal is to obtain a perturbation vector , which causes the ASR model to misinterpret the input audio, expressed as:
[0051] (1)
[0052] In the formula, Indicates the degree of perception norm; Represents disturbance Dimensions;
[0053] Due to the lack of information about functions It is difficult to directly optimize the minimum norm of formula (1) based on the knowledge of Decomposed into a perturbation direction vector and a size scalar ,Right now (2)
[0054] In the formula, represents disturbance, represents the disturbance direction vector, represents the disturbance direction vector The module length, Represents the distance from the audio to the decision boundary along the perturbation direction; thus, given a perturbation direction vector , from audio To the vector along the perturbation direction The minimum decision boundary distance is defined as:
[0055] (3)
[0056] In the formula, is the distance function, representing the audio To the vector along the perturbation direction The distance from the decision boundary, that is ;
[0057] Perturb the target from the query This is converted into obtaining the minimum distance from the audio along the disturbance direction to the decision boundary, so that the ASR model misinterprets the input audio, which is expressed as follows:
[0058] (4).
[0059] Formula (3) can explain the optimization problem in formula (1). First, the objective function is locally smooth and continuous, that is, Small changes in Secondly, simplify the above complex problem into searching for the direction vector , which is an unconstrained optimization, rather than searching for constrained perturbations Although the calculation formula (2) Corresponds to solving for This is another constrained optimization problem, but it only requires one degree of freedom, making the problem simpler.
[0060] For Audio x Randomly generate n disturbance direction vectors , i=1,2…,n, for the disturbance direction vector A search is performed and queried using the ASR model to determine the smallest perturbation that causes the ASR model to misidentify.
[0061] The search process is as follows:
[0062] First, a coarse-grained search is performed to find the range of perturbations that cause the ASR model to misidentify:
[0063] Apply a coarse-grained algorithm to search, specifically: set the step size , the coarse-grained search is performed by querying the sequence of points one by one Until the perturbation range that causes the ASR model to misidentify is found , j Indicates j Step length;
[0064] Secondly, the perturbation range determined by coarse-grained search Within, a binary search method is used to perform an exact search to find the minimum perturbation that the ASR model misrecognizes;
[0065] Thus, a series of sample pairs are obtained , generate a dataset .
[0066] Step 2: Design an enhanced neural predictor to predict the optimal perturbation direction vector;
[0067] The specific structure of the strong neural predictor includes: a Normalize layer for normalizing the input data; the output of the Normalize layer is connected to the Mel frequency spectrum layer for converting the audio waveform spectrum data obtained after short-time Fourier transform processing into Mel frequency cepstral coefficients to extract speech features; the output of the Mel frequency spectrum layer is connected to a convolution layer for compressing the number of channels to 32; the output of the convolution layer is connected to four self-attention convolution blocks in sequence, each of which includes a LeakyReLU activation function, a convolution layer, and an average pooling layer with a kernel size of 2; the output of the last self-attention convolution block is connected to the global average pooling layer for eliminating the remaining time dimension; the output of the global average pooling layer is connected to the linear layer.
[0068] First, the input is normalized to have units l ∞ -norm. To improve processing efficiency, the self-attention neural predictor is designed to accommodate input data of arbitrary length. To reduce the time dimension of the input data, short-time Fourier transform processing is used, where the fast Fourier transform size, window size, and step size are set to 1024, 1024, and 256, respectively. Subsequently, the obtained spectral data is converted into Mel-frequency cepstral coefficients to extract speech features. The processed data treats each frequency as an independent channel and compresses the number of channels to 32 through a one-dimensional convolution operation. In addition, the preprocessed signal is further passed through four convolution blocks to further reduce the time dimension. Each convolution block is activated with the LeakyReLU function and processed through an average pooling layer with a kernel size of 2. All convolution operations use a convolution kernel of size 3, and weight normalization is applied on all layers to maintain computational stability. A global average pooling layer is used to eliminate the remaining time dimension, and the prediction direction is output through a linear layer. To ensure the positivity of the output value, the linear layer is followed by an exponential activation function to ensure that the network output is always positive.
[0069] Step 3: Use dataset D to train the enhanced neural predictor to find the new optimal perturbation direction vector ;
[0070] Step 3.1: Use the dataset Train the enhanced neural predictor, expressed as follows:
[0071] (5)
[0072] Where: represents the enhanced neural predictor, Denoted as training parameters, represents the optimal parameters obtained through training, represents the disturbance direction vector In the parameters The impact on It means taking the parameters that make the objective function reach the optimal value;
[0073] Step 3.2: Freeze , find the preselected disturbance direction :
[0074] (6).
[0075] Add small perturbations to the original speech, which are almost imperceptible to the auditory sense, but are enough to cause the ASR system to produce incorrect recognition results. The mean square error loss function has strong processing capabilities when dealing with continuous numerical prediction problems, making it suitable for processing continuous, high-dimensional data such as speech signals, by quantifying and guiding the degree and direction of these perturbations to achieve the desired misleading effect. In addition, due to its high sensitivity to large errors, the mean square error loss function can effectively guide the optimization process of adversarial samples, ensuring that the generated adversarial samples can deviate from the correct classification boundary, which can be expressed as:
[0076] (7)
[0077] In the formula, L represents the mean square error loss function, m is the total number of speech samples, It is k The actual value of the speech samples, For the k The prediction value of a speech sample is highly detectable for outliers or abnormal values. In extreme cases, the generated adversarial samples deviate from the practical perturbation range and will be discarded. In addition, due to the complexity and multidimensionality of speech data, the use of this loss function requires careful parameter adjustment and iteration to generate effective adversarial samples.
[0078] To train the training parameter Q of the enhanced neural predictor, the Adam optimizer is used with a learning rate of 1e-4 and an exponential scheduler with a decay rate of 0.99. The batch size is set to 32 and the model is trained for 300 epochs.
[0079] Step 4: For the new optimal perturbation direction vector Use the optimized search process to search and use the ASR model query to determine the minimum perturbation that causes the ASR model to misidentify, thereby obtaining new samples and adding them to the dataset D;
[0080] In speech adversarial attacks, finding effective perturbations while keeping the perturbations as small as possible is a key goal. To this end, this paper proposes a dynamic step size strategy that effectively approaches the optimal solution by dynamically adjusting the perturbation step size. The strategy is based on a method of dynamically adjusting the perturbation step size to minimize the perturbation amplitude while ensuring the success of the attack. The initial step size is set to Dth and the maximum number of iterations i In each iteration, the step size is adjusted according to the impact of the current disturbance on the model, so as to gradually approach the minimum disturbance distance d min .
[0081] The dynamic step size strategy uses a dynamic adjustment mechanism that adjusts the distance function g ( i ) to adjust the step size. We define d( i ) is the distance between the current disturbance and the minimum disturbance, and d min is the minimum perturbation distance found. The adaptive step size strategy is adjusted by solving the following optimization problem:
[0082] (8)
[0083] In the formula, represents the distance between the current disturbance and the minimum disturbance, represents the minimum distance found, represents the disturbance direction vector The L2 norm of For the preset perturbation distance threshold of the adversarial sample, the step size update rule can be expressed as:
[0084] (9)
[0085] In the formula, represents the current disturbance direction vector, represents the step size adjustment function, >1 is the step size increase factor, when ≤ hour, The function value is 1, otherwise -1;
[0086] This way, the step size increases when approaching the target and decreases when moving away from the target.
[0087] The dynamic step-size strategy effectively balances the success rate of the attack and the minimization of the disturbance. By dynamically adjusting the disturbance step size, it can quickly adapt to the model's response and find the optimal disturbance range. Parameters such as the step-size adjustment factor can be adjusted according to the specific attack scenario to achieve the best performance. The adaptive disturbance strategy can effectively reduce the magnitude of the disturbance while ensuring the success of the attack.
[0088] In the study of adversarial attacks, finding the minimum perturbation that can effectively deceive machine learning models is a key challenge. In order to improve the search efficiency and reduce the computational cost, an improved pruning strategy is introduced to optimize the perturbation search process by implementing an early stopping mechanism and binary search. The core of the strategy is to add a maximum number of iterations to the traditional binary search method, aiming to prevent over-computation when the calculation is too complex. By gradually increasing the perturbation size, the initial perturbation range of the successful attack model is quickly located. After the range is determined, an accurate binary search method is performed within it to find the minimum successful perturbation amplitude.
[0089] The goal of the attack is to minimize the objective function f ( i ), which represents the attack disturbance direction vector i The impact on the model, we define the decision boundary distance function g ( i ) is used to estimate the distance from the current disturbance to the model decision boundary. The pruning strategy is defined by the following formula:
[0090] (10)
[0091] in, i lo and i hi are the lower and upper bounds of the perturbation direction vector range, u is the preset upper threshold of the distance to the decision boundary. The core of the strategy is to add a maximum number of iterations to the traditional binary search method. This limit prevents over-calculation in complex or computationally expensive situations. At the beginning of the strategy, by gradually increasing the perturbation size, a preliminary perturbation range that can successfully attack the model is quickly located. After determining this range, an accurate binary search is performed within it to find the minimum successful perturbation amplitude.
[0092] The goal of the pruning strategy is to update only those "important" parameters in each iteration, that is, those parameters that have the greatest impact on improving the objective function. Assume that P( i ) is a pruning function that maps the parameter vector to a pruned parameter subset, then the update step can be expressed as:
[0093] (11)
[0094] In the formula, represents the new perturbation direction vector; is the learning rate, set to a constant; Represents the gradient The present invention first defines an initial perturbation range and tests whether the perturbation is successful by increasing it. If a successful perturbation is found before reaching a predetermined upper limit or number of iterations, the increase is stopped. In the initial stage, we use the method of gradually increasing the perturbation amplitude to locate a possible attack success interval. The initial perturbation value is set to i 0 and increment by Δ i The goal of this stage is to find a perturbation value i hi , so that i hi is the first disturbance amplitude that leads to a successful attack. If i hi The search is terminated when the predetermined upper limit is reached or the number of iterations exceeds.
[0095] The pruning strategy designed in this application can effectively reduce the number of iterations required to find a successful perturbation while maintaining the effectiveness of the attack. To further optimize this strategy, we considered different parameter adjustments, including the maximum number of iterations and the perturbation increment. Reasonable setting of early stopping conditions and parameters can significantly improve the efficiency of the attack. By adjusting these parameters, an efficient search method can be provided for adversarial attacks for specific attack scenarios and model complexity, achieving more efficient search.
[0096] Step 5: Repeat steps 3 and 4 until the query limit or perturbation threshold is reached and adversarial examples are found.
[0097] In the process of generating adversarial samples, the search process is constrained by two factors: query limit and perturbation threshold. Specifically, when the number of queries reaches the preset upper limit, the search will automatically terminate. This query limit ensures that resources are not over-consumed within the limited number of queries. In addition, the perturbation threshold sets the maximum amount of perturbation allowed. If the perturbation found exceeds this threshold, it will not be accepted as a valid adversarial sample even if it can cause the model to transcribe incorrectly. Therefore, the size of the perturbation is constantly evaluated during the search process to ensure that it is within the threshold range. Finally, if the query limit or perturbation threshold is reached, the search will stop. This mechanism ensures the generation of high-quality adversarial samples that meet the perturbation limit within limited query resources, improving the practical applicability of the method.
[0098] Example 1
[0099] This embodiment provides a black-box speech adversarial sample generation method based on an enhanced neural predictor, such as Figure 1As shown, the specific steps include:
[0100] Step 1: For Audio x Randomly generate n disturbance direction vectors , i=1,2…,n, for the disturbance direction vector Search and query using the ASR model to determine the minimum perturbation that causes the ASR model to misidentify, generating a dataset D;
[0101] Step 2: Design an enhanced neural predictor;
[0102] Step 3: Use dataset D to train the enhanced neural predictor to find the new optimal perturbation direction vector ;
[0103] Step 4: For the new optimal perturbation direction vector Use the optimized search process to search and use the ASR model query to determine the minimum perturbation that causes the ASR model to misidentify, thereby obtaining new samples and adding them to the dataset D;
[0104] Step 5: Repeat steps 3 and 4 until the query limit or perturbation threshold is reached and adversarial examples are found.
[0105] Example 2
[0106] This embodiment provides a black-box speech adversarial sample generation method based on an enhanced neural predictor, such as Figure 1 As shown, the specific steps include:
[0107] Step 1: For Audio x Randomly generate n disturbance direction vectors , i=1,2…,n, for the disturbance direction vector Search and query using the ASR model to determine the minimum perturbation that causes the ASR model to misidentify, generating a dataset D;
[0108] The perturbation is decomposed into a perturbation direction vector and a scalar, expressed as follows:
[0109] (2)
[0110] In the formula, represents disturbance, represents the disturbance direction vector, represents the disturbance direction vector The module length, Represents the distance from the audio to the decision boundary along the perturbation direction;
[0111] First, a coarse-grained search is performed to find the range of perturbations that cause the ASR model to misidentify:
[0112] Apply a coarse-grained algorithm to search, specifically: for the disturbance direction vector , set the step size , the coarse-grained search is performed by querying the sequence of points one by one Until the perturbation range that causes the ASR model to misidentify is found , j Indicates j Step length;
[0113] Secondly, the perturbation range determined by coarse-grained search Within, a binary search method is used to perform an exact search to find the minimum perturbation that the ASR model misrecognizes;
[0114] Thus, a series of sample pairs are obtained , generate a dataset .
[0115] Step 2: Design an enhanced neural predictor;
[0116] The specific structure of the designed enhanced neural predictor includes: a Normalize layer, which is used to standardize the input data; the output of the Normalize layer is connected to the Mel-frequency spectrum layer, which is used to convert the audio waveform spectrum data obtained after short-time Fourier transform processing into Mel-frequency cepstral coefficients, thereby extracting speech features; the output of the Mel-frequency spectrum layer is connected to a convolutional layer, which is used to compress the number of channels to 32; the output of the convolutional layer is connected to four self-attention convolutional blocks in sequence, each of which includes a LeakyReLU activation function, a convolutional layer, and an average pooling layer with a kernel size of 2; the output of the last self-attention convolutional block is connected to the global average pooling layer, which is used to eliminate the remaining time dimension; the output of the global average pooling layer is connected to the linear layer.
[0117] Step 3: Use dataset D to train the enhanced neural predictor to find the new optimal perturbation direction vector ;
[0118] Step 4: For the new optimal perturbation direction vector Use the optimized search process to search and use the ASR model query to determine the minimum perturbation that causes the ASR model to misidentify, thereby obtaining new samples and adding them to the dataset D;
[0119] Step 5: Repeat steps 3 and 4 until the query limit or perturbation threshold is reached and adversarial examples are found.
[0120] Example 3
[0121] This embodiment provides a black-box speech adversarial sample generation method based on an enhanced neural predictor, such as Figure 1 As shown, the specific steps include:
[0122] Step 1: Randomly generate 100 perturbation direction vectors for the audio "hello world" , i=1,2…,100, for the disturbance direction vector Search and query using the ASR model to determine the minimum perturbation that causes the ASR model to misidentify, generating a dataset D;
[0123] The perturbation is decomposed into a perturbation direction vector and a scalar, expressed as follows:
[0124] (2)
[0125] In the formula, represents disturbance, represents the disturbance direction vector, represents the disturbance direction vector The module length, Represents the distance from the audio to the decision boundary along the perturbation direction;
[0126] First, a coarse-grained search is performed to find the range of perturbations that cause the ASR model to misidentify:
[0127] Apply a coarse-grained algorithm to search, specifically: for the disturbance direction vector , set the step size , the coarse-grained search is performed by querying the sequence of points one by one Until the perturbation range that causes the ASR model to misidentify is found , j Indicates j Step length;
[0128] Secondly, the perturbation range determined by coarse-grained search Within, a binary search method is used to perform an exact search to find the minimum perturbation that the ASR model misrecognizes;
[0129] Thus, a series of sample pairs are obtained , generate a dataset .
[0130] Step 2: Design an enhanced neural predictor;
[0131] The specific structure of the designed enhanced neural predictor includes: a Normalize layer, which is used to normalize the input data; the output of the Normalize layer is connected to the Mel-frequency spectrum layer, which is used to convert the audio waveform spectrum data obtained after short-time Fourier transform processing into Mel-frequency cepstral coefficients, so as to extract speech features; the output of the Mel-frequency spectrum layer is connected to a convolutional layer with a convolution kernel size of 3 and the number of channels gradually decreasing from 1024 to 32; the output of the convolutional layer is connected to four self-attention convolutional blocks in sequence, each of which includes a LeakyReLU activation function with a negative slope of 0.2, a 1D convolutional layer, an average pooling layer with a kernel size of 2, and a pooling window size of 2; the output of the last self-attention convolutional block is connected to a global average pooling layer to eliminate the remaining time dimension; the output of the global average pooling layer is connected to a linear layer.
[0132] Step 3: Use dataset D to train the enhanced neural predictor to find the new optimal perturbation direction vector ;
[0133] Step 3.1: Use the dataset Train the enhanced neural predictor, expressed as follows:
[0134] (5)
[0135] Where: represents the enhanced neural predictor, Denoted as training parameters, represents the optimal parameters obtained through training, represents the disturbance direction vector In the parameters The impact on It means taking the parameters that make the objective function reach the optimal value;
[0136] Step 3.2: Freeze , find the new optimal perturbation direction :
[0137] (6).
[0138] During the training of the designed enhanced neural predictor, the mean square error loss function is adopted, which is expressed as:
[0139] (7)
[0140] In the formula, L represents the mean square error loss function, m is the total number of speech samples, It is k The actual value of the speech samples, For thek The predicted value of a speech sample.
[0141] To train the training parameter Q of the enhanced neural predictor, the Adam optimizer is used with a learning rate of 1e-4 and an exponential scheduler with a decay rate of 0.99. The batch size is set to 32 and the model is trained for 300 epochs.
[0142] Step 4: For the new optimal perturbation direction vector Use the optimized search process to search and use the ASR model query to determine the minimum perturbation that causes the ASR model to misidentify, thereby obtaining new samples and adding them to the dataset D;
[0143] The optimized search process, that is, the optimization of the coarse-grained search algorithm and the binary search method, is as follows:
[0144] For the coarse-grained search algorithm, a dynamic step-size strategy is introduced. The dynamic step-size strategy is based on the distance function The gradient information is used to adjust the step size, and the formula is expressed as:
[0145] (8)
[0146] In the formula, represents the distance between the current disturbance and the minimum disturbance, represents the minimum distance found, represents the disturbance direction vector The L2 norm of For the preset perturbation distance threshold of the adversarial sample, the step size update rule can be expressed as:
[0147] (9)
[0148] In the formula, represents the current disturbance direction vector, represents the step size adjustment function, >1 is the step size increase factor, when hour, The function value is 1, otherwise -1;
[0149] After each iteration, the step size is dynamically adjusted based on the impact of the current disturbance on the model. If the disturbance is close to the decision boundary and is effective, the step size will increase by a dynamic factor of 1.1; if the disturbance deviates from the decision boundary, the step size will decrease by a dynamic factor of 0.9.
[0150] The pruning strategy is introduced for the binary search method. The pruning strategy formula is as follows:
[0151] (10)
[0152] In the formula, is the objective function, which represents the influence of the disturbance direction vector on the model. and are the lower and upper bounds of the perturbation direction vector range, u is the preset upper threshold of the distance to the decision boundary;
[0153] Pruning function , mapping the parameter vector to a pruned parameter subset, the update step can be expressed as:
[0154] (11)
[0155] In the formula, represents the new perturbation direction vector; is the learning rate, set to 1e-4; Represents the gradient of pruning.
[0156] Step 5: Repeat steps 3 and 4, and finally generate an adversarial sample "help word".
[0157] Simulation experiment:
[0158] Dataset: In order to evaluate the effectiveness of the attack method, samples are randomly selected from the clean test data of LibriSpeech to construct a dataset. These audio samples come from English audiobooks with a sampling rate of 16kHz. The dataset contains 1,000 hours of English speech, covering a wide range of topics and voices of many different people, and is widely used in the development and evaluation of automatic speech recognition systems.
[0159] Speech recognition model: The ASR model used is the end-to-end transformer-based ASR model in SpeechBrain, which is trained on the LibriSpeech dataset. It supports a variety of speech tasks, including speech recognition, speech synthesis, speaker recognition, and speech conversion, and provides a series of pre-trained models and tools to support the latest deep learning technologies and algorithms. By using the PyTorch framework, SpeechBrain ensures high performance and flexibility while simplifying the model training and deployment process.
[0160] During training, as the number of queries increases, the size of the perturbation will gradually decrease. Table 1 shows the parameters of the method training process. "Avg-min" refers to the average minimum distance predicted by the model after optimizing the query point, which means that the experiment has found the average input sample that minimizes the model prediction output. Finding the input that makes the model output as small as possible means that the adversarial attack is more likely to succeed. "Perb" is an indicator that measures the size of the perturbation in the adversarial attack, that is, the minimum amount of perturbation applied to the original audio sample. By reducing this value, the difference between the adversarial sample and the original sample can be made as small as possible, making it more difficult to detect. "L-test" is the error metric of the predictor fit, measured using the square mean of the logarithmic difference between the predicted and actual query results. If the value of "L-test" is smaller, the performance of the predictor is better.
[0161] Table 1 Parameters of the training process in this application
[0162]
[0163] In Table 1, it can be observed that as the number of queries gradually increases, the various parameters show a series of changes. The change in "Avg-min" shows that through multiple queries and optimizations, the average input sample that minimizes the model output is found. The perturbation size gradually decreases from 0.0094 to 0.0001, indicating that the difference between the adversarial sample and the original sample gradually decreases, increasing the stealth of the attack. The error metric of the predictor fitting gradually decreases with the increase in the number of queries, from 2615.6279 to 13.0469, indicating that the performance of the predictor gradually improves and the fitting effect is better. In summary, these trends reflect that through multiple iterations of the optimization process, the attack becomes more effective, and the predictor performs better in the fitting task.
[0164] Table 2 NP-Attack training process parameters
[0165]
[0166] Table 1 shows the parameters of the NP-Attack training process. Comparing the data in Table 1 and Table 2, under the same number of queries, the NP-Attack attack method in Table 2 is less effective than the model in Table 1 in terms of adversarial attack disturbance reduction and predictor fitting. The "Avg-min" value is relatively large overall, indicating that the effect of minimizing the average input sample is relatively poor; the disturbance value is also relatively large, indicating that the effect of reducing adversarial attack disturbance is relatively weak; at the same time, the "L-test" value is relatively large overall, indicating that the performance in predictor fitting is relatively poor. Based on the data analysis of the above two tables, it can be seen that the proposed method has a good performance in the training stage.
[0167] When comparing the perturbation size performance of BayesOpt, SignOpt, NP and the method of the present invention in the task of generating speech against attack, it is observed that as the perturbation size decreases, the search times of these four methods all increase. The search times of BayesOpt under 0.01, 0.005 and 0.001 perturbations are 694, 3285 and 4880 respectively, showing the characteristic that it is more difficult to search for smaller perturbations. The perturbation sizes of SignOpt under different sizes are 633, 3077 and 4771, showing a similar trend to BayesOpt and being sensitive to smaller perturbations. The perturbation sizes of the NP method under 0.01, 0.005 and 0.001 perturbations are 551, 2896 and 4570, and like BayesOpt and SignOpt, it also shows an increasing trend in the number of searches for smaller perturbations.
[0168] Table 3 Comparison of search times under different disturbances
[0169]
[0170] In contrast, the method of the present invention exhibits relatively small disturbances at each disturbance size, which are 539, 2671 and 4374 respectively, showing advantages in generating more refined speech disturbances. These results provide important clues for understanding the differences in sensitivity of different methods to disturbance size in the task of generating speech against attacks. Therefore, the method proposed in the present invention may have more potential in practical applications because it can change speech output in a more refined way. Methods such as BayesOpt and SignOpt may require larger disturbances to achieve the target speech transformation. These findings are instructive for further optimizing and improving methods for generating speech against attacks.
Claims
1. A black-box speech adversarial sample generation method based on an enhanced neural predictor, characterized in that: The specific steps include: Step 1: For Audio x Randomly generate n disturbance direction vectors , i=1,2…,n, for the disturbance direction vector Search and query using the ASR model to determine the minimum perturbation that causes the ASR model to misidentify, generating a dataset D; Step 2: Design an enhanced neural predictor; Step 3: Use the dataset D to train the enhanced neural predictor to find the new optimal perturbation direction vector ; Step 4: For the new optimal perturbation direction vector Using the optimized search process to search and using the ASR model query to determine the minimum disturbance that causes the ASR model to misidentify, thereby obtaining new samples and adding them to the data set D; The optimized search process, i.e., optimizing the coarse-grained search algorithm and the binary search method, is specifically as follows: A dynamic step-size strategy is introduced for the coarse-grained search algorithm. The dynamic step-size strategy is based on the distance function. The gradient information is used to adjust the step size, and the formula is expressed as: In the formula, represents the distance between the current disturbance and the minimum disturbance, represents the minimum distance found, represents the disturbance direction vector The L2 norm of For the preset perturbation distance threshold of the adversarial sample, the step size update rule can be expressed as: In the formula, represents the current disturbance direction vector, represents the step size adjustment function, >1 is the step size increase factor, when hour, The function value is 1, otherwise -1; A pruning strategy is introduced for the binary search method, and the pruning strategy formula is as follows: In the formula, is the objective function, which represents the influence of the disturbance direction vector on the model. and are the lower and upper bounds of the perturbation direction vector range, u is the preset upper threshold of the distance to the decision boundary; Pruning function , mapping the parameter vector to a pruned parameter subset, the update step can be expressed as: In the formula, represents the new perturbation direction vector; is the learning rate, set to a constant; Represents the gradient of pruning; Step 5: Repeat steps 3 and 4 until the query limit or perturbation threshold is reached and adversarial examples are found.
2. The black-box speech adversarial sample generation method based on the enhanced neural predictor according to claim 1 is characterized in that: The specific process in step 1 is as follows: The perturbation is decomposed into a perturbation direction vector and a scalar, expressed as follows: In the formula, represents disturbance, represents the disturbance direction vector, represents the disturbance direction vector The module length, Represents the distance from the audio to the decision boundary along the perturbation direction; First, a coarse-grained search is performed to find the range of perturbations that cause the ASR model to misidentify: Apply a coarse-grained algorithm to search, specifically: for the disturbance direction vector , set the step size , the coarse-grained search is performed by querying the sequence of points one by one Until the perturbation range that causes the ASR model to misidentify is found , j Indicates j Step length; Secondly, the perturbation range determined by coarse-grained search Within, a binary search method is used to perform an exact search to find the minimum perturbation that the ASR model misrecognizes; Thus, a series of sample pairs are obtained , generate a dataset .
3. The black-box speech adversarial sample generation method based on the enhanced neural predictor according to claim 2 is characterized in that: The specific structure of the enhanced neural predictor designed in step 2 includes: a Normalize layer for normalizing the input data; the output of the Normalize layer is connected to the Mel-frequency spectrum layer for converting the audio waveform spectrum data obtained after short-time Fourier transform processing into Mel-frequency cepstrum coefficients to extract speech features; the output of the Mel-frequency spectrum layer is connected to a convolution layer for compressing the number of channels to 32; the output of the convolution layer is connected to four self-attention convolution blocks in sequence, each of which includes a LeakyReLU activation function, a convolution layer, and an average pooling layer with a kernel size of 2; the output of the last self-attention convolution block is connected to the global average pooling layer for eliminating the remaining time dimension; the output of the global average pooling layer is connected to the linear layer.
4. The method for generating black-box speech adversarial samples based on an enhanced neural predictor according to claim 3, characterized in that: Step 3: The specific process is as follows: Step 3.1: Use the dataset Train the enhanced neural predictor, expressed as follows: Where: Denoted as training parameters, represents the optimal parameters obtained through training, represents the disturbance direction vector In the parameters The impact on It means taking the parameters that make the objective function reach the optimal value; Step 3.2: Freeze , find the new optimal perturbation direction : 。 5. The method for generating black-box speech adversarial samples based on an enhanced neural predictor according to claim 4, characterized in that: During the training of the designed enhanced neural predictor, the mean square error loss function is adopted, which is expressed as: In the formula, L represents the mean square error loss function, m is the total number of speech samples, It is k The actual value of the speech samples, For the k The predicted value of a speech sample.
