Large model robust machine translation method, device and equipment based on context
Processing parallel data through similarity algorithms and large models solves the problem of insufficient accuracy and robustness of traditional translation methods, improves translation quality and robustness, and performs particularly well in domain adaptation, solving the problem of noise interference.
Patent Information
- Application Number
- CN202410607652.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-16
- Publication Date
- 2024-08-23
AI Technical Summary
Traditional translation methods have low accuracy and poor robustness, and cannot meet the growing needs for cross-language communication. Especially in large models, it is difficult to select noisy data and the domain adaptation challenges are great.
By obtaining the text to be translated and the source text, using similarity algorithms to process sentences and words, combined with large models to process parallel sentence pairs and word pairs, and selecting effective demonstration data to improve translation quality and robustness and reduce noise interference.
It improves the translation quality and robustness of large models, especially in domain adaptation, which effectively avoids noise interference and improves translation accuracy and fluency.
Smart Images

Figure CN118536518A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of natural language processing and machine learning, and more specifically, to a context-based large-model robust machine translation method, apparatus, and device. Background Art
[0002] With the popularization of the Internet and the acceleration of globalization, the demand for cross-language communication and translation in all walks of life is growing. Traditional translation methods have problems with low accuracy and poor robustness, and cannot meet the growing demand for translation. Recent studies usually use large models for translation through contextual learning. However, the inventors found that since the retrieved demonstration data often contains noise, how to select effective demonstration data becomes a key issue. In addition, although large models perform well in translation tasks, there are still challenges in specific scenarios. Summary of the invention
[0003] In view of the above problems, the present disclosure provides a context-based large-model robust machine translation method, apparatus and device.
[0004] According to a first aspect of the present disclosure, a context-based large-model robust machine translation method is provided, comprising: obtaining a text to be translated and a source text, wherein the text to be translated includes a sentence to be translated, the source text includes a source sentence, the sentence to be translated includes a word to be translated, and the source sentence includes an intermediate source word; processing the sentence to be translated and the source sentence using a similarity algorithm to obtain sentence similarity; determining parallel sentence pairs from a parallel corpus based on the sentence similarity, wherein the parallel corpus includes a source text and a source translation corresponding to the source text, and the parallel sentence pairs include an intermediate source sentence matching the sentence to be translated, and an intermediate source translation sentence corresponding to the intermediate source sentence; determining a target source word and a target source translation word matching the word to be translated based on the similarity between the word to be translated and the intermediate source translation word, and the similarity between the intermediate source translation word and the intermediate source word, wherein the intermediate source sentence includes the intermediate source word, and the intermediate source translation sentence includes the intermediate source translation word; processing the parallel sentence pairs, the parallel word pairs and the text to be translated using a large model to obtain a target translation, wherein the parallel word pairs include associated target source words and target source translation words.
[0005] According to an embodiment of the present disclosure, a sentence to be translated and a source sentence are processed using a similarity algorithm to obtain sentence similarity, including: using a similarity algorithm to process the sentence to be translated, the source sentence, and the first K sentences in a parallel corpus that have the highest similarity to the sentence to be translated, to obtain an average similarity between the sentence to be translated and the first K sentences, K>0; processing the sentence to be translated and the source sentence based on the similarity algorithm to obtain candidate similarities; and obtaining sentence similarity based on the average similarity and the candidate similarities.
[0006] According to an embodiment of the present disclosure, sentence similarity is obtained based on average similarity and candidate similarity, including: comparing the candidate similarity with the average similarity to obtain a first similarity; subtracting the average similarity from the candidate similarity to obtain a second similarity; and obtaining sentence similarity based on the first similarity and the second similarity.
[0007] According to an embodiment of the present disclosure, parallel sentence pairs are determined from a parallel corpus based on sentence similarity, including: when the sentence similarity meets a preset threshold, an intermediate source sentence and an intermediate source translation sentence corresponding to the sentence similarity are determined as parallel sentence pairs from the parallel corpus.
[0008] According to an embodiment of the present disclosure, based on the similarity between the word to be translated and the intermediate source translation word, and the similarity between the intermediate source translation word and the intermediate source word, a target source word and a target source translation word matching the word to be translated are determined, including: processing the i-th word to be translated and the j-th intermediate source translation word based on a similarity method to obtain a first word similarity; processing the j-th intermediate source translation word and the m-th intermediate source word based on a similarity method to obtain a second word similarity; and determining the target source word and the target source translation word according to the first word similarity and the second word similarity.
[0009] According to an embodiment of the present disclosure, a large model is used to process parallel sentence pairs, parallel word pairs and text to be translated to obtain a target translation, including: updating a prompt template based on the parallel sentence pairs, parallel word pairs and text to be translated to obtain prompt information; and using the large model to process the prompt information to obtain a target translation corresponding to the text to be translated.
[0010] A second aspect of the present disclosure provides a context-based large model robust machine translation device, comprising:
[0011] An acquisition module, used for acquiring a text to be translated and a source text, wherein the text to be translated includes a sentence to be translated, the source text includes a source sentence, the sentence to be translated includes words to be translated, and the source sentence includes an intermediate source word;
[0012] A processing module, used for processing the sentence to be translated and the source sentence using a similarity algorithm to obtain sentence similarity;
[0013] A determination module, configured to determine parallel sentence pairs from a parallel corpus based on sentence similarity, wherein the parallel corpus includes a source text and a source translation corresponding to the source text, and the parallel sentence pairs include an intermediate source sentence matching the sentence to be translated, and an intermediate source translation sentence corresponding to the intermediate source sentence;
[0014] a target determination module, for determining a target source word and a target source translation word matching the word to be translated based on the similarity between the word to be translated and the intermediate source translation word, and the similarity between the intermediate source translation word and the intermediate source word, wherein the intermediate source sentence includes the intermediate source word, and the intermediate source translation sentence includes the intermediate source translation word;
[0015] The target translation obtaining module is used to use the large model to process parallel sentence pairs, parallel word pairs and text to be translated to obtain the target translation. The parallel word pairs include associated target source words and target source translation words.
[0016] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above method.
[0017] The fourth aspect of the present disclosure also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above method.
[0018] The fifth aspect of the present disclosure also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0019] According to the embodiment of the present disclosure, by obtaining the text to be translated and the source text, using the similarity algorithm to process the sentences to be translated and the source sentences, obtaining the sentence similarity, determining the parallel sentence pairs from the parallel corpus based on the sentence similarity, determining the target source words and the target source translation words matching the words to be translated based on the similarity between the words to be translated and the intermediate source translation words, and the similarity between the intermediate source translation words and the intermediate source words, using the large model to process the parallel sentence pairs, parallel word pairs and the text to be translated, obtaining the target translation, combining the sentence-level and word-level information between the text to be translated, the source text and the target translation in the processing process, selecting effective demonstration data in a multi-perspective manner, improving the translation quality and robustness of the large model, and effectively avoiding noise interference. . BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0021] Figure 1 The application scenario diagram of the context-based large model robust machine translation method, apparatus and device according to the embodiment of the present disclosure is schematically shown;
[0022] Figure 2 A flowchart of a context-based large model robust machine translation method according to an embodiment of the present disclosure is schematically shown;
[0023] Figure 3 A flowchart of a method for obtaining a target source word and a target source translated word according to an embodiment of the present disclosure is schematically shown;
[0024] Figure 4A structural block diagram of a context-based large model robust machine translation device according to an embodiment of the present disclosure is schematically shown; and
[0025] Figure 5 A block diagram of an electronic device suitable for implementing a context-based large-model robust machine translation method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0026] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0027] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0028] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0029] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0030] With the popularization of the Internet and the acceleration of globalization, the demand for cross-language communication and translation in all walks of life is growing. Especially in the business field, with the increase of cross-border trade and international cooperation, companies need to process information from different languages and cultural backgrounds. Previous translation systems usually adopted statistical learning methods. In recent years, researchers have begun to explore the use of large language models (LLMs) for machine translation. LLMs have powerful language understanding and generation capabilities, and can learn the structure and laws of language through large-scale corpora. Compared with traditional statistical machine translation methods, LLMs can better capture contextual information and improve the accuracy and fluency of translation.
[0031] Traditional translation methods have problems with low accuracy and poor robustness, and cannot meet the growing demand for translation. Recent studies often use LLMs for translation through contextual learning. The core idea is to select demonstration data in a parallel corpus to guide the translation process without updating the LLMs. However, since the retrieved demonstration data often contains noise, how to select effective demonstration data becomes a key issue. In addition, although LLMs perform well in translation tasks, there are still challenges in specific scenarios, such as domain adaptation.
[0032] In view of this, the present disclosure provides a context-based large model robust machine translation method, device, electronic device and medium, the method comprising: obtaining a text to be translated and a source text, wherein the text to be translated includes a sentence to be translated, the source text includes a source sentence, the sentence to be translated includes a word to be translated, and the source sentence includes an intermediate source word; using a similarity algorithm to process the sentence to be translated and the source sentence to obtain sentence similarity; based on the sentence similarity, determining parallel sentence pairs from a parallel corpus, wherein the parallel corpus includes a source text and a source translation corresponding to the source text, the parallel sentence pairs include an intermediate source sentence matching the sentence to be translated, and an intermediate source translation sentence corresponding to the intermediate source sentence; based on the similarity between the word to be translated and the intermediate source translation word, and the similarity between the intermediate source translation word and the intermediate source word, determining a target source word and a target source translation word matching the word to be translated, the intermediate source sentence includes an intermediate source word, and the intermediate source translation sentence includes an intermediate source translation word; using a large model to process the parallel sentence pairs, the parallel word pairs and the text to be translated to obtain a target translation, the parallel word pairs include associated target source words and target source translation words.
[0033] It should be noted that the context-based large-model robust machine translation method and device provided in the present disclosure can be used in the field of natural language processing, and can also be used in any field other than the field of natural language processing, such as machine learning and other fields. The application field of the context-based large-model robust machine translation method and device provided in the present disclosure is not limited.
[0034] In the technical solution of the present disclosure, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0035] Figure 1 The application scenario diagram of the context-based large-model robust machine translation method according to an embodiment of the present disclosure is schematically shown.
[0036] like Figure 1 As shown, the application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0037] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0038] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0039] The server 105 may be a server that provides various services, such as a background management server (only an example) that provides support for websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0040] It should be noted that the context-based large-model robust machine translation method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the context-based large-model robust machine translation device provided in the embodiment of the present disclosure can generally be set in the server 105. The context-based large-model robust machine translation method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the context-based large-model robust machine translation device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0041] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0042] The following will be based on Figure 1 The scene described by Figure 2 and Figure 3 A context-based large-model robust machine translation method of the disclosed embodiment is described in detail.
[0043] Figure 2 The flowchart of the context-based large model robust machine translation method according to an embodiment of the present disclosure is schematically shown.
[0044] like Figure 2 As shown, the context-based large model robust machine translation method of this embodiment includes operations S210 to S250.
[0045] In operation S210, a text to be translated and a source text are obtained.
[0046] In operation S220, the sentence to be translated and the source sentence are processed using a similarity algorithm to obtain sentence similarity.
[0047] In operation S230 , parallel sentence pairs are determined from the parallel corpus based on sentence similarities.
[0048] In operation S240 , based on the similarity between the word to be translated and the intermediate source translation word, and the similarity between the intermediate source translation word and the intermediate source word, a target source word and a target source translation word matching the word to be translated are determined.
[0049] In operation S250, the parallel sentence pairs, parallel word pairs and the text to be translated are processed using the large model to obtain a target translation, wherein the parallel word pairs include associated target source words and target source translation words.
[0050] According to an embodiment of the present disclosure, a text to be translated and a source text can be obtained, and a parallel corpus can include text data sets in two or more different languages, and there is a one-to-one correspondence relationship between these texts, that is, a sentence in one text can correspond to a sentence in another text. The parallel corpus can include a source text and a source translation corresponding to the source text. The text to be translated can include multiple sentences to be translated, the source text can include multiple source sentences, the sentence to be translated can include multiple words to be translated, and the source sentence can include multiple intermediate source words.
[0051] It should be noted that the text to be translated and the source text in the embodiments of the present disclosure may be texts in the same language, and the text to be translated and the target translation may be texts in different languages, for example, the text to be translated and the source text are in Chinese, and the target translation is in English.
[0052] According to an embodiment of the present disclosure, a similarity algorithm can be used to process a sentence to be translated and a source sentence to obtain sentence similarity between the sentence to be translated and the source sentence. Based on the sentence similarity between the sentence to be translated and multiple source sentences, parallel sentence pairs can be determined from a parallel corpus.
[0053] According to an embodiment of the present disclosure, a parallel sentence pair may include an intermediate source sentence matching the sentence to be translated, and an intermediate source translation sentence corresponding to the intermediate source sentence. The intermediate source sentence may include intermediate source words, and the intermediate source translation sentence may include intermediate source translation words.
[0054] According to an embodiment of the present disclosure, a target source word and a target source translation word matching the word to be translated can be determined based on the similarity between the word to be translated and the intermediate source translation word, and the similarity between the intermediate source translation word and the intermediate source word. The higher the frequency of word overlap between the sentence to be translated and the source sentence, the more similar the source sentence is to the sentence to be translated, thereby effectively improving the translation quality of the large model, so that the consistency of the word-level information can be considered while ensuring the consistency of the sentence-level similarity.
[0055] According to an embodiment of the present disclosure, a large model can be used to process parallel sentence pairs, parallel word pairs and text to be translated to obtain a target translation. Parallel word pairs may include associated target source words and target source translation words. By calculating the similarity at the sentence level and the similarity between words, the consistency at the sentence and word levels between the text to be translated, the source text and the target translation is ensured. At the same time, the weight of irrelevant word pairs is reduced, while the overall semantics of the sentence is retained, effectively alleviating the noise disturbance problem.
[0056] According to an embodiment of the present disclosure, by obtaining a text to be translated and a source text, a similarity algorithm is used to process sentences to be translated and source sentences to obtain sentence similarity, and based on the sentence similarity, parallel sentence pairs are determined from a parallel corpus, and based on the similarity between the words to be translated and intermediate source translation words, and the similarity between the intermediate source translation words and the intermediate source words, target source words and target source translation words that match the words to be translated are determined, and a large model is used to process parallel sentence pairs, parallel word pairs and text to be translated to obtain a target translation. In the process of processing, sentence-level and word-level information between the text to be translated, the source text and the target translation are combined, and effective demonstration data is selected in a multi-perspective manner, thereby improving the translation quality and robustness of the large model and effectively avoiding noise interference.
[0057] According to an embodiment of the present disclosure, a sentence to be translated and a source sentence are processed using a similarity algorithm to obtain sentence similarity, including: using a similarity algorithm to process the sentence to be translated, the source sentence, and the first k sentences in a parallel corpus that have the highest similarity to the sentence to be translated to obtain an average similarity between the sentence to be translated and the first k sentences, k>0; processing the sentence to be translated and the source sentence based on the similarity algorithm to obtain candidate similarities; and obtaining sentence similarity based on the average similarity and the candidate similarities.
[0058] According to an embodiment of the present disclosure, a similarity algorithm can be used to process the sentence to be translated, the source sentence and the first k sentences in the parallel corpus with the highest similarity to the sentence to be translated, and the average similarity between the sentence to be translated and the first k sentences can be obtained, as shown in formula (1).
[0059]
[0060] Among them, sNN(x, x′) is the average similarity between the sentence to be translated and the previous k sentences, x is the sentence to be translated, x′ is the source sentence, and z is the previous k sentences in the parallel corpus with the highest similarity to the sentence to be translated x.
[0061] According to an embodiment of the present disclosure, the sentence to be translated and the source sentence can be processed based on a similarity algorithm to obtain candidate similarities, as shown in formula (2).
[0062] can(x,x′)=cos(x,x′) (2)
[0063] Among them, can(x, x′) is the candidate similarity between the sentence to be translated and the source sentence, and cos(x, x′) is the cosine similarity between the sentence to be translated x and the source sentence x′.
[0064] According to the embodiments of the present disclosure, high-quality context examples can significantly improve translation capabilities, so how to select context examples is crucial, and sentence similarity can be obtained based on average similarity and candidate similarity.
[0065] According to an embodiment of the present disclosure, sentence similarity is obtained based on average similarity and candidate similarity, including: comparing the candidate similarity with the average similarity to obtain a first similarity; subtracting the average similarity from the candidate similarity to obtain a second similarity; and obtaining sentence similarity based on the first similarity and the second similarity.
[0066] According to an embodiment of the present disclosure, the candidate similarity can be compared with the average similarity to obtain a first similarity, as shown in formula (3).
[0067] score1(x, x′)=can(x, x′) / sNN(x, x′) (3)
[0068] Wherein, score1(x, x′) represents the first similarity between the sentence to be translated and the source sentence.
[0069] According to an embodiment of the present disclosure, the average similarity may be subtracted from the candidate similarity to obtain a second similarity, as shown in formula (4).
[0070] score2(x, x′)=can(x, x′)-sNN(x, x′) (4)
[0071] Wherein, score2(x, x′) represents the second similarity between the sentence to be translated and the source sentence.
[0072] According to an embodiment of the present disclosure, the closer the ratio of the first similarity is to 1, the more similar the sentence to be translated and the source sentence are. The closer the difference of the second similarity is to 0, the more similar the sentence to be translated and the source sentence are. The sentence similarity can be obtained based on the first similarity and the second similarity.
[0073] According to an embodiment of the present disclosure, parallel sentence pairs are determined from a parallel corpus based on sentence similarity, including: when the sentence similarity meets a preset threshold, an intermediate source sentence and an intermediate source translation sentence corresponding to the sentence similarity are determined as parallel sentence pairs from the parallel corpus.
[0074] According to an embodiment of the present disclosure, when the sentence similarity meets a preset threshold, the intermediate source sentence and the intermediate source translation sentence corresponding to the sentence similarity can be determined as a parallel sentence pair from the parallel corpus. For example, the preset threshold can be set to 1.5, the first similarity obtained and the second similarity obtained can be added, and the obtained value can be compared with the preset threshold, thereby, the sentence similarity less than or equal to the preset threshold can be selected, and finally the intermediate source sentence and the intermediate source translation sentence corresponding to the sentence similarity can be determined as a parallel sentence pair from the parallel corpus. However, it is not limited to this, and the embodiment of the present disclosure does not limit the specific numerical value of the preset threshold. If there are multiple sentence similarities that meet the conditions, the first similarity can be used as the main one, and the intermediate source sentence and the intermediate source translation sentence whose first similarity is closer to 1 can be determined as a parallel sentence pair.
[0075] Figure 3 The flowchart of the method for obtaining target source words and target source translated words according to an embodiment of the present disclosure is schematically shown.
[0076] like Figure 3 As shown, the method for obtaining a target source word and a target source translated word in this embodiment includes operations S310 to S330.
[0077] In operation S310, the i-th word to be translated and the j-th intermediate source translation word are processed based on a similarity method to obtain a first word similarity.
[0078] In operation S320, the jth intermediate source translation word and the mth intermediate source word are processed based on a similarity method to obtain a second word similarity.
[0079] In operation S330 , a target source word and a target source translation word are determined according to the first word similarity and the second word similarity.
[0080] According to an embodiment of the present disclosure, the i-th word to be translated and the j-th intermediate source translation word may be processed based on a similarity method to obtain a first word similarity, as shown in formula (5).
[0081]
[0082] in, It is represented as the first word similarity, represents the i-th word to be translated, Represented as the jth intermediate source translation word.
[0083] According to an embodiment of the present disclosure, the jth intermediate source translation word and the mth intermediate source word may be processed based on a similarity method to obtain a second word similarity, as shown in formula (6).
[0084]
[0085] in, It is represented as the second word similarity, is represented as the jth intermediate source translation word, Represented as the mth middle source word.
[0086] According to an embodiment of the present disclosure, the target source word and the target source translation word can be determined according to the first word similarity and the second word similarity. The first word similarity can be calculated first, and when the first word similarity meets the first set value, it can be determined that the i-th word to be translated and the j-th intermediate source translation word are similar, and on the basis that the i-th word to be translated and the j-th intermediate source translation word are similar, the second word similarity is calculated, and when the second word similarity meets the second set value, it can be determined that the j-th intermediate source translation word and the m-th intermediate source word are corresponding, thereby determining the m-th intermediate source word and the j-th intermediate source translation word as the target source word and the target source translation word.
[0087] According to an embodiment of the present disclosure, a large model is used to process parallel sentence pairs, parallel word pairs and text to be translated to obtain a target translation, including: updating a prompt template based on the parallel sentence pairs, parallel word pairs and text to be translated to obtain prompt information; and using the large model to process the prompt information to obtain a target translation corresponding to the text to be translated.
[0088] According to an embodiment of the present disclosure, the prompt template can be updated based on parallel sentence pairs, parallel word pairs, and text to be translated to obtain prompt information, as shown in formula (7).
[0089]
[0090] Among them, psrc is the language to be translated, ptgt is the target translation language, x′1 is the source sentence in the parallel sentence pair, and y′1 is the source translation in the parallel sentence pair. is the source word in a parallel word pair. is the source translation word in the parallel word pair, and x is the sentence to be translated.
[0091] According to an embodiment of the present disclosure, a large language model can be used to process prompt information to obtain a target translation corresponding to the text to be translated. The prompt template shown in Formula 7 can be used to guide the large language model to generate a translation.
[0092] According to the embodiments of the present disclosure, by adopting a multi-perspective approach to select effective sample data for a large language model, the information at the sentence level and word level between the text to be translated, the source text, and the target translation can be combined, and related words can be added to the prompt template, so that higher weights can be assigned to related word pairs in the demonstration, and the weights of irrelevant word pairs can be reduced, while retaining the overall semantics of the sentence, which can effectively alleviate the noise disturbance problem in the translation process, improve translation accuracy and fluency, and have significant advantages in domain adaptation. The experimental results are shown in Table 1.
[0093] Table 1 Experimental results
[0094]
[0095] The experimental results include three different methods, and the experiments were conducted in four different fields. Compared with the two similarity-based methods RM25 and Fuzzy, the method proposed in this disclosure has a significant improvement and has a significant advantage in field adaptation.
[0096] Based on the above-mentioned context-based large model robust machine translation method, the present disclosure also provides a context-based large model robust machine translation device. Figure 4 The device is described in detail.
[0097] Figure 4 The structural block diagram of a context-based large-model robust machine translation apparatus according to an embodiment of the present disclosure is schematically shown.
[0098] like Figure 4 As shown, the context-based large model robust machine translation device 400 of this embodiment includes an acquisition module 410 , a processing module 420 , a determination module 430 , a target determination module 440 and a target translation obtaining module 450 .
[0099] The acquisition module 410 is used to acquire the text to be translated and the source text, wherein the text to be translated includes the sentence to be translated, the source text includes the source sentence, the sentence to be translated includes the words to be translated, and the source sentence includes the intermediate source word. In one embodiment, the acquisition module 410 can be used to perform the operation S210 described above, which will not be repeated here.
[0100] The processing module 420 is used to process the sentence to be translated and the source sentence using a similarity algorithm to obtain sentence similarity.
[0101] The determination module 430 is used to determine parallel sentence pairs from a parallel corpus based on sentence similarity, wherein the parallel corpus includes a source text and a source translation corresponding to the source text, and the parallel sentence pairs include an intermediate source sentence matching the sentence to be translated, and an intermediate source translation sentence corresponding to the intermediate source sentence.
[0102] The target determination module 440 is used to determine the target source word and the target source translation word that match the word to be translated based on the similarity between the word to be translated and the intermediate source translation word, and the similarity between the intermediate source translation word and the intermediate source word, the intermediate source sentence includes the intermediate source word, and the intermediate source translation sentence includes the intermediate source translation word.
[0103] The target translation obtaining module 450 is used to use the large model to process parallel sentence pairs, parallel word pairs and the text to be translated to obtain the target translation, wherein the parallel word pairs include associated target source words and target source translation words.
[0104] According to an embodiment of the present disclosure, by obtaining a text to be translated and a source text, a similarity algorithm is used to process sentences to be translated and source sentences to obtain sentence similarity, and based on the sentence similarity, parallel sentence pairs are determined from a parallel corpus, and based on the similarity between the words to be translated and intermediate source translation words, and the similarity between the intermediate source translation words and the intermediate source words, target source words and target source translation words that match the words to be translated are determined, and a large model is used to process parallel sentence pairs, parallel word pairs and text to be translated to obtain a target translation. In the process of processing, sentence-level and word-level information between the text to be translated, the source text and the target translation are combined, and effective demonstration data is selected in a multi-perspective manner, thereby improving the translation quality and robustness of the large model and effectively avoiding noise interference.
[0105] According to an embodiment of the present disclosure, the processing module 420 includes: an average similarity obtaining unit, a candidate similarity obtaining unit and a sentence similarity obtaining unit.
[0106] The average similarity obtaining unit is used to process the sentence to be translated, the source sentence and the first K sentences in the parallel corpus with the highest similarity to the sentence to be translated using a similarity algorithm to obtain the average similarity between the sentence to be translated and the first K sentences, K>0.
[0107] The candidate similarity obtaining unit is used to process the sentence to be translated and the source sentence based on the similarity algorithm to obtain the candidate similarity.
[0108] The sentence similarity obtaining unit is used to obtain the sentence similarity according to the average similarity and the candidate similarity.
[0109] According to an embodiment of the present disclosure, the sentence similarity obtaining unit includes: a first subunit, a second subunit and a sentence similarity subunit.
[0110] The first subunit is used to add the candidate similarity to the average similarity to obtain a first similarity.
[0111] The second subunit is used to subtract the average similarity from the candidate similarity to obtain a second similarity.
[0112] The sentence similarity subunit is used to obtain the sentence similarity according to the first similarity and the second similarity.
[0113] According to an embodiment of the present disclosure, the determination module 430 includes: a parallel sentence pair determination unit.
[0114] The parallel sentence pair determination unit is used to determine the intermediate source sentence and the intermediate source translation sentence corresponding to the sentence similarity from the parallel corpus as a parallel sentence pair when the sentence similarity meets a preset threshold.
[0115] According to an embodiment of the present disclosure, the target determination module 440 includes: a first word unit, a second word unit and a translation word determination unit.
[0116] The first word unit is used to process the i-th word to be translated and the j-th intermediate source translation word based on a similarity method to obtain a first word similarity.
[0117] The second word unit is used to process the j-th intermediate source translation word and the m-th intermediate source word based on the similarity method to obtain the second word similarity.
[0118] The translation word determination unit is used to determine the target source word and the target source translation word according to the first word similarity and the second word similarity.
[0119] According to an embodiment of the present disclosure, the target translation obtaining module 450 includes: a prompt information unit and a target translation unit.
[0120] The prompt information unit is used to update the prompt template based on the parallel sentence pairs, parallel word pairs and the text to be translated to obtain prompt information.
[0121] The target translation unit is used to process the prompt information using the large model to obtain a target translation corresponding to the text to be translated.
[0122] According to an embodiment of the present disclosure, any multiple modules among the acquisition module 410, the processing module 420, the determination module 430, the target determination module 440 and the target translation obtaining module 450 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the acquisition module 410, the processing module 420, the determination module 430, the target determination module 440 and the target translation obtaining module 450 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation modes of software, hardware and firmware or in a suitable combination of any of them. Alternatively, at least one of the acquisition module 410, the processing module 420, the determination module 430, the target determination module 440 and the target translation obtaining module 450 may be at least partially implemented as a computer program module, and when the computer program module is executed, the corresponding function may be executed.
[0123] Figure 5A block diagram of an electronic device suitable for implementing a context-based large-model robust machine translation method according to an embodiment of the present disclosure is schematically shown.
[0124] like Figure 5 As shown, the electronic device 500 according to an embodiment of the present disclosure includes a processor 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. The processor 501 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include an onboard memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0125] In RAM 503, various programs and data required for the operation of electronic device 500 are stored. Processor 501, ROM 502 and RAM 503 are connected to each other via bus 504. Processor 501 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 502 and / or RAM 503. It should be noted that the program can also be stored in one or more memories other than ROM 502 and RAM 503. Processor 501 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0126] According to an embodiment of the present disclosure, the electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to the bus 504. The electronic device 500 may further include one or more of the following components connected to the I / O interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 508 including a hard disk, etc.; and a communication portion 509 including a network interface card such as a LAN card, a modem, etc. The communication portion 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage portion 508 as needed.
[0127] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0128] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 502 and / or RAM 503 described above and / or one or more memories other than ROM 502 and RAM 503.
[0129] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the context-based large model robust machine translation method provided by the embodiment of the present disclosure.
[0130] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 501. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0131] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 509, and / or installed from the removable medium 511. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0132] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the processor 501, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0133] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0134] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0135] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0136] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A context-based large model robust machine translation method, characterized in that: The method comprises: Acquire a text to be translated and a source text, wherein the text to be translated includes a sentence to be translated, the source text includes a source sentence, the sentence to be translated includes words to be translated, and the source sentence includes an intermediate source word; Processing the sentence to be translated and the source sentence using a similarity algorithm to obtain sentence similarity; Based on the sentence similarity, determining parallel sentence pairs from a parallel corpus, wherein the parallel corpus includes the source text and a source translation corresponding to the source text, and the parallel sentence pairs include an intermediate source sentence matching the sentence to be translated, and an intermediate source translation sentence corresponding to the intermediate source sentence; Determining a target source word and a target source translation word matching the word to be translated based on the similarity between the word to be translated and the intermediate source translation word, and the similarity between the intermediate source translation word and the intermediate source word, the intermediate source sentence including the intermediate source word, and the intermediate source translation sentence including the intermediate source translation word; The parallel sentence pairs, parallel word pairs and the text to be translated are processed using a large model to obtain a target translation, so as to implement a context-based large model robust machine translation method, wherein the parallel word pairs include the associated target source words and the target source translation words.
2. The method according to claim 1, characterized in that The using a similarity algorithm to process the sentence to be translated and the source sentence to obtain sentence similarity includes: Using the similarity algorithm to process the sentence to be translated, the source sentence, and the first K sentences in the parallel corpus that have the highest similarity to the sentence to be translated, to obtain an average similarity between the sentence to be translated and the first K sentences, K>0; Processing the sentence to be translated and the source sentence based on the similarity algorithm to obtain candidate similarities; The sentence similarity is obtained according to the average similarity and the candidate similarities.
3. The method according to claim 2, characterized in that The obtaining the sentence similarity according to the average similarity and the candidate similarity includes: Compare the candidate similarity with the average similarity to obtain a first similarity; Subtract the average similarity from the candidate similarity to obtain a second similarity; The sentence similarity is obtained according to the first similarity and the second similarity.
4. The method according to claim 1, characterized in that: Determining parallel sentence pairs from a parallel corpus based on the sentence similarity includes: When the sentence similarity satisfies a preset threshold, the intermediate source sentence and the intermediate source translation sentence corresponding to the sentence similarity are determined from the parallel corpus as the parallel sentence pair.
5. The method according to claim 1, characterized in that The determining of the target source word and the target source translation word matching the word to be translated based on the similarity between the word to be translated and the intermediate source translation word, and the similarity between the intermediate source translation word and the intermediate source word, comprises: Processing the i-th word to be translated and the j-th intermediate source translation word based on the similarity method to obtain a first word similarity; Processing the j-th intermediate source translation word and the m-th intermediate source word based on the similarity method to obtain a second word similarity; The target source word and the target source translated word are determined according to the first word similarity and the second word similarity.
6. The method according to claim 1, characterized in that The method of using the large model to process the parallel sentence pairs, the parallel word pairs and the text to be translated to obtain a target translation includes: Based on the parallel sentence pairs, the parallel word pairs, and the text to be translated, a prompt template is updated to obtain prompt information; and The prompt information is processed using the large model to obtain the target translation corresponding to the text to be translated.
7. A context-based large model robust machine translation device, characterized in that: The device comprises: An acquisition module, configured to acquire a text to be translated and a source text, wherein the text to be translated includes a sentence to be translated, the source text includes a source sentence, the sentence to be translated includes words to be translated, and the source sentence includes an intermediate source word; A processing module, used for processing the sentence to be translated and the source sentence using a similarity algorithm to obtain sentence similarity; A determination module, configured to determine parallel sentence pairs from a parallel corpus based on the sentence similarity, wherein the parallel corpus includes the source text and a source translation corresponding to the source text, and the parallel sentence pairs include an intermediate source sentence matching the sentence to be translated, and an intermediate source translation sentence corresponding to the intermediate source sentence; a target determination module, configured to determine a target source word and a target source translation word matching the word to be translated based on the similarity between the word to be translated and the intermediate source translation word, and the similarity between the intermediate source translation word and the intermediate source word, the intermediate source sentence including the intermediate source word, and the intermediate source translation sentence including the intermediate source translation word; The target translation obtaining module is used to use the large model to process the parallel sentence pairs, parallel word pairs and the text to be translated to obtain the target translation, wherein the parallel word pairs include the associated target source words and the target source translation words, so as to implement a context-based large model robust machine translation method.
8. An electronic device comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Multi-field machine translation method based on large language model
CN121212170A
