Translation method and device, electronic equipment and computer readable storage medium

By considering the positional bias of word pairs and assigning training loss weights during translation model training, the shortcomings of translation models in learning different word difficulties are addressed, thereby improving translation performance, especially enhancing translation accuracy in simultaneous translation.

CN116663571BActive Publication Date: 2026-08-04TENCENT TECHNOLOGY (SHENZHEN) CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2022-02-16
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

The translation performance of existing translation models needs improvement, especially when faced with the positional bias of different words in the source and target languages, they have difficulty learning and adapting effectively, resulting in poor translation results.

Method used

By considering the positional bias of matching word pairs in the training samples during the training process and assigning corresponding training loss weights, the training loss is adaptively adjusted so that training samples of different difficulties can play an appropriate role in the model, thereby improving the performance of the translation model.

Benefits of technology

It improves the translation performance of the translation model, especially in simultaneous translation scenarios, enhancing the accuracy and adaptability of the translation and meeting the needs of practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116663571B_ABST
    Figure CN116663571B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a translation method and device, electronic equipment and computer readable storage medium, and relate to the fields of artificial intelligence, natural language processing, multimedia and cloud technology. The method comprises: obtaining a source language text to be translated, and translating the text to be translated by using a trained translation model to obtain a target text corresponding to the target language of the text to be translated; the translation model is obtained by the following method: obtaining a plurality of training samples comprising a first text in a source language and a second text corresponding to the target language of the first text; determining the training loss weight corresponding to each sample according to the position bias of each word pair matched in the first text and the second text of each sample in the two texts; and iteratively training an initial neural network model based on the plurality of samples and the training loss weights corresponding thereto to obtain the translation model. Based on the method, the translation effect can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of artificial intelligence, natural language processing, multimedia and cloud technology. Specifically, embodiments of this application relate to a translation method, apparatus, electronic device, computer-readable storage medium and computer program product. Background Technology

[0002] With the rapid development of artificial intelligence technology, more and more artificial intelligence skills are being applied to the field of text translation. Through translation models, text in one language can be translated into text in another language. Automated translation technology based on artificial intelligence has been widely used in more and more scenarios. For example, in people's daily lives, online translation software can be used to meet translation needs. Another example is the use of Simultaneous Machine Translation (SiMT) models for synchronous translation. The SiMT model can start reading from incomplete source text and gradually generate translations. It aims to translate continuously input text streams into another language with the lowest latency and the highest quality, thus meeting the needs of synchronous translation.

[0003] Currently, various translation models exist in related technologies. Training these models typically involves continuously training them with both source and target texts until certain conditions are met. While existing translation models can meet application requirements to some extent, their translation performance still needs improvement. Summary of the Invention

[0004] The purpose of this application is to provide a translation method, apparatus, electronic device, and computer-readable storage medium that can effectively improve translation results. To achieve this purpose, the technical solutions provided by this application are as follows:

[0005] On the one hand, embodiments of this application provide a translation method, which includes:

[0006] Obtain the text to be translated in the source language;

[0007] The text to be translated is translated by calling a pre-trained translation model, resulting in the target text in the target language. The translation model is trained in the following way:

[0008] Obtain multiple training samples, each training sample including a first text in the source language and a second text in the target language corresponding to the first text;

[0009] For each training sample, the training loss weights corresponding to the training sample are determined based on the positional bias of each matching word pair in the first and second texts of the training sample in the two texts.

[0010] Based on multiple training samples and the corresponding training loss weights for each training sample, the initial neural network model is iteratively trained to obtain the translation model; wherein, during the training process, the training loss corresponding to a training sample is determined based on the training loss weight corresponding to that training sample.

[0011] On the other hand, embodiments of this application provide a translation apparatus, which includes:

[0012] The text acquisition module is used to acquire the text to be translated in the source language;

[0013] The text translation module is used to translate the text to be translated by calling a trained translation model, thereby obtaining the target text in the target language. The translation model is trained by a model training device in the following way:

[0014] Obtain multiple training samples, each training sample including a first text in the source language and a second text in the target language corresponding to the first text;

[0015] For each training sample, the training loss weights corresponding to the training sample are determined based on the positional bias of each matching word pair in the first and second texts of the training sample in the two texts.

[0016] Based on multiple training samples and the corresponding training loss weights for each training sample, the initial neural network model is iteratively trained to obtain the translation model; wherein, during the training process, the training loss corresponding to a training sample is determined based on the training loss weight corresponding to that training sample.

[0017] Optionally, the model training device can be used to iteratively train the initial neural network model for:

[0018] The first text of each training sample is input into the neural network model to obtain the translation result of the first text of each training sample corresponding to the target language;

[0019] For each training sample, the training loss corresponding to the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weight corresponding to the training sample.

[0020] Based on the training loss corresponding to each training sample, the total training loss corresponding to the neural network model is obtained.

[0021] The model parameters of the neural network model are adjusted based on the total training loss, and the adjusted neural network model is further trained based on multiple training samples and the training loss weights corresponding to each training sample.

[0022] Optionally, a matching word pair in a training sample includes the source word in the first text of the training sample and the target word in the second text of the training sample that matches the source word; for each training sample, the model training device, when determining the training loss weights corresponding to the training sample based on the positional bias of each matching word pair in the first and second texts of the training sample, can be used for:

[0023] For each matching word pair in the training sample, the alignment bias corresponding to the word pair is determined based on the positional bias between the source word and the target word in the word pair (i.e., the bias between the position of the source word in the first text of the training sample and the position of the target word in the second text of the training sample).

[0024] For each target word in the training sample, the alignment bias corresponding to the target word is determined based on the alignment bias of each matching word pair in the training sample that includes the target word.

[0025] Based on the alignment bias of each target word in the training sample, the training loss weights corresponding to the training sample are determined.

[0026] Optionally, for each matching word pair in the training samples, when determining the alignment bias corresponding to the word pair based on the positional bias between the source and target words in the word pair, the model training device can use the following methods:

[0027] If the positional offset between the source word and the target word in the word pair is greater than or equal to a first set value, the alignment offset of the word pair is determined based on the difference between the positional offset and the first set value, wherein the alignment offset of the word pair is positively correlated with the corresponding positional offset.

[0028] If the positional offset between the source word and the target word in the word pair is less than a first preset value, the alignment offset of the word pair is determined to be the first preset value.

[0029] Optionally, for each target word in each training sample, when the model training device determines the alignment bias corresponding to the target word based on the alignment bias corresponding to each matching word pair including the target word in the training sample, it can be used to: determine the mean of the alignment bias corresponding to each matching word pair including the target word in the training sample as the alignment bias corresponding to the target word.

[0030] Optionally, when determining the training loss weights corresponding to the training samples based on the alignment biases corresponding to each target word in the training samples, the model training device can be used for:

[0031] For each target word in the training sample, the training loss weight corresponding to the target word is determined based on the alignment bias corresponding to the target word; the training loss weight corresponding to the training sample is obtained based on the training loss weight corresponding to each target word in the training sample.

[0032] Optionally, for each target word in the training samples, when determining the training loss weights corresponding to that target word based on the alignment bias, the model training device can use the following methods:

[0033] If the alignment bias corresponding to the target word is greater than or equal to the second preset value, the training loss weight corresponding to the target word is determined to be the second preset value.

[0034] If the alignment bias corresponding to the target word is less than the second set value, the training loss weight corresponding to the target word is determined according to the alignment bias corresponding to the target word. The training loss weight corresponding to a target word is negatively correlated with the alignment bias corresponding to the target word.

[0035] Optionally, the first text of a training sample corresponds to the translation result of the target language, including the translation result of each source word in the first text corresponding to the target language; when the model training device obtains the training loss weight corresponding to the training sample based on the training loss weight corresponding to each target word in the training sample, it can be used to: use the training loss weight corresponding to each target word in the training sample as the training loss weight corresponding to the training sample.

[0036] Accordingly, when determining the training loss for a training sample based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weights corresponding to the training sample, the model training device can be used for:

[0037] For each target word in the second text of the training sample, the translation loss corresponding to the target word is determined based on the difference between the translation results of the target word and the matching source word. The translation loss corresponding to the target word is weighted using the training loss weights of each target word in the second text of the training sample to obtain the training loss corresponding to each target word. The training loss corresponding to the training sample is obtained based on the training loss corresponding to each target word in the second text of the training sample.

[0038] Optionally, for each training sample, when the model training device obtains the training loss weight corresponding to the training sample based on the training loss weight corresponding to each target word in the training sample, it can be used to: fuse the training loss weights corresponding to each target word in the training sample to obtain the training loss weight corresponding to the training sample.

[0039] Accordingly, the model training device can be used to determine the training loss for a training sample based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weights corresponding to the training sample:

[0040] Based on the difference between the second text of the training sample and the corresponding translation result, the translation loss corresponding to the training sample is determined; the translation loss corresponding to the training sample is weighted using the training loss weight corresponding to the training sample to obtain the training loss corresponding to the training sample.

[0041] Optionally, for each training sample, the model training device determines the training loss weights corresponding to that training sample based on the alignment biases of each target word in the training sample. This weight can be used for:

[0042] Based on the alignment bias of each target word in the training sample, determine the alignment bias of the training sample; based on the alignment bias of the training sample, determine the training loss weight of the training sample.

[0043] Accordingly, when determining the training loss for a training sample based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weights corresponding to the training sample, the model training device can be used for:

[0044] Based on the difference between the second text of the training sample and the corresponding translation result, the translation loss corresponding to the training sample is determined; the translation loss corresponding to the training sample is weighted using the training loss weight corresponding to the training sample to obtain the training loss corresponding to the training sample.

[0045] On the other hand, embodiments of this application also provide an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method provided in any optional embodiment of this application.

[0046] On the other hand, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method provided in any optional embodiment of this application.

[0047] On the other hand, embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the methods provided in any optional embodiment of this application.

[0048] The beneficial effects of the technical solution provided in this application are as follows:

[0049] The translation method provided in this application, during the process of training a neural network model based on training samples to obtain a translation model, considers the alignment information (i.e., the positional bias of the matching word pairs in the two texts) between the training samples when determining the training loss corresponding to the training samples. Since the learning difficulty of a sample varies depending on the degree of alignment between words in the first text of the source language and the corresponding second text of the target language, the alignment degree between word pairs in the training samples affects the model's performance. By considering the alignment information between word pairs and assigning corresponding training loss weights to the training samples based on this information, the training loss corresponding to the sample can be calculated based on the training loss weights during training. This allows different training samples to play different roles, enabling the model to adaptively learn samples or words of varying difficulty according to the difficulty level of the samples (the training loss weights represent the difficulty level of the samples). This reduces the performance degradation caused by word order misalignment between the source and target words in the training samples, improves the performance of the trained translation model, and thus enhances the translation effect, better meeting the needs of practical applications. Attached Figure Description

[0050] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.

[0051] Figure 1 A flowchart illustrating a translation method provided in an embodiment of this application;

[0052] Figure 2 A flowchart illustrating a training method for a neural network model provided in an embodiment of this application;

[0053] Figure 3 This is a schematic diagram of the architecture of a translation system applicable to the embodiments of this application;

[0054] Figure 4 A flowchart illustrating a translation method provided in an embodiment of this application;

[0055] Figure 5 , Figure 6 and Figure 7 A schematic diagram of a user interface provided in one example for this application;

[0056] Figure 8 and Figure 9 A schematic diagram of the user interface in another example provided for this application;

[0057] Figure 10 This is a schematic diagram of another translation system applicable to the embodiments of this application;

[0058] Figure 11 This is a schematic diagram of the structure of a translation device provided in an embodiment of this application;

[0059] Figure 12 This is a schematic diagram of the structure of an electronic device to which this application applies. Detailed Implementation

[0060] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.

[0061] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.” When describing multiple (two or more) items, if the relationship between the multiple items is not explicitly defined, the multiple items can refer to one, several or all of the multiple items. For example, the description of "parameter A includes A1, A2, A3" can be implemented as parameter A includes A1 or A2 or A3, or it can be implemented as parameter A includes at least two of the three items A1, A2 and A3.

[0062] This application provides a translation method to address the issue of insufficient translation performance in existing translation models. Based on the method provided in this application, the translation performance of the translation model can be effectively improved, thereby enhancing the translation effect of the text.

[0063] Optionally, the solutions provided in this application embodiment can be implemented based on artificial intelligence (AI) technology. For example, the translation model is a neural network model based on artificial intelligence. The translation model in this application embodiment can be a model based on any existing translation model or a translation model improved from an existing translation model. In other words, the training method of the translation model provided in this application embodiment can be applied to the training of any translation model and can improve the performance of the trained model. The model can be trained based on a training dataset (i.e., multiple training samples) using machine learning (ML) methods.

[0064] Artificial intelligence (AI) studies the design principles and implementation methods of various intelligent machines, enabling them to perceive, reason, and make decisions. With the research and advancement of AI technology, it has already been researched and applied in many fields, including smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, autonomous driving, drones, robots, smart healthcare, smart customer service, connected vehicles, and intelligent transportation. It is believed that with further technological development, this technology will be applied in even more fields and play an increasingly important role.

[0065] The methods provided in this application specifically relate to Natural Language Processing (NLP) technology in artificial intelligence. NLP is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that enable effective communication between humans and computers using natural language. Natural Language Processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language, that is, the language people use in daily life, and thus it is closely related to linguistic research. Natural Language Processing technologies typically include text processing, semantic understanding, machine translation, robot question answering, knowledge graphs, and other technologies.

[0066] Optionally, the data processing involved in the methods provided in this application embodiment can be implemented based on cloud technology. For example, data computation involved in the application and training of the translation model (such as feature extraction of input text by the translation model, calculation of training loss of the model, etc.) can be implemented using cloud computing technology. Cloud computing is a computing model that distributes computing tasks across a resource pool composed of a large number of computers, enabling various application systems to obtain computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." Resources in the "cloud" appear infinitely scalable to users, and can be accessed at any time, used on demand, expanded at any time, and paid for based on usage.

[0067] The translation method provided in this application can be executed by any electronic device, such as a user terminal or a server, or it can be completed through interaction between the user terminal and the server. For example, the text to be translated can be text input by a user through their user terminal. The user terminal can send the text to the server, and the server can deploy a pre-trained translation model. The server executes the method provided in this application, calls the model to translate the text to be translated, and sends the translation result, i.e., the target text (also called the translated text), to the user terminal, which then displays the translation result to the user.

[0068] The aforementioned server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The aforementioned user terminal (also referred to as user equipment) can be a smartphone, tablet computer, laptop computer, desktop computer, intelligent voice interaction device (e.g., smart speaker), wearable electronic device (e.g., smartwatch), in-vehicle terminal, smart home appliance (e.g., smart TV), AR / VR device, etc., but is not limited thereto. The terminal and server can be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions.

[0069] Optionally, the method provided in this application embodiment can be implemented as a standalone application or a functional module / plugin of an application. For example, the application can be dedicated translation software or other applications with translation functions, through which text translation can be achieved.

[0070] The translation method provided in this application embodiment can be applied to any application scenario that requires translation. For example, the translation model in this application embodiment can be a synchronous translation model. This translation method can be applied to synchronous translation scenarios, such as simultaneous interpretation scenarios. Assuming the source language is Chinese and the target language is English, in a simultaneous interpretation scenario, Chinese speech segments can be collected in real time through a speech acquisition device. The speech recognition model can identify the Chinese text corresponding to the real-time collected speech segments. Based on the method provided in this application embodiment, the synchronous translation model can be used to translate the identified Chinese text into English text, and the translated English text can be converted into English speech and played to the corresponding user through a speech playback device.

[0071] Of course, the method provided in this application embodiment is also applicable to scenarios where the complete text to be translated is obtained before translation. For example, a user can input the text to be translated in the client of the application and trigger translation by clicking the "translation control". The application server can translate the entire text input by the user after receiving the user's trigger operation. Alternatively, the text to be translated can also be obtained by recognizing the acquired speech. For example, a user can input the content to be translated by voice. The server can first recognize the corresponding text content of the user's voice input and then translate it to obtain the target text, and then display the target text to the user in text or voice format.

[0072] The technical solutions of this application and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.

[0073] Figure 1 This document illustrates a flowchart of a translation method provided in an embodiment of this application. Figure 1 As shown, the translation method may include the following steps:

[0074] Step S110: Obtain the source language text to be translated;

[0075] Step S120: Translate the text to be translated by calling the trained translation model to obtain the target text of the target language corresponding to the text to be translated.

[0076] The method of obtaining the text to be translated is not limited in this embodiment. It can be a relatively complete text to be translated, or a text fragment obtained in real time, meaning the text to be translated can be translated while it is being acquired. For example, the text to be translated can be a continuously acquired text fragment in a synchronous translation scenario, where translation and text acquisition can be a relatively synchronous process. The text to be translated can be directly acquired text content, or it can be obtained by converting or recognizing non-textual modal data (such as speech, images, or videos). For example, in a practical application scenario (which may include, but is not limited to, simultaneous interpretation scenarios, video-speech translation scenarios, etc.), the source data to be translated can be the speaker's speech data. The corresponding text can be obtained by recognizing the speaker's speech data, and this text is the text to be translated in that scenario.

[0077] The source language and the target language are two different languages. This application does not limit which two languages ​​are specifically source and target languages. They can be selected and configured according to actual application needs. For example, the source language can be Chinese and the target language can be English. Or, the source language can be Korean and the target language can be Chinese.

[0078] For the obtained complete text to be translated or the text fragments obtained in real time, a trained translation model can be used to translate and obtain the corresponding translated text, i.e., the target text. This application does not limit the specific neural network structure of the translation model; it can be selected according to actual application needs and can be any structured translation model, such as, but not limited to, the synchronous translation model, i.e., the SiMT model. Optionally, the translation model can be a deep neural network model, such as a Transformer-based neural network model. Specifically, it can include, but not limited to, the Wait-k model using the wait-k strategy or an improved model of this model, such as the Multipath Wait-k model. The Wait-k model first waits for k source words (i.e., source end words), uses these source words as input, and then translates while inputting the remaining part of the source sentence (text to be translated). That is, using this translation model, translation can begin after inputting k words of the text to be translated, achieving relatively synchronous translation and well meeting the requirements of real-time translation.

[0079] To meet practical application needs, the translation model is trained based on training samples. The translation model described in this application embodiment can be obtained through... Figure 2 The training method shown can include steps S131 to S133, as detailed below:

[0080] Step S131: Obtain multiple training samples, each training sample including a first text in the source language and a second text in the target language corresponding to the first text;

[0081] Step S132: For each training sample, determine the training loss weights corresponding to the training sample based on the positional bias of each matching word pair in the first and second texts of the training sample in the two texts.

[0082] Step S133: Based on multiple training samples and the training loss weights corresponding to each training sample, iteratively train the initial neural network model to obtain the above translation model; wherein, during the training process, the training loss corresponding to a training sample is determined based on the training loss weights corresponding to the training sample.

[0083] In this embodiment, the training dataset used to train the initial neural network model consists of multiple text pairs. Each text pair includes a first text and its translated text (i.e., a second text, which is the actual translation result, and serves as the standard translation result of the first text). During model training, the input to the model is the first text, and the output is the translation result obtained by the model, i.e., the predicted translation result. For each text pair, the model's translation loss (i.e., the training loss, which is the difference between the standard translation result and the predicted translation result) can be calculated based on the standard translation result and the predicted translation result. Based on the translation loss of each text pair, the model's total training loss (the value of the loss function) can be obtained. The model parameters can be adjusted based on the total training loss, and training can continue based on the training data, so that the model's predicted translation result becomes closer and closer to the corresponding actual translation result. By repeatedly performing the above training process, a translation model that meets the preset conditions can be obtained.

[0084] The training method provided in this application embodiment, when calculating the training loss for each training sample, considers not only the difference between the result obtained by the model translation and the actual translation result (i.e., the second text), but also the positional bias of the matching word pairs in the two texts of the training sample (i.e., the bias between the position of the source word in the first text and the position of the target word in the second stable text). Based on this alignment information, a corresponding training loss weight is assigned to the training sample. Thus, during the training process, the training loss corresponding to a training sample is related not only to the difference between the actual translation result and the predicted translation result corresponding to the sample, but also to the training loss weight corresponding to the sample. The training loss weight corresponding to the training sample can be used to weight the difference between the actual translation result and the predicted translation result to obtain the training loss corresponding to the sample.

[0085] Among them, the matching word pairs in each training sample refer to the source-side words in the first text of the training sample and the target-side words in the second text of the sample that match the source-side words. For example, the first text in a training sample is the Chinese text: "你叫什么名字", and the second text in the sample is the English text "what is your name". This training sample includes 4 matching word pairs, namely the word pair "你" and "your", the word pair "叫" and "is", the word pair "什么" and "what", and the word pair "名字" and "name". Among them, the Chinese words are the source-side words in this example, and the English words are the target-side words.

[0086] Based on the training method provided in the embodiments of this application, the model performance of the trained translation model can be effectively improved. This is because in real life, there is a phenomenon of word imbalance in natural languages. Different words usually appear with different frequencies in natural languages, resulting in different learning difficulties for different words in the process of training a neural network model. For the translation task, in the process of text translation, there are problems of misalignment in the word order of the source text (the first text) and the translation text (the second text). For example, if the source language is Chinese and the target language is English, for the Chinese text "你叫什么名字" and the corresponding English text "what is your name", the source-side word "你" is the first word in the Chinese text, while the target-side word "your" that matches this word is the third word in the English text. The word pair "你" and "your" is misaligned in these two texts, that is, there is a position bias (also called position deviation). The misalignment problem will affect the model performance to a certain extent in the process of model training. The more serious the misalignment problem, that is, the greater the position bias of the word, the more difficult it is for the model to learn the word. That is to say, the learning difficulties of different words in the training sample are also different for the model. The greater the position bias corresponding to the matching word pair, the more difficult the learning of the word. Correspondingly, the learning difficulties of different training samples are also different.

[0087] Just considering the above problems, the training method provided in the embodiments of this application further considers the learning difficulty of the training sample when training the model. It will assign corresponding training loss weights to the training sample according to the position bias of the matching word pair in the first text and the second text of the training sample. This weight can more appropriately measure the learning difficulty of the training sample or the words in the training sample. Thus, in the process of model training, based on the training loss weights corresponding to each training sample, the training losses corresponding to each training sample can be adaptively adjusted, so that the training of different training samples corresponding to the model can play different roles.

[0088] Optionally, for each training sample, the training loss weight corresponding to the sample is negatively correlated with its learning difficulty. That is, the greater the learning difficulty of the sample, the smaller the training loss weight corresponding to the sample. During the model training process, the weight of more difficult samples can be adaptively reduced, while the weight of relatively simple samples can be increased. This allows the model to adaptively learn samples or words of different difficulties according to the difficulty of the samples, reducing the performance degradation caused by the misalignment of word order between the source and target words in the training samples.

[0089] The training method provided in this application, based on the characteristics of machine translation tasks, innovatively proposes an evaluation method for the learning difficulty of training samples (or words in the samples) that is more suitable for and adapted to the essence of translation tasks. By assigning different training loss weights to samples with different learning difficulties and performing adaptive training based on these weights, the performance of the trained translation model is effectively improved, the translation effect obtained by the translation model is enhanced, and the needs of practical applications are better met. For example, the translation model can be a simultaneous translation model. Applying this model to simultaneous interpretation scenarios can effectively improve the accuracy of the translated target text.

[0090] When iteratively training the model, the preset conditions for ending model training can be configured according to actual needs, and this application embodiment does not limit them. For example, the preset conditions may include training termination conditions, such as the total training loss meeting certain conditions (e.g., less than a set value or the loss function converging), or the number of training iterations reaching a set number. Optionally, the preset conditions may also include at least one of validation conditions or testing conditions. Correspondingly, validation datasets or testing datasets can be pre-configured. During the model training process, the ability of the current model (the model after one or more training iterations) can be initially evaluated based on the validation dataset to verify the generalization ability (e.g., accuracy). Whether to continue training can be determined by judging whether the current model's ability meets the validation conditions. The testing dataset can be used to evaluate the final ability of the model after the model training stops (e.g., meeting at least one of the training termination conditions or validation conditions). If the testing conditions are met, such as accuracy or recall meeting the testing conditions, the model can be used as the final translation model. If the testing conditions are not met, the model training, validation, and testing process can be repeated until a translation model that meets the preset conditions is obtained.

[0091] Optionally, in practical applications, if there are multiple different language translation needs, training datasets corresponding to each pair of languages ​​can be obtained separately. For example, if there is a need to translate English into Chinese and another need to translate Chinese into German, training datasets can be obtained separately, including multiple text pairs with English as the source language and Chinese as the target language, and multiple text pairs with Chinese as the source language and German as the target language. Based on each training dataset, the initial neural network model can be trained separately using the training method provided in the embodiments of this application, to obtain the trained translation model corresponding to each language pair (one source language and one target language), that is, the model parameters of the neural network model corresponding to each language pair. When the text to be translated needs to be translated during the application stage, the user can specify the target language, or if the user does not specify, the default target language can be used. According to the source language and target language of the text to be translated, the translation model corresponding to that language is called to translate the text to be translated, and the translation result is obtained.

[0092] It should be noted that, in practical applications, the granularity of "words" is not limited in this embodiment. In this embodiment, a word can be understood as a basic linguistic unit that constitutes text. A word can be one or more characters, one or more characters, or one or more words. For example, in Chinese, a word can be one or more characters, while in English, a word can be one or more English words.

[0093] In an optional embodiment of this application, the iterative training of the initial neural network model based on multiple training samples and the training loss weights corresponding to each training sample may include:

[0094] The first text of each training sample is input into the neural network model to obtain the translation result of the first text of each training sample corresponding to the target language;

[0095] For each training sample, the training loss corresponding to the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weight corresponding to the training sample.

[0096] Based on the training loss corresponding to each training sample, the total training loss corresponding to the neural network model is obtained.

[0097] The model parameters of the neural network model are adjusted based on the total training loss, and the adjusted neural network model is further trained based on multiple training samples and the training loss weights corresponding to each training sample.

[0098] Understandably, in practice, after each training iteration, it can be determined whether the model meets the preset conditions. These preset conditions might be that the number of training iterations reaches a set number or the total training loss of the model meets certain conditions. If the model meets the preset conditions, it can be used as a well-trained translation model. If it does not meet the preset conditions, the model parameters can be adjusted, such as updating the model parameters based on the gradient descent algorithm, and then training again based on each training sample and the corresponding training loss weight. This process is repeated until the preset conditions are met, resulting in a well-trained translation model.

[0099] During training, the training loss weights for each training sample are used to weight the translation loss for that sample (the difference between the translation of the second text, i.e., the actual translation result, and the translation result of the first text output by the model), thus obtaining the training loss for that sample. After calculating the training loss for each training sample, the sum or average of the training losses for each sample can be used as the total training loss of the model.

[0100] In an optional embodiment of this application, for each training sample, the training loss weights corresponding to the training sample are determined based on the positional bias of each matching word pair in the first and second texts of the training sample in the two texts, including:

[0101] For each matching word pair in the training sample, the alignment bias corresponding to the word pair is determined based on the positional bias between the source word and the target word in the word pair.

[0102] For each target word in the training sample, the alignment bias corresponding to the target word is determined based on the alignment bias of each matching word pair in the training sample that includes the target word.

[0103] Based on the alignment bias of each target word in the training sample, the training loss weights corresponding to the training sample are determined.

[0104] As described in the foregoing, in the embodiments of the present application, a matching word pair refers to a source word in the first text of a training sample and a target word in the second text of the sample that matches the source word. A training sample will include at least one matching word pair. The matching relationship between the source word and the target word in the first text may be one-to-one or many-to-one. That is, a target word may have one source word that matches it, or may have more than one source word that matches it. For example, in the text pair of "你叫什么名字" and "what is your name" in the foregoing example, the matching source word and target word are both one-to-one. In the text pair of "他们可能对此采取反击" and "They may retaliate against this", the two source words of "采取" and "反击" are aligned with the target word "retaliate", that is, one target word matches two source words, and "retaliate" corresponds to two matching word pairs. One is "采取" and "retaliate", and the other is "反击" and "retaliate".

[0105] In the text translation task, since the purpose of translation is to obtain the translation text corresponding to the source language text to be translated, the purpose of training the model is to enable the model to learn the ability to predict the corresponding target word according to the input source word. For the model, the learning difficulty of the target word in the training sample can better represent the learning difficulty of the sample. Therefore, the training loss weight corresponding to the sample can be determined by calculating the alignment bias corresponding to each target word in the training sample.

[0106] Among them, the position bias and alignment bias between the matching source word and target word in each word pair of a training sample are both used to represent the deviation between the position of the source word in the first text of the sample and the position of the target word in the second text of the sample. Optionally, the alignment bias corresponding to a word pair may be the position bias corresponding to the word pair, or may be calculated based on the position bias corresponding to the word pair according to a pre-configured strategy. Optionally, the calculation strategy of the alignment bias can be configured according to the type of the selected neural network model. For example, the initial neural network model may be a wait-k model. When the model translates the first source word, it needs to read in k (k≥1) source words first. The alignment bias corresponding to the word pair can be determined according to the value of k and the position bias corresponding to the word pair.

[0107] Optionally, the alignment bias corresponding to a word pair is positively correlated with the position bias corresponding to the word pair. The greater the position bias, the greater the alignment bias.

[0108] For each target word in the training sample, if a target word has only one matching source word, the alignment bias between the word pairs can be determined based on the positional bias between the source and target words. This alignment bias can be used as the alignment bias of the target word in the word pair. If a target word has multiple matching source words, the alignment bias of the target word can be obtained based on the alignment biases of the multiple word pairs corresponding to the target word. For example, if a target word corresponds to two word pairs (i.e., two source words match the target word), the sum or average of the alignment biases of these two word pairs can be used as the alignment bias of the target word. As an optional approach, for each target word in a training sample, the average of the alignment biases of all matching word pairs including the target word in the training sample can be used as the alignment bias of the target word.

[0109] As an optional approach, for each matching word pair in the training samples, determining the alignment bias corresponding to the word pair based on the positional bias between the source word and the target word in the word pair can include:

[0110] If the positional offset between the source word and the target word in the word pair is greater than or equal to a first set value, the alignment offset corresponding to the word pair is determined based on the difference between the positional offset and the first set value, wherein the alignment offset corresponding to the word pair is positively correlated with the positional offset.

[0111] If the positional offset between the source word and the target word in the word pair is less than a first preset value, the alignment offset of the word pair is determined to be the first preset value.

[0112] The specific values ​​of the first set value and the first preset value can be configured according to the actual application scenario or requirements. Both the first set value and the first preset value are non-negative values. Optionally, the first set value can be 0 or a relatively small integer. The first set value can be zero or set according to the translation algorithm of the neural network model used. For example, the neural network model can be a translation model based on the wait-k strategy, and the first set value can be k-1.

[0113] In this embodiment, the positional bias between the matching source word and target word can be the absolute value of the deviation between the first position (word order, i.e., the nth word) of the source word in the first text and the second position of the target word in the second text, or it can be the difference between the first position and the second position. For example, if the source word is the i-th word in the first text and the matching target word is the j-th word in the second text, the positional bias between these two words can be ij or the absolute value of ij. As an optional solution in actual implementation, the positional bias can be the difference between the first position and the second position, i.e., ij. This is because in translation tasks, if the matching source word in the first text precedes the target word in the second text, during the translation process, when the model predicts the translation result corresponding to the source word, the source word has already been input into the model. It can be understood that when the model predicts the current output word, it has already seen the source word corresponding to the output word. For the model, predicting the target word corresponding to the source word is relatively easy. Therefore, we can use the above ij as the position bias and determine the alignment bias corresponding to the word pair based on the position bias to improve the learning difficulty of the target word.

[0114] Optionally, if the positional bias of a word pair is greater than or equal to a first set value, that is, the word order of the source word in the first text is later than the word order of the target word in the second text, the model may not have seen the corresponding source word when translating the prediction result of the target word (the model reads the source word while translating). The learning difficulty of the target word is relatively large for the model, and the larger the positional bias, the greater the learning difficulty. Therefore, the alignment bias between the source word and the target word can be determined according to the difference between the positional bias and the first set value. The larger the positional deviation, the later the position of the source word is relative to the position of the target word, and the larger the alignment bias is.

[0115] If the positional offset between the source word and the target word in a word pair is less than the first preset value, it means that the position of the source word in the first text is close to the position of the target word in the second text, or the position of the source word is before the position of the target word. The learning difficulty of the target word is relatively low, and the alignment offset corresponding to the word can be set to the first preset value, for example, set to 0.

[0116] In an optional embodiment of this application, assuming the first preset value is k-1, k≥1, and the first preset value is 0, the alignment offset corresponding to a matching word pair can be calculated using the following expression (1):

[0117]

[0118] Where, x i This represents the i-th word in the first text of the training sample, i.e., the i-th source word, where i represents the position of the word, and y represents the position of the word. j Let x represent the j-th target word in the second text of the training sample, where j represents the position of the target word in the second text. i and y j It is a matching pair of words, also known as an alignment pair (x i ,y j )), The expression represents the alignment offset of the word pair, and ij represents the position offset of the corresponding word pair. As can be seen from the above expression, if ij≥k-1, the alignment offset is ij-(k-1), and if ij<k-1, the alignment offset is 0.

[0119] Here, k can represent the number of source words that the neural network model needs to input into the model before translating the first word when translating the source language text. That is, the model starts synchronous translation when k source words are input.

[0120] Corresponding to the alignment offset calculation method in the above expression (1), as an optional implementation, the target word y j Corresponding alignment offset It can be calculated using the following expression (2):

[0121]

[0122] Among them, C j Indicates the target word y j The set of all source words (that is, all source words that match the target word) in the first text above, where c represents the c-th source word in the set. This represents the c-th source word and the target word y. j The corresponding alignment offset, this expression (2) is calculated by the set C j All source words and the target word y j The mean of the alignment biases between the target words is used to obtain the alignment biases corresponding to the target words, which is a mathematical representation of the learning difficulty of the target words.

[0123] To provide a more intuitive and visual understanding of the above-described method for calculating the alignment offset between word pairs and the corresponding alignment offset of the target word, an example is provided below.

[0124] Assuming the source language is Chinese and the target language is English, the first and second texts in a training sample are shown below: (Representation)

[0125] First text: A1 A2 A3 A4 A5 A6 A7 A8 A9 A 10 A 11

[0126] Second text: B1 B2 B3 B4 B5 B6 B7 B8 99 B 10

[0127] Among them, A i B represents the i-th Chinese word in the first text. j Let A7 represent the j-th English word in the second text. Assume A7 matches B5, and in the first text, B5 only has one matching source word, A7. The positional bias of this word pair is ij = 7 - 5 = 2. Assume k = 1 in the above expression (1), ij - (k - 1) = 2, then the alignment bias of the word pair A7 and B5 is max(0, 2) = 2, and the alignment bias of the target word B5 is also 2. Assume A9 matches B4, A 10 Also matches B4 A 10 According to the above expression (1), the positional offset between A9 and B4 can be calculated to be 5, and the alignment offset is also 5. 10 The position offset corresponding to B4 is 6, and the alignment offset is also 6. Therefore, according to the above expression (2), the average of the alignment offsets of 5 and 6 corresponding to B4 can be calculated, which is 5.5.

[0128] For each training sample, after calculating the alignment bias of each target word in the second text of that training sample, the training loss weights corresponding to that training sample can be determined based on the alignment bias of each target word. This application provides several optional schemes for determining the training loss weights corresponding to training samples, which are described below.

[0129] In one alternative approach, determining the training loss weights corresponding to the training samples based on the alignment biases of each target word in the training samples may include:

[0130] For each target word in the training sample, the training loss weight corresponding to the target word is determined based on the alignment bias corresponding to the target word.

[0131] The training loss weights corresponding to each target word in the training samples are obtained.

[0132] In this alternative approach, training loss weights can be configured for each target word based on its alignment bias in the training sample. Then, the training loss weight for the entire sample can be obtained based on the training loss weight corresponding to that target word. Optionally, the training loss weight for a target word can be negatively correlated with its alignment bias; that is, the larger the alignment bias, the smaller the corresponding training loss weight.

[0133] For each training sample, after obtaining the training loss weights corresponding to each target word in the training sample, these weights can be used as the training loss weight for that training sample. In other words, the training loss weight for a training sample includes the training loss weights corresponding to each target word in the training sample. Alternatively, the training loss weights corresponding to each target word can be fused (e.g., summed or averaged) to obtain the training loss weight for that training sample. During model training, the translation loss for that training sample can be weighted using these training loss weights to obtain the final training loss for that training sample.

[0134] In an optional embodiment of this application, for each target word in a training sample, determining the training loss weight corresponding to the target word based on the alignment bias corresponding to the target word may include:

[0135] If the alignment bias corresponding to the target word is greater than or equal to the second preset value, the training loss weight corresponding to the target word is determined to be the second preset value.

[0136] If the alignment bias corresponding to the target word is less than the second set value, the training loss weight corresponding to the target word is determined according to the alignment bias corresponding to the target word, wherein the training loss weight corresponding to the target word is negatively correlated with the alignment bias corresponding to the target word.

[0137] In practical applications, if the alignment bias of a target word is too large (i.e., the alignment bias is greater than or equal to the second set value), it indicates that the target word is too difficult for the model to learn. In this case, the training loss weight corresponding to the target word can be set to a smaller value. If the alignment bias of the target word is less than the second set value, it indicates that the learning difficulty of the target word is acceptable for the model. In this case, a training loss weight negatively correlated with the alignment bias can be assigned to the target word. In other words, when the learning difficulty of the target word is acceptable for the model, a smaller training loss weight can be assigned to target words with relatively high learning difficulty, so that the training samples corresponding to these target words play a relatively small role in model training, avoiding a negative impact on model performance. Conversely, a relatively larger training loss weight can be assigned to target words with relatively low learning difficulty, so that the training samples corresponding to these target words play a relatively large role in model training, thereby improving model performance.

[0138] The specific values ​​of the second set value and the second preset value can be configured according to actual application requirements. This application embodiment does not limit them. For example, they can be set according to experimental values ​​or empirical values. The second set value is a positive number, and the second preset value is also a non-negative number, such as 0 or a relatively small positive number less than 1.

[0139] As an alternative, after calculating the alignment bias corresponding to each target word in the training sample, the alignment bias corresponding to each target word in the sample can be normalized to a value within a set range. For example, the range can be [0, 1], that is, the maximum alignment bias is 1 and the minimum alignment bias is 0. The second set value can be a value between the maximum and minimum values ​​in the range, selected according to the requirements.

[0140] As an alternative, for a target word in a training sample, the training loss weight corresponding to that target word can be expressed by the following expression (3).

[0141]

[0142] Among them, y j Let represent the j-th target word in the second text of the training sample, and α represent the second preset value. Indicates y j The alignment bias is set to α, with a second preset value of 0. When the alignment bias of the target word is greater than or equal to α, the training loss weight w corresponding to that word is adjusted. jWhen the alignment bias of the target word is less than α, the corresponding training loss weight w is 0. j for As can be seen from this expression, α not only determines the distribution of training loss weights but also controls the alignment bias threshold. The training loss weights for target words with an alignment bias greater than α will be reduced to 0.

[0143] In an optional embodiment of this application, the first text of a training sample corresponds to the translation result of the target language, including the translation result of each source word in the first text corresponding to the target language; for a training sample, the above-mentioned obtaining the training loss weight corresponding to the training sample based on the training loss weight corresponding to each target word in the training sample may include:

[0144] The training loss weights corresponding to each target word in the training sample are used as the training loss weights corresponding to the training sample.

[0145] Correspondingly, based on the difference between the second text of the training sample and the corresponding translation result, and the training loss weights corresponding to the training sample, the training loss for the training sample is determined, including:

[0146] For each target word in the second text of the training sample, the translation loss corresponding to the target word is determined based on the difference between the translation results of the target word and the matching source word.

[0147] The training loss weights corresponding to each target word in the second text of the training sample are used to weight the translation loss corresponding to the target word to obtain the training loss for each target word.

[0148] The training loss corresponding to the training sample is obtained based on the training loss corresponding to each target word in the training sample.

[0149] During training, for each training sample, after inputting the first text of the training sample into the neural network model, the neural network model can predict the translation results corresponding to each source word in the first text. The target words in the second text of the training sample are the standard translation results of each source word. Therefore, for each target word, the translation loss corresponding to the target word can be calculated based on the difference between the target word (i.e., the standard translation result) and the predicted translation result corresponding to the word pre-output by the model. Since each target word has its own training loss weight, the corresponding translation loss can be weighted using the training loss weight corresponding to each target word to obtain the training loss of the target word. The training loss corresponding to the training sample is obtained based on the training loss of each target word. Optionally, the average of the training losses of each target word can be calculated and used as the training loss corresponding to the training sample.

[0150] Optionally, after determining the training loss weights corresponding to each target word, if the training loss weight corresponding to a target word is 0, then the training loss corresponding to that target word is 0. Therefore, in actual implementation, it is not necessary to perform the steps of calculating the translation loss corresponding to the target word and weighting the translation loss. The training loss of the target word can be directly determined to be 0 to reduce the amount of computation.

[0151] In practical applications, the specific form of the training loss function corresponding to the model is not specified in this embodiment. It can be selected according to actual needs. As an optional solution, the training loss function corresponding to the model can be the cross-entropy loss function, and the training loss L corresponding to a training sample can be expressed as:

[0152]

[0153] Where m represents the number of target words included in the second text of the training sample, and y j w represents the j-th target word. j p(y) represents the training loss weight corresponding to the j-th target word. j |x <g(j) ,y <j ) indicates that the j-th word in the model's predicted output is y. j The probability, that is, the probability that the model predicts a word as the true value, -w j logp(y j |x <g(j) ,y <j Then g(j) represents the training loss corresponding to the j-th target word. g(j) represents the loss calculated based on a certain strategy. jThe number of visible source words, that is, the number of source words input into the model when the model predicts the j-th word corresponding to the target language, can be set based on empirical or experimental values ​​and is related to the translation algorithm of the selected neural network model. This application does not limit the specific value of g(j).

[0154] In an optional embodiment of this application, for a training sample, the training loss weight corresponding to the training sample is obtained based on the training loss weight corresponding to each target word in the training sample, including:

[0155] The training loss weights corresponding to each target word in the training sample are fused together to obtain the training loss weights corresponding to the training sample.

[0156] Accordingly, the training loss for the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weights corresponding to the training sample, including:

[0157] The translation loss corresponding to the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result.

[0158] The translation loss corresponding to the training sample is weighted using the training loss weights corresponding to the training sample to obtain the training loss corresponding to the training sample.

[0159] In this optional embodiment, the training loss weights corresponding to each target word in a training sample can be fused to obtain a fused weight, which is then used as the training loss weight for that training sample to weight the translation loss of that training sample. The method for fusion of the training loss weights corresponding to each target word is not limited in this embodiment; it can include, but is not limited to, averaging. For example, the training loss weights corresponding to each target word can be summed to obtain the training loss weight for that training sample. After obtaining the training loss weights for all training samples in this way, the training loss weights for all training samples can be normalized to the range [0,1].

[0160] In this optional approach, the method for calculating the translation loss corresponding to the training samples is not limited in this embodiment of the application; the specific training loss function can be selected according to the requirements. For example, it can be done by calculating the translation loss corresponding to each target word separately as described above, and obtaining the translation loss corresponding to the training sample by fusing the target words through summation or averaging; alternatively, after obtaining the complete translation result corresponding to the first text of the training sample through the model, the translation loss corresponding to the training sample can be obtained by calculating the difference between the complete translation result and the second text. For example, the similarity between the predicted complete translation result and the second text can be calculated, and 1 minus the similarity can be used as the translation loss corresponding to the training sample.

[0161] In another alternative embodiment of this application, for a training sample, determining the training loss weights corresponding to the training sample based on the alignment biases corresponding to each target word in the training sample may include:

[0162] Based on the alignment bias corresponding to each target word in the training sample, determine the alignment bias corresponding to the training sample; based on the alignment bias corresponding to the training sample, determine the training loss weight corresponding to the training sample.

[0163] In response, based on the difference between the second text of the training sample and the corresponding translation result, and the training loss weights corresponding to the training sample, the training loss for the training sample is determined, including:

[0164] Based on the difference between the second text of the training sample and the corresponding translation result, the translation loss corresponding to the training sample is determined; the translation loss corresponding to the training sample is weighted using the training loss weight corresponding to the training sample to obtain the training loss corresponding to the training sample.

[0165] In this alternative approach, when calculating the training loss weights corresponding to the training samples, the alignment biases of each target word in the training sample can be fused first to obtain the alignment bias of the sample. Based on this fused alignment bias, the training loss weights corresponding to the sample can be determined. The fusion of the alignment biases of each target word can be achieved through methods including, but not limited to, summation or averaging. After obtaining the alignment bias of the training sample, a training loss weight can be assigned to the sample based on this bias. Optionally, the training loss weight of a training sample can be negatively correlated with its corresponding alignment bias; that is, the larger the alignment bias, the smaller the weight.

[0166] As another alternative, the training loss weights corresponding to a training sample can also be calculated using the expression (3) mentioned above. In this case, expression (3) can be transformed into the following form:

[0167]

[0168] Where w represents the training loss weight corresponding to the training sample, and AO represents the alignment bias corresponding to the training sample, i.e., the alignment bias after fusion.

[0169] Through the various optional solutions provided in this application, corresponding training loss weights are assigned to training samples or target words in training samples based on the learning difficulty of target words in the training samples. This allows training samples of different difficulties to adaptively play different roles when training the model, enabling the model to learn more adaptively according to the difficulty of the samples, thereby improving the performance of the trained translation model and enhancing the translation effect.

[0170] The translation method provided in this application can be applied to any application scenario with translation needs, including but not limited to real-time translation scenarios (such as simultaneous interpreting). The translation model can adopt a neural network model of any structure, including but not limited to synchronous translation models, such as the wait-k model mentioned above. This translation method can effectively improve the accuracy of translation results and better meet the translation needs in various scenarios.

[0171] To verify the effectiveness of the solution provided in this application, two synchronous translation models, the wait-k model and the Multipath Wait-k model, were used as baseline systems in the SiMT scenario. Experiments and verifications were conducted on a publicly available Chinese-to-English translation dataset. The translation quality metrics BLEU (Bilingual Evaluation Understudy) and AL (Additive Latency), commonly used in synchronous machine translation task evaluation, were used to evaluate the translation effect. Table 1 below shows the comparison results of the verification effects of the existing methods and the methods provided in the embodiments of this application.

[0172] Wait-k+ Existing Method 36.35 6.37 Wait-k+ This application method 36.80(+0.45) 6.35(-0.02) Multipath Wait-k+ Existing Method 37.58 6.29 Multipath Wait-k+ This application method 37.80(+0.22) 6.23(-0.06)

[0173] As shown in Table 1, when using the Wait-k model, the solution provided in this application embodiment improves the BLEU score by 0.45 compared to the prior art, and also reduces translation latency. When using the Multipath Wait-k model, the solution provided in this application embodiment improves the BLEU score by 0.22 compared to the prior art, and also reduces translation latency. Therefore, the method provided in this application embodiment not only improves model performance but can also be applied to various different synchronous machine translation model structures.

[0174] To better understand and illustrate the solutions provided in this application, the optional embodiments of this application are described below in conjunction with some application scenarios.

[0175] Figure 3 A schematic diagram of the structure of a translation system applicable to an embodiment of this application is shown, such as... Figure 3 As shown, the translation system may include a user terminal 10, an application server 20, and a training server 30. The user terminal 10 can communicate with the application server 20 via a network, and the application server 20 and the training server 30 can also communicate via a network, which can be a wired or wireless network. The training server 30 is the model training device in this embodiment, used to iteratively train an initial neural network model based on a training dataset to obtain a translation model that meets preset conditions. The trained translation model can be deployed to the application server 20, which provides translation services to users. For example, a user can send text to be translated to the application server 20 through their user terminal 10. The application server 20 translates the text using the translation model and sends the translation result back to the user terminal 10 for display.

[0176] Figure 4 It shows the basis Figure 3 The diagram below illustrates the process of text translation implemented by the translation system. Figure 3 and Figure 4 The solution provided in this application will be described in detail below. This embodiment may include steps S11 to S13 and steps S21 to S23, as follows:

[0177] Step S11: Obtain the training dataset. The training dataset includes multiple training samples, each containing a first text in the source language and a matching second text in the target language (i.e., the standard translation result). The first and second texts can be sentences, paragraphs, or other forms. This embodiment uses sentences as an example for illustration.

[0178] Step S12: Calculate the training loss weights for the target words.

[0179] This step is used to calculate the training loss weight of each word in the second text of each training sample. For each training sample, the alignment pairs (i.e., matching word pairs) in the two texts of the sample can be counted manually or by other applications first. Then, the alignment bias PAO between each alignment pair can be calculated using the expression (1) above. Based on the alignment bias between each alignment pair, the alignment bias AO corresponding to each target word can be calculated using the expression (2). Finally, the training loss weight corresponding to each target word can be calculated based on the expression (3).

[0180] Step S13: Iteratively train the neural network model based on the training loss weights of each training sample and each target word in each training sample until the preset conditions are met. The neural network model that meets the preset conditions is then used as the trained translation model.

[0181] In this embodiment, the neural network model uses a synchronous machine translation model as an example. This model can be a translation model based on the Transformer structure, such as the Wati-K model. A Transformer-based translation model can include an encoder and a decoder. The encoder reads in the input text (the first text) and encodes it, i.e., extracts features. During encoding, each source word can only see itself and the words preceding it in the word order. The encoder's output is the hidden layer state corresponding to the first text. The decoder is used to decode based on the hidden layer state output by the encoder and the already translated words (the translation of the first word is based on the encoder's output; after the first word, translation can be performed based on the encoder's output and the already translated words). Based on the decoder's output, the predicted result for each word, i.e., the translation result, can be obtained.

[0182] For ease of description, the source sentence (i.e., the first text) in the training samples is defined as x = (x1, x2, ..., x...). n The target sentence (i.e., the second text) is defined as y = (y1, y2, ..., y3). m During model training, source sentences are input into the model, which then provides the predicted translation of the source sentences into the target language. This is achieved by learning the predicted word(s) in the target sentence. Optionally, for each target word(s), the model can predict the target language. j The prediction result of the j-th word output by the model can include the probability corresponding to each candidate word. The probability of a candidate word represents the likelihood that the output word belongs to that candidate word. For a training sample, based on the prediction results of each word output by the model and each target word (true value) in the target sentence, the training loss corresponding to the sample can be calculated using expression (4). The total training loss corresponding to the model can be calculated based on the training loss corresponding to each training sample, such as the sum or mean of the training losses corresponding to each training sample.

[0183] If the preset conditions are not met after each training iteration, the model parameters can be adjusted based on the total training loss of the model, and the training process can be repeated until a translation model that meets the preset conditions is obtained. The trained translation model can then be deployed to the application server.

[0184] Step S21: The user terminal obtains the text to be translated and sends it to the application server.

[0185] Step S22: The application server translates the text to be translated and obtains the translation result.

[0186] Step S23: The application server sends the translation results to each user terminal, which then displays them to the user.

[0187] The method for obtaining the text to be translated may differ in different application scenarios. Several examples are provided below to illustrate this.

[0188] As an example, Figures 5 to 7 This illustrates a method for obtaining text to be translated in one application scenario. For example... Figure 5 As shown, this application scenario can be an instant messaging scenario, where the application server can be the server of an instant messaging application. Users can interact with other users through the user interface of this program. This example uses user A and user B as an example. User A inputs English sentences through their user terminal's user interface, while user B inputs Chinese sentences. After receiving the Chinese message from user B, if user A cannot understand the Chinese or wants to view it in English, optionally, user A can click or long-press the Chinese sentence sent by user B. At this time, a "translate" control can be displayed in their user interface, such as... Figure 6 As shown, if user A clicks on this control, the application server can translate the Chinese statement into the corresponding English statement and display the translation result to user A through user A's user interface, such as... Figure 7 As shown. Alternatively, after user A clicks the "Translate" control, a target language selection list can be displayed. User A can choose the language in which the Chinese sentence is to be translated. After user A selects the target language, the application server can translate the Chinese sentence into the corresponding language and display it to user A.

[0189] Understandably, in this application scenario, if user A wants to send a message in Chinese to user B but doesn't know how to express it in Chinese, they could enter the message in English and then select "translate" before sending it. The application server can then translate the English message into Chinese based on user A's needs and provide it to user A. User A can then choose to send the Chinese message to user B. In this scenario, the application provides users with an automatic translation function, allowing users to smoothly exchange information using different languages.

[0190] Figure 8 and Figure 9The diagram illustrates another application scenario to which this application's embodiments apply. In practical applications, if a user needs to translate a sentence, paragraph, or article, they can input the content to be translated into the source text input area through the user interface of the translation application's client, as shown in the example. Figure 8 In the left rectangular area, the user can select the desired language for translation. Optionally, the source language can be automatically recognized by the program or selected by the user, while the target language can be selected by the user. If the user does not select a target language, the application server can translate the user-input text into the default language based on the default location. In this example, when the user enters the content they want to translate ( Figure 8 After entering the Chinese text "What's your name?", you can click the "Translate" control. The server will then translate the content into English text and display it in the target text display area. Figure 8 and Figure 9 The right-hand rectangular area displays the translation results to the user, such as... Figure 8 As shown.

[0191] It should be noted that in practical applications, the application server can translate the text after the user enters the text to be translated and clicks the "Translate" control, and then display the entire translation result to the user at once. Alternatively, it can be synchronous translation, where the corresponding translation content can be displayed to the user while the user is entering the text to be translated. For example, when the number of words entered by the user equals k, the application server starts translating and displays the translation content to the user in real time.

[0192] The solution provided in this application can also be applied to simultaneous interpretation scenarios. For example, in some speeches, there is a need for simultaneous interpretation, which requires translating the speaker's words without interrupting them and then playing the translation results to the audience simultaneously. Figure 10 The diagram shows a structural schematic of a translation system in this application scenario. The system may include an audio acquisition device 11, a translation device 12, and an audio playback device 13. The specific device forms of the audio acquisition device 11, the translation device 12, and the audio playback device 13 are not limited in this application embodiment. The translation device 12 is equipped with a trained speech recognition model, a translation model, and a text-to-audio module, and is the main body for executing the method provided in this application embodiment in this scenario.

[0193] In simultaneous interpreting scenarios Figure 10The translation model shown is a synchronous translation model trained using the training method provided in this application embodiment. In practical applications, the source speech of the speaker can be collected in real time by the audio acquisition device 11. The language used by the speaker is the language of the scene. The audio acquisition device continuously sends the source speech collected in real time to the translation device 12. For the received source speech, the translation device first uses a speech recognition model to recognize it, and the text content to be translated (the text fragment to be translated) is obtained. The recognized text content is then translated by the translation model to obtain the target text corresponding to the target language. The target text can be converted into the target speech of the target language by the text-to-audio module. The translation device can send the target speech to the audio playback device 13, and the target speech is played to the corresponding listener through the audio playback device 13 (such as headphones worn by the listener).

[0194] It is understood that the translation method provided in this application embodiment can be applied to, but is not limited to, the above-described application scenarios. Using the solution provided in this application can effectively improve translation skills and better meet various translation needs.

[0195] Based on the same principle as the translation method provided in the embodiments of this application, the embodiments of this application also provide a translation device, such as... Figure 11 As shown, the translation device 100 includes a text acquisition module 110 and a text translation module 120. The text acquisition module 110 is used to acquire the text to be translated in the source language; the text translation module 120 is used to translate the text to be translated by calling a trained translation model to obtain the target text in the target language corresponding to the text to be translated; wherein, the translation model is trained by a model training device in the following manner:

[0196] Obtain multiple training samples, each training sample including a first text in the source language and a second text in the target language corresponding to the first text;

[0197] For each training sample, the training loss weights corresponding to the training sample are determined based on the positional bias of each matching word pair in the first and second texts of the training sample in the two texts.

[0198] Based on multiple training samples and the corresponding training loss weights for each training sample, the initial neural network model is iteratively trained to obtain the translation model; wherein, during the training process, the training loss corresponding to a training sample is determined based on the training loss weight corresponding to that training sample.

[0199] Optionally, the model training device can be used to iteratively train the initial neural network model for:

[0200] The first text of each training sample is input into the neural network model to obtain the translation result of the first text of each training sample corresponding to the target language;

[0201] For each training sample, the training loss corresponding to the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weight corresponding to the training sample.

[0202] Based on the training loss corresponding to each training sample, the total training loss corresponding to the neural network model is obtained.

[0203] The model parameters of the neural network model are adjusted based on the total training loss, and the adjusted neural network model is further trained based on multiple training samples and the training loss weights corresponding to each training sample.

[0204] Optionally, a matching word pair includes the source word in the first text of the training sample and the target word in the second text of the training sample that matches the source word; for each training sample, the model training device, when determining the training loss weights corresponding to the training sample based on the positional bias of each matching word pair in the first and second texts of the training sample, can be used for:

[0205] For each matching word pair in the training sample, the alignment bias corresponding to the word pair is determined based on the positional bias between the source word and the target word in the word pair.

[0206] For each target word in the training sample, the alignment bias corresponding to the target word is determined based on the alignment bias of each matching word pair in the training sample that includes the target word.

[0207] Based on the alignment bias of each target word in the training sample, the training loss weights corresponding to the training sample are determined.

[0208] Optionally, for each matching word pair in the training samples, when determining the alignment bias corresponding to the word pair based on the positional bias between the source and target words in the word pair, the model training device can use the following methods:

[0209] If the positional offset between the source word and the target word in the word pair is greater than or equal to a first set value, the alignment offset of the word pair is determined based on the difference between the positional offset and the first set value, wherein the alignment offset of the word pair is positively correlated with the difference.

[0210] If the positional offset between the source word and the target word in the word pair is less than a first preset value, the alignment offset of the word pair is determined to be the first preset value.

[0211] Optionally, for each target word in the training sample, when the model training device determines the alignment bias corresponding to the target word based on the alignment bias corresponding to each matching word pair including the target word in the training sample, it can be used to: determine the mean of the alignment bias corresponding to each matching word pair including the target word in the training sample as the alignment bias corresponding to the target word.

[0212] Optionally, when determining the training loss weights corresponding to the training samples based on the alignment biases corresponding to each target word in the training samples, the model training device can be used for:

[0213] For each target word in the training sample, the training loss weight corresponding to the target word is determined based on the alignment bias corresponding to the target word; the training loss weight corresponding to the training sample is obtained based on the training loss weight corresponding to each target word in the training sample.

[0214] Optionally, for each target word in the training samples, when determining the training loss weights corresponding to that target word based on the alignment bias, the model training device can use the following methods:

[0215] If the alignment bias corresponding to the target word is greater than or equal to the second preset value, the training loss weight corresponding to the target word is determined to be the second preset value.

[0216] If the alignment bias corresponding to the target word is less than the second set value, the training loss weight corresponding to the target word is determined according to the alignment bias corresponding to the target word. The training loss weight corresponding to a target word is negatively correlated with the alignment bias corresponding to the target word.

[0217] Optionally, the first text of a training sample corresponds to the translation result of the target language, including the translation result of each source word in the first text corresponding to the target language; when the model training device obtains the training loss weight corresponding to the training sample based on the training loss weight corresponding to each target word in the training sample, it can be used to: use the training loss weight corresponding to each target word in the training sample as the training loss weight corresponding to the training sample.

[0218] Accordingly, when determining the training loss for a training sample based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weights corresponding to the training sample, the model training device can be used for:

[0219] For each target word in the second text of the training sample, the translation loss corresponding to the target word is determined based on the difference between the translation results of the target word and the matching source word. The translation loss corresponding to the target word is weighted using the training loss weights of each target word in the second text of the training sample to obtain the training loss corresponding to each target word. The training loss corresponding to the training sample is obtained based on the training loss corresponding to each target word in the training sample.

[0220] Optionally, when the model training device obtains the training loss weight corresponding to the training sample based on the training loss weight corresponding to each target word in the training sample, it can be used to: fuse the training loss weights corresponding to each target word in the training sample to obtain the training loss weight corresponding to the training sample.

[0221] Accordingly, the model training device can be used to determine the training loss for a training sample based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weights corresponding to the training sample:

[0222] Based on the difference between the second text of the training sample and the corresponding translation result, the translation loss corresponding to the training sample is determined; the translation loss corresponding to the training sample is weighted using the training loss weight corresponding to the training sample to obtain the training loss corresponding to the training sample.

[0223] Optionally, for each training sample, the model training device determines the training loss weights corresponding to that training sample based on the alignment biases of each target word in the training sample. This weight can be used for:

[0224] Based on the alignment bias of each target word in the training sample, determine the alignment bias of the training sample; based on the alignment bias of the training sample, determine the training loss weight of the training sample.

[0225] Accordingly, when determining the training loss for a training sample based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weights corresponding to the training sample, the model training device can be used for:

[0226] Based on the difference between the second text of the training sample and the corresponding translation result, the translation loss corresponding to the training sample is determined; the translation loss corresponding to the training sample is weighted using the training loss weight corresponding to the training sample to obtain the training loss corresponding to the training sample.

[0227] The apparatus in this application embodiment can execute the method provided in this application embodiment, and their implementation principles are similar. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For a detailed functional description of each module of the apparatus, please refer to the description in the corresponding method shown above, which will not be repeated here. The translation apparatus provided in this application embodiment can be any electronic device.

[0228] This application also provides an electronic device, which may include a memory, a processor, and a computer program stored in the memory. When the processor executes the computer program stored in the memory, it can implement the method in any optional embodiment of this application.

[0229] Optionally, Figure 12 A schematic diagram of the structure of an electronic device to which an embodiment of the present invention applies is shown, such as... Figure 12 As shown, the electronic device can be a server or a user terminal, and it can be used to implement the methods provided in any embodiment of the present invention.

[0230] like Figure 12 As shown, the electronic device 2000 may include at least one processor 2001, a memory 2002, a communication module 2003, and an input / output interface 2004, etc. Optionally, the components can be connected and communicate with each other via a bus 2005. It should be noted that... Figure 12 The structure of the electronic device 2000 shown is merely illustrative and does not constitute a limitation on the electronic devices to which the methods provided in the embodiments of this application are applicable.

[0231] The memory 2002 can be used to store operating systems and applications, etc. The applications can include computer programs that implement the methods shown in the embodiments of the present invention when invoked by the processor 2001, and can also include programs for implementing other functions or services. The memory 2002 can be ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices that can store information and computer programs, or it can be EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disk storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.

[0232] Processor 2001 is connected to memory 2002 via bus 2005, and implements corresponding functions by calling application programs stored in memory 2002. Processor 2001 can be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this invention. Processor 2001 can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0233] Electronic device 2000 can connect to a network via communication module 2003 (which may include, but is not limited to, components such as a network interface) to communicate with other devices (such as user terminals or servers) through the network and achieve data interaction, such as sending data to or receiving data from other devices. Communication module 2003 may include wired network interfaces and / or wireless network interfaces, meaning the communication module may include at least one of wired or wireless communication modules.

[0234] Electronic device 2000 can connect to required input / output devices, such as keyboards and display devices, via input / output interface 2004. Electronic device 2000 itself may have a display device, and other display devices can be connected externally via interface 2004. Optionally, storage devices, such as hard drives, can also be connected via interface 2004 to store data from electronic device 2000, retrieve data from storage devices, or store data from storage devices into memory 2002. It is understood that input / output interface 2004 can be a wired interface or a wireless interface. Depending on the actual application scenario, the device connected to input / output interface 2004 can be a component of electronic device 2000 or an external device connected to electronic device 2000 when needed.

[0235] The bus 2005 used to connect the various components may include a pathway for transmitting information between these components. The bus 2005 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Depending on its function, the bus 2005 can be divided into address bus, data bus, control bus, etc.

[0236] Optionally, for the solution provided in the embodiments of the present invention, the memory 2002 can be used to store a computer program that executes the solution of the present invention, and the processor 2001 runs the computer program. When the processor 2001 runs the computer program, it implements the operation of the method or apparatus provided in the embodiments of the present invention.

[0237] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the corresponding content of the aforementioned method embodiments.

[0238] This application also provides a computer program product, which includes a computer program that, when executed by a processor, can implement the corresponding content of the aforementioned method embodiments.

[0239] It should be noted that the terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text.

[0240] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.

[0241] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of the embodiments of this application.

Claims

1. A method of translation, characterized by, include: Obtain the text to be translated in the source language; By calling a trained translation model to translate the text to be translated, the target text in the target language corresponding to the text to be translated is obtained; The translation model was trained in the following way: Multiple training samples are obtained, each training sample including a first text in the source language and a second text in the target language corresponding to the first text; For each matching word pair in each training sample, the alignment bias corresponding to the word pair is determined based on the positional bias between the source word and the target word in the word pair; a matching word pair in a training sample includes the source word in the first text of the training sample and the target word in the second text of the training sample that matches the source word; For each target word in the training sample, the alignment bias corresponding to the target word is determined based on the alignment bias of each matching word pair in the training sample that includes the target word. Based on the alignment bias corresponding to each target word in the training sample, the training loss weight corresponding to the training sample is determined. Based on the multiple training samples and the training loss weights corresponding to each training sample, the initial neural network model is iteratively trained to obtain the translation model; wherein, during the training process, the training loss corresponding to a training sample is determined based on the training loss weights corresponding to the training sample.

2. The method of claim 1, wherein, The iterative training of the initial neural network model based on the plurality of training samples and the training loss weights corresponding to each training sample includes: The first text of each training sample is input into the neural network model to obtain the translation result of the first text of each training sample corresponding to the target language; For each training sample, the training loss corresponding to the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weight corresponding to the training sample. Based on the training loss corresponding to each training sample, the total training loss corresponding to the neural network model is obtained; The model parameters of the neural network model are adjusted based on the total training loss, and the adjusted neural network model is further trained based on the multiple training samples and the training loss weights corresponding to each training sample.

3. The method of claim 1, wherein, For each matching word pair in the training samples, determining the alignment bias corresponding to the word pair based on the positional bias between the source word and the target word in the word pair includes: If the positional offset between the source word and the target word in the word pair is greater than or equal to a first set value, the alignment offset corresponding to the word pair is determined based on the difference between the positional offset and the first set value, wherein the alignment offset corresponding to the word pair is positively correlated with the positional offset; If the positional offset between the source word and the target word in the word pair is less than the first preset value, the alignment offset corresponding to the word pair is determined as the first preset value.

4. The method of claim 1, wherein, For each target word in the training sample, determining the alignment bias corresponding to the target word based on the alignment biases of each matching word pair including the target word in the training sample includes: The mean of the alignment biases of each matching word pair in the training sample that includes the target word is determined as the alignment bias of the target word.

5. The method of claim 1, wherein, The step of determining the training loss weights corresponding to the training samples based on the alignment biases corresponding to each target word in the training samples includes: For each target word in the training sample, the training loss weight corresponding to the target word is determined based on the alignment bias corresponding to the target word. The training loss weights corresponding to the training samples are obtained based on the training loss weights corresponding to each target word in the training samples.

6. The method of claim 5, wherein, For each target word in the training sample, determining the training loss weight corresponding to the target word based on the alignment bias of the target word includes: If the alignment bias corresponding to the target word is greater than or equal to the second preset value, the training loss weight corresponding to the target word is determined to be the second preset value. If the alignment bias corresponding to the target word is less than the second set value, the training loss weight corresponding to the target word is determined according to the alignment bias corresponding to the target word, wherein the training loss weight corresponding to the target word is negatively correlated with the alignment bias corresponding to the target word.

7. The method of claim 5, wherein, The first text of a training sample corresponds to the translation result of the target language, including the translation result of each source word in the first text corresponding to the target language; The step of obtaining the training loss weights corresponding to the training samples based on the training loss weights corresponding to each target word in the training samples includes: The training loss weights corresponding to each target word in the training sample are used as the training loss weights corresponding to the training sample. The step of determining the training loss corresponding to the training sample based on the difference between the second text of the training sample and the corresponding translation result, and the training loss weight corresponding to the training sample, includes: For each target word in the training sample, the translation loss corresponding to the target word is determined based on the difference between the translation results of the target word and the matching source word. The training loss weights corresponding to each target word in the training samples are used to weight the translation loss corresponding to the target word to obtain the training loss for each target word. The training loss corresponding to the training sample is obtained based on the training loss corresponding to each target word in the training sample.

8. The method of claim 5, wherein, The step of obtaining the training loss weights corresponding to the training samples based on the training loss weights corresponding to each target word in the training samples includes: The training loss weights corresponding to each target word in the training sample are fused together to obtain the training loss weights corresponding to the training sample. The step of determining the training loss corresponding to the training sample based on the difference between the second text of the training sample and the corresponding translation result, and the training loss weight corresponding to the training sample, includes: The translation loss corresponding to the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result; The translation loss corresponding to the training sample is weighted using the training loss weights corresponding to the training sample to obtain the training loss corresponding to the training sample.

9. The method of claim 1, wherein, The step of determining the training loss weights corresponding to the training samples based on the alignment biases corresponding to each target word in the training samples includes: The alignment bias corresponding to the training sample is determined based on the alignment bias corresponding to each target word in the training sample. The training loss weights corresponding to the training samples are determined based on the alignment bias corresponding to the training samples. The step of determining the training loss corresponding to the training sample based on the difference between the second text of the training sample and the corresponding translation result, and the training loss weight corresponding to the training sample, includes: The translation loss corresponding to the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result; The translation loss corresponding to the training sample is weighted using the training loss weights corresponding to the training sample to obtain the training loss corresponding to the training sample.

10. A translation device, characterized by The translation device includes: The text acquisition module is used to acquire the text to be translated in the source language; The text translation module is used to translate the text to be translated by calling a trained translation model, thereby obtaining the target text in the target language corresponding to the text to be translated; wherein, the translation model is trained by a model training device in the following manner: Multiple training samples are obtained, each training sample including a first text in the source language and a second text in the target language corresponding to the first text; For each matching word pair in each training sample, the alignment bias corresponding to the word pair is determined based on the positional bias between the source word and the target word in the word pair; a matching word pair in a training sample includes the source word in the first text of the training sample and the target word in the second text of the training sample that matches the source word; For each target word in the training sample, the alignment bias corresponding to the target word is determined based on the alignment bias of each matching word pair in the training sample that includes the target word. Based on the alignment bias corresponding to each target word in the training sample, the training loss weight corresponding to the training sample is determined. Based on the multiple training samples and the training loss weights corresponding to each training sample, the initial neural network model is iteratively trained to obtain the translation model; wherein, during the training process, the training loss corresponding to a training sample is determined based on the training loss weights corresponding to the training sample.

11. The apparatus of claim 10, wherein, When the model training device iteratively trains the initial neural network model based on the plurality of training samples and the training loss weights corresponding to each training sample, it is specifically used for: The first text of each training sample is input into the neural network model to obtain the translation result of the first text of each training sample corresponding to the target language; For each training sample, the training loss corresponding to the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result, as well as the training loss weight corresponding to the training sample. Based on the training loss corresponding to each training sample, the total training loss corresponding to the neural network model is obtained; The model parameters of the neural network model are adjusted based on the total training loss, and the adjusted neural network model is further trained based on the multiple training samples and the training loss weights corresponding to each training sample.

12. The apparatus of claim 10, wherein, For each matching word pair in the training samples, when the model training device determines the alignment bias corresponding to the word pair based on the positional bias between the source word and the target word in the word pair, it specifically performs the following: If the positional offset between the source word and the target word in the word pair is greater than or equal to a first set value, the alignment offset corresponding to the word pair is determined based on the difference between the positional offset and the first set value, wherein the alignment offset corresponding to the word pair is positively correlated with the positional offset; If the positional offset between the source word and the target word in the word pair is less than the first preset value, the alignment offset corresponding to the word pair is determined as the first preset value.

13. The apparatus of claim 10, wherein, For each target word in the training sample, when the model training device determines the alignment bias corresponding to the target word based on the alignment biases of each matching word pair including the target word in the training sample, it is specifically used for: The mean of the alignment biases of each matching word pair in the training sample that includes the target word is determined as the alignment bias of the target word.

14. The apparatus of claim 10, wherein, When the model training device determines the training loss weights corresponding to the training samples based on the alignment biases corresponding to each target word in the training samples, it is specifically used for: For each target word in the training sample, the training loss weight corresponding to the target word is determined based on the alignment bias corresponding to the target word. The training loss weights corresponding to the training samples are obtained based on the training loss weights corresponding to each target word in the training samples.

15. The apparatus of claim 14, wherein, For each target word in the training sample, when determining the training loss weight corresponding to the target word based on the alignment bias corresponding to the target word, the model training device is specifically used for: If the alignment bias corresponding to the target word is greater than or equal to the second preset value, the training loss weight corresponding to the target word is determined to be the second preset value. If the alignment bias corresponding to the target word is less than the second set value, the training loss weight corresponding to the target word is determined according to the alignment bias corresponding to the target word, wherein the training loss weight corresponding to the target word is negatively correlated with the alignment bias corresponding to the target word.

16. The apparatus of claim 14, wherein, The first text of a training sample corresponds to the translation result of the target language, including the translation result of each source word in the first text corresponding to the target language; When the model training device obtains the training loss weights corresponding to the training samples based on the training loss weights corresponding to each target word in the training samples, it is specifically used for: The training loss weights corresponding to each target word in the training sample are used as the training loss weights corresponding to the training sample. When determining the training loss corresponding to the training sample based on the difference between the second text of the training sample and the corresponding translation result, and the training loss weight corresponding to the training sample, the model training device is specifically used for: For each target word in the training sample, the translation loss corresponding to the target word is determined based on the difference between the translation results of the target word and the matching source word. The training loss weights corresponding to each target word in the training samples are used to weight the translation loss corresponding to the target word to obtain the training loss for each target word. The training loss corresponding to the training sample is obtained based on the training loss corresponding to each target word in the training sample.

17. The apparatus of claim 14, wherein, When the model training device obtains the training loss weights corresponding to the training samples based on the training loss weights corresponding to each target word in the training samples, it is specifically used for: The training loss weights corresponding to each target word in the training sample are fused together to obtain the training loss weights corresponding to the training sample. When determining the training loss corresponding to the training sample based on the difference between the second text of the training sample and the corresponding translation result, and the training loss weight corresponding to the training sample, the model training device is specifically used for: The translation loss corresponding to the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result; The translation loss corresponding to the training sample is weighted using the training loss weights corresponding to the training sample to obtain the training loss corresponding to the training sample.

18. The apparatus of claim 10, wherein, When the model training device determines the training loss weights corresponding to the training samples based on the alignment biases corresponding to each target word in the training samples, it is specifically used for: The alignment bias corresponding to the training sample is determined based on the alignment bias corresponding to each target word in the training sample. The training loss weights corresponding to the training samples are determined based on the alignment bias corresponding to the training samples. When determining the training loss corresponding to the training sample based on the difference between the second text of the training sample and the corresponding translation result, and the training loss weight corresponding to the training sample, the model training device is specifically used for: The translation loss corresponding to the training sample is determined based on the difference between the second text of the training sample and the corresponding translation result; The translation loss corresponding to the training sample is weighted using the training loss weights corresponding to the training sample to obtain the training loss corresponding to the training sample.

19. An electronic device, comprising: The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method according to any one of claims 1-9.

20. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the method described in any one of claims 1-9.

21. A computer program product, characterised in that, The computer program product includes a computer program that, when executed by a processor, implements the method described in any one of claims 1-9.