Text translation method, related equipment and storage medium

By performing field-level feature encoding and language tag vector fusion on the text to be translated, the problem of reduced target language indication ability in multi-language translation in the existing technology is solved, and the quality of the translation is improved.

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

Patent Information

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

AI Technical Summary

Technical Problem

In the multi-language translation process, as the length of the translation increases, the ability of existing language tagging strategies to indicate the target language gradually decreases, resulting in low translation quality.

Method used

By performing field-level feature coding and language tag vector fusion on the text to be translated, the target feature vector is generated to ensure that the semantic information of each field carries the semantic information of the target language, thereby clarifying the translation direction during the decoding process.

Benefits of technology

It effectively reduces the probability of non-target language fields appearing in the target language translation text, improves the quality of the translation, and maintains a high language accuracy especially in long text translation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734867A_ABST
    Figure CN118734867A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a text translation method, related equipment and a storage medium, and the method comprises the following steps: carrying out feature coding processing on a field contained in a to-be-translated text to obtain an initial feature vector of the field; word coding processing is carried out on a language tag of the to-be-translated text to be translated into a target language, and a tag vector of the language tag is obtained; performing fusion processing on the initial feature vector and the label vector of the field to obtain a target feature vector of the to-be-translated text; according to the technical scheme, the target language translation text corresponding to the to-be-translated text can be obtained through decoding on the basis of the target feature vector, the capacity of indicating the target language in the text translation process can be improved, and therefore the translation quality is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the fields of computer technology and artificial intelligence technology, and more specifically, to a text translation method, a text translation device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] In today's era of globalization, multilingual translation models (i.e., language translation models that can translate between any two languages ​​in multiple languages) can help people overcome language barriers and integrate various fields such as finance, culture, and medicine. Among them, the multilingual translation model will use the language tag strategy to determine the language into which the text to be translated should be translated (i.e., determine the target language, which can also be called determining the target translation direction).

[0003] At present, commonly used language tagging strategies include T-Enc (a language tagging strategy that adds the language tag of the target language to the encoder side of the multilingual translation model), S-Enc-T-Dec (a language tagging strategy that adds the language tag of the text to be translated to the encoder side and the language tag of the target language to the decoder side), etc. Although the existing language tagging strategy can indicate the target translation direction for the multilingual translation model to a certain extent, its ability to indicate the target translation direction will gradually decrease during the translation generation process, that is, as the translation length increases, the generated words gradually do not belong to the target language, resulting in low translation quality.

[0004] Therefore, how to improve the ability to indicate the target language in order to improve the quality of translation is an urgent problem that needs to be solved. Summary of the invention

[0005] The embodiments of the present application provide a text translation method, a text translation device, an electronic device, a computer-readable storage medium, and a computer program product, which can improve the ability to indicate the target language during the text translation process, thereby improving the quality of the translation.

[0006] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0007] According to one aspect of an embodiment of the present application, a text translation method is provided, comprising:

[0008] Performing feature encoding processing on the fields contained in the text to be translated to obtain an initial feature vector of the field;

[0009] Performing word encoding processing on the language tag of the target language to be translated into the text to be translated, to obtain a label vector of the language tag;

[0010] Performing a fusion process on the initial feature vector of the field and the label vector to obtain a target feature vector of the text to be translated;

[0011] A target language translation text corresponding to the text to be translated is obtained based on the target feature vector decoding.

[0012] According to one aspect of an embodiment of the present application, a text translation device is provided, wherein:

[0013] A processing unit, used for performing feature coding processing on a field contained in the text to be translated to obtain an initial feature vector of the field;

[0014] The processing unit is further used to perform word encoding processing on the language label of the to-be-translated text to be translated into the target language to obtain a label vector of the language label;

[0015] The processing unit is further used to perform a fusion process on the initial feature vector of the field and the label vector to obtain a target feature vector of the text to be translated;

[0016] A decoding unit is used to decode the target feature vector to obtain a target language translation text corresponding to the text to be translated.

[0017] In one embodiment of the present application, the number of the fields includes multiple; when the processing unit fuses the initial feature vector of the field and the label vector to obtain the target feature vector of the text to be translated, it can be specifically used to: perform feature fusion processing on the initial feature vector of each field with the label vector respectively to obtain the fused feature vector of each field; perform global feature extraction processing on the fused feature vector of each field to obtain the field feature vector of each field; and perform normalization processing on the field feature vector of each field to obtain the target feature vector.

[0018] In one embodiment of the present application, when the processing unit performs global feature extraction processing on the fused feature vectors of the fields to obtain the field feature vectors of the fields, it can be specifically used to: perform linear transformation processing on the fused feature vectors of the fields according to the pre-set query parameter matrix, key parameter matrix and value parameter matrix to obtain the query vector, keyword vector and value vector of the fields; for any field, based on the query vector of any field and the keyword vector of each field, obtain the weight matrix of any field; wherein the weight matrix of any field is used to characterize the semantic consistency between any field and each field; based on the weight matrix of any field, perform weighted processing on the value vector of each field to obtain the field feature vector of any field.

[0019] In one embodiment of the present application, when the processing unit obtains the weight matrix of any field based on the query vector of any field and the keyword vectors of each field, it can be specifically used to: obtain the association matrix of any field based on the query vector of any field and the keyword vectors of each field; wherein the association matrix of any field is used to characterize the semantic association between any field and each field; based on the matrix dimension of the association matrix of any field, process the association matrix of any field to obtain the weight matrix of any field.

[0020] In one embodiment of the present application, before the processing unit performs feature encoding processing on the field contained in the text to be translated to obtain the initial feature vector of the field, it can be further used to: obtain the initial text to be translated into the target language; concatenate the initial text with a specified language tag to obtain the text to be translated; wherein the specified language tag includes one or more of the language tag of the target language and the language tag of the language to which the initial text belongs.

[0021] In one embodiment of the present application, when the processing unit obtains the target language translation text corresponding to the text to be translated based on the target feature vector decoding, it can be specifically used to: splice the label vector with the target feature vector to obtain a spliced ​​feature vector; perform feature decoding processing on the spliced ​​feature vector to obtain the target language translation text.

[0022] In one embodiment of the present application, when the processing unit obtains the target language translation text corresponding to the text to be translated based on the target feature vector decoding, it can be specifically used to: perform word classification processing on the target feature vector based on the start symbol to obtain the first translation field; wherein the start symbol is used to indicate the beginning of the text of the text to be translated; obtain the first feature vector obtained based on the first translation field and the target feature vector; loop execution of the steps of performing word classification processing on the feature vector obtained last time based on all the obtained translation fields to obtain the currently obtained translation field, and obtaining the currently obtained feature vector based on the currently obtained translation field and the previously obtained feature vector, until the current translation field is an end symbol; wherein the end symbol is used to indicate the end of the text to be translated; and generate the translation text based on all the obtained translation fields.

[0023] In one embodiment of the present application, when the processing unit performs feature encoding processing on the field contained in the text to be translated to obtain the initial feature vector of the field, it can be further used to: perform word encoding processing on the field to obtain the word vector of the field; perform position encoding processing on the field according to the position of the field in the text to be translated to obtain the position vector of the field; obtain the initial feature vector of the field based on the word vector and position vector of the field.

[0024] According to one aspect of an embodiment of the present application, an embodiment of the present application provides an electronic device, comprising one or more processors; a storage device for storing one or more computer programs, wherein when the one or more computer programs are executed by the one or more processors, the electronic device implements the text translation method as described above.

[0025] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor of an electronic device, the electronic device executes the text translation method as described above.

[0026] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a computer program product, including a computer program, wherein the computer program is stored in a computer-readable storage medium, and a processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device performs the text translation method as described above.

[0027] In the technical solution provided in the embodiment of the present application, the label vector of the language label of the target language is fused with the vector of the text to be translated at the field level, so that the semantic information of each field represented by the target feature vector of the text to be translated finally carries the semantic information of the language label of the target language. It can be seen that the embodiment of the present application can continuously indicate the translation direction as the target language when translating each field during the decoding process by carrying the semantic information of the language label of the target language in the semantic information of each field, thereby effectively reducing the probability of non-target language fields appearing in the final target language translation text, thereby achieving the purpose of improving the quality of the translation.

[0028] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0030] Figure 1 It is a structural diagram of a text translation system provided in an embodiment of the present application;

[0031] Figure 2 is a flowchart diagram of a text translation method shown in an exemplary embodiment of the present application;

[0032] Figure 3A is a schematic diagram of translation quality comparison of multiple language tag strategies shown in an exemplary embodiment of the present application;

[0033] Figure 3B is a schematic diagram of translation quality comparison of another multi-language tagging strategy shown in an exemplary embodiment of the present application;

[0034] Figure 4 is a flowchart of another text translation method shown in an exemplary embodiment of the present application;

[0035] Figure 5 is a schematic diagram of an encoder language modeling trend shown by an exemplary embodiment of the present application;

[0036] Figure 6 is a flowchart of another text translation method shown in an exemplary embodiment of the present application;

[0037] Figure 7 is a schematic diagram of a process comparison of a multi-language labeling strategy shown in an exemplary embodiment of the present application;

[0038] Figure 8 is a structural block diagram of a text translation device shown in an exemplary embodiment of the present application;

[0039] Fig. 9 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0040] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0041] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0042] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all contents and operations, nor must they be executed in the order described. For example, some operations may be decomposed, while some operations may be combined or partially combined, so the actual execution order may change according to actual conditions.

[0043] It should also be noted that the "multiple" mentioned in this application refers to two or more than two. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship.

[0044] With the continuous development of Internet technology, artificial intelligence (AI) technology has also been better developed. The so-called artificial intelligence technology refers to 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 mainly produces a new intelligent machine that can respond in a similar way to human intelligence by understanding the essence of intelligence, so that the intelligent machine has multiple functions such as perception, reasoning and decision-making. Correspondingly, AI technology is a comprehensive discipline, which mainly includes several major directions such as computer vision technology (Computer Vision, CV), speech technology, natural language processing technology and machine learning (Machine Learning, ML) / deep learning.

[0045] Among them, machine learning is a multi-disciplinary cross-discipline involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills, and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of AI and the fundamental way to make computer devices intelligent; the so-called machine learning is a multi-disciplinary cross-discipline involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines; it specializes in studying how computer devices simulate or implement human learning behavior to acquire new knowledge or skills, and reorganize existing knowledge structures to continuously improve their performance. Deep learning is a technology that uses deep neural network systems to perform machine learning; machine learning / deep learning can usually include artificial neural networks, reinforcement learning (RL), supervised learning, unsupervised learning and other technologies; the so-called supervised learning refers to the processing method of using training samples with known categories (with labeled categories) for model training, and unsupervised learning refers to the processing method of using training samples with unknown categories (not labeled) for model training.

[0046] In addition, Natural Language Processing (NLP) is a science that integrates linguistics, computer science, and mathematics. It studies various theories and methods that can enable effective communication between humans and computers using natural language. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graphs, and other technologies.

[0047] Machine translation refers to the process of converting one natural language (also called source language) into another natural language (also called target language) through a computer. With the development of economic globalization, machine learning models that can translate a fixed language into another fixed language (also called single language translation models) can no longer meet people's needs. Therefore, multilingual translation models came into being, which can complete the translation between any two languages ​​in multiple languages.

[0048] Among them, the multilingual translation model is mainly built based on the Transformer (a machine translation architecture), which usually includes an encoder and a decoder. In addition, the multilingual translation model will use the language label strategy to determine the language into which the text to be translated should be translated (that is, determine the target language, which can also be called determining the target translation direction).

[0049] At present, commonly used language tag strategies include: T-Enc (refers to a language tag strategy of adding the language tag of the target language to the encoder side in a multilingual translation model), S-Enc-T-Dec (refers to a language tag strategy of adding the language tag of the language of the text to be translated to the encoder side, and adding the language tag of the target language to the decoder side), T-Enc-T-Dec (refers to a language tag strategy of adding the language tag of the target language to both the encoder side and the decoder side), ST-Enc (refers to a language tag strategy of adding the language tag of the language of the text to be translated and the language tag of the target language to the encoder side), ST-Enc-T-Dec (refers to a language tag strategy of adding the language tag of the language of the text to be translated and the language tag of the target language to the encoder side, and adding the language tag of the target language to the decoder side), and so on.

[0050] Although the existing language labeling strategy can indicate the target translation direction for the multilingual translation model to a certain extent, its ability to indicate the target translation direction will gradually decrease during the translation generation process. That is, as the length of the translation increases, the generated words gradually do not belong to the target language, resulting in low translation quality.

[0051] In addition, supervised translation (also called supervised translation) refers to the translation direction that appears in the training phase of the multilingual translation model. Specifically, the multilingual translation model has been trained to translate text from language A into language B during the training phase, so the translation direction from language A to language B is supervised translation. Zero-shot translation (also called zero-shot translation) refers to the translation direction that has never appeared in the training phase of the multilingual translation model. Specifically, the multilingual translation model has been trained to translate text from language A into language B and from language B into language C during the training phase, but has not been trained to translate text from language A into language C; then, the translation direction from language A to language C is zero-shot translation.

[0052] Based on this, an embodiment of the present application provides a text translation solution, which, after feature encoding processing of the fields contained in the text to be translated, will fuse the initial feature vector of the field and the label vector of the language label of the target language, and finally obtain the target feature vector of the text to be translated; finally, by decoding the target feature vector, the target language translation text corresponding to the text to be translated is obtained.

[0053] The text to be translated refers to the text that needs to be converted into a language, and the language of the text obtained after the text to be translated belongs to the target language. In addition, the label vector of the language label of the target language is obtained after word encoding processing of the language label of the target language.

[0054] It is not difficult to see that this solution fuses the label vector of the language label of the target language with the field-level vector of the text to be translated, so that the semantic information of each field represented by the target feature vector of the text to be translated finally carries the semantic information of the language label of the target language.

[0055] The text to be translated is composed of fields. The more fields there are, the longer the text to be translated is, and the longer the translation of the text to be translated is. It can be seen that since the semantic information of each field represented by the target feature vector carries the semantic information of the language label of the target language, the text to be translated will clearly indicate the target translation direction when translating each field, thereby effectively reducing the probability of non-target language fields appearing in the final target language translation text, thereby achieving the purpose of improving the translation quality.

[0056] Based on the above text translation scheme, the present application embodiment provides a text translation system, which can be found in Figure 1 , Figure 1 The text translation system shown may include multiple terminal devices 101 and multiple servers 102. Among them, a communication connection is established between any terminal device and any server. For example, the terminal device 101 may include any one or more of a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart car and a smart wearable device. A multimedia playback client, a social client, a browser client, an information stream client, an education client, etc. may be run in the terminal device 101. The server 102 may be a server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms. Any terminal device 101 and any server 102 can be directly or indirectly communicated and connected by wired or wireless communication, and this application is not limited here.

[0057] In some embodiments, the above text translation method can be performed by only Figure 1The terminal device 101 in the text translation system shown is executed, and the specific execution process is: the terminal device 101 performs feature encoding processing on the fields contained in the text to be translated to obtain the initial feature vector of the field. Then, the terminal device 101 can perform word encoding processing on the language tag of the target language to be translated into the text to be translated to obtain the label vector of the language tag. After that, the terminal device 101 will fuse the initial feature vector and the label vector of the field to obtain the target feature vector of the text to be translated. Finally, the terminal device 101 can decode based on the target feature vector to obtain the target language translation text corresponding to the text to be translated.

[0058] Optionally, after obtaining the target language translation text, the terminal device 101 may also output the target language translation text so that the target object can view the target language translation text. Figure 1 The server 102 in the text translation system shown is executed. The specific execution process can refer to the specific execution process of the terminal device 101, which will not be repeated here.

[0059] In other embodiments, the above text translation method may be run in a text translation system, which may include a terminal device and a server. Figure 1 The text translation system shown is jointly completed by the terminal device 101 and the server 102. The specific execution process is: the terminal device 101 responds to the text input operation and obtains the text to be translated; then, the terminal device 101 sends the text to be translated to the server 102.

[0060] After receiving the text to be translated, the server 102 may perform feature encoding processing on the fields contained in the text to be translated to obtain an initial feature vector of the field. Then, the server 102 may perform word encoding processing on the language tag of the target language to be translated into the text to be translated to obtain a label vector of the language tag. Afterwards, the server 102 may fuse the initial feature vector and the label vector of the field to obtain a target feature vector of the text to be translated. Finally, the server 102 may decode the target feature vector to obtain a target language translation text corresponding to the text to be translated.

[0061] Optionally, the server 102 may also send the target language translation text to the terminal device 101 , and then the terminal device 101 outputs the target language translation text for the target to view the target language translation text.

[0062] It should be noted that the embodiments of the present invention can be applied to the translation of various texts and can be applied to various scenarios, including but not limited to multimedia data in various scenarios such as cloud technology, AI (Artificial Intelligence), smart transportation, assisted driving, etc., and can also be used in video applications, educational applications, conversation applications, translation applications or websites, and the like.

[0063] Specifically, if the technical solution of the embodiment of the present application is applied in an assisted driving scenario, the terminal device may be a vehicle-mounted terminal, and a search application is running on the vehicle-mounted terminal. The driver wants to take a short trip to place A, so he searches for a travel guide about place A through the search application on the vehicle-mounted terminal. The language of a travel guide displayed in the search results is different from the language used by the driver, so the driver selects the travel guide and clicks the translation button; at this time, the vehicle-mounted terminal generates a text input operation based on the click operation of the translation button, and the text to be translated obtained is the travel guide.

[0064] Afterwards, the vehicle terminal can perform feature encoding processing on the fields contained in the travel guide to obtain the initial feature vector of the fields in the travel guide. Then, the vehicle terminal can perform word encoding processing on the language label of the language used by the driver (i.e., the target language) to obtain the corresponding label vector. Afterwards, the vehicle terminal will fuse the initial feature vector of the field in the travel guide and the above-mentioned label vector to obtain the target feature vector of the travel guide. Finally, the vehicle terminal can decode the target feature vector of the travel guide to obtain the corresponding translation text of the travel guide, and output the corresponding translation text of the travel guide for the driver to view the travel guide.

[0065] For another example, the technical solution of the embodiment of the present application is applied in a translation application, the server can be a server of the translation application, and the translation application is running in the terminal device. When subject Y is reading an English document, he encounters an English paragraph that he does not understand; then, subject Y inputs the English paragraph into the translation application and selects Chinese as the target language. The translation application in the terminal device responds to the text input operation of subject Y, and the text to be translated obtained is the English paragraph, and the target language is Chinese; then, the translation application in the terminal device sends the language tags of the English paragraph and Chinese to the server.

[0066] After the server receives the English paragraph and the Chinese language tags, it can perform feature encoding processing on the fields contained in the English paragraph to obtain the initial feature vector of the fields in the English paragraph. Then, the server can perform word encoding processing on the Chinese language tags to obtain the Chinese label vector. After that, the server will fuse the initial feature vector of the field in the English paragraph with the Chinese label vector to obtain the target feature vector of the English paragraph. Finally, the server can decode the target feature vector of the English paragraph to obtain the translation text corresponding to the English paragraph and send it to the terminal device. The terminal device outputs the translation text corresponding to the English paragraph through the translation application so that object Y can view the Chinese translation of the English paragraph.

[0067] For another example, the technical solution of the embodiment of the present application is applied to a conversation application, the server may be a server of the conversation application, and the terminal device may run the conversation application. When object Y is chatting with object M in the conversation interface, object M sends an English sentence; then, object Y selects the entire English sentence and selects the translation button. At this time, the conversation application in the terminal device will obtain the language used by the conversation application set by object Y as the target language, and send the English sentence and the language tag of the target language to the server.

[0068] After the server receives the English sentence and the language tag of the target language, it can perform feature encoding processing on the fields contained in the English sentence to obtain the initial feature vector of the field in the English sentence. Then, the server can perform word encoding processing on the language tag of the target language to obtain the label vector of the current target language. After that, the server will fuse the initial feature vector of the field in the English sentence with the label vector of the current target language to obtain the target feature vector of the English sentence. Finally, the server can decode the target feature vector of the English sentence to obtain the translation text corresponding to the English sentence and send it to the terminal device. The terminal device outputs the translation text corresponding to the English sentence in the conversation interface for object Y to view the Chinese translation of the English sentence.

[0069] It should be noted that in the specific implementation of the present application, if the data or information such as the text to be translated or the language label of the target language obtained is related to the object, when the embodiment of the present application is applied to a specific product or technology, it is necessary to obtain the permission or consent of the object, and the collection, use and processing of the relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0070] The following is a detailed description of various implementation details of the technical solution of the embodiment of the present application:

[0071] like Figure 2 As shown, Figure 2 is a flowchart of a text translation method shown in an embodiment of the present application, which can be applied to Figure 1 The text translation system shown. This method can be executed by a terminal device or a server, or jointly executed by a terminal device and a server. In the embodiments of this application, taking the method being executed by the server as an example for illustration, the text translation method may include S201 to S204, which are introduced in detail as follows:

[0072] S201. Perform feature encoding processing on the fields contained in the text to be translated to obtain the initial feature vector of the field.

[0073] In the embodiments of this application, the text to be translated includes one or more fields. One field includes one or more characters. Specifically, one field in the text to be translated has semantics in the language to which the text to be translated belongs. For example, when the language to which the text to be translated belongs is Chinese, Chinese characters or words such as "walk", "look", "apple", etc. are each a field in the corresponding text to be translated; when the language to which the text to be translated belongs is English, words such as "apple", "her", etc. are each a field in the corresponding text to be translated.

[0074] Optionally, before the feature encoding processing, the text to be translated can also be subjected to field segmentation processing to obtain one or more fields contained in the text to be translated. Specifically, the field segmentation processing can be performed by a tokenizer. In practical applications, the tokenizer can specifically be a BasicTokenizer, a WordpieceTokenizer, or a FullTokenizer (a tokenizer that combines BasicTokenizer and WordpieceTokenizer), etc.

[0075] In one embodiment, the specific manner of the feature encoding processing can be: perform word encoding processing on the field to obtain the word vector of the field; perform position encoding processing on the field according to the position of the field in the text to be translated to obtain the position vector of the field; based on the word vector and the position vector of the field, obtain the initial feature vector of the field.

[0076] In specific implementation, one or more of various encoding methods such as One-Hot Encoding, CountEncoding, word2vec algorithm (also known as word embeddings) can be used for word encoding processing. Optionally, other encoding methods can also be used to perform word encoding processing on the field, and this is not limited.

[0077] In addition, since the same word may exhibit different semantics in different positions in the text, it is also necessary to encode the position of the field in the text to be translated, so as to better represent the semantic information of the field through the vectors obtained by encoding.

[0078] Optionally, the number of fields is at least one, and the specific method of position encoding processing can be: determine the number of fields in the text to be translated; and obtain the position vector of the corresponding field according to the determined number and the position of each field in the text to be translated. For example, if there are 3 fields in the text to be translated, field a is the first field in the text to be translated, field b is the second field in the text to be translated, and field c is the third field in the text to be translated. Since field a is the first field, and there are a total of 3 fields in the text to be translated; therefore, it can be determined that the dimension of the position vector is 3, and the position vector of field a is [1,0,0], which is used to represent that field a is the first field in the text to be translated. Similarly, the position vector of field b is [0,1,0], and the position vector of field c is [0,0,1].

[0079] Optionally, based on the word vector and position vector of the field, the specific method of obtaining the initial feature vector of the field can be: fusing the word vector and position vector of the field to obtain the initial feature vector of the field. The specific method of vector fusion can be to concatenate the vectors; or to perform dimension mapping on each vector, so that the vector dimensions of the two processed vectors are the same, and then add the two processed vectors to complete the vector fusion. Optionally, other methods can also be used for fusion processing, which is not limited.

[0080] Optionally, based on the word vector and position vector of the field, the specific method of obtaining the initial feature vector of the field may also be: fusing the word vector and position vector of the field to obtain a reference feature vector of the field; performing local feature extraction on the reference feature vector of the field to obtain the initial feature vector of the field.

[0081] In the specific implementation, since the model architecture of the aforementioned multilingual translation model is mainly built based on Transformer, and the encoder in Transformer usually has multiple encoder layers. Among them, the multiple encoder layers are arranged in a certain order, and the encoder layers arranged in the front order in the multiple encoder layers can be called shallow encoder layers, and the encoder layers arranged in the back order in the multiple encoder layers can be called deep encoder layers. Then, the reference feature vector of the field can be processed for local feature extraction through the shallow encoder layer.

[0082] S202 , performing word encoding processing on the language tag of the target language to be translated into the text to be translated, to obtain a label vector of the language tag.

[0083] In the embodiment of the present application, different languages ​​have different language tags. Specifically, any code or field indicating any language can be selected as the language tag of any language. Specifically, the language tag can be the abbreviation of the language code in ISO639-1, or in the form of LANG_EN, LANG_ZH, etc. For example, the language tag of Chinese can be "zh", and the language tag of Mandarin can be "zh-cmn".

[0084] In a translation scenario, an object usually selects a language from multiple languages ​​into which a text to be translated needs to be translated, so a specific method for obtaining a language tag of a target language may be: in response to an object's selection operation of multiple languages, obtaining a language tag of a target language into which the text to be translated needs to be translated. In a conversation scenario, after the current object receives the conversation information sent by the conversation object, since the current object and its conversation object use different languages, the current object may choose to translate the conversation information in the conversation interface. At this point, the language used by the current object in the conversation application or terminal device may be used as the target language, and the corresponding language tag may be obtained. Optionally, in other scenarios, the language tag of the target language may also be obtained by other means, which is not limited in the embodiments of the present application.

[0085] In one embodiment, one or more of a variety of encoding methods such as One-Hot Encoding, Count Encoding, word vector encoding (word2vec algorithm, also known as word embedding) can be used to encode the language tag of the target language. Optionally, other encoding methods can also be used to encode the field, which is not limited.

[0086] S203: Fusing the initial feature vector and the label vector of the field to obtain a target feature vector of the text to be translated.

[0087] In the embodiment of the present application, the specific method of the fusion processing may be: concatenating the initial feature vector and the label vector of the field to obtain the target feature vector of the text to be translated.

[0088] Optionally, the specific method of the fusion processing can also be: perform dimension mapping processing on the initial feature vector and label vector of the field respectively to obtain the mapped feature vector and mapped label vector of the field, wherein the vector dimensions of the mapped feature vector and the mapped label vector of the field are the same; finally, add the mapped feature vector and the mapped label vector of the field to obtain the target feature vector of the text to be translated.

[0089] Optionally, the initial feature vector and label vector of the field may be fused by other methods capable of fusing two vectors into one vector, and this is not limited.

[0090] S204, decoding the target feature vector to obtain the target language translation text corresponding to the text to be translated. In the embodiment of the present application, the specific process of decoding the target feature vector may be: performing word classification processing on the target feature vector based on the start symbol to obtain the first translation field; obtaining the first feature vector based on the first translation field and the target feature vector; looping the steps of performing word classification processing on the feature vector obtained last time based on all the obtained translation fields to obtain the currently obtained translation field, and obtaining the currently obtained feature vector based on the currently obtained translation field and the previously obtained feature vector, until the current translation field is the end symbol; finally, generating the translation text based on all the obtained translation fields.

[0091] The start symbol is used to indicate the beginning of the text to be translated; the end symbol is used to indicate the end of the text to be translated. In a specific implementation, the start symbol may be [cls], and the end symbol may be [sep]. Optionally, other different characters or fields may be used as the start symbol and the end symbol, respectively, without limitation.

[0092] In one embodiment, the specific method of performing word classification processing on any feature vector may be: performing word classification processing on any feature vector to obtain a classification result, the classification result is used to indicate the probability that the translation field is any field in the vocabulary set; and taking the field with the highest probability as the obtained translation field. The vocabulary set includes all characters and / or words in the target language.

[0093] Optionally, the target feature vector may be decoded by using algorithms such as beam search, bidirectional beam search (bidirectional beam search), etc., which is not limited in the embodiment of the present application.

[0094] In a specific implementation, the target feature vector can be decoded by a decoder in the Transformer. Optionally, an attention mechanism can be introduced into the decoder in the Transformer to decode the target feature vector by a decoder based on the attention mechanism. Since the decoding process of the decoder and the decoding process of the decoder based on the attention mechanism are technical means commonly used by those skilled in the art, they will not be described in detail here.

[0095] In practical applications, the language tag strategy mentioned in the embodiment of this application can be called LCS (Language Converter Strategy) strategy. Among them, through experiments, the comparison of the language accuracy of the LCS strategy and the other two commonly used language tag strategies T-Enc and S-Enc-T-Dec can be obtained, as shown in Table 1:

[0096] Table 1

[0097]

[0098] Among them, MultiUN refers to a corpus provided by the German Research Center for Artificial Intelligence that contains translation comparison corpora between multiple languages; OPUS100 is a multilingual corpus centered on English, covering 100 languages; TED is a multilingual parallel corpus, including multilingual parallel corpora and monolingual corpora, which will not be described in detail later. It should be noted that in order to unify the experimental settings and reduce the cost of data annotation, this experiment is centered on English to build training corpus pairs. In the test phase, when English is the source or target language, it is supervised translation, otherwise it is zero-shot translation.

[0099] It can be seen from Table 1 that the language accuracy of the LCS strategy in the embodiment of the present application tested under the three corpora is much higher than that of the S-Enc-T-Dec strategy; and the language accuracy of the LCS strategy in the embodiment of the present application tested under the MultiUN and TED corpora is higher than that of the T-Enc language tag strategy, and the language accuracy tested under the OPUS100 corpus is much higher than that of the T-Enc language tag strategy.

[0100] In addition, BLEU (Bilingual Evaluation Understudy, a method for measuring the similarity between texts) can also be used to evaluate the translation quality of the translated text. Among them, through experimental calculations, the comparison of BLEU between the LCS strategy, T-Enc strategy and S-Enc-T-Dec strategy in the zero-shot translation scenario can be obtained, as shown in Table 2:

[0101] Table 2

[0102]

[0103] It can be seen from Table 2 that in the zero-shot translation scenario, the BLEU (i.e., translation quality) of the LCS strategy in the embodiment of the present application tested under the three corpora is higher than that of the S-Enc-T-Dec strategy; and the BLEU of the LCS strategy in the embodiment of the present application tested under the MultiUN and TED corpora is slightly higher than that of the T-Enc language tag strategy, and the BLEU tested under the OPUS100 corpus is higher than that of the T-Enc language tag strategy.

[0104] In addition, through experimental calculations, we can also obtain the comparison of BLEU among the LCS strategy, T-Enc strategy and S-Enc-T-Dec strategy in the supervised translation scenario, as shown in Table 3:

[0105] Table 3

[0106]

[0107]

[0108] It can be seen from Table 3 that in supervised translation, the BLEU (i.e., translation quality) of the LCS strategy in the embodiments of the present application tested under three corpora is generally higher than or equal to the BLEU of the S-Enc-T-Dec strategy and the T-Enc strategy tested under three corpora.

[0109] It can be seen that the language accuracy of the translation produced by the LCS strategy proposed in the embodiment of the present application is higher; at the same time, although the quality of the translation produced by the LCS strategy proposed in the embodiment of the present application in the supervised translation direction is not much different from that of the existing language tag strategy, the quality of the translation will not be lower than that of the existing language tag strategy; finally, the LCS strategy proposed in the embodiment of the present application shows great advantages in the supervised translation direction, and the quality of the translation produced by it is much higher than that of the existing language tag strategy.

[0110] Finally, see the attached Figure 3A and Figure 3B , Figure 3A A schematic diagram showing the comparison of translation quality of various language labeling strategies is shown. Figure 3B Another schematic diagram showing the comparison of translation quality of multiple language labeling strategies is shown.

[0111] in, Figure 3A and Figure 3B The broken line x in the included statistical graphs (a) to (d) refers to the language accuracy calculated by translating texts of different text lengths using the LCS strategy; the broken line y refers to the language accuracy calculated by translating texts of different text lengths using the T-Enc strategy; and the broken line z refers to the language accuracy calculated by translating texts of different text lengths using the S-Enc-T-Dec strategy.

[0112] first, Figure 3AThe statistical graph (a) in the figure is the language accuracy calculated after translating texts of different text lengths (i.e., length of sentence) containing 5 fields (i.e., spanlength = 5) using the LCS strategy, T-Enc strategy, and S-Enc-T-Dec strategy in the MultiUN corpus. As can be seen from the statistical graph (a), the language accuracy of the LCS strategy is close to 100%, and is slightly higher than the T-Enc strategy overall, and much higher than the S-Enc-T-Dec strategy; at the same time, as the length of the text increases, the language accuracy of the S-Enc-T-Dec strategy drops significantly, and the LCS strategy drops slightly, but still remains above 98%.

[0113] Secondly, Figure 3A The statistical graph (b) in the figure is the language accuracy calculated after translating texts of different text lengths (i.e., length of sentence) containing one field (i.e., spanlength = 1) using the LCS strategy, T-Enc strategy, and S-Enc-T-Dec strategy in the MultiUN corpus. As can be seen from the statistical graph (b), as the length of the text increases, the language accuracy of the S-Enc-T-Dec strategy drops significantly, while the LCS strategy and the T-Enc strategy fluctuate slightly; overall, the language accuracy of the LCS strategy is close to 100%, and its language accuracy is slightly higher than that of the T-Enc strategy, and much higher than that of the S-Enc-T-Dec strategy.

[0114] Then, Figure 3B The statistical graph (c) in the figure is the language accuracy calculated after translating texts of different text lengths (i.e., length of sentence) containing 5 fields (i.e., spanlength = 5) in the OPUS-100 corpus using the LCS strategy, T-Enc strategy, and S-Enc-T-Dec strategy. As can be seen from the statistical graph (c), as the length of the text increases, the language accuracy of the S-Enc-T-Dec strategy drops significantly, the LCS strategy drops slightly, and the language accuracy of the LCS strategy remains stable. At the same time, overall, the language accuracy of the LCS strategy is close to 100%, and its language accuracy is higher than that of the T-Enc strategy, and much higher than that of the S-Enc-T-Dec strategy.

[0115] at last, Figure 3BThe statistical graph (d) in the figure is the language accuracy calculated after translating texts of different text lengths (i.e., length of sentence) containing one field (i.e., spanlength = 1) using the LCS strategy, T-Enc strategy, and S-Enc-T-Dec strategy in the OPUS-100 corpus. As can be seen from the statistical graph (d), with the increase in text length, the language accuracy of the S-Enc-T-Dec strategy fluctuated and dropped by about 10%, the T-Enc strategy fluctuated and dropped slightly, and the language accuracy of the LCS strategy remained relatively stable during the fluctuations. At the same time, overall, the language accuracy of the LCS strategy is close to 100%, and its language accuracy is higher than that of the T-Enc strategy, and much higher than that of the S-Enc-T-Dec strategy.

[0116] In an embodiment of the present application, by fusing the label vector of the language label of the target language with the vector of the text to be translated at the field level, the semantic information of each field represented by the target feature vector of the text to be translated finally carries the semantic information of the language label of the target language. It can be seen that the embodiment of the present application can continuously indicate the translation direction as the target language when translating each field during the decoding process by carrying the semantic information of the language label of the target language in the semantic information of each field, thereby effectively reducing the probability of non-target language fields appearing in the target language translation text finally obtained, thereby achieving the purpose of improving the quality of the translation.

[0117] In addition, compared with the existing language tag strategy, the target language translation text translated by the method mentioned in the embodiment of the present application can not only maintain or even slightly improve the translation quality in the supervised translation direction, but also greatly improve the translation quality in the zero-shot translation direction.

[0118] In one embodiment of the present application, another text translation method is provided, which can be applied to Figure 1 The text translation system shown in the figure, the method can be executed by the terminal device or the server, or can be executed by the terminal device and the server together. In the embodiment of the present application, the method is executed by the server as an example for explanation. Figure 4 FIG. 1 is a flow chart of another text translation method. Figure 2 This paper expands on the method shown in .

[0119] Among them, S401~S406 are described in detail as follows:

[0120] S401 , performing feature coding processing on the fields contained in the text to be translated to obtain an initial feature vector of the field.

[0121] In an embodiment of the present application, the number of fields contained in the text to be translated is multiple. Then, the specific process of feature coding processing includes: for any field among the multiple fields, word coding processing is performed on any field to obtain the word vector of any field; according to the position of any field in the text to be translated, position coding processing is performed on any field to obtain the position vector of any field; the word vector and position vector of any field are fused to obtain the reference feature vector of any field; the reference feature vector of any field is subjected to local feature extraction processing to obtain the initial feature vector of any field. Among them, the specific implementation methods of word coding processing and position coding processing can refer to the specific implementation methods in step S201, which will not be repeated.

[0122] In one embodiment, a shallow encoder layer in the encoder (i.e., an encoder layer arranged at the front in the Transformer) can be used to perform local feature extraction on the reference feature vector of the field. Optionally, an attention mechanism can be introduced into the encoder in the Transformer to perform local feature extraction on the reference feature vector of the field through an encoder based on the attention mechanism.

[0123] S402 , performing word encoding processing on the language tag of the target language to be translated into the text to be translated, to obtain a label vector of the language tag.

[0124] In the embodiment of the present application, the specific implementation of step S402 can refer to the specific implementation of step S202 in the above embodiment, which will not be repeated here.

[0125] S403 , performing feature fusion processing on the initial feature vectors of each field and the label vector respectively, to obtain fused feature vectors of each field.

[0126] In the embodiment of the present application, the specific implementation of the feature fusion processing can refer to the specific implementation of the fusion processing in step S204, which will not be repeated here.

[0127] S404: Perform global feature extraction processing on the fused feature vectors of each field to obtain field feature vectors of each field.

[0128] In the embodiment of the present application, since there are multiple layers of neural networks for feature extraction or feature encoding during the process of feature extraction or feature encoding, the neural network that first performs feature extraction or feature encoding is usually called a shallow neural network, and the neural network that performs feature extraction or feature encoding later is called a deep neural network. The shallow network pays more attention to the semantics of the field itself (i.e., local) during feature encoding or feature extraction, and the deep network pays more attention to the semantics of the field in the text (i.e., global) during feature encoding or feature extraction. In other words, in the process from shallow to deep, the semantics represented by the obtained feature vector is more abstract and the semantic information is richer. Therefore, the algorithms or methods for local feature extraction processing and global feature extraction processing can be the same, except that the former is executed by a neural network in a shallow layer in the neural network model (such as a shallow encoder layer in the encoder included in the Transformer), and the latter is executed by a neural network in a deep layer in the neural network model (such as a deep encoder layer in the encoder included in the Transformer).

[0129] In one embodiment, the above mentioned attention mechanism can be introduced into the encoder in the Transformer; therefore, the specific manner of global feature extraction processing can be:

[0130] 1) According to the preset query parameter matrix, key parameter matrix and value parameter matrix, the fused feature vectors of each field are linearly transformed to obtain the query vector, keyword vector and value vector of each field;

[0131] Specifically, the query parameter matrix, key parameter matrix and value parameter matrix are obtained during the training phase of Transformer. Optionally, the specific method of linear transformation processing can be: multiplying the query parameter matrix with the fused feature vector of each field to obtain the query vector of the corresponding field; multiplying the key parameter matrix with the fused feature vector of each field to obtain the keyword vector of the corresponding field; multiplying the value parameter matrix with the fused feature vector of each field to obtain the value vector of the corresponding field. Optionally, the fused feature vectors of each field can also be linearly transformed by other methods, which are not limited to this.

[0132] 2) For any field, based on the query vector of any field and the keyword vectors of each field, a weight matrix of any field is obtained;

[0133] Specifically, the weight matrix of any field is used to characterize the semantic consistency between any field and each field. Optionally, the specific method of calculating the weight matrix of any field can be: first, based on the query vector of any field and the keyword vectors of each field, the relevance matrix of any field is obtained; then, based on the matrix dimension of the relevance matrix of any field, the relevance matrix of any field is processed to obtain the weight matrix of any field.

[0134] The association matrix of any field is used to represent the semantic association between any field and each field. Since a vector can also be called a matrix, the matrix dimension is also the vector dimension.

[0135] In a specific implementation, based on the matrix dimension of the correlation matrix of any field, the specific method of processing the correlation matrix of any field can be: dividing the correlation matrix of any field by the matrix dimension of the correlation matrix of the corresponding field to obtain the transition matrix of the corresponding field; performing linear mapping processing on the transition matrix of the corresponding field to obtain the weight matrix of the corresponding field. The linear mapping processing can be to map the data values ​​in the transition matrix to between [0, 1], so that each value included in the weight matrix is ​​between [0, 1].

[0136] 3) Based on the weight matrix of any field, the value vectors of each field are weighted to obtain the field feature vector of any field.

[0137] Specifically, the weight matrix of any field is used to represent the semantic consistency between any field and each field. The values ​​included in the weight matrix of any field are used to represent the degree of semantic consistency between any field and each field.

[0138] Since the core of the attention mechanism is to allocate more attention to fields that are semantically related to a certain field, the specific method of weighted processing can be: multiply the value vector of each field by the numerical value contained in the weight matrix of any field that is used to characterize the semantic consistency between any field and the corresponding field, and obtain the field feature vector of any field.

[0139] In practical applications, the calculation formula for any encoder layer after the attention mechanism is introduced in Transformer is as shown in formula (1-1) and formula (1-2):

[0140]

[0141]

[0142] Where h=[h0,h1,h2,…,h n] represents the feature vector sequence of n fields in the text to be translated output by the previous encoder, h i Refers to any eigenvector in h, i is less than or equal to n, and k is less than or equal to n.

[0143] In addition, W Q is the query parameter matrix, W K is the keyword parameter matrix, W V is the value parameter matrix, which are the parameters of the self-attention mechanism, e t The tag variable for the language tag of the target language. i + t is equivalent to the fused feature vector of the i-th field, so (h i + t ) Q refers to the query vector of the i-th field, (h i + t ) K refers to the keyword vector of the i-th field, (h i + t ) V Refers to the value vector of the i-th field.

[0144] In addition, d refers to the matrix dimension of the relevance matrix obtained after multiplying the query vector and the keyword vector. ij It is equivalent to the transition matrix of the i-th field obtained by dividing the correlation matrix of the i-th field in the text to be translated by the matrix dimension of the correlation matrix of the i-th field. exp refers to the exponential function, which can be used to complete the translation of a ij The linear mapping of .

[0145] S405: Normalize the field feature vectors of each field to obtain a target feature vector.

[0146] In the embodiment of the present application, normalization processing refers to the process of mapping the fused feature vectors of each field in multiple fields into one feature vector. In a specific implementation, normalization processing may include feature vector addition (Add) and normalization (Normalization), which is not limited.

[0147] S406: Obtain a target language translation text corresponding to the text to be translated based on the target feature vector decoding.

[0148] In the embodiment of the present application, the specific implementation of decoding can refer to the specific implementation of the above-mentioned step S204, which will not be described in detail.

[0149] In actual application, please refer to the attached Figure 5 , showing a schematic diagram of the encoder language modeling trend. Figure 5The horizontal axis of the statistical graph shown is the number of encoder layers, and the maximum number of layers is 6, which is used to indicate that the number of encoder layers in the Transformer is 6; Figure 5 The ordinate of the statistical graph shown is cosine similarity. The cosine similarity corresponding to any encoder layer refers to the cosine similarity between the feature vector obtained by extracting features of the fields contained in the text to be translated through the corresponding encoder layer and the feature vector obtained by extracting features of the fields contained in the accurate translation of the text to be translated through the corresponding encoder layer.

[0150] in, Figure 5 The broken line a in the statistical graph shown adopts the language tag strategy (LCS strategy) described in the embodiment of the present application, the broken line b adopts the S-Enc-T-Dec strategy, and the broken line c adopts the T-Enc strategy. Figure 5 It can be seen that as the number of encoder layers increases, the cosine similarity between the feature vector of the field contained in the extracted text to be translated and the feature vector of the field contained in the accurate translation becomes smaller.

[0151] In other words, the shallow encoder layers in multilingual translation models such as Transformer do not distinguish between languages ​​when extracting features, while the deep encoder layers pay more attention to language characteristics when extracting features, that is, distinguishing different languages. It can be seen that the encoders in multilingual translation models such as Transformer will first generate a relatively unified vector representation during the language modeling process, and then generate a vector representation with language characteristics.

[0152] Because the deep encoder layer in multilingual translation models such as Transformer only pays attention to language characteristics and distinguishes languages ​​during feature extraction; while the shallow encoder layer does not pay attention to distinguishing languages ​​during feature extraction; therefore, adding label vectors during feature extraction by the shallow encoder to indicate that the translation direction is the target language is not effective. Therefore, in an embodiment of the present application, by fusing the label vector of the language label of the target language with the field-level vector of the text to be translated during the feature extraction process of the deep encoder layer, it is achieved that on the basis of the original distinction of languages ​​by the deep encoder layer, the direction to the target language is further strengthened, so that the semantic information of each field represented by the target feature vector of the text to be translated finally carries the semantic information of the language label of the target language.

[0153] It can be seen that the embodiment of the present application improves the efficiency of indicating the translation direction by fusing the label vector only when performing feature extraction at the deep encoder layer, rather than fusing the label vector when performing feature extraction at each encoder layer. At the same time, since the semantic information of each field represented by the final target feature vector carries the semantic information of the language label of the target language; therefore, the translation direction can be continuously indicated as the target language when translating each field during the decoding process, thereby effectively reducing the probability of non-target language fields appearing in the final target language translation text, thereby achieving the purpose of improving the quality of the translation.

[0154] This application embodiment provides another text translation method, see the attached Figure 6 , showing a flow chart of another text translation method, which can be applied to Figure 1 The text translation system shown in the figure, the method can be executed by the terminal device or the server, or can be executed by the terminal device and the server together. In the embodiment of the present application, the method is executed by the terminal device as an example for explanation. Figure 6 As shown, the text translation method is Figure 2 This paper expands on the method shown in .

[0155] Among them, S601~S605 are described in detail as follows:

[0156] S601: Acquire an initial text to be translated into a target language.

[0157] In the embodiments of the present application, the initial text refers to a plain text without any language tags. The method of obtaining the initial text is different in different scenarios, and this is not limited. Specifically, in the translation scenario, the text to be translated input by the object can be used as the initial text; in the conversation scenario, the text selected by the conversation object from the conversation interface can be used as the translation text, and so on.

[0158] S602: Concatenate the initial text with the specified language tag to obtain a text to be translated.

[0159] In the embodiment of the present application, the specified language tag includes one or more of the language tag of the target language and the language tag of the language to which the initial text belongs. For example, the initial text is set to "This is a beautiful day", the target language is Chinese, and its language tag is " <zh>"; then, the concatenated text to be translated can be " <zh>This is a beautiful day".

[0160] S603: Perform feature coding processing on the fields contained in the text to be translated to obtain initial feature vectors of the fields.

[0161] S604: Perform word encoding processing on the language tag of the target language to be translated into the text to be translated, and obtain a label vector of the language tag.

[0162] S605: Fusing the initial feature vector and the label vector of the field to obtain a target feature vector of the text to be translated.

[0163] In an embodiment of the present application, the specific method of fusing the initial feature vector and label vector of the field to obtain the target feature vector of the text to be translated may be: fusing the initial feature vector of each field with the label vector respectively to obtain the fused feature vector of each field; performing global feature extraction on the fused feature vector of each field to obtain the field feature vector of each field; and normalizing the field feature vector of each field to obtain the target feature vector.

[0164] In one possible implementation, the above-mentioned global feature extraction processing is performed by a deep encoder layer in the encoder. Since there may be more than one deep encoder layer in the encoder, each deep encoder layer can fuse the feature vector of the field output by the previous encoder layer with the label vector, and then perform global feature extraction processing on the fused feature vector.

[0165] Then, the specific method of fusing the initial feature vector and label vector of the field to obtain the target feature vector of the text to be translated can also be: first, call the first deep encoder layer, perform feature fusion processing on the initial feature vector and label vector of each field, and obtain the fused feature vector of each field corresponding to the first deep encoder layer; perform global feature extraction processing on the fused feature vector of each field corresponding to the first deep encoder layer, and obtain the output feature vector of each field corresponding to the first deep encoder layer. Then, call the current deep encoder layer in a loop, perform feature fusion processing on the output feature vector of each field corresponding to the previous deep encoder layer, and the label vector, and obtain the fused feature vector of each field corresponding to the current deep encoder layer; perform global feature extraction processing on the fused feature vector of each field corresponding to the current deep encoder layer, and obtain the output feature vector of each field corresponding to the current deep encoder layer, until all deep encoder layers in the encoder are called. Finally, the output feature vector of each field corresponding to the last deep encoder layer is used as the field feature vector of each field.

[0166] It should be noted that the shallow encoder layers and deep encoder layers in the encoder can be set by humans, terminal devices or servers, and there is no limitation on this. In addition, the arrangement order of the shallow encoder layers is before the deep encoder layers. If there are 12 encoder layers in the encoder, then the first 9 layers can be set as shallow encoder layers, and layers 10 to 12 can be set as deep encoder layers.

[0167] Optionally, the specific implementations of steps S603 to S605 may also refer to the specific implementations of steps S201 to S203 and steps S401 to S405 in the above embodiments, and are not described in detail here.

[0168] For specific implementation, please refer to the attached Figure 7 , shows a process comparison diagram of multiple language labeling strategies. The encoder in Transformer is set to have 6 layers, the first 4 layers are set as shallow encoder layers, and the last 2 layers are set as deep encoder layers (also called LanguageConverter). In addition, the initial text is set to "This is a beautiful day", the target language is Chinese, and its language tag is "zh". It should be noted that for the convenience of presentation, Figure 7 In the above example, the field is directly used to represent the input feature vector of the field in any layer, and the " <zh>"represents the label vector of the language tag "zh"," <en>” represents the label vector for the English language label “en”.

[0169] Figure 7 Module 701 in the example presents the T-Enc strategy, which is to concatenate the target language label with the initial text, and then perform word encoding, position encoding and other encoding processing on each field contained in the concatenated text to obtain the input feature vectors of each field corresponding to the first layer (layer1) encoder layer. In addition, module 702 presents the S-Enc-T-Dec strategy, which is to concatenate the language label "en" of the source language English with the initial text, and then perform word encoding, position encoding and other encoding processing on each field contained in the concatenated text to obtain the input feature vectors of each field corresponding to the first layer (layer1) encoder layer.

[0170] Finally, module 703 presents the language tag (i.e., LCS strategy) described in the embodiment of the present application. As shown in module 703, after the language tag "en" of the source language English is concatenated with the initial text, each field contained in the obtained concatenated text is subjected to encoding processing such as word encoding and position encoding, and the input feature vector of the first layer (layer1) encoder can be obtained. Then, the first layer of encoder layer performs local feature extraction processing on the input feature vector of the first layer of encoder layer to obtain the output feature vector of each field corresponding to the first layer of encoder layer, and then the output feature vector of each field corresponding to the first layer of encoder layer is used as the input feature vector of the second layer (layer2) encoder layer. The first four shallow encoder layers complete the local feature extraction processing as described in the steps of the first and second layers above.

[0171] Then, the output feature vectors of each field corresponding to the 4th encoder layer can be used as the initial feature vectors of each field. Figure 7 By comparing modules 701, 702, and 703 in the LCS strategy, it can be seen that the encoder layers of layer 5 and layer 6 (i.e., the deep encoder layers) in the LCS strategy compare the output feature vectors of each field of the previous encoder layer with the label vector 704 (i.e., the output feature vectors of each field of the previous encoder layer) before using them as the input feature vectors of the current encoder layer. <zh>) for fusion processing, and then the fused feature vectors of each field corresponding to the current encoder layer are used as the input feature vector of the current encoder layer to perform global feature extraction processing.

[0172] S606: Obtain a target language translation text corresponding to the text to be translated based on the target feature vector decoding.

[0173] In the embodiment of the present application, the specific implementation of step S606 can refer to the specific implementation of step S204 in the above embodiment, which will not be repeated here.

[0174] In a possible implementation, the label vector and the target feature vector may be concatenated to obtain a concatenated feature vector, and then the concatenated feature vector may be decoded to obtain the target language translation text. The specific implementation of decoding the concatenated feature vector to obtain the target language translation text may refer to the specific implementation of decoding the target feature vector to obtain the target language translation text in step S204 above, which will not be described in detail here.

[0175] In the embodiments of the present application, while adopting language tag strategies such as T-Enc strategy, S-Enc-T-Dec strategy, T-Enc-T-Dec strategy, ST-Enc strategy, ST-Enc-T-Dec strategy, etc., the tag vector of the language tag of the target language can also be fused with the vector of the text to be translated at the field level, so that each language tag strategy, on the basis of originally indicating the translation direction, further indicates the translation direction for each translation field during the decoding process by making the semantic information of the language tag of the target language carried in the semantic information of each field. It can be seen that by combining the existing language tag strategy with this solution, the language accuracy and translation quality can be further improved on the basis of the language accuracy and translation quality of the existing language tag strategy.

[0176] The present application embodiment provides a text translation device, such as Figure 8 As shown, the device includes a processing unit 801 and a decoding unit 802:

[0177] A processing unit 801 is used to perform feature coding processing on the fields contained in the text to be translated to obtain an initial feature vector of the field;

[0178] The processing unit 801 is further used to perform word encoding processing on the language tag of the target language to be translated into the text to be translated, so as to obtain a label vector of the language tag;

[0179] The processing unit 801 is further used to fuse the initial feature vector and the label vector of the field to obtain a target feature vector of the text to be translated;

[0180] A decoding unit 802, configured to obtain a target language translation text corresponding to the to-be-translated text by decoding based on the target feature vector;

[0181] In one embodiment of the present application, based on the aforementioned scheme, the number of fields includes multiple fields; when the processing unit 801 fuses the initial feature vector and the label vector of the field to obtain the target feature vector of the text to be translated, it can be specifically used to fuse the initial feature vector of each field with the label vector respectively to obtain the fused feature vector of each field; perform global feature extraction on the fused feature vector of each field to obtain the field feature vector of each field; and normalize the field feature vector of each field to obtain the target feature vector.

[0182] In one embodiment of the present application, based on the aforementioned scheme, when the processing unit 801 performs global feature extraction processing on the fused feature vectors of each field to obtain the field feature vectors of each field, it can be specifically used for: according to the pre-set query parameter matrix, key parameter matrix and value parameter matrix, respectively, the fused feature vectors of each field are linearly transformed to obtain the query vector, keyword vector and value vector of each field; for any field, based on the query vector of any field and the keyword vectors of each field, a weight matrix of any field is obtained; wherein the weight matrix of any field is used to characterize the semantic consistency between any field and each field; based on the weight matrix of any field, the value vectors of each field are weighted to obtain the field feature vector of any field.

[0183] In one embodiment of the present application, based on the aforementioned scheme, when the processing unit 801 obtains the weight matrix of any field for any field based on the query vector of any field and the keyword vectors of each field, it can be specifically used to: obtain the association matrix of any field based on the query vector of any field and the keyword vectors of each field; wherein the association matrix of any field is used to characterize the semantic association between any field and each field; based on the matrix dimension of the association matrix of any field, process the association matrix of any field to obtain the weight matrix of any field.

[0184] In one embodiment of the present application, based on the aforementioned scheme, the processing unit 801, before performing feature encoding processing on the fields contained in the text to be translated and obtaining the initial feature vector of the field, can also be used to: obtain the initial text to be translated into the target language; concatenate the initial text with the specified language tag to obtain the text to be translated; wherein the specified language tag includes one or more of the language tag of the target language and the language tag of the language to which the initial text belongs.

[0185] In one embodiment of the present application, based on the above-mentioned scheme, when the decoding unit 802 obtains the target language translation text corresponding to the text to be translated based on the target feature vector decoding, it can be specifically used to: splice the label vector with the target feature vector to obtain a spliced ​​feature vector; perform feature decoding processing on the spliced ​​feature vector to obtain the target language translation text.

[0186] In one embodiment of the present application, based on the above-mentioned scheme, when the decoding unit 802 obtains the target language translation text corresponding to the text to be translated based on the target feature vector decoding, it can be specifically used to: perform word classification processing on the target feature vector based on the start symbol to obtain the first translation field; wherein the start symbol is used to indicate the beginning of the text to be translated; obtain the first feature vector obtained based on the first translation field and the target feature vector; loop execution of the steps of performing word classification processing on the feature vector obtained last time based on all the obtained translation fields to obtain the currently obtained translation field, and obtaining the currently obtained feature vector based on the currently obtained translation field and the previously obtained feature vector, until the current translation field is the end symbol; wherein the end symbol is used to indicate the end of the text to be translated; and generate the translation text based on all the obtained translation fields.

[0187] It should be noted that the device provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment and will not be repeated here.

[0188] The device provided in the above embodiment can be arranged in a terminal device or in a server. Through the device provided in the embodiment of the present application, the label vector of the language label of the target language can be fused with the vector of the text to be translated at the field level, so that the semantic information of each field represented by the target feature vector of the text to be translated finally carries the semantic information of the language label of the target language. It can be seen that the embodiment of the present application can continuously indicate the translation direction as the target language when translating each field in the decoding process by carrying the semantic information of the language label of the target language in the semantic information of each field, thereby effectively reducing the probability of non-target language fields appearing in the target language translation text finally obtained, thereby achieving the purpose of improving the quality of the translation.

[0189] An embodiment of the present application also provides an electronic device, comprising one or more processors and a storage device, wherein the storage device is used to store one or more computer programs, and when the one or more computer programs are executed by one or more processors, the electronic device implements the above text translation method.

[0190] Fig. 9 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.

[0191] It should be noted that Fig. 9 The computer system 900 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0192] like Fig. 9 As shown, the computer system 900 includes a processor (Central Processing Unit, CPU) 901, which can perform various appropriate actions and processes according to the program stored in the read-only memory (Read-Only Memory, ROM) 902 or the program loaded from the storage part 908 to the random access memory (Random Access Memory, RAM) 903, such as executing the method in the above embodiment. In RAM 903, various programs and data required for system operation are also stored. CPU 901, ROM 902 and RAM 903 are connected to each other through bus 904. Input / output (Input / Output, I / O) interface 905 is also connected to bus 904.

[0193] In some embodiments, the following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.

[0194] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 909, and / or installed from a removable medium 911. When the computer program is executed by a processor (CPU) 901, various functions defined in the system of the present application are executed.

[0195] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (Erasable Programmable Read Only Memory), a flash memory, an optical fiber, a portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0196] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the devices, methods and computer program products according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and a computer program.

[0197] The units or modules involved in the embodiments described in this application may be implemented by software or hardware, and the units or modules described may also be set in a processor. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves.

[0198] Another aspect of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the text translation method as described above is implemented. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.

[0199] Another aspect of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of an electronic device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the electronic device performs the text translation method as described above in the above embodiments.

[0200] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0201] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.

[0202] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person of ordinary skill in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.< / zh> < / en> < / zh> < / zh> < / zh>

Claims

1. A text translation method, It is characterized in that include: Performing feature encoding processing on the fields contained in the text to be translated to obtain an initial feature vector of the field; Performing word encoding processing on the language tag of the target language to be translated into the text to be translated, to obtain a label vector of the language tag; Performing a fusion process on the initial feature vector of the field and the label vector to obtain a target feature vector of the text to be translated; A target language translation text corresponding to the text to be translated is obtained based on the target feature vector decoding.

2. The method according to claim 1, It is characterized in that The number of the fields includes a plurality; the fusing process of the initial feature vector of the field and the label vector to obtain the target feature vector of the text to be translated includes: Performing feature fusion processing on the initial feature vectors of each field and the label vector respectively to obtain fused feature vectors of each field; Performing global feature extraction processing on the fused feature vectors of the respective fields to obtain field feature vectors of the respective fields; The field feature vectors of the respective fields are normalized to obtain the target feature vector.

3. The method according to claim 2, It is characterized in that The performing global feature extraction processing on the fused feature vectors of the respective fields to obtain the field feature vectors of the respective fields includes: According to the preset query parameter matrix, key parameter matrix and value parameter matrix, linear transformation processing is performed on the fused feature vectors of each field to obtain the query vector, keyword vector and value vector of each field; For any field, based on the query vector of the any field and the keyword vectors of the respective fields, a weight matrix of the any field is obtained; wherein the weight matrix of the any field is used to characterize the semantic consistency between the any field and the respective fields; Based on the weight matrix of any field, weighted processing is performed on the value vectors of each field to obtain a field feature vector of any field.

4. The method according to claim 3, It is characterized in that The step of obtaining a weight matrix of any field based on the query vector of the field and the keyword vectors of each field includes: Based on the query vector of any field and the keyword vectors of each field, a relevance matrix of any field is obtained; wherein the relevance matrix of any field is used to represent the semantic relevance between any field and each field; Based on the matrix dimension of the relevance matrix of any field, the relevance matrix of any field is processed to obtain a weight matrix of any field.

5. The method according to any one of claims 1 to 4, It is characterized in that Before performing feature coding processing on the field contained in the text to be translated to obtain the initial feature vector of the field, the method further includes: Obtaining the initial text to be translated into the target language; The initial text is concatenated with a specified language tag to obtain the text to be translated; wherein the specified language tag includes one or more of a language tag of the target language and a language tag of the language to which the initial text belongs.

6. The method according to any one of claims 1 to 4, It is characterized in that The decoding based on the target feature vector to obtain a target language translation text corresponding to the text to be translated includes: Concatenate the label vector and the target feature vector to obtain a concatenated feature vector; Perform feature decoding processing on the concatenated feature vector to obtain the target language translation text.

7. The method according to any one of claims 1 to 4, It is characterized in that The decoding based on the target feature vector to obtain a target language translation text corresponding to the text to be translated includes: Performing word classification processing on the target feature vector based on the start symbol to obtain a translation field obtained for the first time; wherein the start symbol is used to indicate the beginning of the text to be translated; Obtaining a first obtained feature vector according to the first obtained translation field and the target feature vector; The steps of performing word classification processing on the feature vector obtained last time based on all the obtained translation fields to obtain the currently obtained translation field, and obtaining the currently obtained feature vector according to the currently obtained translation field and the feature vector obtained last time are executed cyclically until the currently obtained translation field is an end symbol; wherein the end symbol is used to indicate the end of the text to be translated; The translation text is generated according to all the obtained translation fields.

8. The method according to any one of claims 1 to 4, It is characterized in that The feature encoding process is performed on the field contained in the text to be translated to obtain the initial feature vector of the field, including: Performing word encoding processing on the field to obtain a word vector of the field; According to the position of the field in the text to be translated, performing position encoding processing on the field to obtain a position vector of the field; Based on the word vector and the position vector of the field, an initial feature vector of the field is obtained.

9. A text translation device, It is characterized in that include: A processing unit, used for performing feature coding processing on a field contained in the text to be translated to obtain an initial feature vector of the field; The processing unit is further used to perform word encoding processing on the language label of the to-be-translated text to be translated into the target language to obtain a label vector of the language label; The processing unit is further used to perform a fusion process on the initial feature vector of the field and the label vector to obtain a target feature vector of the text to be translated; A decoding unit is used to decode the target feature vector to obtain a target language translation text corresponding to the text to be translated.

10. An electronic device, It is characterized in that include: one or more processors; A storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the text translation method according to any one of claims 1 to 8.

11. A computer readable medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the text translation method according to any one of claims 1 to 8 is implemented.

12. A computer program product, It is characterized in that The computer program product comprises a computer program, and the computer program is suitable for being loaded by a processor and executing the text translation method according to any one of claims 1 to 8.