Translation method and device, storage medium and electronic device

By encoding and decoding the original statements and historical statements during the session between the first object and the second object during the translation process, the problem of role preference and statement coherence is solved, and the translation accuracy is improved.

CN113569585BActive Publication Date: 2025-08-29TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110212812.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-25
Publication Date
2025-08-29
Estimated Expiration
2041-02-25

AI Technical Summary

Technical Problem

The prior art does not pay attention to role preferences and coherence between statements during the sentence translation process, resulting in low accuracy of translation results.

Method used

By obtaining the original statements and historical statements during the session between the first object and the second object, the first target vector, the second target vector and the third target vector are encoded to represent role preferences, statement order and content associations, and splicing them into combination vectors for decoding to obtain translation results.

Benefits of technology

Improve the accuracy of translation results and realize the processing of character characteristics and dialogue coherence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113569585B_ABST
    Figure CN113569585B_ABST
Patent Text Reader

Abstract

The present invention discloses a translation method and device based on artificial intelligence, a storage medium and an electronic device. The method comprises: during a conversation between a first object and a second object, obtaining an original sentence in a first language to be translated currently input by the first object; obtaining historical sentences associated with the original sentence; encoding the original sentence and the historical sentences to obtain a first target vector, a second target vector and a third target vector, wherein the first target vector is used to represent the role preference of the first object, the second target vector is used to represent the order of the historical sentences, and the third target vector is used to represent the content association between the historical sentences; splicing the first target vector, the second target vector and the third target vector into a combined vector; decoding the combined vector to obtain a translation result in the second language after the original sentence is translated. The present invention solves the technical problem that the translation result does not have the character characteristics and dialogue coherence, and the translation result has low accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a translation method and device, a storage medium, and an electronic device. Background Art

[0002] In the prior art, during the translation of sentences, such as translating sentences from a first language into a second language, attention is usually not paid to role preferences, coherence between sentences, and content relevance between sentences during the translation process, resulting in low accuracy of the translated sentences in the second language.

[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention

[0004] The embodiments of the present invention provide a translation method and apparatus, a storage medium, and an electronic device to at least solve the technical problem that the translation results lack character characteristics and dialogue coherence and have low translation accuracy.

[0005] According to one aspect of an embodiment of the present invention, a translation method is provided, comprising: obtaining, during a conversation between a first object and a second object, an original sentence in a first language to be translated currently input by the first object; obtaining historical sentences associated with the original sentence, wherein the historical sentences include sentences generated by the first object and sentences generated by the second object during the historical conversation between the first object and the second object; encoding the original sentence and the historical sentences to obtain a first target vector, a second target vector, and a third target vector, wherein the first target vector is used to represent the role preference of the first object, the second target vector is used to represent the order of the historical sentences, and the third target vector is used to represent the content association between the historical sentences; splicing the first target vector, the second target vector, and the third target vector into a combined vector; and decoding the combined vector to obtain a translation result in the second language after the original sentence is translated.

[0006] According to another aspect of an embodiment of the present invention, a translation device is further provided, comprising: a first acquisition unit, configured to acquire, during a conversation between a first object and a second object, an original sentence in a first language to be translated currently input by the first object; a second acquisition unit, configured to acquire historical sentences associated with the original sentence, wherein the historical sentences include sentences generated by the first object and sentences generated by the second object during the historical conversation between the first object and the second object; an encoding unit, configured to encode the original sentence and the historical sentences to obtain a first target vector, a second target vector, and a third target vector, wherein the first target vector is used to represent the role preference of the first object, the second target vector is used to represent the order of the historical sentences, and the third target vector is used to represent the content association between the historical sentences; a splicing unit, configured to splice the first target vector, the second target vector, and the third target vector into a combined vector; and a decoding unit, configured to decode the combined vector to obtain a translation result in the second language after the original sentence is translated.

[0007] As an optional example, the splicing unit includes: a splicing module for splicing the first target vector, the second target vector, the third target vector and the encoding vector into the combined vector when the original sentence includes an encoding vector, wherein the encoding vector is a word embedding vector of each word before any word in the original sentence when translating any word after the first word of the original sentence.

[0008] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned translation method when executed by a processor.

[0009] According to another aspect of an embodiment of the present invention, there is provided an electronic device including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the translation method through the computer program.

[0010] In an embodiment of the present invention, during a conversation between a first object and a second object, an original sentence in the first language to be translated currently input by the first object is obtained; historical sentences associated with the original sentence are obtained; the original sentence and the historical sentences are encoded to obtain a first target vector, a second target vector and a third target vector, wherein the first target vector is used to represent the role preference of the first object, the second target vector is used to represent the order of the historical sentences, and the third target vector is used to represent the content association between the historical sentences; the first target vector, the second target vector and the third target vector are spliced ​​into a combined vector; the combined vector is decoded to obtain the second language after the original sentence is translated. The method for obtaining translation results is as follows: in the above method, in the process of translating a sentence, the original sentence is encoded to obtain a first target vector, a second target vector and a third target vector, wherein the above first target vector is used to represent the role preference of the above first object, the above second target vector is used to represent the order of the above historical sentences, and the above third target vector is used to represent the content association between the above historical sentences, so that the role preference, sentence order and sentence content association of the original sentence can be obtained, and then the combined vector of the first target vector, the second target vector and the third target vector is decoded to obtain the translation result, thereby achieving the effect of improving the accuracy of the translation, and thus solving the technical problem that the translation result does not have the character characteristics and dialogue coherence and the translation result has low accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0012] Figure 1 is a schematic diagram of an application environment of an optional translation method according to an embodiment of the present invention;

[0013] Figure 2 is a schematic diagram of an application environment of another optional translation method according to an embodiment of the present invention;

[0014] Figure 3 is a schematic diagram of a process of an optional translation method according to an embodiment of the present invention;

[0015] Figure 4 is a schematic diagram of a translation scenario of an optional translation method according to an embodiment of the present invention;

[0016] Figure 5 is a schematic diagram of a translation scenario of another optional translation method according to an embodiment of the present invention;

[0017] Figure 6 is a schematic diagram of a historical sentence according to an optional translation method of an embodiment of the present invention;

[0018] Figure 7 is a schematic diagram of a target neural network model of an optional translation method according to an embodiment of the present invention;

[0019] Figure 8 is a schematic diagram of a data processing layer of an optional translation method according to an embodiment of the present invention;

[0020] Figure 9 is a schematic structural diagram of an optional translation device according to an embodiment of the present invention;

[0021] Figure 10 FIG. 4 is a schematic structural diagram of an optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0022] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0023] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0024] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also involves studying the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.

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

[0026] Natural language processing (NLP) is a key area of ​​research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. Natural language processing (NLP) integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language we use in everyday life—and is closely linked to the study of linguistics. Natural language processing technologies typically include text processing, semantic understanding, machine translation, robotic question answering, and knowledge graphs.

[0027] According to one aspect of an embodiment of the present invention, a translation method is provided. Optionally, as an optional implementation, the translation method can be applied to, but is not limited to, Figure 1 in the environment shown.

[0028] like Figure 1 As shown, the terminal device 102 includes a memory 104 for storing various data generated during the operation of the terminal device 102, a processor 106 for processing and calculating the above-mentioned various data, and a display 108 for displaying the original sentence and the translation result. The terminal device 102 can exchange data with a server 112 via a network 110. The server 112 includes a database 114 for storing various data and a processing engine 116 for processing the above-mentioned various data. As shown in steps S102, S104 and S106, the terminal device 102 sends the original sentence to the server 112, and the server 112 translates the original sentence to obtain a translation result, and then sends the translation result to the terminal device 102.

[0029] As an optional implementation, the above translation method can be applied to, but is not limited to, Figure 2 in the environment shown.

[0030] like Figure 2 As shown, terminal device 202 includes a memory 204 for storing various data generated during the operation of terminal device 202, a processor 206 for processing and calculating the aforementioned data, and a display 208 for displaying the original sentence and the translation result. Terminal device 202 can sequentially execute steps S202, S204, S206, S208, and S210, that is, terminal device 202 completes the translation of the original sentence and obtains the translation result.

[0031] Optionally, in this embodiment, the above-mentioned terminal device can be a terminal device configured with a target client, which can include but is not limited to at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop computer, a tablet computer, a PDA, an MID (Mobile Internet Devices), a PAD, a desktop computer, a smart TV, etc. The target client can be a video client, an instant messaging client, a browser client, an education client, etc. The above-mentioned network can include but is not limited to: a wired network, a wireless network, wherein the wired network includes: a local area network, a metropolitan area network and a wide area network, and the wireless network includes: Bluetooth, WIFI and other networks that realize wireless communication. The above-mentioned server can be a single server, or it can be a server cluster composed of multiple servers, or a cloud server. The above is only an example, and this embodiment does not impose any limitation on this.

[0032] Alternatively, as an optional implementation, Figure 3 As shown, the above translation method includes:

[0033] S302, during a conversation between a first object and a second object, obtaining an original sentence in a first language to be translated currently input by the first object;

[0034] S304, obtaining historical sentences associated with the original sentence, wherein the historical sentences include sentences generated by the first object and sentences generated by the second object during a historical conversation between the first object and the second object;

[0035] S306: Encode the original sentence and the historical sentences to obtain a first target vector, a second target vector, and a third target vector, wherein the first target vector is used to represent the role preference of the first subject, the second target vector is used to represent the order of the historical sentences, and the third target vector is used to represent the content association between the historical sentences;

[0036] S308, concatenating the first target vector, the second target vector, and the third target vector into a combined vector;

[0037] S310: Decode the combined vector to obtain a translation result in the second language after the original sentence is translated.

[0038] Optionally, the above translation method can be applied, but is not limited to, to the translation of sentences. The language of the sentences is not limited. For example, the language can be a language used in any country or region. It can be applied, but is not limited to, to a conversation between two or more parties. In a conversation between two or more parties, each party can use a different language. In a multi-party conversation, at least two parties can use the same language, while the other parties can use different languages.

[0039] Optionally, the above translation method can be applied to a client. When different users use the client to communicate or instant message, the method in this embodiment can be used to translate. Alternatively, when different users communicate face to face, the client can also be used to translate the content of the conversation. The client can be a single client that receives and translates the content of communication between two or more users, or two users can each use a client to translate the content of the communication.

[0040] For example, if two users use one client to translate, Figure 4 As shown, Figure 4 In this example, two users use a client to translate. The client receives each user's original sentence, translates it, and displays the translation result. When translating a user's original sentence into a translation result, that user is the first subject, and the other user is the second subject. The client receives user A's sentence in the first language and translates it into a translated sentence in the second language 402. The client receives user B's sentence in the second language and translates it into a translated sentence in the first language 404. User A and user B can communicate through the client.

[0041] Or, for example, multiple users using their own clients to translate Figure 5 shown. Figure 5 In this example, three users interact with each other, each using a client. They may speak different languages. User A sends a sentence in the first language to users B and C. The clients of users B and C translate the sentence in the first language into the corresponding sentences in the second and third languages. User A's client translates user B's sentence in the second language and user C's sentence in the third language into the first language.

[0042] Optionally, in the embodiments of the present application, the identities of the first and second objects are not limited. For example, they can be a tour guide and a tourist, a shop owner and a customer, etc. As long as the two objects use sentences in two languages, the translation method of the embodiments of the present application can be used. In the embodiments of the present application, the method for obtaining the original sentence is not limited. For example, the original sentence can be obtained in the form of text input, or in the form of voice input, etc.

[0043] In the embodiments of the present application, historical sentences may be sentences generated during the conversation between the first object and the second object before the original sentence. These may include a first historical sentence in a first language generated by the first object, a second historical sentence in a second language generated by the second object, a first translated sentence of the first historical sentence, and a second translated sentence of the second historical sentence, where the first translated sentence is in the second language and the second translated sentence is in the first language.

[0044] Through this embodiment, through the above method, in the process of translating the original sentence, the original sentence is encoded to obtain a first target vector, a second target vector and a third target vector, wherein the first target vector is used to represent the role preference of the first object, the second target vector is used to represent the order of historical sentences, and the third target vector is used to represent the content association between historical sentences, so that the role preference, sentence order and content association of the original sentence can be obtained, and then the combined vector of the first target vector, the second target vector and the third target vector is decoded to obtain the translation result, thereby achieving the effect of improving the accuracy of translation.

[0045] As an optional implementation, encoding the original sentence and the historical sentence to obtain the first target vector, the second target vector, and the third target vector includes:

[0046] Obtain a first sentence, a second sentence, a third sentence, and a fourth sentence, wherein the first sentence is a first historical sentence, the second sentence is the first historical sentence and the second translated sentence, the third sentence is a historical sentence, and the fourth sentence is an original sentence;

[0047] Obtain a first vector, a second vector, a third vector, and a fourth vector, wherein the first vector is a low-dimensional vector obtained by mapping the first statement, the second vector is a low-dimensional vector obtained by mapping the second statement, the third vector is a low-dimensional vector obtained by mapping the third statement, and the fourth vector is a low-dimensional vector obtained by mapping the fourth statement;

[0048] The first vector is encoded as a first target vector, the second vector and the fourth vector are encoded as a second target vector, and the third vector is encoded as a third target vector.

[0049] Optionally, the first sentence, the second sentence, and the third sentence mentioned in this embodiment may be sentences obtained from historical sentences. The fourth sentence may be an original sentence. Specifically, the first historical sentence of the first character in the historical sentence is used as the first sentence, the first historical sentence and the second translated sentence are used as the second sentence, all the contents of the historical sentence are used as the third sentence, and the original sentence is used as the fourth sentence. The Embedding layer can be used to map the first to fourth sentences into low-dimensional vectors to obtain the first to fourth vectors. The first vector is encoded as a first target vector, the second vector and the fourth vector are encoded as second target vectors, and the third vector is encoded as a third target vector.

[0050] Through this embodiment, the first target vector, the second target vector, and the third target vector can be obtained from the original sentence of the first object and the historical sentences of the conversation between the first object and the second object, thereby determining the role preference of the first object, the order of sentences, and the content association between sentences.

[0051] As an optional implementation, encoding the first vector into a first target vector, encoding the second vector and the fourth vector into a second target vector, and encoding the third vector into a third target vector includes:

[0052] encoding the first vector into a first target vector and encoding the third vector into a third target vector using a first encoding layer;

[0053] The second vector and the fourth vector are encoded into a first intermediate vector and a second intermediate vector using a first coding layer, the second intermediate vector is encoded into a result vector using a second coding layer, and the first intermediate vector and the result vector are combined into a second target vector, wherein the first coding layer includes one coding layer and the second coding layer includes five coding layers.

[0054] Optionally, the first and second encoding layers can be, but are not limited to, encoding layers of the target neural network. Different encoding layers have different numbers of layers and encode different content. The first encoding layer has one encoding layer for encoding the first vector and the third vector to obtain the first target vector and the third target vector. It also encodes the second vector and the fourth vector to obtain the first intermediate vector and the second intermediate vector. The second encoding layer then encodes the first intermediate vector and the second intermediate vector to obtain the second target vector. The second encoding layer has five encoding layers.

[0055] This embodiment encodes the first to fourth vectors by using different encoding layers, thereby obtaining more accurate first target vector, second target vector, and third target vector.

[0056] As an optional implementation, concatenating the first target vector, the second target vector, and the third target vector into a combined vector includes:

[0057] In the case where the original sentence includes an encoding vector, the first target vector, the second target vector, the third target vector, and the encoding vector are concatenated into a combined vector, where the encoding vector is the word embedding vector of each word before any word in the original sentence when translating any word after the first word of the original sentence.

[0058] Optionally, when translating the original sentence, the entire sentence can be translated or translated word by word. For word-by-word translation, when translating any word in the original sentence, the word embedding vectors of each word preceding the original word can be used as encoding vectors. The encoding vectors are then concatenated with the first, second, and third target vectors to generate a combined vector. Finally, the combined vector is decoded to obtain the translation result of the original sentence.

[0059] In this embodiment, the addition of encoding vectors allows for the translation of any word in the original sentence to be influenced by the preceding words, thereby improving translation accuracy. This also avoids the situation where the same word in the first language is translated into different words in the second language.

[0060] As an optional implementation, encoding the original sentence and the historical sentence to obtain the first target vector, the second target vector and the third target vector includes: inputting the historical sentence into the target neural network model, and extracting the first target vector, the second target vector and the third target vector by the feature extraction layer of the target neural network model; decoding the combined vector to obtain the translation result of the second language after the original sentence is translated, including: determining the result obtained by decoding the combined vector using the decoding layer of the target neural network model as the translation result, wherein the target neural network model is a pre-trained model, and the feature extraction layer and the decoding layer include target parameters after the original parameters are trained.

[0061] Optionally, the target neural network model in this embodiment may include a feature extraction layer and a decoding layer. The feature extraction layer is used to extract features from the first vector to the fourth vector to obtain a first target vector, a second target vector and a third target vector. The decoding layer is responsible for decoding the combined vector to obtain the translation result of the original sentence. Both the feature extraction layer and the decoding layer include model parameters. If it is a training process, the parameters of the model will be adjusted as the training progresses. If it is a usage process, the model parameters are generally fixed. According to the model parameters, after inputting the first vector to the fourth vector, the first target vector to the third target vector can be encoded. And the combined vector is decoded into a translation result. The target neural network model is a mature model obtained by training the original neural network model using sample data. The target neural network model learns the role preference of the first object, the order of sentences, and the content association between sentences, so the translation accuracy is high.

[0062] As an optional implementation, before inputting the historical sentence into the target neural network model and extracting the first target vector, the second target vector, and the third target vector by the feature extraction layer of the target neural network model, the method further includes:

[0063] Obtaining an original neural network model, wherein the original neural network model includes a feature extraction layer and a decoding layer, and the feature extraction layer and the decoding layer include original parameters;

[0064] Obtaining a sample original sentence, a sample translation result, and a sample history sentence of the sample original sentence, wherein the sample original sentence is a sentence in the first language generated by the third object, the sample translation result is a sentence in the second language translated from the sample original sentence, and the sample history sentence includes a first sample history sentence in the first language generated by the third object during a conversation between the third object and the fourth object, a second sample history sentence in the second language generated by the fourth object, a first sample translation sentence of the first sample history sentence, and a second sample translation sentence of the second sample history sentence, the first sample translation sentence is a sentence in the second language, and the second sample translation sentence is a sentence in the first language;

[0065] The original parameters of the original neural network model are trained using the sample original sentences, sample translation results and sample historical sentences to obtain the target neural network model.

[0066] Optionally, the sample data in the embodiment of the present application may include multiple pieces. Each piece of sample data includes a sample original sentence, a sample translation result, and a sample historical sentence. The sample original sentence is a sentence in the first language, and the sample translation result is a sentence in the second language. The sample historical sentence includes both sentences in the first language and sentences in the second language. In other words, the sample data includes sentences generated by a conversation between two objects, and the translation results of the generated sentences. However, the two objects may not be the first object and the second object mentioned above. That is, any sentence record in which any object uses the first sentence and the second sentence to have a conversation can be used as a training sample.

[0067] As an optional implementation, using the sample original sentences, the sample translation results, and the sample historical sentences to train the original parameters of the original neural network model to obtain the target neural network model includes:

[0068] The following operations are performed on the original neural network model until the recognition accuracy of the original neural network model is greater than the first threshold to obtain a target neural network model:

[0069] Inputting the sample translation result into the feature extraction layer to obtain a first target sample vector, a second target sample vector, and a third target sample vector;

[0070] Inputting the sample original sentence into the feature extraction layer to obtain a first original sample vector, a second original sample vector, and a third original sample vector;

[0071] Merge the first original sample vector, the second original sample vector, the third original sample vector, and the sample encoding vector of the sample original sentence into a sample combination vector, wherein the sample encoding vector is the word embedding vector of each word before any word in the sample original sentence when translating any word after the first word of the sample original sentence;

[0072] Use the decoding layer to decode the sample combination vector to obtain the estimated sentence;

[0073] When the difference between the first target sample vector and the first original sample vector is greater than a first threshold, or the difference between the second target sample vector and the second original sample vector is greater than a second threshold, or the difference between the third target sample vector and the third original sample vector is greater than a third threshold, or the difference between the sample original statement and the estimated statement is greater than a fourth threshold, adjust the value of the original parameter.

[0074] That is to say, in the process of training the model, the original neural network model can receive the first vector to the fourth vector obtained by mapping the first sentence to the fourth sentence, and then use the feature extraction layer to encode the first vector to the fourth vector to obtain the first target vector to the third target vector. Similarly, the sample translation results of the sample original sentences in the sample data are encoded to obtain the first original sample vector, the second original sample vector and the third original sample vector. In addition, the decoding layer of the target neural network model is used to decode the combined vector into an estimated sentence, and the model parameters of the feature extraction layer and the decoding layer in the original neural network model are constrained by the first original sample vector, the second original sample vector and the third original sample vector and the estimated sentence, thereby playing a training role. Finally, a maturely trained target neural network model is obtained.

[0075] The following is a specific example. In this embodiment, the communication between two objects is used as an example. The two objects use their respective languages. The first object uses the first language, and the second object uses the second language. The first language can be English and the second language can be German. Figure 6 As shown, the first object generates 602-1, 606-1 and 610-1 in the first language, where 602-1 and 606-1 are translated into 602-2 and 606-2 in the second language, and 610-1 is the sentence to be translated into 610-2. The second object generates 604-1 and 608-1 in the second language, which are translated into 604-2 and 608-2 in the first language. Figure 6 The original sentence, historical sentence and translation result in the training of the original neural network model are used as a sample. If the above 610-2 is unknown, the trained target neural network model can be used to translate the original sentence to obtain the translation result. If the above 610-2 is known, then Figure 6 The data in is used as training sample data, and Role-Specific Contexts (c1) is the English sentence generated by object A in the training sample data, that is, Figure 6 602-1 and 606-1 in the figure. Coherent Chat Context (c2) is the English sentence generated by object A and the English sentence obtained by translating the German sentence of object B, that is, Figure 6 602-1, 604-2, 606-1 and 608-2 in the above. Contexts of Inter-Linguistic relationships (c3) are the historical conversation records and translation records of the historical conversation records generated by object A and object C, that is, the sample historical sentences mentioned above, namely Figure 6The Source Inputs (x) are the original sentences to be translated in the sample data of object A, that is, Figure 6 610-1 in the example. The sample translation result is known. If 610-2 is unknown, then Role-Specific Contexts (c1) is the first sentence, Coherent Chat Context (c2) is the second sentence, and Contexts of Inter-Linguistic relationships (c3) is the third sentence. The original text generated by the first object or the second object can be represented by Src, and the translation of the original text generated by the first object or the second object can be represented by Tgt. If it is the target sentence after the sentence to be translated is translated, it can be represented by Ref.

[0076] For the original sentence to be translated, the target neural network model is used to translate and obtain the translation result. The target neural network model is a pre-trained model. The structure of the target neural network model (or original neural network model) is as follows: Figure 7 shown. Figure 7 In this article, we explain how to train and use the model.

[0077] First, the training process requires acquiring training sample data. The training samples include sample original sentences, sample translation results, and sample historical sentences of the sample original sentences. The sample original sentences are the sentences to be translated in the training sample data, such as English. The sample translation results are the translated results of the sentences to be translated in the training sample data, such as German. The sample historical sentences are the historical records before the sample original sentences, including sentences in English and German. Specifically, they include a first sample historical sentence in English generated during the conversation between the third object and the fourth object, a second sample historical sentence in German generated by the fourth object, a first sample translated sentence of the first sample historical sentence, and a second sample translated sentence of the second sample historical sentence. The first sample translated sentence is in German, and the second sample translated sentence is in English. The aforementioned third object may or may not be the first object, and the aforementioned fourth object may or may not be the second object. The aforementioned sample original sentences, sample historical sentences, and sample translation results serve as a training sample to train the original neural network model until the target neural network model is obtained.

[0078] During the training process, multiple training samples can be obtained. The training process of one training sample is used as an example for explanation. A training sample includes the above-mentioned sample original sentence, sample historical sentence and sample translation result.

[0079] First, process the part containing the conversation history information. That is, data acquisition. From the sample original sentence, sample historical sentence and sample translation result, obtain the first sample sentence, the second sample sentence, the third sample sentence and the fourth sample sentence. The first sample sentence is the English generated by the third object in the above historical sentence. The second sample sentence is the English generated by the third object and the German generated by the fourth object translated into English. The third sample sentence includes the English generated by the third object and the translated German and the German generated by the fourth object and the translated English. That is, all the historical sample sentences. The fourth sample sentence is the sample original sentence generated by the third object, that is, the English to be translated into German. Corresponding Figure 7 During the training process, we obtain the training sample data Role-Specific Contexts (c1), Coherent Chat Context (c2), Contexts of Inter-Linguistic relationships (c3), and Source Inputs (x). That is, the first to fourth sample sentences.

[0080] by Figure 6 As an example, the first to third sample statements are obtained as follows:

[0081] For Role-Specific Context (c1):

[0082]

[0083] The SEP can be regarded as "and" or "and", and CLS is the Common Language Specification (abbreviated as CLS). In other words, the English version of the third object is obtained.

[0084] For Coherent Chat Context (c2):

[0085]

[0086] That is, the English translation of the third object and the English translation of the fourth object in German are obtained.

[0087] For Context (c3) used to model the relationship between languages:

[0088]

[0089]

[0090] That is, obtain the English translation of the third object and the German translation of the fourth object, and obtain the German translation of the third object and the German translation of the fourth object. That is, obtain all sample historical sentences.

[0091] Among them, x represents the original text to be translated, and s0~sn-1 (src / tgt) represent different forms of conversation history.

[0092] After learning through Transformer, the following representations are obtained:

[0093] Source sentence representation (Masked representation and): H x

[0094] Target sentence representation (representation after Masked): H y

[0095] Role-Specific Context Representation (i.e., the hidden state representation corresponding to [CLS])

[0096] Dialog-level Coherent Context representation (i.e., the hidden state representation corresponding to [CLS])

[0097] Inter-Linguistic Context representation (i.e., the hidden state representation corresponding to [CLS])

[0098] That is to say, after obtaining the first to fourth sample sentences above, the above information is passed through the Embedding layer to obtain the corresponding token representation (the part containing context information will have an additional Turn embeddings and Role embeddings). Figure 8 This is a diagram of an optional embedding layer. It includes four embedding layers: Token Embeddings (also known as Word Embeddings), Positional Embeddings, Turn Embeddings, and Role Embeddings. In the embedding layer, the source / target input is processed by the token embeddings and positional embeddings layers. For the portion containing the conversation history, additional Turn Embeddings and Role Embeddings layers are added. Figure 8The + in the sentence represents a summation operation. That is, the first through third sample sentences pass through the four Embedding layers described above, while the fourth sample sentence passes through the Word Embedding and Position Embedding layers to obtain the corresponding low-dimensional vectors. These are the first through fourth sample vectors. These vectors are then used to train the original neural network model, which includes a feature extraction layer and a decoding layer. The feature extraction layer converts the first through fourth sample vectors into the first through third target sample vectors.

[0099] For Coherent Chat Context+Source Context(Source Inputs(x)), it passes through the first encoding layer Transformer Bottom Block layer and the second encoding layer Transformer Top Block layer, where the MASK operation is used to make the Top Block layer only encode the Source Inputs information as the input of the Decoder; and the Context information part is represented by the [CLS] hidden state representation of the Transformer Bottom Block layer as the Context representation, in preparation for sampling the latent variable Z2; that is, during the training process, the above-mentioned second sample vector and fourth sample vector are extracted by the feature extraction layer of the original neural network model to obtain the second target sample vector Z2. The Context representation of modeling specific role preferences and inter-linguistic relationships is represented by the [CLS] hidden state representation that only passes through the Transformer Bottom Block layer, in preparation for sampling the latent variables Z1 and Z3. That is, for Role-Specific Contexts(c1) and Contexts of Inter-Linguistic relationships(c3), they are respectively encoded by the first encoding layer of the feature extraction layer to obtain the first target sample vector Z1 and the third target sample vector Z3 (corresponding to Figure 7 Z1 to Z3 of the feature extraction layer output in 702).

[0100] The specific formula for determining the first target sample vector Z1 to the third target sample vector Z3 is as follows:

[0101] Constructing the prior distribution and posterior distribution of the preference of a specific role can effectively model the preference of a specific role. The latent variables obey the multivariate Gaussian distribution, that is, q1(z1|y,x,c1)~N(u1,σ1 2 I) and p1(z1|x,c1)~N(u′1,σ′1 2 I), so its posterior distribution and prior distribution are as follows:

[0102]

[0103]

[0104] Among them, W r and b r are the parameters to be learned.

[0105] During the training phase, Z1 is determined using the posterior distribution. During the usage phase, Z1 is determined using the prior distribution.

[0106] By modeling the prior distribution and posterior distribution of dialogue coherence, the dialogue coherence can be effectively improved. Similarly, assuming that the latent variables obey the multivariate Gaussian distribution, that is, q2(z2|y,x,c2)~N(u2,σ2 2 I) and p2(z2|x,c2)~N(u′2,σ′2 2 I) Its posterior distribution and prior distribution are as follows:

[0107]

[0108]

[0109] W c and b c is the parameter to be learned. During the training phase, Z2 is determined using the posterior distribution. During the use phase, Z2 is determined using the prior distribution.

[0110] By modeling the prior distribution and posterior distribution of the relationship between languages, the problem of inconsistent vocabulary translation can be effectively improved. 2 I), and p3(z3|x, c3)~N(u′3,σ′3 2 I) Its posterior distribution and prior distribution are as follows:

[0111]

[0112]

[0113] W l and b l is the parameter to be learned. c3 consists of two contexts (source and target). During the training phase, Z3 is determined using the posterior distribution. During the usage phase, Z3 is determined using the prior distribution.

[0114] That is to say, during the training process, the original neural network model determines Z1, Z2 and Z3 (corresponding to Figure 7Z1 to Z3 output by the feature extraction layer 702 of the original neural network model. At the same time, use the Target representation that has passed through the Transformer Top Block layer and the Transformer Bottom Block layer as the posterior. That is, input the sample translation result Target Inputs(y) (y < t) in the sample data during the training process into the first encoding layer and the second encoding layer 706, and use the above posterior distribution formula to determine Z1, Z2, and Z3 of Target Inputs (corresponding to Figure 7 Compare the distances of two Z1s, two Z2s, and two Z3s obtained from Z1 to Z3 through the first encoding layer and the second encoding layer 706, that is Figure 7 In the KL(*||*) in, if any one of the distances does not meet the preset threshold, adjust the model parameters in the original neural network, that is, the parameters W and b to be learned above.

[0115] In addition, perform feature aggregation using the representation of the Decoder and the three sampled latent variable information Z1, Z2, and Z3 (Z1, Z2, Z3 sampled from the posterior distribution during the training phase, and Z1, Z2, Z3 sampled from the prior distribution during the test phase), and then decode through Softmax to generate a suitable translation. That is, it is also necessary to decode Z1 to Z3 output by the original neural network model. As Figure 7 In the decoding layer 704 in. During the decoding process, first, when generating the t-th word y t First, encode and learn the historical part y of the Target content using the self-attention mechanism: 1:t-1 H

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

[0117] where y is the word embedding vector representation of y 1:t-1 . The number of y is determined according to the word embedding vector. Then obtain the encoder representation H through another self-attention mechanism x The interactive representation with the content reply representation H y :

[0118] O = FFN(MultiHead(H y , H x , H x ))

[0119] Then merge and represent multiple latent variables through a concatenation operation:

[0120] Z = FFN(z1, z2, z3)

[0121] Finally, perform decoding to generate the final reply: P(yt |y 1:t-1 ;x,z1,z2,z3,θ)=Soft max(W o [O t ,Z]), where W o are the parameters to be learned.

[0122] P is the probability of the predicted word. The word with the highest probability is used as the translation result of the original sentence. After determining the translation result of each translated word of the original sentence, the translation result of the original sentence is obtained. By comparing the predicted sentence and the sample translation result, the above-mentioned learning parameter W is adjusted. o At this point, the original neural network model training is completed and the target neural network model is obtained.

[0123] The MultiHead in the above decoding process can also be replaced by a single-head self-attention mechanism.

[0124] During the use of the target neural network model, the original sentence to be translated and the historical sentences are obtained, and then the first to fourth vectors are obtained. By inputting the first to fourth vectors into the target neural network model, the target neural network model can use the trained feature extraction layer to extract the first to third target vectors. Next, the word embedding vector of each word preceding the currently translated word in the original sentence can be obtained, and the first to third target vectors and the word embedding vector are concatenated into a combined vector. Finally, the combined vector is decoded using the trained decoding layer of the target neural network model to obtain the translation result.

[0125] It should be noted that for the aforementioned method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should be aware that the present invention is not limited by the order of the actions described, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0126] According to another aspect of the embodiments of the present invention, a translation device for implementing the above translation method is also provided. Figure 9 As shown, the device includes:

[0127] A first acquiring unit 902 is configured to acquire, during a conversation between a first subject and a second subject, an original sentence in a first language to be translated currently input by the first subject;

[0128] A second acquiring unit 904 is configured to acquire historical sentences associated with the original sentence, wherein the historical sentences include sentences generated by the first object and sentences generated by the second object during a historical conversation between the first object and the second object;

[0129] An encoding unit 906 is configured to encode the original sentence and the historical sentences to obtain a first target vector, a second target vector, and a third target vector, wherein the first target vector is used to represent the role preference of the first subject, the second target vector is used to represent the order of the historical sentences, and the third target vector is used to represent the content association between the historical sentences;

[0130] a concatenation unit 908, configured to concatenate the first target vector, the second target vector, and the third target vector into a combined vector;

[0131] The decoding unit 910 is configured to decode the combined vector to obtain a translation result in the second language after the original sentence is translated.

[0132] For other examples of this embodiment, please refer to the above examples and will not be repeated here.

[0133] According to another aspect of the embodiment of the present invention, an electronic device for implementing the above translation method is also provided. The electronic device may be Figure 10 The terminal device or server shown in FIG. This embodiment is described by taking the electronic device as a terminal as an example. Figure 10 As shown, the electronic device includes a memory 1002 and a processor 1004. The memory 1002 stores a computer program, and the processor 1004 is configured to execute the steps in any of the above method embodiments through the computer program.

[0134] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.

[0135] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:

[0136] During a conversation between a first object and a second object, obtaining an original sentence in a first language to be translated currently input by the first object;

[0137] Acquire historical sentences associated with the original sentence, wherein the historical sentences include sentences generated by the first object and sentences generated by the second object during a historical conversation between the first object and the second object;

[0138] Encoding the original sentence and the historical sentences to obtain a first target vector, a second target vector, and a third target vector, wherein the first target vector is used to represent the role preference of the first subject, the second target vector is used to represent the order of the historical sentences, and the third target vector is used to represent the content association between the historical sentences;

[0139] splicing the first target vector, the second target vector, and the third target vector into a combined vector;

[0140] The combined vector is decoded to obtain the translation result in the second language after the original sentence is translated.

[0141] Alternatively, those skilled in the art will appreciate that Figure 10 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other terminal devices. Figure 10 It does not limit the structure of the electronic device. For example, the electronic device may also include Figure 10 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 10 Different configurations shown.

[0142] Among them, the memory 1002 can be used to store software programs and modules, such as program instructions / modules corresponding to the translation method and device in the embodiment of the present invention. The processor 1004 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002, that is, realizing the above-mentioned translation method. The memory 1002 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1002 may further include a memory remotely located relative to the processor 1004, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks and combinations thereof. Among them, the memory 1002 can be used specifically, but not limited to, to store information such as original sentences and translation results, historical sentences, etc. As an example, if Figure 10 As shown, the memory 1002 may include, but is not limited to, the first acquisition unit 902, the second acquisition unit 904, the encoding unit 906, the splicing unit 908, and the decoding unit 910 of the translation device. In addition, it may also include, but is not limited to, other modules and units of the translation device, which will not be repeated in this example.

[0143] Optionally, the transmission device 1006 is configured to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 1006 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 1006 is a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.

[0144] In addition, the electronic device further includes: a display 1008 for displaying the original sentence and the translation result; and a connection bus 1010 for connecting the various module components in the electronic device.

[0145] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting multiple nodes through network communication. The nodes may form a peer-to-peer (P2P) network, and any computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.

[0146] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the steps of any of the above method embodiments when run.

[0147] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:

[0148] During a conversation between a first object and a second object, obtaining an original sentence in a first language to be translated currently input by the first object;

[0149] Acquire historical sentences associated with the original sentence, wherein the historical sentences include sentences generated by the first object and sentences generated by the second object during a historical conversation between the first object and the second object;

[0150] Encoding the original sentence and the historical sentences to obtain a first target vector, a second target vector, and a third target vector, wherein the first target vector is used to represent the role preference of the first subject, the second target vector is used to represent the order of the historical sentences, and the third target vector is used to represent the content association between the historical sentences;

[0151] splicing the first target vector, the second target vector, and the third target vector into a combined vector;

[0152] The combined vector is decoded to obtain the translation result in the second language after the original sentence is translated.

[0153] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0154] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.

[0155] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing one or more computer devices (such as personal computers, servers, or network devices) to execute all or part of the steps of the methods of various embodiments of the present invention.

[0156] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0157] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, and can be electrical or other forms.

[0158] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0159] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0160] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A translation method, characterized in that: include: During a conversation between a first object and a second object, obtaining an original sentence in a first language to be translated currently input by the first object; Acquire historical sentences associated with the original sentence, wherein the historical sentences include sentences generated by the first object and sentences generated by the second object during a historical conversation between the first object and the second object; Encoding the original sentence and the historical sentences to obtain a first target vector, a second target vector, and a third target vector, wherein the first target vector is used to represent the role preference of the first subject, the second target vector is used to represent the order of the historical sentences, and the third target vector is used to represent the content association between the historical sentences; splicing the first target vector, the second target vector, and the third target vector into a combined vector; The combined vector is decoded to obtain a translation result in the second language after the original sentence is translated.

2. The method according to claim 1, characterized in that The historical sentences include a first historical sentence in the first language generated by the first object, a second historical sentence in the second language generated by the second object, a first translated sentence of the first historical sentence, and a second translated sentence of the second historical sentence, wherein the first translated sentence is a sentence in the second language, and the second translated sentence is a sentence in the first language. The encoding of the original sentence and the historical sentences to obtain a first target vector, a second target vector, and a third target vector includes: Obtaining a first sentence, a second sentence, a third sentence, and a fourth sentence, wherein the first sentence is the first historical sentence, the second sentence is the first historical sentence and the second translated sentence, the third sentence is the historical sentence, and the fourth sentence is the original sentence; Obtain a first vector, a second vector, a third vector, and a fourth vector, wherein the first vector is a low-dimensional vector obtained by mapping the first statement, the second vector is a low-dimensional vector obtained by mapping the second statement, the third vector is a low-dimensional vector obtained by mapping the third statement, and the fourth vector is a low-dimensional vector obtained by mapping the fourth statement; The first vector is encoded as the first target vector, the second vector and the fourth vector are encoded as the second target vector, and the third vector is encoded as the third target vector.

3. The method according to claim 2, characterized in that The encoding of the first vector into the first target vector, encoding the second vector and the fourth vector into the second target vector, and encoding the third vector into the third target vector comprises: encoding the first vector into the first target vector and encoding the third vector into the third target vector using a first encoding layer; The second vector and the fourth vector are encoded into a first intermediate vector and a second intermediate vector using the first coding layer, the second intermediate vector is encoded into a result vector using the second coding layer, and the first intermediate vector and the result vector are combined into the second target vector, wherein the first coding layer includes one coding layer and the second coding layer includes five coding layers.

4. The method according to claim 1, wherein The splicing the first target vector, the second target vector, and the third target vector into a combined vector includes: In a case where the original sentence includes an encoding vector, the first target vector, the second target vector, the third target vector, and the encoding vector are concatenated into the combined vector, wherein the encoding vector is a word embedding vector of each word before any word in the original sentence when translating any word after the first word of the original sentence.

5. The method according to claim 1, wherein The encoding of the original sentence and the historical sentence to obtain the first target vector, the second target vector, and the third target vector comprises: inputting the historical sentence into a target neural network model, and extracting the first target vector, the second target vector, and the third target vector by a feature extraction layer of the target neural network model; Decoding the combined vector to obtain a translation result in the second language after translating the original sentence includes: determining a result obtained by decoding the combined vector using a decoding layer of the target neural network model as the translation result, wherein the target neural network model is a pre-trained model, and the feature extraction layer and the decoding layer include target parameters after training the original parameters.

6. The method according to claim 5, characterized in that Before inputting the historical sentences into the target neural network model and extracting the first target vector, the second target vector, and the third target vector by the feature extraction layer of the target neural network model, the method further includes: Acquire an original neural network model, wherein the original neural network model includes the feature extraction layer and the decoding layer, and the feature extraction layer and the decoding layer include the original parameters; Obtaining a sample original sentence, a sample translation result, and sample historical sentences of the sample original sentence, wherein the sample original sentence is a sentence in the first language generated by a third object, the sample translation result is a sentence in the second language obtained by translating the sample original sentence, and the sample historical sentences include a first sample historical sentence in the first language generated by the third object during a conversation between the third object and a fourth object, a second sample historical sentence in the second language generated by the fourth object, a first sample translated sentence of the first sample historical sentence, and a second sample translated sentence of the second sample historical sentence, the first sample translated sentence is a sentence in the second language, and the second sample translated sentence is a sentence in the first language; The original parameters of the original neural network model are trained using the sample original sentences, the sample translation results, and the sample historical sentences to obtain the target neural network model.

7. The method according to claim 6, characterized in that The using the sample original sentence, the sample translation result and the sample historical sentence to train the original parameters of the original neural network model to obtain the target neural network model includes: Perform the following operations on the original neural network model until the recognition accuracy of the original neural network model is greater than a first threshold, so as to obtain the target neural network model: Inputting the sample translation result into the feature extraction layer to obtain a first target sample vector, a second target sample vector, and a third target sample vector; Inputting the sample original sentence into the feature extraction layer to obtain a first original sample vector, a second original sample vector, and a third original sample vector; Merging the first original sample vector, the second original sample vector, the third original sample vector, and the sample encoding vector of the sample original sentence into a sample combination vector, wherein the sample encoding vector is a word embedding vector of each word before any word in the sample original sentence when translating any word after the first word of the sample original sentence; Decoding the sample combination vector using the decoding layer to obtain an estimated sentence; When the difference between the first target sample vector and the first original sample vector is greater than a first threshold, or the difference between the second target sample vector and the second original sample vector is greater than a second threshold, or the difference between the third target sample vector and the third original sample vector is greater than a third threshold, or the difference between the sample original statement and the estimated statement is greater than a fourth threshold, adjust the value of the original parameter.

8. A translation device, characterized in that: include: A first acquiring unit is configured to acquire, during a conversation between a first object and a second object, an original sentence in a first language to be translated currently input by the first object; a second acquiring unit, configured to acquire historical sentences associated with the original sentence, wherein the historical sentences include sentences generated by the first object and sentences generated by the second object during a historical conversation between the first object and the second object; an encoding unit, configured to encode the original sentence and the historical sentence to obtain a first target vector, a second target vector, and a third target vector, wherein the first target vector is used to represent the role preference of the first subject, the second target vector is used to represent the order of the historical sentences, and the third target vector is used to represent the content association between the historical sentences; a splicing unit, configured to splice the first target vector, the second target vector, and the third target vector into a combined vector; A decoding unit is used to decode the combined vector to obtain a translation result in the second language after the original sentence is translated.

9. The device according to claim 8, characterized in that The historical sentences include a first historical sentence in the first language generated by the first object, a second historical sentence in the second language generated by the second object, a first translated sentence of the first historical sentence, and a second translated sentence of the second historical sentence, wherein the first translated sentence is a sentence in the second language, and the second translated sentence is a sentence in the first language. The encoding unit includes: A first acquisition module is configured to acquire a first sentence, a second sentence, a third sentence, and a fourth sentence, wherein the first sentence is the first historical sentence, the second sentence is the first historical sentence and the second translated sentence, the third sentence is the historical sentence, and the fourth sentence is the original sentence; a second acquisition module, configured to acquire a first vector, a second vector, a third vector, and a fourth vector, wherein the first vector is a low-dimensional vector obtained by mapping the first statement, the second vector is a low-dimensional vector obtained by mapping the second statement, the third vector is a low-dimensional vector obtained by mapping the third statement, and the fourth vector is a low-dimensional vector obtained by mapping the fourth statement; An encoding module is used to encode the first vector into the first target vector, encode the second vector and the fourth vector into the second target vector, and encode the third vector into the third target vector.

10. The device according to claim 9, characterized in that The encoding module includes: a first encoding module, configured to encode the first vector into the first target vector and the third vector into the third target vector using a first encoding layer; A second encoding module is used to encode the second vector and the fourth vector into a first intermediate vector and a second intermediate vector using the first encoding layer, encode the second intermediate vector into a result vector using the second encoding layer, and combine the first intermediate vector and the result vector into the second target vector, wherein the first encoding layer includes one encoding layer and the second encoding layer includes five encoding layers.

11. The device according to claim 8, characterized in that The encoding unit includes: a third encoding module, configured to input the historical sentence into a target neural network model, and extract the first target vector, the second target vector, and the third target vector by a feature extraction layer of the target neural network model; The decoding unit includes: a decoding module, used to determine a result obtained by decoding the combined vector using a decoding layer of the target neural network model as the translation result, wherein the target neural network model is a pre-trained model, and the feature extraction layer and the decoding layer include target parameters after training the original parameters.

12. The device according to claim 11, characterized in that The device further comprises: a third acquisition unit, configured to acquire an original neural network model before inputting the historical sentence into the target neural network model and extracting the first target vector, the second target vector, and the third target vector by the feature extraction layer of the target neural network model, wherein the original neural network model includes the feature extraction layer and the decoding layer, and the feature extraction layer and the decoding layer include the original parameters; a fourth acquisition unit, configured to acquire a sample original sentence, a sample translation result, and a sample history sentence of the sample original sentence, wherein the sample original sentence is a sentence in the first language generated by a third object, the sample translation result is a sentence in the second language translated from the sample original sentence, and the sample history sentence includes a first sample history sentence in the first language generated by the third object during a conversation between the third object and the fourth object, a second sample history sentence in the second language generated by the fourth object, a first sample translated sentence of the first sample history sentence, and a second sample translated sentence of the second sample history sentence, the first sample translated sentence is a sentence in the second language, and the second sample translated sentence is a sentence in the first language; A training unit is used to train the original parameters of the original neural network model using the sample original sentence, the sample translation result and the sample historical sentence to obtain the target neural network model.

13. The device according to claim 12, characterized in that The training unit comprises: A processing module is configured to perform the following operations on the original neural network model until the recognition accuracy of the original neural network model is greater than a first threshold, so as to obtain the target neural network model: Inputting the sample translation result into the feature extraction layer to obtain a first target sample vector, a second target sample vector, and a third target sample vector; Inputting the sample original sentence into the feature extraction layer to obtain a first original sample vector, a second original sample vector, and a third original sample vector; Merging the first original sample vector, the second original sample vector, the third original sample vector, and the sample encoding vector of the sample original sentence into a sample combination vector, wherein the sample encoding vector is a word embedding vector of each word before any word in the sample original sentence when translating any word after the first word of the sample original sentence; The sample combination vector is decoded using the decoding layer to obtain an estimated sentence; when the difference between the first target sample vector and the first original sample vector is greater than a first threshold, or the difference between the second target sample vector and the second original sample vector is greater than a second threshold, or the difference between the third target sample vector and the third original sample vector is greater than a third threshold, or the difference between the sample original sentence and the estimated sentence is greater than a fourth threshold, the value of the original parameter is adjusted.

14. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed, the method according to any one of claims 1 to 7 is executed.

15. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.

Citation Information

Patent Citations

  • Machine translation method and apparatus based on RNN model

    CN105183720A

  • Machine translation method and apparatus

    CN108304388A