Translation model training method, medium, computer device and program product
By adjusting the translation loss, using the contribution of input word elements to distinguish translation illusions and repeated content, and optimizing the translation model, the quality and efficiency problems of the translation model in processing input information are solved, and the quality and efficiency of translation are improved.
Patent Information
- Application Number
- CN202410872811.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-06-28
AI Technical Summary
Translation models have difficulty distinguishing between duplicate content and translation hallucinations when processing input information, resulting in reduced translation quality and efficiency.
By obtaining the contribution of input word elements to output word elements, the translation loss is adjusted to distinguish translation illusions and repeated content, optimize the training process of the translation model, and reduce misjudgments.
It improves translation quality, reduces misjudgments of translation illusions, and improves translation efficiency and accuracy.
Smart Images

Figure CN118410815B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a training method, medium, computer device, and program product for a translation model. Background Art
[0002] When using a translation model to translate information in a certain language into information in another language, translation hallucination problems may occur. Among them, the translation hallucination problem refers to the appearance of repeated content in the translation results. The translation hallucination problem will lead to reduced quality and efficiency of translation, thereby affecting user experience. In order to reduce the translation hallucination problem, related technologies will train the translation model with the goal of reducing the probability of the translation model outputting repeated content as much as possible. However, repeated content is sometimes not caused by translation hallucinations, but because the input information of the translation model itself includes repeated content. The translation model trained using related technologies cannot distinguish the above two situations well. The repeated content included in the input information itself will be misjudged by the translation model as translation hallucinations and will not be output, resulting in reduced translation quality. Summary of the invention
[0003] In a first aspect, an embodiment of the present disclosure provides a method for training a translation model, the method comprising: obtaining a first translation loss of the translation model, the first translation loss being positively correlated with a probability that a target output word-gram of the translation model and a previous output word-gram of the target output word-gram are the same word-gram, the target output word-gram being a word-gram that the translation model expects to output when translating multiple input words included in input information, and the previous output word-gram being a word-gram obtained by the translation model translating the multiple input words-grams before obtaining the target output word-gram; obtaining a first contribution of the multiple input words-grams to the target output word-gram and a second contribution of the multiple input words-grams to the previous output word-gram; adjusting the first translation loss based on the similarity between the first contribution and the second contribution to obtain a second translation loss of the translation model; and training the translation model based on the second translation loss.
[0004] In a second aspect, an embodiment of the present disclosure provides a method for translating product information, the method comprising: obtaining target product information from an e-commerce platform; obtaining translated product information obtained by translating the target product information using a translation model; the translated product information and the target product information are information in different languages; wherein the translation model is trained based on the method described in any embodiment of the present disclosure.
[0005] In a third aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any embodiment of the present disclosure.
[0006] In a fourth aspect, an embodiment of the present disclosure provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in any embodiment of the present disclosure when executing the program.
[0007] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which implements the method described in any embodiment of the present disclosure when executed by a processor.
[0008] The inventors found that when there is no translation hallucination problem, the contributions of multiple input words in the input information to different output words are different, while when there is a translation hallucination problem, the contributions of multiple input words in the input information to different output words are often similar. Therefore, in the disclosed embodiment, after obtaining the first translation loss of the translation model, the first contribution of multiple input words to the target output word and the second contribution of multiple input words to the previous output word are further obtained, and the first translation loss is adjusted to the second translation loss based on the similarity between the first contribution and the second contribution, and then the translation model is trained based on the second translation loss. The similarity between the first contribution and the second contribution can reflect the probability of the existence of the translation hallucination problem. Therefore, the translation model trained in the above manner can adjust the suppression strength of repeated content based on the probability of the existence of the translation hallucination problem, thereby reducing the misjudgment of translation hallucination and improving the translation quality.
[0009] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The drawings herein are incorporated into the specification and constitute a part of the present disclosure. These drawings illustrate embodiments consistent with the present disclosure and are used to illustrate the technical solutions of the present disclosure together with the specification.
[0011] Figure 1 It is a schematic diagram of an application scenario of an embodiment of the present disclosure.
[0012] Figure 2A and Figure 2B Schematic diagrams comparing contributions of input word units to output word units in the case where there is no translation hallucination problem and there is a translation hallucination problem in the embodiments of the present disclosure.
[0013] Figure 3 It is a projection diagram of the vector corresponding to the output word unit on a two-dimensional plane when there is a translation hallucination problem in the embodiment of the present disclosure.
[0014] Figure 4 It is a flowchart of a method for training a translation model according to an embodiment of the present disclosure.
[0015] Figure 5 It is a schematic diagram of a process of obtaining the similarity between the first contribution and the second contribution in an embodiment of the present disclosure.
[0016] Figure 6 It is a schematic diagram of a method for translating commodity information according to an embodiment of the present disclosure.
[0017] Figure 7 is a schematic diagram of a computer device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0018] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0019] The terms used in this disclosure are only for the purpose of describing specific embodiments and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items. In addition, the term "at least one" herein means any combination of at least two of any one or more of a plurality of.
[0020] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0021] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present disclosure and to make the above-mentioned purposes, features and advantages of the embodiments of the present disclosure more obvious and understandable, the technical solutions in the embodiments of the present disclosure are further described in detail below in conjunction with the accompanying drawings.
[0022] Currently, translation models are widely used in various industries. By adopting translation models, information in a certain language (hereinafter referred to as input information) can be quickly translated into information in another language (hereinafter referred to as output information). Figure 1 The schematic diagram of an e-commerce scenario is shown as an example. Figure 1 As shown, in the e-commerce scenario, buyers can access the e-commerce platform 20 through the terminal 10 and interact with the e-commerce platform 20. For example, the e-commerce platform 20 can push the information of the products on the platform to the terminal 10 for display. In actual applications, the buyers of the e-commerce platform 20 may come from different countries or regions and use different languages. Therefore, the translation model 30 can be deployed in advance, and the information of the products on the e-commerce platform 20 can be translated into the target language used by the buyer through the translation model 30, and then the translated product information can be pushed to the buyer's terminal 10. Among them, the translation model 30 can be deployed on the e-commerce platform 20, or it can be independent of the e-commerce platform 20. For another example, when a buyer on the e-commerce platform 20 communicates with a seller on the e-commerce platform 20, the buyer and the seller may use different languages. The information input by the buyer on the terminal 10 can be sent to the e-commerce platform 20. The e-commerce platform 20 calls the translation model to translate the information, and then forwards the translated information to the seller's terminal 40 for display; or, the information input by the seller through the terminal 40 can be sent to the e-commerce platform 20. The e-commerce platform 20 calls the translation model to translate the information, and then forwards the translated information to the buyer's terminal 10.
[0023] It is understood that the above application scenarios are only illustrative and are not intended to limit the present disclosure. In addition to e-commerce scenarios, the translation model 30 in the embodiment of the present disclosure can also be used in other application scenarios. For example, on a news reading platform, the translation model 30 can be used to translate news published to the news reading platform; on a video playback platform, the translation model 30 can be used to translate subtitles in a video; and so on. For ease of description, the following mainly uses Figure 1 The e-commerce scenario shown is taken as an example to illustrate the solution of the embodiment of the present disclosure.
[0024] The translation model 30 may have a translation hallucination problem during the translation process, that is, repeated content appears in the translation result. In a specific example, assuming that the input information is English and the output information is German, when the input information is "1.8 TonMini Excavator Crawler Excavator Mini Bagger Cheap Price With Ce For Sale EpaCe Iini Excavator", under normal circumstances, if there is no translation hallucination problem, the output information should be "1,8 TonnenMini Bagger Mini Bagger Preis mit Ce Zum Verkauf Epa Ce Mini Bagger", and when there is a translation hallucination problem, the output information may be similar to "1,8 Tonnen Mini Bagger Bagger Bagger Bagger Bagger..." It can be seen that when there is a translation hallucination problem, the output information of the translation model 30 includes multiple repeated "Bagger".
[0025] In order to reduce the problem of translation hallucination, the relevant technology will train the translation model 30 with the goal of reducing the probability of the translation model 30 outputting repeated content as much as possible. However, repeated content is sometimes not caused by translation hallucination, but because the input information of the translation model 30 itself includes repeated content. For example, in the e-commerce scenario, the input information of the translation model 30 often includes product titles. Product titles often do not follow the grammatical rules of normal conversations and present an accumulation of nouns and adjectives. For example, a product title is "4-in-1 Modern Rotating Multifunctional Pool Table 7-foot with Air Hockey Table 4-in-1 Game Table". In the above product title, "4-in-1" and "table" appear many times, and the output information translated by the translation model 30 should also include translation results corresponding to multiple "4-in-1" and multiple "tables" respectively. However, since the translation model 30 is trained with the goal of minimizing the probability of outputting repeated content, even if the input information itself includes repeated content, the translation model 30 will suppress the repetitive content in the output information, resulting in reduced translation quality.
[0026] The inventors have found that, in general, the contribution of multiple input words in the input information to different output words is different, that is, different output words are usually translated from different input words. For example, assuming that the input information is "I like red dress" in English, and the output information is "I like red skirt" in Chinese, and assuming that each English word is an input word and each Chinese character is an output word, then the output word "I" is translated from the input word "I", so the input word "I" has the highest contribution to the output word "I", while the contribution of other input words in the input information to the output word "I" is much smaller than the contribution of the input word "I" to the output word "I". Similarly, the output word "like" is translated from the input word "like", so the contribution of other input words in the input information to the output word "like" is much smaller than the contribution of the input word "like" to the output word "like". Therefore, for any two output words, the contribution of each input word to the two output words is usually different, and the similarity between the contribution of each input word to different output words can reflect the probability of the existence of translation hallucination problem. Figure 2A and Figure 2B The contribution of each input word to the output word is shown in the case where there is no translation hallucination problem and there is a translation hallucination problem. Figure 2A and Figure 2B In , a1~a8 represent input words, b1~b8 represent output words, and the block in the i-th row and j-th column represents the contribution of the input word in the j-th column to the output word in the i-th row. The depth of the block is positively correlated with the contribution represented by the block. Figure 2A As shown in the figure, when there is no translation hallucination problem, the input word that contributes the most to each output word is usually different, showing a one-to-one correspondence between output words and input words; when there is a translation hallucination problem, the contribution of input words to output words is relatively chaotic, and there may be a situation where the contributions of multiple input words to different output words are relatively similar.
[0027] Figure 3 The projection diagram of the vector corresponding to the output word unit on the two-dimensional plane is shown, where each dot represents an output word unit, and the dots in the same ellipse represent the same output word unit. Figure 3 It can be seen that when there is a translation hallucination problem, the translation model 30 will repeatedly generate several identical output tokens. And, it can be seen that Figure 3 The translation information on the right is compared to Figure 3 The translation information on the left has a more serious translation illusion problem. Figure 3 In the translation information on the right, the output word units generated by the translation model 30 are almost all repeated.
[0028] Therefore, the training target of the translation model 30 can be optimized by the similarity between the contributions of multiple input word-grams to different output word-grams, so that the translation model 30 can adjust the suppression strength of repeated content based on the probability of the existence of the translation hallucination problem, thereby reducing the misjudgment of the translation hallucination by the translation model 30. In addition, the present disclosure optimizes the translation model 30 on the training side, which can effectively save reasoning time and improve translation efficiency without increasing the reasoning cost, compared with optimizing the translation model 30 on the reasoning side. The specific scheme of the embodiment of the present disclosure is illustrated below.
[0029] See also Figure 4 Based on this, the present disclosure provides a method for training a translation model 30, the method comprising:
[0030] Step S12: obtaining a first translation loss of the translation model 30, wherein the first translation loss is positively correlated with a probability that a target output word-gram of the translation model 30 and a previous output word-gram of the target output word-gram are the same word-gram, wherein the target output word-gram is a word-gram expected to be output when the translation model 30 translates multiple input word-grams included in the input information, and the previous output word-gram is a word-gram obtained by translating multiple input word-grams by the translation model 30 before obtaining the target output word-gram;
[0031] Step S14: obtaining first contributions of the plurality of input words to the target output word and second contributions of the plurality of input words to the previous output word;
[0032] Step S16: Based on the similarity between the first contribution and the second contribution, the first translation loss is adjusted to obtain a second translation loss of the translation model 30;
[0033] Step S18: Training the translation model 30 based on the second translation loss.
[0034] In step S12, the input information can be input into the translation model 30, and the translation model 30 translates the input information to obtain output information. The input information and the output information can be information in any language, for example, the input information is English information and the output information is German information; or the input information is French information and the output information is Chinese information; or the input information is Chinese information and the output information is German information; and so on. The input information can be text information or information in other modes, such as images or audio. When the input information is an image, optical character recognition (OCR) can be used to extract text information from the image, and then the extracted text information is translated; when the input information is audio, audio recognition can be used to extract text information from the audio, and then the extracted text information is translated. Other models or means independent of the translation model 30 can be used to implement optical character recognition and audio recognition, or the functions of optical character recognition and audio recognition can be directly integrated into the translation model 30.
[0035] The input information may include multiple input tokens, where a token is the basic unit used by the translation model 30 for translation. A character, a word, or a phrase may be used as a token, and a character or a part of a word may be used as a token. For example, for Chinese, the radicals and parts other than radicals in the same Chinese character may be used as different tokens; for another example, for English, the roots and affixes in the same word may be used as different tokens. The input information may be extracted using a pre-trained token extraction model to determine multiple input tokens in the input information. The output information may include multiple output tokens, and the method for determining the output tokens is similar to the method for determining the input tokens, which will not be repeated here.
[0036] During the translation process, the translation model 30 can obtain multiple output word-grams in sequence. The word-gram that the translation model 30 expects to output each time is called the target output word-gram. When obtaining the target output word-gram, the translation model can refer to the previous output word-gram of the target output word-gram. The previous output word-gram of the target output word-gram is the output word-gram obtained by translating multiple input word-grams before the translation model 30 obtains the target output word-gram. For example, when the translation model 30 translates multiple input word-grams, it will first obtain the first output word-gram, and at this time the first output word-gram is the target output word-gram; then, the translation model 30 can use the first output word-gram as context information to continue to translate multiple input word-grams to obtain the second output word-gram. At this time, the second output word-gram is the target output word-gram, and the first output word-gram is the previous output word-gram of the target output word-gram. Similarly, the translation model can continue to translate multiple input word-grams based on the second output word-gram, or based on the first output word-gram and the second output word-gram at the same time, to obtain the third output word-gram. At this time, the third output word-gram is the target output word-gram, and the first output word-gram and the second output word-gram are both previous output word-grams of the target output word-gram.
[0037] In some embodiments, the distance between the previous output word of the target output word and the target output word is less than or equal to a preset distance threshold. That is, in this embodiment, when determining the second translation loss of the translation model 30, only the previous output word that is closer to the target output word is referenced to obtain the target output word. This is because the dependency between the target output word and the previous output word usually decays with the distance between the two. By limiting the distance between the target output word and its previous output word, it is beneficial for the translation model 30 to capture the local correlation between the words, and it can also reduce the amount of calculation in the training process of the translation model 30.
[0038] The first translation loss of the translation model 30 is positively correlated with the probability that the target output word-gram and the previous output word-gram of the target output word-gram are the same word-gram. In some embodiments, when the translation model 30 obtains the target output word-gram, it will respectively calculate the probability of determining multiple candidate output word-grams as the target output word-gram, and determine the candidate output word-gram with the highest probability as the target output word-gram. Among them, the multiple candidate output word-grams may include the previous output word-gram of the target output word-gram. If the probability of determining the previous output word-gram of the target output word-gram as the target output word-gram calculated by the translation model 30 is the largest, the target output word-gram and the previous output word-gram of the target output word-gram are the same word-gram. Therefore, the first translation loss of the translation model 30 can be determined based on the first probability that the previous output word-gram of the target output word-gram is determined as the target output word-gram by the translation model 30. The first translation loss determined in the above manner can suppress the probability of including the same output word-gram in the output information obtained by the translation model 30 as much as possible.
[0039] Furthermore, in addition to the input information, the input to the translation model 30 may also include reference translation information corresponding to the input information. The reference translation information may be obtained by manually translating the input information, or other translation models with better performance than the translation model 30 may be used as teacher models, and the output information obtained by the teacher model translating the input information is determined as the reference translation information corresponding to the input information. The reference translation information may include multiple translation lemmas, and the reference translation information and the output information obtained by the translation model 30 are information in the same language. Since the reference translation information is obtained by manual translation, or by using a translation model with better performance than the translation model 30, the accuracy and reliability of the reference translation information are high, and the reference translation information can be used as the ground truth corresponding to the output information obtained by the translation model 30. When the target output lemma obtained by the translation model 30 is the i-th output lemma in the output information, the translation lemma at the corresponding position in the reference translation information (i.e., the i-th translation lemma in the reference translation information, hereinafter referred to as the target translation lemma) is the ground truth corresponding to the target output lemma. In the case where the translation model 30 obtains output information based on the reference translation information, the first translation loss of the translation model 30 is also inversely correlated with the consistency between the target output word-gram and the target translation word-gram. The second probability that the translation model determines the target translation word-gram corresponding to the target output word-gram as the target output word-gram can be obtained, and the first translation loss of the translation model 30 is jointly determined based on the first probability and the second probability. In the above manner, the output information obtained by the translation model 30 can be made consistent with the reference translation information as much as possible, thereby improving the translation accuracy of the translation model 30.
[0040] In some embodiments, the first translation loss of the translation model 30 may be determined based on the difference between the first probability and the second probability. The first translation loss L0 may be expressed as:
[0041]
[0042] Among them, h t represents the hidden layer state at the current moment (the moment of obtaining the target output word), represents the weight vector corresponding to the previous output word in the weight matrix of the translation model 30, represents the weight vector corresponding to the target output word in the weight matrix of the translation model 30.
[0043] In other embodiments, the difference between the first probability and the second probability may be directly determined as the first translation loss of the translation model 30. Other methods may be used to determine the first translation loss of the translation model 30 based on the first probability and the second probability according to actual needs, which are not listed here.
[0044] In step S14, the first contribution of multiple input words to the target output word and the second contribution of multiple input words to the previous output word of the target output word can be obtained. The contribution of an input word to an output word can characterize the role of the input word in obtaining the output word. The greater the contribution of an input word to an output word, the greater the role of the input word in obtaining the output word, thereby indicating that the output word is mainly obtained by translating the input word. Usually, different output words are translated from different input words. Therefore, when there is no translation hallucination problem, the first contribution of multiple input words to the target output word and the second contribution of multiple input words to the previous output word of the target output word are usually different.
[0045] In step S16, the first translation loss may be adjusted based on the similarity between the first contribution and the second contribution to obtain the second translation loss of the translation model 30. Figure 5 As shown, the input information is the Chinese word "red skirt", and the output information is the English word "red dress". Assuming that each Chinese word is an input word unit and each English word is an output word unit, the input word units include "red" and "skirt", and the output word units include "red" and "dress". When the target output word unit is "dress", the output word unit "red" is the previous output word unit of the target output word unit, and the contribution of the input word units including "red" and "skirt" to the output word unit "red" (i.e., the first contribution) and the contribution of the input word units including "red" and "skirt" to the output word unit "dress" (i.e., the second contribution) can be obtained, and the similarity between the two is calculated, and the second translation loss of the translation model 30 is obtained according to the calculated similarity.
[0046] In some embodiments, the first translation loss can be weighted based on the similarity between the first contribution and the second contribution to obtain the second translation loss of the translation model 30. This embodiment uses the similarity between the first contribution and the second contribution to make a soft decision, that is, the value of the first translation loss is adjusted based on the level of the above similarity, thereby adjusting the suppression strength of repeated word units. When the above similarity is high, the suppression strength of repeated word units is strong; when the above similarity is low, the suppression strength of repeated word units is weak. Compared with the hard decision that only outputs one category prediction result, the similarity output by the soft decision in the embodiment of the present disclosure can be any real number between 0 and 1, which has a wider range of applicable scenarios and higher flexibility. At the same time, if a hard decision is adopted, it is necessary to set a similarity threshold. If the similarity threshold is not set accurately, it is easy to cause the accuracy of the model training results to be low. The soft decision method of the embodiment of the present disclosure avoids the problem of inaccurate model training results caused by inaccurate setting of the similarity threshold.
[0047] In some embodiments, the similarity between the first contribution and the second contribution can be determined in the following manner: determine the first attention matrix based on the first contribution, determine the second attention matrix based on the second contribution, obtain the similarity between the first attention matrix and the second attention matrix, and determine the similarity between the first attention matrix and the second attention matrix as the similarity between the first contribution and the second contribution. Among them, the similarity between the first attention matrix and the second attention matrix can be characterized by the cosine distance between the first attention matrix and the second attention matrix. The similarity between the above-mentioned first attention matrix and the second attention matrix can be used as the weight corresponding to the first translation loss, and the first translation loss can be weighted based on the weight corresponding to the first translation loss to obtain the second translation loss of the translation model 30. The weight corresponding to the first translation loss in some embodiments can be expressed as follows:
[0048]
[0049] in, represents the first attention matrix, represents the second attention matrix, The above method has low implementation complexity and avoids the substantial increase in the complexity and cost of the model training process due to the introduction of similarity calculation between contribution degrees.
[0050] It can be understood that the above method of obtaining the second translation loss is only an exemplary description. In other embodiments, a penalty term may be generated based on the similarity between the first contribution and the second contribution, and the first translation loss and the penalty term may be summed to obtain the second translation loss of the translation model 30. Alternatively, other methods may be used to obtain the second translation loss of the translation model 30, which will not be listed here one by one.
[0051] In some embodiments, in addition to adjusting the first translation loss using the similarity between the first contribution and the second contribution, since the target output word is less affected by the previous output word that is far away from itself, the first translation loss can also be adjusted based on the distance between the target output word and the previous output word of the target output word. Specifically, the second translation loss obtained by adjusting the first translation loss based on the similarity between the first contribution and the second contribution can be used as the intermediate translation loss of the translation model 30, and then the intermediate translation loss is adjusted based on the distance between the target output word and the previous output word of the target output word to obtain the second translation loss of the translation model 30. In this way, the influence of the previous output word that is far away from the target output word on the target output word obtained by the translation model 30 can be reduced, so that the translation model 30 can better capture the local correlation between output words that are close to each other.
[0052] For example, the intermediate translation loss can be weighted based on the distance between the target output word-gram and the previous output word-gram of the target output word-gram to obtain the second translation loss of the translation model 30. In this embodiment, a soft decision is made based on the distance between the target output word-gram and the previous output word-gram of the target output word-gram, that is, the value of the intermediate translation loss is adjusted based on the size of the above distance, thereby adjusting the suppression strength of repeated word-grams. When the above distance is large, the suppression strength of repeated word-grams is strong; when the above distance is small, the suppression strength of repeated word-grams is weak. Compared with hard decisions, the above soft decision method is more applicable to a wider range of scenarios and has higher flexibility, while also avoiding the low accuracy of the model training results caused by inaccurate threshold setting. It can be understood that weighting the intermediate translation loss to obtain the second translation loss is only an optional way to determine the second translation loss. In other embodiments, the penalty term can also be determined based on the above distance, and the sum of the intermediate translation loss and the penalty term is determined as the second translation loss, or the second translation loss is determined by other methods, which are not listed here one by one.
[0053] In the embodiment of weighting the intermediate translation loss to obtain the second translation loss, an exponential operation may be performed on the distance between the target output word-gram and the previous output word-gram of the target output word-gram to obtain a weight corresponding to the intermediate translation loss, and the intermediate translation loss is weighted based on the weight corresponding to the intermediate translation loss to obtain the second translation loss of the translation model 30. The weight corresponding to the intermediate translation loss may be recorded as:
[0054]
[0055] in, represents the weight corresponding to the intermediate translation loss, t represents the position of the target output word, represents the position of the previous output word of the target output word, and T represents the temperature coefficient.
[0056] In the actual translation process, the number of previous output words of the target output word may be greater than or equal to 1. When the number of previous output words of the target output word is greater than 1, the first translation loss of the translation model 30 includes the translation losses corresponding to the multiple previous output words, and the second contribution of the multiple input words to the previous output word includes the contribution of the multiple input words to the multiple previous output words. The translation loss corresponding to the previous output word is positively correlated with the probability that the translation model 30 determines the previous output word as the target output word.
[0057] For example, when the target output word is the third output word in the output information, the previous output word of the target output word includes the first output word and the second output word in the output information, so that the first translation loss of the translation model 30 includes the translation loss corresponding to the first output word in the output information and the translation loss corresponding to the second output word in the output information. The second contribution of the multiple input words to the previous output word includes the contribution of the multiple input words to the first output word in the output information and the contribution of the multiple input words to the second output word in the output information.
[0058] The translation losses corresponding to the multiple previous output words can be summed up to obtain the second translation loss of the translation model 30. The translation loss corresponding to the i-th previous output word among the multiple previous output words is determined based on the following method: based on the first contribution and the similarity between the contributions of the multiple input words to the i-th previous output word, the translation loss corresponding to the i-th previous output word is adjusted to obtain the translation loss corresponding to the i-th previous output word. Continuing with the previous example, based on the first contribution and the similarity between the contributions of the multiple input words to the first output word in the output information, the translation loss corresponding to the first output word in the output information can be adjusted to obtain the translation loss corresponding to the first output word in the output information. Similarly, based on the similarity between the first contribution and the contributions of the multiple input words to the second output word in the output information, the translation loss corresponding to the second output word in the output information can be adjusted to obtain the translation loss corresponding to the second output word in the output information. By summing the translation loss corresponding to the first output word unit in the output information and the translation loss corresponding to the second output word unit in the output information, the second translation loss of the translation model 30 can be obtained. The second translation loss of the translation model 30 in some embodiments can be specifically recorded in the following form:
[0059]
[0060] in, represents the second translation loss of translation model 30, represents the previous output word of the target output word, represents the set of previous output tokens of the target output token, represents the weight corresponding to the intermediate translation loss, represents the weight corresponding to the first translation loss, represents the hidden layer state at the current moment (the moment of obtaining the target output word), represents the weight vector corresponding to the previous output word in the weight matrix of the translation model 30, represents the weight vector corresponding to the target output word in the weight matrix of the translation model 30.
[0061] It can be understood that the above formula is only an optional way to calculate the second translation loss of the translation model 30. In other examples, other ways can also be used to calculate the second translation loss of the translation model 30. For example, only the weight Weight the first translation loss instead of taking the weight Weight The weighted results are weighted twice.
[0062] In practical applications, there are multiple target output word units, and the second translation loss corresponding to each target output word unit of the translation model 30 can be determined in the above manner. , for each second translation loss obtained The sum is performed to obtain a final translation loss, and the translation model 30 is trained based on the final translation loss.
[0063] In step S18 , the weight of the translation model 30 may be adjusted to minimize the second translation loss of the translation model 30 obtained in step S6 .
[0064] It can be understood that in addition to the second translation loss obtained in the foregoing, the translation model 30 in the embodiment of the present disclosure can also be obtained by training in combination with the third translation loss. The third translation loss can be set according to actual needs and is not limited here. In some embodiments, the third translation loss is a cross-entropy (CE) loss. The second translation loss and the third translation loss can be weighted to obtain a weighted loss, and the translation model 30 can be trained based on the weighted loss. The weights when the second translation loss and the third translation loss are weighted can be pre-set as hyperparameters in the training process of the translation model 30. In some embodiments, when determining the second translation loss, only the previous output word that is closer to the target output word can be referenced, and when determining the third translation loss, all output word units in the output information can be referenced.
[0065] In the above embodiment, multiple input word units can be extracted from sample product information, the sample product information can be obtained from an e-commerce platform, and the sample product information includes at least two identical words. Among them, the sample product information can be a product title or the attribute information of the product. Taking the product title as an example, the product title of the e-commerce platform usually includes some repetitive words. For example, in the product title "4-in-1 Modern Rotating Multifunctional Pool Table 7-foot with Air Hockey Table 4-in-1 Game Table", "table" is a repetitive word. When the translation model is translating, the "table" that appears multiple times in the product title should be translated, but if the training method in the relevant technology is adopted, the trained model will mistakenly think that the "table" that appears multiple times has a translation illusion and suppresses it, resulting in reduced translation quality. By adopting the means of the embodiment of the present disclosure, it is possible to effectively distinguish between the translation illusion and the repetitive content originally existing in the input information, reduce unnecessary suppression of repetitive content, and improve translation quality. The method of the embodiment of the present disclosure can be integrated into the self-developed translation training link, greatly reducing the translation illusion problem of input information with repetitive content such as title information, and at the same time reducing the misjudgment of translation illusion.
[0066] See also Figure 6 The present disclosure also provides a method for translating product information, the method comprising:
[0067] Step S22: Obtain target product information from the e-commerce platform;
[0068] Step S24: obtaining translated product information obtained by translating the target product information by the translation model 30; the translated product information and the target product information are in different languages;
[0069] The translation model 30 is trained based on the method described in any embodiment of the present disclosure.
[0070] The translation method of the disclosed embodiment can be used to translate the target product information of the e-commerce platform to obtain high-quality translation results. The target product information can be the product title or the attribute information of the product. The training process of the translation model 30 can refer to the above embodiment and will not be repeated here.
[0071] An embodiment of the present disclosure further provides a computer device, which at least includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in any of the above embodiments is implemented.
[0072] Figure 7A more specific hardware structure diagram of a computer device provided by an embodiment of the present disclosure is shown, and the device may include: a processor 202, a memory 204, an input / output interface 206, a communication interface 208, and a bus 210. The processor 202, the memory 204, the input / output interface 206, and the communication interface 208 are connected to each other through the bus 210 in the device.
[0073] The processor 202 can be implemented by a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided by the embodiments of the present disclosure. The processor 202 can also include a graphics card, which can be a Nvidia titan X graphics card or a 1080Ti graphics card, etc.
[0074] The memory 204 may be implemented in the form of a read-only memory (ROM), a random access memory (RAM), a static storage device, a dynamic storage device, etc. The memory 204 may store an operating system and other application programs. When the technical solution provided by the embodiment of the present disclosure is implemented by software or firmware, the relevant program code is stored in the memory 204 and is called and executed by the processor 202.
[0075] The input / output interface 206 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0076] The communication interface 208 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0077] The bus 210 comprises a pathway for transmitting information between the various components of the device, such as the processor 202 , the memory 204 , the input / output interface 206 , and the communication interface 208 .
[0078] It should be noted that, although the above device only shows the processor 202, the memory 204, the input / output interface 206, the communication interface 208 and the bus 210, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present disclosure, and does not necessarily include all the components shown in the figure.
[0079] An embodiment of the present disclosure provides a computer program product, including a computer program. When the computer program is executed by a processor, the method described in any embodiment of the present disclosure is implemented.
[0080] The present disclosure also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described in any of the above embodiments is implemented.
[0081] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computer device. As defined in this article, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0082] Each embodiment in the present disclosure is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device embodiment described above is merely schematic, wherein the modules described as separate components may or may not be physically separated, and the functions of each module can be implemented in the same one or more software and / or hardware when implementing the embodiment of the present disclosure. It is also possible to select some or all of the modules according to actual needs to achieve the purpose of the embodiment. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0083] The above is only a specific implementation of the embodiment of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the embodiment of the present disclosure. These improvements and modifications should also be regarded as the protection scope of the embodiment of the present disclosure.
Claims
1. A method for training a translation model, the method comprising: Obtaining a first translation loss of a translation model, wherein the first translation loss is positively correlated with a probability that a target output word-gram of the translation model and a previous output word-gram of the target output word-gram are the same word-gram, wherein the target output word-gram is a word-gram expected to be output when the translation model translates multiple input word-grams included in the input information, and the previous output word-gram is a word-gram obtained by the translation model by translating the multiple input word-grams before obtaining the target output word-gram; Acquire a first contribution of the plurality of input word-grams to the target output word-gram and a second contribution of the plurality of input word-grams to the previous output word-gram; Based on the similarity between the first contribution and the second contribution, adjusting the first translation loss to obtain a second translation loss of the translation model; The translation model is trained based on the second translation loss.
2. According to the method of claim 1, the target output word-gram is the target translation word-gram in the reference translation information corresponding to the input information, the previous output word-gram is the translation word-gram in the reference translation information that is located before the target translation word-gram, and the position of the target translation word-gram in the reference translation information corresponds to the position of the target output word-gram in the output information including the target output word-gram and its previous output word-gram.
3. According to the method of claim 2, the step of obtaining the first translation loss of the translation model comprises: Obtaining a first probability that the translation model determines the previous output word-gram as the target output word-gram, and a second probability that the translation model determines the target translation word-gram as the target output word-gram; A first translation loss of the translation model is determined based on a difference between the first probability and the second probability.
4. According to the method of claim 1, the number of the previous output word-grams is greater than 1; the first translation loss of the translation model includes the translation losses corresponding to the multiple previous output word-grams respectively, and the translation losses corresponding to the previous output word-grams are positively correlated with the probability that the translation model determines the previous output word-gram as the target output word-gram; the second contribution of the multiple input word-grams to the previous output word-grams includes the contribution of the multiple input word-grams to the multiple previous output word-grams respectively; The adjusting the first translation loss based on the similarity between the first contribution and the second contribution to obtain the second translation loss of the translation model includes: For any one of the multiple previous output word-grams, based on the similarity between the first contribution and the contribution of the multiple input word-grams to the previous output word-gram, adjusting the translation loss corresponding to the previous output word-gram to obtain the translation loss corresponding to the previous output word-gram; The translation losses corresponding to the multiple previous output word-units are summed to obtain a second translation loss of the translation model. 5 . The method according to claim 1 , wherein the distance between the target output word-gram and a previous output word-gram of the target output word-gram is less than or equal to a preset distance threshold.
6. The method according to claim 1, wherein adjusting the first translation loss based on the similarity between the first contribution and the second contribution to obtain the second translation loss of the translation model comprises: Based on the similarity between the first contribution and the second contribution, adjusting the first translation loss to obtain an intermediate translation loss of the translation model; The intermediate translation loss is adjusted based on the distance between the target output word-gram and the previous output word-gram to obtain a second translation loss of the translation model.
7. The method according to claim 6, wherein adjusting the first translation loss based on the similarity between the first contribution and the second contribution to obtain the intermediate translation loss of the translation model comprises: Based on the similarity between the first contribution and the second contribution, the first translation loss is weighted to obtain an intermediate translation loss of the translation model.
8. The method according to claim 7, further comprising: Determining a first attention matrix based on the first contribution; determining a second attention matrix based on the second contribution; Obtain the similarity between the first attention matrix and the second attention matrix, and determine the similarity between the first attention matrix and the second attention matrix as the similarity between the first contribution and the second contribution.
9. The method according to claim 6, wherein the adjusting the intermediate translation loss based on the distance between the target output word-gram and the previous output word-gram to obtain the second translation loss of the translation model comprises: The intermediate translation loss is weighted based on the distance between the target output word-gram and the previous output word-gram to obtain a second translation loss of the translation model.
10. The method according to claim 9, wherein the step of weighting the intermediate translation loss based on the distance between the target output word-gram and the previous output word-gram to obtain the second translation loss of the translation model comprises: Performing an exponential operation on the distance between the target output word-gram and the previous output word-gram to obtain a weight corresponding to the intermediate translation loss; The intermediate translation loss is weighted based on the weight corresponding to the intermediate translation loss to obtain a second translation loss of the translation model.
11. According to the method of claim 1, the multiple input word units are extracted from sample product information, the sample product information is obtained from an e-commerce platform, and the sample product information includes at least two identical words.
12. A method for translating commodity information, the method comprising: Obtain target product information from the e-commerce platform; Obtain translated product information obtained by translating the target product information using a translation model; The translated product information and the target product information are in different languages; Wherein, the translation model is trained based on the method described in any one of claims 1 to 11.
13. A computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
14. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 12 when executing the program.
15. A computer program product, comprising a computer program, which implements the method according to any one of claims 1 to 12 when executed by a processor.
Citation Information
Patent Citations
Translation processing method and device based on dynamic window
CN110276082A
Translation model training method and device and translation method and device
CN112597778A
Machine translation model training method and device, machine translation method and device and computing equipment
CN115130534A
Translation method, translation model generation method and related equipment
CN117010416A
Translation model training method and device, translation method and device, electronic equipment and medium
CN117574924A
