Machine translation method and apparatus, device, medium, product
By using a machine translation model to input the original text and the pseudo-pinyin text in parallel, and combining probability distribution analysis and secondary translation, the translation anomaly caused by homonym errors was solved, achieving efficient and accurate Chinese-to-English translation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU HUANJU SHIDAI INFORMATION TECH CO LTD
- Filing Date
- 2022-07-21
- Publication Date
- 2026-05-19
AI Technical Summary
Existing machine translation technologies often result in abnormal translations when translating Chinese into English due to homophone errors caused by Pinyin input methods. Furthermore, traditional error correction translation methods are time-consuming and involve a large amount of ineffective computation.
A machine translation model is used to input the original text and the pseudo-pinyin text in parallel. The initial translation obtains a foreign language vector sequence. Anomaly vectors are identified through probability distribution analysis. If necessary, a second translation is performed by combining the original text and the standard pinyin text. Semantic reasoning is performed by using the similarity of homophones linked by pinyin to achieve error-correcting translation.
It improves the error tolerance of translation, reduces the amount of computation, shortens the translation time, and achieves error correction translation with only a single model, thereby reducing costs and improving translation accuracy.
Smart Images

Figure CN115186684B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of machine translation, and in particular, to a machine translation method, its corresponding device, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] Machine translation refers to the technology of translating text expressed in one natural language into text expressed in another natural language by a computer program.
[0003] With the advancement of the economic globalization process, the cross-border characteristics of e-commerce platforms have become increasingly obvious. Machine translation technology is often applied in the e-commerce field to achieve automatic translation of product information, and among them, translating Chinese (Chinese characters) into foreign languages is a high-frequency requirement.
[0004] Taking the translation from Chinese to English as an example, in the process of Chinese-English translation, business users often use pinyin input method to enter Chinese. There are a large number of homophones in Chinese, which will cause the entered text to contain incorrect words with similar pronunciations to the correct Chinese words, directly resulting in abnormal translation of the machine translation model. For example, when the user enters "This cedar looks great" instead of the correct expression "This button-down shirt looks nice" because of the input error. Such situations are relatively common in the e-commerce field, resulting in the inability to obtain accurate translation results.
[0005] To overcome the above problems, traditionally, deep learning methods such as BERT are usually adopted. First, the text is corrected and rewritten through a deep learning model into correct Chinese, and then translated into English. Such technologies require serial inference relying on two models to achieve error correction first and then translation, which takes a long time and has a large amount of ineffective calculations. For example, for about 10% of the abnormal Chinese in actual proportion, 90% of the operations in the error correction process are ineffective calculations.
[0006] In view of this, the applicant of this application has explored other implementation ways of machine translation for Chinese and proposed this application. Summary of the Invention
[0007] The purpose of this application is to solve the above problems and provide a machine translation method, its corresponding device, computer equipment, computer-readable storage medium, computer program product.
[0008] To meet the various purposes of this application, the following technical solutions are adopted:
[0009] On the one hand, to meet one of the purposes of this application, a machine translation method is provided, including:
[0010] Obtain the original text to be translated, wherein the original text is in Chinese characters;
[0011] The original text and the pinyin text set to false are input into the machine translation model in parallel for translation to obtain the first foreign language vector sequence, where each foreign language vector represents the probability distribution corresponding to each word segment in the preset foreign language vocabulary;
[0012] If there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is determined to be a valid vector sequence; otherwise, the original text and its standard pinyin text are input into the machine translation model in parallel for translation to obtain the second foreign language vector sequence as a valid vector sequence.
[0013] Based on the valid vector sequence, the foreign language vocabulary is queried to determine the corresponding word segment for each foreign language vector, and a foreign language text corresponding to the original text is constructed.
[0014] Optionally, when there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is determined to be a valid vector sequence, including:
[0015] The maximum classification probability of each foreign language vector in the first foreign language vector sequence is determined to be lower than a preset threshold. When the maximum classification probability of at least one foreign language vector is lower than the preset threshold, it is determined that the corresponding foreign language vector has an abnormal probability distribution.
[0016] When it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is regarded as a valid vector sequence.
[0017] Optionally, when there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is determined to be a valid vector sequence, including:
[0018] The system sequentially determines whether each foreign language vector in the first foreign language vector sequence satisfies the probability distribution statistically determined during the training of the machine translation model. If it does not satisfy the probability distribution, the corresponding foreign language vector is determined to have an abnormal probability distribution.
[0019] When it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is regarded as a valid vector sequence.
[0020] Optionally, the step of inputting the original text and the pinyin text set to false values into the machine translation model in parallel for translation to obtain a first foreign language vector sequence, or the step of inputting the original text and its standard pinyin text into the machine translation model in parallel for translation to obtain a second foreign language vector sequence as a valid vector sequence, includes:
[0021] The original text is input into the Chinese encoder of the machine translation model to extract features and obtain Chinese vectors.
[0022] Input the pinyin text into the pinyin encoder of the machine translation model to extract features and obtain pinyin vectors;
[0023] A comprehensive vector is constructed based on the Chinese language vector and the Pinyin vector;
[0024] The integrated vector is input into the decoder of the machine translation model for autoregressive decoding to obtain the corresponding foreign language vector sequence.
[0025] Optionally, before inputting the source text and the pinyin text set to false into the machine translation model in parallel for translation, the following steps are included:
[0026] Construct a parallel corpus, which includes multiple parallel corpora. Each parallel corpus includes an original text expressed in Chinese characters and a foreign text expressed in a preset target language. The foreign text is a translation of the original text. Some of the original texts in the parallel corpora contain homophones.
[0027] The machine translation model is trained by iteratively calling the original text and the corresponding standard pinyin text in each parallel corpus of the parallel corpus as the first sample to obtain the corresponding foreign language vector sequence. The foreign language text in the same parallel corpus is used as the label for supervised training to train the machine translation model to a convergent state.
[0028] The original text and the pinyin text set to false values in each parallel corpus of the parallel corpus are iteratively called as the second samples to train the machine translation model and obtain the corresponding foreign language vector sequence. The foreign language text in the same parallel corpus is used as the label for supervised training to train the machine translation model to a convergent state.
[0029] Optionally, construct parallel corpora, including:
[0030] Accurately expressed parallel texts are collected and stored in a parallel corpus. The parallel texts include original texts accurately expressed in Chinese characters and foreign texts accurately expressed in a preset target language. The foreign texts are translations of the original texts.
[0031] Extract a portion of accurately expressed parallel text from a parallel corpus, and segment the original text within it to obtain the segmentation results;
[0032] Randomly select some words from the word segmentation results of the original text and replace them with homophones;
[0033] Parallel texts in which the original text has been replaced with homophones or misspellings are added to the parallel corpus.
[0034] Optionally, based on the valid vector sequence, the foreign language vocabulary is queried to determine the corresponding word segments for each foreign language vector, and a foreign language text corresponding to the original text is constructed, including:
[0035] For each foreign language vector in the effective vector sequence, determine the probability distribution of its mapping to each word segment in the foreign language vocabulary, and take the word segment corresponding to the highest classification probability as the target word corresponding to the foreign language vector.
[0036] According to the order of the foreign language vectors in the effective vector sequence, the target word segments corresponding to each foreign language vector are concatenated in an orderly manner to obtain the foreign language text corresponding to the original text.
[0037] On the other hand, to suit one of the purposes of this application, a machine translation device is provided, including a source text acquisition module, a default translation module, a supplementary translation module, and a foreign language construction module. The source text acquisition module is used to acquire the source text to be translated, wherein the source text is in Chinese. The default translation module is used to input the source text and the pinyin text set to false values into a machine translation model in parallel for translation, obtaining a first foreign language vector sequence, wherein each foreign language vector represents the probability distribution corresponding to each word segment in a preset foreign language vocabulary. The supplementary translation module is used to determine the first foreign language vector sequence as a valid vector sequence when there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence; otherwise, it inputs the source text and its standard pinyin text into the machine translation model in parallel for translation, obtaining a second foreign language vector sequence as a valid vector sequence. The foreign language construction module is used to query the foreign language vocabulary based on the valid vector sequence to determine the corresponding word segments of each foreign language vector, constructing a foreign language text corresponding to the source text.
[0038] Optionally, the supplementary translation module includes: a probability analysis unit, used to sequentially determine whether the maximum classification probability of each foreign language vector in the first foreign language vector sequence is lower than a preset threshold, and when the maximum classification probability of at least one of the foreign language vectors is lower than the preset threshold, it is determined that the corresponding foreign language vector has an abnormal probability distribution; and an output processing unit, used to treat the first foreign language vector sequence as a valid vector sequence when it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence.
[0039] Optionally, the supplementary translation module includes: a distribution analysis unit, used to sequentially determine whether each foreign language vector in the first foreign language vector sequence satisfies the probability distribution statistically determined during the training of the machine translation model; when it does not satisfy the probability distribution, it determines that the corresponding foreign language vector has an abnormal probability distribution; and an output processing unit, used to treat the first foreign language vector sequence as a valid vector sequence when it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence.
[0040] Optionally, the default translation module, or the supplementary translation module, includes: a Chinese encoding unit, used to input the source text into the Chinese encoder of the machine translation model to extract features and obtain Chinese vectors; a Pinyin encoding unit, used to input Pinyin text into the Pinyin encoder of the machine translation model to extract features and obtain Pinyin vectors; a vector synthesis unit, used to construct a synthesis vector based on the Chinese vectors and the Pinyin vectors; and a decoding output unit, used to input the synthesis vector into the decoder of the machine translation model for autoregressive decoding to obtain the corresponding foreign language vector sequence.
[0041] Optionally, prior to the default translation module, the system includes: a corpus building module for constructing parallel corpora, wherein the parallel corpora include multiple parallel corpora, each parallel corpus including original text expressed in Chinese characters and foreign text expressed in a preset target language, wherein the foreign text is a translated version of the original text, and some parallel corpora contain homophones; a first training module for iteratively calling the original text and the corresponding standard pinyin text in each parallel corpus as first samples to train the machine translation model and obtain the corresponding foreign text vector sequence, using the foreign text in the same parallel corpus as the label for supervised training, and training the machine translation model to a convergent state; and a second training module for iteratively calling the original text and the pinyin text set to false values in each parallel corpus as second samples to train the machine translation model and obtain the corresponding foreign text vector sequence, using the foreign text in the same parallel corpus as the label for supervised training, and training the machine translation model to a convergent state.
[0042] Optionally, the corpus building module includes: a preliminary acquisition unit, used to acquire accurately expressed parallel corpora and store them in a parallel corpus, wherein the parallel corpora include original text accurately expressed in Chinese characters and foreign text accurately expressed in a preset target language, wherein the foreign text is a translation of the original text; a word extraction and segmentation unit, used to extract a portion of accurately expressed parallel corpora from the parallel corpus and segment the original text therein to obtain word segmentation results; a homophone replacement unit, used to randomly select a portion of the segmented words in the word segmentation results of the original text and replace them with homophones; and a replacement append unit, used to append the parallel corpora in which the original texts have been replaced with homophones to the parallel corpus.
[0043] Optionally, the foreign language construction module includes: a word segmentation query unit, used to determine the probability distribution of each foreign language vector in the effective vector sequence as mapped to each word in the foreign language vocabulary, and the word corresponding to the highest classification probability is used as the target word corresponding to the foreign language vector; and a foreign language concatenation unit, used to concatenate the target words corresponding to each foreign language vector in an orderly manner according to the arrangement order of the foreign language vectors in the effective vector sequence to obtain the foreign language text corresponding to the original text.
[0044] In another aspect, a computer device provided for one of the purposes of this application includes a central processing unit and a memory, the central processing unit being used to invoke and run a computer program stored in the memory to perform the steps of the machine translation method described in this application.
[0045] In another aspect, a computer-readable storage medium is provided to suit another purpose of this application, which stores, in the form of computer-readable instructions, a computer program implemented according to the machine translation method, which, when invoked by a computer, performs the steps included in the method.
[0046] In another aspect, a computer program product provided for another purpose of this application includes a computer program / instructions that, when executed by a processor, implement the steps of the machine translation method described in any embodiment of this application.
[0047] Compared with existing technologies, this application has several advantages, including but not limited to:
[0048] First, this application targets the original text represented in Chinese characters. It first inputs the Pinyin text (set to falsity) into the machine translation model for initial translation, obtaining a first foreign language vector sequence. By default, this first foreign language vector sequence can be used as a valid vector sequence to determine the foreign language text. However, if the first foreign language vector sequence contains foreign language vectors with abnormal probability distributions, it indicates the presence of misspelled words. Therefore, it further inputs the original text and its standard Pinyin text together into the machine translation model for a second translation, obtaining a second foreign language vector sequence as a valid vector sequence. Finally, the foreign language text is determined based on the valid vector sequence. In this process, the Pinyin text acts as a link between the original word and the misspelled word in the same phrase. This allows two originally unrelated words to be mapped to similar Pinyin encoding spaces through the connection of Pinyin. Utilizing this similarity, effective semantic reasoning can be performed, thus achieving translation error tolerance.
[0049] Secondly, given that most original texts in practice are accurate, in most cases, a single translation by the machine translation model is sufficient to obtain the foreign text. However, a small number of original texts may contain misspelled words. In such cases, by analyzing the probability distribution of foreign text vectors in the first foreign text vector sequence, it can be quickly determined whether a second translation is needed for error correction. When error correction is required, the input is further modified by replacing the pinyin text set as false with the standard pinyin text. This is then input into the same machine translation model again with the corresponding original text for a second translation. The machine translation model, referencing the original text and its pinyin, more accurately predicts the corresponding foreign text. This not only improves the error tolerance in the translation process but also allows for the translation of homophones and polyphonic characters, while significantly reducing computational waste. A balance is struck between the computational efficiency sacrificed for error tolerance and the acquisition of accurate translation results, effectively reducing the translation time required to obtain accurate translation results.
[0050] Furthermore, although this application has an error correction translation mechanism, error correction translation can be achieved by calling the same machine translation model twice. There is no need to use two different models to implement error correction inference. Only a single model needs to be prepared, which results in low implementation cost and high implementation efficiency. Attached Figure Description
[0051] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0052] Figure 1 This is a schematic diagram of the network architecture of the machine translation model used in this application.
[0053] Figure 2 This is a flowchart illustrating one embodiment of the machine translation method of this application.
[0054] Figure 3 This is a schematic diagram illustrating the workflow of the machine translation model used in this application.
[0055] Figure 4 This is a schematic diagram illustrating the training process of the machine translation model used in this application.
[0056] Figure 5 This is a schematic diagram illustrating the construction process of a parallel corpus for the machine translation model exemplified in this application.
[0057] Figure 6 This is a schematic diagram of the machine translation device of this application.
[0058] Figure 7 This is a schematic diagram of the structure of a computer device used in this application. Detailed Implementation
[0059] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0060] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.
[0061] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0062] Those skilled in the art will understand that the terms "client," "terminal," and "terminal device" as used herein include both devices that receive wireless signals, devices that only possess wireless signal receiver capabilities without transmission capabilities, and devices with receiving and transmitting hardware, devices that have receiving and transmitting hardware capable of bidirectional communication over a bidirectional communication link. Such devices may include: cellular or other communication devices such as personal computers or tablets, having single-line displays, multi-line displays, or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service) that can combine voice, data processing, fax, and / or data communication capabilities; PDA (Personal Digital Assistant) that may include a radio frequency receiver, pager, internet / intranet access, web browser, notepad, calendar, and / or GPS (Global Positioning System) receiver; and conventional laptops and / or handheld computers or other devices that have and / or include radio frequency receivers. As used herein, "client," "terminal," and "terminal device" can be portable, transportable, installed in a means of transportation (air, sea, and / or land), or suitable and / or configured to operate locally and / or in a distributed manner, operating in any other location on Earth and / or in space. "Client," "terminal," and "terminal device" as used herein can also be a communication terminal, an internet access terminal, or a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or a smart TV, set-top box, etc.
[0063] The hardware referred to by the names "server," "client," and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann architecture, such as a central processing unit (including an arithmetic logic unit and a control unit), memory, input devices, and output devices. The computer program is stored in its memory, and the central processing unit loads the program stored in the secondary storage into the main memory to run it, execute the instructions in the program, and interact with the input and output devices to complete specific functions.
[0064] It should be noted that the concept of "server" used in this application can also be extended to the case of server clusters. Based on the network deployment principles understood by those skilled in the art, the servers should be logically divided. Physically, these servers can be independent of each other but accessible through interfaces, or they can be integrated into a single physical computer or a computer cluster. Those skilled in the art should understand this flexibility and should not use it to constrain the implementation of the network deployment method in this application.
[0065] One or more of the technical features of this application, unless explicitly specified herein, can be deployed on a server and accessed by a client remotely calling the online service interface provided by the server, or can be directly deployed and run on a client for access.
[0066] Unless otherwise specified, the neural network models referenced or potentially referenced in this application may be deployed on a remote server and invoked remotely on the client, or deployed on a client with the capability to invoke directly. In some embodiments, when running on the client, the corresponding intelligence may be acquired through transfer learning in order to reduce the requirements on the client's hardware resources and avoid excessive consumption of the client's hardware resources.
[0067] Unless otherwise specified, all data involved in this application may be stored remotely on a server or on a local terminal device, as long as it is suitable for use by the technical solution of this application.
[0068] Those skilled in the art will understand that although the various methods in this application are described based on the same concept and thus present commonality among them, they can be performed independently unless otherwise specified. Similarly, the various embodiments disclosed in this application are all based on the same inventive concept; therefore, concepts expressed in the same way, as well as concepts that are appropriately changed for convenience but are expressed differently, should be understood equivalently.
[0069] Unless otherwise expressly stated, the various embodiments disclosed in this application can be combined in a cross-cutting manner to flexibly construct new embodiments, as long as such combination does not depart from the inventive spirit of this application and can meet the needs of the prior art or solve a certain deficiency in the prior art. Those skilled in the art should be aware of such modifications.
[0070] One machine translation method of this application can be programmed into a computer program product and deployed on a client or server for implementation. For example, in an exemplary application scenario of this application, it can be deployed on the server of an e-commerce platform.
[0071] Please see Figure 1 The machine translation method of this application, as shown, employs a network architecture based on a recurrent neural network (RNN). This model includes two encoders and one decoder, both using RNNs. The two encoders serve as a Chinese encoder and a Pinyin encoder, respectively. The Chinese encoder extracts deep semantic information from the original text expressed in Chinese to obtain corresponding Chinese vectors. The Pinyin encoder extracts deep semantic information from the Pinyin text to obtain corresponding Pinyin vectors. According to the embodiments disclosed later in this application, the Pinyin text can be either Pinyin text composed of standard Pinyin corresponding to the original text or Pinyin text represented by falsified values. These falsified values are dummy values provided to prevent the Pinyin encoder from generating valid Pinyin vectors. For example, in one embodiment, the value 0 can be used, corresponding to the input required by the Pinyin encoder, encoded into an all-zero input vector, and input into the Pinyin encoder, so that the Pinyin encoder ultimately generates an all-zero Pinyin vector. Of course, in other embodiments, the falsified value can also be other uniform values, such as other numerical values, but it does not provide standard and valid pinyin information. Therefore, pinyin text represented by falsified values is not real pinyin text, but rather forged pinyin text, fundamentally different from the pinyin text composed of the true standard pinyin of the original text.
[0072] The decoder employs an autoregressive mechanism, which progressively decodes the input vector sequence to obtain each foreign language vector. The previously output foreign language vector is appended to its input side by the autoregressive mechanism to continue decoding subsequent foreign language vectors, ultimately obtaining a foreign language vector sequence that can be used to determine the foreign language text.
[0073] According to the network architecture of the machine translation model of this application, in one embodiment, the encoders and decoders can be constructed based on a Long Short-Time Memory (LSTM) network; in another embodiment, Transformer and Bart can be used as prototypes, with two instances of the encoders contained in such prototypes serving as the Chinese encoder and the Pinyin encoder, and the decoders contained in such prototypes serving as the decoders of the machine translation model. Since these prototypes all apply attention layers, they can refer to the context of the input information and predict the output sequentially, thus obtaining more accurate decoding results.
[0074] The machine translation model described herein can be pre-trained to a convergent state using sufficient data samples corresponding to the machine translation task, enabling it to learn the ability to translate effective foreign text based on given source text and pinyin text, and then applied to the online inference stage of this application to provide translation services for source text.
[0075] Please see Figure 2 The machine translation method of this application, in its typical embodiment, includes the following steps:
[0076] Step S2100: Obtain the original text to be translated, wherein the original text is in Chinese language;
[0077] The machine translation method of this application has a very wide range of applications. It can be used in any scenario involving translating Chinese text into a foreign language that is the target language of the machine translation model. For example, it can be applied to real-time communication between merchants and buyers in cross-border e-commerce, as well as to Chinese product titles and descriptions in cross-border e-commerce. Furthermore, it can be extended to any other scenario requiring Chinese-to-foreign language translation.
[0078] The method for obtaining the source text to be translated varies depending on the scenario. For example, in an online customer service scenario, the chat history entered in Chinese by the first user in the customer service system's chat interface can serve as the source text to be translated, so that the corresponding foreign language text can be displayed in the chat interface of the second user chatting with the first user. As another example, in a scenario where a merchant user edits a product page, the merchant user can directly enter product information expressed in Chinese, including product titles and product details, and submit it to the server. The server then uses the method described in this application to translate the source text of various product information into a foreign language. Furthermore, on a product search page, the source text entered by the user in Chinese is translated into a foreign language by the server, and the search results are returned to the user for viewing. In all these cases, the source text to be translated can be obtained.
[0079] In this application, the original text specifically refers to Chinese characters suitable for representation using pinyin. Since Chinese characters contain a large number of homophones and homonyms, the method of this application is more suitable for translation and can obtain accurate and effective translation results.
[0080] The language of the foreign text referred to in this application is determined based on the corresponding supervision labels in the parallel corpus used during the training phase of the machine translation model. Typically, a single supervision label corresponding to a single foreign language is used to train the machine translation model, enabling it to learn the ability to translate the source text into the corresponding foreign language text. The foreign language can be any language other than the language of the source text, i.e., Chinese, such as English, Spanish, French, Arabic, Japanese, etc. Furthermore, the source language and the foreign language can even be Simplified Chinese and Traditional Chinese respectively, depending on the parallel corpus used for training the machine translation model.
[0081] Step S2200: Input the original text and the pinyin text set to false values into the machine translation model in parallel for translation to obtain the first foreign language vector sequence, wherein each foreign language vector represents the probability distribution corresponding to each word segment in the preset foreign language vocabulary;
[0082] In this step, a machine translation model that has been pre-trained to convergence is invoked to perform the first translation of the original text to obtain the corresponding first foreign language vector sequence.
[0083] As mentioned above, the machine translation model of this application includes a Chinese encoder and a Pinyin encoder, which are used to extract deep semantic information corresponding to the source text and the Pinyin text, respectively. For this purpose, the source text and the Pinyin text can be input into the Chinese encoder and the Pinyin encoder in parallel.
[0084] When inputting the source text into the Chinese encoder of the machine translation model, word embedding is usually performed on the source text by referring to the source text vocabulary corresponding to the language of the source text, so as to obtain the vector sequence representation of the source text. The vector sequence is then input into the Chinese encoder, which performs feature extraction operation on the vector sequence to obtain the corresponding Chinese vector.
[0085] When providing pinyin text to the pinyin encoder of the machine translation model, in the first translation, the pinyin text input to the pinyin encoder in this application is not the pinyin text composed of the standard pinyin of the original text, but a forged pinyin text, which is similarly represented as a vector sequence. However, as mentioned above, each feature value of this vector sequence is set to a false value, such as 0. Since the pinyin encoder constructed based on the recurrent neural network includes multiplication operations when performing operations based on its input vector sequence, taking advantage of this feature, although the pinyin encoder will work normally and eventually generate a pinyin vector, the feature values in this pinyin vector will be significantly different from the feature values corresponding to the standard pinyin text, thus realizing the representation of pinyin text that is not input as the standard pinyin text for the original text.
[0086] After obtaining Chinese and Pinyin vectors through the Chinese encoder and Pinyin encoder respectively, the two vectors can be concatenated to obtain a comprehensive vector. This comprehensive vector contains both the deep semantic features of the original text and the deep semantic features of the Pinyin text set to false values. Of course, the deep semantic features of the Pinyin text are invalid features at this time.
[0087] Then, the decoder of the machine translation model uses the comprehensive vector as a prefix to perform autoregressive decoding step by step. Specifically, the decoder first predicts a foreign language vector corresponding to a foreign language based on the prefix, then appends the foreign language vector to the prefix, and continues to decode and predict the next foreign language vector based on the updated prefix, and so on, until all foreign language vectors are generated, forming the first foreign language vector sequence.
[0088] The aforementioned foreign language vector is a probability distribution containing the classification probabilities corresponding to each word in a preset foreign language vocabulary. From another perspective, the classification probability of a word in the foreign language vocabulary also represents the confidence level of that word becoming the target word of the foreign language vector. Theoretically, the word corresponding to the highest classification probability in the foreign language vector is the target word pointed to by that foreign language vector. However, considering the possibility of homophones in the original text, further judgment is needed to determine whether the first foreign language vector sequence is suitable as a valid vector sequence for determining the corresponding foreign language text of the original text.
[0089] It is easy to see that in the initial translation process, the pinyin text provided in parallel with the original text is pinyin text with a false value. When the false value is set to 0, the calculation of the pinyin encoder and even the decoder can be greatly simplified, that is, the amount of calculation of the entire machine translation model is reduced, thereby improving the calculation efficiency of the machine translation model and shortening the translation time.
[0090] Step S2300: When there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is determined to be a valid vector sequence; otherwise, the original text and its standard pinyin text are input into the machine translation model in parallel for translation to obtain the second foreign language vector sequence as a valid vector sequence.
[0091] The first foreign language vector sequence obtained from the initial translation theoretically corresponds to the word segment in the foreign language vocabulary with the highest classification probability in the foreign language vector, which is the target word segment corresponding to the foreign language vector. However, when all classification probabilities in the foreign language vector are generally low, it means that the confidence level obtained by each word segment in the foreign language vocabulary is not high, indicating that the machine translation model cannot effectively determine the target word segment corresponding to the foreign language vector. In this case, the probability distribution of the foreign language vector can be considered abnormal.
[0092] Alternatively, if the probability distribution of the foreign text vector does not conform to general statistical characteristics, such as not conforming to the Raida criterion (also known as the 3-Sigma criterion) obtained by the machine model during the training phase, then the foreign text vector can also be considered to have an abnormal probability distribution.
[0093] If more than one foreign text vector in the first foreign text vector sequence has an abnormal probability distribution, it can be assumed that the original text may contain homophones or other similar misspellings or typos. Therefore, it is necessary to continue calling the machine translation model to perform a second translation.
[0094] When none of the foreign language vectors in the first foreign language vector sequence exhibit abnormal probability distribution, it can be assumed that there are no homophones or other similar misspellings or typos in the original text. The first foreign language vector sequence is valid and can be used as a valid vector sequence to determine the foreign language text.
[0095] The above two methods for identifying probability distribution anomalies can be used individually or in combination without affecting the inventive spirit of this application. To adapt to these two methods, the following two embodiments can be adopted:
[0096] In one embodiment, the determination of whether there are foreign text vectors with abnormal probability distributions in the first foreign text vector sequence is based on whether the maximum classification probability in the foreign text vector is lower than a preset threshold includes the following steps:
[0097] Step S2311: Sequentially determine whether the maximum classification probability of each foreign language vector in the first foreign language vector sequence is lower than a preset threshold. When the maximum classification probability of at least one foreign language vector is lower than the preset threshold, it is determined that the corresponding foreign language vector has an abnormal probability distribution.
[0098] A loop execution body is set up to read each foreign language vector in the first foreign language vector sequence in sequence and judge it. In each loop, for the corresponding foreign language vector, it is judged whether the maximum classification probability is lower than a preset threshold. The preset threshold can be an empirical threshold, which is generally a value lower than the median of the confidence interval of the probability distribution. For example, if the confidence interval is [0,1], the empirical threshold can be set to 0.5. Of course, it is also advisable to adjust the empirical threshold appropriately. Those skilled in the art can set it flexibly.
[0099] If, during a single loop iteration, the maximum classification probability of the current foreign text vector is found to be below a preset threshold, it indicates an abnormal probability distribution in the foreign text vector, meaning the first foreign text vector sequence is unreliable. In this case, the loop execution can exit, terminating the loop without further iterations. After exiting the loop, the machine translation model can be invoked to perform a second translation of the original text.
[0100] Step S2312: When it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is taken as a valid vector sequence.
[0101] When it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, it indicates that the first foreign language vector sequence can be trusted. Therefore, it is directly output as a valid vector sequence so that step S2400 can generate foreign language text based on the valid vector sequence. Of course, there is no need to perform secondary translation on the original text.
[0102] In another embodiment, the determination of whether there are foreign language vectors with abnormal probability distributions in the first foreign language vector sequence is based on whether the probability distribution of the foreign language vectors conforms to the Laida criterion includes the following steps:
[0103] Step S2321: Sequentially determine whether each foreign language vector in the first foreign language vector sequence satisfies the probability distribution statistically determined during the training of the machine translation model. If it does not satisfy the probability distribution, determine that the corresponding foreign language vector has an abnormal probability distribution.
[0104] To apply the Laida criterion, during the training of the machine translation model, the standard deviation can be calculated based on the probability distribution of the effective foreign text vectors generated during each training session. Then, an interval is determined based on a certain probability. Next, for each foreign text vector in the first foreign text vector sequence, each vector is sequentially tested to determine whether its standard deviation exceeds the defined interval. If it exceeds the interval, the corresponding foreign text vector is considered to have an abnormal probability distribution. Therefore, the testing of subsequent foreign text vectors can be terminated, and the machine translation model can continue to perform a second translation of the source text.
[0105] Step S2322: When it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is taken as a valid vector sequence.
[0106] When it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, it indicates that the first foreign language vector sequence can be trusted. Therefore, it is directly output as a valid vector sequence so that step S2400 can generate foreign language text based on the valid vector sequence. Of course, there is no need to perform secondary translation on the original text.
[0107] Furthermore, for cases where the first foreign language vector sequence contains foreign language vectors with abnormal probability distributions, the machine translation model is invoked to perform a secondary translation on the original text. Before performing the secondary translation, the input to the machine translation model is adjusted. Specifically, the technical feature of the original text as the input to the Chinese encoder remains unchanged. However, unlike step S2200, the input used by the pinyin encoder in the machine translation model is no longer a forged pinyin text represented by false values, but rather a pinyin text composed of the standard pinyin corresponding to each character in the original text, i.e., standard pinyin text. Similarly, after the standard pinyin text is embedded into words, a vector sequence representation is obtained and then input into the pinyin encoder. The pinyin encoder performs feature extraction based on this vector sequence, extracting its deep semantic information and obtaining the corresponding pinyin vector. This pinyin vector is a deep semantic feature representation of the standard pinyin text of the original text. Therefore, it is easy to understand that the original text and its standard pinyin text are input into the Chinese encoder and the pinyin encoder in parallel to extract features and obtain pinyin vectors. The pinyin vectors and the corresponding Chinese vectors of the original text have an alignment connection relationship, which can enrich the semantic information of the Chinese vectors and make it easier for the decoder to predict the foreign language vector sequence more accurately based on such semantic information.
[0108] Similarly, the decoder in the machine translation model further performs autoregressive decoding based on the comprehensive vector constructed from the Chinese vector and the Pinyin vector to obtain a foreign language vector sequence as the second foreign language vector sequence. Since the second foreign language vector sequence is obtained by reasoning based on the original text and its standard Pinyin text, it is reliable enough. Therefore, the second foreign language vector sequence can be directly determined as a valid vector sequence.
[0109] Step S2400: Based on the valid vector sequence, query the foreign language vocabulary to determine the corresponding word segment for each foreign language vector, and construct the foreign language text corresponding to the original text.
[0110] It is easy to understand that by applying the above process to a source text to be translated, a unique valid vector sequence can be determined, whether it is the valid vector sequence obtained by calling the machine translation model once for the first translation or the valid vector sequence obtained by calling the machine translation model a second time for the second translation.
[0111] After obtaining the effective vector sequence, the foreign language vocabulary can be searched based on the effective vector sequence to determine the word segments corresponding to each foreign language vector in the effective vector sequence. Based on these word segments, the corresponding foreign language text for the original text can be constructed. Accordingly, in one embodiment, the following steps are performed:
[0112] Step S1410: For each foreign language vector in the effective vector sequence, determine the probability distribution of its mapping to each word segment in the foreign language vocabulary, and take the word segment corresponding to the highest classification probability as the target word corresponding to the foreign language vector.
[0113] For each foreign language vector in the effective vector sequence, firstly, the word segment in the foreign language vocabulary pointed to by the highest classification probability is determined, and this word segment is identified as the target word corresponding to that foreign language vector. It is easy to understand that each foreign language vector in the effective vector sequence can be matched one-to-one with its corresponding target word.
[0114] Step S1420: According to the order of the foreign language vectors in the effective vector sequence, the target word segments corresponding to each foreign language vector are concatenated in an orderly manner to obtain the foreign language text corresponding to the original text.
[0115] After identifying the target words for each foreign language vector, the corresponding target words are sorted and concatenated according to their order in the effective vector sequence to obtain a string. This string is represented in foreign language, which is the foreign language text corresponding to the original text. Thus, the translation process of the original text to be translated is completed, and a translated version of the original text is obtained.
[0116] Based on the above embodiments, it can be seen that this application has many advantages, including but not limited to:
[0117] First, this application targets the original text represented in Chinese characters. It first inputs the Pinyin text (set to falsity) into the machine translation model for initial translation, obtaining a first foreign language vector sequence. By default, this first foreign language vector sequence can be used as a valid vector sequence to determine the foreign language text. However, if the first foreign language vector sequence contains foreign language vectors with abnormal probability distributions, it indicates the presence of misspelled words. Therefore, it further inputs the original text and its standard Pinyin text together into the machine translation model for a second translation, obtaining a second foreign language vector sequence as a valid vector sequence. Finally, the foreign language text is determined based on the valid vector sequence. In this process, the Pinyin text acts as a link between the original word and the misspelled word in the same phrase. This allows two originally unrelated words to be mapped to similar Pinyin encoding spaces through the connection of Pinyin. Utilizing this similarity, effective semantic reasoning can be performed, thus achieving translation error tolerance.
[0118] Secondly, given that most original texts in practice are accurate, in most cases, a single translation by the machine translation model is sufficient to obtain the foreign text. However, a small number of original texts may contain misspelled words. In such cases, by analyzing the probability distribution of foreign text vectors in the first foreign text vector sequence, it can be quickly determined whether a second translation is needed for error correction. When error correction is required, the input is further modified by replacing the pinyin text set as false with the standard pinyin text. This is then input into the same machine translation model again with the corresponding original text for a second translation. The machine translation model, referencing the original text and its pinyin, more accurately predicts the corresponding foreign text. This not only improves the error tolerance in the translation process but also allows for the translation of homophones and polyphonic characters, while significantly reducing computational waste. A balance is struck between the computational efficiency sacrificed for error tolerance and the acquisition of accurate translation results, effectively reducing the translation time required to obtain accurate translation results.
[0119] Furthermore, although this application has an error correction translation mechanism, error correction translation can be achieved by calling the same machine translation model twice. There is no need to use two different models to implement error correction inference. Only a single model needs to be prepared, which results in low implementation cost and high implementation efficiency.
[0120] Based on any embodiment of this application, please also combine with Figure 1 The network architecture of the machine translation model of this application is shown to deepen the understanding of this embodiment. Specifically, according to the network architecture and working principle of the machine translation model of this application, in step S2200, the source text and the pinyin text set to false values are input into the machine translation model in parallel for translation to obtain a first foreign language vector sequence; or, in step S2300, the source text and its standard pinyin text are input into the machine translation model in parallel for translation to obtain a second foreign language vector sequence as a valid vector sequence. Please refer to [link to relevant documentation]. Figure 3 ,include:
[0121] Step S3100: Input the original text into the Chinese encoder of the machine translation model to extract features and obtain Chinese vectors;
[0122] Whether it's the initial translation or the secondary translation as described in this application, the original text to be translated needs to be input. Therefore, the original text is first segmented into words to determine the segmentation sequence. Then, a preset Chinese lexicon is queried. This lexicon stores the mapping relationship between each Chinese word segment and its feature values, thereby obtaining the feature values corresponding to each word segment. The corresponding feature values are then concatenated in the order of word segmentation to obtain a feature sequence. In one embodiment, this feature sequence can be used as the embedding vector of the original text input into the Chinese encoder. In another embodiment, positional encoding features corresponding to each word can be further synthesized based on this feature sequence to obtain the embedding vector corresponding to the original text, which is then used as the input to the Chinese encoder. The specific encoding method of the embedding vector can be flexibly determined by those skilled in the art, as long as it remains consistent during the training and inference phases of the machine translation model.
[0123] Step S3200: Input the pinyin text into the pinyin encoder of the machine translation model to extract features and obtain pinyin vectors;
[0124] As mentioned earlier, the content and form of pinyin text differ in the initial translation stage and the secondary translation stage. Therefore, it is necessary to distinguish between these two situations and perform different input preprocessing according to different pinyin texts.
[0125] In the initial translation stage, instead of using the standard pinyin text of the original text, a pinyin text represented by falsified values is directly used. Essentially, this is a forged pinyin text embedding vector. This embedding vector is then input into the pinyin encoder. It's easy to understand that the encoder can still extract the pinyin vector from the falsified embedding vector, but this vector is usually an invalid vector that does not help guide the translation of the original text. Especially when the falsified value is assigned a value of 0, since the encoder operates based on 0, the resulting pinyin vector is also an all-zero vector, thus lacking substantial meaning.
[0126] For the second translation stage, the standard pinyin text of the original text is used to compile an embedding vector as the input of the pinyin encoder. That is, the pinyin corresponding to each Chinese character in the original text is obtained. Based on the mapping relationship data between the pinyin and its feature values, the feature values corresponding to these pinyin are determined. In one embodiment, the embedding vector is obtained by orderly concatenating the order of each Chinese character in the original text corresponding to these feature values. In another embodiment, the position encoding features of each character in the original text can also be synthesized into the feature values of the corresponding pinyin to determine the embedding vector.
[0127] As explained above, the Pinyin encoder in the machine translation model can accept input from forged Pinyin text (specifically, its corresponding false value vector) in the initial translation stage to identify Pinyin vectors that are actually invalid. In the secondary translation stage, it can accept input from the embedding vectors obtained by word embedding of the standard Pinyin text of the original text to identify Pinyin vectors that are actually valid. Based on this principle, during the training stage of the machine translation model, by simulating the training samples required for the initial and secondary translations to provide input to the Pinyin encoder, the Pinyin encoder can reflect the similarity between homophones in the Pinyin encoding space based on the connection between characters and sounds. Thus, in the subsequent online inference stage, the Pinyin encoder can distinguish different situations and play a role. For example, it plays a substantial role in the initial translation and can represent the similarity of homophone features in the secondary translation, thereby providing Pinyin vectors to effectively help the decoder accurately predict the foreign text vector sequence.
[0128] Step S3300: Construct a comprehensive vector based on the Chinese language vector and the Pinyin vector;
[0129] Furthermore, the machine translation model aligns and concatenates the Chinese language vector and the pinyin vector through a concatenation layer, constructing a comprehensive vector. This comprehensive vector is used to achieve a comprehensive feature representation of both the original text and the pinyin text.
[0130] It's easy to understand that in the initial translation stage, since the pinyin text is forged, the resulting pinyin vectors are invalid, especially since they may be all zeros. Therefore, after being merged into the composite vector, they will have no effect in the subsequent decoding process. However, in the second translation stage, since the pinyin text is the standard pinyin text of the original text, its pinyin vectors are valid. After being combined with the Chinese language vectors of the original text, they can work together with the Chinese language vectors to play a significant role in the subsequent decoding process.
[0131] Step S3400: Input the comprehensive vector into the decoder of the machine translation model for autoregressive decoding to obtain the corresponding foreign language vector sequence.
[0132] The synthesized vector output from the concatenation layer is used as a prefix for decoding and input into the decoder of the machine translation model. The decoder then performs progressive autoregressive decoding based on the obtained prefix. Specifically, the synthesized vector serves as the initial prefix. After semantic understanding by the decoder, the first foreign language vector can be predicted. Then, the foreign language vector obtained by the decoder is further appended to the prefix via autoregression to update the prefix. This updates the prefix, driving the decoder to continue decoding the next foreign language vector. This updated foreign language vector is then used again to update the prefix to generate the next foreign language vector, and so on, until all foreign language vectors are generated. It is easy to understand that the entire decoding process of the decoder continuously refers to the prefix for inference, gradually obtaining each foreign language vector, and finally all the foreign language vectors constitute a foreign language vector sequence.
[0133] This embodiment demonstrates the workflow of the machine translation model used in this application. As can be seen from this workflow, due to the unique nature of the network architecture of the machine translation model, in addition to the Chinese encoder corresponding to the original text extracting the Chinese vector, a pinyin encoder corresponding to the pinyin text is added. This encoder combines the vector representations corresponding to either forged or genuine pinyin text as needed, generating pinyin vectors based on these vector representations. The pinyin vectors serve to associate homophones, enabling the machine translation model to perform error-tolerant decoding based on the similarity of homophone features. By matching different input methods with a single model, two translation accuracies can be obtained, providing both fast and accurate translation capabilities, which can be flexibly combined. Therefore, applying such a machine translation model ensures higher accuracy of the foreign text translated using the technical solution of this application, and can widely serve various translation scenarios.
[0134] Before inputting the original text and the Pinyin text set to false values into the machine translation model in parallel for translation, based on any embodiment of this application, please refer to [link to relevant documentation]. Figure 4 ,include:
[0135] Step S1100: Construct a parallel corpus, which includes multiple parallel corpora. Each parallel corpus includes the original text expressed in Chinese characters and the foreign text expressed in a preset target language. The foreign text is a translation of the original text. Some of the original texts in the parallel corpora contain homophones.
[0136] In order to train the machine translation model of this application, a parallel corpus can be pre-constructed, such that the parallel corpus contains a sufficient amount of parallel data to train the machine translation model to a convergent state.
[0137] The parallel corpus consists of sentence pairs in two languages, providing mutual translation correspondence; that is, the two texts are translation versions of each other. The first language can be expressed in Chinese, with the corresponding text corresponding to the original text described in this application. The second language can be expressed in a preset target language, set according to the target language required by the machine translation model, such as English, Arabic, French, Japanese, etc. The text in the second language corresponds to the foreign language text described in this application.
[0138] Based on the characteristics of machine translation, the original text in the parallel corpus can be used as the input of the machine translation model, while the foreign text in the same parallel corpus can be used as supervision labels. The supervision labels are used after the machine translation model translates the original text into a foreign text vector sequence corresponding to the foreign text. The cross-entropy loss of each foreign text vector in the foreign text vector sequence is calculated, and the cross-entropy loss is summarized to obtain the model loss value, so as to perform gradient update of the entire machine translation model based on the model loss value.
[0139] The original texts and their corresponding foreign texts in the parallel corpus are mostly provided with semantically accurate content. However, to enable the machine translation model to perform error-tolerant translation of homophones, some deliberately mixed parallel corpora may exist in certain parts of the parallel corpus. In these parallel corpora, individual word segments in the original text are homophones of the intended meaning of the words. The proportion of such mixed parallel corpora can be controlled to a relatively low range, for example, arbitrarily selected between 5% and 20% of the total, in order to reasonably simulate the homophone error rate exhibited when a human inputs the original text. This avoids the machine translation model from being inaccurate due to too many mixed parallel corpora, or losing its error-tolerant translation capability due to too few parallel corpora.
[0140] Step S1200: Iteratively call the original text and the corresponding standard pinyin text in each parallel corpus in the parallel corpus as the first sample, train the machine translation model to obtain the corresponding foreign language vector sequence, use the foreign language text in the same parallel corpus as the label for supervised training, and train the machine translation model to convergence.
[0141] After the parallel corpus is prepared, the parallel corpus can be used to perform the first stage of pre-training on the machine translation model of this application. The machine translation model is trained by iteratively calling the parallel corpus as the first sample until it converges.
[0142] During each iteration of the pre-training process, the original text is obtained from the parallel corpus corresponding to that iteration, and its standard pinyin text is obtained based on the original text. The two constitute the first sample. Then, the original text is input into the Chinese encoder of the machine translation model, and the pinyin text corresponding to the original text is input into the pinyin encoder of the machine translation model. Of course, both the original text and the pinyin text should be word embedded as described above in this application so that they can be input in the form of embedding vectors.
[0143] The machine translation model generates a foreign language vector sequence corresponding to the first sample according to the obtained input information and its workflow. This foreign language vector sequence includes the foreign language vectors corresponding to each word that constitutes the foreign language text. As mentioned earlier, this foreign language vector is a probability distribution, and the target word corresponding to the preset foreign language word can be determined based on the maximum classification probability. Organizing these target words in order yields the foreign language text. Therefore, the corresponding foreign language text in the parallel corpus containing the original text can be used as supervision labels to calculate the model loss value corresponding to the foreign language vector sequence. When the model loss value indicates that the machine translation model has not converged, gradient updates are performed on the machine translation model, and the weight parameters of each stage are corrected through backpropagation, allowing the machine translation model to continuously approach convergence. When the model loss value indicates that the machine translation model has reached convergence, the pre-training of the machine translation model can be terminated.
[0144] It is easy to understand that during the pre-training phase, the input provided to the machine translation model includes not only the original text but also the standard pinyin text of the original text. This allows the original text and its pinyin text to provide the reference information needed for translation, enabling the machine translation model to translate foreign text based on the given original text and its corresponding standard pinyin text after training.
[0145] Step S1300: Iteratively call the original text and the pinyin text set to false values in each parallel corpus in the parallel corpus as the second sample, train the machine translation model to obtain the corresponding foreign language vector sequence, use the foreign language text in the same parallel corpus as the label for supervised training, and train the machine translation model to convergence.
[0146] After completing the first stage of pre-training of the machine translation model, the second stage of fine-tuning training can be initiated. During fine-tuning training, the machine translation model is trained by iteratively calling parallel corpora as second samples until it reaches a convergent state.
[0147] During each iteration of the fine-tuning training process, the original text is extracted from the parallel corpus corresponding to that iteration, and a preset forged pinyin text is also obtained. This forged pinyin text is a vector sequence, where each element is represented by an all-zero false value (0). These two are combined to form a second sample. Then, the original text is input into the Chinese encoder of the machine translation model, and the forged pinyin text is input into the pinyin encoder of the machine translation model, respectively. Of course, the original text should undergo the word embedding described above so that it is input into the Chinese encoder in the form of an embedded vector.
[0148] The machine translation model generates a foreign language vector sequence corresponding to the second sample according to the obtained input information and its workflow. This foreign language vector sequence includes foreign language vectors corresponding to each word that constitutes the foreign language text. As mentioned earlier, this foreign language vector is a probability distribution, and the target word corresponding to the preset foreign language word can be determined based on the maximum classification probability. Organizing these target words in order yields the foreign language text. Therefore, the corresponding foreign language text in the parallel corpus containing the original text can be used as supervision labels to calculate the model loss value corresponding to the foreign language vector sequence. When the model loss value indicates that the machine translation model has not converged, gradient updates are performed on the machine translation model, and the weight parameters of each stage are corrected through backpropagation, allowing the machine translation model to continuously approach convergence. When the model loss value indicates that the machine translation model has reached convergence, the fine-tuning training of the machine translation model can be terminated.
[0149] It's easy to understand that during the fine-tuning training phase, the input provided to the machine translation model is the original text and the forged pinyin text. In essence, this makes the pinyin vector generated by the pinyin encoder become invalid information during the translation process, enabling the decoder to have the ability to translate the corresponding foreign text based on the original text alone.
[0150] In one embodiment, for the pre-training and fine-tuning training stages of the machine translation model, the full set of parallel corpora in the parallel corpus can be allocated according to a certain ratio to balance the machine translation model's ability to translate based on different inputs. For example, a 3:7 ratio can be used, with 30% of the parallel corpora randomly selected from the parallel corpus for pre-training and the remaining 70% used for fine-tuning training. Of course, this ratio can be flexibly adjusted and is not limited to this. However, using a random sampling method when obtaining the parallel corpora required for the pre-training stage helps ensure that the parallel corpora required for both training stages can effectively generalize the sample features, ensuring that the machine translation model can be effectively trained for rapid convergence.
[0151] As can be seen from the above embodiments, this application trains the machine translation model in two stages, enabling it to translate based on different input formats. The pre-training stage allows the model to translate foreign text from the source text and its pinyin, while the fine-tuning stage enables it to translate foreign text from the source text alone. Thus, the machine translation model can quickly translate from a single source text, and also accurately translate foreign text from a single source text and its pinyin, giving it high efficiency and error tolerance. Furthermore, since some source texts in the parallel corpus have been replaced with homophones, training the machine translation model with samples from such parallel corpora ensures effective error tolerance. Even if the user inputs source text containing homophones, the machine translation model can still obtain semantically accurate foreign text.
[0152] Based on any embodiment of this application, a parallel corpus can be constructed. Please refer to [link / reference]. Figure 5 ,include:
[0153] Step S1110: Collect accurately expressed parallel texts and store them in a parallel corpus. The parallel texts include original texts accurately expressed in Chinese characters and foreign texts accurately expressed in a preset target language. The foreign texts are translations of the original texts.
[0154] Existing online parallel corpora can be directly accessed, or accurate parallel corpora can be collected and stored in a parallel corpus to initially obtain a parallel corpus containing parallel corpora with precise expressions and translation relationships. The parallel corpora not only have accurate grammar, vocabulary, and character usage in both the original text and its foreign language version, but also have a precise semantic translation relationship between the original text and the foreign language version; or at least, the foreign language version is a correct translation of the original text.
[0155] For the purposes of this application, the original text is expressed in Chinese characters, while the foreign text is expressed in the corresponding preset target language characters according to the translation language that the machine translation model is expected to be able to translate.
[0156] Step S1120: Extract a portion of accurately expressed parallel corpus from the parallel corpus, and perform word segmentation on the original text to obtain the word segmentation results;
[0157] To add parallel corpora containing homophones and misspellings to the parallel corpus, a portion of the accurately represented parallel corpora can be randomly selected from the existing parallel corpus. The mixing is achieved by intentionally replacing homophones and misspellings in the original text of these parallel corpora. To this end, the original text of these extracted parallel corpora is segmented into words, obtaining the segmentation sequence of each original text in the form of Ma Wentao's words, which serves as the segmentation result.
[0158] As mentioned earlier, the proportion of randomly selected parallel corpora can be controlled to make the proportion of subsequent mixed parallel corpora more reasonable.
[0159] Step S1130: Randomly select some words from the word segmentation results of the original text and replace them with homophones;
[0160] For each segmented original text obtained through word segmentation, one or more segments can be randomly selected. Based on the pinyin information of each randomly selected segment, corresponding homophones are generated. Then, these homophones replace the corresponding segments, modifying the segmentation results of each original text. After replacing some segments with homophones, the extracted original texts have changed, effectively becoming original texts containing misspellings, thus achieving sample mixing. Consequently, the parallel corpora containing these original texts also become mixed parallel corpora.
[0161] Step S1140: Add the parallel corpus to which the original text has been replaced with homophones.
[0162] The mixed parallel corpora are re-added to the parallel corpus to enrich the features of the data samples in the parallel corpus, so that the original text of the parallel corpora contained therein reflects the presence of homophones and misspellings.
[0163] As can be seen from the above embodiments, when the parallel corpus processed in this embodiment is used to train a machine translation model, the mixed parallel corpus can provide important reference features for the error tolerance capability of the machine translation model, ensuring that the machine translation model acquires error-tolerant translation capability after training.
[0164] Please see Figure 6To meet one of the purposes of this application, a machine translation apparatus is provided, which is a functional embodiment of the machine translation method of this application. The apparatus includes a source text acquisition module 2100, a default translation module 2200, a supplementary translation module 2300, and a foreign text construction module 2400. The source text acquisition module 2100 is used to acquire the source text to be translated, wherein the source text is in Chinese. The default translation module 2200 is used to input the source text and the pinyin text set to false values into a machine translation model in parallel for translation, obtaining a first foreign text vector sequence, wherein each foreign text vector... The probability distribution corresponding to each word segment mapped to the preset foreign language vocabulary is represented; the supplementary translation module 2300 is used to determine that the first foreign language vector sequence is a valid vector sequence when there is no foreign language vector with an abnormal probability distribution in the first foreign language vector sequence; otherwise, the original text and its standard pinyin text are input into the machine translation model in parallel for translation to obtain a second foreign language vector sequence as a valid vector sequence; the foreign language construction module 2400 is used to query the foreign language vocabulary according to the valid vector sequence to determine the corresponding word segment of each foreign language vector and construct a foreign language text corresponding to the original text.
[0165] Based on any embodiment of this application, the supplementary translation module 2300 includes: a probability analysis unit, used to sequentially determine whether the maximum classification probability of each foreign language vector in the first foreign language vector sequence is lower than a preset threshold, and when the maximum classification probability of at least one of the foreign language vectors is lower than the preset threshold, it is determined that the corresponding foreign language vector has an abnormal probability distribution; and an output processing unit, used to take the first foreign language vector sequence as a valid vector sequence when it is determined that there are no foreign language vectors with abnormal probability distribution in the first foreign language vector sequence.
[0166] Based on any embodiment of this application, the supplementary translation module 2300 includes: a distribution analysis unit, used to sequentially determine whether each foreign language vector in the first foreign language vector sequence satisfies the probability distribution statistically determined during the training process of the machine translation model, and when it does not satisfy, it determines that the corresponding foreign language vector has an abnormal probability distribution; and an output processing unit, used to take the first foreign language vector sequence as a valid vector sequence when it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence.
[0167] Based on any embodiment of this application, the default translation module 2200 or the supplementary translation module 2300 includes: a Chinese encoding unit, used to input the source text into the Chinese encoder of the machine translation model to extract features and obtain Chinese vectors; a Pinyin encoding unit, used to input Pinyin text into the Pinyin encoder of the machine translation model to extract features and obtain Pinyin vectors; a vector synthesis unit, used to construct a synthesis vector based on the Chinese vectors and the Pinyin vectors; and a decoding output unit, used to input the synthesis vector into the decoder of the machine translation model for autoregressive decoding to obtain the corresponding foreign language vector sequence.
[0168] Based on any embodiment of this application, prior to the default translation module 2200, the module includes: a corpus building module for constructing parallel corpora, such that the parallel corpora include multiple parallel corpora, each parallel corpus including original text expressed in Chinese characters and foreign text expressed in a preset target language, wherein the foreign text is a translated version of the original text, and some parallel corpora contain homophones; a first training module for iteratively calling the original text and the corresponding standard pinyin text in each parallel corpus as first samples to train the machine translation model and obtain corresponding foreign text vector sequences, using the foreign text in the same parallel corpus as labels for supervised training, and training the machine translation model to a convergent state; and a second training module for iteratively calling the original text and pinyin text set to false values in each parallel corpus as second samples to train the machine translation model and obtain corresponding foreign text vector sequences, using the foreign text in the same parallel corpus as labels for supervised training, and training the machine translation model to a convergent state.
[0169] Based on any embodiment of this application, the corpus building module includes: a preliminary acquisition unit, used to acquire accurately expressed parallel corpora and store them in a parallel corpus, wherein the parallel corpora include original text accurately expressed in Chinese characters and foreign text accurately expressed in a preset target language, wherein the foreign text is a translation of the original text; a word extraction and segmentation unit, used to extract a portion of accurately expressed parallel corpora from the parallel corpus and segment the original text therein to obtain word segmentation results; a homophone replacement unit, used to randomly select a portion of the word segmentation results of the original text and replace them with homophones; and a replacement append unit, used to append the parallel corpora whose original texts have been replaced with homophones to the parallel corpus.
[0170] Based on any embodiment of this application, the foreign language construction module 2400 includes: a word segmentation query unit, used to determine the probability distribution of each foreign language vector in the effective vector sequence that it maps to each word in the foreign language vocabulary, and the word corresponding to the highest classification probability is used as the target word corresponding to the foreign language vector; and a foreign language concatenation unit, used to concatenate the target words corresponding to each foreign language vector in an orderly manner according to the arrangement order of the foreign language vectors in the effective vector sequence to obtain the foreign language text corresponding to the original text.
[0171] To address the aforementioned technical problems, embodiments of this application also provide computer equipment. For example... Figure 7 The diagram shows the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database may store a sequence of control information. When the computer-readable instructions are executed by the processor, the processor can implement a product search category identification method. The processor of the computer device provides computing and control capabilities to support the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor can execute the machine translation method of this application. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0172] In this embodiment, the processor is used to execute... Figure 6 The system defines the specific functions of each module and its submodules. The memory stores the program code and various data required to execute these modules or submodules. The network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules / submodules in the machine translation device of this application. The server can call the server's program code and data to execute the functions of all submodules.
[0173] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the machine translation method of any embodiment of this application.
[0174] This application also provides a computer program product, including a computer program / instructions that, when executed by one or more processors, implement the steps of the method described in any embodiment of this application.
[0175] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0176] In summary, this application uses a single machine translation model to achieve fast and accurate translation of the source text, and it can perform error-tolerant translation of the source text, making it widely applicable to various application scenarios that require translation.
[0177] Those skilled in the art will understand that the steps, measures, and solutions in the various operations, methods, and processes discussed in this application can be alternated, modified, combined, or deleted. Furthermore, other steps, measures, and solutions in the various operations, methods, and processes discussed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted. Furthermore, steps, measures, and solutions in the prior art that are similar to those disclosed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted.
[0178] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A machine translation method, characterized in that, include: Obtain the original text to be translated, wherein the original text is in Chinese characters; The original text and the pinyin text set to false values are input into the machine translation model in parallel for translation to obtain a first foreign language vector sequence. Each foreign language vector represents the probability distribution corresponding to each word segment in the preset foreign language vocabulary. The false values are virtual values provided to control the pinyin encoder in the machine translation model from generating effective pinyin vectors. When there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is determined to be a valid vector sequence. Otherwise, the original text and its standard pinyin text are input into the machine translation model in parallel for translation to obtain a second foreign language vector sequence as a valid vector sequence. The abnormal probability distribution includes the maximum classification probability being lower than a preset threshold, or the probability distribution not conforming to the Laida criterion. Based on the valid vector sequence, the foreign language vocabulary is queried to determine the corresponding word segment for each foreign language vector, and a foreign language text corresponding to the original text is constructed.
2. The machine translation method according to claim 1, characterized in that, The first foreign language vector sequence is determined to be a valid vector sequence when there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, including: The maximum classification probability of each foreign language vector in the first foreign language vector sequence is determined to be lower than a preset threshold. When the maximum classification probability of at least one foreign language vector is lower than the preset threshold, it is determined that the corresponding foreign language vector has an abnormal probability distribution. When it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is considered a valid vector sequence.
3. The machine translation method according to claim 1, characterized in that, The first foreign language vector sequence is determined to be a valid vector sequence when there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, including: The system sequentially determines whether each foreign language vector in the first foreign language vector sequence satisfies the probability distribution statistically determined during the training of the machine translation model. If it does not satisfy the probability distribution, the corresponding foreign language vector is determined to have an abnormal probability distribution. When it is determined that there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence, the first foreign language vector sequence is considered a valid vector sequence.
4. The machine translation method according to claim 1, characterized in that, The step of inputting the original text and the Pinyin text set to false values into the machine translation model in parallel for translation to obtain a first foreign language vector sequence, or the step of inputting the original text and its standard Pinyin text into the machine translation model in parallel for translation to obtain a second foreign language vector sequence as a valid vector sequence, includes: The original text is input into the Chinese encoder of the machine translation model to extract features and obtain Chinese vectors. Input the pinyin text into the pinyin encoder of the machine translation model to extract features and obtain pinyin vectors; A comprehensive vector is constructed based on the Chinese language vector and the Pinyin vector; The integrated vector is input into the decoder of the machine translation model for autoregressive decoding to obtain the corresponding foreign language vector sequence.
5. The machine translation method according to claim 1, characterized in that, Before inputting the original text and the Pinyin text set to false values into the machine translation model in parallel for translation, the following steps are included: Construct a parallel corpus, which includes multiple parallel corpora. Each parallel corpus includes an original text expressed in Chinese characters and a foreign text expressed in a preset target language. The foreign text is a translation of the original text. Some of the original texts in the parallel corpora contain homophones. The machine translation model is trained by iteratively calling the original text and the corresponding standard pinyin text from each parallel corpus in the parallel corpus as the first sample to obtain the corresponding foreign language vector sequence. The foreign language text in the same parallel corpus is used as the label for supervised training to train the machine translation model to a convergent state. The original text and the pinyin text set to false values in each parallel corpus of the parallel corpus are iteratively called as the second samples to train the machine translation model and obtain the corresponding foreign language vector sequence. The foreign language text in the same parallel corpus is used as the label for supervised training to train the machine translation model to a convergent state.
6. The machine translation method according to claim 5, characterized in that, Constructing parallel corpora, including: Accurately expressed parallel texts are collected and stored in a parallel corpus. The parallel texts include original texts accurately expressed in Chinese characters and foreign texts accurately expressed in a preset target language. The foreign texts are translations of the original texts. Extract a portion of accurately expressed parallel text from a parallel corpus, and segment the original text within it to obtain the segmentation results; Randomly select some words from the word segmentation results of the original text and replace them with homophones; Parallel texts in which the original text has been replaced with homophones or misspellings are added to the parallel corpus.
7. The machine translation method according to claim 1, characterized in that, Based on the valid vector sequence, the corresponding word segments for each foreign language vector in the foreign language vocabulary are determined, and a foreign language text corresponding to the original text is constructed, including: For each foreign language vector in the effective vector sequence, determine the probability distribution of its mapping to each word segment in the foreign language vocabulary, and take the word segment corresponding to the highest classification probability as the target word corresponding to the foreign language vector. According to the order of the foreign language vectors in the effective vector sequence, the target word segments corresponding to each foreign language vector are concatenated in an orderly manner to obtain the foreign language text corresponding to the original text.
8. A machine translation device, characterized in that, include: The original text acquisition module is used to acquire the original text to be translated, wherein the original text is in Chinese. The default translation module is used to input the original text and the pinyin text set to false values into the machine translation model in parallel for translation, and obtain a first foreign language vector sequence, wherein each foreign language vector represents the probability distribution corresponding to each word segment in the preset foreign language vocabulary, and the false values are virtual values provided to control the pinyin encoder in the machine translation model from generating effective pinyin vectors; The supplementary translation module is used to determine the first foreign language vector sequence as a valid vector sequence when there are no foreign language vectors with abnormal probability distributions in the first foreign language vector sequence; otherwise, the original text and its standard pinyin text are input into the machine translation model in parallel for translation to obtain the second foreign language vector sequence as a valid vector sequence. The abnormal probability distribution includes the maximum classification probability being lower than a preset threshold, or the probability distribution not conforming to the Laida criterion. The foreign language construction module is used to query the foreign language vocabulary based on the effective vector sequence to determine the corresponding word segment for each foreign language vector and construct a foreign language text corresponding to the original text.
9. A computer device comprising a central processing unit and a memory, characterized in that, The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 7, which, when invoked by a computer, executes the steps included in the corresponding method.