Text translation method and device, computer equipment and storage medium

Through automated semantic encoding and decoding processing, the problem of low text translation efficiency in the existing technology is solved, and efficient multi-task translation capabilities are achieved.

CN118734869APending Publication Date: 2024-10-01TENCENT TECHNOLOGY (SHENZHEN) CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310368793.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-28
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

The efficiency of text translation in the existing technology is low, and the efficiency problem cannot be effectively solved due to reliance on manual translation.

Method used

By obtaining the initial text, determining the translation task type, adding mark tags, performing semantic encoding and decoding processing, and generating translations, automatic translation is achieved.

Benefits of technology

It improves translation efficiency, can perform multiple translation task types at the same time, and improves translation efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734869A_ABST
    Figure CN118734869A_ABST
Patent Text Reader

Abstract

The invention relates to artificial intelligence, in particular to a text translation method and device, computer equipment, a storage medium and a computer program product. The method comprises the following steps: acquiring an initial text, and determining at least one translation task type for translating the initial text; aiming at the at least one translation task type, respectively adding a label in the initial text to obtain at least one labeled text; determining at least one text coding mode matched with the at least one tagged text based on the translation task label included in the at least one tagged text; performing semantic coding processing according to an adaptive text coding mode to obtain a coding vector sequence in one-to-one correspondence with the at least one translation task type; and respectively performing semantic decoding processing on the coding vector sequences in one-to-one correspondence with the at least one translation task type to obtain translated texts in one-to-one correspondence with the at least one translation task type. By adopting the method, the text translation efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a text translation method, apparatus, computer device and storage medium. Background Art

[0002] With the advancement of computer technology, translation has become an important research topic in natural language text processing. Translation refers to the process of translating a text in a source language into a semantically equivalent text in a target language. For example, translating a Chinese text into an English text, or translating an English text into Russian, etc. At present, text translation is mainly done manually. However, manual translation has the problem of low translation efficiency. Summary of the invention

[0003] Based on this, it is necessary to provide a text translation method, apparatus, computer device, computer-readable storage medium and computer program product that can improve translation efficiency in response to the above technical problems.

[0004] In a first aspect, the present application provides a text translation method, the method comprising:

[0005] Acquire an initial text, and determine at least one translation task type for translating the initial text;

[0006] For the at least one translation task type, markup tags are added to the initial text to obtain at least one marked text; the marked texts in the at least one marked text correspond to the translation task types in the at least one translation task type, and the marked tags in each of the marked texts include a translation task tag representing the corresponding translation task type;

[0007] Determining a text encoding method adapted for each of the at least one marked text based on a translation task tag included in the at least one marked text;

[0008] For each of the at least one marked text, semantic encoding processing is performed according to the adapted text encoding method to obtain a coding vector sequence corresponding to the at least one translation task type;

[0009] Semantic decoding processing is performed on the encoding vector sequences corresponding one-to-one to the at least one translation task type to obtain translation texts corresponding one-to-one to the at least one translation task type.

[0010] In a second aspect, the present application further provides a text translation device, the device comprising:

[0011] A text input module, used to obtain an initial text and determine at least one translation task type for translating the initial text;

[0012] The encoding module is used to add a markup tag to the initial text for the at least one translation task type to obtain at least one marked text; the marked text in the at least one marked text corresponds to the translation task type in the at least one translation task type, and the marked tag in each of the marked texts includes a translation task tag representing the corresponding translation task type; based on the translation task tag included in the at least one marked text, at least one text encoding method adapted to the at least one marked text is determined; for each of the at least one marked text, semantic encoding processing is performed according to the adapted text encoding method to obtain a coding vector sequence corresponding to the at least one translation task type;

[0013] The decoding module is used to perform semantic decoding processing on the encoding vector sequences corresponding to the at least one translation task type, so as to obtain translation texts corresponding to the at least one translation task type.

[0014] In one of the embodiments, the text input module is further used to display a list of translation task types in response to a translation trigger operation on an initial text; and in response to a selection operation on the list of translation task types, use at least one translation type selected by the selection operation as at least one translation task type for translating the initial text.

[0015] In one of the embodiments, the encoding module is further used to obtain, for each translation task type among the at least one translation task type, a marking tag corresponding to the targeted translation task type; and add the marking tag corresponding to the targeted translation task type to the initial text to obtain a marked text corresponding to the targeted translation task type.

[0016] In one of the embodiments, the at least one translation task type includes at least one of a text sentence translation task type, a document translation task type, a dialogue translation task type, a multimodal translation task type, or a personalized translation task type; the translation task of the text sentence translation task type is used to translate text sentences; the translation task of the document translation task type is used to translate documents; the translation task of the dialogue translation task type is used to translate dialogue content; the translation task of the multimodal translation task type is used to translate text extracted from multimedia; and the translation task of the personalized translation task type is used to perform personalized translation of text.

[0017] In one of the embodiments, the marking tags corresponding to the targeted translation task type include a first sentence start tag, a first sentence end tag, an end tag, and a translation task tag representing the targeted translation task type; the encoding module is further used to add a translation task tag representing the targeted translation task type to the head of the initial text when the number of text sentences included in the initial text is less than or equal to a preset number threshold; add the first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text; add the first sentence end tag to the end of the initial text, and add the end tag after the added first sentence end tag, to obtain the marked text corresponding to the targeted translation task type.

[0018] In one of the embodiments, the marking tags corresponding to the targeted translation task type include a first sentence start tag, a first sentence end tag, a sentence spacing tag, and a translation task tag representing the targeted translation task type; the encoding module is also used to add a translation task tag representing the targeted translation task type to the head of the initial text when the number of text sentences included in the initial text is greater than a preset number threshold; add the first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text; add the first sentence end tag at the end of the first text sentence in the initial text; determine the remaining text sentences in the initial text except the first text sentence, and add the sentence spacing tag between every two adjacent remaining text sentences to obtain a marked text corresponding to the targeted translation task type.

[0019] In one of the embodiments, the encoding module is further used to, for each marked text in the at least one marked text, determine that the text encoding method adapted to the marked text is a dialogue encoding method for encoding dialogue content when the translation task type represented by the translation task tag included in the marked text belongs to the dialogue task type; when the translation task type represented by the translation task tag included in the marked text belongs to the non-dialogue task type, determine that the text encoding method adapted to the marked text is a sentence encoding method for encoding non-dialogue content.

[0020] In one of the embodiments, the encoding module is also used to, for each marked text in the at least one marked text, when the text encoding method adapted to the marked text is a dialogue encoding method, perform dialogue turn encoding processing on each text sentence in the marked text to obtain a dialogue turn encoding vector corresponding to each text sentence in the marked text; perform dialogue role encoding processing on each text sentence in the marked text to obtain a dialogue role encoding vector corresponding to each text sentence in the marked text; perform word embedding processing on each text sentence in the marked text to obtain a word embedding vector sequence corresponding to each text sentence in the marked text; perform position encoding processing on each text sentence in the marked text to obtain a position encoding vector sequence corresponding to each text sentence in the marked text; and obtain an encoding vector sequence corresponding to the marked text according to the dialogue turn encoding vector, dialogue role encoding vector, word embedding vector sequence and position encoding vector sequence corresponding to each text sentence in the marked text.

[0021] In one of the embodiments, the encoding module is also used to determine, for each text sentence in the targeted marked text, a dialogue turn of each text sentence in the targeted marked text; and encode each determined dialogue turn to obtain a dialogue turn encoding vector corresponding to each text sentence in the targeted marked text.

[0022] In one of the embodiments, the encoding module is also used to determine the dialogue role to which each text sentence in the targeted marked text belongs based on the dialogue role identifier carried by each text sentence in the targeted marked text; encode the dialogue role to which each text sentence belongs respectively to obtain the dialogue role encoding vector corresponding to each text sentence in the targeted marked text.

[0023] In one of the embodiments, the encoding module is also used to, for each marked text in the at least one marked text, when the text encoding method adapted to the marked text is a sentence encoding method, perform word embedding processing on each word in the marked text to obtain a word embedding vector corresponding to each word in the marked text; perform position encoding processing on each word in the marked text to obtain a position encoding vector corresponding to each word in the marked text; superimpose the word embedding vector and the position encoding vector corresponding to the same word to obtain a superimposed vector corresponding to each word in the marked text; and obtain an encoding vector sequence corresponding to the marked text according to the superimposed vector corresponding to each word in the marked text.

[0024] In one of the embodiments, the decoding module is further used to generate a first translation word for each coding vector sequence based on the targeted coding vector sequence and a start character corresponding to the targeted coding vector sequence; perform at least one round of decoding processing based on the first translation word and the targeted coding vector sequence to obtain at least one subsequent translation word; and obtain a translation text corresponding to the targeted coding vector sequence by combining the first translation word and the at least one subsequent translation word.

[0025] In one of the embodiments, the decoding module is also used to obtain a start character corresponding to the targeted encoding vector sequence, and perform self-attention processing on the start character to obtain a first content representation vector; perform self-attention processing on the targeted encoding vector sequence and the first content representation vector to obtain a first interaction representation vector; and decode the first interaction representation vector to obtain a first translation word.

[0026] In one of the embodiments, the decoding module is also used to determine the current round, and determine the historical translation words output in each historical round before the current round to obtain a historical translation word sequence; perform self-attention processing on the historical translation word sequence to obtain a current content representation vector; perform self-attention processing on the targeted encoding vector sequence and the current content representation vector to obtain a current interaction representation vector; decode the current interaction representation vector to obtain a successive translation word output in the current round; enter the next round of decoding processing, take the next round as the current round, return to determine the historical translation words output in each historical round before the current round, and continue to perform the steps of obtaining a historical translation word sequence until the last successive translation word is output.

[0027] In one embodiment, the text translation device further includes a model training module, which is further used to obtain a sample text and a plurality of standard translation texts corresponding to the sample text; for a plurality of preset translation task types, respectively, mark tags are added to the sample text to obtain a plurality of marked sample texts corresponding to the plurality of translation task types; the mark tags in each of the marked sample texts include a translation task tag representing the corresponding translation task type; based on the translation task tags included in each of the plurality of marked sample texts, at least one text encoding method adapted for the plurality of marked sample texts is determined; for each of the plurality of marked sample texts, semantic encoding processing is performed according to the adapted text encoding method to obtain a sample encoding vector sequence corresponding to each of the plurality of translation task types; semantic decoding processing is performed on the sample encoding vector sequences corresponding to each of the plurality of translation task types to obtain a predicted translation text corresponding to each of the plurality of translation task types; the text translation model is trained through the predicted translation text corresponding to each of the plurality of translation task types and the plurality of standard translation texts to obtain a trained text translation model.

[0028] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps in any text translation method provided in the embodiments of the present application are implemented.

[0029] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any text translation method provided in the embodiments of the present application are implemented.

[0030] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it performs the steps in any text translation method provided in the embodiments of the present application.

[0031] The above-mentioned text translation method, device, computer equipment, storage medium and computer program product can determine at least one type of translation task for translating the initial text by obtaining the initial text. By determining at least one type of translation task, the initial text can be converted into a marked text corresponding to each type of translation task based on the determined translation task type. By generating at least one marked text, at least one text encoding method adapted to at least one marked text can be determined based on the translation task tag included in the at least one marked text, so that the corresponding marked text is encoded according to the adapted text encoding method, and a coding vector sequence corresponding to at least one translation task type is obtained, and then each coding vector sequence is decoded to obtain a translation text corresponding to at least one translation task type. Since the present application can automatically translate the initial text, the translation efficiency is improved compared to traditional manual translation. And when at least one translation task type is more than one translation task type, the present application can also execute multiple translation task types simultaneously to translate the initial text into multiple different types of translation texts, thereby further improving the translation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A diagram showing an application environment of a text translation method in an embodiment;

[0033] Figure 2 A flowchart of a text translation method in one embodiment;

[0034] Figure 3 A schematic diagram of triggering translation in one embodiment;

[0035] Figure 4 A schematic diagram of determining a translation task type in one embodiment;

[0036] Figure 5 A schematic diagram of generating a marked text in one embodiment;

[0037] Figure 6 A schematic diagram of the overall framework of text translation in one embodiment;

[0038] Figure 7 A schematic diagram of adding a marking label in one embodiment;

[0039] Figure 8 A schematic diagram of adding a marking label in another embodiment;

[0040] Fig. 9 A schematic diagram of generating a coding vector sequence in one embodiment;

[0041] Fig.10 A schematic diagram of decoding in one embodiment;

[0042] Fig.11 A schematic diagram of multiple translations in one embodiment;

[0043] Fig.12 A flowchart of a text translation method in a specific embodiment;

[0044] Fig.13 is a structural block diagram of a text translation device in an embodiment;

[0045] Fig.14 is an internal structure diagram of a computer device in one embodiment;

[0046] Fig.15 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0048] The text translation method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other servers. Both the terminal 102 and the server 104 can be used alone to execute the text translation method provided in the embodiment of the present application. The terminal 102 and the server 104 can also be used in conjunction to execute the text translation method provided in the embodiment of the present application. Taking the terminal 102 and the server 104 as an example of being used in conjunction to execute the text translation method provided in the embodiment of the present application, the terminal 102 can obtain the initial text and send the obtained initial text to the server 104, so that the server 104 translates the received initial text, obtains a variety of translations, and returns the generated multiple translations to the terminal 104 for display. Among them, the terminal 102 can be, but is not limited to, various desktop computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices, and the Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0049] It should be noted that this application involves artificial intelligence technology. For example, this application is to optimize the training of object detection models used to detect detection objects. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that involves a wide range of fields, including both hardware-level technology and software-level technology. Basic artificial intelligence technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0050] It should be noted that the "first", "second" and similar words used in this application do not indicate any order, quantity or importance, but are only used to distinguish different components. Unless the context clearly indicates otherwise, the singular form "one", "an" or "the" and other similar words do not indicate a quantity limitation, but rather indicate the presence of at least one. The "at least one" mentioned in the various embodiments of the present application refers to one or more than one. The quantities of "multiple" or "multiple copies" mentioned in the various embodiments of the present application all refer to the quantity of "at least two", for example, "multiple" refers to "at least two", and "multiple copies" refers to "at least two copies".

[0051] In one embodiment, Figure 2 As shown, a text translation method is provided, and the method is applied to a computer device as an example for explanation. The computer device may be Figure 1 The text translation method comprises the following steps:

[0052] Step 202: obtaining an initial text and determining at least one translation task type for translating the initial text.

[0053] Among them, the initial text refers to the text to be translated. The initial text can specifically be a text sentence, a document, a conversation, etc. A document can include multiple text sentences, and a text sentence can include one or more words. The conversation can be a two-party conversation, or it can also be a multi-party conversation. The translation task is a task that indicates the translation of the initial text. The translation task type refers to the type of the translation task, and the translation task type can specifically include a text sentence translation task type, a document translation task type, a conversation translation task type, a multimodal translation task type, and a personalized translation task type, etc.

[0054] Specifically, the computer device may receive a text translation request, and determine the initial text pointed to by the text translation request and at least one type of translation task for translating the initial text. For example, a text translation application may be run in the terminal, and when the user desires to translate the initial text, the user may specify the initial text to be translated through the text translation application, and specify at least one type of translation task for translating the initial text, so that the terminal may generate a text translation request based on the initial text and the translation task type specified by the user, and send the text translation request to the server, so that the server responds to the text translation request, determines the initial text pointed to by the text translation request and at least one type of translation task for translating the initial text.

[0055] In one embodiment, the computer device may extract text from the image and generate the initial text based on the text extracted from the image. Alternatively, the computer device may perform speech recognition on the audio and generate the initial text based on the recognized text.

[0056] In one embodiment, the computer device may perform text analysis on the initial text, and determine at least one type of translation task for translating the initial text based on the text analysis result. For example, when the initial text includes multiple text sentences, it may be determined that at least one type of translation task for translating the initial text includes a document translation task type; when the initial text includes a text sentence, it may be determined that at least one type of translation task for translating the initial text includes a text sentence translation task type; when the initial text includes a user's conversation content, it may be determined that at least one type of translation task for translating the initial text includes a conversation translation task type.

[0057] In one embodiment, determining at least one translation task type for translating an initial text includes: in response to a translation trigger operation on the initial text, displaying a translation task type list; in response to a selection operation on the translation task type list, using at least one translation type selected by the selection operation as the at least one translation task type for translating the initial text.

[0058] Specifically, the computer device may be a terminal, and a text translation application may be run in the terminal. The user may determine the initial text through the text translation application. For example, the user may upload the initial text in the text translation application, or the user may input a voice through the text translation application, and the text translation application may perform voice recognition on the voice input by the user to obtain the initial text. Furthermore, the user may trigger a translation trigger operation through the text translation application, and the text translation application may display a list of translation task types. For example, refer to Figure 3 The text translation application can display a translation control 301. When the user clicks the translation control 301, the text translation application can display the following Figure 4 The translation task type list shown. The translation task type list may include multiple translation task types. The user may select one or more of the translation task types, so that the text translation application uses each translation task type selected by the user as a translation task type for translating the initial text. Figure 3 A schematic diagram of triggering translation in one embodiment is shown. Figure 4 A schematic diagram of determining the type of translation task in one embodiment is shown.

[0059] In one embodiment, the text translation application may also use a plurality of preset translation task types as translation task types for translating the initial text.

[0060] In the above embodiment, by displaying the translation task type list, the user can independently select the translation task type that needs to translate the initial text according to the needs, thereby greatly improving the user experience.

[0061] Step 204, for at least one translation task type, respectively add markup tags to the initial text to obtain at least one marked text; the marked texts in the at least one marked text correspond one-to-one to the translation task types in the at least one translation task type, and the marked tags in each marked text include a translation task tag representing the corresponding translation task type.

[0062] Among them, the marking label refers to a label that marks the structure of the text and the type of translation task for translating the text. The marking label may include a translation task label for characterizing the type of translation task and a text structure label for indicating the structure of the text. The translation task label refers to a label that identifies the type of translation task. For example, the translation task label may specifically be a text sentence translation task label that characterizes a text sentence translation task type, a document translation task label that characterizes a document translation task type, a personalized translation task label that characterizes a personalized translation task type, a multimodal translation task label that characterizes a multimodal translation task type, or a dialogue translation task label that characterizes a dialogue translation task type.

[0063] Specifically, the computer device may determine at least one type of translation task for translating the initial text, and obtain a corresponding tag for each determined translation task type. Figure 5 When it is determined that the initial text needs to be translated into a personalized translation and a document translation, the computer device may obtain a markup tag corresponding to the personalized translation task type, and obtain a markup tag set corresponding to the document translation task type. Each markup tag obtained includes a translation task tag representing the corresponding translation task type. For example, in the above example, the markup tag corresponding to the personalized translation task type obtained may include a translation task tag used to represent the personalized translation task type; the markup tag corresponding to the document translation task type obtained may include a translation task tag used to represent the document translation task type.

[0064] Furthermore, when the markup tags corresponding to each translation task type are obtained, for each translation task type in at least one translation task type, the computer device may add the markup tags corresponding to the translation task type to the initial text, thereby obtaining the marked text corresponding to the translation task type. For example, in the above example, the computer device may add the markup tags corresponding to the personalized translation task type to the initial text, thereby obtaining the marked text corresponding to the personalized translation task type; and add the markup tags corresponding to the document translation task type to the initial text, thereby obtaining the marked text corresponding to the personalized translation task type. Figure 5 A schematic diagram of generating a marked text in an embodiment is shown.

[0065] Step 206: Determine at least one text encoding method adapted to the at least one marked text based on the translation task tag included in the at least one marked text.

[0066] Specifically, when generating the marked text corresponding to at least one translation task type, that is, when generating at least one marked text, for each marked text in the at least one marked text, the computer device can determine the translation task tag included in the marked text, and determine the corresponding text encoding method according to the determined translation task tag. For example, when the translation task tag included in the marked text is a word translation task tag representing the dialogue translation task type, the computer device can determine that the text encoding method adapted to the word translation task tag is a dialogue encoding method for encoding the dialogue content. Among them, the text encoding methods adapted to each marked text in the at least one marked text can be the same or different. For example, when the at least one marked text includes a marked text corresponding to the dialogue translation task type and a marked text corresponding to the text sentence translation task type, it can be determined that the method for encoding the marked text corresponding to the dialogue translation task type is the dialogue encoding method, and the method for encoding the marked text corresponding to the text sentence translation task type is the text sentence encoding method. When at least one marked text includes marked text corresponding to a text sentence translation task type and marked text corresponding to a personalized translation task type, it can be determined that the method used to encode the marked text corresponding to the text sentence translation task type is a text sentence encoding method, and the method used to encode the marked text corresponding to the personalized translation task type is also determined to be a text sentence encoding method.

[0067] In one embodiment, the computer device may also determine the text encoding mode according to the text content in the initial text. When the initial text includes dialogue content, the encoding mode adapted to the at least one markup text is determined to be the dialogue encoding mode. When the initial text does not include dialogue content, the encoding mode adapted to the at least one markup text is determined to be the dialogue encoding mode text sentence encoding mode.

[0068] In one embodiment, the computer device may store a correspondence between the translation task tag and the adapted text encoding method. When determining the translation task tag in the targeted marked text, the computer device may determine the text encoding method adapted to the translation task tag in the targeted marked text based on the correspondence between the translation task tag and the adapted text encoding method.

[0069] Step 208: For each of the at least one marked text, semantic encoding processing is performed according to the adapted text encoding method to obtain a coding vector sequence corresponding to at least one translation task type.

[0070] Specifically, for each marked text in at least one marked text, the computer device can perform semantic encoding processing on the marked text according to a text encoding method suitable for the marked text to obtain a coding vector sequence corresponding to the marked text.

[0071] In one embodiment, the computer device may map the targeted marked text to a high-dimensional space according to a text encoding method suitable for the targeted marked text, thereby obtaining a corresponding encoding vector sequence. For example, the computer device may convert the targeted marked text into multiple vectors of a preset dimension, thereby synthesizing the multiple vectors to obtain a corresponding encoding vector sequence.

[0072] In one embodiment, the computer device can perform the text translation method through a text translation model. The text translation model includes an encoding network and a decoding network. The encoding network can encode the marked text to obtain a corresponding encoding vector sequence.

[0073] Step 210 , semantic decoding is performed on the coding vector sequences corresponding to at least one translation task type to obtain translation texts corresponding to at least one translation task type.

[0074] Specifically, the computer device can decode the encoding vector sequences corresponding to at least one translation task type through the decoding network in the text translation model to obtain the translation text corresponding to at least one translation task type.

[0075] In one embodiment, reference Figure 6 , Figure 6 The overall framework schematic diagram of text translation in one embodiment is shown. A text translation model is deployed in a computer device, and the text translation model may include an encoding network and a decoding network. When the initial text is obtained, the encoding network can convert the initial text according to at least one translation task type for translating the initial text, and obtain a marked text corresponding to each of the at least one translation task type. Further, for each marked text, the encoding network can encode the corresponding marked text according to the text encoding method adapted for each marked text, so as to obtain a coding vector sequence corresponding to each marked text. The encoding network can input each generated coding vector sequence into a decoding network, so as to decode each coding vector sequence respectively through the decoding network, so as to obtain a translation translation corresponding to at least one translation task type.

[0076] In the above-mentioned text translation method, by obtaining the initial text, at least one type of translation task for translating the initial text can be determined. By determining at least one type of translation task, the initial text can be converted into a marked text corresponding to each type of translation task based on the determined translation task type. By generating at least one marked text, at least one text encoding method adapted to at least one marked text can be determined based on the translation task tag included in the at least one marked text, so that the corresponding marked text is encoded according to the adapted text encoding method, and a coding vector sequence corresponding to at least one translation task type is obtained, and then each coding vector sequence is decoded to obtain a translation text corresponding to at least one translation task type. Since the present application can automatically translate the initial text, the translation efficiency is improved compared to traditional manual translation. And when at least one translation task type is more than one translation task type, the present application can also execute multiple translation task types simultaneously to translate the initial text into multiple different types of translation texts, thereby further improving the translation efficiency.

[0077] In one of the embodiments, for at least one translation task type, marking tags are added to the initial text respectively to obtain at least one marked text, including: for each translation task type in the at least one translation task type, obtaining the marking tags corresponding to the targeted translation task type; adding the marking tags corresponding to the targeted translation task type to the initial text to obtain the marked text corresponding to the targeted translation task type.

[0078] Specifically, the computer device obtains the correspondence between the translation task type and the markup tag to be added. For each translation task type in at least one translation task type, the computer device determines the markup tag corresponding to the translation task type according to the correspondence between the translation task type and the markup tag to be added. Further, the computer adds the determined markup tag to the initial text to obtain the markup text corresponding to the translation task type. For example, when the translation task type is a document translation task type, the computer device can determine that the markup tag corresponding to the document translation task type is a document markup tag according to the correspondence between the translation task type and the markup tag to be added. At this time, the computer device adds the document markup tag to the initial text to obtain the markup text corresponding to the document translation task type.

[0079] In this embodiment, by obtaining the correspondence between the translation task type and the markup tag to be added, the markup tag to be added can be quickly determined based on the correspondence, thereby improving the efficiency of adding the markup tag. Since the markup tag can represent the type of translation task to be translated for the initial text, adding the corresponding markup tag to the initial text can facilitate the text translation model to determine the translation method that needs to be translated for the initial text, thereby obtaining the translation of the corresponding translation task type.

[0080] In one of the embodiments, at least one translation task type includes at least one of a text sentence translation task type, a document translation task type, a dialogue translation task type, a multimodal translation task type, or a personalized translation task type; the translation task of the text sentence translation task type is used to translate text sentences; the translation task of the document translation task type is used to translate documents; the translation task of the dialogue translation task type is used to translate dialogue content; the translation task of the multimodal translation task type is used to translate text extracted from multimedia; and the translation task of the personalized translation task type is used to perform personalized translation of text.

[0081] Among them, text sentences refer to sentences, and translation tasks of the text sentence translation task type are used to translate text sentences, such as translating proverbs, translating famous sayings, etc. Documents refer to texts that include at least one text sentence, and translation tasks of the document translation task type are used to translate each text sentence in the document. Dialogues refer to dialogues between two or more objects, and translation tasks of the dialogue translation task type are used to translate the content of dialogues. Translation tasks of the multimodal translation task type are used to translate texts extracted from multimedia, such as translating sentences obtained through speech recognition, or translating text extracted from images. Translation tasks of the personalized translation task type are used to perform personalized translations on texts, such as translating texts into translated texts with local characteristics, etc.

[0082] In one embodiment, for each translation task type in at least one translation task type, the computer device can determine a marking tag corresponding to the translation task type. The marking tag corresponding to the translation task type can be a translation task tag representing the translation task type, so that the computer device adds the translation task tag representing the translation task type to the initial text to obtain a marked text corresponding to the translation task type.

[0083] For example, when the initial text sentence is "The above is the reason for going out", and the translation task type is a text sentence translation task type, the computer device may determine that the mark label corresponding to the text sentence translation task type is the text sentence translation task label " <sentmt>", at this time, the computer equipment will" <sentmt>"Add to the initial text "The above is the reason for going out", and get the marked text corresponding to the text sentence translation task type" <sentmt>The above is the reason for going out. When the initial text sentence is "The above is the reason for going out" and the translation task type is a document translation task type, the computer device can determine that the mark label corresponding to the document translation task type is the document translation task label " <docmt>", at this time, the computer equipment will" <docmt>"Add to the initial text "The above is the reason for going out", get the marked text corresponding to the document translation task type" <docmt>That’s the reason to go out.”

[0084] In this embodiment, by setting a plurality of translation task types, the text translation model can simultaneously execute a plurality of translation task types to obtain a plurality of translation texts, thereby improving the translation efficiency of the text translation.

[0085] In one of the embodiments, the marking tags corresponding to the targeted translation task type include a first sentence start tag, a first sentence end tag, an end tag, and a translation task tag representing the targeted translation task type; adding the marking tags corresponding to the targeted translation task type to the initial text to obtain the marked text corresponding to the targeted translation task type includes: when the number of text sentences included in the initial text is less than or equal to a preset number threshold, adding the translation task tag representing the targeted translation task type to the head of the initial text; adding the first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text; adding the first sentence end tag at the end of the initial text, and adding the end tag after the added first sentence end tag, to obtain the marked text corresponding to the targeted translation task type.

[0086] Specifically, the computer device may determine the marking tags corresponding to the translation task type according to the number of text sentences included in the initial text and the translation task type. When the number of text sentences included in the initial text is less than or equal to the preset number threshold, the marking tags corresponding to the translation task type may specifically include the first sentence start tag, the first sentence end tag, the end tag, and the translation task tag representing the translation task type. Further, referring to Figure 7 The computer device adds a translation task tag representing the targeted translation task type to the head of the initial text, adds a first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text, adds a first sentence end tag to the tail of the initial text, and adds an end tag after the added first sentence end tag, thereby obtaining a marked text corresponding to the targeted translation task type. Figure 7 A schematic diagram of adding a marking tag in one embodiment is shown.

[0087] In one embodiment, the preset quantity threshold may specifically be 1, that is, when the initial text includes a text sentence, the markup tags corresponding to the targeted translation task type may specifically include a first sentence start tag, a first sentence end tag, an end tag, and a translation task tag representing the targeted translation task type.

[0088] In one embodiment, when the initial text includes a text sentence, the markup tags corresponding to the translation task type may specifically include a first sentence start tag, a first sentence end tag, an end tag, and a translation task tag representing the translation task type. For example, the first sentence start tag may specifically be " <bos>", the first sentence end tag can be " <eos> <context>", the end tag can be "NULL"; the text sentence translation task tag representing the text sentence translation task type can be " <sentmt>", the document translation task label representing the document translation task type can be specifically " <docmt>", the dialog translation task label representing the dialog translation task type can be specifically " <chatmt>", the multimodal translation task label representing the multimodal translation task type can be specifically " <dentmt>", the personalized translation task label representing the personalized translation task type can be specifically " <permt>”.

[0089] Thus, when the initial text sentence is "The above is the reason for going out", and the translation task type is the text sentence translation task type, the corresponding marked text is " <sentmt> <bos>These are the reasons to go out. <eos> <context>NULL"; when the translation task type is a document translation task type, the corresponding tag text is " <docmt> <bos>These are the reasons to go out. <eos> <context>NULL"; when the translation task type is a dialogue translation task type, the corresponding marker text is " <chatmt> <bos>These are the reasons to go out. <eos> <context>NULL", and so on.

[0090] In the above embodiment, the first sentence start tag, the first sentence end tag, the end tag and the translation task tag representing the type of translation task are used to facilitate the text translation model to determine the text structure of the initial text and the type of translation task to be performed based on the added tags, thereby performing the corresponding translation task based on the determined type of translation task to be performed, and performing a more accurate translation based on the determined text structure to obtain a more accurate translation.

[0091] In one of the embodiments, the marking tags corresponding to the targeted translation task type include a first sentence termination tag, a sentence spacing tag, and a translation task tag representing the targeted translation task type; adding the marking tags corresponding to the targeted translation task type to the initial text to obtain the marked text corresponding to the targeted translation task type includes: when the number of text sentences included in the initial text is greater than a preset number threshold, adding the translation task tag representing the targeted translation task type at the beginning of the initial text; adding the first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text; adding the first sentence termination tag at the end of the first text sentence in the initial text; determining the remaining text sentences except the first text sentence in the initial text, and adding a sentence spacing tag between every two adjacent remaining text sentences to obtain the marked text corresponding to the targeted translation task type.

[0092] Specifically, the computer device may determine the marking label corresponding to the translation task type according to the number of text sentences included in the initial text and the translation task type. When the number of text sentences included in the initial text is greater than a preset number threshold, the marking label corresponding to the translation task type may specifically include a first sentence start label, a first sentence end label, a sentence interval label, and a translation task label representing the translation task type. Further, referring to Figure 8 The computer device adds a translation task tag representing the translation task type to the head of the initial text, adds a first sentence start tag after the translation task tag representing the translation task type and before the first sentence of the initial text, and adds a first sentence end tag to the tail of the initial text. Further, the computer device determines the remaining text sentences except the first text sentence in the initial text, and adds a sentence spacing tag between every two adjacent remaining text sentences to obtain a marked text corresponding to the translation task type. Figure 8 A schematic diagram of adding a marking label in another embodiment is shown.

[0093] In one embodiment, the sentence interval label may be specifically " <sep>For example, when the initial text sentence is "The above are the reasons for going out. Cheer up and say to the dog: Mommy will take you out. Write down in detail a few things to do when going out. Bought some snacks for the dog. " and the translation task type is the document translation task type, the corresponding marked text is " <docmt> <bos>The above are the reasons to go out. <eos> <context>Cheer up and say to the dog: Mommy will take you out. <sep>I wrote down in detail a few things I needed to do before going out. <sep>I bought some snacks for my dog. "; When the translation task type is a personalized translation task type, the corresponding marker text is " <permt> <bos>The above are the reasons to go out. <eos> <context>Cheer up and say to the dog: Mommy will take you out. <sep>I wrote down in detail a few things I needed to do before going out. <sep>Bought some dog snacks.", etc.

[0094] In the above embodiment, by using the first sentence start label, the first sentence end label, the sentence interval label and the translation task label that characterizes the type of translation task, the text translation model can determine the text structure and the type of task to be translated of the initial text based on the added labels, thereby executing the corresponding translation task based on the determined type of task to be translated, and performing a more accurate translation based on the determined text structure to obtain a more accurate translation.

[0095] It is easy to understand that the encoding network in the text translation model can perform the above-mentioned marking label adding process to obtain at least one marked text.

[0096] In one of the embodiments, determining at least one text encoding method adapted to at least one marked text includes: for each marked text in the at least one marked text, when the translation task type represented by the translation task tag included in the marked text belongs to the dialogue task type, determining the text encoding method adapted to the marked text to be a dialogue encoding method for encoding dialogue content; when the translation task type represented by the translation task tag included in the marked text belongs to the non-dialogue task type, determining the text encoding method adapted to the marked text to be a sentence encoding method for encoding non-dialogue content.

[0097] Specifically, the translation task type includes translation task types belonging to the dialogue task type and translation task types belonging to the non-dialogue task type. For example, the dialogue translation task type is a translation task type belonging to the dialogue task type; the text sentence translation task type, document translation task type, multimodal translation task type and personalized translation task type are all translation task types belonging to the non-dialogue task type.

[0098] Furthermore, a text translation model may be deployed in the computer device, and the text translation model includes an encoding network and a decoding network. For each marked text in the at least one generated marked text, the encoding network extracts the translation task label in the marked text, and determines whether the translation task type represented by the extracted translation task label belongs to the dialogue task type. If it belongs to the dialogue task type, the text encoding method adapted to the marked text is determined to be a dialogue encoding method for encoding dialogue content; if it does not belong to the dialogue task type, the text encoding method adapted to the marked text is determined to be a sentence encoding method for encoding non-dialogue content.

[0099] Exemplarily, when the translation task label extracted from the targeted marked text is a dialogue translation task label, the dialogue encoding mode is used as the encoding mode corresponding to the targeted marked text. When the translation task label extracted from the targeted marked text is a text sentence translation task label, a document translation task label, a multimodal translation task label, or a personalized translation task label, the sentence encoding mode is used as the encoding mode corresponding to the targeted marked text.

[0100] In this embodiment, since the dialogue encoding method is suitable for encoding dialogue content and the sentence encoding method is suitable for encoding text sentences, by adding translation task tags to the initial text, an adapted encoding method can be determined based on the added translation task tags, thereby performing more accurate encoding based on the adapted encoding method, and obtaining a more accurate encoding vector sequence.

[0101] In one of the embodiments, for each of at least one marked text, semantic encoding processing is performed according to an adapted text encoding method to obtain an encoding vector sequence corresponding to at least one translation task type, including: for each marked text in the at least one marked text, when the text encoding method adapted to the marked text is a dialogue encoding method, dialogue turn encoding processing is performed on each text sentence in the marked text to obtain a dialogue turn encoding vector corresponding to each text sentence in the marked text; dialogue role encoding processing is performed on each text sentence in the marked text to obtain a dialogue role encoding vector corresponding to each text sentence in the marked text; word embedding processing is performed on each text sentence in the marked text to obtain a word embedding vector sequence corresponding to each text sentence in the marked text; position encoding processing is performed on each text sentence in the marked text to obtain a position encoding vector sequence corresponding to each text sentence in the marked text; according to the dialogue turn encoding vector, dialogue role encoding vector, word embedding vector sequence and position encoding vector sequence corresponding to each text sentence in the marked text, an encoding vector sequence corresponding to the marked text is obtained.

[0102] Specifically, for each marked text in at least one marked text, when the text encoding method adapted to the marked text is a dialogue encoding method, the encoding network performs dialogue turn encoding processing on each text sentence in the marked text to obtain a dialogue turn encoding vector corresponding to each text sentence in the marked text. The dialogue turn encoding processing refers to encoding the dialogue turn to which the text sentence belongs. And, the encoding network performs dialogue role encoding processing on each text sentence in the marked text to obtain a dialogue role encoding vector corresponding to each text sentence in the marked text; the dialogue role encoding processing refers to encoding the dialogue role to which the text sentence belongs.

[0103] Furthermore, the encoding network performs word embedding processing on each text sentence in the targeted marked text, and obtains a sequence of word embedding vectors corresponding to each text sentence in the targeted marked text. For example, for each text sentence, the encoding network encodes each word in the text sentence to obtain a word embedding vector, and combines the word embedding vectors corresponding to each word to obtain a sequence of word embedding vectors corresponding to the text sentence. The encoding network performs position encoding processing on each text sentence in the targeted marked text, and obtains a sequence of position encoding vectors corresponding to each text sentence in the targeted marked text. For example, for each text sentence, the encoding network determines the position of the word in the text sentence in the text sentence, and encodes the determined position, thereby obtaining a position encoding vector corresponding to each word in the text sentence, and combines the position encoding vectors corresponding to each word to obtain a sequence of position encoding vectors corresponding to the text sentence.

[0104] In one embodiment, reference Fig. 9 , when the marked text to be targeted is determined to be a dialogue text based on the marked label added in the marked text, for each text sentence in the marked text, the encoding network will generate the corresponding dialogue turn encoding vector, dialogue role encoding vector, word embedding vector sequence and position encoding vector sequence, so that the encoding network can obtain the encoding vector sequence corresponding to the targeted marked text by combining the dialogue turn encoding vector, dialogue role encoding vector, word embedding vector sequence and position encoding vector sequence corresponding to each text sentence. For example, the encoding network concatenates the dialogue turn encoding vector, dialogue role encoding vector, word embedding vector sequence and position encoding vector sequence corresponding to the same text sentence to obtain the concatenated vector, and combines the concatenated vectors corresponding to each text sentence to obtain the concatenated vector sequence corresponding to the targeted marked text. The encoding network performs self-attention processing on the concatenated vector sequence to obtain the encoding vector sequence corresponding to the targeted marked text. Fig. 9 A schematic diagram of generating a coding vector sequence in an embodiment is shown.

[0105] In this embodiment, by performing dialogue turn encoding processing, dialogue role encoding processing, word embedding processing and position encoding processing on the text sentences in the dialogue, the encoded encoding vector sequence can contain dialogue turn information, dialogue role information, dialogue content information and dialogue context information, that is, the generated encoding vector sequence can contain rich information, and then generate a more accurate decoded translation based on the rich information.

[0106] In one of the embodiments, each text sentence in the targeted marked text is respectively processed for dialogue turn encoding to obtain a dialogue turn encoding vector corresponding to each text sentence in the targeted marked text, including: for each text sentence in the targeted marked text, respectively determining the dialogue turn of each text sentence in the targeted marked text; respectively encoding each determined dialogue turn to obtain a dialogue turn encoding vector corresponding to each text sentence in the targeted marked text.

[0107] Specifically, for each text sentence in the targeted marked text, the encoding network can determine the dialogue turn to which the current text sentence belongs. The dialogue turn refers to the turn to which the dialogue belongs. For example, when the first dialogue round ends and the second dialogue round begins, the text sentence output by the second dialogue round belongs to the second dialogue round. The encoding network can encode the dialogue turn to which the current text sentence belongs, thereby obtaining the dialogue turn encoding vector corresponding to the current text sentence.

[0108] In one of the embodiments, each text sentence in the targeted marked text is respectively subjected to dialogue role encoding processing to obtain a dialogue role encoding vector corresponding to each text sentence in the targeted marked text, including: determining the dialogue role to which each text sentence in the targeted marked text belongs according to the dialogue role identifier carried by each text sentence in the targeted marked text; and encoding the dialogue role to which each text sentence belongs to respectively to obtain a dialogue role encoding vector corresponding to each text sentence in the targeted marked text.

[0109] Specifically, for each text sentence in the targeted marked text, the encoding network can determine the dialogue role to which the current text sentence belongs. A dialogue role refers to the dialogue object in a two-party or multi-party dialogue. For example, when A and B are having a dialogue, A and B are dialogue roles. The encoding network can determine whether the current text sentence is spoken by A or B. If it is spoken by A, the dialogue role to which the current text sentence belongs is determined to be A. If it is spoken by B, the dialogue role to which the current text sentence belongs is determined to be B. Further, when the dialogue role to which the current text sentence belongs is determined, the dialogue role to which the current text sentence belongs can be encoded, thereby obtaining the dialogue role encoding vector corresponding to the current text sentence.

[0110] In one of the embodiments, for each of at least one marked text, semantic encoding processing is performed according to an adapted text encoding method to obtain a coding vector sequence corresponding to at least one translation task type, including: for each marked text in the at least one marked text, when the text encoding method adapted to the targeted marked text is a sentence encoding method, word embedding processing is performed on each word in the targeted marked text to obtain a word embedding vector corresponding to each word in the targeted marked text; position encoding processing is performed on each word in the targeted marked text to obtain a position encoding vector corresponding to each word in the targeted marked text; the word embedding vector and the position encoding vector corresponding to the same word are superimposed to obtain a superimposed vector corresponding to each word in the targeted marked text; according to the superimposed vector corresponding to each word in the targeted marked text, a coding vector sequence corresponding to the targeted marked text is obtained.

[0111] Specifically, for each marked text in at least one marked text, when the text encoding method adapted to the marked text is a sentence encoding method, the encoding network can determine the words in the marked text, and perform word embedding processing on each word in the marked text, so as to obtain the word embedding vector corresponding to each word in the marked text. Further, the encoding network determines the position of each word in the marked text, and encodes the position of each word, so as to obtain the position encoding vector corresponding to each word in the marked text. Further, the encoding network superimposes the word embedding vector and the position encoding vector corresponding to the same word, so as to obtain the superimposed vector corresponding to each word in the marked text. For example, when the marked text includes word a and word b, the encoding network can superimpose the word embedding vector and the position encoding vector corresponding to word a, so as to obtain the superimposed vector corresponding to word a, and superimpose the word embedding vector and the position encoding vector corresponding to word b, so as to obtain the superimposed vector corresponding to word b. Furthermore, the encoding network combines the superimposed vector corresponding to word a and the superimposed vector corresponding to word b to obtain an encoding vector sequence corresponding to the targeted marked text.

[0112] In one embodiment, when the superposition vector corresponding to each word is obtained, the encoding network can perform self-attention processing on each superposition vector respectively, so as to obtain the self-attention superposition vector corresponding to each word, and the encoding vector sequence can be obtained by combining the self-attention superposition vectors corresponding to each word.

[0113] In one embodiment, when the initial text is a dialogue text, a mark tag corresponding to the dialogue translation task type may be added to the initial text to obtain a marked text, so that the marked text may be encoded by a dialogue encoding method. When the initial text is a non-dialogue text, a mark tag corresponding to the text sentence translation task type, a mark tag corresponding to the document translation task type, a mark tag corresponding to the multimodal translation task type, or a mark tag corresponding to the personalized translation task type may be added to the initial text to obtain a marked text, and then the marked text may be encoded by a sentence encoding method. It is easy to understand that when the initial text is a non-dialogue text, multiple marked texts may be generated based on the mark tags corresponding to the text sentence translation task type, the mark tags corresponding to the document translation task type, the mark tags corresponding to the multimodal translation task type, or the mark tags corresponding to the personalized translation task type, and the multiple marked texts may be encoded respectively by a sentence encoding method.

[0114] In this embodiment, by performing word embedding processing, the encoding vector sequence can include the meaning of each word in the marked text, and by performing position encoding processing, the encoding vector sequence can include the arrangement order information of each word in the marked text in the initial text, thereby obtaining a more accurate translation based on the word meaning and arrangement order information.

[0115] In one of the embodiments, semantic decoding processing is performed on coding vector sequences corresponding to at least one translation task type to obtain a translation text corresponding to at least one translation task type, including: for each coding vector sequence, a first translation word is generated based on the targeted coding vector sequence and a start character corresponding to the targeted coding vector sequence; at least one round of decoding processing is performed based on the first translation word and the targeted coding vector sequence to obtain at least one subsequent translation word; and the first translation word and at least one subsequent translation word are combined to obtain a translation text corresponding to the targeted coding vector sequence.

[0116] Specifically, the decoding network in the text translation model can decode each encoding vector sequence to obtain the translation text corresponding to each encoding vector sequence, that is, to obtain the translation text corresponding to at least one translation task type. For each encoding vector sequence corresponding to at least one marked text, the decoding network obtains the start character corresponding to the encoding vector sequence in question, and generates the first translation word based on the encoding vector sequence in question and the obtained start character. Furthermore, the decoding network can perform at least one round of decoding based on the first translation word and the encoding vector sequence in question, to obtain the subsequent translation words output in each round. The decoding network sorts the subsequent translation words in the order of the decoding rounds to obtain a sequence of subsequent translation words, and adds the first translation word to the head of the subsequent translation word, to obtain the translation text corresponding to the encoding vector sequence in question.

[0117] In one embodiment, the translation task label in the markup text corresponding to the targeted coding vector sequence may be extracted, and the coding vector obtained by encoding the extracted translation task label is used as the start character corresponding to the targeted coding vector sequence.

[0118] In the above embodiment, by sequentially generating translation words, corresponding translation texts can be output based on the sequentially generated translation words.

[0119] In one of the embodiments, generating a first translation word based on a targeted coding vector sequence and a starting character corresponding to the targeted coding vector sequence includes: obtaining a starting character corresponding to the targeted coding vector sequence, and performing self-attention processing on the starting character to obtain a first content representation vector; performing self-attention processing on the targeted coding vector sequence and the first content representation vector to obtain a first interaction representation vector; decoding the first interaction representation vector to obtain a first translation word.

[0120] Specifically, the decoding network obtains the start character corresponding to the targeted encoding vector sequence, and performs single-head self-attention processing or multi-head self-attention processing on the start character, thereby obtaining the first content representation vector. Further, the decoding network performs single-head self-attention processing or multi-head self-attention processing on the targeted encoding vector sequence and the first content representation vector, thereby obtaining the first interaction representation vector. The decoding network decodes the first interaction representation vector to obtain the first translation word.

[0121] In this embodiment, only one start character needs to be set, and the first translation word can be output based on the start character, so that subsequent translation words can be output based on the generated first translation word.

[0122] In one of the embodiments, performing at least one round of decoding processing based on the first translation word and the targeted encoding vector sequence to obtain at least one subsequent translation word includes: determining the current round, and determining the historical translation words output in each historical round before the current round to obtain a historical translation word sequence; performing self-attention processing on the historical translation word sequence to obtain a current content representation vector; performing self-attention processing on the targeted encoding vector sequence and the current content representation vector to obtain a current interaction representation vector; decoding the current interaction representation vector to obtain a subsequent translation word output in the current round; entering the next round of decoding processing, taking the next round as the current round, returning to determine the historical translation words output in each historical round before the current round, and continuing the steps of obtaining the historical translation word sequence until the last subsequent translation word is output.

[0123] Specifically, for the decoding process of the current round, the decoding network determines all historical rounds before the current round, and determines the historical translation words output in each historical round, and synthesizes the historical translation words to obtain a historical translation word sequence. For example, when the current round is the third round, the first round and the second round can be used as historical rounds, and the translation words output in the first round and the second round are obtained. At this time, the translation words output in the first round and the second round are historical translation words. The decoding network synthesizes the historical translation words to obtain a historical translation word sequence. Among them, the position of the historical translation word in the historical translation word sequence is consistent with the order of the historical decoding rounds that output the historical translation word in all decoding rounds.

[0124] Further, the decoding network performs single-head self-attention processing or multi-head self-attention processing on the historical translation word sequence to obtain the current content representation vector, and performs single-head self-attention processing or multi-head self-attention processing on the targeted encoding vector sequence and the current content representation vector to obtain the current interaction representation vector. The decoding network performs decoding processing on the current interaction representation vector to obtain the continuous translation word output in the current round. The decoding network enters the next round of decoding processing, takes the next round as the current round, and returns to determine the historical translation words output in each historical round before the current round, and the step of obtaining the historical translation word sequence continues to be executed until the last continuous translation word is output.

[0125] In one embodiment, reference Fig.10 In the first round of decoding, the first translation word can be output based on the start character. In the decoding after the first round, the translation word of the current round can be output based on the translation word output before the historical round. Fig.10 A schematic diagram of decoding in one embodiment is shown.

[0126] In one embodiment, the decoding network may generate a content representation vector using the following formula:

[0127] H y =MultiHead(y,y,y)

[0128] Where y is y 1:t-1 The word embedding representation of y 1:t-1 is the historical translation word sequence; t is the decoding process of the tth round; MultiHead is the multi-head self-attention process.

[0129] In one embodiment, the decoding network can generate the interaction representation vector by the following formula:

[0130]

[0131] Among them, H y H is the content representation vector of the output of the tth round; x is the targeted encoding vector sequence; FFN is a multi-layer feedforward neural network; is the interaction representation vector output by the decoding process of the tth round.

[0132] In one embodiment, the decoding network may output the subsequent translation word by the following formula:

[0133]

[0134] Among them, Y t is the translated word output by the decoding process of the tth round; X is the standard translated word; C is the additional output content, such as pictures or context, etc.; W o and b o These are model parameters of the text translation model; is the interaction representation vector output by the decoding process of the tth round.

[0135] In the above embodiment, by performing self-attention processing on the historical translation word sequence, the output current content representation vector can learn the meaning of the words in the historical translation word sequence, thereby outputting more accurate subsequent translation words based on the learned meaning of the words. By performing self-attention processing on the current content representation vector and the targeted encoding vector sequence, the output interaction representation vector can learn the meaning of the words in the historical translation word sequence and the meaning of the initial text, thereby outputting more accurate subsequent translation words based on the learned meaning of the words in the historical translation word sequence and the meaning of the initial text.

[0136] In one of the embodiments, the text translation method is executed by a text translation model, and the text translation model is obtained by training through a model training step, and the model training step includes: obtaining a sample text and a plurality of standard translation texts corresponding to the sample text; for a plurality of preset translation task types, respectively adding a mark label to the sample text to obtain a plurality of marked sample texts corresponding to the plurality of translation task types; the mark label in each marked sample text includes a translation task label representing the corresponding translation task type; based on the translation task labels respectively included in the plurality of marked sample texts, determining at least one text encoding method adapted for the plurality of marked sample texts; for each of the plurality of marked sample texts, respectively performing semantic encoding processing according to the adapted text encoding method to obtain a sample encoding vector sequence corresponding to each of the plurality of translation task types; respectively performing semantic decoding processing on the sample encoding vector sequence corresponding to each of the plurality of translation task types to obtain a predicted translation text corresponding to each of the plurality of translation task types; training the text translation model through the predicted translation text corresponding to each of the plurality of translation task types and the plurality of standard translation texts to obtain a trained text translation model.

[0137] Specifically, before using the text translation model for text translation, the text translation model can be trained first. When it is necessary to train the text translation model, the computer device can obtain a sample text and a plurality of standard translation texts corresponding to the sample text. Among them, each translation text in the plurality of translation texts corresponds to a plurality of preset translation task types. That is, the computer device can obtain a standard translation text corresponding to each translation task type corresponding to the sample text. Further, the computer device can obtain a markup tag corresponding to each preset plurality of translation task types, and add the markup tags to the sample text respectively, to obtain a markup sample text corresponding to each of the plurality of translation task types. The computer device determines the text encoding method adapted to each of the plurality of sample texts based on the translation task tags included in each of the plurality of marked sample texts, and encodes the corresponding marked sample text according to the adapted text encoding method, thereby obtaining a sample encoding vector sequence corresponding to each of the plurality of translation task types. The computer device performs semantic decoding processing on the sample encoding vector sequences corresponding to the various translation task types respectively, obtains the predicted translation texts corresponding to the various translation task types, and trains the text translation model according to the differences between each predicted translation text and the corresponding standard translation text until the training stops, thereby obtaining a trained text translation model.

[0138] In one embodiment, the computer device can input the sample text into the encoding network, and input multiple standard translation texts into the decoding network, so that the encoding network can convert the sample text into multiple labeled sample texts, and encode each labeled sample text respectively to obtain multiple sample encoding vector sequences. For each of the multiple sample encoding vector sequences, the decoding network determines the translation task type corresponding to the sample encoding vector sequence, and determines the target standard translation text corresponding to the translation task type. The decoding network performs self-attention processing on the first word in the target standard translation text to obtain the first sample content representation vector, and performs self-attention processing on the sample encoding vector sequence and the first sample content representation vector to obtain the first sample interaction representation vector. The decoding network decodes the first sample interaction representation vector to obtain the first translation prediction word. Further, the decoding network performs at least one round of decoding based on the first translation prediction word and the sample encoding vector sequence to obtain at least one subsequent translation prediction word, and synthesizes the first translation prediction word and the subsequent translation prediction word to obtain the predicted translation text corresponding to the sample encoding vector sequence. Among them, the decoding network performs at least one round of decoding based on the first translation prediction word and the targeted sample encoding vector sequence to obtain at least one subsequent translation prediction word, which can refer to the process in which the decoding network performs at least one round of decoding based on the first translation word and the targeted encoding vector sequence.

[0139] In one embodiment, when it is necessary to train a text translation model, multiple preset translation task types may be determined, and sample text sets corresponding to each translation task type may be obtained. For each sample text set corresponding to each translation task type, a markup label may be added to each sample text in the current sample text set corresponding to the current translation task type. The added markup label is a markup label corresponding to the current translation task type. For example, convert sample text X into sample marked text X. input .

[0140] Among them, X input =[s p ,s bos ,X,s eos ,s ctx ,X add ]. p is the translation task label, s bos The tag for the first sentence <bos>,s eos and ctx The first sentence end tag <eos> <context>, X add NULL for the end tag.

[0141] The converted sample marked text can be shown in the following table:

[0142] Sample text These are the reasons to go out. Reference text All these were the reasons to go out. w / SentMT <sentmt> <bos>These are the reasons to go out. <eos> <context>NULL < / context> < / eos> < / bos> < / sentmt> w / DoctMT <doctmt> <bos>These are the reasons to go out. <eos> <context>NULL < / context> < / eos> < / bos> < / doctmt>

[0143] Furthermore, the computer device inputs the above-mentioned sample labeled text into a sequence-to-sequence text translation model for training, and during testing, multiple translation task labels can be added to one test case, so that the computer device converts the test case into multiple test labeled texts according to the added translation task labels, and inputs the multiple test labeled texts into the text translation model for testing.

[0144] In one embodiment, after the sample labeled text is input into the sequence-to-sequence text translation model, at the encoding layer of the text translation model, the input may be processed by word embedding and position encoding, and the part containing the dialogue history may be processed as follows, and an additional dialogue turn encoding vector and dialogue role encoding vector may be added. When generating the tth translation prediction word, the history part y may be processed as follows: 1:t-1 Perform self-attention processing to obtain H y , and the predicted coding vector sequence H output by the coding layer x With H y Perform self-attention processing to obtain the interaction representation vector Thus, the interaction vector Decode to obtain the tth translation prediction word. When multiple translation prediction words are obtained, the computer device can train the text translation model through the following loss function:

[0145]

[0146] Among them, y t is the translation prediction word output by the decoding of the tth round; y 1:-1 is the translation prediction word output from the first round to the t-1th round; X is the standard translation text; C is the additional output content, such as context or pictures.

[0147] In one embodiment, reference Fig.11 When a trained text translation model is obtained, the user can input the initial text into the text translation model and select at least one translation task type for translating the initial text, so that the trained text translation model can translate the initial text and obtain the translation corresponding to at least one translation task type. Fig.11 A schematic diagram showing various translations in one embodiment is shown.

[0148] In the above embodiment, by training the text translation model, the trained text translation model can output multiple translations, thereby improving the efficiency of text translation. And since only one text translation model needs to be trained to make the text translation model output multiple translations, compared with the traditional training of multiple different text translation models so that different text translation models output different translations, the present application can also reduce training costs and storage space during deployment.

[0149] In one embodiment, reference Fig.12 , Fig.12 A text translation method in a specific embodiment is shown, and the text translation method includes:

[0150] Step S1202: In response to a translation trigger operation on the initial text, the computer device displays a translation task type list; in response to a selection operation on the translation task type list, at least one translation type selected by the selection operation is used as at least one translation task type for translating the initial text.

[0151] Step S1204: for each translation task type in the at least one translation task type, the computer device obtains a marking tag corresponding to the translation task type.

[0152] Step S1206, when the number of text sentences included in the initial text is less than or equal to a preset number threshold, the computer device adds a translation task tag representing the targeted translation task type at the beginning of the initial text; adds a first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text; adds a first sentence end tag at the end of the initial text, and adds an end tag after the added first sentence end tag, to obtain a marked text corresponding to the targeted translation task type.

[0153] Step S1208, when the number of text sentences included in the initial text is greater than a preset number threshold, the computer device adds a translation task tag representing the targeted translation task type at the beginning of the initial text; adds a first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text; adds a first sentence end tag at the end of the first text sentence in the initial text; determines the remaining text sentences in the initial text except the first text sentence, and adds a sentence spacing tag between every two adjacent remaining text sentences to obtain a marked text corresponding to the targeted translation task type.

[0154] Step S1210, for each marked text in at least one marked text, when the translation task type represented by the translation task tag included in the marked text belongs to the dialogue task type, the computer device determines that the text encoding method adapted to the marked text is a dialogue encoding method used to encode the dialogue content.

[0155] Step S1212: when the translation task type represented by the translation task tag included in the targeted marked text belongs to the non-dialogue task type, the computer device determines that the text encoding method adapted to the targeted marked text is a sentence encoding method for encoding non-dialogue content.

[0156] Step S1214, for each marked text in at least one marked text, when the text encoding method adapted to the marked text is the dialogue encoding method, the computer device performs dialogue turn encoding processing, dialogue role encoding processing, word embedding processing and position encoding processing on each text sentence in the marked text, and obtains the dialogue turn encoding vector, dialogue role encoding vector, word embedding vector sequence and position encoding vector sequence corresponding to each text sentence in the marked text.

[0157] In step S1216, the computer device obtains a coding vector sequence corresponding to the targeted marked text based on the dialogue turn coding vector, dialogue role coding vector, word embedding vector sequence and position coding vector sequence corresponding to each text sentence in the targeted marked text.

[0158] Step S1218, for each marked text in at least one marked text, when the text encoding method adapted to the marked text is a sentence encoding method, the computer device performs word embedding processing and position encoding processing on each word in the marked text to obtain a word embedding vector and a position encoding vector corresponding to each word in the marked text.

[0159] In step S1220, the computer device superimposes the word embedding vector and the position encoding vector corresponding to the same word to obtain a superimposed vector corresponding to each word in the targeted marked text; based on the superimposed vector corresponding to each word in the targeted marked text, a coding vector sequence corresponding to the targeted marked text is obtained.

[0160] Step S1222: For each coding vector sequence, the computer device obtains the starting character corresponding to the coding vector sequence, and performs self-attention processing on the starting character to obtain the first content representation vector; performs self-attention processing on the coding vector sequence and the first content representation vector to obtain the first interaction representation vector; decodes the first interaction representation vector to obtain the first translation word.

[0161] In step S1224, the computer device determines the current round, and determines the historical translation words output in each historical round before the current round, to obtain a historical translation word sequence; performs self-attention processing on the historical translation word sequence to obtain a current content representation vector; performs self-attention processing on the targeted encoding vector sequence and the current content representation vector to obtain a current interaction representation vector.

[0162] Step S1226, the computer device decodes the current interaction representation vector to obtain the successive translation word output in the current round; enters the decoding process of the next round, takes the next round as the current round, returns to determine the historical translation words output in each historical round before the current round, and continues to execute the step of obtaining the historical translation word sequence until the last successive translation word is output; combines the first translation word and at least one successive translation word to obtain the translation corresponding to the targeted encoding vector sequence.

[0163] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0164] The present application also provides an application scenario, which applies the above-mentioned text translation method. Specifically, the application of the text translation method in the application scenario is as follows:

[0165] A text translation model can be embedded in a game application, so that the text translation model can translate the text generated in the game and obtain multiple translations. For example, the text translation model can translate the dialogue content output by users participating in the game, or can translate the text in the game screen and obtain multiple translations, so that game users can improve their gaming experience based on the translations.

[0166] The present application also provides an application scenario, which applies the above-mentioned text translation method.

[0167] Specifically, the application of the text translation method in this application scenario is as follows:

[0168] A text translation model may be embedded in an instant messaging application, so that the instant conversation content output by the instant messaging application may be translated based on the text translation model, or the document output by the instant messaging application may be translated, etc.

[0169] The above application scenarios are merely illustrative. It is to be understood that the application of the text translation method provided in each embodiment of the present application is not limited to the above scenarios.

[0170] Based on the same inventive concept, the embodiment of the present application also provides a text translation device for implementing the text translation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more text translation device embodiments provided below can refer to the limitations on the text translation method above, and will not be repeated here.

[0171] In one embodiment, Fig.13 As shown, a text translation device 1300 is provided, comprising: a text input module 1302, an encoding module 1302 and a decoding module 1306, wherein:

[0172] A text input module 1302 is used to obtain an initial text and determine at least one translation task type for translating the initial text;

[0173] The encoding module 1304 is used to add a markup tag to the initial text for at least one translation task type, to obtain at least one marked text; the marked text in the at least one marked text corresponds to the translation task type in the at least one translation task type, and the marked tag in each marked text includes a translation task tag representing the corresponding translation task type; based on the translation task tag included in the at least one marked text, at least one text encoding method adapted to the at least one marked text is determined; for each of the at least one marked text, semantic encoding processing is performed according to the adapted text encoding method, to obtain a coding vector sequence corresponding to the at least one translation task type;

[0174] The decoding module 1306 is used to perform semantic decoding processing on the coding vector sequences corresponding to at least one translation task type, and obtain translation texts corresponding to at least one translation task type.

[0175] In one embodiment, the text input module 1302 is further used to display a list of translation task types in response to a translation trigger operation on the initial text; in response to a selection operation on the list of translation task types, use at least one translation type selected by the selection operation as at least one translation task type for translating the initial text.

[0176] In one embodiment, the encoding module 1304 is further used to obtain, for each translation task type in at least one translation task type, a marking tag corresponding to the targeted translation task type; and add the marking tag corresponding to the targeted translation task type to the initial text to obtain a marked text corresponding to the targeted translation task type.

[0177] In one of the embodiments, at least one translation task type includes at least one of a text sentence translation task type, a document translation task type, a dialogue translation task type, a multimodal translation task type, or a personalized translation task type; the translation task of the text sentence translation task type is used to translate text sentences; the translation task of the document translation task type is used to translate documents; the translation task of the dialogue translation task type is used to translate dialogue content; the translation task of the multimodal translation task type is used to translate text extracted from multimedia; and the translation task of the personalized translation task type is used to perform personalized translation of text.

[0178] In one of the embodiments, the marking tags corresponding to the targeted translation task type include a first sentence start tag, a first sentence end tag, an end tag, and a translation task tag representing the targeted translation task type; the encoding module 1304 is further used to add a translation task tag representing the targeted translation task type at the beginning of the initial text when the number of text sentences included in the initial text is less than or equal to a preset number threshold; add a first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text; add a first sentence end tag at the end of the initial text, and add an end tag after the added first sentence end tag, to obtain a marked text corresponding to the targeted translation task type.

[0179] In one embodiment, the marking tags corresponding to the targeted translation task type include a first sentence start tag, a first sentence end tag, a sentence spacing tag, and a translation task tag representing the targeted translation task type; the encoding module 1304 is also used to add a translation task tag representing the targeted translation task type at the beginning of the initial text when the number of text sentences included in the initial text is greater than a preset number threshold; add a first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text; add a first sentence end tag at the end of the first text sentence in the initial text; determine the remaining text sentences in the initial text except the first text sentence, and add a sentence spacing tag between every two adjacent remaining text sentences to obtain a marked text corresponding to the targeted translation task type.

[0180] In one embodiment, the encoding module 1304 is further used to, for each marked text in at least one marked text, determine that the text encoding method adapted to the marked text is a dialogue encoding method for encoding dialogue content when the translation task type represented by the translation task tag included in the marked text belongs to the dialogue task type; and when the translation task type represented by the translation task tag included in the marked text belongs to the non-dialogue task type, determine that the text encoding method adapted to the marked text is a sentence encoding method for encoding non-dialogue content.

[0181] In one embodiment, the encoding module 1304 is also used to, for each marked text in at least one marked text, when the text encoding method adapted to the marked text is a dialogue encoding method, perform dialogue turn encoding processing on each text sentence in the marked text to obtain a dialogue turn encoding vector corresponding to each text sentence in the marked text; perform dialogue role encoding processing on each text sentence in the marked text to obtain a dialogue role encoding vector corresponding to each text sentence in the marked text; perform word embedding processing on each text sentence in the marked text to obtain a word embedding vector sequence corresponding to each text sentence in the marked text; perform position encoding processing on each text sentence in the marked text to obtain a position encoding vector sequence corresponding to each text sentence in the marked text; and obtain an encoding vector sequence corresponding to the marked text according to the dialogue turn encoding vector, dialogue role encoding vector, word embedding vector sequence and position encoding vector sequence corresponding to each text sentence in the marked text.

[0182] In one embodiment, the encoding module 1304 is also used to determine, for each text sentence in the targeted marked text, the dialogue turn of each text sentence in the targeted marked text; encode each determined dialogue turn respectively to obtain a dialogue turn encoding vector corresponding to each text sentence in the targeted marked text.

[0183] In one embodiment, the encoding module 1304 is also used to determine the dialogue role to which each text sentence in the targeted marked text belongs based on the dialogue role identifier carried by each text sentence in the targeted marked text; encode the dialogue role to which each text sentence belongs respectively to obtain the dialogue role encoding vector corresponding to each text sentence in the targeted marked text.

[0184] In one of the embodiments, the encoding module 1304 is also used to, for each marked text in at least one marked text, when the text encoding method adapted to the marked text is a sentence encoding method, perform word embedding processing on each word in the marked text to obtain a word embedding vector corresponding to each word in the marked text; perform position encoding processing on each word in the marked text to obtain a position encoding vector corresponding to each word in the marked text; superimpose the word embedding vector and the position encoding vector corresponding to the same word to obtain a superimposed vector corresponding to each word in the marked text; and obtain a coding vector sequence corresponding to the marked text based on the superimposed vector corresponding to each word in the marked text.

[0185] In one embodiment, the decoding module 1306 is further used to generate a first translation word for each coding vector sequence based on the targeted coding vector sequence and a start character corresponding to the targeted coding vector sequence; perform at least one round of decoding processing based on the first translation word and the targeted coding vector sequence to obtain at least one subsequent translation word; and combine the first translation word and at least one subsequent translation word to obtain a translation corresponding to the targeted coding vector sequence.

[0186] In one embodiment, the decoding module 1306 is further used to obtain a start character corresponding to the targeted coding vector sequence, and perform self-attention processing on the start character to obtain a first content representation vector; perform self-attention processing on the targeted coding vector sequence and the first content representation vector to obtain a first interaction representation vector; and decode the first interaction representation vector to obtain a first translation word.

[0187] In one embodiment, the decoding module 1306 is further used to determine the current round, and determine the historical translation words output in each historical round before the current round, to obtain a historical translation word sequence; perform self-attention processing on the historical translation word sequence to obtain a current content representation vector; perform self-attention processing on the targeted encoding vector sequence and the current content representation vector to obtain a current interaction representation vector; decode the current interaction representation vector to obtain a successive translation word output in the current round; enter the next round of decoding processing, take the next round as the current round, return to determine the historical translation words output in each historical round before the current round, and continue to perform the steps of obtaining a historical translation word sequence until the last successive translation word is output.

[0188] In one of the embodiments, the text translation device also includes a model training module, which is further used to obtain a sample text and a plurality of standard translation texts corresponding to the sample text; for a plurality of preset translation task types, respectively, mark tags are added to the sample text to obtain a plurality of marked sample texts corresponding to the plurality of translation task types; the mark tags in each marked sample text include a translation task tag representing the corresponding translation task type; based on the translation task tags included in each of the plurality of marked sample texts, at least one text encoding method adapted for the plurality of marked sample texts is determined; for each of the plurality of marked sample texts, semantic encoding processing is performed according to the adapted text encoding method to obtain sample encoding vector sequences corresponding to the plurality of translation task types; semantic decoding processing is performed on the sample encoding vector sequences corresponding to the plurality of translation task types to obtain predicted translation texts corresponding to the plurality of translation task types; the text translation model is trained through the predicted translation texts corresponding to the plurality of translation task types and the plurality of standard translation texts to obtain a trained text translation model.

[0189] Each module in the above text translation device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0190] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.14 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store text translation data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a text translation method is implemented.

[0191] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.15 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a text translation method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.

[0192] Those skilled in the art will understand that Figure 14 to Figure 15 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0193] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0194] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0195] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.

[0196] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0197] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0198] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0199] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.< / context> < / eos> < / bos> < / sep> < / sep> < / context> < / eos> < / bos> < / permt> < / sep> < / sep> < / context> < / eos> < / bos> < / docmt> < / sep> < / context> < / eos> < / bos> < / chatmt> < / context> < / eos> < / bos> < / docmt> < / context> < / eos> < / bos> < / sentmt> < / permt> < / dentmt> < / chatmt> < / docmt> < / sentmt> < / context> < / eos> < / bos> < / docmt> < / docmt> < / docmt> < / sentmt> < / sentmt> < / sentmt>

Claims

1. A text translation method, characterized in that: The method comprises: Acquire an initial text, and determine at least one translation task type for translating the initial text; For the at least one translation task type, markup tags are added to the initial text to obtain at least one marked text; the marked texts in the at least one marked text correspond to the translation task types in the at least one translation task type, and the marked tags in each of the marked texts include a translation task tag representing the corresponding translation task type; Determining at least one text encoding method adapted to the at least one marked text based on the translation task tag included in the at least one marked text; For each of the at least one marked text, semantic encoding processing is performed according to the adapted text encoding method to obtain a coding vector sequence corresponding to the at least one translation task type; Semantic decoding processing is performed on the encoding vector sequences corresponding one-to-one to the at least one translation task type to obtain translation texts corresponding one-to-one to the at least one translation task type.

2. The method according to claim 1, characterized in that The determining of at least one type of translation task for translating the initial text includes: In response to a translation trigger operation for the initial text, displaying a list of translation task types; In response to a selection operation on the translation task type list, at least one translation type selected by the selection operation is used as at least one translation task type for translating the initial text.

3. The method according to claim 1, characterized in that For the at least one translation task type, respectively adding mark tags to the initial text to obtain at least one marked text includes: For each translation task type in the at least one translation task type, obtaining a marking tag corresponding to the translation task type; A markup tag corresponding to the targeted translation task type is added to the initial text to obtain a marked text corresponding to the targeted translation task type.

4. The method according to any one of claims 1 to 3, characterized in that: The at least one translation task type includes at least one of a text sentence translation task type, a document translation task type, a dialogue translation task type, a multimodal translation task type, or a personalized translation task type; The translation tasks of the text sentence translation task type are used to translate text sentences; the translation tasks of the document translation task type are used to translate documents; the translation tasks of the dialogue translation task type are used to translate dialogue content; the translation tasks of the multimodal translation task type are used to translate text extracted from multimedia; and the translation tasks of the personalized translation task type are used to perform personalized translation of text.

5. The method according to claim 3, characterized in that: Markup tags corresponding to the targeted translation task type include a first sentence start tag, a first sentence end tag, an end tag, and a translation task tag representing the targeted translation task type; The step of adding a markup tag corresponding to the targeted translation task type to the initial text to obtain a marked text corresponding to the targeted translation task type includes: When the number of text sentences included in the initial text is less than or equal to a preset number threshold, adding a translation task label representing the type of translation task to the head of the initial text; Adding the first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text; The first sentence termination tag is added to the end of the initial text, and the end tag is added after the added first sentence termination tag to obtain a marked text corresponding to the targeted translation task type.

6. The method according to claim 3, characterized in that Marking tags corresponding to the targeted translation task type include a first sentence start tag, a first sentence end tag, a sentence interval tag, and a translation task tag representing the targeted translation task type; The step of adding a markup tag corresponding to the targeted translation task type to the initial text to obtain a marked text corresponding to the targeted translation task type includes: When the number of text sentences included in the initial text is greater than a preset number threshold, adding a translation task label representing the type of translation task to the header of the initial text; Adding the first sentence start tag after the translation task tag representing the targeted translation task type and before the first sentence of the initial text; Adding the first sentence termination tag to the end of the first text sentence in the initial text; The remaining text sentences except the first text sentence in the initial text are determined, and the sentence spacing label is added between every two adjacent remaining text sentences to obtain a marked text corresponding to the targeted translation task type.

7. The method according to claim 1, characterized in that The determining of at least one text encoding method adapted to the at least one marked text includes: For each of the at least one marked text, when the translation task type represented by the translation task tag included in the marked text belongs to the dialogue task type, determining that the text encoding method adapted to the marked text is a dialogue encoding method used to encode dialogue content; When the translation task type represented by the translation task tag included in the targeted marked text belongs to the non-dialogue task type, the text encoding method adapted to the targeted marked text is determined to be a sentence encoding method for encoding non-dialogue content.

8. The method according to claim 7, characterized in that The step of performing semantic encoding processing on each of the at least one marked text according to the adapted text encoding method to obtain an encoding vector sequence corresponding to the at least one translation task type comprises: For each marked text in the at least one marked text, when the text encoding method adapted to the marked text is a dialogue encoding method, each text sentence in the marked text is respectively subjected to dialogue turn encoding processing to obtain a dialogue turn encoding vector corresponding to each text sentence in the marked text; Performing dialogue role encoding processing on each text sentence in the targeted marked text to obtain a dialogue role encoding vector corresponding to each text sentence in the targeted marked text; Performing word embedding processing on each text sentence in the targeted marked text to obtain a word embedding vector sequence corresponding to each text sentence in the targeted marked text; Performing position encoding processing on each text sentence in the targeted marked text to obtain a position encoding vector sequence corresponding to each text sentence in the targeted marked text; According to the dialogue turn encoding vector, dialogue role encoding vector, word embedding vector sequence and position encoding vector sequence corresponding to each text sentence in the targeted marked text, an encoding vector sequence corresponding to the targeted marked text is obtained.

9. The method according to claim 8, characterized in that The step of performing dialogue turn encoding processing on each text sentence in the targeted marked text to obtain a dialogue turn encoding vector corresponding to each text sentence in the targeted marked text includes: For each text sentence in the targeted marked text, respectively determine the dialogue turn of each text sentence in the targeted marked text; The determined dialogue turns are respectively encoded to obtain a dialogue turn encoding vector corresponding to each text sentence in the targeted marked text.

10. The method according to claim 8, characterized in that The step of performing dialogue role encoding processing on each text sentence in the targeted marked text to obtain a dialogue role encoding vector corresponding to each text sentence in the targeted marked text includes: Determining the dialogue role to which each text sentence in the targeted marked text belongs according to the dialogue role identifier carried by each text sentence in the targeted marked text; The dialogue roles to which each text sentence belongs are encoded respectively to obtain the dialogue role encoding vector corresponding to each text sentence in the targeted marked text.

11. The method according to claim 7, characterized in that The step of performing semantic encoding processing on each of the at least one marked text according to the adapted text encoding method to obtain an encoding vector sequence corresponding to the at least one translation task type comprises: For each marked text in the at least one marked text, when the text encoding method adapted to the marked text is a sentence encoding method, each word in the marked text is respectively subjected to word embedding processing to obtain a word embedding vector corresponding to each word in the marked text; Performing position encoding processing on each word in the targeted marked text respectively to obtain a position encoding vector corresponding to each word in the targeted marked text; Superimposing the word embedding vector and the position encoding vector corresponding to the same word to obtain a superimposed vector corresponding to each word in the targeted marked text; According to the superimposed vectors corresponding to each word in the targeted marked text, a coding vector sequence corresponding to the targeted marked text is obtained.

12. The method according to claim 1, characterized in that The performing semantic decoding processing on the encoding vector sequences corresponding to the at least one translation task type to obtain translation texts corresponding to the at least one translation task type includes: For each encoding vector sequence, generating a first translation word based on the encoding vector sequence and a start character corresponding to the encoding vector sequence; Perform at least one round of decoding processing according to the first translation word and the targeted encoding vector sequence to obtain at least one subsequent translation word; The first translation word and the at least one subsequent translation word are combined to obtain a translation corresponding to the targeted encoding vector sequence.

13. The method according to claim 12, characterized in that The generating a first translation word based on the targeted coding vector sequence and the start character corresponding to the targeted coding vector sequence comprises: Obtaining a start character corresponding to the targeted encoding vector sequence, and performing self-attention processing on the start character to obtain a first content representation vector; Performing self-attention processing on the targeted encoding vector sequence and the first content representation vector to obtain a first interaction representation vector; The first interaction representation vector is decoded to obtain a first translation word.

14. The method according to claim 12, characterized in that The step of performing at least one round of decoding processing according to the first translation word and the targeted encoding vector sequence to obtain at least one subsequent translation word includes: Determine a current round, and determine historical translation words output in each historical round before the current round, to obtain a historical translation word sequence; Perform self-attention processing on the historical translation word sequence to obtain a current content representation vector; Performing self-attention processing on the targeted encoding vector sequence and the current content representation vector to obtain a current interaction representation vector; Decoding the current interaction representation vector to obtain a subsequent translation word output in the current round; Enter the next round of decoding processing, take the next round as the current round, return to determine the historical translation words output in each historical round before the current round, and continue to execute the step of obtaining the historical translation word sequence until the last continuous translation word is output.

15. The method according to claim 1, characterized in that The text translation method is performed by a text translation model, and the text translation model is obtained by training through a model training step, and the model training step includes: Acquire a sample text and a plurality of standard translation texts corresponding to the sample text; For the preset multiple translation task types, mark tags are added to the sample texts respectively to obtain multiple marked sample texts corresponding to the multiple translation task types; the mark tags in each of the marked sample texts include a translation task tag representing the corresponding translation task type; Determining at least one text encoding method adapted for the multiple marked sample texts based on the translation task tags respectively included in the multiple marked sample texts; For each of the multiple marked sample texts, semantic encoding processing is performed according to the adapted text encoding method to obtain sample encoding vector sequences corresponding to the multiple translation task types; Performing semantic decoding processing on the sample encoding vector sequences corresponding to the plurality of translation task types respectively to obtain predicted translations corresponding to the plurality of translation task types respectively; The text translation model is trained by using the predicted translations corresponding to the multiple translation task types and the multiple standard translation texts to obtain a trained text translation model.

16. A text translation device, characterized in that: The device comprises: A text input module, used to obtain an initial text and determine at least one translation task type for translating the initial text; The encoding module is used to add a markup tag to the initial text for the at least one translation task type to obtain at least one marked text; the marked text in the at least one marked text corresponds to the translation task type in the at least one translation task type, and the marked tag in each of the marked texts includes a translation task tag representing the corresponding translation task type; based on the translation task tag included in the at least one marked text, at least one text encoding method adapted to the at least one marked text is determined; for each of the at least one marked text, semantic encoding processing is performed according to the adapted text encoding method to obtain a coding vector sequence corresponding to the at least one translation task type; The decoding module is used to perform semantic decoding processing on the encoding vector sequences corresponding to the at least one translation task type, so as to obtain translation texts corresponding to the at least one translation task type.

17. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 15 are implemented.

18. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 15 are implemented.

19. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 15 are implemented.