Translation method, translation model generation method, and related device

CN117010416BActive Publication Date: 2026-10-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211351649.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-31
Publication Date
2026-10-27
Estimated Expiration
2042-10-31

AI Technical Summary

Technical Problem

[0004]本公开提供了一种翻译方法、翻译模型的生成方法及相关设备,以解决现有技术中至少一种技术问题

Benefits of technology

[0031]本公开实施例通过经训练的翻译模型先对实时输入文本中待翻译的当前词语进行翻译处理,再次利用该翻译模型中的第一解码器和第二解码器对第一词语、第一解码器和第二解码器上次分别针对该当前词语进行翻译处理所输出的第一隐藏状态信息和第二隐藏状态进行处理,得到第二词语的翻译词语并输出;该第一词语包括当前词语和在当前词语的词语位置之前的至少一个目标源词语,第二词语是经第一解码器预测得到的当前词语的下一个源词语;将输入文本中与第二词语的词语位置对应的源词语的下一个源词语作为当前词语,返回调用经训练的翻译模型对当前词语进行翻译处理的步骤,直至输出输入文本中各源词语对应的翻译词语。从而无需等待实时输入文本的下一个源词语,也无需按源词语顺序读取各源词语进行额外的编码处理,更好的提升同步机器翻译的性能,在保证翻译质量的同时,进一步降低同步翻译延迟。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117010416B_ABST
    Figure CN117010416B_ABST
Patent Text Reader

Abstract

The disclosure provides a translation method, a translation model generation method and related equipment, which can be applied to various scenes such as cloud technology, artificial intelligence, intelligent transportation and auxiliary driving. The method first translates the current word to be translated in the real-time input text by using the trained translation model, then processes the hidden state information output by the first decoder and the second decoder in the translation model respectively for the current word by using the first word including the current word, the first decoder and the second decoder, and obtains the translation word of the second word, which is the next source word of the current word predicted by the first decoder; the next source word of the source word corresponding to the second word is taken as the current word, and the step of translating the current word is returned until the translation is completed, thereby improving the performance of synchronous machine translation and reducing the synchronous translation delay.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computers, and in particular to a translation method, a method for generating translation models, and related equipment. Background Technology

[0002] Simultaneous Machine Translation (SiMT) is a subtask of machine translation. It starts by reading incomplete source text and gradually produces translations to quickly translate a continuously input stream of text into another language.

[0003] In related technologies, the mainstream translation models for the target audience all adopt the encoder-decoder architecture of the Transformer model to realize translation tasks. However, existing translation models have certain technical bottlenecks in reducing translation latency while ensuring translation quality. Summary of the Invention

[0004] This disclosure provides a translation method, a translation model generation method, and related equipment to solve at least one technical problem in the prior art.

[0005] On the one hand, this disclosure provides a translation method, including:

[0006] Obtain real-time input text and determine the current word to be translated from the input text;

[0007] The trained translation model is invoked to translate the current word, and intermediate processing results corresponding to the current word and the translated word of the current word are obtained and output; the intermediate processing results include the first hidden state information output by the first decoder and the second hidden state information output by the second decoder in the translation model;

[0008] The first decoder and the output decoding module of the translation model containing the second decoder are invoked to process the first word, the first hidden state information and the second hidden state information to obtain the translated word of the second word and output it; the first word includes the current word and at least one target source word before the word position of the current word, and the second word is the next source word of the current word predicted by the first decoder;

[0009] The next source word corresponding to the word position of the second word in the input text is taken as the current word, and the step of calling the trained translation model to translate the current word is returned until the translated words corresponding to each source word in the input text are output.

[0010] On the other hand, it also provides a method for generating translation models, including:

[0011] Obtain a training sample set, which includes training source text and expected translation sample words corresponding to each sample source word in the training text;

[0012] The current sample word to be translated is determined from the training source text, and the translation model is called to translate the current sample word to obtain the intermediate sample processing result corresponding to the current sample word, as well as the predicted translation sample word of the current sample word; the intermediate sample processing result includes the first sample hidden state information output by the first decoder and the second sample hidden state information output by the second decoder in the translation model;

[0013] The first decoder and the output decoding module of the translation model containing the second decoder are invoked to process the first sample word, the first sample hidden state information and the second sample hidden state information to obtain the predicted translation sample word of the second sample word; the first sample word includes the current sample word and at least one target sample source word input before the current sample word, and the second sample word is the next sample source word of the current sample word predicted by the first decoder;

[0014] The next source word of the source word corresponding to the word position of the second sample word in the input sample text is taken as the current sample word. The step of calling the translation model to translate the current sample word is returned until the translated words corresponding to each source word in the training source text are obtained.

[0015] Based on the predicted translation sample words and the corresponding expected translation sample words for each sample source word in the training source text, the translation model is trained to obtain the trained translation model.

[0016] On the other hand, a translation device is also provided, including:

[0017] The text acquisition module is used to acquire real-time input text and determine the current word to be translated from the input text;

[0018] The first processing module is used to call the trained translation model to translate the current word, obtain the intermediate processing result corresponding to the current word, and output the translated word of the current word; the intermediate processing result includes the first hidden state information output by the first decoder in the translation model and the second hidden state information output by the second decoder.

[0019] The second processing module is used to call the first decoder and the output decoding module of the translation model containing the second decoder to process the first word, the first hidden state information and the second hidden state information to obtain the translated word of the second word and output it; the first word includes the current word and at least one target source word before the word position of the current word, and the second word is the next source word of the current word predicted by the first decoder;

[0020] The iterative translation module is used to take the next source word of the source word corresponding to the word position of the second word in the input text as the current word, return to the step of calling the trained translation model to translate the current word, until the translated words corresponding to each source word in the input text are output.

[0021] On the other hand, it also provides a device for generating translation models, including :

[0022] The training data module is used to acquire a training sample set, which includes training source text and expected translation sample words corresponding to each sample source word in the training text.

[0023] The first training processing module is used to determine the current sample word to be translated from the training source text, call the translation model to translate the current sample word, and obtain the intermediate sample processing result corresponding to the current sample word, as well as the predicted translation sample word of the current sample word; the intermediate sample processing result includes the first sample hidden state information output by the first decoder in the translation model and the second sample hidden state information output by the second decoder.

[0024] The second training processing module is used to call the first decoder and the output decoding module of the translation model containing the second decoder to process the first sample word, the first sample hidden state information and the second sample hidden state information to obtain the predicted translation sample word of the second sample word; the first sample word includes the current sample word and at least one target sample source word input before the current sample word, and the second sample word is the next sample source word of the current sample word predicted by the first decoder;

[0025] The model training module is used to take the next sample source word of the sample source word corresponding to the word position of the second sample word in the input sample text as the current sample word, and return to the step of calling the translation model to translate the current sample word, until the translated words corresponding to each sample source word in the training source text are obtained;

[0026] The model generation module is used to train the translation model based on the predicted translation sample words and the corresponding expected translation sample words corresponding to each sample source word in the training source text, so as to obtain the trained translation model.

[0027] On the other hand, an electronic device is also provided, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement any of the translation methods or translation model generation methods described above.

[0028] On the other hand, a computer-readable storage medium is also provided, wherein at least one instruction or at least one program is stored therein, the at least one instruction or the at least one program being loaded and executed by a processor to implement any of the translation methods or translation model generation methods described above.

[0029] On the other hand, a computer program product or computer program is also provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the translation methods or translation model generation methods described above.

[0030] The translation method, translation model generation method, and related equipment disclosed herein have the following technical effects:

[0031] This embodiment first translates the current word to be translated in the real-time input text using a trained translation model. Then, it uses the first and second decoders in the model to process the first word, the first hidden state information output by the first and second decoders respectively during the previous translation of the current word, to obtain and output the translated word for the second word. The first word includes the current word and at least one target source word preceding the current word's position. The second word is the next source word predicted by the first decoder. The next source word corresponding to the second word's position in the input text is taken as the current word. The process of calling the trained translation model to translate the current word is repeated until the translated words corresponding to each source word in the input text are output. This eliminates the need to wait for the next source word in the real-time input text and avoids additional encoding processing of source words in order, thus improving the performance of synchronous machine translation and further reducing synchronous translation latency while ensuring translation quality. Attached Figure Description

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

[0033] Figure 1 This is a schematic diagram illustrating the application environment of a translation method provided in this embodiment.

[0034] Figure 2 This is a flowchart illustrating a translation method provided in an embodiment of this disclosure;

[0035] Figure 3 This is a partial flowchart illustrating a translation method provided in an embodiment of this disclosure;

[0036] Figure 4 This is a partial flowchart illustrating a translation method provided in an embodiment of this disclosure;

[0037] Figure 5 This is a flowchart illustrating a method for generating a translation model according to an embodiment of this disclosure;

[0038] Figure 6 This is a schematic diagram illustrating the training process of a translation model provided in an embodiment of this disclosure;

[0039] Figure 7 This is a schematic diagram illustrating the training process of another translation model provided in this embodiment of the disclosure;

[0040] Figure 8 This is a structural block diagram of a translation device provided in an embodiment of this disclosure;

[0041] Figure 9 This is a structural block diagram of a translation model generation device provided in an embodiment of this disclosure;

[0042] Figure 10 This is a schematic diagram of the hardware structure of an electronic device for implementing the methods provided in the embodiments of this disclosure. Detailed Implementation

[0043] To enable those skilled in the art to better understand the present disclosure, the technical solutions of the present disclosure will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present disclosure, and not all embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present disclosure.

[0044] To make the objectives, technical solutions, and advantages of this disclosure clearer, the embodiments of this disclosure will be described in further detail below with reference to the accompanying drawings.

[0045] To facilitate understanding of the technical solutions described above and their resulting technical effects in the embodiments of this disclosure, the terms used in the embodiments of this disclosure are briefly introduced as follows:

[0046] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.

[0047] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.

[0048] With the research and advancement of artificial intelligence (AI) technology, AI is being studied and applied in various fields, such as smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, autonomous driving, drones, robots, smart healthcare, and smart customer service. It is believed that with the development of technology, AI will be applied in more fields and play an increasingly important role.

[0049] Enabling computers to hear, see, speak, and feel represents the future direction of human-computer interaction. Natural Language Processing (NLP) is a crucial area within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language people use in daily life—and thus has a close connection to linguistic research. NLP technologies typically include machine translation, text preprocessing, semantic understanding, question answering, and knowledge graphs.

[0050] In the field of natural language processing, machine translation (MT), also known as automatic translation, refers to the process of using computers to convert one natural language (source language) into another natural language (target language). It is a branch of computational linguistics and one of the ultimate goals of artificial intelligence, possessing significant scientific research value. Simultaneously, machine translation also has important practical value. With economic globalization and the rapid development of the internet, machine translation technology plays an increasingly important role in promoting economic and cultural exchange. Deep learning-based translation models have achieved considerable success in machine translation. The technical solutions provided in this application relate to artificial intelligence-based machine translation and other technologies, which will be described in detail below.

[0051] Simultaneous Machine Translation (SiMT) is a type of machine translation that rapidly translates a continuously input stream of text into another natural language by starting with an incomplete source text and gradually generating a translation structure.

[0052] The Transformer is an encoder-decoder framework based on a SAN network, belonging to the sequence-to-sequence generation model structure.

[0053] Bilingual Evaluation Understudy (BLEU) is an evaluation metric in machine translation models. A higher BLEU value indicates a better translation performance of the machine translation model.

[0054] Average Delay (AL) is an evaluation metric for machine translation models. The lower the AL value, the lower the translation delay of the machine translation model.

[0055] The solutions provided in this disclosure relate to technologies such as computer vision and machine learning in artificial intelligence, and are specifically illustrated through the following embodiments:

[0056] The translation method disclosed herein can be applied to, for example... Figure 1 The application environment shown. For example... Figure 1 As shown, the application environment may include at least terminal 110 and server 120.

[0057] Terminal 110 can be used to provide real-time input text, send a translation request carrying the input text to the server, and the server responds to the translation request by translating the input text in real time and sending the translated words to terminal 110 for display.

[0058] The aforementioned terminals 110 include, but are not limited to, mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc.

[0059] The aforementioned server 120 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal and server can be connected directly or indirectly via wired or wireless communication, and this disclosure does not impose any limitations. It should be noted that the aforementioned server 120 can be implemented as a cloud server in the cloud.

[0060] In some embodiments, the server 120 can also be implemented as a node in a blockchain system. Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.

[0061] It should be noted that, in practical applications, the translation method provided in this disclosure can be implemented in a server or a terminal, or jointly by a terminal and a server. This disclosure can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving.

[0062] Of course, the methods provided in this disclosure are not limited to... Figure 1 The hardware environment shown can also be used in other possible hardware environments, and this disclosure does not limit the scope of the embodiments. Figure 1 The functions that each device in the hardware environment shown can perform will be described in subsequent method embodiments, and will not be elaborated on here.

[0063] Figure 2 This is a flowchart illustrating a translation method provided in an embodiment of this disclosure. This disclosure provides the operational steps of the method described in the embodiments or flowcharts, but based on conventional or non-inventive labor, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many steps and does not represent the only possible execution order. The executing entity of this translation method can be the translation device provided in the embodiments of this disclosure, or an electronic device integrating the translation device, wherein the translation device can be implemented in hardware or software. Taking the executing entity as described above... Figure 1 Taking the server in the example of this, such as Figure 2 As shown, the method may include:

[0064] S201: Obtain a real-time input text, and determine a current word to be translated from the input text.

[0065] Herein, the input text may be a source-side sentence that is input in real time by a user and needs to be translated. Since the input text is input in real time, the input text may include an incomplete sentence that is being continuously input. The current word refers to the word that needs to be translated at the current time step. The word herein is a general term for words and phrases, which includes words (including individual words and compound words) and word groups (also called phrases), and is the smallest unit of word combination structure that constitutes sentences and articles.

[0066] Optionally, the terminal may send a translation request to the server in response to the user inputting text in real time in a target area. In response to the translation request, the server obtains the real-time input text, performs word segmentation processing on the currently visible text content in the input text to obtain at least one word, and takes the at least one word as the current word to be translated. The target area is related to the application scenario, for example, the target area may include, but is not limited to, a translation box, a dialog box of a translation application, a chat box, a search box, a text editing area of other applications with translation functions, and the like. For example, if the current real-time input text is "我们将", it is determined that the current words include the two words "我们" and "将".

[0067] S203: Invoke a trained translation model to perform translation processing on the current word, obtain an intermediate processing result corresponding to the current word, as well as a translated word of the current word and output the translated word; the intermediate processing result includes first hidden state information output by a first decoder and second hidden state information output by a second decoder in the translation model.

[0068] Optionally, the server inputs word vector information corresponding to the current word into the trained translation model, performs translation processing on the word vector information of the current word through the translation model, obtains the intermediate processing result corresponding to the current word, as well as the translated word of the current word, and outputs the translated word. For example, taking Chinese-to-English translation as an example, if the current words include the two words "我们" and "将", the output translated words corresponding to the current words may be "We" and "will" respectively.

[0069] The translation model is a pre-trained neural network model. Optionally, the translation model may include an input decoding module and an output decoding module, wherein the input decoding module includes a first decoder and a prediction output module, and the output decoding module includes a second decoder and a translation output module. The network structures of the first decoder and the second decoder are similar to those of the decoder in the Transformer model, but the network parameters of the first decoder and the second decoder are different. For example, the number of first decoders and second decoders can be N, and each decoder may include a masked self-attention layer, a cross-attention layer, and a feedforward layer.

[0070] The intermediate processing results are the intermediate outputs of each decoding module in the translation model during the translation of the current word. These intermediate processing results include the first hidden state information output by the first decoder and the second hidden state information output by the second decoder. The first hidden state information is output by the last of the multiple first decoders and is used to characterize the semantic information of the current word in the input text. Specifically, the first hidden state information may include the word vector information of the current word input to the first decoder and the hidden dependency information between the current word and other words preceding it. The second hidden state information is output by the last of the multiple second decoders and is used to characterize the semantic information of the translated word. Specifically, the second hidden state information may include the word vector information of the predicted translated word and the hidden dependency information between the predicted translated word and other predicted translated words preceding it.

[0071] In an alternative implementation, such as Figure 3 As shown, the above-mentioned call to the trained translation model to translate the current word, obtains the intermediate processing result corresponding to the current word, and outputs the translated word of the current word, including:

[0072] S301: Call the first decoder in the trained translation model to encode the current word and obtain the first hidden state information output by the first decoder.

[0073] Optionally, the server inputs the word vector information corresponding to the current word into the first decoder in the translation model, and encodes the word vector information of the current word through the first decoder to obtain the first hidden state information output by the first decoder.

[0074] In one optional implementation, the above-mentioned invocation of the first decoder in the trained translation model to encode the current word and obtain the first hidden state information output by the first decoder includes:

[0075] S3011: Call the first mask self-attention layer in the first decoder to perform self-attention processing on the word vector information corresponding to the current word to obtain the first attention processing information; the first attention processing information is used to point to the first cross attention layer in the first decoder.

[0076] S3013: At the current time step, the first attention processing information is passed through the first cross-attention layer to the first feedforward layer in the first decoder. The first feedforward layer transforms the first attention processing information to obtain the first hidden state information output by the first decoder.

[0077] Optionally, the first decoder includes a first masked self-attention layer, a first cross-attention layer, and a first feedforward layer. During the first decoding process for the current word at the current time step, the server inputs the current word into the embedding layer for embedding representation processing, and then inputs the resulting word vector information corresponding to the current word into the first masked self-attention layer for self-attention mechanism processing to obtain the first attention processing information. This first masked self-attention layer is a masked multi-head attention layer, used to obtain the intrinsic relationships between the input word vectors from multiple representation spaces. This first masked self-attention layer only focuses on words input before the current time step, while masking words input after the current time step.

[0078] The first attention processing information is used to direct the first cross-attention layer in the first decoder. During the encoding process at the current time step, since the first cross-attention layer detects that there is no hidden state information input from other decoders, it passes the acquired first attention processing information through the first cross-attention layer to the first feedforward layer in the first decoder. That is, it skips the first cross-attention layer, does not perform the corresponding operations, and directly transforms the first attention processing information to obtain the first hidden state information output by the first decoder. The first feedforward layer performs a fully connected operation on the first attention processing information output from the attention layer of the first mask, using the output of the last decoder among multiple first decoders as the first hidden state information.

[0079] It should be understood that a residual structure can be set after the first mask, the first attention layer, the first cross-attention layer, and the first feedforward layer. The input and output of each layer are residually connected through this residual structure, and then normalized before being input into the next layer.

[0080] S303: Call the output decoding module to perform the first decoding process on the first hidden state information and the already obtained translation words, obtain the second hidden state information output by the second decoder, and output the translation words of the current word.

[0081] Optionally, the server inputs the first hidden state information and the word vector information corresponding to the already obtained translated words into the output decoding module. The second decoders in this output decoding module perform the first decoding process to obtain the first hidden state information output by the first decoder, and then output the translated word for the current word. Here, the already obtained translated words refer to the currently predicted translated words.

[0082] In an optional implementation, the aforementioned call output decoding module performs a first decoding process on the first hidden state information and the already obtained translated words to obtain the second hidden state information output by the second decoder, and outputs the translated words of the current word, including:

[0083] The second mask self-attention layer in the second decoder of the output decoding module is called to perform self-attention processing on the word vector information corresponding to the already obtained translated words, and obtain the second attention processing information.

[0084] The second cross-attention layer in the second decoder is invoked to perform cross-attention processing on the first hidden state information and the second attention processing information to obtain the third attention processing information.

[0085] The second feedforward layer in the second decoder is invoked to transform the third attention processing information, thereby obtaining the second hidden state information output by the second decoder; the second hidden state information is used to point to the first cross attention layer of the first decoder.

[0086] The translation output module in the output decoding module is called to perform translation prediction on the second hidden state information and output the translated word of the current word.

[0087] Optionally, the output decoding module includes a second decoder and a translation output module. The second decoder includes a second masked self-attention layer, a second cross-attention layer, and a second feedforward layer. During the second decoding process at the current time step, the server inputs the already obtained translated words into the embedding layer for embedding representation processing, and then inputs the word vector information corresponding to the obtained translated words into the second masked self-attention layer for self-attention mechanism processing to obtain the second attention processing information. This second masked self-attention layer is a masked multi-head attention layer, used to obtain the intrinsic relationships between the already obtained translated words from multiple representation spaces. This second masked self-attention layer only focuses on the already obtained translated words before the current time step, while masking the translated words obtained after the current time step.

[0088] Next, the first hidden state information and the second attention processing information are input into the second cross-attention layer for cross-attention processing to obtain the third attention processing information. This third attention processing information is then input into the second feedforward layer for transformation processing to obtain the second hidden state information output by the second decoder. This second hidden state information is used to point to the first cross-attention layer of the first decoder. Finally, the second hidden state information is input into the translation output module for translation prediction, outputting the translated word for the current word.

[0089] Similar to the second mask self-attention layer, the second cross-attention layer, in addition to acquiring the output of the second attention processing information, also acquires the first hidden state information output by the corresponding first decoder. The second feedforward layer performs a fully connected operation on the third attention processing information output by the first cross-attention layer, using the output of the last decoder among the multiple second decoders as the second hidden state information. This second hidden state information is used to point to the first cross-attention layer of the first decoder; that is, the second hidden state information output by the second decoder is input to the first cross-attention layer of the first decoder.

[0090] It should be understood that a residual structure can be set after the second mask, the second cross-attention layer, and the second feedforward layer. The input and output of each layer are residually connected through this residual structure, and then normalized before being input into the next layer.

[0091] S205: Call the output decoding module of the first decoder and the translation model containing the second decoder to process the first word, the first hidden state information and the second hidden state information to obtain the translated word of the second word and output it; the first word includes the current word and at least one target source word before the word position of the current word, and the second word is the next source word of the current word predicted by the first decoder.

[0092] In an alternative implementation, such as Figure 4 As shown, the above-mentioned call to the first decoder and the translation model includes the output decoding module of the second decoder, which processes the first word, the first hidden state information, and the second hidden state information to obtain and output the translated word of the second word, including:

[0093] S401: Call the first decoder to perform a second decoding process on the first word and the second hidden state information to obtain the third hidden state information of the second word.

[0094] The first word includes the current word and at least one source word input before the current word. The second word is the next source word predicted by the first decoder. The third hidden state information is the output of the last of the multiple first decoders and is used to characterize the semantic information of the predicted second word. Specifically, the third hidden state information may include the word vector information of the second word and the hidden dependency information between the second word and other words acquired and / or predicted before the second word.

[0095] In an optional implementation, the above-mentioned invocation of the first decoder to perform a second decoding process on the first word and the second hidden state information to obtain the third hidden state information of the second word includes:

[0096] The first mask self-attention layer in the first decoder of the input decoding module is called to perform self-attention processing on the word vector information corresponding to the first word, and obtain the fourth attention processing information.

[0097] The first cross-attention layer in the first decoder is invoked to perform cross-attention processing on the second hidden state information and the fourth attention processing information to obtain the fifth attention processing information.

[0098] The first feedforward layer in the first decoder is invoked to transform the fifth attention processing information, thereby obtaining the third hidden state information of the second word.

[0099] Optionally, during the third decoding process at the current time step, the server inputs the first word into the embedding layer for embedding representation processing. This first word includes the current word and at least one source word input before the current word. Then, the word vector information corresponding to the obtained first word is input into the first mask self-attention layer for self-attention processing to obtain the fourth attention processing information. Next, the second hidden state information and the fourth attention processing information are input into the first cross-attention layer for cross-attention processing to obtain the fifth attention processing information. Finally, the fifth attention processing information is transformed through the first feedforward layer to obtain the third hidden state information of the second word.

[0100] Optionally, after calling the first decoder to process the first word and the second hidden state information to obtain the third hidden state information of the second word, the method further includes: calling the prediction output module in the input decoding module to predict the third hidden state information and output the second word. Specifically, the input decoding module includes not only the first decoder but also the prediction output module. The third hidden state information is input to the prediction output module for prediction, and the next source word of the current word is predicted, that is, the second word is obtained and output.

[0101] S403: Call the output decoding module containing the second decoder in the translation model to perform a third decoding process on the first hidden state information, the third hidden state information, and the already obtained translation words to obtain the translation words of the second word and output them.

[0102] In an optional implementation, the above-mentioned translation model includes an output decoding module of the second decoder, which performs a third decoding process on the first hidden state information, the third hidden state information, and the already obtained translation words to obtain and output the translation words of the second word, including:

[0103] The target hidden state information is obtained by concatenating the first hidden state information and the third hidden state information.

[0104] The second mask self-attention layer in the second decoder of the output decoding module is called to perform self-attention processing on the word vector information corresponding to the already obtained translated words, and obtain the sixth attention processing information.

[0105] The second cross-attention layer in the second decoder is invoked to perform cross-attention processing on the target hidden state information and the sixth attention processing information to obtain the seventh attention processing information.

[0106] The second feedforward layer and translation output module in the second decoder are invoked to translate the seventh attention processing information and output the translated word of the second word.

[0107] Optionally, after the server obtains the first and third hidden state information, it concatenates them. Since both the first and third hidden state information are hidden vector sequences, the target hidden state information can be obtained by concatenating them. Next, the second mask self-attention layer in the second decoder performs self-attention processing on the word vector information corresponding to the already obtained translation word to obtain the sixth attention processing information. Then, the second cross-attention layer performs cross-attention processing on the target hidden state information and the sixth attention processing information to obtain the seventh attention processing information. Finally, the seventh attention processing information is translated by the second feedforward layer and the translation output module to output the translated word of the second word.

[0108] S207: Take the next source word of the source word corresponding to the word position of the second word in the input text as the current word, return to the step of calling the trained translation model to translate the current word, until the translated words corresponding to each source word in the input text are output.

[0109] Optionally, after obtaining the translation of the second word, the server determines to proceed to the next time step. In the next time step, the next source word of the source word corresponding to the word position of the second word in the input text is taken as the current word. That is, the source word corresponding to the word position of the second word is skipped, and the next source word of that word position in the input text is taken as the word to be translated in the next time step. Optionally, the current word may include the odd-numbered or even-numbered source word in the text to be translated. Then, the word to be translated is taken as the current word, and the process returns to step S203. Steps S203-S207 are repeated until the translations corresponding to all source words in the real-time input text are output. Based on the output translations, the translation result corresponding to the real-time input text is obtained.

[0110] For example, if the current real-time input text is "we will", then the current word at the current time step is determined to include both "we" and "will", and the translated word for the current word is output as "we will". The next source word for the current word is predicted, i.e., the second word is predicted to be "have", and the translated word for the second word is output as "have". If the current real-time input text is updated to "we will have a trip", then the next source word for the second word ("have") ("once") is taken as the word to be translated at the next time step, and the word to be translated ("once") is taken as the current word. Steps S203-S207 are repeated, and so on, until all words in the real-time input text are translated, resulting in the translation of the input text.

[0111] In the above embodiment, a trained translation model first translates the current word to be translated in the real-time input text. Then, the first decoder and second decoder in the translation model process the first word, the first hidden state information output by the first decoder and second decoder respectively during the previous translation of the current word, to obtain and output the translated word of the second word. The first word includes the current word and at least one target source word preceding the current word's position. The second word is the next source word predicted by the first decoder. The next source word of the source word corresponding to the second word's position in the input text is taken as the current word. The process of calling the trained translation model to translate the current word is repeated until the translated words corresponding to each source word in the input text are output. This eliminates the need to wait for the next source word in the real-time input text and avoids additional encoding processing of source words in order, thus improving the performance of synchronous machine translation and further reducing latency while ensuring translation quality.

[0112] Figure 5This is a flowchart illustrating a method for generating a translation model according to an embodiment of this disclosure. This disclosure provides the operational steps of the method described in the embodiments or flowchart, but based on conventional or non-inventive labor, it may include more or fewer operational steps. The order of steps listed in the embodiments is merely one possible execution order among many steps and does not represent the only possible execution order. The executing entity of this translation method can be the translation model generation device provided in the embodiments of this disclosure, or an electronic device integrating the translation model generation device, wherein the translation model generation device can be implemented in hardware or software. Taking the executing entity as described above... Figure 1 Taking the server in the example of this, such as Figure 5 As shown, the method may include:

[0113] S501: Obtain the training sample set, which includes the training source text and the expected translation sample words corresponding to each sample source word in the training text.

[0114] The expected translation sample words can be standard translation sample words obtained by professional translators.

[0115] S503: Determine the current sample word to be translated from the training source text, call the translation model to translate the current sample word, and obtain the intermediate sample processing result corresponding to the current sample word, as well as the predicted translation sample word of the current sample word; the intermediate sample processing result includes the first sample hidden state information output by the first decoder in the translation model and the second sample hidden state information output by the second decoder.

[0116] S505: Call the output decoding module of the first decoder and the translation model containing the second decoder to process the first sample word, the first sample hidden state information and the second sample hidden state information to obtain the predicted translation sample word of the second sample word; the first sample word includes the current sample word and at least one target sample source word input before the current sample word, and the second sample word is the next sample source word of the current sample word predicted by the first decoder.

[0117] S507: Take the next source word of the source word in the input sample text that corresponds to the word position of the second sample word as the current sample word, and return to the step of calling the translation model to translate the current sample word, until the translated words corresponding to each source word in the training source text are obtained.

[0118] S509: Based on the predicted translation sample words and the corresponding expected translation sample words of each sample source word in the training source text, the translation model is trained to obtain the trained translation model.

[0119] Optionally, the server can determine the training loss based on the difference between the predicted translation sample words and the corresponding expected translation sample words for each sample source word in the training source text. The translation model is then trained based on this training loss until the training termination condition is met, resulting in a trained translation model. The trained translation model is then deployed and applied to perform any of the translation methods described in the foregoing embodiments. The loss function corresponding to the training loss can be a loss function commonly used in the field of language processing models, and this disclosure does not specifically limit the expression of its loss function. The training termination condition may include the training loss satisfying the prediction convergence condition, the translation quality satisfying a preset quality condition, and the number of training iterations satisfying a preset condition, etc.

[0120] In one optional implementation, the above-mentioned invocation of the translation model to translate the current sample word yields the intermediate sample processing result corresponding to the current sample word, and the predicted translation sample word for the current sample word, including:

[0121] The first decoder in the translation model is invoked to encode the current sample word, and the first sample hidden state information output by the first decoder is obtained.

[0122] The output decoding module is invoked to perform the first decoding process on the first hidden state information and the first translated sample word sequence, so as to obtain the second sample hidden state information output by the second decoder, and to obtain the predicted translated sample word of the current sample word. The first translated sample word sequence includes the target translated sample words corresponding to each sample source word before the current sample word.

[0123] In an optional implementation, the first decoder in the translation model is invoked to encode the current sample word, obtaining the first sample hidden state information output by the first decoder, including:

[0124] The first mask self-attention layer in the first decoder is invoked to perform self-attention processing on the word vector information corresponding to the current sample word, thereby obtaining the first sample attention processing information; the first sample attention processing information is used to point to the first cross attention layer in the first decoder.

[0125] At the current time step, the attention processing information of the first sample is passed through the first cross-attention layer to the first feedforward layer in the first decoder. The first feedforward layer transforms the attention processing information of the first sample to obtain the hidden state information of the first sample output by the first decoder.

[0126] In an optional implementation, the aforementioned call output decoding module performs a first decoding process on the first hidden state information and the first translated sample word sequence to obtain the second sample hidden state information output by the second decoder, and obtains the predicted translated sample word for the current sample word, including:

[0127] The second mask self-attention layer in the second decoder of the output decoding module is called to perform self-attention processing on the word vector information corresponding to the word sequence of the first translation sample to obtain the attention processing information of the second sample.

[0128] The second cross-attention layer in the second decoder is invoked to perform cross-attention processing on the hidden state information of the first sample and the attention processing information of the second sample to obtain the attention processing information of the third sample.

[0129] The second feedforward layer in the second decoder is invoked to transform the attention processing information of the third sample, thereby obtaining the hidden state information of the second sample output by the second decoder; the hidden state information of the second sample is used to point to the first cross attention layer of the first decoder.

[0130] The translation output module in the output decoding module is called to perform translation prediction on the hidden state information of the second sample, so as to obtain the predicted translation sample word of the current sample word.

[0131] In one optional implementation, the output decoding module of the first decoder and the translation model, which includes the second decoder, is invoked to process the first sample word, the first sample hidden state information, and the second sample hidden state information to obtain the predicted translation sample word of the second sample word, including:

[0132] The first decoder is invoked to process the first sample word and the second sample hidden state information to obtain the third sample hidden state information of the second sample word.

[0133] The output decoding module of the translation model containing the second decoder is called to process the hidden state information of the first sample, the hidden state information of the third sample, and the word sequence of the second translation sample to obtain the predicted translation sample word of the second sample word. The word sequence of the second translation sample includes the target translation sample word corresponding to each source word of the sample, including the current sample word.

[0134] In an optional implementation, the above-mentioned invocation of the first decoder to process the first sample word and the second sample hidden state information to obtain the third sample hidden state information of the second sample word includes:

[0135] The first mask self-attention layer in the first decoder of the input decoding module is called to perform self-attention processing on the word vector information corresponding to the first sample word to obtain the fourth sample attention processing information.

[0136] The first cross-attention layer in the first decoder is invoked to perform cross-attention processing on the hidden state information of the second sample and the attention processing information of the fourth sample to obtain the attention processing information of the fifth sample.

[0137] The first feedforward layer in the first decoder is invoked to transform the attention processing information of the fifth sample, thereby obtaining the hidden state information of the third sample of the second sample word.

[0138] Accordingly, after calling the first decoder to process the first sample word and the hidden state information of the second sample word to obtain the third hidden state information of the second sample word, the method further includes:

[0139] The prediction output module in the input decoding module is called to predict the hidden state information of the third sample and obtain the words of the second sample.

[0140] In this case, during model training, the aforementioned training loss, besides considering the translation loss determined by the difference between the predicted translation sample words and the corresponding expected translation sample words for each sample source word in the training source text, also considers the word prediction loss determined by the difference between the predicted second sample word and the corresponding true input word; and the training loss is jointly determined based on the weighted sum of the translation loss and the word prediction loss. The loss functions corresponding to the translation loss and the word prediction loss can be loss functions commonly used in the field of language processing models, and this disclosure does not specifically limit the expression of their loss functions. In this way, the training efficiency of the translation model and the accuracy of the translation model's prediction results can be improved.

[0141] In an optional implementation, the above-mentioned translation model includes an output decoding module of a second decoder, which processes the first sample hidden state information, the third sample hidden state information, and the second translation sample word sequence to obtain the predicted translation sample words of the second sample words, including:

[0142] The target sample hidden state information is obtained by concatenating the first hidden state information with the third sample hidden state information.

[0143] The second mask self-attention layer in the second decoder of the output decoding module is invoked to perform self-attention processing on the word vector information corresponding to the word sequence of the second translation sample, so as to obtain the attention processing information of the sixth sample.

[0144] The second cross-attention layer in the second decoder is invoked to perform cross-attention processing on the hidden state information of the target sample and the attention processing information of the sixth sample to obtain the attention processing information of the seventh sample.

[0145] The second feedforward layer and translation output module in the second decoder are invoked to translate the attention processing information of the seventh sample, and the predicted translation sample words of the second sample words are output.

[0146] It should be understood that for steps S501-S509 and other steps not detailed in the above translation model generation method embodiments, please refer to the aforementioned translation method embodiments, which will not be repeated here.

[0147] Figure 6 The diagram illustrates the model structure of a translation model, which is a decoder-decoder framework consisting of an input decoding module and an output decoding module. The input decoding module includes at least a first decoder and a prediction output module. The first decoder includes a first mask self-attention layer, a first cross-attention layer, and a first feedforward layer. The output decoding module includes at least a second decoder and a translation output module. The second decoder includes a second mask self-attention layer, a second cross-attention layer, and a second feedforward layer. At each time step, encoding and multiple decoding processes are performed through the input and output decoding modules. Specifically, encoding and decoding are performed sequentially once through the input and output decoding modules, followed by two more decoding processes sequentially through the same modules. In other words, encoding and multiple decoding processes are executed through the input and output decoding modules.

[0148] The following is combined with Figure 6 The model structure of the translation model is shown, and the training process of the above translation model is described in detail:

[0149] Step 1: At each time step, the input decoding module (first box) reads the current sample source word (i.e., source end word) of the training source text. After passing through the embedding layer and the first decoder, since the current decoder is the first step and there is no input from other decoders, the cross-multi-head attention mechanism in the first decoder can be skipped when the current time passes. At this time, the first decoder performs the encoding function and outputs the first sample hidden state information corresponding to the current sample source word.

[0150] Step 2: The output decoding module (second box) reads in the translation sample words (i.e., the target words), which are then processed through the embedding layer and the second decoder. The second cross-attention layer is used to receive the output from the training source text (i.e., the output of step 1) for the prediction of the current target words. The output is the second sample hidden state information corresponding to the target words.

[0151] Step 3: The input decoding module (third box) continues to read in the source words, which pass through the embedding layer and the first decoder. The first cross-attention layer is used to receive the output from the target word (i.e. the output of step 2) for the prediction of the source word of the next sample. The output is the hidden state information of the third sample corresponding to the newly read source word.

[0152] Step 4: The output decoding module (fourth box) continues to read in the target words, which pass through the embedding layer and the second decoder. The current cross-multi-head attention mechanism is used to receive the output from the training source text (i.e., the concatenation of the output of step 1 and the predicted output of step 3) for the prediction of the next translation sample word. The output is the fourth sample hidden state information corresponding to the newly read target words.

[0153] The hidden state information of each sample obtained in steps 5, 2 and 4 is processed by linear transformation and softmax operation in the translation output model to obtain the translation prediction result at the current time step.

[0154] Step 6: Repeat the above steps to obtain the translation prediction results at each time step until the translation process ends.

[0155] During model training, the target source words and target translation sample words can be processed in the following ways:

[0156] Method a: The target sample source words can be the real input sample source words in the training sample set. The target translation sample words can be the real expected translation sample words in the training sample set.

[0157] Method b can optimize the target sample source words during the training process. Optionally, the target sample source words can include the input sample source words with a first screening rate and the predicted sample source words with a second screening rate, the sum of the first screening rate and the second screening rate being 1; and during the training process, the first screening rate decreases with the increase of the training rounds until it reaches a preset screening threshold (e.g., 0.001). For example, in the first training round, the first screening rate P1 can be 0.9; in the m-th training round, the first screening rate P1 is adjusted to 0.3; in the n-th training round, the first screening rate P1 is adjusted to 0.1; in the k-th training round, the first screening rate P1 is adjusted to 0.01, etc., where the values ​​of m, n, and k gradually increase.

[0158] Method c can optimize the target translation sample words during training. Optionally, the target translation sample words include the expected translation sample words with the third screening rate and the predicted translation sample words with the fourth screening rate, the sum of the third screening rate and the fourth screening rate being 1; and during training, the third screening rate decreases with the increase of training rounds. The adjustment strategy of the third screening rate p2 is similar to the adjustment strategy of the first screening rate p1 mentioned above. In the same training round, the third screening rate p2 and the first screening rate p1 can be the same or different. Method c and the above-mentioned method b can be executed simultaneously. For example, in each training round during the training process, both method b and method c can be sampled for training. Alternatively, method c and the above-mentioned method b can be selected for execution. For example, in some training rounds, only method b is used for training, and in other training rounds, only method c is used for training. That is, the two training methods of method b and method c are alternated; or only method b or method c can be used for training in all training rounds.

[0159] Specifically, taking the simultaneous execution of method b and method c as an example, such as Figure 7 As shown, by connecting the prediction output of the first decoder to the source words (dashed line in the figure) and connecting the translation output of the second decoder to the target words (dashed line in the image), simultaneous optimization of the target sample source words and target translation sample words during training is achieved. Specifically, the first decoder (first box) outputs the hidden state information of the first sample. After passing the hidden state information of the first sample through the linear layer and Softmax in the prediction output, the output represents the prediction result of the first decoder. Then, when passing through the first decoder again (third box), the true label (input) is selected as the input with a certain probability p1, while the prediction result output by the first box is selected as the input with a probability of 1-p1 (corresponding to the dashed line connecting the first and third boxes). Similarly, the second decoder (second box) outputs the second sample hidden state information. After the second sample hidden state information is passed through the linear layer and Softmax in the translation output, it is output as the prediction result of the second decoder. Then, when it passes through the second decoder again (fourth box), the true label (input) is selected as the input with a certain probability p2, while the prediction result output by the nth box is selected as the input with a probability of 1-p2 (corresponding to the dashed line part connecting the second and fourth boxes).

[0160] By using the words predicted by the previous decoder as input for the next decoder with a certain probability during training, even if errors occur in the previous iterations, the training objective remains to maximize the probability of translating the true target word sequence. This ensures the model trains in the correct direction, reduces inconsistencies between training and prediction, and increases the fault tolerance of the trained translation model.

[0161] It should be understood that the translation method and translation model of this disclosure can be applied not only to synchronous translation scenarios but also to asynchronous translation scenarios. In asynchronous translation scenarios, the translation time can be significantly reduced while ensuring translation quality.

[0162] The following are embodiments of the apparatus disclosed herein, which can be used to execute embodiments of the method disclosed herein. For details not disclosed in the apparatus embodiments of this disclosure, please refer to the embodiments of the method disclosed herein.

[0163] Please refer to Figure 8 This diagram illustrates a structural block diagram of a translation apparatus provided in an embodiment of this disclosure. The apparatus has the functions described in the method examples above; these functions can be implemented in hardware or by hardware executing corresponding software. The translation apparatus may include:

[0164] The text acquisition module 810 is used to acquire real-time input text and determine the current word to be translated from the input text;

[0165] The first processing module 820 is used to call the trained translation model to translate the current word, obtain the intermediate processing result corresponding to the current word, and output the translated word of the current word; the intermediate processing result includes the first hidden state information output by the first decoder in the translation model and the second hidden state information output by the second decoder.

[0166] The second processing module 830 is used to call the first decoder and the output decoding module of the translation model containing the second decoder to process the first word, the first hidden state information and the second hidden state information to obtain the translated word of the second word and output it; the first word includes the current word and at least one target source word before the word position of the current word, and the second word is the next source word of the current word predicted by the first decoder;

[0167] The iterative translation module 840 is used to take the next source word of the source word corresponding to the word position of the second word in the input text as the current word, return to the step of calling the trained translation model to translate the current word, until the translated words corresponding to each source word in the input text are output.

[0168] In an optional implementation, the first processing module includes:

[0169] The first processing submodule is used to call the first decoder in the trained translation model to encode the current word and obtain the first hidden state information output by the first decoder.

[0170] The second processing submodule is used to call the output decoding module to perform a first decoding process on the first hidden state information and the already obtained translated words, to obtain the second hidden state information output by the second decoder, and to output the translated words of the current word.

[0171] In an optional implementation, the first processing submodule is specifically used for:

[0172] The first mask self-attention layer in the first decoder is invoked to perform self-attention processing on the word vector information corresponding to the current word, thereby obtaining first attention processing information; the first attention processing information is used to point to the first cross-attention layer in the first decoder.

[0173] At the current time step, the first attention processing information is passed through the first cross-attention layer to the first feedforward layer in the first decoder. The first feedforward layer transforms the first attention processing information to obtain the first hidden state information output by the first decoder.

[0174] In an optional implementation, the second processing submodule is specifically used for:

[0175] The second mask self-attention layer in the second decoder of the output decoding module is invoked to perform self-attention processing on the word vector information corresponding to the already obtained translated words, thereby obtaining the second attention processing information;

[0176] The second cross-attention layer in the second decoder is invoked to perform cross-attention processing on the first hidden state information and the second attention processing information to obtain the third attention processing information.

[0177] The second feedforward layer in the second decoder is invoked to transform the third attention processing information, thereby obtaining the second hidden state information output by the second decoder; the second hidden state information is used to point to the first cross-attention layer of the first decoder.

[0178] The translation output module in the output decoding module is invoked to perform translation prediction on the second hidden state information and output the translated word of the current word.

[0179] In an optional embodiment, the second processing module includes:

[0180] The third processing submodule is used to call the first decoder to perform a second decoding process on the first word and the second hidden state information to obtain the third hidden state information of the second word.

[0181] The fourth processing submodule is used to call the output decoding module of the second decoder in the translation model to perform a third decoding process on the first hidden state information, the third hidden state information and the already obtained translation words, to obtain the translation words of the second word and output them.

[0182] In an optional implementation, the third processing submodule is specifically used for:

[0183] The first mask self-attention layer in the first decoder of the input decoding module is invoked to perform self-attention processing on the word vector information corresponding to the first word, thereby obtaining the fourth attention processing information.

[0184] The first cross-attention layer in the first decoder is invoked to perform cross-attention processing on the second hidden state information and the fourth attention processing information to obtain the fifth attention processing information.

[0185] The first feedforward layer in the first decoder is invoked to transform the fifth attention processing information to obtain the third hidden state information of the second word;

[0186] Accordingly, the device also includes:

[0187] The output module is used to call the prediction output module in the input decoding module to predict the third hidden state information and output the second word.

[0188] In an optional implementation, the fourth processing submodule is specifically used for:

[0189] The target hidden state information is obtained by concatenating the first hidden state information and the third hidden state information.

[0190] The second mask self-attention layer in the second decoder of the output decoding module is invoked to perform self-attention processing on the word vector information corresponding to the already obtained translated words, thereby obtaining the sixth attention processing information;

[0191] The second cross-attention layer in the second decoder is invoked to perform cross-attention processing on the target hidden state information and the sixth attention processing information to obtain the seventh attention processing information.

[0192] The second feedforward layer and translation output module in the second decoder are invoked to translate the seventh attention processing information and output the translated word of the second word.

[0193] Please refer to Figure 9This diagram illustrates a structural block diagram of a translation model generation apparatus provided in an embodiment of this disclosure. The apparatus has the functions described in the method example above; these functions can be implemented in hardware or by hardware executing corresponding software. The translation model generation apparatus may include:

[0194] The training data module 910 is used to acquire a training sample set, which includes training source text and expected translation sample words corresponding to each sample source word in the training text.

[0195] The first training processing module 920 is used to determine the current sample word to be translated from the training source text, call the translation model to perform translation processing on the current sample word, and obtain the intermediate sample processing result corresponding to the current sample word, as well as the predicted translation sample word of the current sample word; the intermediate sample processing result includes the first sample hidden state information output by the first decoder in the translation model and the second sample hidden state information output by the second decoder.

[0196] The second training processing module 930 is used to call the first decoder and the output decoding module of the translation model containing the second decoder to process the first sample word, the first sample hidden state information and the second sample hidden state information to obtain the predicted translation sample word of the second sample word; the first sample word includes the current sample word and at least one target sample source word input before the current sample word, and the second sample word is the next sample source word of the current sample word predicted by the first decoder;

[0197] The model training module 940 is used to take the next sample source word of the sample source word corresponding to the word position of the second sample word in the input sample text as the current sample word, and return to the step of calling the translation model to translate the current sample word, until the translated words corresponding to each sample source word in the training source text are obtained;

[0198] The model generation module 950 is used to train the translation model based on the predicted translation sample words and the corresponding expected translation sample words corresponding to each sample source word in the training source text, so as to obtain the trained translation model.

[0199] In one optional implementation, the second training processing module includes:

[0200] The first training processing submodule is used to call the first decoder to process the first sample word and the second sample hidden state information to obtain the third sample hidden state information of the second sample word; the first sample word includes the current sample word and at least one target sample source word input before the current sample word, and the second sample word is the next sample source word of the current sample word predicted by the first decoder;

[0201] The second training processing submodule is used to call the output decoding module of the second decoder in the translation model to process the first sample hidden state information, the third sample hidden state information and the second translation sample word sequence to obtain the predicted translation sample word of the second sample word. The second translation sample word sequence includes the target translation sample word corresponding to each sample source word, including the current sample word.

[0202] In one optional implementation, the target sample source words include input sample source words with a first screening rate and predicted sample source words with a second screening rate, the sum of the first screening rate and the second screening rate being 1; and during training, the first screening rate decreases as the number of training rounds increases; and / or

[0203] The target translation sample words include expected translation sample words with a third screening rate and predicted translation sample words with a fourth screening rate, the sum of the third screening rate and the fourth screening rate being 1; and during the training process, the third screening rate decreases as the number of training rounds increases.

[0204] The apparatus provided in the above embodiments can execute the corresponding methods in the embodiments of this disclosure, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the above embodiments can be found in the methods provided in any embodiment of this application.

[0205] This disclosure provides an electronic device that may include a processor and a memory. The memory stores at least one instruction, at least one program, a code set, or an instruction set. The at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the method described in any of the above method embodiments.

[0206] Furthermore, Figure 10 This is a schematic diagram of the hardware structure of an electronic device for implementing the methods provided in the embodiments of this disclosure. (Refer to...) Figure 10 The electronic device includes a processor; a memory for storing processor-executable instructions; wherein, when the processor is configured to execute the instructions stored in the memory, it implements the steps of any of the methods in the above embodiments.

[0207] The electronic device can be a terminal, a server, or a similar computing device. Taking a server as an example... Figure 10 This is a block diagram illustrating an electronic device 1000 for determining or recommending content, according to an exemplary embodiment. The electronic device 1000 can vary significantly due to different configurations or performance characteristics. It may include one or more central processing units (CPUs) 1010 (CPUs 1010 may include, but are not limited to, microprocessors such as MCUs or programmable logic devices such as FPGAs), a memory 1030 for storing data, and one or more storage media 1020 (e.g., one or more mass storage devices) for storing application programs 1023 or data 1022. The memory 1030 and storage media 1020 may be temporary or persistent storage. The program stored in the storage media 1020 may include one or more modules, each module including a series of instruction operations on the electronic device. Furthermore, the CPU 1010 may be configured to communicate with the storage media 1020 and execute the series of instruction operations in the storage media 1020 on the electronic device 1000.

[0208] Electronic device 1000 may also include one or more power supplies 1060, one or more wired or wireless network interfaces 1050, one or more input / output interfaces 1040, and / or one or more operating systems 1021, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc.

[0209] The input / output interface 1040 can be used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the electronic device 1000. In one example, the input / output interface 1040 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In an exemplary embodiment, the input / output interface 1040 can be a radio frequency (RF) module for wireless communication with the Internet.

[0210] Those skilled in the art will understand that Figure 10 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, the electronic device 1000 may also include components that are more... Figure 10 The more or fewer components shown, or having the same Figure 10 The different configurations shown.

[0211] This disclosure also provides a computer-readable storage medium storing at least one instruction or at least one program segment, which is loaded and executed by a processor to implement any of the methods described above. For example, the storage medium includes a memory for instructions that can be executed by a processor of an electronic device 1000 to perform the methods described above. Optionally, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device, etc.

[0212] This disclosure also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the methods described above.

[0213] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.

[0214] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments of this disclosure have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired results. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired results. In some implementations, multitasking and parallel processing are also possible or may be advantageous.

[0215] The various embodiments in this disclosure are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and electronic device embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0216] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0217] The above description is only a preferred embodiment of this disclosure and is not intended to limit this disclosure. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the protection scope of this disclosure.

Claims

1. A translation method, characterized in that, include: Obtain real-time input text and determine the current word to be translated from the input text; The trained translation model is invoked to translate the current word, and the intermediate processing result corresponding to the current word and the translated word of the current word are obtained and output. The intermediate processing results include the first hidden state information output by the first decoder and the second hidden state information output by the second decoder in the translation model. The first decoder and the output decoding module of the translation model containing the second decoder are invoked to process the first word, the first hidden state information and the second hidden state information to obtain the translated word of the second word and output it; the first word includes the current word and at least one target source word before the word position of the current word, and the second word is the next source word of the current word predicted by the first decoder; The next source word corresponding to the word position of the second word in the input text is taken as the current word, and the step of calling the trained translation model to translate the current word is returned until the translated words corresponding to each source word in the input text are output.

2. The method according to claim 1, characterized in that, The process of calling the trained translation model to translate the current word, obtaining the intermediate processing result corresponding to the current word, and the translated word of the current word and outputting it includes: The first decoder in the trained translation model is invoked to encode the current word, thereby obtaining the first hidden state information output by the first decoder; The output decoding module is invoked to perform a first decoding process on the first hidden state information and the already obtained translated words, to obtain the second hidden state information output by the second decoder, and to output the translated words of the current word.

3. The method according to claim 2, characterized in that, The invocation of the first decoder in the trained translation model to encode the current word and obtain the first hidden state information output by the first decoder includes: The first mask self-attention layer in the first decoder is invoked to perform self-attention processing on the word vector information corresponding to the current word, thereby obtaining first attention processing information; the first attention processing information is used to point to the first cross-attention layer in the first decoder. At the current time step, the first attention processing information is passed through the first cross-attention layer to the first feedforward layer in the first decoder. The first feedforward layer transforms the first attention processing information to obtain the first hidden state information output by the first decoder.

4. The method according to claim 2, characterized in that, The step of calling the output decoding module to perform a first decoding process on the first hidden state information and the already obtained translated words, obtaining the second hidden state information output by the second decoder, and outputting the translated words of the current word, includes: The second mask self-attention layer in the second decoder of the output decoding module is invoked to perform self-attention processing on the word vector information corresponding to the already obtained translated words, thereby obtaining the second attention processing information; The second cross-attention layer in the second decoder is invoked to perform cross-attention processing on the first hidden state information and the second attention processing information to obtain the third attention processing information. The second feedforward layer in the second decoder is invoked to transform the third attention processing information, thereby obtaining the second hidden state information output by the second decoder; the second hidden state information is used to point to the first cross-attention layer of the first decoder. The translation output module in the output decoding module is invoked to perform translation prediction on the second hidden state information and output the translated word of the current word.

5. The method according to any one of claims 1-4, characterized in that, The step of calling the output decoding module of the first decoder and the translation model, which includes the second decoder, processes the first word, the first hidden state information, and the second hidden state information to obtain and output the translated word of the second word, including: The first decoder is invoked to perform a second decoding process on the first word and the second hidden state information to obtain the third hidden state information of the second word; The output decoding module containing the second decoder in the translation model is invoked to perform a third decoding process on the first hidden state information, the third hidden state information, and the already obtained translation words to obtain the translation words of the second word and output them.

6. The method according to claim 5, characterized in that, The step of calling the first decoder to perform a second decoding process on the first word and the second hidden state information to obtain the third hidden state information of the second word includes: The first mask self-attention layer in the first decoder of the input decoding module is invoked to perform self-attention processing on the word vector information corresponding to the first word, thereby obtaining the fourth attention processing information. The first cross-attention layer in the first decoder is invoked to perform cross-attention processing on the second hidden state information and the fourth attention processing information to obtain the fifth attention processing information. The first feedforward layer in the first decoder is invoked to transform the fifth attention processing information to obtain the third hidden state information of the second word; Accordingly, after calling the first decoder to process the first word and the second hidden state information to obtain the third hidden state information of the second word, the method further includes: The prediction output module in the input decoding module is invoked to predict the third hidden state information and output the second word.

7. The method according to claim 5, characterized in that, The call to the translation model includes the output decoding module of the second decoder, which performs a third decoding process on the first hidden state information, the third hidden state information, and the already obtained translation words to obtain and output the translation words of the second word, including: The target hidden state information is obtained by concatenating the first hidden state information and the third hidden state information. The second mask self-attention layer in the second decoder of the output decoding module is invoked to perform self-attention processing on the word vector information corresponding to the already obtained translated words, thereby obtaining the sixth attention processing information; The second cross-attention layer in the second decoder is invoked to perform cross-attention processing on the target hidden state information and the sixth attention processing information to obtain the seventh attention processing information. The second feedforward layer and translation output module in the second decoder are invoked to translate the seventh attention processing information and output the translated word of the second word.

8. A method for generating a translation model, characterized in that, include: Obtain a training sample set, which includes training source text and expected translation sample words corresponding to each sample source word in the training source text; The current sample word to be translated is determined from the training source text, and the translation model is called to translate the current sample word to obtain the intermediate sample processing result corresponding to the current sample word, as well as the predicted translation sample word of the current sample word; The intermediate sample processing results include the first sample hidden state information output by the first decoder and the second sample hidden state information output by the second decoder in the translation model. The first decoder and the output decoding module of the translation model containing the second decoder are invoked to process the first sample word, the first sample hidden state information and the second sample hidden state information to obtain the predicted translation sample word of the second sample word; the first sample word includes the current sample word and at least one target sample source word input before the current sample word, and the second sample word is the next sample source word of the current sample word predicted by the first decoder; The next source word of the source word in the input sample text that corresponds to the word position of the second sample word is taken as the current sample word. The step of calling the translation model to translate the current sample word is returned until the translated words corresponding to each source word in the training source text are obtained. Based on the predicted translation sample words and the corresponding expected translation sample words for each sample source word in the training source text, the translation model is trained to obtain the trained translation model.

9. The method according to claim 8, characterized in that, The method involves calling the output decoding module of the first decoder and the translation model, which includes the second decoder, to process the first sample word, the first sample hidden state information, and the second sample hidden state information to obtain the predicted translation sample word of the second sample word, including: The first decoder is invoked to process the first sample word and the second sample hidden state information to obtain the third sample hidden state information of the second sample word. The output decoding module of the second decoder in the translation model is invoked to process the first sample hidden state information, the third sample hidden state information and the second translation sample word sequence to obtain the predicted translation sample word of the second sample word. The second translation sample word sequence includes the target translation sample word corresponding to each sample source word, including the current sample word.

10. The method according to claim 9, characterized in that, The target sample source words include input sample source words with a first screening rate and predicted sample source words with a second screening rate, the sum of the first screening rate and the second screening rate is 1; and during the training process, the first screening rate decreases as the number of training rounds increases; and / or The target translation sample words include expected translation sample words with a third screening rate and predicted translation sample words with a fourth screening rate, the sum of the third screening rate and the fourth screening rate being 1; and during the training process, the third screening rate decreases as the number of training rounds increases.

11. A translation device, characterized in that, include: The text acquisition module is used to acquire real-time input text and determine the current word to be translated from the input text; The first processing module is used to call the trained translation model to translate the current word, obtain the intermediate processing result corresponding to the current word, and output the translated word of the current word; The intermediate processing results include the first hidden state information output by the first decoder and the second hidden state information output by the second decoder in the translation model. The second processing module is used to call the first decoder and the output decoding module of the translation model containing the second decoder to process the first word, the first hidden state information and the second hidden state information to obtain the translated word of the second word and output it; the first word includes the current word and at least one target source word before the word position of the current word, and the second word is the next source word of the current word predicted by the first decoder; The iterative translation module is used to take the next source word of the source word corresponding to the word position of the second word in the input text as the current word, return to the step of calling the trained translation model to translate the current word, until the translated words corresponding to each source word in the input text are output.

12. The apparatus according to claim 11, characterized in that, The first processing module includes: The first processing submodule is used to call the first decoder in the trained translation model to encode the current word and obtain the first hidden state information output by the first decoder. The second processing submodule is used to call the output decoding module to perform a first decoding process on the first hidden state information and the already obtained translated words, to obtain the second hidden state information output by the second decoder, and to output the translated words of the current word.

13. The apparatus according to claim 12, characterized in that, The first processing submodule is specifically used for: The first mask self-attention layer in the first decoder is invoked to perform self-attention processing on the word vector information corresponding to the current word, thereby obtaining first attention processing information; the first attention processing information is used to point to the first cross-attention layer in the first decoder. At the current time step, the first attention processing information is passed through the first cross-attention layer to the first feedforward layer in the first decoder. The first feedforward layer transforms the first attention processing information to obtain the first hidden state information output by the first decoder.

14. The apparatus according to claim 12, characterized in that, The second processing submodule is specifically used for: The second mask self-attention layer in the second decoder of the output decoding module is invoked to perform self-attention processing on the word vector information corresponding to the already obtained translated words, thereby obtaining the second attention processing information; The second cross-attention layer in the second decoder is invoked to perform cross-attention processing on the first hidden state information and the second attention processing information to obtain the third attention processing information. The second feedforward layer in the second decoder is invoked to transform the third attention processing information, thereby obtaining the second hidden state information output by the second decoder. The second hidden state information is used to point to the first cross-attention layer of the first decoder; The translation output module in the output decoding module is invoked to perform translation prediction on the second hidden state information and output the translated word of the current word.

15. The apparatus according to any one of claims 11 to 14, characterized in that, The second processing module includes: The third processing submodule is used to call the first decoder to perform a second decoding process on the first word and the second hidden state information to obtain the third hidden state information of the second word. The fourth processing submodule is used to call the output decoding module of the second decoder in the translation model to perform a third decoding process on the first hidden state information, the third hidden state information and the already obtained translation words, to obtain the translation words of the second word and output them.

16. The apparatus according to claim 15, characterized in that, The third processing submodule is specifically used for: The first mask self-attention layer in the first decoder of the input decoding module is invoked to perform self-attention processing on the word vector information corresponding to the first word, thereby obtaining the fourth attention processing information. The first cross-attention layer in the first decoder is invoked to perform cross-attention processing on the second hidden state information and the fourth attention processing information to obtain the fifth attention processing information. The first feedforward layer in the first decoder is invoked to transform the fifth attention processing information to obtain the third hidden state information of the second word; Accordingly, the device also includes: The output module is used to call the prediction output module in the input decoding module to predict the third hidden state information and output the second word.

17. The apparatus according to claim 15, characterized in that, The fourth processing submodule is specifically used for: The target hidden state information is obtained by concatenating the first hidden state information and the third hidden state information. The second mask self-attention layer in the second decoder of the output decoding module is invoked to perform self-attention processing on the word vector information corresponding to the already obtained translated words, thereby obtaining the sixth attention processing information; The second cross-attention layer in the second decoder is invoked to perform cross-attention processing on the target hidden state information and the sixth attention processing information to obtain the seventh attention processing information. The second feedforward layer and translation output module in the second decoder are invoked to translate the seventh attention processing information and output the translated word of the second word.

18. A device for generating a translation model, characterized in that, include: The training data module is used to acquire a training sample set, which includes training source text and expected translation sample words corresponding to each sample source word in the training source text. The first training processing module is used to determine the current sample word to be translated from the training source text, call the translation model to translate the current sample word, and obtain the intermediate sample processing result corresponding to the current sample word, as well as the predicted translation sample word of the current sample word; The intermediate sample processing results include the first sample hidden state information output by the first decoder and the second sample hidden state information output by the second decoder in the translation model. The second training processing module is used to call the first decoder and the output decoding module of the translation model containing the second decoder to process the first sample word, the first sample hidden state information and the second sample hidden state information to obtain the predicted translation sample word of the second sample word; the first sample word includes the current sample word and at least one target sample source word input before the current sample word, and the second sample word is the next sample source word of the current sample word predicted by the first decoder; The model training module is used to take the next sample source word of the sample source word corresponding to the word position of the second sample word in the input sample text as the current sample word, and return to the step of calling the translation model to translate the current sample word, until the translated words corresponding to each sample source word in the training source text are obtained; The model generation module is used to train the translation model based on the predicted translation sample words and the corresponding expected translation sample words corresponding to each sample source word in the training source text, so as to obtain the trained translation model.

19. The apparatus according to claim 18, characterized in that, The second training processing module includes: The first training processing submodule is used to call the first decoder to process the first sample word and the second sample hidden state information to obtain the third sample hidden state information of the second sample word; the first sample word includes the current sample word and at least one target sample source word input before the current sample word, and the second sample word is the next sample source word of the current sample word predicted by the first decoder; The second training processing submodule is used to call the output decoding module of the second decoder in the translation model to process the first sample hidden state information, the third sample hidden state information and the second translation sample word sequence to obtain the predicted translation sample word of the second sample word. The second translation sample word sequence includes the target translation sample word corresponding to each sample source word, including the current sample word.

20. The apparatus according to claim 19, characterized in that, The target sample source words include input sample source words with a first screening rate and predicted sample source words with a second screening rate, the sum of the first screening rate and the second screening rate is 1; and during the training process, the first screening rate decreases as the number of training rounds increases; and / or The target translation sample words include expected translation sample words with a third screening rate and predicted translation sample words with a fourth screening rate, the sum of the third screening rate and the fourth screening rate being 1; and during the training process, the third screening rate decreases as the number of training rounds increases.

21. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction or at least one program segment, which is loaded and executed by a processor to implement the translation method as described in any one of claims 1-7, or the method for generating a translation model as described in any one of claims 8-10.

22. An electronic device comprising a processor and a memory, the memory storing at least one instruction, the at least one instruction being loaded and executed by the processor to implement the translation method as claimed in any one of claims 1-7, or the method for generating a translation model as claimed in any one of claims 8-10.

23. A computer program product comprising computer instructions stored in a computer-readable storage medium; a processor of a computer device reading the computer instructions from the computer-readable storage medium, the processor executing the computer instructions to cause the computer device to perform the translation method of any one of claims 1-7, or the method for generating a translation model as described in any one of claims 8-10.

Citation Information

Patent Citations

  • Machine translation method and device and storage medium

    CN111310485A

  • Translation evaluation method, device and system and computer storage medium

    CN112446221A