Translation model training method and device and related equipment

By constructing spoken language and preference sample sets and adopting a phased model training strategy, the translation quality of the machine translation model was improved, the problem of repeated output was solved, and high-precision translation results were achieved.

CN121835950APending Publication Date: 2026-04-10THE FOURTH PARADIGM BEIJING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing machine learning-based translation technologies suffer from repetitive output issues during model training and translation generation, leading to a decline in translation quality and making it difficult to meet the application requirements of high-precision translation scenarios.

Method used

We construct spoken language sample sets and preference sample sets, and use incremental model training and preference model training to specifically suppress the generation of repeated words. We adopt a phased model training strategy. First, we improve the general translation ability of the model through spoken language sample sets, and then we optimize the model through preference sample sets to reduce repeated output.

Benefits of technology

It significantly improves the translation quality and robustness of the translation model, ensuring accurate, fluent, and natural translations, reducing repetitive output, and enhancing translation effectiveness in practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121835950A_ABST
    Figure CN121835950A_ABST
Patent Text Reader

Abstract

The invention provides a translation model training method and device and related equipment, and the method comprises the steps: constructing a spoken language sample set, the spoken language sample set comprises a plurality of spoken language samples, and each spoken language sample comprises a spoken language text and a spoken language translation text corresponding to the spoken language text; a preference sample set is generated, the preference sample set comprises a plurality of preference samples, and each preference sample comprises a preference text, a preference translation text corresponding to the preference text and a rewritten preference translation text corresponding to the preference text; wherein the preference text is a spoken language text which is screened out from a spoken language sample set and has continuous and repeated fields, and the part, corresponding to the continuous and repeated fields, in the rewriting preference translation text is enhanced; performing incremental model training on the to-be-optimized translation model based on the spoken language sample set to obtain an intermediate translation model; and performing preference model training on the intermediate translation model based on the preference sample set to obtain a target translation model. The translation quality of the translation model is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine learning, and in particular to a method, apparatus, and related equipment for training a translation model. Background Technology

[0002] With the rapid development of machine learning technology, its application areas continue to expand, and its application in the field of machine translation is particularly widespread.

[0003] Among translation-related technologies, automatic translation systems based on machine learning architectures have become the mainstream implementation path. However, existing machine learning-based translation technologies suffer from repetitive output problems in the core stages of model training and translation generation, due to inherent technical limitations. This manifests as redundant translation results. These shortcomings directly lead to a decline in translation quality, making it difficult to meet the application requirements of high-precision translation scenarios and significantly reducing the practical value of the translated text. Summary of the Invention

[0004] This application provides a method, apparatus, and related equipment for training a translation model to address the problem of poor translation quality in related technologies.

[0005] To solve the above problems, this application is implemented as follows:

[0006] In a first aspect, embodiments of this application provide a method for training a translation model, the method comprising:

[0007] Construct a spoken language sample set, which includes multiple spoken language samples. Each spoken language sample includes: spoken language text and the spoken language translation text corresponding to the spoken language text.

[0008] Generate a preference sample set, which includes multiple preference samples. Each preference sample includes: preference text, preference translation text corresponding to the preference text, and rewritten preference translation text corresponding to the preference text. The preference text is spoken text with continuous repeating fields selected from the spoken language sample set, and the part of the rewritten preference translation text corresponding to the continuous repeating fields is enhanced.

[0009] Based on the spoken language sample set, incremental model training is performed on the translation model to be optimized to obtain an intermediate translation model;

[0010] The intermediate translation model is trained using a preference sample set to obtain the target translation model.

[0011] Optionally, the steps for constructing a spoken language sample set include:

[0012] Acquire spoken audio, which includes conversational features, including at least one of the following: interjections, and discontinuous speech.

[0013] Convert spoken audio into spoken text;

[0014] Obtain the spoken audio translation text corresponding to the spoken audio;

[0015] Each spoken text is paired with its corresponding spoken translation text to form spoken samples in the spoken sample set.

[0016] Optionally, the steps for generating a preference sample set include:

[0017] Select spoken texts with consecutively repeated fields as preferred texts. The repeated fields include at least one of the following: reduplicated words, repeated words;

[0018] Obtain the corresponding preferred translation text based on the preferred text;

[0019] Generate rewritten preference translation text using any of the following methods:

[0020] The preference text is rewritten to obtain the rewritten preference text, which expands the consecutive repeated fields in the preference text; the rewritten preference translation text is obtained based on the rewritten preference text.

[0021] Expand the portion of the preference translation text corresponding to consecutively repeated fields to obtain the rewritten preference translation text;

[0022] Pair the preference text, the translated preference text, and the rewritten preference text to form preference samples in the preference sample set.

[0023] Optionally, the steps to obtain the corresponding preference translation text from the preference text include:

[0024] Obtain the translated text corresponding to the preferred text based on the preferred text;

[0025] The translated text corresponding to the preferred text is corrected to obtain the preferred translated text.

[0026] Optionally, based on the spoken language sample set, incremental model training is performed on the translation model to be optimized to obtain an intermediate translation model, including:

[0027] Input the spoken language sample set into the translation model to be optimized, and output the translation result to be optimized.

[0028] The first loss value is obtained by calculating the loss value between the translation result to be optimized and the spoken translation text based on the first loss function.

[0029] Incremental model training is performed on the encoder and decoder of the translation model to be optimized based on the first loss value to obtain an intermediate translation model.

[0030] Optionally, the steps of incrementally training the encoder and decoder of the translation model to be optimized based on the first loss value to obtain the intermediate translation model include:

[0031] Calculate the entropy of the attention weights of the model to be optimized for the spoken sample set, and obtain the target entropy value;

[0032] The second loss value is calculated based on the target entropy value, the preset weight value, and the first loss value.

[0033] Incremental model training is performed on the encoder of the translation model to be optimized based on the second loss value until the second loss value converges to a preset threshold, thus obtaining an intermediate translation model.

[0034] Optionally, a preference model can be trained on the intermediate translation model based on the preference sample set to obtain the target translation model, including:

[0035] The preference sample set is input into the intermediate translation model, and the preference translation result is output.

[0036] The third loss value is obtained by calculating the loss value between the preferred translation result and the preferred translated text based on the second loss function;

[0037] The fourth loss value is obtained by calculating the loss value between the preferred translation result and the rewritten preferred translation text based on the third loss function;

[0038] Based on the third and fourth loss values, the intermediate translation model is trained using a preference model to obtain the target translation model.

[0039] Optionally, after the step of training the intermediate translation model based on the preference sample set to obtain the target translation model, the method further includes:

[0040] Obtain the target text to be translated;

[0041] The target text is input into the target translation model for decoding and translation.

[0042] During the decoding and translation process, word segments in the generated target translation text are detected in real time. If any word segment is detected to have been repeated a certain number of times in the generated target translation text, it is identified as a target word segment, and a repetition penalty coefficient is generated for the target word segment. The repetition penalty coefficient is used to reduce the probability of generating target words in the future.

[0043] Optionally, after the step of training the intermediate translation model based on the preference sample set to obtain the target translation model, the method further includes:

[0044] Input the target translation model into the target inference framework;

[0045] The target translation model is converted into an intermediate representation format compatible with the target inference framework using the model conversion tools provided by the target inference framework.

[0046] Accuracy transformation is performed on the activation values ​​of at least one of the following in the transformed target translation model: model weights, calculation process, to obtain the optimized translation model;

[0047] The target inference framework automatically calls the hardware optimization computing library corresponding to the deployment hardware type of the translation model, thereby accelerating the inference of the optimization model.

[0048] Secondly, embodiments of this application provide a training apparatus for a translation model, the apparatus comprising:

[0049] The spoken language sample set construction module is used to construct a spoken language sample set, which includes multiple spoken language samples. Each spoken language sample includes: spoken language text and the spoken language translation text corresponding to the spoken language text.

[0050] The preference sample set generation module is used to generate a preference sample set, which includes multiple preference samples. Each preference sample includes: preference text, preference translation text corresponding to the preference text, and rewritten preference translation text corresponding to the preference text. Among them, the preference text is spoken text with continuous repeating fields selected from the spoken language sample set, and the part of the rewritten preference translation text corresponding to the continuous repeating fields is enhanced.

[0051] The incremental training module is used to incrementally train the translation model to be optimized based on the spoken language sample set, so as to obtain an intermediate translation model.

[0052] The preference training module is used to train the intermediate translation model based on the preference sample set to obtain the target translation model.

[0053] Thirdly, embodiments of this application also provide an electronic device, including: a memory, a processor, and a program stored in the memory and executable on the processor; the processor is configured to read the program in the memory to implement the steps of the method described in the first aspect above.

[0054] Fourthly, embodiments of this application also provide a readable storage medium for storing a program, which, when executed by a processor, implements the steps of the method described in the first aspect above.

[0055] Fifthly, embodiments of this application also provide a computer program product, including computer instructions, which, when executed by a processor, implement the steps in the method described in the first aspect above. Attached Figure Description

[0056] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0057] Figure 1 One of the flowcharts illustrating a training method for a translation model provided in this application embodiment;

[0058] Figure 2 A second schematic flowchart illustrating a training method for a translation model provided in an embodiment of this application;

[0059] Figure 3 A third schematic flowchart illustrating a training method for a translation model provided in this application embodiment;

[0060] Figure 4 The fourth schematic flowchart of a translation model training method provided in this application embodiment;

[0061] Figure 5 Fifth of a flowchart illustrating a training method for a translation model provided in this application embodiment;

[0062] Figure 6 A flowchart illustrating a training method for a translation model provided in this application is shown in Figure 6.

[0063] Figure 7 The seventh flowchart illustrates a method for training a translation model according to an embodiment of this application.

[0064] Figure 8 This is the eighth flowchart illustrating a training method for a translation model provided in this application embodiment;

[0065] Figure 9 A flowchart illustrating a training method for a translation model provided in this application is shown in Figure 9.

[0066] Figure 10 A schematic diagram of the structure of a translation model training device provided in an embodiment of this application;

[0067] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0068] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0069] The terms "first," "second," etc., used in the embodiments of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or devices. Additionally, the use of "and / or" in this application indicates at least one of the connected objects, such as A and / or B and / or C, representing seven possibilities: including A alone, B alone, C alone, and the presence of both A and B, both B and C, both A and C, and the presence of A, B, and C.

[0070] See Figure 1 , Figure 1 This is one of the flowcharts illustrating the training method for the translation model provided in this application embodiment. Figure 1 The training method for the translation model shown can be performed by a computer. For example... Figure 1 As shown, the training method for the translation model may include the following steps:

[0071] Step 200: Construct a spoken language sample set, which includes multiple spoken language samples. Each spoken language sample includes: spoken language text and the corresponding spoken language translation text.

[0072] In this embodiment, a large-scale first-language-second-language spoken language dataset is collected and organized, wherein the first language and the second language are different; for example, if the first language is Chinese, then the second language can be English. The spoken language dataset may include meeting transcripts, real-time dialogues, and simultaneous interpretation corpora, etc.

[0073] Generate a spoken language sample set based on a colloquial dataset. The spoken language sample set includes multiple spoken language samples, and each spoken language sample includes spoken language text and a corresponding spoken language translation text for the spoken language text. The spoken language text refers to content expressed in a natural spoken language form, and the spoken language translation text is a translation of the spoken language content, which is another language pointing to the same semantics. The spoken language text is the first language text, and the spoken language translation text is the second language text, and the first language and the second language are different. Exemplarily, the spoken language text can be "How are you?", and the corresponding spoken language translation text is "你好吗?". It should be noted that the collected spoken language samples should cover different topics, scenarios, and conversation types as much as possible to more comprehensively reflect the diversity of actual spoken language communication. The spoken language sample set contains at least a preset proportion of samples with colloquial features to ensure the distribution density of colloquial features in the training data. The preset proportion can be set by the user according to needs, and this application does not make a limit. Exemplarily, it can be set to 50%, 70%, or 80%.

[0074] The spoken language sample set generated in this embodiment can provide high-quality training data to ensure that the model adapts to the unstructured input in colloquial scenarios.

[0075] Step 400: Generate a preference sample set. The preference sample set includes multiple preference samples, and each preference sample includes: preference text, a corresponding preference translation text for the preference text, and a rewritten preference translation text corresponding to the preference text; where the preference text is the spoken language text selected from the spoken language sample set and having continuous repeated fields, and the part corresponding to the continuous repeated fields in the rewritten preference translation text is enhanced.

[0076] In this embodiment, in daily conversation data, due to colloquial habits or recognition errors in Automatic Speech Recognition (ASR), the phenomenon of reduplicated words / repeated words often appears. Such data is likely to cause problems of repeated translation during translation.

[0077] Therefore, in this embodiment, a preference sample set with reduplicated words / repeated words is generated. Each preference sample includes: preference text, a corresponding preference translation text for the preference text, and a rewritten preference translation text corresponding to the preference text. The preference text refers to the text with continuous repeated fields. The preference translation text refers to the translation text of the corresponding preference text. The rewritten preference translation text refers to a version obtained by enhancing the continuous repeated fields in the preference translation text. It should be noted that the rewritten preference translation text can be a rewritten translation text obtained by strengthening the repeated fields of the repeated text and then translating it, or it can be directly rewriting the translation text of the repeated text to strengthen the repeated fields to obtain a rewritten text.

[0078] Specifically, the corpus can be statistically analyzed using unigrams, bigrams, and trigrams. Sentences with fields repeated more than three times consecutively in the original data are selected as preference texts. Their corresponding translations are then obtained to obtain the preference translation text. Further expansion of the repeated fields within the preference texts creates expanded repeated data, and its corresponding translations are obtained to obtain the rewritten preference translation text. Alternatively, the rewritten preference translation text can be obtained by directly expanding the repeated fields within the preference translation text.

[0079] For example, the preferred text could be "Hello, hello, hello, how's the weather today?". The preferred translated text could be "Hello, hello, hello, How's the weather today?". The rewritten preferred translated text could be "Hello, hello, hello, hello, hello, How's the weather today?".

[0080] Step 600: Based on the spoken language sample set, perform incremental model training on the translation model to be optimized to obtain an intermediate translation model.

[0081] In this embodiment, an intermediate translation model is obtained by incrementally training the translation model to be optimized using a spoken language sample set. Incremental model training is a machine learning model training method that allows for continuous learning and updating based on an existing model. In this embodiment, incremental model training refers to supervised fine-tuning of the translation model to be optimized using a spoken language sample set.

[0082] Specifically, during fine-tuning, the encoder and decoder parameters of the translation model to be optimized are updated to adapt to the semantic and syntactic features of spoken Chinese-English input. By incrementally training the translation model to be optimized, the model's general translation capabilities in simultaneous interpreting scenarios can be improved, ensuring that the translation is fluent and natural.

[0083] Step 800: Train the intermediate translation model using the preference sample set to obtain the target translation model.

[0084] In this embodiment, the intermediate translation model obtained after incremental model training is trained based on the preference sample set to obtain the final trained target translation model. The preference model training refers to further model fine-tuning, that is, by adjusting the generation probability distribution, the tendency to generate repeated words or phrases is suppressed.

[0085] In this embodiment, preference model training enables the trained target translation model to significantly reduce the problem of repetitive translation output while maintaining conversational translation capabilities.

[0086] This application employs a phased model training strategy by constructing spoken language sample sets and preference sample sets. First, the spoken language sample set is used for incremental training of the translation model to be optimized, enabling the model to fully learn the semantic and syntactic features of spoken language expressions. This effectively improves the model's general translation capabilities in scenarios such as simultaneous interpreting, ensuring accurate, fluent, and natural translations. Subsequently, preference-optimized training is performed using the preference sample set. While maintaining spoken language translation capabilities, this specifically suppresses the model's tendency to over-generate repetitive patterns in the source language, significantly reducing the problem of repetitive output in the translation. This overall improves the translation quality and robustness of the model in practical applications.

[0087] In some feasible implementations, step 200, the step of constructing the spoken language sample set, optionally includes:

[0088] Step 210: Obtain spoken audio. Spoken audio includes conversational features, which include at least one of the following: interjections, or broken speech.

[0089] Step 220: Convert the spoken audio into spoken text;

[0090] Step 230: Obtain the spoken translation text corresponding to the spoken audio;

[0091] Step 240: Pair each spoken text with its corresponding spoken translation text to form spoken samples in the spoken sample set.

[0092] In this embodiment, as Figure 2 As shown, Figure 2 This is the second flowchart of the training method for the translation model provided in this application embodiment. When constructing the spoken language sample set, spoken language audio and the corresponding translation content of the spoken language audio are collected to generate spoken language translation text. The spoken language audio is in the first language, and the spoken language translation text is in the second language. The first language and the second language are different languages.

[0093] When acquiring spoken audio, the audio includes conversational features such as "um," "ah," and "this," which express the speaker's emotions, thought processes, or pauses between sentences. This allows the model to better recognize conversational features during training. There can be one or more spoken audio clips. Spoken audio can be segmented, such as by sentence, by paragraph, or by topic. After acquiring the spoken audio, it undergoes text conversion to obtain spoken text. This text conversion can be done by converting each sentence, each paragraph, or even converting the entire spoken audio clip into a single text file.

[0094] Obtain the spoken translation text corresponding to the spoken audio. Among them, the method for obtaining the spoken translation text can be to translate the spoken text. For example, it can be translated manually or through a translation model. After translation by the translation model, manual review can also be performed to ensure the accuracy of the translation result. In some embodiments, it is also possible to directly obtain the spoken translation audio corresponding to the spoken audio and convert the spoken translation audio into the spoken translation text, such as simultaneous interpretation, etc.

[0095] Pair each obtained spoken text with the corresponding spoken translation text to generate a spoken sample. In this embodiment, an effective spoken sample set can be constructed. By preserving the spoken features, the authenticity and effectiveness of the data in the sample set are ensured.

[0096] Optionally, step 400, the step of generating the preference sample set includes:

[0097] Step 410, screen the spoken text with continuous repeated fields in the spoken text as the preference text, and the repeated fields include at least one of the following: reduplicated words, repeated words;

[0098] Step 420, obtain the corresponding preference translation text according to the preference text;

[0099] Step 430, generate the rewritten preference translation text;

[0100] Among them, the rewritten preference translation text is generated by any of the following methods:

[0101] Rewrite the preference text to obtain the rewritten preference text, and the rewritten preference text expands the continuous repeated fields in the preference text; obtain the rewritten preference translation text according to the rewritten preference text;

[0102] Expand the part corresponding to the continuous repeated fields in the preference translation text to obtain the rewritten preference translation text;

[0103] Step 440, pair the preference text, the preference translation text, and the rewritten preference text to form the preference samples in the preference sample set.

[0104] In this embodiment, as Figure 3 shown, Figure 3 is the third flow diagram of the training method of the translation model provided by the embodiment of the present application. After generating the spoken sample set, screen the text with continuous repeated fields from the spoken sample set as the preference text. These continuous repeated fields can include: reduplicated words: such as "good good", "slowly", etc., repeated words: such as "I think I think", "very very happy", etc.

[0105] The corresponding preferred translation text is obtained based on the preferred text. Specifically, based on the preferred text, i.e., spoken text with consecutively repeated fields, the corresponding spoken translation text is obtained from the spoken language sample set, and this spoken translation text is used as the preferred translation text corresponding to the preferred text. Alternatively, the preferred text can be directly and accurately translated to obtain the preferred translation text.

[0106] Generating rewritten preference translation text can be done in various ways. In this embodiment, preference translation text can be obtained through any of the following methods:

[0107] Expanding consecutively repeated fields in the preference text yields rewritten preference text. For example, the original preference text was: "I really like this movie." The rewritten text is: "I really like this movie." Then, translating the rewritten preference text yields the translated preference text.

[0108] The rewritten preference translation text is obtained by directly expanding the part of the preference translation text corresponding to the consecutive repeated fields. For example, the preference translation text "I really, really love this movie" is directly expanded to "I really, really, really, really love this movie".

[0109] Each preference text, each preference translation text, and each rewritten preference text are paired to generate a preference sample. The technical solution in this embodiment generates a preference sample set that strengthens the repetitive fields, which facilitates the targeted improvement of the model's ability to identify repetitive content in subsequent model training.

[0110] Optionally, step 420, obtaining the corresponding preference translation text based on the preference text, includes:

[0111] Step 421: Obtain the translated text corresponding to the preferred text from the spoken language sample set based on the preferred text;

[0112] Step 422: Correct the translated text corresponding to the preferred text to obtain the preferred translated text.

[0113] In this embodiment, as Figure 4 As shown, Figure 4This is the fourth flowchart illustrating the training method of the translation model provided in this application. The method involves obtaining the corresponding translated text based on the preferred text. Specifically, based on the preferred text, i.e., spoken text with consecutive repeated fields, a corresponding spoken translation text is obtained from the spoken language sample set. This spoken translation text is then used as the translated text corresponding to the preferred text. For example, the translated text could be "II really love this movie". The translated text corresponding to the preferred text is then specifically corrected. This correction can be made to repeating fields, or other inaccurate translations, to generate the preferred translated text. For example, correcting repeating fields in the translated text could result in the preferred translated text being "I really love this movie". By correcting the original translated text, the accuracy of the preferred translated text can be ensured, redundancy can be effectively eliminated, and the model's translation performance can be improved, better meeting the translation needs of real-world application scenarios.

[0114] Optionally, step 600 involves incrementally training the translation model to be optimized based on the spoken language sample set to obtain an intermediate translation model, including:

[0115] Step 610: Input the spoken language sample set into the translation model to be optimized, and output the translation result to be optimized;

[0116] Step 620: Calculate the loss value between the translation result to be optimized and the spoken translation text according to the first loss function to obtain the first loss value;

[0117] Step 630: Based on the first loss value, perform incremental model training on the encoder and decoder of the translation model to be optimized to obtain an intermediate translation model.

[0118] In this embodiment, as Figure 5 As shown, Figure 5 This is the fifth flowchart of the training method for the translation model provided in this application embodiment. The translation model to be optimized is a pre-trained translation model, which is further trained using a spoken language sample set to improve its translation accuracy and naturalness.

[0119] Specifically, the spoken language sample set is input into the translation model to be optimized, and the corresponding spoken language sample set is output as the translation result to be optimized. The loss value between the translation result to be optimized and the spoken language translation text is calculated by a preset first loss function to obtain the first loss value. The first loss function is a function that evaluates the difference between the translation result generated by the model and the real translation text, such as cross-entropy loss.

[0120] The translation model to be optimized includes an encoder and a decoder. The encoder is responsible for capturing the features of the input text, and its weights are updated as training progresses to better represent the input information. The decoder generates the output content, and its parameters are also adjusted based on the loss value to improve the quality of the generated content. After obtaining the first loss value, the parameters of the encoder and decoder of the translation model to be optimized are adjusted according to the first loss value, i.e., supervised fine-tuning of the encoder and decoder, resulting in a fine-tuned intermediate translation model.

[0121] The technical solution in this embodiment can effectively improve the model's translation performance for spoken content.

[0122] Optionally, step 630, which involves incrementally training the encoder and decoder of the translation model to be optimized based on the first loss value to obtain an intermediate translation model, includes:

[0123] Step 631: Calculate the entropy of the attention weights of the model to be optimized for the spoken sample set, and obtain the target entropy value;

[0124] Step 632: Calculate the second loss value based on the target entropy value, the preset weight value, and the first loss value;

[0125] Step 633: Based on the second loss value, perform incremental model training on the encoder of the translation model to be optimized until the second loss value converges to a preset threshold to obtain an intermediate translation model.

[0126] In this embodiment, as Figure 6 As shown, Figure 6 This is the sixth flowchart illustrating the training method of the translation model provided in this application. The entropy of the attention weights of the model to be optimized for the spoken sample set is calculated to obtain the target entropy value. The attention mechanism is used to determine the degree of influence of each input word generated by the encoder on the decoder output. The target entropy value can be calculated using the following formula:

[0127]

[0128] Where H(α) is the target entropy value; i is the output position index of the decoder, representing the position of the currently generated translation word in the translated text; j is the input vocabulary index of the encoder, representing the position of a certain input word in the spoken text; α ij α is an element in the attention weight matrix, specifically referring to the attention weight assigned to the encoder for the j-th input word when the encoder generates the i-th output word. For a fixed i, α corresponds to all j. ij This forms a probability distribution.

[0129] In this embodiment, by calculating the target entropy value, the model to be optimized can be assisted in adjusting the allocation strategy of attention weights, and the stability of attention distribution can be constrained to reduce the risk of repeated generation caused by abnormal attention distribution in some scenarios.

[0130] By adding an entropy regularization term to the loss function, which encourages diversity in the global distribution of attention weights, the second loss value can be calculated using the following formula:

[0131]

[0132] Among them, L task L is the first loss value. total λ is the second loss value, and λ is the preset weight value.

[0133] The calculated second loss value is used to incrementally train the encoder of the translation model to be optimized, thereby comprehensively evaluating the translation ability and attention allocation of the model to be optimized, until the second loss value converges to a preset threshold, resulting in an intermediate translation model. The preset threshold is the training objective; it is expected that the second loss value will gradually decrease during training and eventually converge to the preset threshold, thus stabilizing the model's performance and achieving the expected translation effect.

[0134] During the training of the model to be optimized, continuous loss calculation and training iteration enable the model to better adapt to actual translation tasks and optimize its performance, thereby improving the translation quality of the model output.

[0135] Optionally, step 800 involves training the intermediate translation model using a preference model based on the preference sample set to obtain the target translation model, including:

[0136] Step 810: Input the preference sample set into the intermediate translation model and output the preference translation result.

[0137] Step 820: Calculate the loss value between the preferred translation result and the preferred translated text based on the second loss function to obtain the third loss value.

[0138] Step 830: Calculate the loss value between the preference translation result and the rewritten preference translation text based on the third loss function to obtain the fourth loss value.

[0139] Step 840: Based on the third and fourth loss values, train the intermediate translation model using a preference model to obtain the target translation model.

[0140] In this embodiment, as Figure 7 As shown, Figure 7This is the seventh flowchart of the training method for the translation model provided in this application embodiment. After obtaining the intermediate translation model, the generated preference sample set is input into the intermediate translation model, and the preference translation result is output. Through this training process, the model can generate translation results that meet expectations.

[0141] The second loss function is a function that evaluates the difference between the preferred translation result generated by the model and the preferred translated text, such as cross-entropy loss. The third loss function is a function that evaluates the difference between the preferred translation result generated by the model and the rewritten preferred translated text, which can also be cross-entropy loss.

[0142] The third loss value is calculated by comparing the preferred translation result with the corresponding preferred translation text. This third loss value reflects the model's accuracy in generating translated content. The fourth loss value is calculated by comparing the preferred translation result with the corresponding rewritten preferred translation text. This fourth loss value guides the model to learn the translation of consecutively repeated fields, strengthening the model's ability to identify and optimize consecutively repeated content. It also reflects the model's accuracy in generating translated content.

[0143] Therefore, the generation capability of the intermediate translation model is optimized based on the third and fourth loss values ​​to obtain the target translation model. The target translation model performs better than the intermediate translation model in translating the preferred sample set.

[0144] The technical solution of this embodiment gradually inputs the sample set into the model, calculates the loss, and optimizes the parameters to finally obtain a target translation model that can effectively handle preferred texts. This model can ensure the accuracy of the translated content, effectively suppress the output of consecutive repeated fields, and take into account the diversity and naturalness of the translated text. It significantly improves the user experience and the practical value of the translated text in translation scenarios.

[0145] Optionally, after step 800, which involves training the intermediate translation model based on the preference sample set to obtain the target translation model, the method further includes:

[0146] Step 900: Obtain the target text to be translated;

[0147] Step 1000: Input the target text into the target translation model for decoding and translation;

[0148] During the decoding and translation process, word segments in the generated target translation text are detected in real time. If any word segment is detected to have been repeated a certain number of times in the generated target translation text, it is identified as a target word segment, and a repetition penalty coefficient is generated for the target word segment. The repetition penalty coefficient is used to reduce the probability of generating target words in the future.

[0149] In this embodiment, as Figure 8 As shown, Figure 8 This is the eighth flowchart illustrating the training method of the translation model provided in this application. After obtaining the trained target translation model, the target text to be translated is acquired. The target text can be a sentence in any language, and the goal is to translate it into another language. The target translation model outputs the translation result in the target language from the input target text. Specifically, the target translation model includes an encoder and a decoder. The encoder is responsible for understanding the context of the input text, and the decoder generates the translation output.

[0150] Word segmentation refers to breaking down text into smaller units (such as words or phrases). During translation, it's necessary to track the generated word segments for detection in subsequent generation processes. Specifically, during decoding and translation, the target translation model detects word segments in the generated target translation text in real time, identifying frequently repeated words and marking them as target segments. Once a segment is identified as a target segment, a repetition penalty coefficient is generated to adjust the probability of the model outputting the target segment in subsequent generation processes. This reduces the likelihood of the same word appearing repeatedly in the translated text, thus enhancing the diversity and naturalness of the text. It should be noted that the preset threshold can be set according to actual conditions, such as repetition counts of 3 or 4.

[0151] The technical solution in this embodiment controls translation quality through real-time detection and penalty strategies during translation, which helps to improve the readability and expressive richness of the output text.

[0152] Optionally, after step 800, which involves training the intermediate translation model based on the preference sample set to obtain the target translation model, the method further includes:

[0153] Step 1100: Input the target translation model into the target inference framework;

[0154] Step 1200: Using the model conversion tool provided by the target inference framework, convert the target translation model into an intermediate representation format compatible with the target inference framework;

[0155] Step 1300: Perform precision conversion on the activation values ​​of at least one of the following in the transformed target translation model: model weights, calculation process, to obtain the optimized translation model;

[0156] Step 1400: The target inference framework automatically calls and optimizes the hardware optimization computing library corresponding to the deployment hardware type of the translation model to accelerate the inference of the optimization model.

[0157] In this embodiment, as Figure 9 As shown, Figure 9This is the ninth flowchart of the training method for the translation model provided in this application embodiment. The target reasoning framework is an environment in which the trained model is applied to actual reasoning (i.e., generating translation).

[0158] The model conversion tool for the target inference framework is used to convert models of different formats into framework-compatible intermediate representation formats, such as computation graphs, operator mappings, etc.

[0159] Before entering the inference phase, precision optimization can be performed on some key components of the transformed model to improve performance. This includes precision conversion of model weights and the computation process, resulting in an optimized translation model. Specifically, precision conversion of model weights involves converting floating-point weights (e.g., 32-bit floating-point numbers) to lower precision (e.g., 16-bit floating-point numbers or 8-bit integers) to reduce memory usage and speed up computation. Precision conversion of the computation process allows for the application of various precision strategies during model inference, such as mixed-precision training and inference, to further optimize the computation process.

[0160] The target inference framework will automatically invoke the optimization computing library corresponding to the hardware type deployed on the optimized translation model during the inference phase. By utilizing specific hardware acceleration libraries, the model can effectively reduce latency, increase throughput, and provide concurrent processing capabilities during inference, thereby achieving higher computational efficiency and effectively reducing model operating costs.

[0161] The technical solution in this embodiment significantly improves the inference efficiency and performance of the model by inputting the target translation model into the target inference framework and performing conversion and optimization. Furthermore, through precision conversion and the use of hardware-specific optimized computational libraries, not only are the required computational resources and latency reduced, but the real-time processing capability of the model translation is also improved.

[0162] This application embodiment constructs a spoken language sample set and a preference sample set. During the training process of the translation model to be optimized, the model is first fine-tuned using the spoken language sample set, which can improve the model's general translation ability in translation scenarios, ensuring accuracy, fluency, and naturalness of the translation. Then, the model is further fine-tuned using the preference sample set, thereby significantly reducing the problem of repetitive translation output while maintaining the spoken language translation ability, and effectively improving the translation quality of the translation model.

[0163] See Figure 10 , Figure 10 This is a structural diagram of the training device for the translation model provided in an embodiment of this application. For example... Figure 10 As shown, the training device 1500 for the translation model includes:

[0164] The spoken language sample set construction module 1510 is used to construct a spoken language sample set, which includes multiple spoken language samples. Each spoken language sample includes: spoken language text and the spoken language translation text corresponding to the spoken language text.

[0165] The preference sample set generation module 1520 is used to generate a preference sample set, which includes multiple preference samples. Each preference sample includes: preference text, preference translation text corresponding to the preference text, and rewritten preference translation text corresponding to the preference text. The preference text is spoken text with continuous repeating fields selected from the spoken language sample set, and the part of the rewritten preference translation text corresponding to the continuous repeating fields is enhanced.

[0166] Incremental training module 1530 is used to incrementally train the translation model to be optimized based on the spoken language sample set to obtain an intermediate translation model.

[0167] The preference training module 1540 is used to train the intermediate translation model based on the preference sample set to obtain the target translation model.

[0168] The training device for the translation model provided in this application constructs a spoken language sample set and a preference sample set, employing a phased model training strategy. First, incremental training is performed on the translation model to be optimized using the spoken language sample set, enabling the model to fully learn the semantic and syntactic features of spoken language expressions. This effectively improves the model's general translation capabilities in scenarios such as simultaneous interpreting, ensuring accurate, fluent, and natural translations. Subsequently, preference optimization training is performed using the preference sample set. While maintaining spoken language translation capabilities, this specifically suppresses the model's tendency to over-generate repetitive patterns in the source language, significantly reducing the problem of repetitive output in the translation. This overall improves the translation quality and robustness of the translation model in practical applications.

[0169] Optionally, the spoken language sample set construction module 1510 includes:

[0170] The audio acquisition submodule is used to acquire spoken audio, which includes conversational features, including at least one of the following: interjections and discontinuous speech.

[0171] The conversion submodule is used to convert spoken audio into spoken text;

[0172] The first text acquisition submodule is used to acquire the spoken translation text corresponding to the spoken audio;

[0173] The first pairing submodule is used to pair each spoken text with its corresponding spoken translation text to form spoken samples in the spoken sample set.

[0174] Optionally, the preference sample set generation module 1520 includes:

[0175] The filtering submodule is used to filter spoken texts with consecutively repeated fields as preferred texts. The repeated fields include at least one of the following: reduplicated words, repeated words;

[0176] The second text acquisition submodule is used to obtain the corresponding preferred translation text based on the preferred text.

[0177] The text generation submodule is used to generate rewrite preference translation text in any of the following ways:

[0178] The preference text is rewritten to obtain the rewritten preference text, which expands the consecutive repeated fields in the preference text; the rewritten preference translation text is obtained based on the rewritten preference text.

[0179] Expand the portion of the preference translation text corresponding to consecutively repeated fields to obtain the rewritten preference translation text;

[0180] The second pairing submodule is used to pair preference text, preference translation text, and rewritten preference text to form preference samples in the preference sample set.

[0181] Optionally, the second text acquisition submodule includes:

[0182] The text acquisition unit is used to obtain the translated text corresponding to the preferred text from the spoken language sample set based on the preferred text.

[0183] The text correction unit is used to correct the translated text corresponding to the preferred text to obtain the preferred translated text.

[0184] Optionally, the incremental training module 1530 includes:

[0185] The first processing submodule is used to input the spoken language sample set into the translation model to be optimized and output the translation result to be optimized.

[0186] The first calculation submodule is used to calculate the loss value between the translation result to be optimized and the spoken translation text according to the first loss function, and obtain the first loss value;

[0187] The first training submodule is used to incrementally train the encoder and decoder of the translation model to be optimized based on the first loss value, so as to obtain an intermediate translation model.

[0188] Optionally, the first training submodule includes:

[0189] The entropy calculation unit is used to calculate the entropy of the attention weights of the model to be optimized for the spoken sample set, and obtain the target entropy value.

[0190] The loss calculation unit is used to calculate the second loss value based on the target entropy value, the preset weight value, and the first loss value.

[0191] The first training unit is used to incrementally train the encoder of the translation model to be optimized based on the second loss value until the second loss value converges to a preset threshold, thus obtaining an intermediate translation model.

[0192] Optionally, the preference training module 1540 includes:

[0193] The second processing submodule is used to input the preference sample set into the intermediate translation model and output the preference translation result.

[0194] The second calculation submodule is used to calculate the loss value between the preferred translation result and the preferred translated text based on the second loss function, and obtain the third loss value;

[0195] The third calculation submodule is used to calculate the loss value between the preference translation result and the rewritten preference translation text based on the third loss function, and obtain the fourth loss value;

[0196] The second training submodule is used to train the intermediate translation model using the third and fourth loss values ​​to obtain the target translation model.

[0197] Optional, also includes:

[0198] The text acquisition module is used to acquire the target text to be translated.

[0199] The text translation module is used to input the target text into the target translation model for decoding and translation;

[0200] During the decoding and translation process, word segments in the generated target translation text are detected in real time. If any word segment is detected to have been repeated a certain number of times in the generated target translation text, it is identified as a target word segment, and a repetition penalty coefficient is generated for the target word segment. The repetition penalty coefficient is used to reduce the probability of generating target words in the future.

[0201] Optional, also includes:

[0202] The input module is used to input the target translation model into the target inference framework;

[0203] The format conversion module is used to convert the target translation model into an intermediate representation format compatible with the target inference framework using the model conversion tools provided by the target inference framework.

[0204] The precision conversion module is used to perform precision conversion on the activation values ​​of at least one of the following in the converted target translation model: model weights, calculation process, to obtain an optimized translation model;

[0205] The optimization computing module is used by the target inference framework to automatically call the hardware optimization computing library corresponding to the deployment hardware type of the optimized translation model, thereby accelerating the inference of the optimized model.

[0206] This application also provides an electronic device. Please refer to [link to relevant documentation]. Figure 11 The electronic device may include a processor 1610, a memory 1620, and a program 1621 stored in the memory 1620 and executable on the processor 1610.

[0207] When program 1621 is executed by processor 1610, it can achieve the following: Figure 1 Any step in the corresponding method embodiment:

[0208] Construct a spoken language sample set, which includes multiple spoken language samples. Each spoken language sample includes: spoken language text and the spoken language translation text corresponding to the spoken language text.

[0209] Generate a preference sample set, which includes multiple preference samples. Each preference sample includes: preference text, preference translation text corresponding to the preference text, and rewritten preference translation text corresponding to the preference text. The preference text is spoken text with continuous repeating fields selected from the spoken language sample set, and the part of the rewritten preference translation text corresponding to the continuous repeating fields is enhanced.

[0210] Based on the spoken language sample set, incremental model training is performed on the translation model to be optimized to obtain an intermediate translation model;

[0211] The intermediate translation model is trained using a preference sample set to obtain the target translation model.

[0212] Optionally, the steps for constructing a spoken language sample set include:

[0213] Acquire spoken audio, which includes conversational features, including at least one of the following: interjections, and discontinuous speech.

[0214] Convert spoken audio into spoken text;

[0215] Obtain the spoken audio translation text corresponding to the spoken audio;

[0216] Each spoken text is paired with its corresponding spoken translation text to form spoken samples in the spoken sample set.

[0217] Optionally, the steps for generating a preference sample set include:

[0218] Select spoken texts with consecutively repeated fields as preferred texts. The repeated fields include at least one of the following: reduplicated words, repeated words;

[0219] Obtain the corresponding preferred translation text based on the preferred text;

[0220] Generate rewritten preference translation text using any of the following methods:

[0221] The preference text is rewritten to obtain the rewritten preference text, which expands the consecutive repeated fields in the preference text; the rewritten preference translation text is obtained based on the rewritten preference text.

[0222] Expand the portion of the preference translation text corresponding to consecutively repeated fields to obtain the rewritten preference translation text;

[0223] Pair the preference text, the translated preference text, and the rewritten preference text to form preference samples in the preference sample set.

[0224] Optionally, the steps to obtain the corresponding preference translation text from the preference text include:

[0225] Based on the preferred text, the corresponding translated text is obtained from the spoken language sample set;

[0226] The translated text corresponding to the preferred text is corrected to obtain the preferred translated text.

[0227] Optionally, based on the spoken language sample set, incremental model training is performed on the translation model to be optimized to obtain an intermediate translation model, including:

[0228] Input the spoken language sample set into the translation model to be optimized, and output the translation result to be optimized.

[0229] The first loss value is obtained by calculating the loss value between the translation result to be optimized and the spoken translation text based on the first loss function.

[0230] Incremental model training is performed on the encoder and decoder of the translation model to be optimized based on the first loss value to obtain an intermediate translation model.

[0231] Optionally, the steps of incrementally training the encoder and decoder of the translation model to be optimized based on the first loss value to obtain the intermediate translation model include:

[0232] Calculate the entropy of the attention weights of the model to be optimized for the spoken sample set, and obtain the target entropy value;

[0233] The second loss value is calculated based on the target entropy value, the preset weight value, and the first loss value.

[0234] Incremental model training is performed on the encoder of the translation model to be optimized based on the second loss value until the second loss value converges to a preset threshold, thus obtaining an intermediate translation model.

[0235] Optionally, a preference model can be trained on the intermediate translation model based on the preference sample set to obtain the target translation model, including:

[0236] The preference sample set is input into the intermediate translation model, and the preference translation result is output.

[0237] The third loss value is obtained by calculating the loss value between the preferred translation result and the preferred translated text based on the second loss function;

[0238] The fourth loss value is obtained by calculating the loss value between the preferred translation result and the rewritten preferred translation text based on the third loss function;

[0239] Based on the third and fourth loss values, the intermediate translation model is trained using a preference model to obtain the target translation model.

[0240] Optionally, after the step of training the intermediate translation model based on the preference sample set to obtain the target translation model, the method further includes:

[0241] Obtain the target text to be translated;

[0242] The target text is input into the target translation model for decoding and translation.

[0243] During the decoding and translation process, word segments in the generated target translation text are detected in real time. If any word segment is detected to have been repeated a certain number of times in the generated target translation text, it is identified as a target word segment, and a repetition penalty coefficient is generated for the target word segment. The repetition penalty coefficient is used to reduce the probability of generating target words in the future.

[0244] Optionally, after the step of training the intermediate translation model based on the preference sample set to obtain the target translation model, the method further includes:

[0245] Input the target translation model into the target inference framework;

[0246] The target translation model is converted into an intermediate representation format compatible with the target inference framework using the model conversion tools provided by the target inference framework.

[0247] Accuracy transformation is performed on the activation values ​​of at least one of the following in the transformed target translation model: model weights, calculation process, to obtain the optimized translation model;

[0248] The target inference framework automatically calls the hardware optimization computing library corresponding to the deployment hardware type of the translation model, thereby accelerating the inference of the optimization model.

[0249] This application embodiment constructs a spoken language sample set and a preference sample set. During the training process of the translation model to be optimized, the model is first fine-tuned using the spoken language sample set, which can improve the model's general translation ability in simultaneous interpretation scenarios and ensure that the translation is accurate, fluent, and natural. Then, the model is further fine-tuned using the preference sample set, thereby significantly reducing the problem of repetitive translation output while maintaining the spoken language translation ability, and effectively improving the translation quality of the translation model.

[0250] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, this computer program implements the various processes of the above-described translation model training method embodiments and achieves the same technical effects. To avoid repetition, further details are omitted here. The computer-readable storage medium provided in this application can be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.

[0251] This application also provides a computer program product, including computer instructions, which are executed by at least one processor to implement the various processes of the above-described translation model training method embodiment and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0252] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0253] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods of the various embodiments of this application.

[0254] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A method for training a translation model, the method comprising: The method comprises: constructing a spoken language sample set, the spoken language sample set comprising a plurality of spoken language samples, each of the spoken language samples comprising: a spoken language text and a spoken language translation text corresponding to the spoken language text; generating a preference sample set, the preference sample set comprising a plurality of preference samples, each of the preference samples comprising: a preference text, a preference translation text corresponding to the preference text, and a rewritten preference translation text corresponding to the preference text; wherein the preference text is a spoken language text with a continuous repeated field selected from the spoken language sample set, and the rewritten preference translation text is enhanced in the part corresponding to the continuous repeated field; based on the spoken language sample set, incrementally training a to-be-optimized translation model to obtain an intermediate translation model; based on the preference sample set, preference model training is performed on the intermediate translation model to obtain a target translation model.

2. The method of claim 1, wherein, The step of constructing a spoken language sample set comprises: obtaining a spoken language audio, the spoken language audio comprising a spoken language feature, the spoken language feature comprising at least one of the following: intonation words, intermittent speech flow; converting the spoken language audio into the spoken language text; obtaining the spoken language translation text corresponding to the spoken language audio; pairing each of the spoken language texts with the corresponding spoken language translation texts to form the spoken language samples in the spoken language sample set.

3. The method of claim 1, wherein, The step of generating a preference sample set comprises: selecting the spoken language text with a continuous repeated field in the spoken language text as a preference text, the repeated field comprising at least one of the following: reduplicated words, repeated words; obtaining the corresponding preference translation text according to the preference text; generating a rewritten preference translation text in any of the following ways: rewriting the preference text to obtain a rewritten preference text, the rewritten preference text expanding the continuous repeated field in the preference text; obtaining the rewritten preference translation text according to the rewritten preference text; expanding the part of the preference translation text corresponding to the continuous repeated field to obtain the rewritten preference translation text; pairing the preference text, the preference translation text, and the rewritten preference text to form the preference samples in the preference sample set.

4. The method of claim 3, wherein, The step of obtaining the corresponding preference translation text according to the preference text comprises: obtaining the translation text corresponding to the preference text from the spoken language sample set according to the preference text; correcting the translation text corresponding to the preference text to obtain the preference translation text.

5. The method of claim 1, wherein, The step of incrementally training the to-be-optimized translation model based on the spoken language sample set to obtain an intermediate translation model comprises: inputting the spoken language sample set into the to-be-optimized translation model to output a to-be-optimized translation result; calculating the loss value between the to-be-optimized translation result and the spoken language translation text according to a first loss function to obtain a first loss value; based on the first loss value, incrementally training the encoder and the decoder of the to-be-optimized translation model to obtain the intermediate translation model.

6. The method of claim 5, wherein, The step of incrementally training the encoder and the decoder of the to-be-optimized translation model based on the first loss value to obtain the intermediate translation model comprises: calculate an entropy value of the attention weight of the to-be-optimized model for the spoken language sample set; calculate the second loss value according to the target entropy value, a preset weight value, and the first loss value; perform incremental model training on the encoder of the to-be-optimized translation model based on the second loss value until the second loss value converges to a preset threshold value, to obtain the intermediate translation model.

7. The method of claim 1, wherein, The method further includes: input the preference sample set into the intermediate translation model to output a preference translation result; calculate a loss value between the preference translation result and the preference translation text according to a second loss function, to obtain a third loss value; calculate a loss value between the preference translation result and the rewritten preference translation text according to a third loss function, to obtain a fourth loss value; perform preference model training on the intermediate translation model based on the third loss value and the fourth loss value, to obtain the target translation model.

8. The method according to any one of claims 1 to 7, characterized in that, The method further includes: obtain a target text to be translated; input the target text into the target translation model for decoding translation; In the decoding translation process, a word segmentation in the generated target translation text is detected in real time. When any word segmentation is detected to have a continuous repetition number reaching a preset threshold value in the generated target translation text, the word segmentation is determined as a target word segmentation, and a repetition penalty coefficient corresponding to the target word segmentation is generated. The repetition penalty coefficient is used to reduce the probability of generating the target word segmentation in the future.

9. A device for training a translation model, characterized by, The apparatus includes: a spoken language sample set construction module configured to construct the spoken language sample set, the spoken language sample set including a plurality of spoken language samples, each of the spoken language samples including a spoken language text and a spoken language translation text corresponding to the spoken language text; a preference sample set generation module configured to generate the preference sample set, the preference sample set including a plurality of preference samples, each of the preference samples including a preference text, a preference translation text corresponding to the preference text, and a rewritten preference translation text corresponding to the preference text, wherein the preference text is a spoken language text with a continuous repetition field selected from the spoken language sample set, and a portion of the rewritten preference translation text corresponding to the continuous repetition field is enhanced; an incremental training module configured to perform incremental model training on a to-be-optimized translation model based on the spoken language sample set to obtain an intermediate translation model; a preference training module configured to perform preference model training on the intermediate translation model based on the preference sample set to obtain a target translation model.

10. An electronic device comprising: a memory, a processor, and a program stored in the memory and executable on the processor, wherein the processor is configured to read the program in the memory to implement the steps in the training method of the translation model according to any one of claims 1 to 8.