Method for training keyword recognition model, method and device for recognizing keywords

The speech keyword recognition model is trained through preset label data and meta-learning methods, combined with encoder and cosine similarity, to solve the problem of data consumption and custom keyword requirements of speech keyword recognition technology in diverse application scenarios, and achieve Efficient few-sample keyword identification.

CN118312890BActive Publication Date: 2024-09-06BEIJING UNIV OF CIVIL ENG & ARCHITECTURE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410742658.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-09-06
Estimated Expiration
2044-06-11

AI Technical Summary

Technical Problem

When faced with diverse application scenarios, existing speech keyword recognition technology is time-consuming to collect and label a large amount of corpus data, and adding new keywords requires retraining the model. It cannot meet customer customization needs, especially when language resources are scarce. The accuracy of the few-sample keyword recognition model is insufficient.

Method used

Train a basic full classification model through preset label data, combine the encoder and meta-learning methods to determine the category centroid, use cosine similarity to predict the category probability of the query sample, and adjust the model parameters through loss to achieve the training and implementation of the few-sample keyword recognition model. Identify.

Benefits of technology

Accurately train keyword recognition models with a small amount of training data, improve the accuracy of keyword recognition with few samples, reduce user data requirements and model training time, and support customer-defined keywords.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118312890B
    Figure CN118312890B
Patent Text Reader

Abstract

The present application provides a method for training a keyword recognition model, a method and device for recognizing keywords, the method comprising: training a basic full classification model on all base classes through preset label data to obtain a classifier and an encoder, wherein the label data includes multiple texts with keyword labels; training the classifier in combination with the encoder to obtain a full classification model; when training the model using a meta-learning method in the meta-training stage, determining the category centroid of the supporting sample, and combining the cosine similarity method to predict the similarity probability that the query sample belongs to the category corresponding to the category centroid; calculating the loss of the training task through the similarity probability, and adjusting the parameters of the full classification model according to the loss to obtain a few-sample keyword recognition model. This method can accurately train the keyword recognition model and recognize the effect of speech keywords through the few-sample keyword recognition model in the case of a small amount of training data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of speech recognition, and in particular, to a method for training a keyword recognition model, and a method and device for recognizing keywords. Background Art

[0002] Speech keyword recognition is the task of detecting specific words in a speech stream. It is an important interface for current human-computer speech interaction and a basic function that users can access remotely through voice in current devices. Nowadays, most keyword systems have manufacturers pre-define keywords for their products, and then collect large-scale data sets to train recognition models. The speech keyword recognition method based on deep learning first extracts the high-dimensional features of the speech keywords to be recognized, and then directly inputs the features into the neural network. The probability of each category is calculated based on the network, and the keyword is judged to belong to a certain category based on a pre-set threshold. The current speech keyword recognition technology, with the help of a large amount of fully annotated sample data and complex deep neural networks, can achieve high-precision recognition effects.

[0003] However, with the diversification of application scenarios, this traditional method faces many challenges. On the one hand, collecting and annotating large amounts of corpus data is time-consuming and expensive, especially for some situations where language resources are scarce. On the other hand, traditional models are usually optimized for preset keywords, and adding new keywords often requires retraining the model from scratch, which is impractical for users. Currently, adding new keywords still faces challenges because it requires retraining the model and requires a large number of annotated data sets containing new keywords, which is impractical for most users. Therefore, the vast majority of existing small-sample keyword recognition models can only recognize pre-set keywords and cannot meet customer needs for customized keywords.

[0004] Therefore, how to accurately train the keyword recognition model and identify voice keywords through the few-sample keyword recognition model is a technical problem that needs to be solved. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide a method for training a few-sample keyword recognition model. Through the technical solution of the embodiments of the present application, it is possible to achieve the effect of accurately training a few-sample keyword recognition model and recognizing voice keywords through the few-sample keyword recognition model.

[0006] In a first aspect, an embodiment of the present application provides a method for training a keyword recognition model, comprising: training a basic full classification model on all base classes through preset label data to obtain a classifier and an encoder, wherein the label data includes multiple texts with keyword labels; training the classifier in combination with the encoder to obtain a full classification model; when training the model using a meta-learning method in a meta-training stage, determining the category centroid of the supporting samples, and predicting the similarity probability that the query sample belongs to the category corresponding to the category centroid in combination with the cosine similarity method; calculating the loss of the training task through the similarity probability, and adjusting the parameters of the full classification model according to the loss to obtain a few-sample keyword recognition model.

[0007] In the above embodiments of the present application, the keyword recognition model is trained by using the full classification and meta-learning method, in which the encoder and cosine similarity method for calculating sample categories are combined to improve the accuracy of the few-sample keyword recognition model. This method can accurately train the keyword recognition model and recognize voice keywords through the few-sample keyword recognition model with a small amount of training data.

[0008] In some embodiments, the classifier is trained in combination with the encoder to obtain a full classification model, including: training the classifier through a cross entropy loss algorithm and removing the last fully connected layer of the classifier to obtain an encoder; mapping the input of the classifier to an embedding through the encoder to obtain a full classification model.

[0009] In the above embodiments of the present application, by improving the internal structure of the classifier on the full classification and training the classifier in combination with the encoder, a preliminary full classification model can be obtained to provide a basis for subsequent training of a few-sample keyword recognition model.

[0010] In some embodiments, when a model is trained using a meta-learning method during a meta-training phase, the category centroid of the support sample is determined, and the cosine similarity method is used to predict the similarity probability that the query sample belongs to the category corresponding to the category centroid, including: calculating the average embedding of the support sample, and using the average embedding as the category centroid; calculating the cosine similarities of the query sample with the category centroid respectively using the cosine similarity method to obtain multiple cosine similarities; introducing a learnable scalar into the multiple cosine similarities to obtain multiple introduced cosine similarities; and judging the similarity probability that the query sample belongs to the category respectively using the multiple introduced cosine similarities.

[0011] In the above embodiment of the present application, the cosine similarity is used in the meta-learning stage and a learnable scalar is introduced to scale the cosine similarity to replace the existing Euclidean distance, and the category of the query sample is predicted by this, so that the category of the query sample can be accurately determined.

[0012] In some embodiments, the classifier is trained in combination with the encoder to obtain a full classification model, including: extracting the Mel-cepstral coefficients of the label data; using the Mel-cepstral coefficients as the input of the classifier, and using the encoder to convolve the keyword signal along the time axis to obtain the full classification model, wherein the encoder includes a preset convolution kernel step size and a hole convolution.

[0013] In the above embodiments of the present application, the dilated convolution enables the model to process more complex audio patterns without significantly increasing the computational burden. The present application uses convolution along the time axis in conjunction with the dilated convolution, which not only speeds up the running speed of the model and improves efficiency, but also brings better performance for keyword recognition by expanding the receptive field.

[0014] In some embodiments, before the basic full classification model is trained on all base classes with preset label data to obtain the classifier and encoder, it also includes: obtaining sample speech recorded by multiple people containing multiple keywords and background noise; preprocessing the sample speech to obtain label data, wherein the preprocessing includes: at least one processing method of filtering, grouping, equalization, division, mixed noise and setting a silent class.

[0015] In the above embodiments of the present application, in the prototype network method, after background noise is added to the core words, the present application inherits the good metrics in the classifier baseline in the meta-learning stage, so that for data containing background noise, it has a better representation when mapped to the metric space. In addition, by preprocessing the sample speech, the keyword recognition model can be better trained.

[0016] In some embodiments, the loss of the training task is calculated by similarity probability, and the parameters of the full classification model are adjusted according to the loss to obtain a few-sample keyword recognition model, including: calculating the deviation between the similarity probability and the preset probability to obtain the loss; adjusting the parameters of the full classification model according to the loss, and recalculating the latest loss of the training task, and when the latest loss meets the preset threshold, the few-sample keyword recognition model is obtained.

[0017] In the above embodiments of the present application, the recognition accuracy of the few-sample keyword recognition model can be continuously improved through the calculation of loss.

[0018] In a second aspect, an embodiment of the present application provides a method for identifying keywords, including obtaining a user's speech to be identified; identifying keywords of the speech to be identified through a preset few-sample keyword recognition model, wherein the few-sample keyword recognition model is obtained by calculating the loss of the training task through the similarity probability, and adjusting the parameters of the full classification model according to the loss, and the similarity probability is obtained by determining the category centroid of the supporting sample when training the model using the meta-learning method in the meta-training stage, and combining the cosine similarity method to predict the probability that the query sample belongs to the category corresponding to the category centroid, and the full classification model is obtained by training the classifier through the encoder, and the classifier and the encoder are obtained by training the basic full classification model on all base classes through preset label data.

[0019] In the above embodiments of the present application, the keyword recognition model is trained by using the full classification and meta-learning methods, in which the encoder and cosine similarity method for calculating sample categories are combined to improve the accuracy of the few-sample keyword recognition model, thereby achieving the effect of quickly and accurately training the keyword recognition model while enabling the few-sample keyword recognition model to accurately recognize voice keywords.

[0020] In some embodiments, before obtaining the user's speech to be recognized, it also includes: training the basic full classification model on all base classes through preset label data to obtain a classifier and an encoder, wherein the label data includes multiple texts with keyword labels; training the classifier in combination with the encoder to obtain a full classification model; when training the model using the meta-learning method in the meta-training stage, determining the category centroid of the supporting samples, and combining the cosine similarity method to predict the similarity probability that the query sample belongs to the category corresponding to the category centroid; calculating the loss of the training task through the similarity probability, and adjusting the parameters of the full classification model according to the loss to obtain a few-sample keyword recognition model.

[0021] In the above embodiments of the present application, the keyword recognition model is trained by using the full classification and meta-learning methods, in which the encoder and cosine similarity method for calculating sample categories are combined to improve the accuracy of the few-sample keyword recognition model, thereby achieving the effect of quickly and accurately training the keyword recognition model while enabling the few-sample keyword recognition model to accurately recognize voice keywords.

[0022] In a third aspect, an embodiment of the present application provides a device for training a keyword recognition model, comprising:

[0023] A full classification module is used to train a basic full classification model on all base classes through preset label data to obtain a classifier and an encoder, wherein the label data includes multiple texts with keyword labels;

[0024] A first training module, used to train the classifier in combination with the encoder to obtain a full classification model;

[0025] The meta-learning module is used to determine the class centroid of the support samples and predict the similarity probability of the query sample belonging to the class corresponding to the class centroid by combining the cosine similarity method;

[0026] The second training module is used to calculate the loss of the training task by similarity probability when training the model using the meta-learning method in the meta-training stage, and adjust the parameters of the full classification model according to the loss to obtain a few-sample keyword recognition model.

[0027] Optionally, the first training module is specifically used for:

[0028] The classifier is trained using the cross entropy loss algorithm and the last fully connected layer of the classifier is removed to obtain the encoder.

[0029] The input of the classifier is mapped to the embedding through the encoder to obtain a full classification model.

[0030] Optionally, the meta-learning module is specifically used to:

[0031] Calculate the average embedding of the support samples and use the average embedding as the class centroid;

[0032] The cosine similarity between the query sample and the category centroid is calculated by the cosine similarity method to obtain multiple cosine similarities;

[0033] Introducing a learnable scalar into multiple cosine similarities to obtain multiple introduced cosine similarities;

[0034] The similarity probabilities of the query samples belonging to different categories are determined by using multiple introduced cosine similarities.

[0035] Optionally, the first training module is specifically used for:

[0036] Extract the Mel cepstral coefficients of the label data;

[0037] The Mel-frequency cepstral coefficient is used as the input of the classifier, and the encoder is used to convolve the keyword signal along the time axis to obtain a full classification model, wherein the encoder includes a preset convolution kernel step size and a dilated convolution.

[0038] Optionally, the device further comprises:

[0039] A preprocessing module, used for obtaining sample speech recorded by multiple people containing multiple keywords and background noise before the full classification module trains the basic full classification model on all base classes with preset label data to obtain the classifier and encoder;

[0040] The sample speech is preprocessed to obtain label data, wherein the preprocessing includes: at least one processing method of filtering, grouping, equalization, division, mixed noise and setting a mute class.

[0041] Optionally, the second training module is specifically used for:

[0042] Calculate the deviation between the similar probability and the preset probability to get the loss;

[0043] The parameters of the full classification model are adjusted according to the loss, and the latest loss of the training task is recalculated. When the latest loss meets the preset threshold, the few-sample keyword recognition model is obtained.

[0044] In a fourth aspect, an embodiment of the present application provides a device for training a keyword recognition model, comprising:

[0045] An acquisition module is used to acquire the user's speech to be recognized;

[0046] The recognition module is used to identify the keywords of the speech to be recognized through a preset few-sample keyword recognition model, wherein the few-sample keyword recognition model is obtained by calculating the loss of the training task through similarity probability and adjusting the parameters of the full classification model according to the loss. The similarity probability is obtained by determining the category centroid of the supporting samples when training the model using the meta-learning method in the meta-training stage, and combining the cosine similarity method to predict the probability that the query sample belongs to the category corresponding to the category centroid. The full classification model is obtained by training the classifier through the encoder, and the classifier and encoder are obtained by training the basic full classification model on all base classes through preset label data.

[0047] Optionally, the device further comprises:

[0048] A training module, used for the acquisition module to train the basic full classification model on all base classes through preset label data before acquiring the user's speech to be recognized, so as to obtain a classifier and an encoder, wherein the label data includes a plurality of texts with keyword labels;

[0049] Training the classifier in combination with the encoder to obtain a full classification model;

[0050] Determine the class centroid of the support sample, and use the cosine similarity method to predict the similarity probability that the query sample belongs to the class corresponding to the class centroid;

[0051] The loss of the training task is calculated by similarity probability, and the parameters of the full classification model are adjusted according to the loss to obtain a few-sample keyword recognition model.

[0052] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the embodiments of the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0054] Figure 1 A flowchart of a method for training a keyword recognition model provided in an embodiment of the present application;

[0055] Figure 2 A flowchart of a method for identifying keywords provided in an embodiment of the present application;

[0056] Figure 3 A schematic block diagram of a device for training a keyword recognition model provided in an embodiment of the present application;

[0057] Figure 4 A schematic block diagram of a device for identifying keywords provided in an embodiment of the present application;

[0058] Figure 5 A schematic block diagram of the structure of a device for training a keyword recognition model provided in an embodiment of the present application;

[0059] Figure 6 A schematic block diagram of the structure of a device for identifying keywords provided in an embodiment of the present application. DETAILED DESCRIPTION

[0060] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0061] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0062] First, some terms involved in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.

[0063] Speech keyword spotting is the task of detecting specific words in a speech stream. It is an important interface for current human-computer voice interaction and a basic function for users to remotely access via voice in current devices.

[0064] The Meta-Baseline method pre-trains classifiers on all base classes and performs meta-learning on a nearest centroid-based few-shot classification algorithm.

[0065] The present application is applied to the scenario of speech recognition. The specific scenario is to use a method combining full classification and meta-learning to train a keyword recognition model, and recognize the keywords of the speech through a few-sample keyword recognition model.

[0066] Speech keyword recognition is the task of detecting specific words in a speech stream. It is an important interface for current human-computer speech interaction and a basic function that users can access remotely through voice in current devices. Nowadays, most keyword systems are that manufacturers predefine keywords for their products and then collect large-scale data sets to train recognition models. The speech keyword recognition method based on deep learning first extracts high-dimensional features of the speech keywords to be recognized, and then directly inputs the features into the neural network. Then, the probability of each category is calculated based on the network, and the keyword is judged to belong to a certain category based on the pre-set threshold. The current speech keyword recognition technology can achieve high-precision recognition effects with the help of a large amount of fully annotated sample data and complex deep neural networks. However, with the diversification of application scenarios, this traditional method faces many challenges. On the one hand, collecting and annotating a large amount of corpus data is time-consuming and expensive, especially for some situations where language resources are scarce. On the other hand, traditional models are usually optimized for preset keywords, and adding new keywords often requires retraining the model from scratch, which is impractical for users. At present, adding new keywords still faces challenges because it requires retraining the model and must have a large number of annotated data sets containing new keywords, which is impractical for most users. Therefore, most of the existing few-sample keyword recognition models can only identify pre-set keywords and cannot meet customers' needs for customized keywords.

[0067] To this end, the present application trains the basic full classification model on all base classes through preset label data to obtain a classifier and an encoder, wherein the label data includes multiple texts with keyword labels; the classifier is trained in combination with the encoder to obtain a full classification model; the category centroid of the supporting samples is determined, and the similarity probability of the query sample belonging to the category corresponding to the category centroid is predicted in combination with the cosine similarity method; the loss of the training task is calculated by the similarity probability, and the parameters of the full classification model are adjusted according to the loss to obtain a few-sample keyword recognition model. The keyword recognition model is trained by using the full classification and meta-learning method, wherein the encoder and the method of calculating the sample category by cosine similarity are also combined to improve the accuracy of the few-sample keyword recognition model. This method can accurately train the keyword recognition model and recognize the effect of speech keywords through the few-sample keyword recognition model in the case of a small amount of training data.

[0068] In the embodiment of the present application, the execution entity can be a training keyword recognition model device in a training keyword recognition model system. In actual applications, the training keyword recognition model device can be electronic devices such as terminal devices and servers, which is not limited here.

[0069] Combine the following Figure 1 The method for training a keyword recognition model in an embodiment of the present application is described in detail.

[0070] Please see Figure 1 , Figure 1 A flowchart of a method for training a keyword recognition model provided in an embodiment of the present application is shown in FIG. Figure 1 The method for training a keyword spotting model includes:

[0071] Step 110: Train the basic full classification model on all base classes using preset label data to obtain a classifier and an encoder.

[0072] Among them, the label data includes multiple texts with keyword labels, and the keyword labels can be speech marked in four cases: core word, core word + background noise, core word + unknown word, core word + unknown word + background noise + silence.

[0073] Specifically, the existing basic full classification model is used to train the entire labeled dataset, and a classifier with classification loss is trained on all base classes.

[0074] In some embodiments of the present application, before the basic full classification model is trained on all base classes using preset label data to obtain the classifier and encoder, Figure 1 The method shown also includes: obtaining sample speech recorded by multiple people containing multiple keywords and background noise; preprocessing the sample speech to obtain label data, wherein the preprocessing includes: at least one processing method of filtering, grouping, equalization, division, mixed noise and setting a mute class.

[0075] In the above process, in the prototype network method, after adding background noise to the core words, the present application inherits the good metrics in the classifier baseline in the meta-learning stage, so that the data containing background noise has a better representation when mapped to the metric space. In addition, by preprocessing the sample speech, the keyword recognition model can be better trained.

[0076] The specific preprocessing process is as follows: Filtering: Filter out all audio features less than 1 second to make the MFCC (Mel-frequency cepstral coefficient) feature matrix extracted from each audio file consistent. Grouping: Classify keywords with more than 1000 user voices as core words, and those with less than 1000 as unknown words. Balance: Balance the data set so that all keywords in a group have the same number of samples. Set the number of samples for each core word to 1062, and set the number of samples for each unknown word to 386. Partition: Divide the 30 core keywords into training set, verification set, and test set according to the training method. The number of core words is 20, 5, and 5 respectively, and they do not intersect with each other. For unknown words, since there are only 5 categories, this application uses 60% of the number of samples for each keyword for training, 20% for verification, and 20% for testing, and each sample is also non-intersecting. Mixed noise: Randomly select existing noise fragments and mix them with 1 second keyword audio noise. The loudness is random and controlled by a hyperparameter, where 0 is silence and 1 is the maximum volume. In the experiment, the background volume is set to 0.1, and the experiment is conducted with and without background noise. Set the silence class: In addition to the core and unknown categories, an additional silence category is added. In order to simulate the scene of no speaking in daily life, and there is no complete silence in daily life, 1000 1-second long speech clips are randomly extracted from the noisy audio to simulate the silence clip.

[0077] Step 120: Train the classifier in combination with the encoder to obtain a full classification model.

[0078] In some embodiments of the present application, the classifier is trained in combination with the encoder to obtain a full classification model, including: training the classifier through a cross entropy loss algorithm and removing the last fully connected layer of the classifier to obtain an encoder; mapping the input of the classifier to an embedding through the encoder to obtain a full classification model.

[0079] In the above process, the present application can obtain a preliminary full classification model by improving the internal structure of the classifier on the full classification and training the classifier in combination with the encoder, which provides a basis for the subsequent few-sample keyword recognition model training.

[0080] In some embodiments of the present application, a classifier is trained in combination with an encoder to obtain a full classification model, including: extracting Mel-cepstral coefficients of label data; using the Mel-cepstral coefficients as input to the classifier, and using the encoder to convolve the keyword signal along the time axis to obtain a full classification model, wherein the encoder includes a preset convolution kernel step size and a hole convolution.

[0081] In the above process, the dilated convolution enables the model to process more complex audio patterns without significantly increasing the computational burden. The application uses convolution along the time axis in conjunction with dilated convolution, which not only speeds up the model's operation and improves efficiency, but also brings better performance for keyword recognition by expanding the receptive field.

[0082] For example, for each input label data sample, the MFCC features of each sample are extracted and reorganized as input, and TD-ResNet7 (encoder) is used as the encoder to perform convolution processing on the keyword signal along the time axis. For each ResNet (encoder) block, a 7×1 convolution kernel with a step size of 1 is used, and for the three ResNet blocks, 1, 2, and 4 dilated convolutions are used respectively.

[0083] Among them, when performing convolution operations along the time axis, the number of parameters of the model is significantly reduced, thereby directly improving the processing speed of the model. This strategy is crucial for building lightweight and efficient speech processing systems. In addition, by adopting the hole convolution technology, the present application can intentionally expand the receptive field of the convolution layer without adding additional parameters. This method enables the convolution layer to cover a wider time range, thereby capturing longer-term dependencies, which is particularly beneficial for keyword detection. The capture of long-term dependencies is an important aspect of identifying keywords because it allows the model to integrate information across large time spans and identify and distinguish keywords that may appear in longer speech sequences. Furthermore, the hole convolution allows the model to process more complex audio patterns without significantly increasing the computational burden. Therefore, the present application adopts the use of convolution along the time axis in conjunction with the hole convolution, which not only speeds up the running speed of the model and improves efficiency, but also brings better performance for keyword recognition by expanding the receptive field.

[0084] Step 130: When using the meta-learning method to train the model in the meta-training phase, determine the category centroid of the support sample, and use the cosine similarity method to predict the similarity probability that the query sample belongs to the category corresponding to the category centroid.

[0085] In some embodiments of the present application, the category centroid of the supporting samples is determined, and the similarity probability of the query sample belonging to the category corresponding to the category centroid is predicted in combination with the cosine similarity method, including: calculating the average embedding of the supporting samples, and using the average embedding as the category centroid; calculating the cosine similarities of the query samples with the category centroid respectively by the cosine similarity method to obtain multiple cosine similarities; introducing a learnable scalar into the multiple cosine similarities to obtain multiple introduced cosine similarities; judging the similarity probability of the query samples belonging to the categories respectively by the multiple introduced cosine similarities.

[0086] In the above process, the present application uses cosine similarity in the meta-learning stage and introduces a learnable scalar to scale cosine similarity to replace the existing Euclidean distance, and uses this to predict the category of the query sample, so as to accurately determine the category of the query sample.

[0087] Specifically, the average embedding of the support samples is calculated, and the average embedding is used as the category centroid, which can be obtained by the following formula:

[0088] ;

[0089] in, represents the feature encoder, represents the samples belonging to category c in the support sample set, represents the average embedding as the centroid of class c, and x represents the support samples.

[0090] Optionally, the cosine similarity between the query sample and the category centroid is calculated using the cosine similarity method, and multiple cosine similarities can be obtained using the following formula:

[0091] ;

[0092] in, represents the feature encoder, c represents the category, represents the average embedding as the centroid of category c, x represents the query sample, and p represents the cosine similarity.

[0093] Optionally, a learnable scalar is introduced into multiple cosine similarities, and the multiple introduced cosine similarities can be obtained by the following formula:

[0094] ;

[0095] in, represents the feature encoder, c represents the category, represents the average embedding as the centroid of category c, x represents the query sample, p represents the cosine similarity, and τ represents a learnable scalar.

[0096] Step 140: Calculate the loss of the training task by similarity probability, and adjust the parameters of the full classification model according to the loss to obtain a few-sample keyword recognition model.

[0097] In some embodiments of the present application, the loss of the training task is calculated by similarity probability, and the parameters of the full classification model are adjusted according to the loss to obtain a few-sample keyword recognition model, including: calculating the deviation between the similarity probability and the preset probability to obtain the loss; adjusting the parameters of the full classification model according to the loss, and recalculating the latest loss of the training task, and when the latest loss meets the preset threshold, the few-sample keyword recognition model is obtained.

[0098] In the above process, the recognition accuracy of the small sample keyword recognition model can be continuously improved by calculating the loss.

[0099] Among them, the preset probability can be set according to needs.

[0100] Specifically, the deviation between the similarity probability and the preset probability is calculated, and the loss can be obtained by using the existing model loss calculation method, which is implemented by combining the cross entropy loss with the cosine similarity algorithm. Adjust the parameters of the full classification model according to the loss, and recalculate the latest loss of the training task, including adjusting the parameters of the full classification model according to the loss and retesting the few-sample keyword recognition model through query data. After the test, it is determined again whether the loss reaches the preset threshold. If not, the model parameters are adjusted again until the preset threshold is met. The preset threshold can be set according to needs.

[0101] In the above Figure 1 In the process shown, the present application trains the basic full classification model on all base classes through preset label data to obtain a classifier and an encoder, wherein the label data includes multiple texts with keyword labels; the classifier is trained in combination with the encoder to obtain a full classification model; the category centroid of the supporting samples is determined, and the similarity probability of the query sample belonging to the category corresponding to the category centroid is predicted in combination with the cosine similarity method; the loss of the training task is calculated by the similarity probability, and the parameters of the full classification model are adjusted according to the loss to obtain a few-sample keyword recognition model. By using the full classification and meta-learning method to train the keyword recognition model, which also combines the encoder and the cosine similarity method to calculate the sample category, the accuracy of the few-sample keyword recognition model can be improved, achieving the effect of quickly and accurately training the keyword recognition model while allowing the few-sample keyword recognition model to accurately recognize speech keywords.

[0102] Combine the following Figure 2 The method for identifying keywords in an embodiment of the present application is described in detail.

[0103] Please see Figure 2 , Figure 2 A flowchart of a method for identifying keywords provided in an embodiment of the present application is shown in FIG. Figure 2 The method for identifying keywords shown includes:

[0104] Step 210: Obtain the user's speech to be recognized.

[0105] In some embodiments of the present application, before obtaining the user's speech to be recognized, Figure 2The method shown also includes: training the basic full classification model on all base classes through preset label data to obtain a classifier and an encoder, wherein the label data includes multiple texts with keyword labels; training the classifier in combination with the encoder to obtain a full classification model; when training the model using the meta-learning method in the meta-training stage, determining the category centroid of the supporting samples, and combining the cosine similarity method to predict the similarity probability that the query sample belongs to the category corresponding to the category centroid; calculating the loss of the training task through the similarity probability, and adjusting the parameters of the full classification model according to the loss to obtain a few-sample keyword recognition model.

[0106] In the above process, the present application trains the keyword recognition model by using the full classification and meta-learning methods, which also combines the encoder and cosine similarity method to calculate the sample category to improve the accuracy of the few-sample keyword recognition model, so as to achieve the effect of quickly and accurately training the keyword recognition model while enabling the few-sample keyword recognition model to accurately recognize voice keywords.

[0107] Step 220: Identify keywords of the speech to be recognized using a preset few-sample keyword recognition model.

[0108] Among them, the keywords of the speech to be recognized are identified by a preset few-shot keyword recognition model, wherein the few-shot keyword recognition model is obtained by calculating the loss of the training task through the similarity probability, and adjusting the parameters of the full classification model according to the loss, and the similarity probability is obtained by determining the category centroid of the supporting sample when training the model using the meta-learning method in the meta-training stage, and combining the cosine similarity method to predict the probability that the query sample belongs to the category corresponding to the category centroid, and the full classification model is obtained by training the classifier through the encoder, and the classifier and the encoder are obtained by training the basic full classification model on all base classes through preset label data.

[0109] also, Figure 2 The specific methods and steps shown can be found in Figure 1 The method shown will not be described in detail here.

[0110] Previous article Figure 1-Figure 2 Describes the method of training a keyword recognition model and the method of recognizing keywords. Figure 3-Figure 6 A device for training a keyword recognition model and a device for recognizing keywords are described.

[0111] Please refer to Figure 3 , is a schematic block diagram of a device 300 for training a keyword recognition model provided in an embodiment of the present application, and the device 300 may be a module, program segment or code on an electronic device. Figure 1 The method embodiment corresponds to and can be executed Figure 1The various steps involved in the method embodiment and the specific functions of the device 300 can be found in the description below. To avoid repetition, the detailed description is appropriately omitted here.

[0112] Optionally, the device 300 includes:

[0113] A full classification module 310 is used to train a basic full classification model on all base classes using preset label data to obtain a classifier and an encoder, wherein the label data includes a plurality of texts with keyword labels;

[0114] A first training module 320, used to train the classifier in combination with the encoder to obtain a full classification model;

[0115] The meta-learning module 330 is used to determine the category centroid of the support sample when training the model using the meta-learning method in the meta-training stage, and to predict the similarity probability that the query sample belongs to the category corresponding to the category centroid by combining the cosine similarity method;

[0116] The second training module 340 is used to calculate the loss of the training task through similarity probability, and adjust the parameters of the full classification model according to the loss to obtain a few-sample keyword recognition model.

[0117] Optionally, the first training module is specifically used for:

[0118] The classifier is trained using the cross entropy loss algorithm and the last fully connected layer of the classifier is removed to obtain the encoder. The input of the classifier is mapped to the embedding through the encoder to obtain the full classification model.

[0119] Optionally, the meta-learning module is specifically used to:

[0120] The average embedding of the support samples is calculated and used as the category centroid; the cosine similarity between the query samples and the category centroid is calculated by the cosine similarity method to obtain multiple cosine similarities; a learnable scalar is introduced into the multiple cosine similarities to obtain multiple introduced cosine similarities; the similarity probability of the query samples belonging to the categories is judged by the multiple introduced cosine similarities.

[0121] Optionally, the first training module is specifically used for:

[0122] Extract the Mel-frequency cepstral coefficients of the label data; use the Mel-frequency cepstral coefficients as the input of the classifier, and use the encoder to convolve the keyword signal along the time axis to obtain a full classification model, wherein the encoder includes a preset convolution kernel step size and a dilated convolution.

[0123] Optionally, the device further comprises:

[0124] A preprocessing module is used for the full classification module to train the basic full classification model on all base classes with preset label data to obtain sample speech recorded by multiple people containing multiple keywords and background noise before obtaining the classifier and encoder; the sample speech is preprocessed to obtain label data, wherein the preprocessing includes: at least one processing method of filtering, grouping, equalization, division, mixed noise and setting a silent class.

[0125] Optionally, the second training module is specifically used for:

[0126] Calculate the deviation between the similarity probability and the preset probability to get the loss; adjust the parameters of the full classification model according to the loss, and recalculate the latest loss of the training task. When the latest loss meets the preset threshold, the few-sample keyword recognition model is obtained.

[0127] Please refer to Figure 4 , is a schematic block diagram of a device 400 for identifying keywords provided in an embodiment of the present application, and the device 400 may be a module, program segment or code on an electronic device. Figure 2 The method embodiment corresponds to and can be executed Figure 2 The various steps involved in the method embodiment and the specific functions of the device 400 can be found in the description below. To avoid repetition, the detailed description is appropriately omitted here.

[0128] Optionally, the device 400 includes:

[0129] An acquisition module 410 is used to acquire the user's speech to be recognized;

[0130] The recognition module 420 is used to recognize the keywords of the speech to be recognized through a preset few-sample keyword recognition model, wherein the few-sample keyword recognition model is obtained by calculating the loss of the training task through similarity probability and adjusting the parameters of the full classification model according to the loss. The similarity probability is obtained by determining the category centroid of the supporting samples when training the model using the meta-learning method in the meta-training stage, and combining the cosine similarity method to predict the probability that the query sample belongs to the category corresponding to the category centroid. The full classification model is obtained by training the classifier through the encoder, and the classifier and the encoder are obtained by training the basic full classification model on all base classes through preset label data.

[0131] Optionally, the device further comprises:

[0132] A training module is used for the acquisition module to train the basic full classification model on all base classes with preset label data before acquiring the user's speech to be recognized, so as to obtain a classifier and an encoder, wherein the label data includes multiple texts with keyword labels; the classifier is trained in combination with the encoder to obtain a full classification model; the category centroid of the supporting samples is determined, and the similarity probability that the query sample belongs to the category corresponding to the category centroid is predicted in combination with the cosine similarity method; the loss of the training task is calculated by the similarity probability, and the parameters of the full classification model are adjusted according to the loss to obtain a few-sample keyword recognition model.

[0133] Please refer to Figure 5 5 is a schematic block diagram of a device for training a keyword recognition model provided in an embodiment of the present application. The device may include a memory 510 and a processor 520. Optionally, the device may also include: a communication interface 530 and a communication bus 540. The device and the above Figure 1 The method embodiment corresponds to and can be executed Figure 1 The various steps involved in the method embodiment and the specific functions of the device can be found in the description below.

[0134] Specifically, the memory 510 is used to store computer-readable instructions.

[0135] Processor 520, configured to process readable instructions stored in the memory, capable of executing Figure 1 The steps in the method.

[0136] The communication interface 530 is used for signaling or data communication with other node devices, for example, for communication with a server or a terminal, or for communication with other device nodes, but the embodiments of the present application are not limited thereto.

[0137] The communication bus 540 is used to realize direct connection and communication among the above components.

[0138] The communication interface 530 of the device in the embodiment of the present application is used to communicate with other node devices for signaling or data. The memory 510 can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The memory 510 can also be at least one storage device located away from the aforementioned processor. The memory 510 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 520, the electronic device executes the aforementioned Figure 1The method process shown. The processor 520 can be used on the device 300 and used to perform the functions in the present application. Exemplarily, the above-mentioned processor 520 can be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and the embodiments of the present application are not limited thereto.

[0139] Please refer to Figure 6 6 is a schematic block diagram of a device for recognizing keywords provided in an embodiment of the present application. The device may include a memory 610 and a processor 620. Optionally, the device may also include: a communication interface 630 and a communication bus 640. The device is similar to the above Figure 2 The method embodiment corresponds to and can be executed Figure 2 The various steps involved in the method embodiment and the specific functions of the device can be found in the description below.

[0140] Specifically, the memory 610 is used to store computer-readable instructions.

[0141] Processor 620 is used to process the readable instructions stored in the memory and can execute Figure 2 The steps in the method.

[0142] The communication interface 630 is used for signaling or data communication with other node devices, for example, for communication with a server or a terminal, or for communication with other device nodes, but the embodiments of the present application are not limited thereto.

[0143] The communication bus 640 is used to realize direct connection and communication among the above components.

[0144] The communication interface 630 of the device in the embodiment of the present application is used to communicate with other node devices for signaling or data. The memory 610 can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The memory 610 can also be at least one storage device located away from the aforementioned processor. The memory 610 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 620, the electronic device executes the aforementioned Figure 2The method process shown. The processor 620 can be used on the device 400 and used to perform the functions in the present application. Exemplarily, the above-mentioned processor 620 can be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and the embodiments of the present application are not limited thereto.

[0145] The embodiment of the present application also provides a readable storage medium, when the computer program is executed by a processor, Figure 1 or Figure 2 The method process in the method embodiment shown is executed by the electronic device.

[0146] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method, and will not be described in detail here.

[0147] In summary, the embodiments of the present application provide a method for training a keyword recognition model, a method and device for recognizing keywords, the method comprising: training a basic full classification model on all base classes through preset label data to obtain a classifier and an encoder, wherein the label data includes multiple texts with keyword labels; training the classifier in combination with the encoder to obtain a full classification model; determining the category centroid of the supporting samples, and predicting the similarity probability that the query sample belongs to the category corresponding to the category centroid in combination with the cosine similarity method; calculating the loss of the training task through the similarity probability, and adjusting the parameters of the full classification model according to the loss to obtain a few-sample keyword recognition model. This method can accurately train the keyword recognition model and recognize the effect of speech keywords through the few-sample keyword recognition model with a small amount of training data.

[0148] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0149] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0150] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.

[0151] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0152] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0153] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

Claims

1. A method for training a keyword recognition model, characterized in that: include: A basic full classification model is trained on all base classes using preset label data to obtain a classifier and an encoder, wherein the label data includes a plurality of texts with keyword labels; The classifier is trained in combination with the encoder to obtain a full classification model, wherein the training of the classifier in combination with the encoder to obtain the full classification model includes: training the classifier through a cross entropy loss algorithm, and removing the last fully connected layer of the classifier to obtain the encoder, and mapping the input of the classifier to an embedding through the encoder to obtain the full classification model; When using the meta-learning method to train the model in the meta-training stage, the category centroid of the supporting samples is determined, and the cosine similarity method is used to predict the similarity probability that the query sample belongs to the category corresponding to the category centroid; The loss of the training task is calculated by the similarity probability, and the parameters of the full classification model are adjusted according to the loss to obtain a few-sample keyword recognition model.

2. The method according to claim 1, characterized in that When the model is trained using the meta-learning method in the meta-training stage, the category centroid of the supporting sample is determined, and the similarity probability that the query sample belongs to the category corresponding to the category centroid is predicted by combining the cosine similarity method, including: Calculate the average embedding of the samples and use the average embedding as the category centroid; Calculate the cosine similarities between the query sample and the centroid of the category respectively by the cosine similarity method to obtain multiple cosine similarities; Introducing a learnable scalar into the multiple cosine similarities to obtain multiple introduced cosine similarities; The similarity probabilities that the query samples belong to the categories are determined by using the multiple introduced cosine similarities.

3. The method according to claim 1 or 2, characterized in that: The combining the encoder to train the classifier to obtain a full classification model includes: Extracting Mel-frequency cepstral coefficients of the label data; The Mel-frequency cepstral coefficient is used as the input of the classifier, and the encoder is used to perform convolution processing on the keyword signal along the time axis to obtain the full classification model, wherein the encoder includes a preset convolution kernel step size and a dilated convolution.

4. The method according to claim 1 or 2, characterized in that: Before the basic full classification model is trained on all base classes by using preset label data to obtain the classifier and encoder, the method further includes: Obtain sample speech recorded by multiple people containing multiple keywords and background noise; The sample speech is preprocessed to obtain the label data, wherein the preprocessing includes: at least one processing method of filtering, grouping, equalization, division, mixed noise and setting a silence class.

5. The method according to claim 4, characterized in that The loss of the training task is calculated by the similarity probability, and the parameters of the full classification model are adjusted according to the loss to obtain a few-sample keyword recognition model, including: Calculating the deviation between the similarity probability and the preset probability to obtain the loss; The parameters of the full classification model are adjusted according to the loss, and the latest loss of the training task is recalculated. When the latest loss meets a preset threshold, the few-sample keyword recognition model is obtained.

6. A method for identifying keywords, characterized in that: include: Get the user's voice to be recognized; Keywords of the speech to be recognized are identified by a preset few-sample keyword recognition model, wherein the few-sample keyword recognition model is obtained by calculating the loss of the training task through similarity probability and adjusting the parameters of the full classification model according to the loss, the similarity probability is obtained by determining the category centroid of the supporting sample when training the model using the meta-learning method in the meta-training stage, and combining the cosine similarity method to predict the probability that the query sample belongs to the category corresponding to the category centroid, the full classification model is obtained by mapping the input of the classifier to the embedding through the encoder, the encoder is obtained by training the classifier through the cross entropy loss algorithm and removing the last fully connected layer of the classifier, and the classifier and the encoder are obtained by training the basic full classification model on all base classes through preset label data.

7. The method according to claim 6, characterized in that Before acquiring the user's speech to be recognized, the method further includes: The basic full classification model is trained on all base classes by using the preset label data to obtain the classifier and the encoder, wherein the label data includes a plurality of texts with keyword labels; Training the classifier in combination with the encoder to obtain the full classification model; When using the meta-learning method to train the model in the meta-training stage, determine the category centroid of the support sample, and use the cosine similarity method to predict the similarity probability that the query sample belongs to the category corresponding to the category centroid; The loss of the training task is calculated by the similarity probability, and the parameters of the full classification model are adjusted according to the loss to obtain the few-sample keyword recognition model.

8. A device for training a keyword recognition model, characterized in that: include: A full classification module, used to train a basic full classification model on all base classes through preset label data to obtain a classifier and an encoder, wherein the label data includes a plurality of texts with keyword labels; A first training module is used to train the classifier in combination with the encoder to obtain a full classification model, wherein the first training module is specifically used to: train the classifier through a cross entropy loss algorithm, and remove the last fully connected layer of the classifier to obtain the encoder, and map the input of the classifier to an embedding through the encoder to obtain the full classification model; A meta-learning module, used to determine the category centroid of the support sample when training the model using the meta-learning method in the meta-training phase, and to predict the similarity probability that the query sample belongs to the category corresponding to the category centroid by combining the cosine similarity method; The second training module is used to calculate the loss of the training task through the similarity probability, and adjust the parameters of the full classification model according to the loss to obtain a few-sample keyword recognition model.

9. A device for identifying keywords, characterized in that: include: An acquisition module is used to acquire the user's speech to be recognized; A recognition module is used to recognize keywords of the speech to be recognized through a preset few-sample keyword recognition model, wherein the few-sample keyword recognition model is obtained by calculating the loss of the training task through similarity probability and adjusting the parameters of the full classification model according to the loss, the similarity probability is obtained by determining the category centroid of the supporting sample when training the model using the meta-learning method in the meta-training stage, and combining the cosine similarity method to predict the probability that the query sample belongs to the category corresponding to the category centroid, the full classification model is obtained by mapping the input of the classifier to the embedding through the encoder, the encoder is trained by the cross entropy loss algorithm, and the last fully connected layer of the classifier is removed, and the classifier and the encoder are obtained by training the basic full classification model on all base classes through preset label data.