Machine translation method based on related languages

Through a machine translation method based on kin language, through grammatical detection and semantic verification, the problems of low translation efficiency and poor semantic retention of kin languages ​​in the prior art are solved, efficient and accurate translation results are achieved, and the context semantics and intrinsic characteristics of the source language are retained.

CN119167950BActive Publication Date: 2025-03-11STATE GRID ZHEJIANG ELECTRIC POWER CO LTD HANGZHOU POWER SUPPLY CO
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411659670.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-03-11
Estimated Expiration
2044-11-20

AI Technical Summary

Technical Problem

Existing machine translation techniques are inefficient when translating between kin languages ​​and are difficult to retain the contextual semantics and intrinsic characteristics of the translated language.

Method used

A machine translation method based on kin language is proposed. By obtaining translation samples and test samples, generating prompt templates, performing grammatical detection and semantic verification, we ensure that the translation results retain the context semantics and intrinsic features of the source language.

Benefits of technology

It realizes efficient and accurate translation between kin languages, ensuring that the translation results retain the contextual semantics and intrinsic characteristics of the translated language, improving translation performance, especially in the translation of low-resource languages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119167950B_ABST
    Figure CN119167950B_ABST
Patent Text Reader

Abstract

The present application discloses a machine translation method based on related languages, comprising: obtaining a translation sample and a test sample, determining a test block matched by the test sample, wherein the translation sample comprises a sentence pair consisting of a source language sentence and a corresponding target language sentence, the language corresponding to the test sample is the source language, and the target language is a related language of the source language; generating a first prompt template based on the translation sample and the test block, and determining a first independent translation block corresponding to the test block according to the first prompt template; performing a grammar check on the first independent translation block to obtain a second independent translation block according to the grammar check result; generating a context translation block based on the translation sample and the second independent translation block; performing semantic verification based on the context translation block and the test block to obtain a target context translation block according to the semantic verification result; generating a target language translation result based on the target context translation block, so as to efficiently and accurately perform translation between related languages ​​and retain the intrinsic characteristics of the translated language.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of machine translation, and in particular to a machine translation method based on related languages. Background Art

[0002] Related languages ​​usually come from the same language family, have the same word order and vocabulary features, and have monotonous translation relationships. A large number of commercial activities and social relationships also occur between neighboring regions that speak related languages. In recent years, in the field of machine translation, large language models have been used extensively for translation. However, since the reasoning process of translation may cause cascading errors, using a third-party relay language to translate between related languages ​​is very inefficient.

[0003] However, the translations generated by large language models usually ensure fluent word order, which makes it easy to ignore the unique intrinsic characteristics of the translated language. In addition, when selecting training data, large language models tend to prefer several major international languages ​​(such as English), so translations between niche related languages ​​may also need to borrow a common language as a third-party relay language for translation. This makes large language models relatively inefficient when translating between related languages ​​and it is difficult to exert their full performance. Summary of the invention

[0004] In order to solve the above technical problems, the embodiment of the present application proposes a machine translation method based on related languages, which can efficiently and accurately translate between related languages ​​and ensure that the translated language retains the contextual semantics of the translated language to retain the intrinsic characteristics of the translated language.

[0005] The present application embodiment provides a machine translation method based on related languages, including:

[0006] Obtaining a translation sample and a test sample, and determining a test block matching the test sample, wherein the translation sample includes a sentence pair consisting of a source language sentence and a corresponding target language sentence, the language corresponding to the test sample is the source language, and the target language is a relative language of the source language;

[0007] Based on the translation sample and the test block, generate a first prompt template, and determine a first independent translation block corresponding to the test block according to the first prompt template;

[0008] Performing grammar detection on the first independent translation block to modify the first independent translation block according to the grammar detection result to obtain a second independent translation block;

[0009] Based on the translation example and the second independent translation block, generating a context translation block using a context translation model;

[0010] Based on the context translation block and the test block, semantic verification is performed to update the context translation block according to the semantic verification result to obtain a target context translation block;

[0011] A target language translation result corresponding to the test example is generated based on the target context translation block.

[0012] Optionally, the test example is decomposed into a plurality of the test blocks, and the generating a first prompt template based on the translation example and the test block, and determining a first independent translation block corresponding to the test block according to the first prompt template, comprises:

[0013] Based on each test block and the translation example, construct a first prompt template corresponding to each test block;

[0014] Each first prompt template is input into a pre-configured multi-language pre-training model for translation to obtain a first independent translation block corresponding to each test block, wherein the multi-language pre-training model includes a first mT5 model.

[0015] Optionally, the source language sentence includes a plurality of first source language word blocks, the target language sentence includes a plurality of first target language word blocks corresponding to the plurality of first source language word blocks one by one, and constructing a first prompt template corresponding to each test block based on each test block and the translation example includes:

[0016] splicing each first source language word block and its corresponding first target language word block to construct an independent translation prompt template corresponding to each first source language word block;

[0017] Based on the independent translation prompt templates corresponding to the plurality of first source language word blocks and each test block, a first prompt template corresponding to each test block is constructed.

[0018] Optionally, the performing grammar detection on the first independent translation block to modify the first independent translation block according to the grammar detection result to obtain the second independent translation block includes:

[0019] Using a first deep learning model, according to a target grammar rule used in a target language, grammar detection is performed on each first independent translation block to obtain a corresponding grammar detection result, wherein the first deep learning model includes a RoBERTa model;

[0020] For each first independent translation block, if the grammar detection result corresponding to the first independent translation block indicates the existence of a grammatical error, a grammar annotation result matching the existing grammatical error is generated, and the grammar annotation result is fed back to the multilingual pre-training model, so that the multilingual pre-training model corrects the first independent translation block according to the grammar annotation result to obtain a second independent translation block corresponding to the first independent translation block; if the grammar error does not exist, the first independent translation block is used as the corresponding second independent translation block.

[0021] Optionally, the test example is decomposed into a plurality of test blocks having a sequence, wherein the sequence is determined by a text structure of a text indicated by the test example, and the generating of a context translation block by using a context translation model based on the translation example and the second independent translation block comprises:

[0022] For each test block, at least based on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, and the translation examples, construct a second prompt template corresponding to the test block;

[0023] The context translation model is used to perform context translation based on the second prompt template corresponding to each test block to generate a context translation block corresponding to each test block, wherein the context translation model includes a second mT5 model.

[0024] Optionally, constructing a second prompt template corresponding to the test block based at least on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, and the translation example, includes:

[0025] Based on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, the translation examples, and the context translation block corresponding to the previous test block of the test block, a second prompt template corresponding to the test block is constructed.

[0026] Optionally, the source language sentence includes a plurality of second source language word blocks, and the target language sentence includes a plurality of second target language word blocks corresponding to the plurality of second source language word blocks one by one; the constructing a second prompt template corresponding to the test block based on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, the translation sample, and the context translation block corresponding to the previous test block of the test block includes:

[0027] splicing each second source language word block and its corresponding second target language word block to construct a context translation prompt template corresponding to each second source language word block;

[0028] Based on the context translation prompt templates corresponding to each of the several second source language word blocks, the test block and its adjacent test blocks, the second independent translation blocks corresponding to each of the test block and its adjacent test blocks, and the context translation block corresponding to the previous test block of the test block, a second prompt template corresponding to the test block is constructed.

[0029] Optionally, the performing semantic verification based on the context translation block and the test block includes:

[0030] Determining a semantic similarity score between each test block and its corresponding context translation block by a second deep learning model, wherein the second deep learning model comprises a Sentence-BERT model;

[0031] For each test block, determining the semantic cohesion between the context translation block corresponding to the test block and the context translation block corresponding to the previous test block through the second deep learning model, as the semantic cohesion score corresponding to the test block;

[0032] The semantic verification result is determined based on a first comparison result between the semantic similarity score corresponding to each context translation block and a set similarity threshold, and / or a second comparison result between the semantic cohesion score corresponding to each context translation block and a set cohesion score threshold.

[0033] Optionally, the semantic verification result is determined by the first comparison result and the second comparison result, and updating the context translation block according to the semantic verification result to obtain a target context translation block includes:

[0034] For each context translation block,

[0035] When the semantic similarity score corresponding to the context translation block is not less than the set similarity threshold, and the semantic cohesion score corresponding to the context translation block is not less than the set cohesion score threshold, the context translation block is used as the corresponding target context translation block;

[0036] When the semantic similarity score corresponding to the context translation block is less than the set similarity threshold, feeding back the first comparison result corresponding to the context translation block to the context translation model, so that the context translation model updates the context translation block according to the corresponding first comparison result, and uses the updated context translation block as the corresponding target context translation block;

[0037] In a case where the semantic coherence score corresponding to the context translation block is less than the set coherence score threshold, the second comparison result corresponding to the context translation block is fed back to the context translation model, so that the context translation model updates the context translation block according to the corresponding second comparison result, and uses the updated context translation block as the corresponding target context translation block.

[0038] Optionally, generating a target language translation result corresponding to the test example based on the target context translation block includes:

[0039] splicing the target context translation blocks in the order described above to obtain an initial language translation result;

[0040] Performing a coherence test on the initial language translation result by using a second deep learning model; if the coherence test result indicates that the test is passed, taking the initial language translation result as the target language translation result; otherwise, correcting the initial language translation result by using the contextual translation model according to the coherence test result until the corrected initial language translation result passes the coherence test, and taking the initial language translation result that passes the coherence test as the target language translation result;

[0041] The coherence detection result includes at least one of the following: a semantic coherence detection result and a grammatical coherence detection result.

[0042] In summary, the embodiments of the present application have at least the following beneficial effects:

[0043] According to an embodiment of the present application, a translation sample and a test sample are obtained, and a test block matching the test sample is determined, wherein the translation sample includes a sentence pair consisting of a source language sentence and a corresponding target language sentence, the language corresponding to the test sample is the source language, and the target language is a related language of the source language; based on the translation sample and the test block, a first prompt template is generated, and a first independent translation block corresponding to the test block is determined according to the first prompt template; a grammar check is performed on the first independent translation block to correct the first independent translation block according to the grammar check result to obtain a second independent translation block; based on the translation sample and the second independent translation block, a context translation block is generated using a context translation model; based on the context translation block and the test block, semantic verification is performed to update the context translation block according to the semantic verification result to obtain a target context translation block; based on the target context translation block, a target language translation result corresponding to the test sample is generated, so that translation between related languages ​​can be performed efficiently and accurately, and it is ensured that the translated language retains the context semantics of the translated language to retain the intrinsic characteristics of the translated language. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 It is a flowchart of a machine translation method based on related languages ​​provided in an embodiment of the present application;

[0045] Figure 2 It is a schematic diagram of machine translation based on related languages ​​provided in an embodiment of the present application. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0047] In the description of the present application, the terms "first", "second", "third", etc. are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, features defined as "first", "second", "third", etc. may explicitly or implicitly include one or more of the features. In the description of the present application, unless otherwise specified, the meaning of "multiple" is two or more. In the description of the present application, the term "including" and its variations are open inclusions, i.e., "including but not limited to". The term "based on" means "at least partially based on". The term "according to" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments".

[0048] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0049] In the description of this application, it should be noted that, unless otherwise defined, all technical and scientific terms used in this application have the same meaning as those commonly understood by those skilled in the art. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood by specific circumstances.

[0050] The following is an explanation of some terminology concepts involved in the embodiments of the present application:

[0051] The mT5 (Multilingual T5) model is a multilingual pre-trained model, which is a multilingual version of the T5 (Text-to-Text Transfer Transformer) model.

[0052] RoBERTa (Robustly Optimized BERT Pretraining Approach) is an improved version of the BERT (Bidirectional Encoder Representations from Transformers) model. The main goal of RoBERTa is to improve the performance of the BERT model by optimizing the pre-training process.

[0053] Sentence-BERT is an improved version of the BERT model, which is specifically designed to generate high-quality sentence embeddings. Sentence-BERT fine-tunes the BERT model to enable it to directly generate sentence-level embedding vectors, which can be used for various natural language processing tasks, such as semantic similarity calculation, information retrieval, and clustering.

[0054] See also Figure 1 , shows a flow chart of a machine translation method based on a related language provided in an embodiment of the present application, the method includes steps S101-S106, which are as follows:

[0055] S101, obtaining a translation sample and a test sample, and determining a test block matching the test sample, wherein the translation sample includes a sentence pair consisting of a source language sentence and a corresponding target language sentence, the language corresponding to the test sample is the source language, and the target language is a relative language of the source language.

[0056] It should be noted that the translation example in this embodiment can be obtained through annotation processing, and the annotation processing can be used to monotonically align the source language sentence and its corresponding target language sentence, and can also be used to make the source language sentence and its corresponding target language sentence have the same semantics and / or sentence structure.

[0057] In an example, the test sample may be represented as text data, and the test block may be a plurality of text blocks extracted from the test sample.

[0058] In one example, the number of translation examples may be multiple (e.g., 5), each of which includes a sentence pair consisting of a source language sentence and a corresponding target language sentence. For the i-th translation example, its source language sentence is represented as , the target language sentence is represented as In addition, in this embodiment, the translation examples can be monotonically aligned and maintain the same information order through annotation processing, and the annotation processing can be used to modify the sentences contained in each translation example to achieve this.

[0059] S102: Generate a first prompt template based on the translation sample and the test block, and determine a first independent translation block corresponding to the test block according to the first prompt template.

[0060] In one example, each test block may correspond to a text block (e.g., a word block), and an independent translation independent of context information may be performed based on a first prompt template generated by a single test block, so that each first independent translation block translated corresponds to an independent translation of a test block. This process can ensure that the independent translation block is not affected by the context.

[0061] S103: Perform a grammar check on the first independent translation block to modify the first independent translation block according to a grammar check result to obtain a second independent translation block.

[0062] In step S103, it may be checked whether there is a grammatical error in the first independent translation block. If there is, the grammatical error in the first independent translation block may be corrected.

[0063] S104: Generate a context translation block using a context translation model based on the translation example and the second independent translation block.

[0064] S105 , performing semantic verification based on the context translation block and the test block, so as to update the context translation block according to the semantic verification result and obtain a target context translation block.

[0065] In step S105, the semantics between the context translation block and the test block may be verified to ensure that the semantics between the translated target context translation block and its corresponding test block are similar or even consistent.

[0066] It can be understood that this embodiment is equivalent to introducing a cross-supervision mechanism between the multilingual pre-training model and the contextual translation model, and using semantic consistency to correct the translation results in real time.

[0067] S106: Generate a target language translation result corresponding to the test example based on the target context translation block.

[0068] In an optional implementation, the test example is decomposed into a plurality of the test blocks, generating a first prompt template based on the translation example and the test block, and determining a first independent translation block corresponding to the test block according to the first prompt template, includes:

[0069] Based on each test block and the translation example, a first prompt template corresponding to each test block is constructed.

[0070] Each first prompt template is input into a pre-configured multi-language pre-training model for translation to obtain a first independent translation block corresponding to each test block, wherein the multi-language pre-training model includes a first mT5 model.

[0071] In an example, suppose the test case Decompose into test blocks, each test block contains m units, and for the i-th test block, Indicates that using The first prompt template is constructed with the translation examples as the prompt template of the independent translation model (i.e., the multilingual pre-trained model) The formula is as follows:

[0072]

[0073] in, is the i-th test block, Represents the process of constructing the first prompt template, Represents the first prompt template corresponding to the i-th test block.

[0074] See also Figure 2 , the independent translation model generates the first independent translation block by processing the first hint template:

[0075]

[0076] in, represents the first prompt template corresponding to the i-th test block, It indicates the process of generating the first independent translation block using the mT5 model in the independent translation model. is the first independent translation block corresponding to the i-th test block.

[0077] In an optional implementation, the source language sentence includes a plurality of first source language word blocks, the target language sentence includes a plurality of first target language word blocks corresponding to the plurality of first source language word blocks one by one, and constructing a first prompt template corresponding to each test block based on each test block and the translation example includes:

[0078] Each first source language word block and its corresponding first target language word block are concatenated to construct an independent translation prompt template corresponding to each first source language word block.

[0079] Based on the independent translation prompt templates corresponding to the plurality of first source language word blocks and each test block, a first prompt template corresponding to each test block is constructed.

[0080] In one example, the source language sentence of the i-th translation example can be Each k word unit in the first source language word block and the target language sentence Each k word in composes a first target language word block, where express The jth first source language word chunk in express The j-th first target language word chunk in .

[0081] Thus, the independent translation hint template corresponding to the first source language word block can be constructed as follows: the preset translation template starts with "Translate from [source language] to [target language]:", followed by a line break, followed by "[source language]:", and then the first source language word block in the source language sentence of the first translation example. , followed by a line break, add "[target language]:", and concatenate , repeat this process for all word blocks in the same sentence until all sentences in each translation sample have been processed to construct each independent translation prompt template.

[0082] After all word blocks in a translation sample are constructed, they are separated by a line break, and then the next translation sample is constructed, and this process is repeated until all translation samples are processed.

[0083] In addition, for each test example, after the independent translation prompt template, it starts with "Translate from [source language] to [target language]:", followed by a line break, and then "[source language]:", followed by the corresponding i-th test block (source language) in the test example, that is, the above , followed by a line of "[target language]: <mask>", to indicate that the independent translation model (i.e., the multilingual pre-trained model) can infer the content in <mask>, i.e., the first independent translation block corresponding to the i-th test block above .

[0084] In summary, the first independent translation block Can be constructed as follows:

[0085] Translate from [source language] to [target language]:

[0086] [Original language]:

[0087] [Target language]:

[0088] [Original language]:

[0089] [Target language]:

[0090] …

[0091] [Original language]:

[0092] [Target language]:

[0093] Translate from [source language] to [target language]:

[0094] [Original language]:

[0095] [target language]:<mask>

[0096] Reasoning: <mask> is

[0097] In an optional implementation, the performing grammar detection on the first independent translation block to modify the first independent translation block according to the grammar detection result to obtain the second independent translation block includes:

[0098] Using a first deep learning model, grammar detection is performed on each first independent translation block according to target grammar rules used in the target language to obtain corresponding grammar detection results, wherein the first deep learning model includes a RoBERTa model.

[0099] It can be understood that this embodiment is equivalent to introducing a cross-supervision mechanism between the multilingual pre-training model and the contextual translation model, and using the target grammar rules of the target language to correct the translation results in real time.

[0100] For each first independent translation block, if the grammar detection result corresponding to the first independent translation block indicates the existence of a grammatical error, a grammar annotation result matching the existing grammatical error is generated, and the grammar annotation result is fed back to the multilingual pre-training model, so that the multilingual pre-training model corrects the first independent translation block according to the grammar annotation result to obtain a second independent translation block corresponding to the first independent translation block; if the grammar error does not exist, the first independent translation block is used as the corresponding second independent translation block.

[0101] In one example, a first deep learning model including a RoBERTa model may be used to translate a first independent translation block corresponding to the i-th test block according to the corresponding target grammar rule. Analyze to detect whether there are grammatical errors. If so, generate annotation results corresponding to the grammatical errors. . And, you can Feedback is given to the independent translation model (i.e., the multilingual pre-trained model), so that the independent translation model can be based on To redefine the corrected independent translation blocks ,by As a second independent translation block.

[0102] In an optional implementation, the test example is decomposed into a plurality of test blocks having a sequence, wherein the sequence is determined by a text structure of a text indicated by the test example, and generating a context translation block based on the translation example and the second independent translation block by using a context translation model includes:

[0103] For each test block, a second prompt template corresponding to the test block is constructed based at least on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, and the translation examples.

[0104] The context translation model is used to perform context translation based on the second prompt template corresponding to each test block to generate a context translation block corresponding to each test block, wherein the context translation model includes a second mT5 model.

[0105] It should be noted that the sequence in this embodiment may be the sequence used when the text indicated by the test sample is sequentially decomposed into multiple test blocks.

[0106] In one example, the second prompt template corresponding to the i-th test block can be Input into the contextual translation model containing the second mT5 model, and autoregressively generate the corresponding contextual translation block, which is expressed as follows:

[0107]

[0108] in, Represents the context translation block corresponding to the i-th test block.

[0109] In an optional implementation, constructing a second prompt template corresponding to the test block based at least on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, and the translation example, includes:

[0110] Based on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, the translation examples, and the context translation block corresponding to the previous test block of the test block, a second prompt template corresponding to the test block is constructed.

[0111] In an optional implementation, the source language sentence includes a plurality of second source language word blocks, and the target language sentence includes a plurality of second target language word blocks corresponding to the plurality of second source language word blocks one by one; the constructing a second prompt template corresponding to the test block based on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, the translation sample, and the context translation block corresponding to the previous test block of the test block includes:

[0112] Each second source language word block and its corresponding second target language word block are concatenated to construct a context translation prompt template corresponding to each second source language word block.

[0113] Based on the context translation prompt templates corresponding to each of the several second source language word blocks, the test block and its adjacent test blocks, the second independent translation blocks corresponding to each of the test block and its adjacent test blocks, and the context translation block corresponding to the previous test block of the test block, a second prompt template corresponding to the test block is constructed.

[0114] In one example, the second prompt template corresponding to the i-th test block It can be constructed by the following formula:

[0115]

[0116]

[0117]

[0118] in, represents the context translation block corresponding to the i-1th test block (i.e., the previous test block of the i-th test block), Indicates the number of test blocks.

[0119] In one example, the number of the second source language word blocks may be different from the number of the first source language word blocks. For example, the second source language word block in this embodiment may be the source language sentence of the i-th translation example. Each n word unit in the second source language constitutes a word block and the target language sentence Every n words in compose a second target language word block, where express The j-th second source language word block in express The j-th second target language word block in .

[0120] So, see Figure 2 , the contextual translation hint template corresponding to the second source language word block can be constructed as follows: the default translation template starts with "Translate from [source language] to [target language]:", followed by a line break, then "[source language]:", and then the source language sentence of the first translation example. , followed by a line break, add "[target language]:", and concatenate , and repeat this process for all word blocks in the same sentence until all sentences in each translation sample have been processed to construct each context translation prompt template.

[0121] After all word blocks in a translation sample are constructed, they are separated by a line break, and then the next translation sample is constructed, and this process is repeated until all translation samples are processed.

[0122] In addition, for each test example, after the context translation prompt template, it starts with "Translate from [source language] to [target language]:", followed by a line break, and the next line is "[target language]:", followed by the concatenation of , in particular, when Time The splicing, when Time The next line is "[target language]:[previous context translation block]<mask>[next second independent translation block]". When [previous context translation block] is empty, when , [next second independent translation block] is empty, indicating that the context translation model containing the second mT5 model infers the content of <mask>, which is the context translation block corresponding to the above i-th test block Among them, the previous context translation block is the context translation block corresponding to the previous test block.

[0123] In summary, the context translation block corresponding to the i+1th test block Can be constructed as follows:

[0124] Translate from [source language] to [target language]:

[0125] [Original language]:

[0126] [Target language]:

[0127] [Original language]:

[0128] [Target language]:

[0129] …

[0130] [Original language]:

[0131] [Target language]:

[0132] Translate from [source language] to [target language]:

[0133] [Original language]:

[0134] [Target language]: <mask>

[0135] Reasoning: <mask> is

[0136] In an optional implementation, the performing semantic verification based on the context translation block and the test block includes:

[0137] Determine a semantic similarity score between each test block and its corresponding context translation block through a second deep learning model, wherein the second deep learning model includes a Sentence-BERT model.

[0138] In one example, a second deep learning model including a Sentence-BERT model may determine / calculate the i-th test block The corresponding context translation block The semantic similarity between them generates a semantic similarity score .

[0139] For each test block, the second deep learning model is used to determine the semantic coherence between the context translation block corresponding to the test block and the context translation block corresponding to the previous test block as the semantic coherence score corresponding to the test block.

[0140] In one example, a second deep learning model including a Sentence-BERT model can determine / calculate the context translation block corresponding to the i-th test block The context translation block corresponding to the i-1th test block (i.e. the previous test block) Semantic cohesion , to obtain the semantic coherence score corresponding to the i-th test block.

[0141] The semantic verification result is determined based on a first comparison result between the semantic similarity score corresponding to each context translation block and a set similarity threshold, and / or a second comparison result between the semantic cohesion score corresponding to each context translation block and a set cohesion score threshold.

[0142] In one example, the semantic verification result can be used to characterize the first comparison result, or to characterize the second comparison result, or to characterize the first comparison result and the second comparison result, that is, this embodiment can determine whether the corresponding context translation block can pass the semantic verification based on at least one of the first comparison result and the second comparison result.

[0143] In an optional implementation, the semantic verification result is determined by the first comparison result and the second comparison result, and updating the context translation block according to the semantic verification result to obtain a target context translation block includes:

[0144] For each context translation block,

[0145] When the semantic similarity score corresponding to the context translation block is not less than the set similarity threshold, and the semantic cohesion score corresponding to the context translation block is not less than the set cohesion score threshold, the context translation block is used as the corresponding target context translation block.

[0146] When the semantic similarity score corresponding to the context translation block is less than the set similarity threshold, the first comparison result corresponding to the context translation block is fed back to the context translation model, so that the context translation model updates the context translation block according to the corresponding first comparison result, and uses the updated context translation block as the corresponding target context translation block.

[0147] In a case where the semantic coherence score corresponding to the context translation block is less than the set coherence score threshold, the second comparison result corresponding to the context translation block is fed back to the context translation model, so that the context translation model updates the context translation block according to the corresponding second comparison result, and uses the updated context translation block as the corresponding target context translation block.

[0148] In one example, for a context translation block that needs to be updated, the corresponding first comparison result and / or second comparison result may be input into the context translation model, so that the context translation model updates and adjusts the context translation block that needs to be updated according to the input comparison result, so as to regenerate a context translation block that meets the semantic consistency requirement (semantic similarity requirement and / or semantic cohesion requirement). .

[0149]

[0150] in, Indicates the first comparison result and / or the second comparison result corresponding to the i-th context translation block (the context translation block that needs to be updated).

[0151] In an optional implementation, generating a target language translation result corresponding to the test example based on the target context translation block includes:

[0152] The target context translation blocks are concatenated in the order described above to obtain an initial language translation result.

[0153] The initial language translation result is subjected to a coherence check through the second deep learning model. If the coherence check result indicates that the check is passed, the initial language translation result is used as the target language translation result. Otherwise, the initial language translation result is corrected according to the coherence check result using the context translation model until the corrected initial language translation result passes the coherence check. The initial language translation result that passes the coherence check is used as the target language translation result.

[0154] The coherence detection result includes at least one of the following: a semantic coherence detection result and a grammatical coherence detection result.

[0155] In one example, the target context translation blocks are spliced ​​in the order to obtain the initial language translation result, which may include: first, the target context translation blocks are stored in the order as ,in Indicates target context translation blocks, is the number of target context translation blocks; then, each target context translation block is spliced ​​in order to form a complete initial language translation result The splicing process is:

[0156]

[0157] in, Represents the concatenation operation between translation blocks.

[0158] In one example, the second deep learning model can implement coherence detection by calculating semantic similarity between adjacent target context translation blocks, and / or by detecting grammatical structures between adjacent target context translation blocks.

[0159] In one example, if in the coherence check, adjacent context translation blocks are found and If there is semantic incoherence and / or grammatical incoherence between the contexts, the incoherent context translation blocks will be marked and fed back to the context translation model, so that the context translation module regenerates or adjusts the incoherent context translation blocks according to the feedback. The regenerated context translation blocks The original incoherent context translation block will be replaced and the context translation block will be regenerated. Afterwards, each context translation block is reassembled to obtain a new initial language translation result as the revised initial language translation result, until the initial language translation result that passes the coherence test is used as the target language translation result. :

[0160]

[0161] In this embodiment, the bias of the large language model in machine translation between non-English languages ​​is alleviated by incorporating the inductive bias of monotonicity between related languages, and the decomposition hint method is used to improve the performance of the large language model in machine translation between related languages, especially in the translation of low-resource languages ​​(i.e., languages ​​that are relatively scarce in digital resources, such as text data, annotated data, etc., and lack sufficient training data).

[0162] Some examples are given below.

[0163] This embodiment is evaluated on the Flores dataset (a large-scale multilingual dataset specifically designed for evaluating and improving cross-lingual natural language processing tasks, with a special focus on low-resource languages), and translation comparisons are performed between multiple related languages, including Hindi (hin) and Marathi (mar), Hindi (hin) and Malayalam (mal), Hindi (hin) and Gujarati (guj), Hindi (hin) and Telugu (tel), Indonesian (ind) and Malay (zsm), Ukrainian (ukr) and Russian (rus), Portuguese (por) and Spanish (spa).

[0164] In this embodiment, the number of word units k contained in the first source language word block of a translation example in the multilingual pre-training model is set to 5, and the number of word units n contained in the second source language word block of the prompt translation example in the context translation model is set to 10.

[0165] This embodiment uses automatic evaluation and manual evaluation to evaluate the performance of the method. The automatic evaluation selects spBLEU and chrF++ for evaluation, where spBLEU is a variant of BLEU (Bilingual Evaluation Understudy), which is an automatic evaluation indicator used to measure the similarity between the machine translation output and the reference translation, and chrF++ is an improved version of chrF (Character F-score) used to evaluate the quality of machine translation. chrF++ considers not only character-level n-gram (n-gram is a language model commonly used in large vocabulary continuous speech recognition) matching, but also word-level n-gram matching, thereby providing a more comprehensive evaluation.

[0166] And compared with the established benchmark methods: BLOOM (BigScienceLanguage Open-science Open-access Multilingual Model, an open source model), XGLM (Cross-lingual Generative Model, a generative model), mT5 (Multilingual T5), where BLOOM and XGLM use SP (Standard Prompting, standard prompt strategy), and the mT5 model uses a method that combines the standard prompt strategy SP, SAP (Single Answer Prompting, single answer prompt strategy) method and the method proposed in this embodiment. XSTS (Cross-lingual Semantic Text Similarity) was used for manual evaluation. The test results are shown in Tables 1 to 3 below.

[0167] Table 1: Automatic evaluation spBLUE evaluation results on the Flores test set

[0168]

[0169] Table 2: Automatic evaluation chrF++ evaluation results on the Flores test set

[0170]

[0171] Table 3: Cross-language semantic text similarity evaluation results on the Flores test set

[0172]

[0173] The results of Tables 1 to 3 above show that the performance of this embodiment exceeds that of all other methods in various “low-resource language pairs” (except for the “high-resource language pair” of “Portuguese por and Spanish spa”).

[0174] In summary, the embodiments of the present application have at least the following beneficial effects:

[0175] According to an embodiment of the present application, a translation sample and a test sample are obtained, and a test block matching the test sample is determined, wherein the translation sample includes a sentence pair consisting of a source language sentence and a corresponding target language sentence, the language corresponding to the test sample is the source language, and the target language is a related language of the source language; based on the translation sample and the test block, a first prompt template is generated, and a first independent translation block corresponding to the test block is determined according to the first prompt template; a grammar check is performed on the first independent translation block to correct the first independent translation block according to the grammar check result to obtain a second independent translation block; based on the translation sample and the second independent translation block, a context translation block is generated using a context translation model; based on the context translation block and the test block, semantic verification is performed to update the context translation block according to the semantic verification result to obtain a target context translation block; based on the target context translation block, a target language translation result corresponding to the test sample is generated, so that translation between related languages ​​can be performed efficiently and accurately, and it is ensured that the translated language retains the context semantics of the translated language to retain the intrinsic characteristics of the translated language.

[0176] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary hardware platform, and of course, it can also be implemented entirely by hardware. Based on such an understanding, all or part of the contribution of the technical solution of the present application to the background technology can be embodied in the form of a software product, and the computer software product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application or some parts of the embodiments.

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

Claims

1. A machine translation method based on related languages, characterized in that: include: Obtaining a translation sample and a test sample, and determining a test block matching the test sample, wherein the translation sample includes a sentence pair consisting of a source language sentence and a corresponding target language sentence, the language corresponding to the test sample is the source language, and the target language is a relative language of the source language; Based on the translation sample and the test block, generate a first prompt template, and determine a first independent translation block corresponding to the test block according to the first prompt template; Performing grammar detection on the first independent translation block to modify the first independent translation block according to the grammar detection result to obtain a second independent translation block; Based on the translation example and the second independent translation block, generating a context translation block using a context translation model; Based on the context translation block and the test block, semantic verification is performed to update the context translation block according to the semantic verification result to obtain a target context translation block; Generating a target language translation result corresponding to the test example based on the target context translation block; The test example is decomposed into a plurality of the test blocks, and the first prompt template is generated based on the translation example and the test block, and the first independent translation block corresponding to the test block is determined according to the first prompt template, including: Based on each test block and the translation example, construct a first prompt template corresponding to each test block; Each first prompt template is input into a pre-configured multi-language pre-training model for translation, and a first independent translation block corresponding to each test block is obtained.

2. The machine translation method based on related languages ​​as claimed in claim 1, characterized in that: The multilingual pre-trained model includes a first mT5 model.

3. The machine translation method based on related languages ​​as claimed in claim 2, characterized in that: The source language sentence includes a plurality of first source language word blocks, the target language sentence includes a plurality of first target language word blocks corresponding to the plurality of first source language word blocks one by one, and constructing a first prompt template corresponding to each test block based on each test block and the translation sample includes: splicing each first source language word block and its corresponding first target language word block to construct an independent translation prompt template corresponding to each first source language word block; Based on the independent translation prompt templates corresponding to the plurality of first source language word blocks and each test block, a first prompt template corresponding to each test block is constructed.

4. The machine translation method based on related languages ​​as claimed in claim 2, characterized in that: The step of performing grammar detection on the first independent translation block to correct the first independent translation block according to the grammar detection result to obtain a second independent translation block includes: Using a first deep learning model, according to a target grammar rule used in a target language, a grammar check is performed on each first independent translation block to obtain a corresponding grammar check result, wherein the first deep learning model includes a RoBERTa model; For each first independent translation block, if the grammar detection result corresponding to the first independent translation block indicates the existence of a grammatical error, a grammar annotation result matching the existing grammatical error is generated, and the grammar annotation result is fed back to the multilingual pre-training model, so that the multilingual pre-training model corrects the first independent translation block according to the grammar annotation result to obtain a second independent translation block corresponding to the first independent translation block; if the grammar error does not exist, the first independent translation block is used as the corresponding second independent translation block.

5. The machine translation method based on related languages ​​as claimed in claim 1, characterized in that: The test sample is decomposed into a plurality of test blocks having a sequence, wherein the sequence is determined by a text structure of a text indicated by the test sample, and the context translation block is generated by using a context translation model based on the translation sample and the second independent translation block, including: For each test block, at least based on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, and the translation examples, construct a second prompt template corresponding to the test block; The context translation model is used to perform context translation based on the second prompt template corresponding to each test block to generate a context translation block corresponding to each test block, wherein the context translation model includes a second mT5 model.

6. The machine translation method based on related languages ​​as claimed in claim 5, characterized in that: The step of constructing a second prompt template corresponding to the test block based at least on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, and the translation sample includes: Based on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, the translation examples, and the context translation block corresponding to the previous test block of the test block, a second prompt template corresponding to the test block is constructed.

7. The machine translation method based on related languages ​​as claimed in claim 6, characterized in that: The source language sentence includes a plurality of second source language word blocks, and the target language sentence includes a plurality of second target language word blocks corresponding to the plurality of second source language word blocks one by one; the second prompt template corresponding to the test block is constructed based on the test block and its adjacent test blocks, the second independent translation blocks corresponding to the test block and its adjacent test blocks, the translation sample, and the context translation block corresponding to the previous test block of the test block, including: splicing each second source language word block and its corresponding second target language word block to construct a context translation prompt template corresponding to each second source language word block; Based on the context translation prompt templates corresponding to each of the several second source language word blocks, the test block and its adjacent test blocks, the second independent translation blocks corresponding to each of the test block and its adjacent test blocks, and the context translation block corresponding to the previous test block of the test block, a second prompt template corresponding to the test block is constructed.

8. The machine translation method based on related languages ​​as claimed in claim 5, characterized in that: The performing semantic verification based on the context translation block and the test block includes: Determining a semantic similarity score between each test block and its corresponding context translation block by a second deep learning model, wherein the second deep learning model comprises a Sentence-BERT model; For each test block, determining the semantic cohesion between the context translation block corresponding to the test block and the context translation block corresponding to the previous test block through the second deep learning model, as the semantic cohesion score corresponding to the test block; The semantic verification result is determined based on a first comparison result between the semantic similarity score corresponding to each context translation block and a set similarity threshold, and / or a second comparison result between the semantic cohesion score corresponding to each context translation block and a set cohesion score threshold.

9. The machine translation method based on related languages ​​as claimed in claim 8, characterized in that: The semantic verification result is determined by the first comparison result and the second comparison result, and the updating of the context translation block according to the semantic verification result to obtain a target context translation block includes: For each context translation block, When the semantic similarity score corresponding to the context translation block is not less than the set similarity threshold, and the semantic cohesion score corresponding to the context translation block is not less than the set cohesion score threshold, the context translation block is used as the corresponding target context translation block; When the semantic similarity score corresponding to the context translation block is less than the set similarity threshold, feeding back the first comparison result corresponding to the context translation block to the context translation model, so that the context translation model updates the context translation block according to the corresponding first comparison result, and uses the updated context translation block as the corresponding target context translation block; In a case where the semantic coherence score corresponding to the context translation block is less than the set coherence score threshold, the second comparison result corresponding to the context translation block is fed back to the context translation model, so that the context translation model updates the context translation block according to the corresponding second comparison result, and uses the updated context translation block as the corresponding target context translation block.

10. The machine translation method based on related languages ​​as claimed in claim 5, characterized in that: The generating a target language translation result corresponding to the test example based on the target context translation block includes: splicing the target context translation blocks in the order described above to obtain an initial language translation result; Performing a coherence test on the initial language translation result by using a second deep learning model; if the coherence test result indicates that the test is passed, taking the initial language translation result as the target language translation result; otherwise, correcting the initial language translation result by using the contextual translation model according to the coherence test result until the corrected initial language translation result passes the coherence test, and taking the initial language translation result that passes the coherence test as the target language translation result; The coherence detection result includes at least one of the following: a semantic coherence detection result and a grammatical coherence detection result.

Citation Information

Patent Citations

  • Method for machine translation, device and medium

    CN113887253A

  • Translation processing method and device under large model, storage medium and electronic equipment

    CN117744670A