Model training method and device, electronic equipment, medium and program product

By using the combination of teacher and student models in translation model training, and using the loss value to update the student model parameters, the problems of low training efficiency of cross-domain translation model and insufficient adaptability to multi-scene are solved, and efficient multi-scene translation ability is achieved.

CN119599032APending Publication Date: 2025-03-11TENCENT TECHNOLOGY (SHENZHEN) CO LTD +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311175504.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-11
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

In the prior art, cross-domain translation model training efficiency is low, and a lot of manpower and time are required to collect cross-domain corpus, resulting in insufficient adaptability of the model in multiple scenarios.

Method used

By obtaining the training sample set, including the sample text of the initial scene and the newly added scene, the teacher model is used to translate the initial sample text to obtain the teacher's translation results, and then the initial and newly added sample text is translated through the initial student model, the loss value is calculated based on the teacher and student translation results, and the student model parameters are updated to improve the model's multi-scene adaptability.

Benefits of technology

While improving the efficiency of model training, the model's multi-scene adaptability is enhanced, so that the trained student model has good translation ability for multiple scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119599032A_ABST
    Figure CN119599032A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a model training method and device, electronic equipment, a medium and a program product, which can be applied to various scenes such as cloud technology, artificial intelligence, intelligent traffic, auxiliary driving and the like. According to the embodiment of the invention, a training sample set is obtained, wherein the training sample set comprises an initial sample text corresponding to an initial scene and a newly-added sample text corresponding to a newly-added scene; translating the initial sample text through a teacher model to obtain a teacher translation result; translating the initial sample text and the newly added sample text through an initial student model to obtain a student translation result; calculating a loss value by combining the teacher translation result and the student translation result; and on the basis of the loss value, updating model parameters of the initial student model to obtain a trained student model, so that the trained student model is used for translating the to-be-translated text corresponding to the initial scene and the newly-added scene. Therefore, according to the scheme, the multi-scene adaptive capacity of the model can be enhanced while the model training efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a model training method, device, electronic device, medium and program product. Background Art

[0002] Machine translation, also known as automatic translation, is the process of using computers to convert one natural language (source language) into another natural language (target language). In recent years, with the development of computer technology, more and more neural network models such as encoder-decoder models or attention models have been applied to machine translation tasks. These translation models can be widely used in a variety of translation fields.

[0003] However, in the prior art, translation models are usually trained through a large amount of labeled corpus in a specific field through supervised learning to obtain a model that adapts to the field. In particular, when training a cross-domain translation model, a large amount of corpus from multiple fields must be collected for training. Due to the differences between different fields, it takes a lot of manpower and time to collect cross-domain corpus, resulting in low training efficiency of cross-domain translation models. Summary of the invention

[0004] The embodiments of the present application provide a model training method, device, electronic device, medium and program product, which can improve the model training efficiency while enhancing the model's multi-scenario adaptability.

[0005] An embodiment of the present application provides a model training method, comprising: obtaining a training sample set, the training sample set comprising an initial sample text corresponding to an initial scene, and a newly added sample text corresponding to a newly added scene; translating the initial sample text through a teacher model to obtain a teacher translation result, the teacher model being trained by the initial training sample text corresponding to the initial scene, and the number of samples of the initial training sample text being greater than the number of samples of the initial sample text; translating the initial sample text and the newly added sample text through an initial student model to obtain a student translation result, the initial student model being obtained by the teacher model; calculating a loss value by combining the teacher translation result and the student translation result; and updating the model parameters of the initial student model based on the loss value to obtain a trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

[0006] The embodiment of the present application also provides a model training device, including: an acquisition unit, used to acquire a training sample set, the training sample set including an initial sample text corresponding to an initial scene, and a newly added sample text corresponding to a newly added scene; a teacher model unit, used to translate the initial sample text through a teacher model to obtain a teacher translation result, the teacher model is trained by the initial training sample text corresponding to the initial scene, and the number of samples of the initial training sample text is greater than the number of samples of the initial sample text; a student model unit, used to translate the initial sample text and the newly added sample text through an initial student model to obtain a student translation result, the initial student model is obtained by the teacher model; a loss unit, used to calculate a loss value in combination with the teacher translation result and the student translation result; an update unit, used to update the model parameters of the initial student model based on the loss value to obtain a trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

[0007] In some embodiments, the initial student model includes an encoding network, an attention network and a decoding network, and the student model unit includes an encoding subunit, an attention subunit and a decoding subunit, including: the encoding subunit is used to encode the target text through the encoding network to obtain an encoding vector, and the target text is any sample text in the training sample set; the attention subunit is used to perform attention processing on the encoding vector through the attention network to obtain an attention vector; the decoding subunit is used to decode the attention vector through the decoding network to obtain a translation result of the target text, so as to obtain the student translation result.

[0008] In some embodiments, the encoding subunit is used to: map the to-be-processed word in the target text into a word vector through the encoding network; generate a position vector of the to-be-processed word according to the position of the to-be-processed word in the target text; and generate the encoding vector by combining the word vector and the position vector.

[0009] In some embodiments, the attention network includes a first attention network and a second attention network, and the attention sub-unit is used to: perform attention processing on the vector before the to-be-processed vector in the encoding vector through the first attention network to obtain an initial attention vector, where the to-be-processed vector is a vector of any to-be-processed word in the encoding vector corresponding to the target text; perform attention processing on the initial attention vector and the encoding vector through the second attention network to obtain an attention vector.

[0010] In some implementations, the decoding subunit is used to: perform linear prediction on the attention vector through the decoding network to obtain a prediction vector; perform classification transformation on the prediction vector to obtain a distribution probability to obtain the student translation result.

[0011] In some embodiments, the loss value includes a comprehensive loss value, and the loss unit includes a first loss sub-unit, a second loss sub-unit and a third loss sub-unit, including: the first loss sub-unit is used to determine the first similarity between the translation results corresponding to the same sample text, the second similarity between the translation results corresponding to different sample texts, and the distillation loss value between the teacher model and the initial student model based on the teacher translation result and the student translation result; the second loss sub-unit is used to calculate the contrast loss value based on the first similarity and the second similarity; the third loss sub-unit is used to determine the comprehensive loss value by combining the contrast loss value and the distillation loss value.

[0012] In some embodiments, the first loss subunit is used to: obtain a negative sample translation result, wherein the negative sample translation result is a translation result of the initial sample text translated by a negative sample processing model, wherein the negative sample processing model is trained by the newly added training sample text corresponding to the newly added scene; determine a first similarity between the translation results corresponding to the same sample text according to the teacher translation result and the initial translation result, wherein the initial translation result is a translation result corresponding to the initial sample text in the student translation result; and determine a second similarity between the translation results corresponding to different sample texts according to the negative sample translation result and the initial translation result.

[0013] In some embodiments, the second loss subunit is used to: determine a normalization factor by combining the first similarity and the second similarity; and normalize the first similarity according to the normalization factor to obtain the comparison loss value.

[0014] In some embodiments, the loss value includes a distillation loss value, and the loss unit includes a fourth loss subunit, a fifth loss subunit and a sixth loss subunit, including: a fourth loss subunit, used to calculate the difference between the label information of the newly added sample text and the newly added translation result to obtain a predicted difference value, and the newly added translation result is the translation result corresponding to the newly added sample text in the student translation result; a fifth loss subunit, used to calculate the difference between the teacher translation result and the student translation result to obtain an inter-model difference value; a sixth loss subunit, used to calculate the distillation loss value based on the predicted difference value and the inter-model difference value.

[0015] In some embodiments, the fifth loss subunit is used to: obtain an initial translation result, which is a translation result corresponding to the initial sample text in the student translation result; calculate the difference between the teacher translation result and the initial translation result to obtain an inter-model difference value.

[0016] In some embodiments, the initial scene includes multiple scenes, and the loss unit includes a seventh loss sub-unit and an eighth loss sub-unit, including: the seventh loss sub-unit, used to calculate the sub-loss value corresponding to any scene in the multiple scenes; the eighth loss sub-unit, used to merge the sub-loss values ​​corresponding to the multiple scenes to obtain the loss value.

[0017] An embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores multiple instructions; the processor loads instructions from the memory to execute the steps in any one of the model training methods provided in the embodiments of the present application.

[0018] An embodiment of the present application also provides a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for a processor to load to execute the steps in any model training method provided in the embodiment of the present application.

[0019] An embodiment of the present application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps in any one of the model training methods provided in the embodiments of the present application.

[0020] The embodiment of the present application can obtain a training sample set, which includes an initial sample text corresponding to an initial scene and a newly added sample text corresponding to a newly added scene; the initial sample text is translated by a teacher model to obtain a teacher translation result, the teacher model is trained by the initial training sample text corresponding to the initial scene, and the number of samples of the initial training sample text is greater than the number of samples of the initial sample text; the initial sample text and the newly added sample text are translated by an initial student model to obtain a student translation result, and the initial student model is obtained by the teacher model; a loss value is calculated by combining the teacher translation result and the student translation result; based on the loss value, the model parameters of the initial student model are updated to obtain a trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

[0021] In the present application, only a small amount of sample data corresponding to the initial scene can be obtained for training the student model to reduce the acquisition cost of the sample data of the initial scene, and improve the construction efficiency of the training sample set and the training efficiency of the model. In this way, in the training of the student model, only the teacher model is used to process a small amount of initial sample text corresponding to the initial scene, and the student model is used to process a small amount of initial sample text corresponding to the initial scene and a large amount of newly added sample text corresponding to the newly added scene. Through the newly added sample text, the student model gradually learns and adapts to the representation of the newly added scene, improves the translation ability of the student model in the newly added scene, and uses a small amount of initial sample text to guide the student model to learn the representation of certain features of the teacher model, avoid forgetting the initial scene, so as to improve the expression ability of the student model in the initial scene and the newly added scene, so as to enhance the multi-scene adaptability of the model while improving the model training efficiency, so that the trained student model has good translation ability for multiple scenes. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0023] Figure 1a It is a scenario schematic diagram of the model training method provided in the embodiment of the present application;

[0024] Figure 1b It is a flowchart of the model training method provided in the embodiment of the present application;

[0025] Figure 1c It is a schematic diagram of the training process of the teacher model provided in the embodiment of the present application;

[0026] Figure 1d It is a structural diagram of the teacher model provided in the embodiment of the present application;

[0027] Figure 1e is a schematic diagram of the encoding process provided by an embodiment of the present application;

[0028] Figure 1f is a schematic diagram of a process for calculating a distillation loss value provided in an embodiment of the present application;

[0029] Figure 1g It is a schematic diagram of the process of calculating the contrast loss value provided in an embodiment of the present application;

[0030] Figure 1h It is another schematic diagram of a process for calculating the distillation loss value provided in an embodiment of the present application;

[0031] Figure 1i It is another schematic diagram of a flow chart for calculating a comparative loss value provided in an embodiment of the present application;

[0032] Figure 2a is a flowchart of a model training method provided by another embodiment of the present application;

[0033] Figure 2b is a schematic diagram of the translation quality of the trained translation model in different scenarios provided in the embodiments of the present application;

[0034] Figure 3a is a flowchart of a model training method provided in yet another embodiment of the present application;

[0035] Figure 3b is a schematic diagram of the translation quality of a trained translation model in different scenarios provided by another embodiment of the present application;

[0036] Figure 4 It is a structural schematic diagram of a model training device provided in an embodiment of the present application;

[0037] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0039] It should be noted that the terms "first", "second", etc. in the embodiments of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.

[0040] Embodiments of the present application provide a model training method, device, electronic device, medium and program product.

[0041] The model training device can be integrated into an electronic device, which can be a terminal, a server, or other device. The terminal includes but is not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, and other devices; the server can be a single server or a server cluster consisting of multiple servers.

[0042] In some embodiments, the model training device can also be integrated into multiple electronic devices. For example, the model training device can be integrated into multiple servers, and the model training method of the present application can be implemented by multiple servers.

[0043] In some embodiments, the server may also be implemented in the form of a terminal.

[0044] For example, refer to Figure 1a The model training method can be integrated in a server, and the server can obtain a training sample set, which includes an initial sample text corresponding to an initial scene and a newly added sample text corresponding to a newly added scene; the initial sample text is translated by a teacher model to obtain a teacher translation result, and the teacher model is trained by an initial training sample text corresponding to the initial scene, and the number of samples of the initial training sample text is greater than the number of samples of the initial sample text; the initial sample text and the newly added sample text are translated by an initial student model to obtain a student translation result, and the initial student model is obtained by the teacher model; the loss value is calculated by combining the teacher translation result and the student translation result; based on the loss value, the model parameters of the initial student model are updated to obtain a trained student model, so that the trained student model can be used to translate the texts to be translated corresponding to the initial scene and the newly added scene.

[0045] The following are detailed descriptions. It should be noted that the order of the following embodiments is not intended to limit the preferred order of the embodiments. It is understood that in the specific implementation of the present application, sample texts, texts to be translated and other user-related data are involved. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0046] Artificial Intelligence (AI) is a technology that uses digital computers to simulate human perception of the environment, acquire knowledge, and use knowledge. This technology can enable machines to have functions similar to human perception, reasoning, and decision-making. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, as well as machine learning / deep learning, autonomous driving, smart transportation, and other major directions.

[0047] Computer Vision (CV) is a technology that uses computers to replace human eyes to identify, measure and further process target images. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, virtual reality, augmented reality, simultaneous positioning and map construction, autonomous driving, smart transportation and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition. For example, image processing technologies such as image coloring and image stroke extraction.

[0048] The key technologies of speech technology include automatic speech recognition technology, speech synthesis technology and voiceprint recognition technology. Enabling computers to listen, see, speak and feel is the development direction of human-computer interaction in the future, among which speech has become one of the most promising human-computer interaction methods in the future.

[0049] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.

[0050] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning.

[0051] Autonomous driving technology usually includes high-precision maps, environmental perception, behavioral decision-making, path planning, motion control and other technologies. Autonomous driving technology has broad application prospects.

[0052] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, Internet of Vehicles, smart transportation, etc. I believe that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.

[0053] In this embodiment, a model training method involving artificial intelligence is provided, such as Figure 1b As shown, the specific process of the model training method can be as follows:

[0054] 110. Obtain a training sample set, where the training sample set includes an initial sample text corresponding to the initial scene and a newly added sample text corresponding to the newly added scene.

[0055] The training sample set refers to a sample set used to train the initial student model. It is understandable that the training sample set may include multiple sample texts, and a sample text is any initial sample text or any newly added sample text.

[0056] Among them, the sample text refers to the sample text used to train the initial student model, and the initial sample text and the newly added sample text refer to the sample text corresponding to the initial scene and the newly added scene, respectively. For example, the sample text can be in the form of words, phrases, sentences, etc., and can include text information such as text, numbers, characters, symbols, etc. The sample text can be a text in any language, such as Chinese, English, etc., or it can be a text mixed in different languages, such as a text mixed in Chinese and English. The embodiment of the present application does not limit the form of the sample text.

[0057] Wherein, scene refers to the scene that student model is applicable to, that is, the professional field, language form or subject scope involved in the translation task that student model is applicable to. Embodiment of the present application can be used for training of different applicable scenes of student model, such as scene can be professional fields such as legal translation, medical translation, information technology translation, financial translation or literary translation, scene can also be different language forms such as Chinese, English, Japanese, scene can also be different subject scopes such as business, tourism, education. Initial scene refers to the scene that is applicable before student model training (i.e. initial student model), and newly added scene refers to the applicable scene that is newly added after student model training (i.e. student model after training).

[0058] For example, a multi-scenario training sample set can be constructed from sample texts corresponding to scenario A (such as medical translation) and sample texts corresponding to scenario B (such as literary translation). The initial student model can be trained with the training sample set so that it can further learn how to translate the text of scenario B on the basis of having previously learned how to translate the text of scenario A. The trained student model can be used to translate the texts of scenario A and scenario B, so as to enhance the model's adaptability in multiple scenarios.

[0059] 120. The initial sample text is translated by the teacher model to obtain a teacher translation result. The teacher model is trained by the initial training sample text corresponding to the initial scene. The number of samples of the initial training sample text is greater than the number of samples of the initial sample text.

[0060] Among them, the teacher model is a neural network model for guiding the student model. The student model is a neural network model for simulating the teacher model to learn the features and decision rules in the teacher model. For example, the teacher model and the student model can be models in transfer learning or knowledge distillation. In an embodiment of the present application, the teacher model and the student model can be any neural network model that can be used for text translation. For example, the teacher model and the student model can include but are not limited to an encoder-decoder model Seq2Seq (sequence to sequence) model, an attention mechanism model such as a Transformer (multi-head attention) model or a Single-Head Attention (single-head attention model), a pre-trained language model such as a Bert (bidirectional encoder pre-training) model, etc. One or more.

[0061] The teacher translation result refers to the translation result obtained by translating the initial sample text using the teacher model. The translation result may be a result in text form or a result in numerical / vector form obtained by translating the initial sample text.

[0062] The initial training sample text refers to the sample text used to train the teacher model, and the initial training sample text is the sample text corresponding to the initial scene. Figure 1c The training process of the teacher model shown in the figure can use a large amount of initial training sample texts with label information to train the initial teacher model to obtain the teacher model. Specifically, the initial teacher model calculates the loss value of the translation result corresponding to the initial training sample and the corresponding label information. Based on the loss value, the error signal is transmitted back to the initial teacher model through the back propagation algorithm to update the model parameters of the initial teacher model to obtain the teacher model.

[0063] After the teacher model is trained using the sample data of the initial scene (i.e., the initial training sample text), due to the long-term storage restrictions on the sample data of the initial scene or the loss of the stored data, the number of training samples in the scene that can be directly obtained from the storage is small or even zero. For example, only the source data of the verification set corresponding to the initial scene may be saved, but it takes a lot of manpower and time to re-acquire the sample data of the initial scene. Therefore, in order to reduce the acquisition cost of the sample data of the initial scene and improve the efficiency of building the training sample set in the embodiment of the present application, only a small amount of sample data corresponding to the initial scene can be obtained for training the student model.

[0064] Thus, in the embodiment of the present application, a small amount of initial sample text and a large amount of newly added sample text can be used to form a training sample set, so as to use the training sample set to train the initial learning model to obtain a trained student model. Specifically, in the training process of the student model, each initial sample text in a small amount of initial sample text can be represented as a vector form using word vectors or sentence vectors, such as the vector representation of initial sample text 1: [0.2, 0.4, -0.3, ...], ..., the vector representation of initial sample text n: [0.5, 0.2, -0.4, ...], and then the vector representation of the initial sample text is decoded by the teacher model or the initial student model to obtain the translation results corresponding to each initial sample text, such as the vector representation of translation result 1 corresponding to initial sample text 1: [-0.1, 0.3, -0.2, ...], ..., the vector representation of translation result n corresponding to initial sample text n: [0.3, 0.1, -0.5, ...].

[0065] In some embodiments, the teacher model can obtain the translation result of the model through encoding processing, attention processing and decoding processing, so as to automatically learn the importance weights of different positions in the input text based on the attention mechanism, so that the teacher model can focus on the most critical and meaningful parts of the text, so as to improve the expression ability of the teacher model and increase the accuracy of the translation result. Specifically, the teacher model includes a teacher encoding network, a teacher attention network and a teacher decoding network. The teacher model is used to translate the initial sample text, and the teacher translation result obtained includes:

[0066] Through the teacher encoding network, the initial sample text is encoded to obtain the teacher encoding vector;

[0067] Through the teacher attention network, the teacher encoding vector is processed with attention to obtain the teacher attention vector;

[0068] The teacher's attention vector is decoded through the teacher decoding network to obtain the translation result of the initial sample text to obtain the teacher's translation result.

[0069] Among them, the teacher encoding network, the teacher attention network and the teacher decoding network refer to the encoding network, the attention network and the decoding network in the teacher model respectively. For example, the encoding network may include but is not limited to one or more of the neural network structures that can convert the input content into a vector representation, such as a recurrent neural network (RNN), a convolutional neural network (CNN), an embedding layer, a global vector representation (GloVe) model, a Word2Vec model, etc.; the attention network may include but is not limited to one or more of the neural network structures that can use the attention mechanism to focus on relevant information, such as a network based on self-attention (Self-Attention), a network based on multi-head attention (Multi-Head Attention), and an attention network based on LSTM; the decoding network may include but is not limited to one or more of the neural network structures that can be used to convert the encoded vector into the final output, such as a recurrent neural network (RNN) decoder, a Transformer (multi-head attention network) decoder, a convolutional neural network (CNN) decoder, and a fully connected layer.

[0070] The teacher encoding vector refers to the encoding vector obtained by encoding the initial sample text by the teacher encoding network. The teacher attention vector refers to the attention vector obtained by the teacher attention network performing attention processing on the teacher encoding vector.

[0071] For example, for any initial sample text "Hello, how are you", you can enter the text as follows Figure 1d The teacher model shown converts the text into a teacher encoding vector through a teacher encoding network, and the teacher encoding vector represents the semantic information of the text. Then the teacher encoding vector is input into the teacher attention network, and the teacher encoding vector is processed by the teacher attention network to obtain the teacher attention vector, which represents the importance weight of each teacher encoding vector position. Then the teacher attention vector is input into the teacher decoding network, and the teacher attention vector is decoded by the teacher decoding network to obtain the translation result of the initial sample text. Among them, the translation result can be a vector representing the probability distribution of the target sequence obtained by decoding (i.e., the translation result in vector form), and the translation result can also be the translation text corresponding to the vector, such as the probability of all words in the vocabulary at each position in the sequence represented by the vector of the target sequence probability distribution, and the word with the largest probability at each position in the sequence is selected as the final output, and a translation text such as "Hello, how are you recently" can be obtained.

[0072] In some implementations, in the teacher model, the initial sample text can be converted into a teacher encoding vector that integrates word vectors and position vectors through a teacher encoding network, so that the vector representation of each word not only considers its semantic information, but also integrates the position information, so as to improve the expression ability of the teacher model and increase the accuracy of the translation result. Specifically, the initial sample text is encoded through the teacher encoding network to obtain a teacher encoding vector, including:

[0073] Through the teacher encoding network, the words in the initial sample text are mapped to the teacher word vectors;

[0074] Generate a teacher position vector of the word according to the position of the word in the initial sample text;

[0075] Combine the teacher word vector and the teacher position vector to generate the teacher encoding vector.

[0076] The teacher word vector refers to the vector obtained by mapping the words in the initial sample text. The teacher position vector refers to the vector generated according to the position of the words in the initial sample text.

[0077] For example, for any initial sample text "I love to eat fruit", the word vector representations v1, v2, v3, and v4 of the words "I", "love", "eat", and "fruit" in the text can be obtained through a pre-trained word vector model such as the global vector representation (GloVe) model. The position vector of the word is obtained using absolute position encoding or relative position encoding. For example, using absolute position encoding, the positions of these four words in the text are 1, 2, 3, and 4, respectively, so their position vector representations p1, p2, p3, and p4 can be generated. Then, the word vector and the position vector are combined by addition or concatenation to obtain the teacher encoding vector. For example, by adding, the vector representation of each word combination can be obtained: c1 = v1 + p1, c2 = v2 + p2, c3 = v3 + p3, c4 = v4 + p4, so the teacher encoding vector corresponding to "I love to eat fruit" can be expressed as {c1, c2, c3, c4}. Based on this method, the teacher encoding vector corresponding to each initial sample text in the training sample set can be obtained.

[0078] In some embodiments, an embedding layer can be used as the teacher encoding network of the teacher model. Figure 1eIn the encoding process shown in FIG. 1 , the teacher encoding network of the teacher model may include a word embedding layer and a positional embedding layer, wherein the word embedding layer is used to map to obtain a word vector, and the positional embedding layer is used to perform position encoding. In this way, the discrete words in the text are mapped to a continuous vector space through the embedding layer, so that the semantic information of the words is encoded into a dense vector representation, and different data are assigned to different positions through the positional embedding layer to obtain a position vector, and then the word vector and the position vector are combined by element addition, concatenation, and matrix multiplication to obtain the teacher encoding vector, so that the model can better understand and process text data.

[0079] In some implementations, historical key information in the text can be obtained through a single attention process, and then the obtained historical key information can be fused with all encoding vectors through another attention process to obtain context information, so as to better capture the long-term dependencies and context perception in the text, so as to improve the expressiveness of the teacher model and increase the accuracy of the translation results. Specifically, the teacher attention network includes a first teacher attention network and a second teacher attention network. Through the teacher attention network, the teacher encoding vector is subjected to attention processing to obtain the teacher attention vector, including:

[0080] Through the first teacher attention network, the vector before the to-be-processed teacher vector in the teacher encoding vector is subjected to attention processing to obtain an initial teacher attention vector, where the to-be-processed teacher vector is the vector of any word of the initial sample text corresponding to the teacher encoding vector;

[0081] Through the second teacher attention network, the initial teacher attention vector and the teacher encoding vector are processed to obtain the teacher attention vector.

[0082] For example, the teacher attention network may include two layers of multi-head attention networks (Transformer) and one layer of feedforward neural network (FNN). After the teacher coding vector is input into the teacher attention network, the vector corresponding to each word in the teacher coding vector is firstly processed by the first layer of Transformer (i.e., the first teacher attention network) to obtain the initial teacher attention vector corresponding to each word. For example, for the teacher coding vector H x {c1,c2,c3,c4}, for the vector ct corresponding to the t-th word, such as the vector c4 corresponding to the word "fruit", we can use H y =MultiHead(y,y,y) to get the initial teacher attention vector H corresponding to the word "fruit" y, where MultiHead() represents the multi-head attention process, and y represents the vector corresponding to the word before the word "fruit". For example, y, y, y can represent the query, key, and value in the multi-head attention obtained by transforming c1 to c3. Then, the second Transformer layer (i.e., the second teacher attention network) is used to process H x and H corresponding to the tth word in the text y Perform multi-head attention processing to obtain H x And H corresponding to the tth word y The interactive representation is forward-calculated through the FNN layer to obtain the teacher attention vector. Calculate the teacher attention vector corresponding to the tth word Among them, H y ,H x ,H x They represent the query, key, and value in multi-head attention respectively, and FNN() represents the forward calculation process of FNN.

[0083] In some implementations, the teacher attention vector can be linearly predicted and classified to better understand the importance and probability of each word in the text in the translation based on the teacher distribution probability, so as to increase the accuracy of the translation result. Specifically, the teacher attention vector is decoded through the teacher decoding network to obtain the translation result of the initial sample text, so as to obtain the teacher translation result, including:

[0084] Through the teacher decoding network, the teacher attention vector is linearly predicted to obtain the teacher prediction vector;

[0085] The teacher prediction vector is classified and transformed to obtain the teacher distribution probability to obtain the teacher translation result.

[0086] Among them, the teacher prediction vector refers to the prediction vector obtained by linear prediction of the teacher attention vector, and the teacher prediction distribution refers to the probability distribution obtained by normalizing the teacher prediction vector.

[0087] For example, the teacher decoding network may include a linear layer. Linear prediction and normalization of the teacher's attention vector are performed to obtain the teacher's prediction distribution p θ (Y t |X), where represents the linear layer processing process, W o ,b o Represent the weight matrix and bias matrix of the linear layer respectively, so as to pass W in the linear layer o ,bo The teacher's attention vector is linearly weighted to obtain the teacher's prediction vector corresponding to the t-th word, where Softmax() is a normalization process. For example, the teacher's prediction vector can be mapped to the (0,1) interval through a normalized exponential function (i.e., softmax function) to obtain a distribution probability corresponding to the t-th word (i.e., teacher's distribution probability), and the teacher's distribution probability can be used as the teacher's translation result. The word with the highest score can also be determined as the translation of the t-th word based on the distribution probability, thereby determining the translation of all words in the text, and composing the translation text according to the word order in the text, that is, obtaining the teacher's translation result.

[0088] In some implementations, the distribution probability or translation corresponding to each word can be determined from the beginning to the end according to the word order in the text input into the teacher model, and then the teacher translation result can be obtained from the distribution probability corresponding to all words, or the translation corresponding to the distribution probability can be concatenated according to the word order to obtain the teacher translation result. For example, after obtaining the translation composed of the t-1th word, Predict the tth word in the translation, where X represents the teacher encoding vector and y 1:t-1 represents the translation composed of the predicted t-1th word, and Y represents the translated text. For example, the teacher attention network can include two layers of multi-head attention network (Transformer) layers, and the self-attention mechanism is used to establish the dependency between the word sequence in the input text and the word sequence in the generated translation, and generate the next element. Specifically, in the decoder part of the Transformer, the input sequence X and the generated sequence y 1:t-1 It will be processed through multiple layers of multi-head attention network layers and a feedforward neural network (FNN) layer, and the next target element y will be generated according to the result of attention weight distribution. t , and so on, until all the words in the translation are predicted.

[0089] 130. The initial sample text and the newly added sample text are translated by the initial student model to obtain the student translation result. The initial student model is obtained by the teacher model.

[0090] The initial student model refers to the student model before training, and the student model obtained by training the initial student model is the student model after training.

[0091] Among them, the student translation result refers to the translation result obtained by translating the initial sample text and the newly added sample text using the student model. The translation result can be a text result obtained by translating the initial sample text and the newly added sample text, or a result in a numerical / vector form.

[0092] It can be understood that in the embodiment of the present application, in the training of the student model, only the teacher model is used to process a small amount of initial sample text corresponding to the initial scene, while the student model is used to process a small amount of initial sample text corresponding to the initial scene and a large amount of newly added sample text corresponding to the newly added scene. The student model is gradually learned and adapted to different scenes through the newly added sample text, thereby improving the translation ability of the student model in the newly added scene. The sample data corresponding to a small amount of initial scenes is used to guide the student model to learn the representation of certain features of the teacher model to avoid forgetting the initial scene, so as to improve the expression ability of the student model in the initial scene and the newly added scene, enhance the multi-scene adaptability of the model, and enable the trained student model to have good translation ability for multiple scenes.

[0093] In the embodiments of the present application, the initial student model can be obtained by a variety of methods. For example, the student model can be initialized using the model parameters of the teacher model to obtain the initial student model, so as to use the knowledge learned by the teacher model on large-scale data as the starting point of the student model to accelerate the convergence of the student model and improve the performance. For another example, part of the model structure of the teacher model can be extracted as the initial student model to simplify the model structure of the student model and improve the training efficiency.

[0094] In some embodiments, in order to simplify the training process and improve the training efficiency, the teacher model can be used as the initial student model. For example, the initial student model can be copied from the teacher model, that is, the model structure and model parameters of the teacher model and the initial student model are the same. It should be noted that the processing process and principle of the same model structure in the initial student model and the teacher model are the same. Therefore, the specific processing process and principle of the initial student model can refer to the corresponding content of the corresponding network structure processing process of the aforementioned teacher model, which will not be repeated here.

[0095] In some embodiments, the student model can obtain the translation result of the model through encoding processing, attention processing and decoding processing, so as to automatically learn the importance weights of different positions in the input text based on the attention mechanism, so that the student model can focus on the most critical and meaningful parts of the text, so as to improve the expression ability of the student model and increase the accuracy of the translation result. Specifically, the initial student model includes an encoding network, an attention network and a decoding network. The initial sample text and the newly added sample text are translated by the initial student model to obtain the student translation result, including:

[0096] Through the encoding network, the target text is encoded to obtain an encoding vector, and the target text is any sample text in the training sample set;

[0097] Through the attention network, the encoding vector is processed with attention to obtain the attention vector;

[0098] The attention vector is decoded through the decoding network to obtain the translation result of the target text to obtain the student translation result.

[0099] For example, for any input target text "Hello, how are you", the text can be input into the encoding network, and the encoding network converts the text into an encoding vector, which represents the semantic information of the text. The encoding vector is then input into the attention network, and the attention network performs attention processing on the encoding vector to obtain an attention vector, which represents the importance weight of each encoding vector position. The attention vector is then input into the decoding network, and the attention vector is decoded by the decoding network to obtain the translation result of the target text.

[0100] It should be noted that the encoding network, attention network and decoding network in the student model have the same structures as the teacher encoding network, teacher attention network and teacher decoding network in the teacher model respectively. The specific processing process and principles of each network can be found in the corresponding content of the corresponding network structure processing process of the aforementioned teacher model, which will not be repeated here.

[0101] In some implementations, in the student model, the initial sample text and the newly added sample text can be converted into an encoding vector that integrates the word vector and the position vector through the student encoding network, so that the vector representation of each word not only considers its semantic information, but also integrates the position information, so as to improve the expression ability of the student model and increase the accuracy of the translation result. Specifically, the target text is encoded through the encoding network to obtain the encoding vector, including:

[0102] Through the encoding network, the words to be processed in the target text are mapped into word vectors;

[0103] Generate a position vector of the word to be processed according to the position of the word to be processed in the target text;

[0104] Combine the word vector and the position vector to generate the encoding vector.

[0105] The words to be processed are words in the target text. For example, for any target text "I love to eat fruit", the word vector representations v1, v2, v3, and v4 of the words "I", "love", "eat", and "fruit" in the text can be obtained through a pre-trained word vector model such as the Global Vector Expression (GloVe) model. The position vector of the word is obtained using absolute position encoding or relative position encoding. Then, the word vector and the position vector are combined by addition or concatenation to obtain the encoding vector.

[0106] In some implementations, an embedding layer may be used as the encoding network of the student model.

[0107] In some implementations, historical key information in the text can be obtained through a single attention process, and then the obtained historical key information can be fused with all encoding vectors through another attention process to obtain context information, so as to better capture the long-term dependencies and context perception in the text, so as to improve the expression ability of the student model and increase the accuracy of the translation results. Specifically, the attention network includes a first attention network and a second attention network. Through the attention network, the encoding vector is subjected to attention processing to obtain an attention vector, including:

[0108] Through the first attention network, the vector before the to-be-processed vector in the encoding vector is subjected to attention processing to obtain an initial attention vector, where the to-be-processed vector is the vector of any to-be-processed word in the encoding vector corresponding to the target text;

[0109] Through the second attention network, the initial attention vector and the encoding vector are processed to obtain the attention vector.

[0110] The first attention network and the second attention network in the attention network in the student model can be the first teacher attention network and the second teacher attention network in the teacher attention network, respectively. For example, the attention network can include two layers of multi-head attention network (Transformer) layers and one layer of feedforward neural network (FNN) layer. After the encoding vector is input into the attention network. First, the vector corresponding to each word in the encoding vector is processed by multi-head attention through the first layer of Transformer layer (i.e., the first attention network) to obtain the initial attention vector corresponding to each word. Then, the encoding vector and the initial attention vector are processed by multi-head attention through the second layer of Transformer layer (i.e., the second attention network) to obtain the interactive representation of the encoding vector and the initial attention vector, and the interactive representation is forward calculated through the FNN layer to obtain the attention vector.

[0111] In some implementations, linear prediction and classification changes can be performed on the attention vector to better understand the importance and possibility of each word in the text in the translation based on the distribution probability, so as to increase the accuracy of the translation result. Specifically, the attention vector is decoded through the decoding network to obtain the translation result of the target text, so as to obtain the student translation result, including:

[0112] Through the decoding network, the attention vector is linearly predicted to obtain the prediction vector;

[0113] The prediction vector is transformed into a classification form to obtain the distribution probability and thus the student translation result is obtained.

[0114] For example, the decoding network may include a linear layer. Perform linear prediction and normalization on the attention vector to obtain the predicted distribution p θ (Y t |X), where represents the linear layer processing process, W o ,b o Represent the weight matrix and bias matrix of the linear layer respectively, so as to pass W in the linear layer o ,b o The attention vector is linearly weighted to obtain the prediction vector corresponding to the t-th word, where Softmax() is a normalization process. For example, the prediction vector can be mapped to the (0,1) interval through a normalized exponential function (i.e., softmax function) to obtain a distribution probability (i.e., distribution probability) corresponding to the t-th word, and the distribution probability can be used as the translation result. The word with the highest score can also be determined as the translation of the t-th word based on the distribution probability, thereby determining the translation of all words in the text, and composing the translation text according to the word order in the text, that is, obtaining the translation result.

[0115] In some implementations, the distribution probability or translation corresponding to each word may be determined from front to back according to the word order in the text input into the model, and then the distribution probabilities or translations corresponding to all words may be concatenated according to the word order to obtain the translation result.

[0116] 140. Combining the teacher's translation results with the student's translation results, the loss value is calculated.

[0117] In an embodiment of the present application, a loss value can be calculated by combining the teacher translation result and the student translation result through a variety of methods, so as to guide the student model to learn the representation of the teacher model through the loss value, thereby realizing knowledge transfer and model optimization. For example, the loss between the teacher translation result output by the teacher model and the student translation result output by the student model can be measured by contrast loss, distillation loss, KL divergence loss, and reconstruction loss. It should be noted that based on different loss value calculation methods, the initial sample text and the newly added sample text provided in the embodiment of the present application can carry label information (i.e., sample labels) or not (i.e., no sample labels).

[0118] In some embodiments, the loss between the teacher translation result output by the teacher model and the student translation result output by the student model can be measured by a distillation loss value. Specifically, the loss value includes a distillation loss value. Among them, the distillation loss refers to a loss function used for knowledge distillation, which is used to guide the student model to learn knowledge from the teacher model. For example, the distillation loss may include but is not limited to a combination of one or more of the mean square error loss, cross entropy loss, KL divergence loss, etc. The loss value calculated by the distillation loss is the distillation loss value.

[0119] In some embodiments, in the process of the student model learning the newly added scene representation, the distillation loss value can be calculated by combining the performance of the student model in the translation task of the newly added scene, and the difference between the teacher model and the student model in the translation task, so as to evaluate the translation quality and adaptability of the student model in the newly added scene and the initial scene, avoid forgetting the initial scene, so as to improve the expression ability of the student model in the initial scene and the newly added scene, and enhance the multi-scene adaptability of the model. Specifically, the newly added sample text carries label information, and the loss value is calculated by combining the teacher translation result and the student translation result, including (or the distillation loss value is obtained by the following steps):

[0120] Calculate the difference between the label information of the newly added sample text and the newly added translation result to obtain a predicted difference value, and the newly added translation result is the translation result corresponding to the newly added sample text in the student translation result;

[0121] Calculate the difference between the teacher's translation result and the student's translation result to obtain the difference value between models;

[0122] The distillation loss value is calculated based on the predicted difference value and the difference value between models.

[0123] The label information refers to information used to describe and represent the characteristics, attributes or categories of the sample text, that is, the sample label. For example, in the embodiment of the present application, the label information carried by the newly added sample text may refer to the translation result of the sample text.

[0124] The prediction difference value refers to the difference between the label information of the newly added sample text and its corresponding translation result, that is, the prediction difference value can measure the difference between the sample label and the model prediction value, so as to characterize the performance of the student model in the translation task of the newly added scenario through this difference. The inter-model difference value refers to the difference between the teacher's translation result and the student's translation result, that is, the inter-model difference value can characterize the difference between the teacher model and the student model in the translation task. The distillation loss value refers to the loss value calculated based on the prediction difference value and the inter-model difference value.

[0125] For example, L B =CE(Y b ,θ AB (X b )) Calculate the predicted difference value L B , where X b Indicates the addition of sample text, Y b represents the label information of the newly added sample text (i.e., sample label), θ AB represents the processing of the initial student model, θ AB (X b ) represents the newly added translation result, and CE() represents the cross entropy loss function. Figure 1f The process of calculating the distillation loss value shown in the figure is to calculate the cross entropy loss of the sample label (i.e. label information) of the newly added sample text and its corresponding newly added translation result through the cross entropy loss function, and the loss value obtained is the prediction difference value. At the same time, the cross entropy loss can be calculated for the teacher's translation result and the student's translation result through the cross entropy loss function, and the loss value obtained is the difference between models. Then, the predicted difference value and the difference between models are calculated through arithmetic operations, logical operations and other calculation methods to obtain the distillation loss value.

[0126] It is understandable that since the embodiment of the present application uses a small amount of sample data corresponding to the initial scene for training the initial student model. To this end, in order to enhance the training effect of the student model, the embodiment of the present application combines the performance of the student model in the translation task of the newly added scene, and the difference between the teacher model and the student model in the translation task, so as to resist the forgetting of the initial scene in the process of the student model learning the newly added scene representation through the distillation loss. In this way, only a small amount of sample data corresponding to the initial scene can be used to prevent forgetting in the transfer learning process, so as to enhance the training effect of the student model, improve the expression ability of the student model, and increase the accuracy of the translation results.

[0127] In some implementations, a more accurate difference value between models can be obtained by comparing the performance of the teacher model and the student model on the same translation task. Specifically, the difference between the teacher translation result and the student translation result is calculated to obtain the difference value between models, including:

[0128] Obtaining an initial translation result, where the initial translation result is a translation result corresponding to an initial sample text in the student translation result;

[0129] The difference between the teacher's translation result and the initial translation result is calculated to obtain the inter-model difference value.

[0130] For example, you can Calculate the difference between models, where X a represents the initial sample text, θ A represents the processing of the teacher model, θ AB represents the processing of the initial student model, θ A (X a ) represents the teacher's translation result, θ AB (X a ) represents the initial translation result, and CE() represents the cross entropy loss function. Figure 1f The process of calculating the distillation loss value is shown in the figure. The cross entropy loss function can be used to calculate the cross entropy loss for the teacher translation result and the initial translation result. The loss value obtained is the difference between the models.

[0131] In some implementations, the predicted difference value and the model difference value may be weighted and summed to obtain the distillation loss value. Perform weighted summation to get the distillation loss value Where L B represents the predicted difference value, Represents the difference between models, α represents the dynamic learning weight, and the value range of α can be 0 to 1 or 0 to 5. Usually α is set to 1.0. Figure 1f The process of calculating the distillation loss value is shown in the figure. The distillation loss value can be obtained by weighted summing the predicted difference value and the difference value between models.

[0132] In some embodiments, the loss between the teacher translation result output by the teacher model and the student translation result output by the student model can be measured in combination with the distillation loss value and the contrast loss value. Specifically, the loss value includes a comprehensive loss value, and the comprehensive loss value is obtained by the distillation loss value and the contrast loss value. Among them, the contrast loss refers to a loss function used to learn the similarities and differences between samples. For example, the contrast loss may include but is not limited to a combination of one or more of positive and negative sample loss, triple loss, center loss, N to M contrast loss, etc. The loss value calculated by the contrast loss is the contrast loss value. For example, the comprehensive loss value can be calculated by arithmetic operations, logical operations, and other calculation methods on the distillation loss value and the contrast loss value.

[0133] In some implementations, the similarity between the translation results of the same translation task and the similarity between the translation results of different translation tasks can be combined to determine the comparison loss value corresponding to the similarity, and then combined with the distillation loss value to more comprehensively evaluate the student model's expression ability and adaptability to the initial scene and the newly added scene, and also avoid forgetting the initial scene, and enhance the model's multi-scene adaptability. Specifically, the loss value includes a comprehensive loss value, which is calculated by combining the teacher's translation results and the student's translation results, including:

[0134] According to the teacher translation result and the student translation result, determine a first similarity between translation results corresponding to the same sample text, a second similarity between translation results corresponding to different sample texts, and a distillation loss value between the teacher model and the initial student model;

[0135] Calculate the comparison loss value according to the first similarity and the second similarity;

[0136] The comprehensive loss value is determined by combining the comparison loss value and the distillation loss value.

[0137] The first similarity refers to the similarity between the translation results of the same sample text (i.e., the same translation task), and the second similarity refers to the similarity between the translation results of different sample texts (i.e., different translation tasks). The similarity can be expressed as a characteristic distance such as Euclidean distance, cosine similarity or other distance metrics. The contrast loss value refers to the loss value calculated based on the first similarity and the second similarity.

[0138] For example, taking the initial scene and the newly added scene as scene A and scene B respectively, and taking the training sample set as an example including m initial sample texts and n newly added sample texts, m<n, the teacher translation result may include the translation results of m initial sample texts, such as A1, ..., A m , the student model can include the translation results of m initial sample texts and n newly added sample texts, such as A'1, ..., A' m and B1, ..., B n . The A corresponding to the same sample text such as the initial sample text i can be calculated i and A' i The first feature distance (i.e., the first similarity) between them, and the calculation of the A corresponding to different sample texts such as the initial sample text i i A' corresponding to the initial sample text j j The second feature distance (i.e., the second similarity) between the two, or calculate the A corresponding to different sample texts such as the initial sample text i i and B corresponding to the newly added sample text k k The second characteristic distance (i.e., the second similarity) between the first characteristic distance and the second characteristic distance is calculated by arithmetic operations, logical operations, and the like to obtain a contrast loss value. The contrast loss value and the distillation loss value obtained by the above method are then calculated by arithmetic operations, logical operations, and the like to obtain a comprehensive loss value.

[0139] It is understandable that, since the embodiment of the present application uses a small amount of sample data corresponding to the initial scene for training the initial student model. To this end, in order to enhance the training effect of the student model, the embodiment of the present application calculates the feature distances respectively for the translation results of the teacher model and the student model, the translation results corresponding to the same sample text and the translation results corresponding to different sample texts, so that the feature distance between the translation results corresponding to the same sample text can be reduced based on the feature distance minimization loss value, and the feature distance between the translation results corresponding to different sample texts can be increased to ensure that the student model can produce differentiated translation results when processing different sample texts, so as to enhance the model's adaptability to multiple scenes. In this way, only a small amount of sample data corresponding to the initial scene can be used to prevent the initial scene from being forgotten during the transfer learning process, so as to enhance the training effect of the student model, and improve the expression ability of the student model, and increase the accuracy of the translation results.

[0140] In some implementations, negative sample translation results can be obtained through a negative sample processing model, so as to use the negative sample translation results and the student translation results to determine the second similarity between the translation results corresponding to different sample texts, so as to use the negative sample translation results to balance the training between positive and negative samples and improve the model's recognition ability for negative samples. Specifically, the first similarity and the second similarity are determined by the following steps:

[0141] Obtaining negative sample translation results, where the negative sample translation results are translation results of the initial sample texts using a negative sample processing model, where the negative sample processing model is trained using newly added training sample texts corresponding to newly added scenarios;

[0142] Determine a first similarity between translation results corresponding to the same sample text according to the teacher's translation result and the initial translation result, wherein the initial translation result is a translation result corresponding to the initial sample text in the student's translation result;

[0143] According to the negative sample translation result and the initial translation result, a second similarity between translation results corresponding to different sample texts is determined.

[0144] Among them, the negative sample processing model refers to a neural network model used to process negative sample text. In some embodiments, the model structure of the negative sample processing model is the same as the teacher model or the student model, such as the negative sample processing model can be obtained by training the initial teacher model or the initial student model with the newly added training sample text. It should be noted that since the model structure of the negative sample processing model is the same as the teacher model or the student model, its specific processing process and principle can refer to the corresponding content of the aforementioned teacher model or student model processing process, which will not be repeated here.

[0145] The newly added training sample text refers to the sample text used to train the negative sample processing model, and the sample text is the sample text corresponding to the newly added scene. The newly added training sample text can be obtained from all or part of the newly added sample text, or from sample text corresponding to other newly added scenes.

[0146] Among them, the negative sample translation result refers to the translation result obtained by translating the negative sample text using the negative sample processing model, and the translation result can be a text result obtained by translating the negative sample text, or a result in the form of a numerical value or vector. For example, all or part of the sample text of the initial sample text can be input as a negative sample text into the negative sample processing model to obtain the negative sample translation result.

[0147] For example, taking the initial scene and the newly added scene as scene A and scene B respectively, and taking the training sample set as an example including m initial sample texts and n newly added sample texts, m<n, the teacher translation result may include the translation results of m initial sample texts, such as A1, ..., Am , the student model can include the translation results of m initial sample texts and n newly added sample texts, such as A'1, ..., A' m (i.e. the initial translation result) and B1, ..., B n , the negative sample translation result can include the translation results of o initial sample texts (o≤m), such as A”1, …, A” o The A corresponding to the same sample text in the teacher's translation result and the initial translation result, such as the initial sample text i, can be calculated i and A' i The first feature distance (ie, the first similarity) between the initial translation result and the negative sample translation result, and the calculation of the A' corresponding to different sample texts such as the initial sample text i i A" corresponding to the initial sample text j j The second feature distance (i.e., the second similarity) between them is then calculated by arithmetic operations, logical operations, and other operation methods to obtain the contrast loss value.

[0148] It is understandable that if Figure 1g The process of calculating the contrast loss value is shown in FIG. 1 . For the contrastive learning process, the initial sample text input to the teacher model is a positive sample, that is, the teacher translation result is a positive sample feature representation, the initial sample text input to the student model is a simple negative sample that is relatively easy to distinguish, that is, the student translation result corresponding to the initial sample text is a simple negative sample feature representation, and the initial sample text input to the negative sample processing model is a difficult negative sample that is difficult to distinguish, that is, the negative sample translation result is a difficult negative sample feature representation. Therefore, the contrast loss value is calculated based on the positive sample feature representation, the simple negative sample feature representation, and the difficult negative sample feature representation, so that the negative sample feature representation of different difficulties is used in contrastive learning to balance the training process between positive and negative samples in different scenes, forcing the student model to learn and distinguish between the initial scene and the newly added scene, so that the trained student model has good translation capabilities for multiple scenes, so as to enhance the model's adaptability in multiple scenes.

[0149] In some embodiments, a normalization factor may be determined in combination with the first similarity and the second similarity, and the first similarity may be normalized using the factor to obtain a more robust and comparable contrast loss value. Specifically, the contrast loss value is calculated based on the first similarity and the second similarity, including:

[0150] Determine a normalization factor by combining the first similarity and the second similarity;

[0151] The first similarity is normalized according to the normalization factor to obtain a comparison loss value.

[0152] For example, the contrast loss value can be calculated using the following formula:

[0153]

[0154] Among them, A represents the teacher model, AB represents the student model, and B represents the negative sample processing model. represents the first similarity, Represents the second similarity, sim() represents the similarity calculation, and the specific similarity calculation method can be different according to the application scenario and actual needs. represents the translation result of the student model for any initial sample text i, represents the translation result of the teacher model for any initial sample text i, Represents the translation result of the negative sample processing model for any initial sample text j, τ represents the temperature adjustment factor, usually τ = 0.7. In this way, in the above formula, the first similarity is divided by the temperature adjustment factor after being raised to a power, the second similarity corresponding to all negative sample translation results processed by the negative sample processing model is raised to a power and then added and divided by the temperature adjustment factor, and then the two parts are added to obtain the normalization factor, and then the value of the first similarity raised to a power and divided by the temperature adjustment factor is divided by the normalization factor, and the negative logarithm operation is used to obtain the final contrast loss value

[0155] In practical applications, all or part of the initial sample text can be used for negative sample processing model translation to obtain negative sample translation results. In some embodiments, the initial sample text can be randomly sampled to obtain part of the sample text to reduce the amount of tasks processed by the negative sample processing model and improve the model training efficiency. Specifically, the negative sample translation result includes a first negative sample translation result and a second negative sample translation result, and the negative sample translation result is obtained by the following steps:

[0156] Randomly sample the initial sample text to obtain a sample text;

[0157] The sample text is translated through the negative sample processing model to obtain the negative sample translation result.

[0158] In some embodiments, the comparison loss value and the distillation loss value may be weighted and summed to obtain a comprehensive loss value. The weighted sum is used to obtain the comprehensive loss value, where represents the distillation loss value, It represents the contrast loss value, β represents the dynamic learning weight, and the value range of β can be 0-1 or 0-5. β is usually set to 1.0.

[0159] In some implementations, sub-loss values ​​may be calculated for multiple initial scenes respectively, and then the multiple sub-loss values ​​may be combined to obtain a total loss value, so as to avoid forgetting each initial scene, so that the model has good translation capabilities for multiple scenes, and enhance the model's adaptability in multiple scenes. Specifically, the initial scene includes multiple scenes, and the loss value is calculated by combining the teacher's translation results and the student's translation results, including:

[0160] For any scenario among the multiple scenarios, calculate the sub-loss value corresponding to any scenario;

[0161] The sub-loss values ​​corresponding to multiple scenes are merged to obtain the loss value.

[0162] The sub-loss value may be one or more of a distillation loss value, a contrast loss value, or a difference value between models. The merging process of the sub-loss values ​​may include arithmetic operations, logical operations, and other operation methods, such as weighted summation, weighted average, and the like.

[0163] For example, the teacher model applicable to the initial scene A and the initial student model copied from the teacher model can be trained using the method of the embodiment of the present application to obtain a trained student model applicable to scene A and scene B. The trained student model is used as the teacher model, and the initial student model copied from the teacher model is used in the training process in which the initial scene includes scene A and scene B, and the newly added scene includes scene C, so as to obtain a trained student model applicable to scene A, scene B and scene C. By analogy, for each newly added scene, the trained student model obtained from the last training can be used as a teacher model to train the trained student model applicable to the new newly added scene as a teacher model, so as to gradually expand the scenarios to which the student model is applicable to more scenarios.

[0164] In some embodiments, when the loss value includes a distillation loss value, the sub-loss may be a difference value between models corresponding to each initial scene, for example, The distillation loss value is obtained by weighted calculation, where L C Indicates the predicted difference value corresponding to the newly added scenario, represents the difference between models corresponding to the initial scene A, represents the difference between models corresponding to the initial scene B, α represents the dynamic learning weight, and the value range of α can be 0-1 or 0-5, and α is usually set to 1.0. C =CE(Y c ,θ ABC (X c )), Among them, Y b Indicates the label information of the newly added sample text (i.e., sample label), X arepresents the initial sample text corresponding to the initial scene A, θ ABC represents the processing of the initial student model, θ ABC (X c ) represents the translation result corresponding to the newly added sample text in the student translation result, θ AB represents the processing of the teacher model, θ AB (X a ) represents the teacher translation result of the initial sample text corresponding to the initial scene A, θ AB (X b ) represents the teacher translation result of the initial sample text corresponding to the initial scene B, θ ABC (X a ) represents the initial translation result of the initial sample text corresponding to the initial scene A in the student translation result, θ ABC (X b ) represents the initial translation result of the initial sample text corresponding to the initial scene B in the student translation result, and CE() represents the cross entropy loss function.

[0165] In this way, Figure 1h The process of calculating the distillation loss value shown in FIG. 1 is to calculate the cross entropy loss of the sample label (i.e., label information) of the newly added sample text corresponding to the newly added scene C and its corresponding translation result (i.e., newly added translation result) through the cross entropy loss function, and the loss value is the predicted difference value L C ; The cross entropy loss function is used to calculate the cross entropy loss of the teacher translation results and the corresponding student translation results corresponding to different initial scenes, that is, the difference between the models corresponding to the initial scene A Corresponding to the initial scene B Then through The difference between models corresponding to the initial scene A Initial scene B corresponds to And the predicted difference value L C Weighted summation to get the distillation loss value

[0166] In some embodiments, when the loss value includes a comprehensive loss value, the sub-loss may be a comparative loss value corresponding to each initial scene, for example, The weighted sum is used to obtain the comprehensive loss value, where the distillation loss value It can be obtained by the above method, the comparison loss value in represents the contrast loss value corresponding to the initial scene A, represents the contrast loss value corresponding to the initial scene B. Specifically, Among them, AB represents the teacher model, ABC represents the student model, and C represents the negative sample processing model. represents the translation result of the student model for any initial sample text i corresponding to the initial scene A, represents the translation result of the teacher model for any initial sample text i corresponding to the initial scene A, represents the translation result of the negative sample processing model for any initial sample text j, τ represents the temperature adjustment factor, usually τ = 0.7; in, represents the translation result of the student model for any initial sample text i corresponding to the initial scene B, represents the translation result of the teacher model for any initial sample text i corresponding to the initial scene B, Represents the translation result of the negative sample processing model for any initial sample text j.

[0167] In this way, Figure 1i The process of calculating the contrast loss value is shown in Figure 2. In the contrast learning process, the initial sample texts corresponding to the initial scene A and the initial scene B are input into the teacher model as positive samples, and the positive sample feature representations corresponding to the initial scene A and the initial scene B are obtained respectively. and The initial sample texts corresponding to the initial scene A and the initial scene B are input into the initial student model as simple negative samples, and the simple negative sample feature representations corresponding to the initial scene A and the initial scene B are obtained respectively. and The initial sample texts corresponding to the initial scene A and the initial scene B are input into the negative sample processing model as difficult negative samples, and the feature representations of the difficult negative samples corresponding to the initial scene A and the initial scene B are obtained respectively. and Then, the contrast loss value corresponding to the initial scene is calculated by the positive sample feature representation, simple negative sample feature representation and difficult negative sample feature representation corresponding to the same initial scene. and Then through Sum to get the contrast loss value

[0168] 150. Based on the loss value, update the model parameters of the initial student model to obtain a trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

[0169] For example, based on the loss value, the error signal can be passed back to the initial student model through the back propagation algorithm to update the model parameters of the initial student model so that the initial student model can learn. This process is iterated continuously until the loss function converges to obtain the trained student model, which can be used to translate the text of the initial scene and the newly added scene (i.e., the text to be translated). The convergence of the loss function can refer to the loss value reaching a stable value, and the fluctuation around this value is not large, and no obvious changes occur. Usually, a convergence threshold can be set, and when the loss value is lower than the threshold, the loss function is considered to have converged.

[0170] In some embodiments, the text to be translated corresponding to the initial scene or the newly added scene can be input into the trained student model, and the encoding network in the trained student model can encode the text to be translated to obtain an encoding vector; the attention network in the trained student model can perform attention processing on the encoding vector to obtain an attention vector; the attention vector can be decoded by the decoding network in the trained student model to obtain a translation result of the text to be translated, and the translation result is returned to the terminal in the form of text for display. The specific processing process and principles of each network can refer to the corresponding content of the initial student model processing process in the aforementioned training process, which will not be repeated here.

[0171] The model training scheme provided by the embodiment of the present application can be applied to the training scenarios of various models. For example, taking the training applied to the attention mechanism model as an example, a training sample set is obtained, and the training sample set includes the initial sample text corresponding to the initial scene and the newly added sample text corresponding to the newly added scene; the initial sample text is translated by the teacher model to obtain the teacher translation result, and the teacher model is trained by the initial training sample text corresponding to the initial scene, and the number of samples of the initial training sample text is greater than the number of samples of the initial sample text; the initial sample text and the newly added sample text are translated by the initial student model to obtain the student translation result, and the initial student model is obtained by the teacher model; the loss value is calculated by combining the teacher translation result and the student translation result; based on the loss value, the model parameters of the initial student model are updated to obtain the trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

[0172] As can be seen from the above, in the embodiment of the present application, only a small amount of sample data corresponding to the initial scene can be obtained for training the student model, so as to reduce the acquisition cost of the sample data of the initial scene, and improve the construction efficiency of the training sample set and the training efficiency of the model. In this way, in the training of the student model, only the teacher model is used to process a small amount of initial sample text corresponding to the initial scene, and the student model is used to process a small amount of initial sample text corresponding to the initial scene and a large amount of newly added sample text corresponding to the newly added scene. Through the newly added sample text, the student model gradually learns and adapts to the representation of the newly added scene, improves the translation ability of the student model in the newly added scene, and uses a small amount of initial sample text to guide the student model to learn the representation of certain features of the teacher model, avoid forgetting the initial scene, so as to improve the expression ability of the student model in the initial scene and the newly added scene, so as to enhance the multi-scene adaptability of the model while improving the model training efficiency, so that the trained student model has good translation ability for multiple scenes.

[0173] The method described in the above embodiment will be further described in detail below.

[0174] In this embodiment, the method of the embodiment of the present application will be described in detail by taking the application in a bilingual translation scenario as an example.

[0175] like Figure 2a As shown, the specific process of a model training method is as follows:

[0176] 210. Obtain a training sample set.

[0177] The training sample set includes two batches of training data, one batch of training data is the initial sample text corresponding to the initial scene, such as a small amount of unlabeled monolingual data with the same distribution, and the other batch of training data is the newly added sample text corresponding to the newly added scene, such as bilingual data. The initial sample text does not carry label information, and the newly added sample text carries label information.

[0178] For example, after the teacher model A has been trained to adapt to domain A (i.e., initial scenario A), as time goes by, a new domain B (i.e., newly added scenario B) appears. At this time, it is expected that a new model can handle domains A and B at the same time. However, due to authority restrictions or storage restrictions, the training data of domain A is no longer available, that is, when training a new model, there is only training data of domain B (i.e., newly added sample text). In order to prevent the new model from forgetting the knowledge of domain A, a small amount of unlabeled identically distributed data on domain A, such as the source data on the validation set, can be used as the initial sample text. These data are small in size and very easy to obtain, and can resist forgetting domain A during training.

[0179] 220. The initial sample text is translated through the teacher model to obtain the teacher translation result.

[0180] The teacher model is trained by the initial training sample text corresponding to the initial scene, and the number of samples of the initial training sample text is greater than the number of samples of the initial sample text. For example, the teacher model can map and position encode the initial sample text through the word embedding layer and position embedding layer in the teacher encoding network, and then add the word vector obtained by the mapping and the position vector obtained by the position encoding to obtain the teacher encoding vector of the text. The teacher attention vector is obtained by performing multi-head attention processing and forward calculation on the teacher encoding vector through the multi-head attention network and feedforward neural network in the teacher attention network. The teacher attention vector is linearly predicted and classified through the linear layer in the teacher decoding network to obtain the teacher translation result corresponding to the initial sample text.

[0181] 230. The initial sample text and the newly added sample text are translated through the initial student model to obtain the student translation result.

[0182] The initial student model is obtained by copying the teacher model. For example, the initial student model can map and position-encode the initial sample text or the newly added sample text through the word embedding layer and the position embedding layer in the encoding network, and then add the word vector obtained by the mapping and the position vector obtained by the position encoding to obtain the encoding vector of the sample text. The multi-head attention network and the feedforward neural network in the attention network perform multi-head attention processing and forward calculation on the encoding vector to obtain the attention vector. The linear layer in the decoding network performs linear prediction and classification transformation on the attention vector to obtain the student translation result corresponding to the sample text.

[0183] 240. Calculate the difference between the label information of the newly added sample text and the newly added translation result to obtain a predicted difference value.

[0184] The newly added translation results are the translation results corresponding to the newly added sample texts in the student translation results. B =CE(Y b ,θ AB (X b )) Calculate the predicted difference value L B , where X b Indicates the addition of sample text, Y b represents the label information of the newly added sample text (i.e., sample label), θ AB represents the processing of the initial student model, θ AB (X b ) represents the newly added translation result, and CE() represents the cross entropy loss function.

[0185] 250. Calculate the difference between the teacher's translation result and the initial translation result to obtain the inter-model difference value.

[0186] The initial translation result is the translation result corresponding to the initial sample text in the student translation result. Calculate the difference between models, where X a represents the initial sample text, θ A represents the processing of the teacher model, θ AB represents the processing of the initial student model, θ A (X a ) represents the teacher's translation result, θ AB (X a ) represents the initial translation result, and CE() represents the cross entropy loss function.

[0187] 260. According to the predicted difference value and the difference value between models, the distillation loss value is calculated.

[0188] For example, you can Perform weighted summation to get the distillation loss value Where L B represents the predicted difference value, It represents the difference between models, α represents the dynamic learning weight, and the value range of α can be 0-1 or 0-5. Usually α is set to 1.0.

[0189] 270. Based on the distillation loss value, update the model parameters of the initial student model to obtain a trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

[0190] For example, based on the distillation loss value, the error signal can be passed back to the initial student model through the back propagation algorithm to update the model parameters of the initial student model so that the initial student model can learn. This process is iterated continuously until the loss function converges to obtain the trained student model, which can be used to translate the text of the initial scene and the newly added scene (i.e., the text to be translated).

[0191] In order to verify the effect of the model training method provided in the embodiment of the present application, the model training method provided in the embodiment of the present application is applied to train multiple different translation models (i.e., initial student models) to make them suitable for multiple scenarios. The translation quality of the trained translation models in different scenarios is as follows: Figure 2b As shown, the translation quality is represented by the BLEU indicator, which is an indicator used to evaluate the quality of machine translation. In mBART50-nn(), mBART refers to a multilingual translation pre-training model, 50-nn means that the model uses 50 different languages, and the content in brackets indicates different versions of the model. For example, ET in mBART50-nn(ET) refers to a model that is fine-tuned to obtain a translation task suitable for English to the target language. The student model of this application refers to the student model provided in this application. Figure 2b It can be seen that the multiple models trained by the model training method provided in the embodiment of the present application have good performance in multiple scenarios such as information technology and Korean, and can achieve high translation quality.

[0192] From the above, it can be seen that the embodiment of the present application can retain the performance of the model in the trained field (i.e., the initial field) as much as possible through knowledge distillation learning without using bilingual data (without using supervised training data in the initial field), using only a small amount of unlabeled monolingual data with the same distribution, so as to effectively prevent excessive forgetting, which can not only reduce the cost of training the model during training, but also save storage space when deploying the model.

[0193] The method described in the above embodiment will be further described in detail below.

[0194] In this embodiment, the method of the embodiment of the present application will be described in detail by taking the application in a bilingual translation scenario as an example.

[0195] like Figure 3a As shown, the specific process of a model training method is as follows:

[0196] 310. Obtain a training sample set.

[0197] The training sample set includes two batches of training data, one batch of training data is the initial sample text corresponding to the initial scene, such as a small amount of unlabeled monolingual data with the same distribution, and the other batch of training data is the newly added sample text corresponding to the newly added scene, such as bilingual data. The initial sample text does not carry label information, and the newly added sample text carries label information.

[0198] For example, after the teacher model A has been trained to adapt to domain A (i.e., initial scenario A), as time goes by, a new domain B (i.e., newly added scenario B) appears. At this time, it is expected that a new model can handle domains A and B at the same time. However, due to authority restrictions or storage restrictions, the training data of domain A is no longer available, that is, when training a new model, there is only training data of domain B (i.e., newly added sample text). In order to prevent the new model from forgetting the knowledge of domain A, a small amount of unlabeled identically distributed data on domain A, such as the source data on the validation set, can be used as the initial sample text. These data are small in size and very easy to obtain, and can resist forgetting domain A during training.

[0199] 320. The initial sample text is translated through the teacher model to obtain the teacher translation result.

[0200] The teacher model is trained by the initial training sample text corresponding to the initial scene. The number of samples of the initial training sample text is greater than the number of samples of the initial sample text, and the initial training sample text carries label information. For example, the teacher model can map and position-encode the initial sample text through the word embedding layer and the position embedding layer in the teacher encoding network, and then add the word vector obtained by the mapping and the position vector obtained by the position encoding to obtain the teacher encoding vector of the text. The teacher encoding vector is subjected to multi-head attention processing and forward calculation through the multi-head attention network and the feedforward neural network in the teacher attention network to obtain the teacher attention vector. The teacher attention vector is linearly predicted and classified through the linear layer in the teacher decoding network to obtain the teacher translation result corresponding to the initial sample text.

[0201] 330. The initial sample text and the newly added sample text are translated by the initial student model to obtain the student translation result.

[0202] The initial student model is obtained by copying the teacher model. For example, the initial student model can map and position-encode the initial sample text or the newly added sample text through the word embedding layer and the position embedding layer in the encoding network, and then add the word vector obtained by the mapping and the position vector obtained by the position encoding to obtain the encoding vector of the sample text. The encoding vector is subjected to multi-head attention processing and forward calculation by the multi-head attention network and the feedforward neural network in the attention network to obtain the attention vector. The attention vector is linearly predicted and categorically transformed by the linear layer in the decoding network to obtain the student translation result corresponding to the sample text. Among them, the translation result corresponding to the initial sample text in the student translation result is the initial translation result, and the translation result corresponding to the newly added sample text in the student translation result is the newly added translation result.

[0203] 340. Obtain a negative sample translation result, where the negative sample translation result is a translation result of the initial sample text translated by the negative sample processing model.

[0204] The negative sample processing model is trained by the newly added training sample text corresponding to the newly added scene. For example, the negative sample processing model can map and position-encode the initial sample text or the newly added sample text through the word embedding layer and the position embedding layer in the negative sample encoding network, and then add the word vector obtained by mapping and the position vector obtained by position encoding to obtain the negative sample encoding vector of the sample text. The negative sample encoding vector is subjected to multi-head attention processing and forward calculation by the multi-head attention network and the feedforward neural network in the negative sample attention network to obtain the negative sample attention vector. The negative sample attention vector is subjected to linear prediction and classification transformation by the linear layer in the negative sample decoding network to obtain the negative sample translation result corresponding to the sample text.

[0205] 350. Determine, based on the teacher's translation result and the initial translation result, a first similarity between translation results corresponding to the same sample text, and a second similarity between translation results corresponding to different sample texts.

[0206] 360. Calculate a comparison loss value according to the first similarity and the second similarity.

[0207] For example, the contrast loss value can be calculated using the following formula:

[0208]

[0209] Among them, A represents the teacher model, AB represents the student model, and B represents the negative sample processing model. represents the first similarity, Indicates the second similarity. Specifically, sim() indicates similarity calculation. The specific similarity calculation method may vary according to the application scenario and actual needs. represents the translation result of the student model for any initial sample text i, represents the translation result of the teacher model for any initial sample text i, represents the translation result of the negative sample processing model for any initial sample text j, τ represents the temperature adjustment factor, usually τ = 0.7.

[0210] In the embodiment of the present application, in order to effectively distinguish the knowledge in domain A from the knowledge in domain B, a cross-domain contrastive learning method is used to train the initial student model. At the same time, in order to ensure the domain characteristics, a cross-domain contrast objective (i.e., loss function ) to enhance the extracted knowledge. Specifically, in the contrastive learning process, sample texts can be extracted from the training data of domain A and domain B to form a batch, and any sample text in the corresponding batch of domain A is X a The training data of the corresponding batch of domain A is input into the teacher model θ as positive samples A , by the teacher model θ A Output feature representation of positive samples (i.e., the teacher’s translation result). Input the training data of the corresponding batch of domain A into the student model θ AB , and get the student model θ AB The output feature representation of (i.e. the initial translation result), where X a The corresponding feature representation is the anchor feature. Among them, other sample texts in the batch corresponding to domain A are input into the student model θ as simple negative samples AB , and its corresponding output is the feature representation of simple negative samples. The training data of the corresponding batch of domain A is input into the negative sample processing model θ as difficult negative samplesB , by the negative sample processing model θ B Output feature representation of difficult negative samples

[0211] In this way, the anchor feature can be With the teacher model θ A The original domain representation of the output (i.e. the teacher's translation result) and pulls irrelevant pairs away. and (i.e. j is not equal to the student translation result in i).

[0212] It is understandable that the simple negative samples in the comparative learning process of the present application embodiment are from different instances (i.e., sample texts) of the same field, and cannot distinguish the field features well. Therefore, the present application embodiment designs a difficult sample for field B, which is processed by a model of another field, i.e., the negative sample processing model θ B Encode the same instance through different models to distinguish the domain features between domains A and B. That is, the negative sample in contrastive learning (i.e., the negative sample translation result) consists of two parts: 1) Simple negative sample By removing X from the training sample set a Sample texts other than AB (i.e. negative sample processing model) encoding (j is not equal to i); 2) difficult negative examples (The second negative sample translation result), which is obtained through the domain model θ B (i.e., negative sample processing model) is encoded. Through simple negative samples and difficult negative samples, the student model θ is forced AB Learn and distinguish between domain A and domain B.

[0213] 370. Determine the distillation loss value based on the teacher's translation results and the student's translation results.

[0214] For example, you can Perform weighted summation to get the distillation loss value Where L B represents the predicted difference value, It indicates the difference between models, α indicates the dynamic learning weight, and the value range of α can be 0-1 or 0-5. Usually α is set to 1.0. The details are as follows:

[0215] Through L B =CE(Y b ,θ AB (X b )) Calculate the predicted difference value L B , where X bIndicates the addition of sample text, Y b represents the label information of the newly added sample text (i.e., sample label), θ AB represents the processing of the initial student model, θ AB (X b ) represents the newly added translation result, and CE() represents the cross entropy loss function.

[0216] Can be Calculate the difference between models, where X a represents the initial sample text, θ A represents the processing of the teacher model, θ AB represents the processing of the initial student model, θ A (X a ) represents the teacher's translation result, θ AB (X a ) represents the initial translation result, and CE() represents the cross entropy loss function.

[0217] 380. Combine the comparison loss value and the distillation loss value to determine the comprehensive loss value.

[0218] For example, you can The weighted sum is used to obtain the comprehensive loss value, where represents the distillation loss value, It represents the contrast loss value, β represents the dynamic learning weight, and the value range of β can be 0-1 or 0-5. β is usually set to 1.0.

[0219] 390. Based on the comprehensive loss value, the model parameters of the initial student model are updated to obtain a trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

[0220] For example, based on the comprehensive loss value, the error signal can be passed back to the initial student model through the back propagation algorithm to update the model parameters of the initial student model so that the initial student model can learn. This process is iterated continuously until the loss function converges to obtain the trained student model, which can be used to translate the text of the initial scene and the newly added scene (i.e., the text to be translated).

[0221] In order to verify the effect of the model training method provided in the embodiment of the present application, the model training method provided in the embodiment of the present application is applied to train multiple different translation models (i.e., initial student models) to make them suitable for multiple scenarios. The translation quality of the trained translation models in different scenarios is as follows: Figure 3bAs shown, the translation quality is represented by the BLEU indicator, which is an indicator used to evaluate the quality of machine translation. In mBART50-nn(), mBART refers to a multilingual translation pre-training model, 50-nn means that the model uses 50 different languages, and the content in brackets indicates different versions of the model. For example, ET in mBART50-nn(ET) refers to a model that is fine-tuned to obtain a translation task suitable for English to the target language. The student model of this application refers to the student model provided in this application. Figure 3b It can be seen that the multiple models trained by the model training method provided in the embodiments of the present application have good performance in multiple scenarios such as information technology, Korean, law, medicine, and subtitles, and can achieve high translation quality.

[0222] From the above, it can be seen that the embodiment of the present application can retain the performance of the model in the trained field (i.e., the initial field) as much as possible through knowledge distillation learning without using bilingual data (without using supervised training data in the initial field), using only a small amount of unlabeled monolingual data with the same distribution, so as to effectively prevent excessive forgetting, which can not only reduce the cost of training the model during training, but also save storage space when deploying the model.

[0223] In order to better implement the above method, the embodiment of the present application also provides a model training device, which can be integrated in an electronic device, and the electronic device can be a terminal, a server, etc. Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, a personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.

[0224] For example, in this embodiment, the method of the embodiment of the present application will be described in detail by taking the specific integration of the model training device in the server as an example.

[0225] For example, Figure 4 As shown, the model training device may include an acquisition unit 410, a teacher model unit 420, a student model unit 430, a loss unit 440, and an update unit 450, as follows:

[0226] (I) Acquisition Unit 410

[0227] Used to obtain a training sample set, the training sample set includes an initial sample text corresponding to the initial scene and a newly added sample text corresponding to the newly added scene.

[0228] (II) Teacher Model Unit 420

[0229] It is used to translate the initial sample text through the teacher model to obtain the teacher translation result. The teacher model is trained by the initial training sample text corresponding to the initial scene. The number of samples of the initial training sample text is greater than the number of samples of the initial sample text.

[0230] (III) Student Model Unit 430

[0231] It is used to translate the initial sample text and the newly added sample text through the initial student model to obtain the student translation result. The initial student model is obtained from the teacher model.

[0232] In some embodiments, the initial student model includes an encoding network, an attention network, and a decoding network. The student model unit 430 includes an encoding subunit, an attention subunit, and a decoding subunit. The student model unit 430 can be specifically used for:

[0233] The encoding subunit is used to encode the target text through the encoding network to obtain an encoding vector, and the target text is any sample text in the training sample set;

[0234] The attention subunit is used to perform attention processing on the encoding vector through the attention network to obtain the attention vector;

[0235] The decoding subunit is used to decode the attention vector through a decoding network to obtain the translation result of the target text, so as to obtain the student translation result.

[0236] In some embodiments, the encoding subunit may be specifically used for:

[0237] Through the encoding network, the words to be processed in the target text are mapped into word vectors;

[0238] Generate a position vector of the word to be processed according to the position of the word to be processed in the target text;

[0239] Combine the word vector and the position vector to generate the encoding vector.

[0240] In some embodiments, the attention network includes a first attention network and a second attention network, and the attention sub-unit can be specifically used for:

[0241] Through the first attention network, the vector before the to-be-processed vector in the encoding vector is subjected to attention processing to obtain an initial attention vector, where the to-be-processed vector is the vector of any to-be-processed word in the encoding vector corresponding to the target text;

[0242] Through the second attention network, the initial attention vector and the encoding vector are processed to obtain the attention vector.

[0243] In some implementations, the decoding subunit may be specifically configured to:

[0244] Through the decoding network, the attention vector is linearly predicted to obtain the prediction vector;

[0245] The prediction vector is transformed into a classification form to obtain the distribution probability and thus the student translation result is obtained.

[0246] (IV) Loss Unit 440

[0247] It is used to combine the teacher's translation results and the student's translation results to calculate the loss value.

[0248] In some embodiments, the loss value includes a comprehensive loss value, and the loss unit 440 includes a first loss subunit, a second loss subunit, and a third loss subunit. The loss unit 440 can be specifically used to:

[0249] A first loss subunit, used to determine, according to the teacher translation result and the student translation result, a first similarity between translation results corresponding to the same sample text, a second similarity between translation results corresponding to different sample texts, and a distillation loss value between the teacher model and the initial student model;

[0250] A second loss subunit, configured to calculate a comparison loss value according to the first similarity and the second similarity;

[0251] The third loss subunit is used to determine a comprehensive loss value by combining the comparison loss value and the distillation loss value.

[0252] In some embodiments, the first loss subunit may be specifically used for:

[0253] Obtaining negative sample translation results, where the negative sample translation results are translation results of the initial sample texts using a negative sample processing model, where the negative sample processing model is trained using newly added training sample texts corresponding to newly added scenarios;

[0254] Determine a first similarity between translation results corresponding to the same sample text according to the teacher's translation result and the initial translation result, wherein the initial translation result is a translation result corresponding to the initial sample text in the student's translation result;

[0255] According to the negative sample translation result and the initial translation result, a second similarity between translation results corresponding to different sample texts is determined.

[0256] In some embodiments, the second loss subunit may be specifically used for:

[0257] Determine a normalization factor by combining the first similarity and the second similarity;

[0258] The first similarity is normalized according to the normalization factor to obtain a comparison loss value.

[0259] In some embodiments, the loss value includes a distillation loss value, and the loss unit 440 includes a fourth loss subunit, a fifth loss subunit, and a sixth loss subunit. The loss unit 440 can be specifically used to:

[0260] The fourth loss subunit is used to calculate the difference between the label information of the newly added sample text and the newly added translation result to obtain a predicted difference value, where the newly added translation result is the translation result corresponding to the newly added sample text in the student translation result;

[0261] The fifth loss subunit is used to calculate the difference between the teacher's translation result and the student's translation result to obtain the difference value between the models;

[0262] The sixth loss subunit is used to calculate the distillation loss value according to the prediction difference value and the difference value between models.

[0263] In some embodiments, the fifth loss subunit may be specifically used for:

[0264] Obtaining an initial translation result, where the initial translation result is a translation result corresponding to an initial sample text in the student translation result;

[0265] The difference between the teacher's translation result and the initial translation result is calculated to obtain the inter-model difference value.

[0266] In some implementations, the initial scenario includes multiple scenarios, and the loss unit 440 includes a seventh loss subunit and an eighth loss subunit. The loss unit 440 can be specifically used to:

[0267] a seventh loss sub-unit, configured to calculate a sub-loss value corresponding to any of the multiple scenarios;

[0268] The eighth loss sub-unit is used to merge the sub-loss values ​​corresponding to multiple scenes to obtain a loss value.

[0269] (V) Update Unit 450

[0270] It is used to update the model parameters of the initial student model based on the loss value to obtain the trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

[0271] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.

[0272] As can be seen from the above, the model training device of this embodiment includes an acquisition unit, a teacher model unit, a student model unit, a loss unit and an update unit. Among them, the acquisition unit is used to acquire a training sample set, and the training sample set includes an initial sample text corresponding to the initial scene and a newly added sample text corresponding to the newly added scene; the teacher model unit is used to translate the initial sample text through the teacher model to obtain a teacher translation result, and the teacher model is trained by the initial training sample text corresponding to the initial scene, and the number of samples of the initial training sample text is greater than the number of samples of the initial sample text; the student model unit is used to translate the initial sample text and the newly added sample text through the initial student model to obtain a student translation result, and the initial student model is obtained by the teacher model; the loss unit is used to calculate the loss value by combining the teacher translation result and the student translation result; the update unit is used to update the model parameters of the initial student model based on the loss value to obtain the trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

[0273] Therefore, the embodiment of the present application can only obtain a small amount of sample data corresponding to the initial scene for training the student model, so as to reduce the acquisition cost of the sample data of the initial scene, and improve the construction efficiency of the training sample set and the training efficiency of the model. In this way, in the training of the student model, only the teacher model is used to process a small amount of initial sample text corresponding to the initial scene, and the student model is used to process a small amount of initial sample text corresponding to the initial scene and a large amount of newly added sample text corresponding to the newly added scene. Through the newly added sample text, the student model gradually learns and adapts to the representation of the newly added scene, improves the translation ability of the student model in the newly added scene, and uses a small amount of initial sample text to guide the student model to learn the representation of certain features of the teacher model, avoid forgetting the initial scene, so as to improve the expression ability of the student model in the initial scene and the newly added scene, so as to enhance the multi-scene adaptability of the model while improving the model training efficiency, so that the trained student model has good translation ability for multiple scenes.

[0274] The embodiment of the present application also provides an electronic device, which can be a terminal, a server, etc. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, a personal computer, etc. The server can be a single server or a server cluster composed of multiple servers, etc.

[0275] In some embodiments, the model training device can also be integrated into multiple electronic devices. For example, the model training device can be integrated into multiple servers, and the model training method of the present application can be implemented by multiple servers.

[0276] In this embodiment, the electronic device of this embodiment is a server as an example for detailed description, for example, Figure 5As shown, it shows a schematic diagram of the structure of the server involved in the embodiment of the present application, specifically:

[0277] The server may include one or more processing core processors 510, one or more computer-readable storage media memories 520, a power supply 530, an input module 540, and a communication module 550. Those skilled in the art will appreciate that Figure 5 The server structure shown in the figure does not constitute a limitation on the server, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0278] The processor 510 is the control center of the server, and uses various interfaces and lines to connect various parts of the entire server. It executes various functions of the server and processes data by running or executing software programs and / or modules stored in the memory 520, and calling data stored in the memory 520. In some embodiments, the processor 510 may include one or more processing cores; in some embodiments, the processor 510 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 510.

[0279] The memory 520 can be used to store software programs and modules. The processor 510 executes various functional applications and data processing by running the software programs and modules stored in the memory 520. The memory 520 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the server, etc. In addition, the memory 520 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 520 may also include a memory controller to provide the processor 510 with access to the memory 520.

[0280] The server also includes a power supply 530 for supplying power to various components. In some embodiments, the power supply 530 can be logically connected to the processor 510 through a power management system, so that the power management system can manage charging, discharging, power consumption, etc. The power supply 530 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0281] The server may further include an input module 540, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.

[0282] The server may further include a communication module 550. In some embodiments, the communication module 550 may include a wireless module. The server may perform short-range wireless transmission through the wireless module of the communication module 550, thereby providing users with wireless broadband Internet access. For example, the communication module 550 may be used to help users send and receive emails, browse web pages, and access streaming media.

[0283] Although not shown, the server may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 510 in the server will load the executable files corresponding to the processes of one or more application programs into the memory 520 according to the following instructions, and the processor 510 will run the application programs stored in the memory 520, thereby realizing various functions, as follows:

[0284] A training sample set is obtained, the training sample set includes an initial sample text corresponding to an initial scene and a newly added sample text corresponding to a newly added scene; the initial sample text is translated by a teacher model to obtain a teacher translation result, the teacher model is trained by an initial training sample text corresponding to the initial scene, and the number of samples of the initial training sample text is greater than the number of samples of the initial sample text; the initial sample text and the newly added sample text are translated by an initial student model to obtain a student translation result, the initial student model is obtained by the teacher model; a loss value is calculated by combining the teacher translation result and the student translation result; based on the loss value, the model parameters of the initial student model are updated to obtain a trained student model, so that the trained student model can be used to translate the texts to be translated corresponding to the initial scene and the newly added scene.

[0285] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0286] As can be seen from the above, the embodiment of the present application can only obtain a small amount of sample data corresponding to the initial scene for training the student model, so as to reduce the acquisition cost of the sample data of the initial scene, and improve the construction efficiency of the training sample set and the training efficiency of the model. In this way, in the training of the student model, only the teacher model is used to process a small amount of initial sample text corresponding to the initial scene, and the student model is used to process a small amount of initial sample text corresponding to the initial scene and a large amount of newly added sample text corresponding to the newly added scene. Through the newly added sample text, the student model gradually learns and adapts to the representation of the newly added scene, improves the translation ability of the student model in the newly added scene, and uses a small amount of initial sample text to guide the student model to learn the representation of certain features of the teacher model, avoid forgetting the initial scene, so as to improve the expression ability of the student model in the initial scene and the newly added scene, so as to enhance the multi-scene adaptability of the model while improving the model training efficiency, so that the trained student model has good translation ability for multiple scenes.

[0287] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0288] To this end, an embodiment of the present application provides a computer-readable storage medium, which stores multiple instructions, which can be loaded by a processor to execute the steps in any model training method provided in the embodiment of the present application. For example, the instruction can execute the following steps:

[0289] A training sample set is obtained, the training sample set includes an initial sample text corresponding to an initial scene and a newly added sample text corresponding to a newly added scene; the initial sample text is translated by a teacher model to obtain a teacher translation result, the teacher model is trained by an initial training sample text corresponding to the initial scene, and the number of samples of the initial training sample text is greater than the number of samples of the initial sample text; the initial sample text and the newly added sample text are translated by an initial student model to obtain a student translation result, the initial student model is obtained by the teacher model; a loss value is calculated by combining the teacher translation result and the student translation result; based on the loss value, the model parameters of the initial student model are updated to obtain a trained student model, so that the trained student model can be used to translate the texts to be translated corresponding to the initial scene and the newly added scene.

[0290] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0291] According to one aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program including a computer program / instruction, the computer program / instruction being stored in a computer-readable storage medium. A processor of an electronic device reads the computer program / instruction from the computer-readable storage medium, and the processor executes the computer program / instruction, so that the electronic device executes the method provided in various optional implementations provided in the above embodiments.

[0292] Since the instructions stored in the storage medium can execute the steps in any model training method provided in the embodiments of the present application, the beneficial effects that can be achieved by any model training method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0293] The above is a detailed introduction to a model training method, device, electronic device, medium and program product provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A model training method, characterized in that: include: Acquire a training sample set, wherein the training sample set includes an initial sample text corresponding to an initial scene and a newly added sample text corresponding to a newly added scene; The initial sample text is translated by a teacher model to obtain a teacher translation result, wherein the teacher model is trained by initial training sample texts corresponding to the initial scene, and the number of samples of the initial training sample texts is greater than the number of samples of the initial sample texts; The initial sample text and the newly added sample text are translated by an initial student model to obtain a student translation result, wherein the initial student model is obtained by the teacher model; Combining the teacher's translation result and the student's translation result, a loss value is calculated; Based on the loss value, the model parameters of the initial student model are updated to obtain a trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

2. The model training method according to claim 1, characterized in that: The loss value includes a comprehensive loss value, and the loss value is calculated by combining the teacher's translation result and the student's translation result, including: Determine, according to the teacher translation result and the student translation result, a first similarity between translation results corresponding to the same sample text, a second similarity between translation results corresponding to different sample texts, and a distillation loss value between the teacher model and the initial student model; Calculating a comparison loss value according to the first similarity and the second similarity; The comprehensive loss value is determined by combining the comparative loss value and the distillation loss value.

3. The model training method according to claim 2, characterized in that: The first similarity and the second similarity are determined by the following steps: Obtaining a negative sample translation result, where the negative sample translation result is a translation result of the initial sample text translated by a negative sample processing model, where the negative sample processing model is trained by the newly added training sample text corresponding to the newly added scenario; Determining a first similarity between the translation results corresponding to the same sample text according to the teacher translation result and the initial translation result, wherein the initial translation result is a translation result corresponding to the initial sample text in the student translation result; According to the negative sample translation result and the initial translation result, a second similarity between the translation results corresponding to different sample texts is determined.

4. The model training method according to claim 2, characterized in that: The calculating the contrast loss value according to the first similarity and the second similarity includes: Determine a normalization factor by combining the first similarity and the second similarity; The first similarity is normalized according to the normalization factor to obtain the contrast loss value.

5. The model training method according to claim 1, characterized in that: The loss value includes a distillation loss value, the newly added sample text carries label information, and the distillation loss value is obtained by the following steps: Calculating the difference between the label information of the newly added sample text and the newly added translation result to obtain a predicted difference value, wherein the newly added translation result is the translation result corresponding to the newly added sample text in the student translation result; Calculating the difference between the teacher's translation result and the student's translation result to obtain an inter-model difference value; The distillation loss value is calculated according to the predicted difference value and the inter-model difference value.

6. The model training method according to claim 5, characterized in that: The calculating the difference between the teacher translation result and the student translation result to obtain the inter-model difference value includes: Obtaining an initial translation result, wherein the initial translation result is a translation result corresponding to the initial sample text in the student translation result; The difference between the teacher translation result and the initial translation result is calculated to obtain an inter-model difference value.

7. The model training method according to claim 1, characterized in that: The initial scenario includes multiple scenarios, and the loss value is calculated by combining the teacher translation result and the student translation result, including: For any scenario among the multiple scenarios, calculating a sub-loss value corresponding to the any scenario; The sub-loss values ​​corresponding to the multiple scenes are merged to obtain the loss value.

8. The model training method according to any one of claims 1 to 7, characterized in that: The initial student model includes an encoding network, an attention network, and a decoding network. The initial student model is used to translate the initial sample text and the newly added sample text to obtain a student translation result, including: Through the encoding network, encoding the target text to obtain an encoding vector, wherein the target text is any sample text in the training sample set; Performing attention processing on the encoding vector through the attention network to obtain an attention vector; The attention vector is decoded through the decoding network to obtain the translation result of the target text, so as to obtain the student translation result.

9. The model training method according to claim 8, characterized in that: The encoding network is used to encode the target text to obtain an encoding vector, including: Mapping the to-be-processed words in the target text into word vectors through the encoding network; Generating a position vector of the word to be processed according to the position of the word to be processed in the target text; The encoding vector is generated by combining the word vector and the position vector.

10. The model training method according to claim 8, characterized in that: The attention network includes a first attention network and a second attention network, and the attention network is used to perform attention processing on the encoding vector to obtain an attention vector, including: By using the first attention network, attention processing is performed on the vector before the to-be-processed vector in the encoding vector to obtain an initial attention vector, wherein the to-be-processed vector is a vector of any to-be-processed word in the target text in the encoding vector; The initial attention vector and the encoding vector are subjected to attention processing through the second attention network to obtain an attention vector.

11. The model training method according to claim 8, characterized in that: The decoding network is used to decode the attention vector to obtain the translation result of the target text, so as to obtain the student translation result, including: Performing linear prediction on the attention vector through the decoding network to obtain a prediction vector; The prediction vector is subjected to classification transformation to obtain distribution probability, so as to obtain the student translation result.

12. A model training device, characterized in that: include: An acquisition unit, configured to acquire a training sample set, wherein the training sample set includes an initial sample text corresponding to an initial scene and a newly added sample text corresponding to a newly added scene; A teacher model unit, used for translating the initial sample text through a teacher model to obtain a teacher translation result, wherein the teacher model is trained by initial training sample text corresponding to the initial scene, and the number of samples of the initial training sample text is greater than the number of samples of the initial sample text; A student model unit, used for translating the initial sample text and the newly added sample text by using an initial student model to obtain a student translation result, wherein the initial student model is obtained by the teacher model; A loss unit, used for calculating a loss value by combining the teacher's translation result and the student's translation result; An updating unit is used to update the model parameters of the initial student model based on the loss value to obtain a trained student model, so that the trained student model can be used to translate the text to be translated corresponding to the initial scene and the newly added scene.

13. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the model training method as described in any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, which are suitable for loading by a processor to execute the steps in the model training method described in any one of claims 1 to 11.

15. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps in the model training method described in any one of claims 1 to 11 are implemented.

Citation Information

Cited By

  • Model training method and device, electronic equipment and storage medium

    CN116451127A

  • Model training method and apparatus, electronic device, and storage medium

    CN116451127B