WO2023045949A1 - 一种模型训练方法及其相关设备 - Google Patents

一种模型训练方法及其相关设备 Download PDF

Info

Publication number
WO2023045949A1
WO2023045949A1 PCT/CN2022/120108 CN2022120108W WO2023045949A1 WO 2023045949 A1 WO2023045949 A1 WO 2023045949A1 CN 2022120108 W CN2022120108 W CN 2022120108W WO 2023045949 A1 WO2023045949 A1 WO 2023045949A1
Authority
WO
WIPO (PCT)
Prior art keywords
model
sequence
trained
data sequence
target
Prior art date
Application number
PCT/CN2022/120108
Other languages
English (en)
French (fr)
Inventor
黄文勇
张真赫
杨宇庭
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP22871995.1A priority Critical patent/EP4401000A1/en
Publication of WO2023045949A1 publication Critical patent/WO2023045949A1/zh
Priority to US18/617,095 priority patent/US20240265256A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0464Convolutional networks [CNN, ConvNet]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/764Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/82Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L15/00Speech recognition
    • G10L15/08Speech classification or search
    • G10L15/16Speech classification or search using artificial neural networks

Definitions

  • This application relates to the technical field of artificial intelligence (AI), in particular to a model training method and related equipment.
  • AI artificial intelligence
  • the data sequence can be processed through the neural network model to obtain the label of the data sequence.
  • the voice sequence can be recognized through the neural network model to obtain the corresponding text of the voice sequence.
  • Another example is, Classify the image sequence through the neural network to obtain the category of the image sequence and so on.
  • the training process of the aforementioned neural network model usually includes two stages, namely a pre-training (pre-train) stage and a fine-tuning (fine-tune) stage.
  • pre-train pre-training
  • fine-tune fine-tune stage.
  • the model to be trained can be obtained, and the first data sequence (usually a data sequence with an unknown label) is used to pre-train the model to be trained, and then the second data sequence (usually a data sequence with a known label) is used to pre-train
  • the obtained model is fine-tuned to obtain the aforementioned neural network model.
  • the aforementioned pre-training stage is often designed to be very complicated, resulting in the inability to use the perturbed first data sequence to complete the pre-training of the model to be trained.
  • the final neural network model is usually only able to accurately obtain the labels of the data sequence under normal conditions (for example, a speech sequence in a quiet environment), but cannot accurately obtain the data sequence under abnormal conditions (that is, after disturbance) (eg, speech sequences in noisy environments).
  • the embodiment of the present application provides a model training method and related equipment. Based on the final model obtained by this method, not only the labels of the data sequences under normal conditions can be accurately obtained, but the labels of the data sequences under abnormal conditions cannot be accurately obtained. .
  • the first aspect of the embodiments of the present application provides a model training method, the method comprising:
  • the first model to be trained and the second model to be trained can be obtained, and pre-training is performed on the first model to be trained and the second model to be trained.
  • the structure of the first model to be trained and the structure of the second model to be trained may be the same.
  • the first data sequence may be obtained, and the first data sequence may be perturbed, so as to obtain the perturbed first data sequence.
  • the first data sequence includes multiple elements, and each element represents a certain part of the data.
  • the disturbed first data sequence also contains multiple elements, and each element represents a certain part of the disturbed data.
  • the disturbed first data sequence can be input into the first model to be trained, so as to perform feature extraction processing on the disturbed first data sequence through the first model to be trained to obtain the first feature sequence, and the first data The sequence is input to the second model to be trained, so that the first data sequence is processed by the second model to be trained to obtain a second feature sequence.
  • the first model to be trained can be trained to obtain the first target model.
  • the second model to be trained can also be jointly trained, that is, the parameters of the second model to be trained are updated according to the parameters in the training process of the first model to be trained, so as to obtain the second target model.
  • the first target model or the second target model is fine-tuned to obtain the third target model, and the third target model is used to obtain the label of the data sequence.
  • the above method provides a new model training architecture, which includes two branches, the first model to be trained and the second model to be trained, and can realize joint pre-training of the two models.
  • the first data sequence can be processed through the branch where the first model to be trained is located, to obtain the first feature sequence, and through the second model to be trained
  • the branch where it is located processes the disturbed first data sequence to obtain the second feature sequence.
  • the first model to be trained and the second model to be trained are jointly trained to correspondingly obtain the first target model and the second target model.
  • the first target model or the second target model is fine-tuned to obtain the third target model
  • the third target model is used to obtain the label of the data sequence.
  • the first model to be trained can be used to perform feature extraction on the disturbed first data sequence
  • the second model to be trained can be used to perform feature extraction on the original first data sequence
  • the two features obtained by feature extraction are jointly trained on the first model to be trained and the second model to be trained to complete the pre-training of the two models, and the final model (ie, the third target model) obtained based on this pre-training method, Not only can the label of the data sequence under normal conditions be accurately obtained, but the label of the data sequence under abnormal conditions (that is, after disturbance) cannot be accurately obtained.
  • training the first model to be trained and the second model to be trained according to the first feature sequence and the second feature sequence, and obtaining the first target model and the second target model include: according to the first The feature sequence and the second feature sequence obtain the first loss, and the first loss is used to indicate the difference between the first feature sequence and the second feature sequence; update the parameters of the first model to be trained according to the first loss, and according to the updated The parameters of the first model to be trained are updated to the parameters of the second model to be trained until the model training conditions are met, and the first target model and the second target model are obtained.
  • the first feature sequence and the second feature sequence can be calculated through the preset first loss function to obtain the first loss, which is used to indicate The difference between the first feature sequence and the second feature sequence, that is, for any element in the first feature sequence, the first loss is used to indicate that the element is different from the corresponding element in the second feature sequence (ie, the second feature The difference between identically ordered elements in a sequence).
  • the parameters of the first model to be trained may be updated according to the first loss
  • the parameters of the second model to be trained may be updated according to the updated parameters of the first model to be trained.
  • the next batch of first data sequences can be collected continuously, and the updated first model to be trained and the updated second model to be trained can be used to continue training until the model training condition (for example, the first loss converges, etc.), which is equivalent to completing the pre-training of the first model to be trained and the pre-training of the second model to be trained, and correspondingly obtain the first target model and the second target model.
  • the model training condition For example, the first loss converges, etc.
  • the updated parameters of the second model to be trained are determined according to the updated parameters of the first model to be trained, parameters of the second model to be trained, and preset weights.
  • any round of training can be understood as the training of the two models using the first data sequence of the batch.
  • the training process of the current round that is, during the training of the two models using the current batch of first data sequences
  • the moving average of the historical parameters of the first model to be trained can be used as the parameter of the second model to be trained, and the joint training of the two models can be realized to optimize the performance of the finally obtained model.
  • fine-tuning the first target model or the second target model to obtain the third target model includes: acquiring the second data sequence; converting one of the first target model and the second target model to Fusing with the preset model to obtain a third model to be trained; processing the second data sequence through the third model to be trained to obtain the predicted label of the second data sequence; according to the real label and predicted label of the second data sequence, Train the third model to be trained to obtain a third target model.
  • the first target model and the second target model can be obtained after completing the pre-training of the first model to be trained and the pre-training of the second model to be trained. Since the two are similar in function, it can be selected First, fine-tuning is performed to obtain a third target model that can be used in practical applications, that is, a neural network model with labels for acquiring data sequences.
  • the first data sequence is processed by the first model to be trained to obtain the first feature sequence
  • the disturbed first data sequence is processed by the second model to be trained to obtain the second feature sequence.
  • the method further includes: adding padding elements at both ends of the first data sequence or both ends of the perturbed first data sequence.
  • filling elements can be added to the first data sequence or the perturbed first data sequence, so that the two models In the training process, not only the position information of the elements in the sequence is used, but also the content of the elements in the sequence can be better learned, thereby improving the performance of the final model.
  • the perturbation includes at least one of adding noise, adding reverberation, and adding a time-frequency domain mask.
  • the first data sequence and the second data sequence are speech sequences
  • the third target model is used to obtain the label of the data sequence
  • the third target model is used to obtain the recognition result of the speech sequence
  • the third target model can be used to obtain the text corresponding to the speech sequence
  • the first data sequence and the second data sequence are text sequences
  • the third target model is used to obtain the label of the data sequence, specifically the third target model is used to obtain
  • the recognition result of the text sequence for example, the third target model can be used to obtain the content of the text sequence; or, the first data sequence and the second data sequence are image sequences, and the third target model is used to obtain the label of the data sequence, specifically the first
  • the three-object model is used to obtain the classification result of the image sequence, for example, the third object model can be used to obtain the category of the image sequence.
  • the second aspect of the embodiment of the present application provides a method for obtaining a sequence label, the method comprising: obtaining a target data sequence; processing the target data sequence through a third target model to obtain a label of the target data sequence, and the third target model It is obtained by performing training according to the first aspect or any possible implementation manner in the first aspect.
  • the third target model is obtained based on one of the branches in the aforementioned training framework, so the third target model can perform certain processing on the target data sequence to accurately obtain the label of the target data sequence, It has better label acquisition ability.
  • the third aspect of the embodiment of the present application provides a model training device, which includes: an acquisition module, used to acquire the first data sequence and the disturbed first data sequence; a pre-training model module, used to pass the first waiting
  • the training model processes the disturbed first data sequence to obtain the first feature sequence, and processes the first data sequence through the second model to be trained to obtain the second feature sequence;
  • the pre-training module is also used to obtain the second feature sequence according to the first A feature sequence and a second feature sequence, train the first model to be trained and the second model to be trained to obtain the first target model and the second target model, wherein the first target model is based on the first feature sequence and the second feature
  • the sequence is obtained by training the first model to be trained, and the second target model is obtained according to the parameters in the training process of the first model to be trained;
  • the fine-tuning module is used to fine-tune the first target model or the second target model to obtain the second target model
  • Three-objective model, the third objective model is used to obtain the labels of the data
  • the above device provides a new model training architecture, which includes two branches, the first model to be trained and the second model to be trained, and can realize joint pre-training of the two models.
  • the first data sequence can be processed through the branch where the first model to be trained is located, to obtain the first feature sequence, and through the second model to be trained
  • the branch where it is located processes the disturbed first data sequence to obtain the second feature sequence.
  • the first model to be trained and the second model to be trained are jointly trained to correspondingly obtain the first target model and the second target model.
  • the first target model or the second target model is fine-tuned to obtain the third target model
  • the third target model is used to obtain the label of the data sequence.
  • the first model to be trained can be used to perform feature extraction on the disturbed first data sequence
  • the second model to be trained can be used to perform feature extraction on the original first data sequence
  • the two features obtained by feature extraction are jointly trained on the first model to be trained and the second model to be trained to complete the pre-training of the two models, and the final model (ie, the third target model) obtained based on this pre-training method, Not only can the label of the data sequence under normal conditions be accurately obtained, but the label of the data sequence under abnormal conditions (that is, after disturbance) cannot be accurately obtained.
  • the pre-training module is configured to: obtain a first loss according to the first feature sequence and the second feature sequence, and the first loss is used to indicate the difference between the first feature sequence and the second feature sequence Difference; update the parameters of the first model to be trained according to the first loss, and update the parameters of the second model to be trained according to the parameters of the updated first model to be trained, until the model training conditions are met, and the first target model and the second target model.
  • the updated parameters of the second model to be trained are determined according to the updated parameters of the first model to be trained, parameters of the second model to be trained, and preset weights.
  • the fine-tuning module is configured to: obtain the second data sequence; fuse one of the first target model and the second target model with a preset model to obtain a third model to be trained ;
  • the second data sequence is processed by the third model to be trained to obtain the predicted label of the second data sequence; according to the real label and predicted label of the second data sequence, the third model to be trained is trained to obtain the third target model .
  • the obtaining module is further configured to add padding elements at both ends of the first data sequence or both ends of the perturbed first data sequence.
  • the perturbation includes at least one of adding noise, adding reverberation, and adding a time-frequency domain mask.
  • the first data sequence and the second data sequence are speech sequences
  • the third target model is used to obtain the label of the data sequence, specifically, the third target model is used to obtain the recognition result of the speech sequence
  • the first data sequence and the second data sequence are text sequences
  • the third target model is used to obtain the label of the data sequence, specifically, the third target model is used to obtain the recognition result of the text sequence
  • the first data sequence and the second The data sequence is an image sequence
  • the third target model is used to obtain a label of the data sequence, specifically, the third target model is used to obtain a classification result of the image sequence.
  • the fourth aspect of the embodiment of the present application provides a sequence label acquisition device, the device includes: an acquisition module, used to acquire the target data sequence; a processing module, used to process the target data sequence through the third target model, to obtain The label of the target data sequence, and the third target model is obtained by training according to the model training method described in the first aspect or any possible implementation manner of the first aspect.
  • the third target model is obtained based on one of the branches in the aforementioned training framework, so the third target model can perform certain processing on the target data sequence to accurately obtain the label of the target data sequence, It has better label acquisition ability.
  • the fifth aspect of the embodiment of the present application provides a model training device, which includes a memory and a processor; the memory stores codes, the processor is configured to execute the codes, and when the codes are executed, the model training device performs the first Aspect or the method described in any possible implementation manner of the first aspect.
  • the sixth aspect of the embodiment of the present application provides a device for obtaining a sequence tag, the device includes a memory and a processor; the memory stores code, the processor is configured to execute the code, and when the code is executed, the device for obtaining a sequence tag Execute the method as in the second aspect.
  • a seventh aspect of the embodiments of the present application provides a circuit system, where the circuit system includes a processing circuit configured to perform the processing described in the first aspect, any possible implementation manner of the first aspect, or the second aspect. Methods.
  • the eighth aspect of the embodiments of the present application provides a chip system, the chip system includes a processor, used to call the computer program or computer instruction stored in the memory, so that the processor executes the first aspect, the first aspect Any possible implementation or the method described in the second aspect.
  • the processor is coupled to the memory through an interface.
  • the chip system further includes a memory, where computer programs or computer instructions are stored.
  • the ninth aspect of the embodiments of the present application provides a computer storage medium, the computer storage medium stores a computer program, and when the program is executed by a computer, the computer implements any one of the possible methods of the first aspect and the first aspect.
  • the tenth aspect of the embodiments of the present application provides a computer program product, the computer program product stores instructions, and when the instructions are executed by a computer, the computer implements any one of the possible implementations of the first aspect and the first aspect way or the method described in the second aspect.
  • the embodiment of the present application provides a new model training architecture, which includes two branches, the first model to be trained and the second model to be trained, and can realize joint pre-training of the two models.
  • the first data sequence can be processed through the branch where the first model to be trained is located, to obtain the first feature sequence, and through the second model to be trained
  • the branch where it is located processes the disturbed first data sequence to obtain the second feature sequence.
  • the first model to be trained and the second model to be trained are jointly trained to correspondingly obtain the first target model and the second target model.
  • the first target model or the second target model is fine-tuned to obtain the third target model
  • the third target model is used to obtain the label of the data sequence.
  • the first model to be trained can be used to perform feature extraction on the disturbed first data sequence
  • the second model to be trained can be used to perform feature extraction on the original first data sequence
  • the two features obtained by feature extraction are jointly trained on the first model to be trained and the second model to be trained to complete the pre-training of the two models, and the final model (ie, the third target model) obtained based on this pre-training method, Not only can the label of the data sequence under normal conditions be accurately obtained, but the label of the data sequence under abnormal conditions (that is, after disturbance) cannot be accurately obtained.
  • Fig. 1 is a kind of structural schematic diagram of main frame of artificial intelligence
  • FIG. 2a is a schematic structural diagram of a data sequence processing system provided by an embodiment of the present application.
  • Fig. 2b is another schematic structural diagram of the data sequence processing system provided by the embodiment of the present application.
  • Figure 2c is a schematic diagram of related equipment for data sequence processing provided by the embodiment of the present application.
  • FIG. 3 is a schematic diagram of the architecture of the system 100 provided by the embodiment of the present application.
  • Fig. 4 is a schematic flow chart of the model training method provided by the embodiment of the present application.
  • Fig. 5 is a schematic diagram of the pre-training stage provided by the embodiment of the present application.
  • FIG. 6 is another schematic flowchart of the model training method provided by the embodiment of the present application.
  • FIG. 7 is another schematic diagram of the pre-training stage provided by the embodiment of the present application.
  • FIG. 8 is another schematic flowchart of the model training method provided by the embodiment of the present application.
  • FIG. 9 is a schematic flow chart of a method for obtaining a sequence tag provided in an embodiment of the present application.
  • FIG. 10 is a schematic structural diagram of a model training device provided in an embodiment of the present application.
  • FIG. 11 is a schematic structural diagram of a sequence tag acquisition device provided in the embodiment of the present application.
  • Fig. 12 is a schematic structural diagram of the execution device provided by the embodiment of the present application.
  • Fig. 13 is a schematic structural diagram of the training equipment provided by the embodiment of the present application.
  • FIG. 14 is a schematic structural diagram of a chip provided by an embodiment of the present application.
  • the embodiment of the present application provides a model training method and related equipment. Based on the final model obtained by this method, not only the labels of the data sequences under normal conditions can be accurately obtained, but the labels of the data sequences under abnormal conditions cannot be accurately obtained. .
  • the data sequence can be processed through the neural network model in AI technology to obtain the label of the data sequence.
  • the speech sequence can be recognized through the neural network model to obtain the corresponding text of the speech sequence , as another example, classify the image sequence through the neural network to obtain the category of the image sequence, and for another example, recognize the text sequence through the neural network model to obtain the content indicated by the text sequence, and so on.
  • the training process of the aforementioned neural network model usually includes two stages, namely, a pre-training stage based on a supervised learning method and a fine-tuning stage based on an unsupervised learning method.
  • the following takes the data sequence as a speech sequence as an example for introduction.
  • the model to be trained can be obtained, and the first speech sequence (the text corresponding to the first speech sequence is unknown) is used to pre-train the model to be trained, and then the second speech sequence (the text corresponding to the second speech sequence is unknown) ) to fine-tune the pre-trained model to obtain a neural network model that can realize speech recognition.
  • the aforementioned pre-training stage is often designed to be very complicated, and traditional data augmentation methods cannot be used to perturb the first speech sequence (for example, adding noise to the first speech sequence, etc.), resulting in the inability to use the perturbed first data
  • the sequence-to-be-trained model completes pre-training.
  • the final neural network model when applied in practice, it can usually only accurately obtain the labels of data sequences under normal conditions (for example, speech sequences in quiet environments), but cannot accurately obtain labels under abnormal conditions (that is, disturbances).
  • the label of the data sequence for example, the speech sequence in the noise environment).
  • AI technology is a technical discipline that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence. AI technology obtains the best results by perceiving the environment, acquiring knowledge and using knowledge.
  • artificial intelligence technology is a branch of computer science that attempts to understand the nature of intelligence and produce a new kind of intelligent machine that can respond in a similar way to human intelligence.
  • the use of artificial intelligence for data processing is a common application of artificial intelligence.
  • Figure 1 is a schematic structural diagram of the main framework of artificial intelligence, from the “intelligent information chain” (horizontal axis) and “IT value chain” (vertical axis)
  • the "intelligent information chain” reflects a series of processes from data acquisition to processing.
  • it can be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output.
  • the data has undergone a condensed process of "data-information-knowledge-wisdom”.
  • IT value chain reflects the value brought by artificial intelligence to the information technology industry from the underlying infrastructure of artificial intelligence, information (provided and processed by technology) to the systematic industrial ecological process.
  • the infrastructure provides computing power support for the artificial intelligence system, realizes communication with the outside world, and realizes support through the basic platform.
  • the basic platform includes distributed computing framework and network and other related platform guarantees and supports, which can include cloud storage and Computing, interconnection network, etc.
  • sensors communicate with the outside to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
  • Data from the upper layer of the infrastructure is used to represent data sources in the field of artificial intelligence.
  • the data involves graphics, images, voice, text, and IoT data of traditional equipment, including business data of existing systems and sensory data such as force, displacement, liquid level, temperature, and humidity.
  • Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making, etc.
  • machine learning and deep learning can symbolize and formalize intelligent information modeling, extraction, preprocessing, training, etc. of data.
  • Reasoning refers to the process of simulating human intelligent reasoning in a computer or intelligent system, and using formalized information to carry out machine thinking and solve problems according to reasoning control strategies.
  • the typical functions are search and matching.
  • Decision-making refers to the process of decision-making after intelligent information is reasoned, and usually provides functions such as classification, sorting, and prediction.
  • some general capabilities can be formed based on the results of data processing, such as algorithms or a general system, such as translation, text analysis, computer vision processing, speech recognition, image processing identification, etc.
  • Intelligent products and industry applications refer to the products and applications of artificial intelligence systems in various fields. It is the packaging of the overall solution of artificial intelligence, which commercializes intelligent information decision-making and realizes landing applications. Its application fields mainly include: intelligent terminals, intelligent transportation, Smart healthcare, autonomous driving, smart cities, etc.
  • Fig. 2a is a schematic structural diagram of a data sequence processing system provided by an embodiment of the present application.
  • the data sequence processing system includes a user device and a data processing device.
  • the user equipment includes smart terminals such as a mobile phone, a personal computer, or an information processing center.
  • the user equipment is the initiator of the data sequence processing, and as the initiator of the data sequence processing request, usually the user initiates the request through the user equipment.
  • the above-mentioned data processing device may be a device or server having a data processing function such as a cloud server, a network server, an application server, and a management server.
  • the data processing device receives the image processing request from the intelligent terminal through the interactive interface, and then performs image processing such as machine learning, deep learning, search, reasoning, and decision-making through the memory for storing data and the processor link of data processing.
  • the storage in the data processing device may be a general term, including local storage and a database storing historical data, and the database may be on the data processing device or on other network servers.
  • the user equipment can receive the user's instruction, for example, the user equipment can obtain a data sequence (for example, voice sequence, image sequence and text sequence, etc.) input/selected by the user, and then send The data processing device initiates a request, so that the data processing device processes the data sequence obtained by the user equipment (for example, acquires a label of the data sequence, etc.), so as to obtain a processing result for the data sequence.
  • the user equipment may acquire an image input by the user, and then initiate a speech sequence recognition request to the data processing device, so that the data processing device recognizes the speech sequence, thereby obtaining the recognition result of the speech sequence, that is, the speech The text corresponding to the sequence.
  • the data processing device may execute the method for obtaining a sequence tag according to the embodiment of the present application.
  • Fig. 2b is another schematic diagram of the structure of the data sequence processing system provided by the embodiment of the present application.
  • the user equipment is directly used as a data processing equipment, and the user equipment can directly obtain the input from the user and be directly controlled by the hardware of the user equipment itself.
  • the specific process is similar to that in FIG. 2a , and reference may be made to the above description, which will not be repeated here.
  • the user equipment can receive user instructions, for example, the user equipment can obtain a data sequence selected by the user in the user equipment, and then the user equipment itself executes the data sequence for the data sequence processing (for example, obtaining the label of the data sequence, etc.), so as to obtain a processing result for the label of the obtained data sequence.
  • the user equipment can receive user instructions, for example, the user equipment can obtain a data sequence selected by the user in the user equipment, and then the user equipment itself executes the data sequence for the data sequence processing (for example, obtaining the label of the data sequence, etc.), so as to obtain a processing result for the label of the obtained data sequence.
  • the user equipment itself can execute the method for obtaining a sequence tag in the embodiment of the present application.
  • FIG. 2c is a schematic diagram of related equipment for data sequence processing provided by the embodiment of the present application.
  • the above-mentioned user equipment in FIG. 2a and FIG. 2b may specifically be the local device 301 or the local device 302 in FIG. 2c, and the data processing device in FIG. 2a may specifically be the execution device 210 in FIG.
  • the data storage system 250 may be integrated on the execution device 210, or set on the cloud or other network servers.
  • the processors in Figure 2a and Figure 2b can perform data training/machine learning/deep learning through a neural network model or other models (for example, a model based on a support vector machine), and use the data to finally train or learn the model for image execution Image processing application, so as to obtain the corresponding processing results.
  • a neural network model or other models for example, a model based on a support vector machine
  • FIG. 3 is a schematic diagram of the architecture of the system 100 provided by the embodiment of the present application.
  • the execution device 110 is configured with an input/output (input/output, I/O) interface 112 for data interaction with external devices, and the user Data can be input to the I/O interface 112 through the client device 140, and the input data in this embodiment of the application may include: various tasks to be scheduled, callable resources, and other parameters.
  • I/O input/output
  • the execution device 110 When the execution device 110 preprocesses the input data, or when the calculation module 111 of the execution device 110 executes calculations and other related processing (such as implementing the function of the neural network in this application), the execution device 110 can call the data storage system 150
  • the data, codes, etc. in the system can be used for corresponding processing, and the data, instructions, etc. obtained by corresponding processing can also be stored in the data storage system 150 .
  • the I/O interface 112 returns the processing result to the client device 140, thereby providing it to the user.
  • the training device 120 can generate corresponding target models/rules based on different training data for different goals or different tasks, and the corresponding target models/rules can be used to achieve the above-mentioned goals or complete the above-mentioned tasks , giving the user the desired result.
  • the training data may be stored in the database 130 and come from training samples collected by the data collection device 160 .
  • the user can manually specify the input data, and the manual specification can be operated through the interface provided by the I/O interface 112 .
  • the client device 140 can automatically send the input data to the I/O interface 112 . If the client device 140 is required to automatically send the input data to obtain the user's authorization, the user can set the corresponding authority in the client device 140 .
  • the user can view the results output by the execution device 110 on the client device 140, and the specific presentation form may be specific ways such as display, sound, and action.
  • the client device 140 can also be used as a data collection terminal, collecting the input data input to the I/O interface 112 as shown in the figure and the output results of the output I/O interface 112 as new sample data, and storing them in the database 130 .
  • the client device 140 may not be used for collection, but the I/O interface 112 directly uses the input data input to the I/O interface 112 as shown in the figure and the output result of the output I/O interface 112 as a new sample.
  • the data is stored in database 130 .
  • FIG. 3 is only a schematic diagram of a system architecture provided by the embodiment of the present application, and the positional relationship between devices, devices, modules, etc. shown in the figure does not constitute any limitation.
  • the data The storage system 150 is an external memory relative to the execution device 110 , and in other cases, the data storage system 150 may also be placed in the execution device 110 .
  • the neural network can be obtained by training according to the training device 120 .
  • An embodiment of the present application also provides a chip, the chip includes a neural network processor (NPU).
  • the chip can be set in the execution device 110 shown in FIG. 3 to complete the computing work of the computing module 111 .
  • the chip can also be set in the training device 120 shown in FIG. 3 to complete the training work of the training device 120 and output the target model/rule.
  • NPU neural network processor
  • the neural network processor NPU is mounted on the main central processing unit (central processing unit, CPU) (host CPU) as a coprocessor, and the main CPU assigns tasks.
  • the core part of the NPU is the operation circuit, and the controller controls the operation circuit to extract the data in the memory (weight memory or input memory) and perform operations.
  • the operation circuit includes multiple processing units (process engine, PE).
  • the arithmetic circuit is a two-dimensional systolic array.
  • the arithmetic circuit may also be a one-dimensional systolic array or other electronic circuitry capable of performing mathematical operations such as multiplication and addition.
  • the arithmetic circuit is a general purpose matrix processor.
  • the operation circuit fetches the data corresponding to the matrix B from the weight memory, and caches it on each PE in the operation circuit.
  • the operation circuit takes the data of matrix A from the input memory and performs matrix operation with matrix B, and the obtained partial or final results of the matrix are stored in the accumulator.
  • the vector calculation unit can further process the output of the operation circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc.
  • the vector computing unit can be used for network calculations of non-convolution/non-FC layers in neural networks, such as pooling, batch normalization, local response normalization, etc.
  • the vector computation unit can store the processed output vectors to a unified register.
  • a vector computation unit may apply a non-linear function to the output of the arithmetic circuit, such as a vector of accumulated values, to generate activation values.
  • the vector computation unit generates normalized values, merged values, or both.
  • the vector of processed outputs can be used as an activation input to an operational circuit, for example for use in a subsequent layer in a neural network.
  • Unified memory is used to store input data and output data.
  • the weight data directly transfers the input data in the external memory to the input memory and/or the unified memory through the storage unit access controller (direct memory access controller, DMAC), stores the weight data in the external memory into the weight memory, and stores the weight data in the unified memory Store the data in the external memory.
  • DMAC direct memory access controller
  • bus interface unit (bus interface unit, BIU) is used to realize the interaction between the main CPU, DMAC and instruction fetch memory through the bus.
  • the instruction fetch buffer connected to the controller is used to store the instructions used by the controller
  • the controller is used for invoking instructions cached in the memory to control the working process of the computing accelerator.
  • the unified memory, the input memory, the weight memory and the instruction fetch memory are all on-chip (On-Chip) memory
  • the external memory is the memory outside the NPU
  • the external memory can be a double data rate synchronous dynamic random access memory (double data rate synchronous dynamic random access memory, DDR SDRAM), high bandwidth memory (high bandwidth memory, HBM) or other readable and writable memory.
  • the neural network can be composed of neural units, and the neural unit can refer to an operation unit that takes xs and intercept 1 as input, and the output of the operation unit can be:
  • Ws is the weight of xs
  • b is the bias of the neural unit.
  • f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal. The output signal of this activation function can be used as the input of the next convolutional layer.
  • the activation function may be a sigmoid function.
  • a neural network is a network formed by connecting many of the above-mentioned single neural units, that is, the output of one neural unit can be the input of another neural unit.
  • the input of each neural unit can be connected with the local receptive field of the previous layer to extract the features of the local receptive field.
  • the local receptive field can be an area composed of several neural units.
  • W is a weight vector, and each value in the vector represents the weight value of a neuron in this layer of neural network.
  • the vector W determines the space transformation from the input space to the output space described above, that is, the weight W of each layer controls how to transform the space.
  • the purpose of training the neural network is to finally obtain the weight matrix of all layers of the trained neural network (the weight matrix formed by the vector W of many layers). Therefore, the training process of the neural network is essentially to learn the way to control the spatial transformation, and more specifically, to learn the weight matrix.
  • the neural network can use the error back propagation (back propagation, BP) algorithm to correct the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, passing the input signal forward until the output will generate an error loss, and updating the parameters in the initial neural network model by backpropagating the error loss information, so that the error loss converges.
  • the backpropagation algorithm is a backpropagation movement dominated by error loss, aiming to obtain the optimal parameters of the neural network model, such as the weight matrix.
  • the model training method provided in the embodiment of this application involves the processing of data sequences, and can be specifically applied to methods such as data training, machine learning, and deep learning.
  • training data such as the first data sequence in this application, the first data sequence and the second data sequence
  • sequence label acquisition method can use the above-mentioned trained neural network, input the input data (such as the target data sequence in this application) into the trained neural network, and obtain the output data (such as the target data sequence in this application) label of the target data sequence in , etc.
  • the model training method and sequence label acquisition method provided in the embodiment of this application are inventions based on the same idea, and can also be understood as two parts in a system, or two stages of an overall process: Such as model training phase and model application phase.
  • Fig. 4 is a schematic flow chart of the model training method provided by the embodiment of the present application. As shown in Fig. 4, the method includes:
  • the first model to be trained and the second model to be trained can be obtained, and the first model to be trained and the second model to be trained are firstly processed. pre-training.
  • the structure of the first model to be trained and the structure of the second model to be trained can be the same, for example, the first model to be trained can include a convolutional layer, a fully connected layer, a pooling layer, a normalization layer, etc. Any one or any combination of them, the same is true for the second model to be trained, which will not be repeated here.
  • the current batch of first training data can be collected earlier, and the first batch of training data includes the current batch of the first data sequence used for training, and the type of the first data sequence can vary due to actual needs (i.e. the first The types of data sequences are diverse), and the first data sequence is a data sequence with unknown labels (it can also be understood as a data sequence without annotations), for example, the first data sequence can be the first voice sequence, and the first voice sequence The corresponding text is unknown.
  • the first data sequence may be a first image sequence, and the category of the first image sequence is unknown.
  • the first data sequence may be a first text sequence, and the content of the first text sequence (or, the part of speech of the first text sequence, etc.) is unknown, and so on.
  • the first data sequence includes multiple elements, and each element represents a certain part of data.
  • Figure 5 Figure 5 is a schematic diagram of the pre-training stage provided by the embodiment of the present application
  • Xi is usually a vector representing a certain part of the data (for example, a segment of speech, an image block of an image, a vocabulary of text, etc.).
  • the first data sequence may be disturbed to obtain a disturbed first data sequence.
  • the perturbed first data sequence also includes a plurality of elements, and each element represents a certain part of the perturbed data.
  • the ith element of the first data sequence X′ of , i 1, 2, . . . , N.
  • X′ i is usually a vector representing a certain part of the perturbed data.
  • the length of the original first data sequence and the length of the disturbed first data sequence are usually the same. Compared with the original first data sequence, the part of the disturbed first data sequence The elements have changed, and the example shown in Figure 5 is still the same.
  • the second element X 2 in the first data sequence X and the element X in the first data sequence X' after the disturbance are The second element X′ 2 is different, the third element X 3 in the first data sequence X is different from the third element X′ 3 in the disturbed first data sequence X′, and the first data sequence X
  • the remaining elements of are the same as the remaining elements in the first data sequence X' after the disturbance, that is, the first element X 1 in the first data sequence X is the same as the first element X in the first data sequence X' after the disturbance ' 1 is the same, the fourth element X4 in the first data sequence X is the same as the fourth element X'4 in the perturbed first data sequence X' and so on.
  • the method of perturbing the first data sequence can be determined according to the type of the first data sequence. Still as in the above example, assuming that the collected first speech sequence is a speech sequence in a quiet environment, the traditional data expansion method can be used Disturb the first speech sequence, that is, add noise to the first speech sequence, so that some elements in the original first speech sequence change, and obtain a disturbed first speech sequence, that is, a speech sequence in a noise environment.
  • the method of perturbing the first speech sequence may also be to add reverberation to the first speech sequence, and for another example, the method of perturbing the first speech sequence may also be to add a time-frequency domain mask (mask) to the first speech sequence, and so on.
  • mask time-frequency domain mask
  • the first text sequence can also be perturbed, for example, adding a word mask to the first text sequence, randomly exchanging element positions in the sequence (that is, exchanging words in adjacent positions in the text), etc., or Perturb the first image sequence, for example, convert the first image sequence originally used to represent a color image into the first image sequence used to represent a black-and-white image, add a mask to a random region of the first image sequence, and so on.
  • the disturbed first data sequence can be input to the first model to be trained, so as to perform feature extraction on the disturbed first data sequence through the first model to be trained processing to obtain the first feature sequence.
  • the first data sequence can also be input into the second model to be trained, so as to perform feature extraction processing on the first data sequence through the second model to be trained to obtain the second feature sequence.
  • the first feature sequence includes multiple elements, each element represents a feature of a certain part of the data, and the second feature sequence also contains multiple elements, and each element represents a feature of a certain part of the perturbed data.
  • h i is usually a vector, which represents the characteristics of a certain part of the data.
  • the first model to be trained and the second model to be trained are trained to obtain the first target model and the second target model accordingly .
  • the first target model and the second target model can be obtained in the following ways:
  • the first feature sequence and the second feature sequence can be calculated through the preset first loss function to obtain the first loss, which is used to indicate the first
  • the difference between the feature sequence and the second feature sequence, that is, for any element in the first feature sequence, the first loss is used to indicate that the element is different from the corresponding element in the second feature sequence (that is, in the second feature sequence
  • the purpose of pre-training is to make the i-th element h' i of the first feature sequence H' as close as possible to the first
  • the i-th element h i in the second feature sequence H is as far away as possible from the remaining elements in the second feature sequence H, so the first feature sequence H′ and the second feature sequence can be compared by comparing the loss function (contrastive loss function) H is calculated to obtain the first loss L, which can be obtained by the following formula (ie, the comparison loss function):
  • h′ i sim(x, y) is a similarity function, indicating the similarity between vectors x and y;
  • t is a preset parameter, and its value is greater than 0.
  • the parameters of the first model to be trained can be updated according to the first loss, and the parameters of the second model to be trained can be updated according to the updated parameters of the first model to be trained.
  • the next batch of first training data i.e., the next batch of first data sequences
  • the updated first model to be trained and the updated second model to be trained can be used for the next batch of first training data.
  • any round of training can be understood as the training of the two models using the first training data of the batch.
  • you can Use the parameters of the first model to be trained after the current round of updating, the parameters of the second model to be trained after the previous round of updating, and the preset weights to determine the parameters of the second model to be trained after the current round of updating which can be determined specifically by the following formula:
  • the parameter of the second model to be trained updated in the current round is the parameter of the first model to be trained after updating in the current round; It is the parameters of the second model to be trained after the previous round update and the preset weight; i is the current round; i-1 is the previous round; ⁇ is the preset weight (the size can be adjusted according to actual needs setting, there is no limit here).
  • the fine-tuning phase of the model can be launched for one of the first target model and the second target model.
  • the current batch of second training data can be collected first, the batch of second training data includes the current batch of second data sequences used for training, the type of the second data sequence is the same as the type of the first training data, And the second data sequence is a data sequence with known real labels (it can also be understood as a data sequence with annotations). For example, if the first data sequence is a first speech sequence, then the second data sequence is a second speech sequence, and the text corresponding to the second speech sequence is known. For another example, if the first data sequence is the first image sequence, then the second data sequence is the second image sequence, and the type of the second image sequence is known.
  • the second data sequence is the second text sequence
  • the content of the second text sequence (or, the part of speech of the first text sequence, etc.) is known, etc. .
  • the second data sequence includes multiple elements, and each element represents a certain part of the data.
  • the second data sequence can be used to fine-tune the first target model or the second target model to obtain a third target model
  • the third target model is used to obtain the label of the data sequence.
  • the third target model can be obtained in the following ways:
  • the preset model is usually a part of additional feature extraction layer, which can be spliced at the end of the first target model and the second target model, so as to construct the third model to be trained. In this way, the third model to be trained can output the predicted label of the second data sequence.
  • the third model According to the real label and predicted label of the second data sequence, train the third model to be trained to obtain the third target model.
  • the second loss function (for example, linking time series classification function, etc.)
  • the true label of the second data sequence and the predicted label of the second data sequence are calculated to obtain a second loss, and the second loss is used to indicate the difference between the true label of the second data sequence and the predicted label of the second data sequence.
  • the parameters of the third model to be trained can be updated according to the second loss, and the next batch of second training data (ie, the next batch of second data sequences) can be used to update the updated third model to be trained
  • the next batch of second training data ie, the next batch of second data sequences
  • the model training conditions for example, the second loss converges, etc.
  • the third target model that can be used in practical applications can be obtained, that is, a neural network model with labels for acquiring data sequences.
  • the embodiment of the present application provides a new model training architecture, which includes two branches, the first model to be trained and the second model to be trained, and can realize joint pre-training of the two models.
  • the first data sequence can be processed through the branch where the first model to be trained is located, to obtain the first feature sequence, and through the second model to be trained
  • the branch where it is located processes the disturbed first data sequence to obtain the second feature sequence.
  • the first model to be trained and the second model to be trained are jointly trained to correspondingly obtain the first target model and the second target model.
  • the first target model or the second target model is fine-tuned to obtain the third target model
  • the third target model is used to obtain the label of the data sequence.
  • the first model to be trained can be used to perform feature extraction on the disturbed first data sequence
  • the second model to be trained can be used to perform feature extraction on the original first data sequence
  • the two features obtained by feature extraction are jointly trained on the first model to be trained and the second model to be trained to complete the pre-training of the two models, and the final model (ie, the third target model) obtained based on this pre-training method, Not only can the label of the data sequence under normal conditions be accurately obtained, but the label of the data sequence under abnormal conditions (that is, after disturbance) cannot be accurately obtained.
  • Fig. 6 is another schematic flowchart of the model training method provided by the embodiment of the present application. As shown in Fig. 6, the method includes:
  • step 601 For the description of step 601, reference may be made to the relevant description of step 401 in the embodiment shown in FIG. 4 above, and details will not be repeated here.
  • padding elements can be added to both ends of the original first data sequence to obtain the third data sequence.
  • the third data sequence The length is greater than the length of the first data sequence.
  • step 603 For the description of step 603, reference may be made to the related description of step 403 in the embodiment shown in FIG. 4 above, and details are not repeated here.
  • the elements in the second feature sequence corresponding to the filling elements in the third data sequence can be removed to obtain the third feature sequence.
  • steps 605 to 607 For descriptions of steps 605 to 607, reference may be made to relevant descriptions of steps 403 to 405 in the embodiment shown in FIG. 4 , and details are not repeated here.
  • the two models in the process of pre-training the first model to be trained and the second model to be trained, by adding filling elements to the first data sequence, the two models will not be Only using the position information of the elements in the sequence can also better learn the content of the elements themselves in the sequence, thereby improving the performance of the final model.
  • Fig. 8 is another schematic flowchart of the model training method provided by the embodiment of the present application. As shown in Fig. 8, the method includes:
  • step 801 For the description of step 801, reference may be made to the related description of step 401 in the embodiment shown in FIG. 4 above, and details are not repeated here.
  • filling elements may be added to both ends of the perturbed first data sequence to obtain the third data sequence. It can be understood that the length of the third data sequence is greater than the length of the disturbed first data sequence.
  • step 803 For the description of step 803, reference may be made to the relevant description of step 403 in the embodiment shown in FIG. 4 above, and details are not repeated here.
  • the elements in the first feature sequence corresponding to the filling elements in the third data sequence can be removed to obtain the third feature sequence.
  • steps 805 to 807 For descriptions of steps 805 to 807, reference may be made to relevant descriptions of steps 403 to 405 in the embodiment shown in FIG. 4 , and details are not repeated here.
  • the two models in the process of pre-training the first model to be trained and the second model to be trained, by adding filling elements to the perturbed first data sequence, the two models can be , will not only use the position information of the elements in the sequence, but also better learn the content of the elements in the sequence, thereby improving the performance of the final model.
  • Fig. 9 is a schematic flow chart of a method for obtaining a sequence tag provided in the embodiment of the present application. As shown in Fig. 9, the method includes:
  • the third target model obtained by the embodiment shown in Figure 4 the embodiment shown in Figure 6 or the embodiment shown in Figure 8 can be obtained, and then the target data sequence is input into the value of the The three-objective model is used to process the target data sequence through the third objective model, so as to obtain the label of the target data sequence for use by the user.
  • the third target model is obtained based on one of the branches in the aforementioned training framework, so the third target model can perform certain processing on the target data sequence to accurately obtain the label of the target data sequence, with Better label acquisition ability.
  • FIG. 10 is a schematic structural diagram of a model training device provided by an embodiment of the present application. As shown in Figure 10, the device includes:
  • the pre-training module 1002 is configured to process the disturbed first data sequence through the first model to be trained to obtain the first feature sequence, and process the first data sequence through the second model to be trained to obtain the second feature sequence ;
  • the pre-training module 1002 is further configured to train the first model to be trained and the second model to be trained according to the first feature sequence and the second feature sequence to obtain the first target model and the second target model, wherein the first target The model is obtained by training the first model to be trained according to the first feature sequence and the second feature sequence, and the second target model is obtained according to the parameters in the training process of the first model to be trained;
  • the fine-tuning module 1003 is configured to fine-tune the first target model or the second target model to obtain a third target model, and the third target model is used to obtain labels of data sequences.
  • the pre-training module 1002 is configured to: obtain a first loss according to the first feature sequence and the second feature sequence, and the first loss is used to indicate the difference between the first feature sequence and the second feature sequence The difference; update the parameters of the first model to be trained according to the first loss, and update the parameters of the second model to be trained according to the parameters of the updated first model to be trained, until the model training conditions are met, and the first target model and the second model are obtained.
  • Two-objective model Two-objective model.
  • the updated parameters of the second model to be trained are determined according to the updated parameters of the first model to be trained, parameters of the second model to be trained, and preset weights.
  • the fine-tuning module 1003 is configured to: acquire the second data sequence; fuse one of the first target model and the second target model with the preset model to obtain the third target model to be trained model; the second data sequence is processed by the third model to be trained to obtain the predicted label of the second data sequence; according to the real label and predicted label of the second data sequence, the third model to be trained is trained to obtain the third target Model.
  • the acquiring module 1001 is further configured to add padding elements at both ends of the first data sequence or both ends of the perturbed first data sequence.
  • the perturbation includes at least one of adding noise, adding reverberation, and adding a time-frequency domain mask.
  • the first data sequence and the second data sequence are speech sequences
  • the third target model is used to obtain the label of the data sequence, specifically, the third target model is used to obtain the recognition result of the speech sequence
  • the first data sequence and the second data sequence are text sequences
  • the third target model is used to obtain the label of the data sequence, specifically, the third target model is used to obtain the recognition result of the text sequence
  • the first data sequence and the second The data sequence is an image sequence
  • the third target model is used to obtain a label of the data sequence, specifically, the third target model is used to obtain a classification result of the image sequence.
  • FIG. 11 is a schematic structural diagram of a device for acquiring sequence tags provided by an embodiment of the present application. As shown in Figure 11, the device includes:
  • the processing module 1102 is configured to process the target data sequence through a third target model to obtain the label of the target data sequence.
  • the third target model is obtained by training according to the model training method in the embodiment shown in FIG. 4 .
  • FIG. 12 is a schematic structural diagram of the execution device provided in the embodiment of the present application.
  • the execution device 1200 may specifically be a mobile phone, a tablet, a notebook computer, a smart wearable device, a server, etc., which is not limited here.
  • the device for obtaining sequence tags described in the embodiment corresponding to FIG. 12 may be deployed on the execution device 1200, so as to realize the function of obtaining sequence tags in the embodiment corresponding to FIG. 9 .
  • the execution device 1200 includes: a receiver 1201, a transmitter 1202, a processor 1203, and a memory 1204 (the number of processors 1203 in the execution device 1200 may be one or more, and one processor is taken as an example in FIG. 12 ) , where the processor 1203 may include an application processor 12031 and a communication processor 12032 .
  • the receiver 1201 , the transmitter 1202 , the processor 1203 and the memory 1204 may be connected through a bus or in other ways.
  • the memory 1204 may include read-only memory and random-access memory, and provides instructions and data to the processor 1203 .
  • a part of the memory 1204 may also include a non-volatile random access memory (non-volatile random access memory, NVRAM).
  • NVRAM non-volatile random access memory
  • the memory 1204 stores processors and operating instructions, executable modules or data structures, or their subsets, or their extended sets, wherein the operating instructions may include various operating instructions for implementing various operations.
  • the processor 1203 controls the operations of the execution device.
  • various components of the execution device are coupled together through a bus system, where the bus system may include not only a data bus, but also a power bus, a control bus, and a status signal bus.
  • the various buses are referred to as bus systems in the figures.
  • the methods disclosed in the foregoing embodiments of the present application may be applied to the processor 1203 or implemented by the processor 1203 .
  • the processor 1203 may be an integrated circuit chip, which has a signal processing capability.
  • each step of the above-mentioned method may be implemented by an integrated logic circuit of hardware in the processor 1203 or instructions in the form of software.
  • the above-mentioned processor 1203 can be a general-purpose processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), field programmable Field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • DSP digital signal processing
  • ASIC application specific integrated circuit
  • FPGA field programmable Field-programmable gate array
  • the processor 1203 may implement or execute various methods, steps, and logic block diagrams disclosed in the embodiments of the present application.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory 1204, and the processor 1203 reads the information in the memory 1204, and completes the steps of the above method in combination with its hardware.
  • the receiver 1201 can be used to receive input digital or character information, and generate signal input related to performing device related settings and function control.
  • the transmitter 1202 can be used to output digital or character information through the first interface; the transmitter 1202 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1202 can also include a display device such as a display screen .
  • the processor 1203 is configured to obtain the label of the target data sequence by using the third target model in the embodiment corresponding to FIG. 9 .
  • FIG. 13 is a schematic structural diagram of the training device provided in the embodiment of the present application.
  • the training device 1300 is implemented by one or more servers, and the training device 1300 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (central processing units, CPU) 1314 (eg, one or more processors) and memory 1332, and one or more storage media 1330 (eg, one or more mass storage devices) for storing application programs 1342 or data 1344.
  • the memory 1332 and the storage medium 1330 may be temporary storage or persistent storage.
  • the program stored in the storage medium 1330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the training device. Furthermore, the central processing unit 1314 may be configured to communicate with the storage medium 1330 , and execute a series of instruction operations in the storage medium 1330 on the training device 1300 .
  • the training device 1300 can also include one or more power supplies 1326, one or more wired or wireless network interfaces 1350, one or more input and output interfaces 1358; or, one or more operating systems 1341, such as Windows ServerTM, Mac OS XTM , UnixTM, LinuxTM, FreeBSDTM and so on.
  • operating systems 1341 such as Windows ServerTM, Mac OS XTM , UnixTM, LinuxTM, FreeBSDTM and so on.
  • the training device may execute the model training method in the embodiment corresponding to FIG. 4 , FIG. 6 or FIG. 8 .
  • the embodiment of the present application also relates to a computer storage medium, where a program for signal processing is stored in the computer-readable storage medium, and when the program is run on the computer, the computer executes the steps performed by the aforementioned execution device, or, The computer is caused to perform the steps as performed by the aforementioned training device.
  • the embodiment of the present application also relates to a computer program product, where instructions are stored in the computer program product, and when executed by a computer, the instructions cause the computer to perform the steps performed by the aforementioned executing device, or cause the computer to perform the steps performed by the aforementioned training device.
  • the execution device, training device or terminal device provided in the embodiment of the present application may specifically be a chip.
  • the chip includes: a processing unit and a communication unit.
  • the processing unit may be, for example, a processor, and the communication unit may be, for example, an input/output interface, pins or circuits etc.
  • the processing unit can execute the computer-executed instructions stored in the storage unit, so that the chips in the execution device execute the data processing methods described in the above embodiments, or make the chips in the training device execute the data processing methods described in the above embodiments.
  • the storage unit is a storage unit in the chip, such as a register, a cache, etc.
  • the storage unit may also be a storage unit located outside the chip in the wireless access device, such as only Read-only memory (ROM) or other types of static storage devices that can store static information and instructions, random access memory (random access memory, RAM), etc.
  • ROM Read-only memory
  • RAM random access memory
  • FIG. 14 is a schematic structural diagram of the chip provided by the embodiment of the present application.
  • the chip can be represented as a neural network processor NPU 1400, and the NPU 1400 is mounted to the main CPU (Host CPU) as a coprocessor ), the tasks are assigned by the Host CPU.
  • the core part of the NPU is the operation circuit 1403, and the operation circuit 1403 is controlled by the controller 1404 to extract matrix data in the memory and perform multiplication operations.
  • the operation circuit 1403 includes multiple processing units (Process Engine, PE).
  • arithmetic circuit 1403 is a two-dimensional systolic array.
  • the arithmetic circuit 1403 may also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition.
  • arithmetic circuit 1403 is a general-purpose matrix processor.
  • the operation circuit fetches the data corresponding to the matrix B from the weight storage 1402, and caches it in each PE in the operation circuit.
  • the operation circuit takes the data of matrix A from the input memory 1401 and performs matrix operation with matrix B, and the obtained partial or final results of the matrix are stored in an accumulator 1408 .
  • the unified memory 1406 is used to store input data and output data.
  • the weight data directly accesses the controller (Direct Memory Access Controller, DMAC) 1405 through the storage unit, and the DMAC is transferred to the weight storage 1402.
  • the input data is also transferred to the unified memory 1406 through the DMAC.
  • DMAC Direct Memory Access Controller
  • the BIU is the Bus Interface Unit, that is, the bus interface unit 1413, which is used for the interaction between the AXI bus and the DMAC and the instruction fetch buffer (Instruction Fetch Buffer, IFB) 1409.
  • IFB Instruction Fetch Buffer
  • the bus interface unit 1413 (Bus Interface Unit, BIU for short), is used for the instruction fetch memory 1409 to obtain instructions from the external memory, and is also used for the storage unit access controller 1405 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
  • BIU Bus Interface Unit
  • the DMAC is mainly used to move the input data in the external memory DDR to the unified memory 1406 , to move the weight data to the weight memory 1402 , or to move the input data to the input memory 1401 .
  • the vector computing unit 1407 includes a plurality of computing processing units, and if necessary, further processes the output of the computing circuit 1403, such as vector multiplication, vector addition, exponent operation, logarithmic operation, size comparison and so on. It is mainly used for non-convolutional/fully connected layer network calculations in neural networks, such as Batch Normalization (batch normalization), pixel-level summation, upsampling of predicted label planes, etc.
  • the vector computation unit 1407 can store the vector of the processed output to the unified memory 1406 .
  • the vector calculation unit 1407 can apply a linear function; or, a non-linear function to the output of the operation circuit 1403, such as performing linear interpolation on the predicted label plane extracted by the convolutional layer, and then for example, a vector of accumulated values to generate an activation value .
  • the vector computation unit 1407 generates normalized values, pixel-level summed values, or both.
  • the vector of processed outputs can be used as an activation input to operational circuitry 1403, eg, for use in subsequent layers in a neural network.
  • An instruction fetch buffer 1409 connected to the controller 1404 is used to store instructions used by the controller 1404;
  • the unified memory 1406, the input memory 1401, the weight memory 1402 and the fetch memory 1409 are all On-Chip memories. External memory is private to the NPU hardware architecture.
  • the processor mentioned above can be a general-purpose central processing unit, microprocessor, ASIC, or one or more integrated circuits for controlling the execution of the above-mentioned programs.
  • the device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, and the components shown as units may or may not be A physical unit can be located in one place, or it can be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • the connection relationship between the modules indicates that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines.
  • the essence of the technical solution of this application or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a readable storage medium, such as a floppy disk of a computer , U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., including several instructions to make a computer device (which can be a personal computer, training device, or network device, etc.) execute the instructions described in various embodiments of the present application method.
  • a computer device which can be a personal computer, training device, or network device, etc.
  • all or part of them may be implemented by software, hardware, firmware or any combination thereof.
  • software When implemented using software, it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transferred from a website, computer, training device, or data
  • the center transmits to another website site, computer, training device or data center via wired (eg, coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.).
  • wired eg, coaxial cable, fiber optic, digital subscriber line (DSL)
  • wireless eg, infrared, wireless, microwave, etc.
  • the computer-readable storage medium may be any available medium that can be stored by a computer, or a data storage device such as a training device or a data center integrated with one or more available media.
  • the available medium may be a magnetic medium (such as a floppy disk, a hard disk, or a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (Solid State Disk, SSD)), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • Biophysics (AREA)
  • Data Mining & Analysis (AREA)
  • Biomedical Technology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Molecular Biology (AREA)
  • Mathematical Physics (AREA)
  • Multimedia (AREA)
  • Databases & Information Systems (AREA)
  • Medical Informatics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Acoustics & Sound (AREA)
  • Human Computer Interaction (AREA)
  • Image Analysis (AREA)

Abstract

本申请提供一种模型训练方法及其相关设备,基于该方法所得到最终模型,不仅可准确获取正常条件下的数据序列的标签,而无法准确获取非正常条件下的数据序列的标签。本申请的方法包括:获取第一数据序列和扰动后的第一数据序列;通过第一待训练模型对扰动后的第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型对第一数据序列进行处理,得到第二特征序列;根据第一特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行训练,得到第一目标模型和第二目标模型;对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。

Description

一种模型训练方法及其相关设备
本申请要求于2021年09月27日提交中国专利局、申请号为202111138624.6、发明名称为“一种模型训练方法及其相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能(artificial intelligence,AI)技术领域,尤其涉及一种模型训练方法及其相关设备。
背景技术
为了满足用户对数据的智能处理需求,可通过神经网络模型对数据序列进行处理,以得到数据序列的标签,例如,通过神经网络模型对语音序列进行识别,得到语音序列对应的文本,又如,通过神经网络对图像序列进行分类,得到图像序列的类别等等。
前述神经网络模型的训练过程通常包含两个阶段,即预训练(pre-train)阶段和微调(fine-tune)阶段。具体地,可获取待训练模型,并使用第一数据序列(通常为未知标签的数据序列)对待训练模型进行预训练,再使用第二数据序列(通常为已知标签的数据序列)对预训练得到的模型进行微调,得到前述的神经网络模型。
然而,前述预训练阶段往往被设计得很复杂,导致无法使用扰动后的第一数据序列对待训练模型完成预训练。如此一来,最终得到的神经网络模型通常仅准确能获取正常条件下的数据序列(例如,安静环境下的语音序列)的标签,而无法准确获取非正常条件下(即扰动后)的数据序列(例如,嘈杂环境下的语音序列)的标签。
发明内容
本申请实施例提供了一种模型训练方法及其相关设备,基于该方法所得到最终模型,不仅可准确获取正常条件下的数据序列的标签,而无法准确获取非正常条件下的数据序列的标签。
本申请实施例的第一方面提供了一种模型训练方法,该方法包括:
当需得到具备获取序列的标签的能力的神经网络模型时,可获取第一待训练模型和第二待训练模型,并先对第一待训练模型和第二待训练模型进行预训练。一般地,第一待训练模型的结构和第二待训练模型的结构可以是相同的。
得到第一待训练模型和第二待训练模型后,可获取第一数据序列,并对第一数据序列进行扰动,从而得到扰动后的第一数据序列。其中,第一数据序列包含多个元素,每一个元素表示数据的某一部分,同样地,扰动后的第一数据序列也包含多个元素,每一个元素表示扰动后的数据的某一部分。
接着,可将扰动后的第一数据序列输入至第一待训练模型,以通过第一待训练模型对扰动后的第一数据序列进行特征提取处理,得到第一特征序列,并将第一数据序列输入至第二待训练模型,以通过第二待训练模型对第一数据序列进行处理,得到第二特征序列。
然后,根据第一特征序列和第二特征序列,可对第一待训练模型进行训练,从而得到第一目标模型。在对第一待训练模型进行训练的过程中,还可对第二待训练模型进行联合训练,即根据第一待训练模型训练过程中的参数更新第二待训练模型的参数,从而得到第二目标模型。
最后,对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。
上述方法提供了一种新的模型训练架构,该架构包含第一待训练模型和第二待训练模型两个分支,可实现两个模型的联合预训练。具体地,在获取第一数据序列和扰动后的第一数据序列后,可通过第一待训练模型所在的分支对第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型所在的分支对扰动后的第一数据序列进行处理,得到第二特征序列。然后,根据第一特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行联合训练,对应得到第一目标模型和第二目标模型。最后,对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。可见,在该新的模型训练架构下,可通过第一待训练模型对扰动后的第一数据序列进行特征提取,并通过第二待训练模型对原始的第一数据序列进行特征提取,再利用特征提取得到的两个特征对第一待训练模型和第二待训练模型进行联合训练,以完成两个模型的预训练,基于这种预训练方式所得到最终模型(即第三目标模型),不仅可准确获取正常条件下的数据序列的标签,而无法准确获取非正常条件下(即扰动后)的数据序列的标签。
在一种可能的实现方式中,根据第一特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行训练,得到第一目标模型和第二目标模型包括:根据第一特征序列和第二特征序列,获取第一损失,第一损失用于指示第一特征序列和第二特征序列之间的差异;根据第一损失更新第一待训练模型的参数,并根据更新后的第一待训练模型的参数更新第二待训练模型的参数,直至满足模型训练条件,得到第一目标模型和第二目标模型。前述实现方式中,得到第一特征序列和第二特征序列后,可通过预置的第一损失函数对第一特征序列和第二特征序列进行计算,得到第一损失,第一损失用于指示第一特征序列和第二特征序列之间的差异,即对于第一特征序列中的任意一个元素而言,第一损失用于指示该元素与第二特征序列中相应的元素(即第二特征序列中排序相同的元素)之间的差异。得到第一损失后,可根据第一损失对第一待训练模型的参数进行更新,并根据更新后的第一待训练模型的参数对第二待训练模型的参数进行更新。此后,可继续采集下一批第一数据序列,并利用下一批第一数据序列对更新后的第一待训练模型和更新后的第二待训练模型继续进行训练,直至满足模型训练条件(例如,第一损失收敛等等),相当于完成对第一待训练模型的预训练以及对第二待训练模型的预训练,可对应得到第一目标模型和第二目标模型。
在一种可能的实现方式中,更新后的第二待训练模型的参数根据更新后的第一待训练模型的参数、第二待训练模型的参数以及预置的权重确定。前述实现方式中,由于两个模型会进行多轮次的训练,任意一个轮次的训练可理解为使用该批次的第一数据序列对两个模型所进行的训练。那么,在当前轮次的训练过程中(即使用当前批第一数据序列对两个模型进行训练的过程中),在基于当前轮次的第一损失更新第一待训练模型的参数后,可利用当前轮次更新后的第一待训练模型的参数、前一轮次更新后的第二待训练模型的参数以及预置的权重, 来确定当前轮次更新后的第二待训练模型的参数。可见,第一待训练模型的历史参数的移动平均值可作为第二待训练模型的参数,可实现两个模型的联合训练,以优化最终得到的模型的性能。
在一种可能的实现方式中,对第一目标模型或第二目标模型进行微调,得到第三目标模型包括:获取第二数据序列;将第一目标模型和第二目标模型中的其中一个模型与预置的模型进行融合,得到第三待训练模型;通过第三待训练模型对第二数据序列进行处理,得到第二数据序列的预测标签;根据第二数据序列的真实标签和预测标签,对第三待训练模型进行训练,得到第三目标模型。前述实现方式中,完成第一待训练模型的预训练和第二待训练模型的预训练后,可得到第一目标模型和第二目标模型,由于二者在功能上是相似的,故可择一进行微调,从而得到能在实际应用中使用的第三目标模型,即具备获取数据序列的标签的神经网络模型。
在一种可能的实现方式中,通过第一待训练模型对第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型对扰动后的第一数据序列进行处理,得到第二特征序列之前,该方法还包括:在第一数据序列的两端或扰动后的第一数据序列的两端添加填充元素。前述实现方式中,在对第一待训练模型和第二待训练模型进行预训练的过程中,可通过向第一数据序列或扰动后的第一数据序列中添加填充元素,可使得两个模型在训练过程中,不会只利用序列中元素的位置信息,还可更好地学习到序列中元素自身的内容,从而提高最终得到的模型的性能。
在一种可能的实现方式中,扰动包含添加噪声、添加混响以及添加时频域的掩码中的至少一种。
在一种可能的实现方式中,第一数据序列和第二数据序列为语音序列,第三目标模型用于获取数据序列的标签,具体为第三目标模型用于获取语音序列的识别结果,例如,第三目标模型可用于获取语音序列对应的文本;或者,第一数据序列和第二数据序列为文本序列,第三目标模型用于获取数据序列的标签,具体为第三目标模型用于获取文本序列的识别结果,例如,第三目标模型可用于获取文本序列的内容;或者,第一数据序列和第二数据序列为图像序列,第三目标模型用于获取数据序列的标签,具体为第三目标模型用于获取图像序列的分类结果,例如,第三目标模型可用于获取图像序列的类别。
本申请实施例的第二方面提供了一种序列标签的获取方法,该方法包括:获取目标数据序列;通过第三目标模型对目标数据序列进行处理,得到目标数据序列的标签,第三目标模型为根据第一方面或第一方面中任意一种可能的实现方式进行训练所得到的。
从上述方法可以看出:第三目标模型是基于前述的训练架构中的其中一个分支所得到的,故第三目标模型可对目标数据序列进行一定的处理,以准确获取目标数据序列的标签,具备较优的标签获取能力。
本申请实施例的第三方面提供了一种模型训练装置,该装置包括:获取模块,用于获取第一数据序列和扰动后的第一数据序列;预训练模模块,用于通过第一待训练模型对扰动后的第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型对第一数据序列进行处理,得到第二特征序列;预训练模块,还用于根据第一特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行训练,得到第一目标模型和第二目标模型,其中,第一目 标模型为根据第一特征序列和第二特征序列,对第一待训练模型进行训练得到,第二目标模型为根据第一待训练模型训练过程中的参数获得;微调模块,用于对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。
上述装置提供了一种新的模型训练架构,该架构包含第一待训练模型和第二待训练模型两个分支,可实现两个模型的联合预训练。具体地,在获取第一数据序列和扰动后的第一数据序列后,可通过第一待训练模型所在的分支对第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型所在的分支对扰动后的第一数据序列进行处理,得到第二特征序列。然后,根据第一特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行联合训练,对应得到第一目标模型和第二目标模型。最后,对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。可见,在该新的模型训练架构下,可通过第一待训练模型对扰动后的第一数据序列进行特征提取,并通过第二待训练模型对原始的第一数据序列进行特征提取,再利用特征提取得到的两个特征对第一待训练模型和第二待训练模型进行联合训练,以完成两个模型的预训练,基于这种预训练方式所得到最终模型(即第三目标模型),不仅可准确获取正常条件下的数据序列的标签,而无法准确获取非正常条件下(即扰动后)的数据序列的标签。
在一种可能的实现方式中,预训练模块,用于:根据第一特征序列和第二特征序列,获取第一损失,第一损失用于指示第一特征序列和第二特征序列之间的差异;根据第一损失更新第一待训练模型的参数,并根据更新后的第一待训练模型的参数更新第二待训练模型的参数,直至满足模型训练条件,得到第一目标模型和第二目标模型。
在一种可能的实现方式中,更新后的第二待训练模型的参数根据更新后的第一待训练模型的参数、第二待训练模型的参数以及预置的权重确定。
在一种可能的实现方式中,微调模块,用于:获取第二数据序列;将第一目标模型和第二目标模型中的其中一个模型与预置的模型进行融合,得到第三待训练模型;通过第三待训练模型对第二数据序列进行处理,得到第二数据序列的预测标签;根据第二数据序列的真实标签和预测标签,对第三待训练模型进行训练,得到第三目标模型。
在一种可能的实现方式中,获取模块,还用于在第一数据序列的两端或扰动后的第一数据序列的两端添加填充元素。
在一种可能的实现方式中,扰动包含添加噪声、添加混响以及添加时频域的掩码中的至少一种。
在一种可能的实现方式中,第一数据序列和第二数据序列为语音序列,第三目标模型用于获取数据序列的标签,具体为第三目标模型用于获取语音序列的识别结果;或者,第一数据序列和第二数据序列为文本序列,第三目标模型用于获取数据序列的标签,具体为第三目标模型用于获取文本序列的识别结果;或者,第一数据序列和第二数据序列为图像序列,第三目标模型用于获取数据序列的标签,具体为第三目标模型用于获取图像序列的分类结果。
本申请实施例的第四方面提供了一种序列标签的获取装置,该装置包括:获取模块,用于获取目标数据序列;处理模块,用于通过第三目标模型对目标数据序列进行处理,得到目标数据序列的标签,第三目标模型为根据第一方面或第一方面任意一种可能的实现方式所述的模型训练方法进行训练所得到的。
从上述装置可以看出:第三目标模型是基于前述的训练架构中的其中一个分支所得到的,故第三目标模型可对目标数据序列进行一定的处理,以准确获取目标数据序列的标签,具备较优的标签获取能力。
本申请实施例的第五方面提供了一种模型训练装置,该装置包括存储器和处理器;存储器存储有代码,处理器被配置为执行代码,当代码被执行时,模型训练装置执行如第一方面或第一方面中任意一种可能的实现方式所述的方法。
本申请实施例的第六方面提供了一种序列标签的获取装置,该装置包括存储器和处理器;存储器存储有代码,处理器被配置为执行代码,当代码被执行时,序列标签的获取装置执行如第二方面的方法。
本申请实施例的第七方面提供了一种电路系统,该电路系统包括处理电路,该处理电路配置为执行如第一方面、第一方面中任意一种可能的实现方式或第二方面所述的方法。
本申请实施例的第八方面提供了一种芯片系统,该芯片系统包括处理器,用于调用存储器中存储的计算机程序或计算机指令,以使得该处理器执行如第一方面、第一方面中任意一种可能的实现方式或第二方面所述的方法。
在一种可能的实现方式中,该处理器通过接口与存储器耦合。
在一种可能的实现方式中,该芯片系统还包括存储器,该存储器中存储有计算机程序或计算机指令。
本申请实施例的第九方面提供了一种计算机存储介质,该计算机存储介质存储有计算机程序,该程序在由计算机执行时,使得计算机实施如第一方面、第一方面中任意一种可能的实现方式或第二方面所述的方法。
本申请实施例的第十方面提供了一种计算机程序产品,该计算机程序产品存储有指令,该指令在由计算机执行时,使得计算机实施如第一方面、第一方面中任意一种可能的实现方式或第二方面所述的方法。
本申请实施例提供了一种新的模型训练架构,该架构包含第一待训练模型和第二待训练模型两个分支,可实现两个模型的联合预训练。具体地,在获取第一数据序列和扰动后的第一数据序列后,可通过第一待训练模型所在的分支对第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型所在的分支对扰动后的第一数据序列进行处理,得到第二特征序列。然后,根据第一特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行联合训练,对应得到第一目标模型和第二目标模型。最后,对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。可见,在该新的模型训练架构下,可通过第一待训练模型对扰动后的第一数据序列进行特征提取,并通过第二待训练模型对原始的第一数据序列进行特征提取,再利用特征提取得到的两个特征对第一待训练模型和第二待训练模型进行联合训练,以完成两个模型的预训练,基于这种预训练方式所得到最终模型(即第三目标模型),不仅可准确获取正常条件下的数据序列的标签,而无法准确获取非正常条件下(即扰动后)的数据序列的标签。
附图说明
图1为人工智能主体框架的一种结构示意图;
图2a为本申请实施例提供的数据序列处理系统的一个结构示意图;
图2b为本申请实施例提供的数据序列处理系统的另一结构示意图;
图2c为本申请实施例提供的数据序列处理的相关设备的一个示意图;
图3为本申请实施例提供的系统100架构的一个示意图;
图4为本申请实施例提供的模型训练方法的一个流程示意图;
图5为本申请实施例提供的预训练阶段的一个示意图;
图6为本申请实施例提供的模型训练方法的另一流程示意图;
图7为本申请实施例提供的预训练阶段的另一示意图;
图8为本申请实施例提供的模型训练方法的另一流程示意图;
图9为本申请实施例提供的序列标签的获取方法的一个流程示意图;
图10为本申请实施例提供的模型训练装置的一个结构示意图;
图11为本申请实施例提供的序列标签的获取装置的一个结构示意图;
图12为本申请实施例提供的执行设备的一个结构示意图;
图13为本申请实施例提供的训练设备的一个结构示意图;
图14为本申请实施例提供的芯片的一个结构示意图。
具体实施方式
本申请实施例提供了一种模型训练方法及其相关设备,基于该方法所得到最终模型,不仅可准确获取正常条件下的数据序列的标签,而无法准确获取非正常条件下的数据序列的标签。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的术语在适当情况下可以互换,这仅仅是描述本申请的实施例中对相同属性的对象在描述时所采用的区分方式。此外,术语“包括”和“具有”并他们的任何变形,意图在于覆盖不排他的包含,以便包含一系列单元的过程、方法、系统、产品或设备不必限于那些单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它单元。
随着技术的飞速发展,AI技术被广泛应用于人们的日常生活中。为了满足人们对数据的智能处理需求,可通过AI技术中的神经网络模型对数据序列进行处理,以得到数据序列的标签,例如,通过神经网络模型对语音序列进行识别,得到语音序列对应的文本,又如,通过神经网络对图像序列进行分类,得到图像序列的类别,再如,通过神经网络模型对文本序列进行识别,得到文本序列所指示的内容等等。
前述神经网络模型的训练过程通常包含两个阶段,即基于监督学习(supervised learning)方法构建的预训练阶段和基于无监督学习(unsupervised learning)方法构建的微调阶段。为了便于说明,下文以数据序列是语音序列为例进行介绍。具体地,可获取待训练模型,并使用第一语音序列(第一语音序列对应的文本是未知的)对待训练模型进行预训练,再使用第二语音序列(第二语音序列对应的文本是未知的)对预训练得到的模型进行微调,从而得到可实现语音识别的神经网络模型。
然而,前述预训练阶段往往被设计得很复杂,无法使用传统的数据扩充方法对第一语音 序列做扰动(例如,对第一语音序列添加噪声等等),导致无法使用扰动后的第一数据序列对待训练模型完成预训练。如此一来,最终得到的神经网络模型在实际应用时,通常仅准确能获取正常条件下的数据序列(例如,安静环境下的语音序列)的标签,而无法准确获取非正常条件下(即扰动后)的数据序列(例如,噪声环境下的语音序列)的标签。
为了解决上述问题,本申请提供了一种模型训练方法,该方法可结合人工智能(artificial intelligence,AI)技术实现。AI技术是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能的技术学科,AI技术通过感知环境、获取知识并使用知识获得最佳结果。换句话说,人工智能技术是计算机科学的一个分支,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式做出反应的智能机器。利用人工智能进行数据处理是人工智能常见的一个应用方式。
首先对人工智能系统总体工作流程进行描述,请参见图1,图1为人工智能主体框架的一种结构示意图,下面从“智能信息链”(水平轴)和“IT价值链”(垂直轴)两个维度对上述人工智能主题框架进行阐述。其中,“智能信息链”反映从数据的获取到处理的一列过程。举例来说,可以是智能信息感知、智能信息表示与形成、智能推理、智能决策、智能执行与输出的一般过程。在这个过程中,数据经历了“数据—信息—知识—智慧”的凝练过程。“IT价值链”从人智能的底层基础设施、信息(提供和处理技术实现)到系统的产业生态过程,反映人工智能为信息技术产业带来的价值。
(1)基础设施
基础设施为人工智能系统提供计算能力支持,实现与外部世界的沟通,并通过基础平台实现支撑。通过传感器与外部沟通;计算能力由智能芯片(CPU、NPU、GPU、ASIC、FPGA等硬件加速芯片)提供;基础平台包括分布式计算框架及网络等相关的平台保障和支持,可以包括云存储和计算、互联互通网络等。举例来说,传感器和外部沟通获取数据,这些数据提供给基础平台提供的分布式计算系统中的智能芯片进行计算。
(2)数据
基础设施的上一层的数据用于表示人工智能领域的数据来源。数据涉及到图形、图像、语音、文本,还涉及到传统设备的物联网数据,包括已有系统的业务数据以及力、位移、液位、温度、湿度等感知数据。
(3)数据处理
数据处理通常包括数据训练,机器学习,深度学习,搜索,推理,决策等方式。
其中,机器学习和深度学习可以对数据进行符号化和形式化的智能信息建模、抽取、预处理、训练等。
推理是指在计算机或智能系统中,模拟人类的智能推理方式,依据推理控制策略,利用形式化的信息进行机器思维和求解问题的过程,典型的功能是搜索与匹配。
决策是指智能信息经过推理后进行决策的过程,通常提供分类、排序、预测等功能。
(4)通用能力
对数据经过上面提到的数据处理后,进一步基于数据处理的结果可以形成一些通用的能力,比如可以是算法或者一个通用系统,例如,翻译,文本的分析,计算机视觉的处理,语音识别,图像的识别等等。
(5)智能产品及行业应用
智能产品及行业应用指人工智能系统在各领域的产品和应用,是对人工智能整体解决方案的封装,将智能信息决策产品化、实现落地应用,其应用领域主要包括:智能终端、智能交通、智能医疗、自动驾驶、智慧城市等。
接下来介绍几种本申请的应用场景。
图2a为本申请实施例提供的数据序列处理系统的一个结构示意图,该数据序列处理系统包括用户设备以及数据处理设备。其中,用户设备包括手机、个人电脑或者信息处理中心等智能终端。用户设备为数据序列处理的发起端,作为数据序列处理请求的发起方,通常由用户通过用户设备发起请求。
上述数据处理设备可以是云服务器、网络服务器、应用服务器以及管理服务器等具有数据处理功能的设备或服务器。数据处理设备通过交互接口接收来自智能终端的图像处理请求,再通过存储数据的存储器以及数据处理的处理器环节进行机器学习,深度学习,搜索,推理,决策等方式的图像处理。数据处理设备中的存储器可以是一个统称,包括本地存储以及存储历史数据的数据库,数据库可以在数据处理设备上,也可以在其它网络服务器上。
在图2a所示的数据序列处理系统中,用户设备可以接收用户的指令,例如用户设备可以获取用户输入/选择的一个数据序列(例如,语音序列、图像序列和文本序列等等),然后向数据处理设备发起请求,使得数据处理设备针对用户设备得到的该数据序列进行处理(例如,获取数据序列的标签等等),从而得到针对该数据序列的处理结果。示例性的,用户设备可以获取用户输入的一张图像,然后向数据处理设备发起语音序列的识别请求,使得数据处理设备对该语音序列进行识别,从而得到该语音序列的识别结果,即该语音序列对应的文本。
在图2a中,数据处理设备可以执行本申请实施例的序列标签的获取方法。
图2b为本申请实施例提供的数据序列处理系统的另一结构示意图,在图2b中,用户设备直接作为数据处理设备,该用户设备能够直接获取来自用户的输入并直接由用户设备本身的硬件进行处理,具体过程与图2a相似,可参考上面的描述,在此不再赘述。
在图2b所示的数据序列处理系统中,用户设备可以接收用户的指令,例如用户设备可以获取用户在用户设备中所选择的一个数据序列,然后再由用户设备自身针对该数据序列执行数据序列处理(例如,获取数据序列的标签等),从而得到针对该获取数据序列的标签的处理结果。
在图2b中,用户设备自身就可以执行本申请实施例的序列标签的获取方法。
图2c为本申请实施例提供的数据序列处理的相关设备的一个示意图。
上述图2a和图2b中的用户设备具体可以是图2c中的本地设备301或者本地设备302,图2a中的数据处理设备具体可以是图2c中的执行设备210,其中,数据存储系统250可以存储执行设备210的待处理数据,数据存储系统250可以集成在执行设备210上,也可以设置在云上或其它网络服务器上。
图2a和图2b中的处理器可以通过神经网络模型或者其它模型(例如,基于支持向量机的模型)进行数据训练/机器学习/深度学习,并利用数据最终训练或者学习得到的模型针对图像执行图像处理应用,从而得到相应的处理结果。
图3为本申请实施例提供的系统100架构的一个示意图,在图3中,执行设备110配置 输入/输出(input/output,I/O)接口112,用于与外部设备进行数据交互,用户可以通过客户设备140向I/O接口112输入数据,所述输入数据在本申请实施例中可以包括:各个待调度任务、可调用资源以及其他参数。
在执行设备110对输入数据进行预处理,或者在执行设备110的计算模块111执行计算等相关的处理(比如进行本申请中神经网络的功能实现)过程中,执行设备110可以调用数据存储系统150中的数据、代码等以用于相应的处理,也可以将相应处理得到的数据、指令等存入数据存储系统150中。
最后,I/O接口112将处理结果返回给客户设备140,从而提供给用户。
值得说明的是,训练设备120可以针对不同的目标或称不同的任务,基于不同的训练数据生成相应的目标模型/规则,该相应的目标模型/规则即可以用于实现上述目标或完成上述任务,从而为用户提供所需的结果。其中,训练数据可以存储在数据库130中,且来自于数据采集设备160采集的训练样本。
在图3中所示情况下,用户可以手动给定输入数据,该手动给定可以通过I/O接口112提供的界面进行操作。另一种情况下,客户设备140可以自动地向I/O接口112发送输入数据,如果要求客户设备140自动发送输入数据需要获得用户的授权,则用户可以在客户设备140中设置相应权限。用户可以在客户设备140查看执行设备110输出的结果,具体的呈现形式可以是显示、声音、动作等具体方式。客户设备140也可以作为数据采集端,采集如图所示输入I/O接口112的输入数据及输出I/O接口112的输出结果作为新的样本数据,并存入数据库130。当然,也可以不经过客户设备140进行采集,而是由I/O接口112直接将如图所示输入I/O接口112的输入数据及输出I/O接口112的输出结果,作为新的样本数据存入数据库130。
值得注意的是,图3仅是本申请实施例提供的一种系统架构的示意图,图中所示设备、器件、模块等之间的位置关系不构成任何限制,例如,在图3中,数据存储系统150相对执行设备110是外部存储器,在其它情况下,也可以将数据存储系统150置于执行设备110中。如图3所示,可以根据训练设备120训练得到神经网络。
本申请实施例还提供的一种芯片,该芯片包括神经网络处理器NPU。该芯片可以被设置在如图3所示的执行设备110中,用以完成计算模块111的计算工作。该芯片也可以被设置在如图3所示的训练设备120中,用以完成训练设备120的训练工作并输出目标模型/规则。
神经网络处理器NPU,NPU作为协处理器挂载到主中央处理器(central processing unit,CPU)(host CPU)上,由主CPU分配任务。NPU的核心部分为运算电路,控制器控制运算电路提取存储器(权重存储器或输入存储器)中的数据并进行运算。
在一些实现中,运算电路内部包括多个处理单元(process engine,PE)。在一些实现中,运算电路是二维脉动阵列。运算电路还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路是通用的矩阵处理器。
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)中。
向量计算单元可以对运算电路的输出做进一步处理,如向量乘,向量加,指数运算,对 数运算,大小比较等等。例如,向量计算单元可以用于神经网络中非卷积/非FC层的网络计算,如池化(pooling),批归一化(batch normalization),局部响应归一化(local response normalization)等。
在一些实现种,向量计算单元能将经处理的输出的向量存储到统一缓存器。例如,向量计算单元可以将非线性函数应用到运算电路的输出,例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元生成归一化的值、合并值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路的激活输入,例如用于在神经网络中的后续层中的使用。
统一存储器用于存放输入数据以及输出数据。
权重数据直接通过存储单元访问控制器(direct memory access controller,DMAC)将外部存储器中的输入数据搬运到输入存储器和/或统一存储器、将外部存储器中的权重数据存入权重存储器,以及将统一存储器中的数据存入外部存储器。
总线接口单元(bus interface unit,BIU),用于通过总线实现主CPU、DMAC和取指存储器之间进行交互。
与控制器连接的取指存储器(instruction fetch buffer),用于存储控制器使用的指令;
控制器,用于调用指存储器中缓存的指令,实现控制该运算加速器的工作过程。
一般地,统一存储器,输入存储器,权重存储器以及取指存储器均为片上(On-Chip)存储器,外部存储器为该NPU外部的存储器,该外部存储器可以为双倍数据率同步动态随机存储器(double data rate synchronous dynamic random access memory,DDR SDRAM)、高带宽存储器(high bandwidth memory,HBM)或其他可读可写的存储器。
由于本申请实施例涉及大量神经网络的应用,为了便于理解,下面先对本申请实施例涉及的相关术语及神经网络等相关概念进行介绍。
(1)神经网络
神经网络可以是由神经单元组成的,神经单元可以是指以xs和截距1为输入的运算单元,该运算单元的输出可以为:
Figure PCTCN2022120108-appb-000001
其中,s=1、2、……n,n为大于1的自然数,Ws为xs的权重,b为神经单元的偏置。f为神经单元的激活函数(activation functions),用于将非线性特性引入神经网络中,来将神经单元中的输入信号转换为输出信号。该激活函数的输出信号可以作为下一层卷积层的输入。激活函数可以是sigmoid函数。神经网络是将许多个上述单一的神经单元联结在一起形成的网络,即一个神经单元的输出可以是另一个神经单元的输入。每个神经单元的输入可以与前一层的局部接受域相连,来提取局部接受域的特征,局部接受域可以是由若干个神经单元组成的区域。
神经网络中的每一层的工作可以用数学表达式y=a(Wx+b)来描述:从物理层面神经网络中的每一层的工作可以理解为通过五种对输入空间(输入向量的集合)的操作,完成输入空间到输出空间的变换(即矩阵的行空间到列空间),这五种操作包括:1、升维/降维;2、放大/缩小;3、旋转;4、平移;5、“弯曲”。其中1、2、3的操作由Wx完成,4的操作由+b完成,5的操作则由a()来实现。这里之所以用“空间”二字来表述是因为被分类的对象并不 是单个事物,而是一类事物,空间是指这类事物所有个体的集合。其中,W是权重向量,该向量中的每一个值表示该层神经网络中的一个神经元的权重值。该向量W决定着上文所述的输入空间到输出空间的空间变换,即每一层的权重W控制着如何变换空间。训练神经网络的目的,也就是最终得到训练好的神经网络的所有层的权重矩阵(由很多层的向量W形成的权重矩阵)。因此,神经网络的训练过程本质上就是学习控制空间变换的方式,更具体的就是学习权重矩阵。
因为希望神经网络的输出尽可能的接近真正想要预测的值,所以可以通过比较当前网络的预测值和真正想要的目标值,再根据两者之间的差异情况来更新每一层神经网络的权重向量(当然,在第一次更新之前通常会有初始化的过程,即为神经网络中的各层预先配置参数),比如,如果网络的预测值高了,就调整权重向量让它预测低一些,不断的调整,直到神经网络能够预测出真正想要的目标值。因此,就需要预先定义“如何比较预测值和目标值之间的差异”,这便是损失函数(loss function)或目标函数(objective function),它们是用于衡量预测值和目标值的差异的重要方程。其中,以损失函数举例,损失函数的输出值(loss)越高表示差异越大,那么神经网络的训练就变成了尽可能缩小这个loss的过程。
(2)反向传播算法
神经网络可以采用误差反向传播(back propagation,BP)算法在训练过程中修正初始的神经网络模型中参数的大小,使得神经网络模型的重建误差损失越来越小。具体地,前向传递输入信号直至输出会产生误差损失,通过反向传播误差损失信息来更新初始的神经网络模型中参数,从而使误差损失收敛。反向传播算法是以误差损失为主导的反向传播运动,旨在得到最优的神经网络模型的参数,例如权重矩阵。
下面从神经网络的训练侧和神经网络的应用侧对本申请提供的方法进行描述。
本申请实施例提供的模型训练方法,涉及数据序列的处理,具体可以应用于数据训练、机器学习、深度学习等方法,对训练数据(如本申请中的第一数据序列、扰动后的第一数据序列以及第二数据序列)进行符号化和形式化的智能信息建模、抽取、预处理、训练等,最终得到训练好的神经网络(如本申请中的第三目标模型);并且,本申请实施例提供的序列标签的获取方法可以运用上述训练好的神经网络,将输入数据(如本申请中的目标数据序列)输入到所述训练好的神经网络中,得到输出数据(如本申请中目标数据序列的标签等等)。需要说明的是,本申请实施例提供的模型训练方法和序列标签的获取方法是基于同一个构思产生的发明,也可以理解为一个系统中的两个部分,或一个整体流程的两个阶段:如模型训练阶段和模型应用阶段。
图4为本申请实施例提供的模型训练方法的一个流程示意图,如图4所示,该方法包括:
401、获取第一数据序列和扰动后的第一数据序列。
本实施例中,当需得到具备获取序列的标签的能力的神经网络模型时,可获取第一待训练模型和第二待训练模型,并先对第一待训练模型和第二待训练模型进行预训练。一般地,第一待训练模型的结构和第二待训练模型的结构可以是相同的,例如,第一待训练模型可包含卷积层、全连接层、池化层、归一化层等等中的任意一种或任意组合,第二待训练模型也是如此,此处不再赘述。
在开始预训练时,可先采集当前批第一训练数据,该批第一训练数据包含当前批用于训 练的第一数据序列,第一数据序列的类型可因实际需求而变化(即第一数据序列的类型是多样的),且第一数据序列为未知标签的数据序列(也可以理解为无批注的数据序列),例如,第一数据序列可以为第一语音序列,且第一语音序列对应的文本是未知的。又如,第一数据序列可以为第一图像序列,且第一图像序列的类别是未知的。再如,第一数据序列可以为第一文本序列,且第一文本序列的内容(或者,第一文本序列的词性等等)是未知的等等。可以理解的是,第一数据序列包含多个元素,每一个元素表示数据的某一部分。例如,如图5所示(图5为本申请实施例提供的预训练阶段的一个示意图),第一数据序列可表示为X={X 1,X 2,X 3,...,X N},X i为第一数据序列X的第i个元素,i=1,2,...,N。X i通常是一个向量,表示数据的某一部分(例如,语音的片段,图像的图像块,文本的词汇等等)。
得到第一数据序列后,可对第一数据序列进行扰动,得到扰动后的第一数据序列。可以理解的是,扰动后的第一数据序列也包含多个元素,每一个元素表示扰动后的数据的某一部分。依旧如图5所示的例子,扰动后的第一数据序列可表示为X′={X′ 1,X′ 2,X′ 3,...,X′ N},X′ i为扰动后的第一数据序列X′的第i个元素,i=1,2,...,N。X′ i通常是一个向量,表示扰动后的数据的某一部分。
需要说明的是,原始的第一数据序列的长度和扰动后的第一数据序列的长度通常是相同的,相较于原始的第一数据序列而言,扰动后的第一数据序列中的部分元素发生了变化,依旧如图5所示的例子,设在对第一数据序列进行扰动后,第一数据序列X中的第二个元素X 2和扰动后的第一数据序列X′中的第二个元素X′ 2不同,第一数据序列X中的第三个元素X 3和扰动后的第一数据序列X′中的第三个元素X′ 3不同,而第一数据序列X中的其余元素和扰动后的第一数据序列X′中的其余元素相同,即第一数据序列X中的第一个元素X 1与扰动后的第一数据序列X′中的第一个元素X′ 1相同,第一数据序列X中的第四个元素X 4与扰动后的第一数据序列X′中的第四个元素X′ 4相同等等。
此外,对第一数据序列进行扰动的方法可根据第一数据序列的类型来确定,依旧如上述例子,设采集到的第一语音序列为安静环境下的语音序列,可使用传统的数据扩充方法对第一语音序列进行扰动,即对第一语音序列添加噪声,使得原始的第一语音序列中的部分元素发生变化,得到扰动后的第一语音序列,即噪声环境下的语音序列。
应理解,本实施例中,仅以对第一语音序列添加噪声进行示意性说明,并不对本申请中对第一语音序列进行扰动的方法构成限制,例如,对第一语音序列进行扰动的方法还可以是对第一语音序列添加混响,又如,对第一语音序列进行扰动的方法还可以是对第一语音序列添加时频域上的掩码(mask)等等。
还应理解,还可对第一文本序列进行扰动,例如,在第一文本序列中添加文字掩码、随机交换序列中的元素位置(即交换文本中相邻位置的字)等等,也可对第一图像序列进行扰动,例如,将原先用于表征彩图的第一图像序列转换为用于表征黑白图的第一图像序列、在第一图像序列的随机区域添加掩码等等。
402、通过第一待训练模型对扰动后的第一数据序列进行处理,得到第一特征序列,并通 过第二待训练模型对第一数据序列进行处理,得到第二特征序列。
得到第一数据序列和扰动后的第一数据序列后,可将扰动后的第一数据序列输入至第一待训练模型,以通过第一待训练模型对扰动后的第一数据序列进行特征提取处理,得到第一特征序列。同样地,还可将第一数据序列输入至第二待训练模型,以通过第二待训练模型对第一数据序列进行特征提取处理,得到第二特征序列。
可以理解的是,第一特征序列包含多个元素,每一个元素表示数据的某一部分的特征,第二特征序列也包含多个元素,每一个元素表示扰动后的数据的某一部分的特征。依旧如图5所示的例子,可将第一数据序列X输入至第二待训练模型,可得到第二待训练模型输出的第二特征序列,第二特征序列可表示为H={h 1,h 2,h 3,...,h M},h i为第二特征序列H中的第i个元素,i=1,2,...,M,M≥N。h i通常为一个向量,表示某一部分数据的特征。同样地,还可将扰动后的第一数据序列X′输入至第一待训练模型,可得到第一特征序列,第一特征序列可表示为H′={h′ 1,h′ 2,h′ 3,...,h′ M},h′ i为第一特征序列H′中的第i个元素,i=1,2,...,M。h′ i通常为一个向量,表示某一部分扰动后的数据的特征。
403、根据第一特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行训练,得到第一目标模型和第二目标模型。
得到第一特征序列和第二特征序列后,根据第一特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行训练,以相应得到第一目标模型和第二目标模型。具体地,第一目标模型和第二目标模型可通过以下方式获取:
(1)得到第一特征序列和第二特征序列后,可通过预置的第一损失函数对第一特征序列和第二特征序列进行计算,得到第一损失,第一损失用于指示第一特征序列和第二特征序列之间的差异,即对于第一特征序列中的任意一个元素而言,第一损失用于指示该元素与第二特征序列中相应的元素(即第二特征序列中排序相同的元素)之间的差异。依旧如图5所示的例子,得到第一特征序列H′和第二特征序列H后,由于预训练的目的为:令第一特征序列H′的第i个元素h′ i尽量地靠近第二特征序列H中的第i个元素h i,并尽量地远离第二特征序列H中的其余元素,故可通过对比损失函数(contrastive loss function)对第一特征序列H′和第二特征序列H进行计算,从而得到第一损失L,第一损失L可通过以下公式(即对比损失函数)得到:
Figure PCTCN2022120108-appb-000002
上式中,
Figure PCTCN2022120108-appb-000003
为负样本集合,对于第一特征序列H′中的第i个元素h′ i,第二特征序列H中的第i个元素h i为h′ i的正样本,第二特征序列H中除第i个元素之外的其余元素中的部分元素和全部元素,可构成h′ i
Figure PCTCN2022120108-appb-000004
sim(x,y)为相似度函数,表示向量x与y之间的相似度;t为预置的参数,其值大于0。
(2)得到第一损失后,可根据第一损失对第一待训练模型的参数进行更新,并根据更新 后的第一待训练模型的参数对第二待训练模型的参数进行更新。此后,可继续采集下一批第一训练数据(即下一批第一数据序列),并利用下一批第一训练数据对更新后的第一待训练模型和更新后的第二待训练模型继续进行训练(可参考前述利用当前批第一训练数据对两个模型进行训练的过程,即重新执行步骤401至步骤403),直至满足模型训练条件(例如,第一损失收敛等等),相当于完成对第一待训练模型的预训练以及对第二待训练模型的预训练,可对应得到第一目标模型和第二目标模型。
进一步地,由于两个模型会进行多轮次的训练,任意一个轮次的训练可理解为使用该批次的第一训练数据对两个模型所进行的训练。那么,在当前轮次的训练过程中(即使用当前批第一训练数据对两个模型进行训练的过程中),在基于当前轮次的第一损失更新第一待训练模型的参数后,可利用当前轮次更新后的第一待训练模型的参数、前一轮次更新后的第二待训练模型的参数以及预置的权重,来确定当前轮次更新后的第二待训练模型的参数,具体可通过以下公式确定:
Figure PCTCN2022120108-appb-000005
上式中,
Figure PCTCN2022120108-appb-000006
为当前轮次更新后的第二待训练模型的参数;
Figure PCTCN2022120108-appb-000007
为当前轮次更新后的第一待训练模型的参数;
Figure PCTCN2022120108-appb-000008
为前一轮次更新后的第二待训练模型的参数以及预置的权重;i为当前轮次;i-1为前一轮次;γ为预置的权重(其大小可根据实际需求进行设置,此处不做限制)。
404、获取第二数据序列。
在得到第一目标模型和第二目标模型后,相当于完成了模型的预训练阶段,故可对第一目标模型和第二目标模型中的其中一个,展开模型的微调阶段。
在开始微调时,可先采集当前批第二训练数据,该批第二训练数据包含当前批用于训练的第二数据序列,第二数据序列的类型与第一训练数据的类型是相同的,且第二数据序列为已知真实标签的数据序列(也可以理解为携带有批注的数据序列)。例如,若第一数据序列为第一语音序列,则第二数据序列为第二语音序列,且第二语音序列对应的文本是已知的。又如,若第一数据序列为第一图像序列,则第二数据序列为第二图像序列,且第二图像序列的类别是已知的。再如,若第一数据序列为第一文本序列,则第二数据序列为第二文本序列,且第二文本序列的内容(或者,第一文本序列的词性等等)是已知的等等。可以理解的是,第二数据序列包含多个元素,每一个元素表示数据的某一部分。
405、根据第二数据序列对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。
得到第二数据序列后,可使用第二数据序列对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。具体地,第三目标模型可通过以下方式获取:
(1)将第一目标模型和第二目标模型中的其中一个模型与预置的模型进行融合,得到第三待训练模型。需要说明的是,预置的模型通常为一部分额外的特征提取层,这部分层可拼接在第一目标模型和第二目标模型的末端,从而构建第三待训练模型。如此一来,第三待训 练模型可输出第二数据序列的预测标签。
(2)通过第三待训练模型对第二数据序列进行处理,得到第二数据序列的预测标签。需要说明的是,得到第三待训练模型后,可将第二数据序列输入至第三待训练模型,以通过第三待训练模型对第二数据序列进行处理,得到第二数据序列的预测标签。
(3)根据第二数据序列的真实标签和预测标签,对第三待训练模型进行训练,得到第三目标模型。需要说明的是,得到第二数据序列的预测标签后,由于第二数据序列的真实标签是已知的,故可通过预置的第二损失函数(例如,连结时序分类函数等等)对第二数据序列的真实标签和第二数据序列的预测标签进行计算,得到第二损失,第二损失用于指示第二数据序列的真实标签和的第二数据序列的预测标签之间的差异。得到第二损失后,可根据第二损失对第三待训练模型的参数进行更新,并利用下一批第二训练数据(即下一批第二数据序列)对更新后的第三待训练模型继续进行训练(可参考前述利用当前批第二训练数据对第三待训练模型进行训练的过程,即重新执行步骤404至步骤405),直至满足模型训练条件(例如,第二损失收敛等等),相当于完成对第一目标模型的微调或对第二目标模型的微调,可得到能在实际应用中使用的第三目标模型,即具备获取数据序列的标签的神经网络模型。
本申请实施例提供了一种新的模型训练架构,该架构包含第一待训练模型和第二待训练模型两个分支,可实现两个模型的联合预训练。具体地,在获取第一数据序列和扰动后的第一数据序列后,可通过第一待训练模型所在的分支对第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型所在的分支对扰动后的第一数据序列进行处理,得到第二特征序列。然后,根据第一特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行联合训练,对应得到第一目标模型和第二目标模型。最后,对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。可见,在该新的模型训练架构下,可通过第一待训练模型对扰动后的第一数据序列进行特征提取,并通过第二待训练模型对原始的第一数据序列进行特征提取,再利用特征提取得到的两个特征对第一待训练模型和第二待训练模型进行联合训练,以完成两个模型的预训练,基于这种预训练方式所得到最终模型(即第三目标模型),不仅可准确获取正常条件下的数据序列的标签,而无法准确获取非正常条件下(即扰动后)的数据序列的标签。
图6为本申请实施例提供的模型训练方法的另一流程示意图,如图6所示,该方法包括:
601、获取第一数据序列和扰动后的第一数据序列。
关于步骤601的说明,可参考前述图4所示实施例中步骤401的相关说明部分,此处不再赘述。
602、在第一数据序列的两端添加填充元素,得到第三数据序列。
得到第一数据序列和扰动后的第一数据序列后,可在原始的第一数据序列的两端添加填充((padding)元素,得到第三数据序列。可以理解的是,第三数据序列的长度大于第一数据序列的长度。例如,如图7所示(图7为本申请实施例提供的预训练阶段的另一示意图,图7为在图5的基础上绘制的),第一数据序列为X={X 1,X 2,X 3,...,X N},可在第一数据序列X的两端添加填充元素,得到第三数据序列Y={Y 1,...,Y Q,X 1,...,X N,Y Q+1,...,Y P},其中,Y j为第j个填充元素,j=1,...,P,P≥2。
603、通过第一待训练模型对扰动后的第一数据序列进行处理,得到第一特征序列,并通 过第二待训练模型对第三数据序列进行处理,得到第二特征序列。
关于步骤603的说明,可参考前述图4所示实施例中步骤403的相关说明部分,此处不再赘述。
604、在第二特征序列中,将与填充元素对应的元素剔除,得到第三特征序列。
在得到第一特征序列和第二特征序列后,可将第二特征序列中与第三数据序列中填充元素对应的元素剔除,得到第三特征序列。依旧如7所示的例子,将第三数据序列Y输入第二待训练模型后,可通过第二待训练模型对第三数据序列Y进行处理,得到第二待训练模型输出的第二特征序列G={g 1,...,g K,h 1,...,h M,g K+1,...,g L},其中,g 1,...,g L为与Y 1,...,Y P对应的元素,L≥P,故可将第二特征序列G中的元素g 1,...,g L剔除,得到第三特征序列H={h 1,...,h M}。
605、根据第一特征序列和第三特征序列,对第一待训练模型和第二待训练模型进行训练,得到第一目标模型和第二目标模型。
606、获取第二数据序列。
607、根据第二数据序列对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。
关于步骤605至步骤607的说明,可参考前述图4所示实施例中步骤403至步骤405的相关说明部分,此处不再赘述。
本申请实施例中,在对第一待训练模型和第二待训练模型进行预训练的过程中,可通过向第一数据序列中添加填充元素,可使得两个模型在训练过程中,不会只利用序列中元素的位置信息,还可更好地学习到序列中元素自身的内容,从而提高最终得到的模型的性能。
图8为本申请实施例提供的模型训练方法的另一流程示意图,如图8所示,该方法包括:
801、获取第一数据序列和扰动后的第一数据序列。
关于步骤801的说明,可参考前述图4所示实施例中步骤401的相关说明部分,此处不再赘述。
802、在扰动后的第一数据序列的两端添加填充元素,得到第三数据序列。
得到第一数据序列和扰动后的第一数据序列后,可在扰动后的第一数据序列的两端添加填充元素,得到第三数据序列。可以理解的是,第三数据序列的长度大于扰动后的第一数据序列的长度。
803、通过第一待训练模型对第三数据序列进行处理,得到第一特征序列,并通过第二待训练模型对第一数据序列进行处理,得到第二特征序列。
关于步骤803的说明,可参考前述图4所示实施例中步骤403的相关说明部分,此处不再赘述。
804、在第一特征序列中,将与填充元素对应的元素剔除,得到第三特征序列。
在得到第一特征序列和第二特征序列后,可将第一特征序列中与第三数据序列中填充元素对应的元素剔除,得到第三特征序列。
805、根据第三特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行训练,得到第一目标模型和第二目标模型。
806、获取第二数据序列。
807、根据第二数据序列对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。
关于步骤805至步骤807的说明,可参考前述图4所示实施例中步骤403至步骤405的相关说明部分,此处不再赘述。
本申请实施例中,在对第一待训练模型和第二待训练模型进行预训练的过程中,可通过向扰动后的第一数据序列中添加填充元素,可使得两个模型在训练过程中,不会只利用序列中元素的位置信息,还可更好地学习到序列中元素自身的内容,从而提高最终得到的模型的性能。
以上是对本申请实施例提供的模型训练方法所进行的详细说明,以下将对本申请实施例提供的序列标签的获取方法进行介绍。图9为本申请实施例提供的序列标签的获取方法的一个流程示意图,如图9所示,该方法包括:
901、获取目标数据序列。
902、通过第三目标模型对目标数据序列进行处理,得到目标数据序列的标签。
当用户需要获取目标数据序列的标签时,可获取如图4所示实施例、图6所示实施例或图8所示实施例所得到的第三目标模型,然后将目标数据序列输入值第三目标模型,以通过第三目标模型对目标数据序列进行处理,从而得到目标数据序列的标签,以供用户使用。
本申请实施例中,第三目标模型是基于前述的训练架构中的其中一个分支所得到的,故第三目标模型可对目标数据序列进行一定的处理,以准确获取目标数据序列的标签,具备较优的标签获取能力。
以上是对本申请实施例提供的序列标签的获取方法所进行的详细说明,以下将对本申请实施例提供的序列标签的获取装置和模型训练装置分别进行介绍。图10为本申请实施例提供的模型训练装置的一个结构示意图。如图10所示,该装置包括:
获取模块1001,用于获取第一数据序列和扰动后的第一数据序列;
预训练模块1002,用于通过第一待训练模型对扰动后的第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型对第一数据序列进行处理,得到第二特征序列;
预训练模块1002,还用于根据第一特征序列和第二特征序列,对第一待训练模型和第二待训练模型进行训练,得到第一目标模型和第二目标模型,其中,第一目标模型为根据第一特征序列和第二特征序列,对第一待训练模型进行训练得到,第二目标模型为根据第一待训练模型训练过程中的参数获得;
微调模块1003,用于对第一目标模型或第二目标模型进行微调,得到第三目标模型,第三目标模型用于获取数据序列的标签。
在一种可能的实现方式中,预训练模块1002,用于:根据第一特征序列和第二特征序列,获取第一损失,第一损失用于指示第一特征序列和第二特征序列之间的差异;根据第一损失更新第一待训练模型的参数,并根据更新后的第一待训练模型的参数更新第二待训练模型的参数,直至满足模型训练条件,得到第一目标模型和第二目标模型。
在一种可能的实现方式中,更新后的第二待训练模型的参数根据更新后的第一待训练模型的参数、第二待训练模型的参数以及预置的权重确定。
在一种可能的实现方式中,微调模块1003,用于:获取第二数据序列;将第一目标模型和第二目标模型中的其中一个模型与预置的模型进行融合,得到第三待训练模型;通过第三待训练模型对第二数据序列进行处理,得到第二数据序列的预测标签;根据第二数据序列的 真实标签和预测标签,对第三待训练模型进行训练,得到第三目标模型。
在一种可能的实现方式中,获取模块1001,还用于在第一数据序列的两端或扰动后的第一数据序列的两端添加填充元素。
在一种可能的实现方式中,扰动包含添加噪声、添加混响以及添加时频域的掩码中的至少一种。
在一种可能的实现方式中,第一数据序列和第二数据序列为语音序列,第三目标模型用于获取数据序列的标签,具体为第三目标模型用于获取语音序列的识别结果;或者,第一数据序列和第二数据序列为文本序列,第三目标模型用于获取数据序列的标签,具体为第三目标模型用于获取文本序列的识别结果;或者,第一数据序列和第二数据序列为图像序列,第三目标模型用于获取数据序列的标签,具体为第三目标模型用于获取图像序列的分类结果。
图11为本申请实施例提供的序列标签的获取装置的一个结构示意图。如图11所示,该装置包括:
获取模块1101,用于获取目标数据序列;
处理模块1102,用于通过第三目标模型对目标数据序列进行处理,得到目标数据序列的标签,第三目标模型为根据图4所示实施例中的模型训练方法进行训练所得到的。
需要说明的是,上述装置各模块/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其带来的技术效果与本申请方法实施例相同,具体内容可参考本申请实施例前述所示的方法实施例中的叙述,此处不再赘述。
本申请实施例还涉及一种执行设备,图12为本申请实施例提供的执行设备的一个结构示意图。如图12所示,执行设备1200具体可以表现为手机、平板、笔记本电脑、智能穿戴设备、服务器等,此处不做限定。其中,执行设备1200上可部署有图12对应实施例中所描述的序列标签的获取装置,用于实现图9对应实施例中序列标签的获取功能。具体的,执行设备1200包括:接收器1201、发射器1202、处理器1203和存储器1204(其中执行设备1200中的处理器1203的数量可以一个或多个,图12中以一个处理器为例),其中,处理器1203可以包括应用处理器12031和通信处理器12032。在本申请的一些实施例中,接收器1201、发射器1202、处理器1203和存储器1204可通过总线或其它方式连接。
存储器1204可以包括只读存储器和随机存取存储器,并向处理器1203提供指令和数据。存储器1204的一部分还可以包括非易失性随机存取存储器(non-volatile random access memory,NVRAM)。存储器1204存储有处理器和操作指令、可执行模块或者数据结构,或者它们的子集,或者它们的扩展集,其中,操作指令可包括各种操作指令,用于实现各种操作。
处理器1203控制执行设备的操作。具体的应用中,执行设备的各个组件通过总线系统耦合在一起,其中总线系统除包括数据总线之外,还可以包括电源总线、控制总线和状态信号总线等。但是为了清楚说明起见,在图中将各种总线都称为总线系统。
上述本申请实施例揭示的方法可以应用于处理器1203中,或者由处理器1203实现。处理器1203可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器1203中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器1203可以是通用处理器、数字信号处理器(digital signal processing,DSP)、微处理器或微控制器,还可进一步包括专用集成电路(application specific integrated circuit, ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。该处理器1203可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器1204,处理器1203读取存储器1204中的信息,结合其硬件完成上述方法的步骤。
接收器1201可用于接收输入的数字或字符信息,以及产生与执行设备的相关设置以及功能控制有关的信号输入。发射器1202可用于通过第一接口输出数字或字符信息;发射器1202还可用于通过第一接口向磁盘组发送指令,以修改磁盘组中的数据;发射器1202还可以包括显示屏等显示设备。
本申请实施例中,在一种情况下,处理器1203,用于通过图9对应实施例中的第三目标模型,获取目标数据序列的标签。
本申请实施例还涉及一种训练设备,图13为本申请实施例提供的训练设备的一个结构示意图。如图13所示,训练设备1300由一个或多个服务器实现,训练设备1300可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上中央处理器(central processing units,CPU)1314(例如,一个或一个以上处理器)和存储器1332,一个或一个以上存储应用程序1342或数据1344的存储介质1330(例如一个或一个以上海量存储设备)。其中,存储器1332和存储介质1330可以是短暂存储或持久存储。存储在存储介质1330的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对训练设备中的一系列指令操作。更进一步地,中央处理器1314可以设置为与存储介质1330通信,在训练设备1300上执行存储介质1330中的一系列指令操作。
训练设备1300还可以包括一个或一个以上电源1326,一个或一个以上有线或无线网络接口1350,一个或一个以上输入输出接口1358;或,一个或一个以上操作系统1341,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM等等。
具体的,训练设备可以执行图4、图6或图8对应实施例中的模型训练方法。
本申请实施例还涉及一种计算机存储介质,该计算机可读存储介质中存储有用于进行信号处理的程序,当其在计算机上运行时,使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。
本申请实施例还涉及一种计算机程序产品,该计算机程序产品存储有指令,该指令在由计算机执行时使得计算机执行如前述执行设备所执行的步骤,或者,使得计算机执行如前述训练设备所执行的步骤。
本申请实施例提供的执行设备、训练设备或终端设备具体可以为芯片,芯片包括:处理单元和通信单元,所述处理单元例如可以是处理器,所述通信单元例如可以是输入/输出接口、管脚或电路等。该处理单元可执行存储单元存储的计算机执行指令,以使执行设备内的芯片执行上述实施例描述的数据处理方法,或者,以使训练设备内的芯片执行上述实施例描述的数据处理方法。可选地,所述存储单元为所述芯片内的存储单元,如寄存器、缓存等,所述 存储单元还可以是所述无线接入设备端内的位于所述芯片外部的存储单元,如只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)等。
具体的,请参阅图14,图14为本申请实施例提供的芯片的一个结构示意图,所述芯片可以表现为神经网络处理器NPU 1400,NPU 1400作为协处理器挂载到主CPU(Host CPU)上,由Host CPU分配任务。NPU的核心部分为运算电路1403,通过控制器1404控制运算电路1403提取存储器中的矩阵数据并进行乘法运算。
在一些实现中,运算电路1403内部包括多个处理单元(Process Engine,PE)。在一些实现中,运算电路1403是二维脉动阵列。运算电路1403还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现中,运算电路1403是通用的矩阵处理器。
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路从权重存储器1402中取矩阵B相应的数据,并缓存在运算电路中每一个PE上。运算电路从输入存储器1401中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)1408中。
统一存储器1406用于存放输入数据以及输出数据。权重数据直接通过存储单元访问控制器(Direct Memory Access Controller,DMAC)1405,DMAC被搬运到权重存储器1402中。输入数据也通过DMAC被搬运到统一存储器1406中。
BIU为Bus Interface Unit即,总线接口单元1413,用于AXI总线与DMAC和取指存储器(Instruction Fetch Buffer,IFB)1409的交互。
总线接口单元1413(Bus Interface Unit,简称BIU),用于取指存储器1409从外部存储器获取指令,还用于存储单元访问控制器1405从外部存储器获取输入矩阵A或者权重矩阵B的原数据。
DMAC主要用于将外部存储器DDR中的输入数据搬运到统一存储器1406或将权重数据搬运到权重存储器1402中或将输入数据数据搬运到输入存储器1401中。
向量计算单元1407包括多个运算处理单元,在需要的情况下,对运算电路1403的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。主要用于神经网络中非卷积/全连接层网络计算,如Batch Normalization(批归一化),像素级求和,对预测标签平面进行上采样等。
在一些实现中,向量计算单元1407能将经处理的输出的向量存储到统一存储器1406。例如,向量计算单元1407可以将线性函数;或,非线性函数应用到运算电路1403的输出,例如对卷积层提取的预测标签平面进行线性插值,再例如累加值的向量,用以生成激活值。在一些实现中,向量计算单元1407生成归一化的值、像素级求和的值,或二者均有。在一些实现中,处理过的输出的向量能够用作到运算电路1403的激活输入,例如用于在神经网络中的后续层中的使用。
控制器1404连接的取指存储器(instruction fetch buffer)1409,用于存储控制器1404使用的指令;
统一存储器1406,输入存储器1401,权重存储器1402以及取指存储器1409均为On- Chip存储器。外部存储器私有于该NPU硬件架构。
其中,上述任一处提到的处理器,可以是一个通用中央处理器,微处理器,ASIC,或一个或多个用于控制上述程序执行的集成电路。
另外需说明的是,以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本申请提供的装置实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。但是,对本申请而言更多情况下软件程序实现是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘、U盘、移动硬盘、ROM、RAM、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,训练设备,或者网络设备等)执行本申请各个实施例所述的方法。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、训练设备或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、训练设备或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的训练设备、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。

Claims (20)

  1. 一种模型训练方法,其特征在于,所述方法包括:
    获取第一数据序列和扰动后的第一数据序列;
    通过第一待训练模型对所述扰动后的第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型对所述第一数据序列进行处理,得到第二特征序列;
    根据所述第一特征序列和所述第二特征序列,对所述第一待训练模型和所述第二待训练模型进行训练,得到第一目标模型和第二目标模型,所述第一目标模型为根据所述第一特征序列和所述第二特征序列,对所述第一待训练模型进行训练得到,所述第二目标模型为根据所述第一待训练模型训练过程中的参数获得;
    对所述第一目标模型或所述第二目标模型进行微调,得到第三目标模型,所述第三目标模型用于获取数据序列的标签。
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述第一特征序列和所述第二特征序列,对所述第一待训练模型和所述第二待训练模型进行训练,得到第一目标模型和第二目标模型包括:
    根据所述第一特征序列和所述第二特征序列,获取第一损失,所述第一损失用于指示所述第一特征序列和所述第二特征序列之间的差异;
    根据所述第一损失更新所述第一待训练模型的参数,并根据更新后的第一待训练模型的参数更新所述第二待训练模型的参数,直至满足模型训练条件,得到第一目标模型和第二目标模型。
  3. 根据权利要求2所述的方法,其特征在于,更新后的第二待训练模型的参数根据所述更新后的第一待训练模型的参数、所述第二待训练模型的参数以及预置的权重确定。
  4. 根据权利要求1至3任意一项所述的方法,其特征在于,所述对所述第一目标模型或所述第二目标模型进行微调,得到第三目标模型包括:
    获取第二数据序列;
    将所述第一目标模型和所述第二目标模型中的其中一个模型与预置的模型进行融合,得到第三待训练模型;
    通过所述第三待训练模型对所述第二数据序列进行处理,得到所述第二数据序列的预测标签;
    根据所述第二数据序列的真实标签和所述预测标签,对所述第三待训练模型进行训练,得到第三目标模型。
  5. 根据权利要求1至4任意一项所述的方法,其特征在于,所述通过第一待训练模型对所述第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型对所述扰动后的第一数据序列进行处理,得到第二特征序列之前,所述方法还包括:
    在所述第一数据序列的两端或所述扰动后的第一数据序列的两端添加填充元素。
  6. 根据权利要求1至5任意一项所述的方法,其特征在于,所述扰动包含添加噪声、添加混响以及添加时频域的掩码中的至少一种。
  7. 根据权利要求4所述的方法,其特征在于,所述第一数据序列和所述第二数据序列为语音序列,所述第三目标模型用于获取数据序列的标签,具体为所述第三目标模型用于获取 所述语音序列的识别结果;
    或者,
    所述第一数据序列和所述第二数据序列为文本序列,所述第三目标模型用于获取数据序列的标签,具体为所述第三目标模型用于获取所述文本序列的识别结果;
    或者,
    所述第一数据序列和所述第二数据序列为图像序列,所述第三目标模型用于获取数据序列的标签,具体为所述第三目标模型用于获取所述图像序列的分类结果。
  8. 一种序列标签的获取方法,其特征在于,所述方法包括:
    获取目标数据序列;
    通过第三目标模型对所述目标数据序列进行处理,得到所述目标数据序列的标签,所述第三目标模型为根据权利要求1至7任意一项所述的模型训练方法进行训练所得到的。
  9. 一种模型训练装置,其特征在于,所述装置包括:
    获取模块,用于获取第一数据序列和扰动后的第一数据序列;
    预训练模模块,用于通过第一待训练模型对所述扰动后的第一数据序列进行处理,得到第一特征序列,并通过第二待训练模型对所述第一数据序列进行处理,得到第二特征序列;
    所述预训练模块,还用于根据所述第一特征序列和所述第二特征序列,对所述第一待训练模型和所述第二待训练模型进行训练,得到第一目标模型和第二目标模型,所述第一目标模型为根据所述第一特征序列和所述第二特征序列,对所述第一待训练模型进行训练得到,所述第二目标模型为根据所述第一待训练模型训练过程中的参数获得;
    微调模块,用于对所述第一目标模型或所述第二目标模型进行微调,得到第三目标模型,所述第三目标模型用于获取数据序列的标签。
  10. 根据权利要求9所述的装置,其特征在于,所述预训练模块,用于:
    根据所述第一特征序列和所述第二特征序列,获取第一损失,所述第一损失用于指示所述第一特征序列和所述第二特征序列之间的差异;
    根据所述第一损失更新所述第一待训练模型的参数,并根据更新后的第一待训练模型的参数更新所述第二待训练模型的参数,直至满足模型训练条件,得到第一目标模型和第二目标模型。
  11. 根据权利要求10所述的装置,其特征在于,更新后的第二待训练模型的参数根据所述更新后的第一待训练模型的参数、所述第二待训练模型的参数以及预置的权重确定。
  12. 根据权利要求9至11任意一项所述的装置,其特征在于,所述微调模块,用于:
    获取第二数据序列;
    将所述第一目标模型和所述第二目标模型中的其中一个模型与预置的模型进行融合,得到第三待训练模型;
    通过所述第三待训练模型对所述第二数据序列进行处理,得到所述第二数据序列的预测标签;
    根据所述第二数据序列的真实标签和所述预测标签,对所述第三待训练模型进行训练,得到第三目标模型。
  13. 根据权利要求9至12任意一项所述的装置,其特征在于,所述获取模块,还用于在 所述第一数据序列的两端或所述扰动后的第一数据序列的两端添加填充元素。
  14. 根据权利要求9至13任意一项所述的装置,其特征在于,所述扰动包含添加噪声、添加混响以及添加时频域的掩码中的至少一种。
  15. 根据权利要求12所述的装置,其特征在于,所述第一数据序列和所述第二数据序列为语音序列,所述第三目标模型用于获取数据序列的标签,具体为所述第三目标模型用于获取所述语音序列的识别结果;
    或者,
    所述第一数据序列和所述第二数据序列为文本序列,所述第三目标模型用于获取数据序列的标签,具体为所述第三目标模型用于获取所述文本序列的识别结果;
    或者,
    所述第一数据序列和所述第二数据序列为图像序列,所述第三目标模型用于获取数据序列的标签,具体为所述第三目标模型用于获取所述图像序列的分类结果。
  16. 一种序列标签的获取装置,其特征在于,所述装置包括:
    获取模块,用于获取目标数据序列;
    处理模块,用于通过第三目标模型对所述目标数据序列进行处理,得到所述目标数据序列的标签,所述第三目标模型为根据权利要求1至7任意一项所述的模型训练方法进行训练所得到的。
  17. 一种模型训练装置,其特征在于,所述装置包括存储器和处理器;所述存储器存储有代码,所述处理器被配置为执行所述代码,当所述代码被执行时,所述模型训练装置执行如权利要求1至7任一所述的方法。
  18. 一种序列标签的获取装置,其特征在于,所述装置包括存储器和处理器;所述存储器存储有代码,所述处理器被配置为执行所述代码,当所述代码被执行时,所述序列标签的获取装置执行如权利要求8所述的方法。
  19. 一种计算机存储介质,其特征在于,所述计算机存储介质存储有一个或多个指令,所述指令在由一个或多个计算机执行时使得所述一个或多个计算机实施权利要求1至8任一所述的方法。
  20. 一种计算机程序产品,其特征在于,所述计算机程序产品存储有指令,所述指令在由计算机执行时,使得所述计算机实施权利要求1至8任意一项所述的方法。
PCT/CN2022/120108 2021-09-27 2022-09-21 一种模型训练方法及其相关设备 WO2023045949A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP22871995.1A EP4401000A1 (en) 2021-09-27 2022-09-21 Model training method and related device
US18/617,095 US20240265256A1 (en) 2021-09-27 2024-03-26 Model training method and related device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111138624.6 2021-09-27
CN202111138624.6A CN115879524A (zh) 2021-09-27 2021-09-27 一种模型训练方法及其相关设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/617,095 Continuation US20240265256A1 (en) 2021-09-27 2024-03-26 Model training method and related device

Publications (1)

Publication Number Publication Date
WO2023045949A1 true WO2023045949A1 (zh) 2023-03-30

Family

ID=85720071

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/120108 WO2023045949A1 (zh) 2021-09-27 2022-09-21 一种模型训练方法及其相关设备

Country Status (4)

Country Link
US (1) US20240265256A1 (zh)
EP (1) EP4401000A1 (zh)
CN (1) CN115879524A (zh)
WO (1) WO2023045949A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114860535A (zh) * 2022-04-18 2022-08-05 地平线征程(杭州)人工智能科技有限公司 数据评估模型生成方法及装置、异常数据监控方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110210035A (zh) * 2019-06-04 2019-09-06 苏州大学 序列标注方法、装置及序列标注模型的训练方法
CN111737952A (zh) * 2020-06-24 2020-10-02 深圳前海微众银行股份有限公司 一种序列标注模型的训练方法及装置
CN112215298A (zh) * 2020-10-21 2021-01-12 平安国际智慧城市科技股份有限公司 模型训练方法、装置、设备及可读存储介质
US20210201147A1 (en) * 2018-11-28 2021-07-01 Tencent Technology (Shenzhen) Company Limited Model training method, machine translation method, computer device, and storage medium
WO2021164317A1 (zh) * 2020-02-18 2021-08-26 腾讯科技(深圳)有限公司 序列挖掘模型的训练方法、序列数据的处理方法及设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210201147A1 (en) * 2018-11-28 2021-07-01 Tencent Technology (Shenzhen) Company Limited Model training method, machine translation method, computer device, and storage medium
CN110210035A (zh) * 2019-06-04 2019-09-06 苏州大学 序列标注方法、装置及序列标注模型的训练方法
WO2021164317A1 (zh) * 2020-02-18 2021-08-26 腾讯科技(深圳)有限公司 序列挖掘模型的训练方法、序列数据的处理方法及设备
CN111737952A (zh) * 2020-06-24 2020-10-02 深圳前海微众银行股份有限公司 一种序列标注模型的训练方法及装置
CN112215298A (zh) * 2020-10-21 2021-01-12 平安国际智慧城市科技股份有限公司 模型训练方法、装置、设备及可读存储介质

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114860535A (zh) * 2022-04-18 2022-08-05 地平线征程(杭州)人工智能科技有限公司 数据评估模型生成方法及装置、异常数据监控方法及装置

Also Published As

Publication number Publication date
EP4401000A1 (en) 2024-07-17
CN115879524A (zh) 2023-03-31
US20240265256A1 (en) 2024-08-08

Similar Documents

Publication Publication Date Title
WO2022022274A1 (zh) 一种模型训练方法及装置
WO2022068623A1 (zh) 一种模型训练方法及相关设备
WO2022228425A1 (zh) 一种模型训练方法及装置
WO2022179586A1 (zh) 一种模型训练方法及其相关联设备
WO2023051369A1 (zh) 一种神经网络的获取方法、数据处理方法以及相关设备
WO2024160186A1 (zh) 一种模型训练方法及其相关设备
US20240265256A1 (en) Model training method and related device
CN115238909A (zh) 一种基于联邦学习的数据价值评估方法及其相关设备
WO2021036397A1 (zh) 目标神经网络模型的生成方法和装置
CN112529149A (zh) 一种数据处理方法及相关装置
WO2024179485A1 (zh) 一种图像处理方法及其相关设备
WO2024175014A1 (zh) 一种图像处理方法及其相关设备
WO2024179503A1 (zh) 一种语音处理方法及其相关设备
CN114169393A (zh) 一种图像分类方法及其相关设备
WO2024061123A1 (zh) 一种图像处理方法及其相关设备
WO2024114659A1 (zh) 一种摘要生成方法及其相关设备
CN113627421A (zh) 一种图像处理方法、模型的训练方法以及相关设备
WO2023246735A1 (zh) 一种项目推荐方法及其相关设备
WO2023197857A1 (zh) 一种模型切分方法及其相关设备
WO2023185541A1 (zh) 一种模型训练方法及其相关设备
WO2023207823A1 (zh) 类别描述的特征信息的获取方法、图像的处理方法及设备
WO2023020185A1 (zh) 一种图像分类方法及其相关设备
CN116739154A (zh) 一种故障预测方法及其相关设备
CN117056589A (zh) 一种物品推荐方法及其相关设备
CN113065638A (zh) 一种神经网络压缩方法及其相关设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22871995

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2022871995

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2022871995

Country of ref document: EP

Effective date: 20240409

NENP Non-entry into the national phase

Ref country code: DE