Speech recognition model acquisition method, device and program product based on parallel adapter fine-tuning
By fine-tuning the parallel adapter module in the encoder and decoder of the speech recognition model, the problem of mismatch in the identification data in actual applications is solved, and the effect of fewer parameters and higher recognition performance is achieved.
Patent Information
- Application Number
- CN202411898485.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-04
AI Technical Summary
The existing speech recognition model has the problem of mismatch in the identification data in actual applications, resulting in poor performance, and low-parameter fine-tuning methods such as Lora and adapter still have room for improvement in parameter quantity and recognition accuracy.
The parallel adapter fine-tuning method is adopted to fine-tune the multi-head self-attention layer and feedforward network parallel adapter modules at each level in the encoder and decoder of the speech recognition model. Through upsampling, downsampling and intermediate linear layers and nonlinear activation functions, the amount of parameters is reduced and the recognition performance is improved.
It realizes that without changing the original structure of the speech recognition model, fine-tuning is performed by inserting the adapter module in parallel, reducing the number of parameters and improving the recognition accuracy, avoiding catastrophic forgetting problems.
Smart Images

Figure CN119763553A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of speech recognition technology, and in particular to a speech recognition model acquisition method, device and program product based on parallel adapter fine-tuning. Background Art
[0002] Automatic speech recognition technology is a technology that transcribes speech into text. With the advancement of deep learning technology, the increase of data sets and computing power, after large language models such as GPT and BERT in the NLP field have been developed and widely cited, large models in the speech field such as Whisper, Google USM and MMS have also been proposed and widely studied. Large speech models have good performance on data sets in general fields, but in practical applications, they often encounter situations where recognition data does not match. Even though Whisper uses speech data from multiple fields for training, its performance may still be poor in actual tasks.
[0003] To solve this problem, you can use the specified data set to perform full fine tuning FFT (Full Fine Tuning) and low-parameter fine tuning PEFT (Parameter-Efficient Fine Tuning) on the large model. Full fine tuning is to train all the parameters of the model. Rishabh et al. performed full fine tuning on whisper for children's speech recognition, but the result was not as good as wav2vec. Full fine tuning can have a good performance improvement on the data set in the specified field, but the training cost is high and there is a problem of catastrophic forgetting. Low-parameter fine tuning can alleviate these two problems well. Commonly used low-parameter fine tuning methods include Lora and adapter. Both methods were originally introduced in natural language processing (NLP) and can effectively customize the corresponding large language model for the specified field.
[0004] Lora inserts a decomposable low-rank matrix module with fewer parameters to perform task adaptation during training while keeping the pre-trained model parameters unchanged. When it is applied to whisper fine-tuning, although it can alleviate the problem of high training cost during fine-tuning to a certain extent, the number of parameters is still high and the recognition accuracy still needs to be improved.
[0005] Adapter inserts a module consisting of multiple linear layers into the model, and then adapts the new task in the low-rank dimension during the training process through the conversion of the linear layer. Therefore, how to implement whisper fine-tuning based on Adapter has solved the problem of high parameter volume and low recognition accuracy.
[0006] In order to solve the above problems, people have been seeking an ideal technical solution. Summary of the invention
[0007] Based on this, it is necessary to provide a method, device and program product for acquiring a speech recognition model based on parallel adapter fine-tuning to address the above technical problems.
[0008] In order to achieve the above object, the first aspect of the present invention provides a method for acquiring a speech recognition model based on parallel adapter fine-tuning, comprising the following steps: Step 1: Train a speech recognition model based on an end-to-end encoder-decoder architecture; Step 2: Fine-tune the speech recognition model of the trained encoder-decoder by using a parallel adapter, wherein the adapter includes an upsampling linear layer, a downsampling linear layer, and an intermediate linear layer arranged between the upsampling linear layer and the downsampling linear layer, and nonlinear activation functions are arranged on both sides of the intermediate linear layer.
[0009] In a possible embodiment of the first aspect, fine-tuning the trained encoder-decoder speech recognition model using a parallel adapter includes: In the encoder, an adapter module is connected in parallel to the multi-head self-attention layer and feed-forward network of each encoding block; In the decoder, an adapter module is connected in parallel to the mask multi-head attention layer and feed-forward network of each decoding block.
[0010] In a possible embodiment of the first aspect, the nonlinear activation function is a RELU nonlinear activation function.
[0011] In order to achieve the above-mentioned object, the second aspect of the present invention provides a speech recognition model acquisition device based on parallel adapter fine-tuning, comprising: Model training module, used to train speech recognition models based on end-to-end encoder-decoder architecture; The model fine-tuning module is used to perform parallel adapter fine-tuning on the trained encoder-decoder speech recognition model, wherein the adapter includes an upsampling linear layer, a downsampling linear layer, and an intermediate linear layer arranged between the upsampling linear layer and the downsampling linear layer, and nonlinear activation functions are also arranged on both sides of the intermediate linear layer.
[0012] In order to achieve the above-mentioned object, the third aspect of the present invention provides a computer device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; The processor is used to implement the speech recognition model acquisition method based on parallel adapter fine-tuning as described in the first aspect when executing the program stored in the memory.
[0013] In order to achieve the above-mentioned purpose, the fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for acquiring a speech recognition model based on parallel adapter fine-tuning as described in the first aspect is implemented.
[0014] In order to achieve the above-mentioned purpose, the fifth aspect of the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements the speech recognition model acquisition method based on parallel adapter fine-tuning as described in the first aspect.
[0015] The beneficial effects of the present invention are: The present invention proposes a method for acquiring a speech recognition model based on parallel adapter fine-tuning, which does not change the original overall structure and input and output of the speech recognition model, but performs fine-tuning by inserting an adapter in parallel next to an encoder-decoder module. The adapter includes an upsampling linear layer, a downsampling linear layer, and an intermediate linear layer arranged between the upsampling linear layer and the downsampling linear layer. Nonlinear activation functions are further arranged on both sides of the intermediate linear layer, and no additional residual connection is required; fewer parameters are required. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a structural diagram of the whisper architecture.
[0017] Figure 2 It is a structural schematic diagram of the parallel adapter of the present invention.
[0018] Figure 3 It is a structural schematic diagram of the computer device of the present invention. DETAILED DESCRIPTION
[0019] The Whisper model still uses an end-to-end encoder-decoder architecture based on Transformer, except that the input audio and output labels are specially processed. Figure 1 As shown in the figure, the processed audio is first segmented into 30-second segments and then converted into log - Mel The spectrogram is then fed into the encoder, and the decoder outputs text using special tags. Tokens The labels are different from those of common end-to-end speech recognition tasks and machine translation tasks. The labels here have three additional special tags: language, task type, and timestamp to guide the model to perform tasks such as speech recognition, speech translation, language identification, and multilingual speech transcription.
[0020] The encoder is mainly composed of one-dimensional convolution, position encoding and attention modules. log - Mel After the spectrogram is sent to the encoder, it first performs one-dimensional convolution to reduce the length of the input sequence, then performs position encoding to allow the subsequent attention module to better generalize the length of the input sequence, and finally sends it to the attention module for high-level feature extraction. The decoder is mainly composed of position encoding and attention modules. Tokens After being sent to the decoder, it is sent to the attention module after adding the position code, and then the predicted value is output after the attention operation. token The attention module is mainly composed of masked multi-head self-attention and cross-attention. The multi-head self-attention is used to explore the connection between the decoder input sequence, and the cross-attention mechanism is used to learn the relationship between the decoder internal sequence and the encoder output sequence.
[0021] There are two low-parameter fine-tuning methods for whisper fine-tuning: Lora and adapter. Although Lora can alleviate the high training cost problem during whisper fine-tuning to a certain extent, the number of parameters is still high and the recognition accuracy still needs to be improved. As for the Adapter, the traditional Adapter fine-tunes parameters by inserting small modules in series in each layer of the transformer. During the fine-tuning process, other parameters in the transformer need to be frozen, and only a small number of parameters including the adapter are updated.
[0022] The structure of the adapter layer is very simple, it consists of two linear layers and a residual connection. The output of the transformer layer h Projected down to a smaller dimension, through a nonlinear activation function After that, another linear layer Then project it upward to the original dimension. In addition, there is a residual connection between the input and output of the entire adapter layer. The formula is: .
[0023] In order to further reduce the amount of trainable parameters and improve recognition performance, the present invention studies a low-parameter fine-tuning method that inserts the Adapter into the model in parallel.
[0024] The technical solution of the present invention is further described in detail below through specific implementation methods.
[0025] Example 1 This embodiment provides a method for acquiring a speech recognition model based on parallel adapter fine-tuning, comprising the following steps: Step 1: Train a speech recognition model based on an end-to-end encoder-decoder architecture; Step 2: Fine-tune the trained encoder-decoder speech recognition model using the parallel adapter.
[0026] Specifically, Figure 2 As shown, this embodiment maintains the original overall structure of Whisper and the input and output of the model. Only in the encoder, the adapter module is connected in parallel to the multi-head self-attention layer and the feedforward network of each encoding block; in the decoder, the adapter module is connected in parallel to the mask multi-head attention layer and the feedforward network of each decoding block.
[0027] It should be noted that in this embodiment, the Cross-Attention module of each decoding block in the decoder is not connected in parallel with the adapter module.
[0028] It should be noted that in this application adapter Improvements have also been made. Specifically, adapter Including upsampling linear layer , downsampling linear layer And set it in the upsampling linear layer and a downsampling linear layer The intermediate linear layer between , the intermediate linear layer Nonlinear activation functions are also provided on both sides. In one embodiment, the nonlinear activation function is RELU Non-linear activation function.
[0029] For each adapter Module, given input h , after it passes through the linear layer W down After being projected to the dimension r The low-rank vector space is then transformed into two nonlinear activation functions. and the linear layer W middle After the transformation, it finally passes through the linear layerW up After being projected to the original dimension, d in the vector space of .
[0030] The whole process can be expressed as:
[0031] in, x is the hidden layer vector inside the model.
[0032] It should be noted that when using Lora to fine-tune whisper, when only one multi-head attention mechanism q , k , v When training the two linear layer parameters corresponding to the attention heads, there are a total of 8 linear layer parameters; but Lora has three multi-head attention mechanisms, so there are a total of 24 linear layer parameters. All adapter modules in the parallel adapter There are 12 linear layer parameters in total, and four of them have dimensions r≤d In comparison, the parallel adapter has fewer parameters than Lora.
[0033] Verification experiment: The Mandarin Chinese dataset aishell-1 was used as experimental data, which was divided into training set, validation set and test set. A total of 7 models in Whisper, including Tiny, Base, Small, Medium, Large, Large-v2 and Large-v3, were used to test and compare the performance of the adapter.
[0034] Specifically, the initial model performance of whisper and the fully fine-tuned model were tested, and whisper was fine-tuned and tested using Lora and adapter with different parameters. rank is set to 32, α is set to 64, the multi-head self-attention q, k, v The linear layer and the output linear layer and two fully connected layers are used for training. In the adapter fine-tuning, in order to explore the impact of the number of parameters on its performance, r Can be set to 32, 64, 128.
[0035] The statistics of the number of training parameters during the fine-tuning of Whisper, Lora, and adapter are shown in Table 1.
[0036] Table 1 The number and percentage of parameters trained by the model
[0037] During the training process, the model used the Adam optimization algorithm. The learning rate corresponding to the full fine-tuning was set to 0.00001, and the learning rate of Lora and adapter was set to 0.001. Tiny, Base, and Small were trained for 60 epochs, and Medium, Large, Large-v2, and Large-v3 were trained for 30 epochs, and the deepspeed technology was used for acceleration. The entire experiment was conducted on 4 V100 graphics cards using the pytorch deep learning framework.
[0038] The experimental results on the Aishell dataset are shown in Table 2. The experiment uses CER as the performance evaluation indicator. In the table, ori represents the model without fine-tuning.
[0039] Table 2 CER of whisper on the test set of aishell-1
[0040] As can be seen from the table, after fine-tuning with Lora, the CER of each model in whisper decreased by an average of 62.16%, among which the CER of Large-v2 decreased by the largest amount of 66.44%. At this time, the number of parameters required for fine-tuning is 57M, accounting for 3.6% of all trainable parameters. For the parallel adapter, when the model is Medium, Large, Large-v2, Large-v3 and r=32, the CER decreased by 16.59%, 17.44%, 5.41%, and 11.70% respectively compared with Lora, and the number of parameters required for training was reduced by 80.30% and 80.70% respectively. This shows that the parallel adapter studied in the present invention can train fewer parameters during the fine-tuning process and achieve better recognition performance compared with Lora. However, compared to CER The full fine-tuning, which dropped by an average of 72.43%, still has a certain performance gap.
[0041] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0042] Example 2 Based on the same inventive concept, the embodiment of the present application also provides a speech recognition model acquisition device based on parallel adapter fine-tuning for implementing the above-mentioned speech recognition model acquisition method based on parallel adapter fine-tuning. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more embodiments of the speech recognition model acquisition device based on parallel adapter fine-tuning provided below can be referred to the limitations of the speech recognition model acquisition method based on parallel adapter fine-tuning in the above text, and will not be repeated here.
[0043] like Figure 2 As shown, the speech recognition model acquisition device based on parallel adapter fine-tuning includes: Model training module, used to train speech recognition models based on end-to-end encoder-decoder architecture; The model fine-tuning module is used to perform parallel adapter fine-tuning on the trained encoder-decoder speech recognition model, wherein the adapter includes an upsampling linear layer, a downsampling linear layer, and an intermediate linear layer arranged between the upsampling linear layer and the downsampling linear layer, and nonlinear activation functions are also arranged on both sides of the intermediate linear layer.
[0044] Example 3 This embodiment has provided a computer device, which may be a terminal, and its internal structure diagram may be as follows: Figure 3As shown, the computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for acquiring a speech recognition model based on parallel adapter fine-tuning is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0045] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0046] Example 4 On the basis of the above embodiments, this embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the military target recognition method based on visual Transformer as described in Example 1 is implemented.
[0047] Example 5 On the basis of the above embodiments, this embodiment provides a computer program product, including a computer program, which implements the following steps when executed by a processor: Step 1: training a speech recognition model based on an end-to-end encoder-decoder architecture; Step 2: Fine-tune the speech recognition model of the trained encoder-decoder by using a parallel adapter, wherein the adapter includes an upsampling linear layer, a downsampling linear layer, and an intermediate linear layer arranged between the upsampling linear layer and the downsampling linear layer, and nonlinear activation functions are arranged on both sides of the intermediate linear layer.
[0048] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0049] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0050] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
[0051] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or some technical features can be replaced by equivalents without departing from the spirit of the technical solution of the present invention, which should be included in the scope of the technical solution for protection of the present invention.
Claims
1. A method for acquiring a speech recognition model based on parallel adapter fine-tuning, characterized in that: The following steps are involved: Step 1: Train a speech recognition model based on an end-to-end encoder-decoder architecture; Step 2: Fine-tune the speech recognition model of the trained encoder-decoder by using a parallel adapter, wherein the adapter includes an upsampling linear layer, a downsampling linear layer, and an intermediate linear layer arranged between the upsampling linear layer and the downsampling linear layer, and nonlinear activation functions are arranged on both sides of the intermediate linear layer.
2. The method for acquiring a speech recognition model based on parallel adapter fine-tuning according to claim 1, characterized in that: Fine-tune the trained encoder-decoder speech recognition model using the parallel adapter, including: In the encoder, an adapter module is connected in parallel to the multi-head self-attention layer and feed-forward network of each encoding block; In the decoder, an adapter module is connected in parallel to the mask multi-head attention layer and feed-forward network of each decoding block.
3. The method for acquiring a speech recognition model based on parallel adapter fine-tuning according to claim 1, characterized in that: The nonlinear activation function is a RELU nonlinear activation function.
4. A speech recognition model acquisition device based on parallel adapter fine-tuning, characterized in that: include: Model training module, used to train speech recognition models based on end-to-end encoder-decoder architecture; The model fine-tuning module is used to perform parallel adapter fine-tuning on the trained encoder-decoder speech recognition model, wherein the adapter includes an upsampling linear layer, a downsampling linear layer, and an intermediate linear layer arranged between the upsampling linear layer and the downsampling linear layer, and nonlinear activation functions are also arranged on both sides of the intermediate linear layer.
5. The device for acquiring a speech recognition model based on parallel adapter fine-tuning according to claim 4, characterized in that: In the encoder, the multi-head self-attention layer and feed-forward network of each encoding block are connected in parallel with an adapter module; In the decoder, the mask multi-head attention layer and feed-forward network of each decoding block are connected in parallel with an adapter module.
6. The device for acquiring a speech recognition model based on parallel adapter fine-tuning according to claim 5, characterized in that: The nonlinear activation function is a RELU nonlinear activation function.
7. A computer device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; The processor is used to implement the method for acquiring a speech recognition model based on parallel adapter fine-tuning as described in any one of claims 1 to 3 when executing a program stored in the memory.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for acquiring a speech recognition model based on parallel adapter fine-tuning as described in any one of claims 1 to 3 is implemented.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for acquiring a speech recognition model based on parallel adapter fine-tuning as described in any one of claims 1 to 4 is implemented.