A translation method combining language model and intelligent agent
By combining language models and agents, and using domain adaptation feed-forward networks and review agents, we solve the problems of context understanding and ambiguous expression processing in machine translation using large language models, and improve the accuracy and fluency of translation, especially Translation performance in multi-domain and terminological texts.
Patent Information
- Application Number
- CN202411123867.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-08-16
AI Technical Summary
It is difficult for large language models to maintain the contextual information of long texts and adapt to complex context changes in machine translation, especially in multi-domain or professional terminology texts, and it is difficult to accurately understand ambiguous expressions in natural languages, resulting in poor translation accuracy.
Combining language models and agents, by building a domain-adaptive feed-forward network, using parallel corpora in general and vertical fields to train language models, selecting translation game agents adapted to vertical fields for translation, and evaluating the translation through review agents to obtain scores. Top results.
It enhances the language model's ability to learn knowledge in different fields, improves the accuracy of multi-field translation results and the consistency of professional terms, effectively breaks through the context limitations of the language model, and improves the fidelity and fluency of translation.
Smart Images

Figure CN118643845B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine translation, and in particular to a translation method combining a language model and an intelligent agent. Background Art
[0002] The application of large language models trained on multiple languages in machine translation is constantly pushing the boundaries of translation technology, making translation faster and more convenient. However, large language models have challenges in machine translation: due to the limitations of large language models' contextual understanding, large language models may encounter difficulties when processing long texts, and it is difficult to maintain the contextual information of the entire text and adapt to complex context changes, especially in texts involving multiple fields or professional terms. In addition, there are a large number of ambiguous expressions in natural language, and large language models find it difficult to accurately understand and translate these ambiguous expressions, resulting in poor translation accuracy. Fidelity and fluency: It is a challenge to generate fluent target language text while maintaining fidelity to the original text. Summary of the invention
[0003] In order to solve the above technical problem or at least partially solve the above technical problem, the present invention provides a translation method combining a language model and an intelligent agent.
[0004] In a first aspect, the present invention provides a translation method combining a language model and an agent, comprising:
[0005] Construct and use a large-scale parallel corpus in a general domain and a parallel corpus in a vertical domain to train a language model including a domain-adaptive feedforward network, and obtain a language model adapted for machine translation in different vertical domains, wherein the domain-adaptive feedforward network supports the adaptation of the language model to machine translation in multiple vertical domains;
[0006] During translation: determine the vertical domain scope to which the target text to be translated belongs, select several language models adapted to the corresponding vertical domain as translation game agents that provide translation solutions based on the vertical domain scope, and multiple translation game agents are sequentially controlled by prompt words to provide a translation of the original text based on the translation of the original text and the original text's preamble for any original text in the target text;
[0007] For each translation provided by the translation game agent, the pre-trained review agent evaluates the joint translation of the original text and its previous context, and the original text and its previous context, and obtains the translation with the highest score as the final translation result of the original text.
[0008] Furthermore, building and training a language model that includes a domain-adapted feedforward network involves:
[0009] Create a Transformer language model with an encoder-decoder architecture, and combine the feedforward network in the Transformer language model with a trainable memory mask to obtain a domain-adapted feedforward network.
[0010] During training, the constructed language model is first pre-trained using a large-scale parallel corpus in a general field, and then fine-tuned using a parallel corpus in a vertical field to obtain a language model adapted to the corresponding vertical field.
[0011] During the training process, various memory masks are Hadamard-producted with the fully connected layer of the domain-adaptive feedforward network to realize the allocation of memory units in the domain-adaptive feedforward network; during the training process, the memory mask allocates some target memory units of the feedforward network to record the parallel corpus content of the general domain; and when adding parallel corpus of an additional vertical domain, based on the memory mask of the general domain, the backward propagation process of the memory unit allocated to memorize the parallel corpus of the general domain is locked, and the memory mask of the additional vertical domain is used to select the target main memory unit from the memory units of the domain-adaptive feedforward network that are not allocated memory, and all memory units participate in the forward propagation process of learning the parallel corpus of the vertical domain, while the backward propagation process only updates the parameters of the target main memory unit, so that the target main memory unit memorizes the parallel corpus of the additional vertical domain.
[0012] Furthermore, the training methods of trainable memory masks include:
[0013] Controlling the Transformer language model to input information , two forward passes with and without memory mask are performed, and the Transformer language model generates the corresponding input information Two translation distributions of and ;in, , For the data set, Input information output by the Transformer language model 's translation;
[0014] calculate and The average translation distribution of , and calculate the similarity between the two translation distributions:
[0015] ;
[0016] in, It means to find the KL divergence between two distributions;
[0017] Within the data set, the average similarity gradient of each feedforward network memory unit is calculated; the memory mask element corresponding to the memory unit whose average similarity gradient is greater than the set threshold is set to 1, otherwise the memory mask element is set to 0, so as to determine the memory unit activated by the memory mask for the current data set based on the similarity between the translation distributions. Enter information in The importance of discriminative ability, taking the memory units whose importance exceeds the set threshold as the record of the current data set Memory unit for content;
[0018] Among them, when any memory unit is first selected to memorize parallel corpora in any field, the memory unit will no longer memorize parallel corpora in subsequent fields.
[0019] Furthermore, the memory mask is associated with the vertical domain to which the input content belongs to adaptively control the activation of the memory mask: the features of the input content are input into the domain adaptation feedforward network with a learnable domain embedding vector, and the memory mask is represented by the domain embedding vector:
[0020] ;in, is the first Corresponding domain of feedforward networks The memory mask of For the corresponding Fields of memory masks for feed-forward networks The domain embedding vector of Initialized according to the normal distribution, is the sigmoid activation function, is the adjustment coefficient.
[0021] Furthermore, the evaluation process implemented by the review agent includes:
[0022] Get the original text and the previous text to form the original context sequence , obtain the original text and the joint translation of the original text to form the translation context sequence , where the translation of the original text is provided by the translation game agent to be evaluated, and the translation of the previous text of the original text is provided by the optimal translation selected by the evaluation agent;
[0023] Obtaining the original context sequence through the Embedding model and the translated context sequence The original context sequence embedding vector and the translated context sequence embedding vector ;
[0024] The original context sequence is embedded into the vector through a bidirectional gated recurrent unit and the translated context sequence embedding vector The concatenation result is mapped into the hidden state ;
[0025] The hidden state , the original context sequence and the translated context sequence The length of, and, the translated context sequence Sequence with original context Between and in the context of the target text The current optimal translation context sequence The distance and variance of the BLEURT scores between them are combined, and the combined features are input into the scoring fully connected network to obtain the score.
[0026] Furthermore, the process of training the review agent includes:
[0027] Constructing an ambiguous calibration dataset for parallel corpora in various fields; the ambiguous calibration dataset includes: training original text, ambiguous translation of the training original text and reference translation;
[0028] Obtain the training original text, the ambiguous translation of the training original text and the reference translation in the ambiguous calibration dataset;
[0029] Obtain the embedding vectors of the training original text, the ambiguous translation of the training original text, and the reference translation through the Embedding model, and concatenate the embedding vectors of the training original text with the embedding vectors of the ambiguous translation of the training original text and the reference translation to obtain several groups of concatenated embedding vectors;
[0030] Concatenate the embedding vectors into corresponding hidden states through bidirectional gated recurrent units;
[0031] The hidden state, the normalized representation of the length of the training original text and the ambiguous translation or the normalized representation of the length of the training original text and the reference translation, and the distance and variance of the BLEURT score between the training original text and the ambiguous translation and between the training original text and the reference translation are combined to obtain a combined feature, and the combined feature is input into a scoring fully connected network to obtain a score; within the scope of the ambiguous calibration data set, determine whether the translation predicted according to the score is a cross entropy of the reference translation, and train the review agent through the gradient descent method with the cross entropy as the loss, so that the review agent selects a reference translation based on the training original text in the ambiguous calibration data set.
[0032] Furthermore, the scoring fully connected network in the review agent adopts an architecture consistent with the domain-adapted feedforward network, operates with a trainable scoring mask, and stacks multiple fully connected networks to increase the overall number of neurons; various scoring masks are Hadamard products with the fully connected layers of the scoring fully connected network to achieve the allocation of neurons in the scoring fully connected network;
[0033] The ambiguous calibration dataset is subdivided into general domain and vertical domain. During the training process, the score mask is used to assign some neurons of the scoring fully connected network for the ambiguous calibration dataset in the general domain. Then, the review agent is fine-tuned using the ambiguous calibration dataset in the vertical domain. Based on the score mask in the general domain, the back propagation process of the neurons assigned with the general domain score is locked, and the score mask in the vertical domain is used to select the target main neurons from the unassigned neurons. All neurons participate in the forward propagation process of scoring the ambiguous calibration dataset in the vertical domain, while the back propagation process only updates the parameters of the target main neurons, so that the target neurons can memorize the translation scores of the additional vertical domain.
[0034] Furthermore, the training methods of trainable rating masks include:
[0035] Review agent for any original text and translation , two forward passes with and without score masks are performed, and the review agent generates two score distributions corresponding to any original text and translation and ,in, To review the scores output by the agent;
[0036] Calculate the mean score distribution of two score distributions , and calculate the similarity between the two distributions based on the average rating distribution and the two rating distributions:
[0037] ;
[0038] in, It means to find the KL divergence between two distributions;
[0039] Within the scope of the ambiguous calibration data set, the average similarity gradient of each scoring fully connected network neuron is calculated; the scoring mask element corresponding to the neuron whose average similarity gradient is greater than the set threshold is set to 1, otherwise the scoring mask element is set to 0, so as to determine the importance of the neurons activated by the scoring mask to the scoring performance of the current ambiguous calibration data set based on the similarity between the scoring distributions, and select the neurons whose importance exceeds the set threshold to participate in the scoring;
[0040] Among them, when any neuron is first selected to score the translation of the corresponding field, the neuron will no longer score the translation of other fields.
[0041] Furthermore, the rating mask is associated with the vertical domain to which the evaluated translation content belongs to adaptively control the activation of the rating mask: the features of the translation content are input into the rating fully connected network together with the learnable domain embedding vector, and the rating mask is represented by the domain embedding vector:
[0042] ;in, To review the agent The corresponding domain of the scoring fully connected network The scoring mask of For the corresponding The domain of the score mask of the scoring fully connected network The domain embedding vector of Initialized according to the normal distribution, is the sigmoid activation function, is the adjustment coefficient.
[0043] Furthermore, the translation rounds of multiple translation game agents are preset, and the game amount between the translation game agents is controlled according to the rounds.
[0044] In a second aspect, the present invention provides a translation device combining a language model and an intelligent agent, comprising: at least one processing unit, the processing unit being connected to a storage unit via a bus unit, the storage unit storing a computer program, and when the computer program is executed by the processing unit, the translation method combining a language model and an intelligent agent is implemented.
[0045] In a third aspect, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the translation method combining a language model and an agent.
[0046] The above technical solution provided by the embodiment of the present invention has the following advantages compared with the prior art:
[0047] In the present application, a language model including a domain-adaptive feedforward network is constructed and trained using large-scale parallel corpora in general fields and parallel corpora in vertical fields, so as to obtain a language model adapted for machine translation in different vertical fields. The domain-adaptive feedforward network enhances the language model's ability to learn knowledge in different fields and enhances the language model's ability to continuously and incrementally learn knowledge, thereby optimizing the machine translation results of the language model in multiple vertical fields.
[0048] During translation, the present application: determines the vertical domain scope to which the target text to be translated belongs, selects several language models adapted to the corresponding vertical domain as translation game agents that provide translation solutions based on the vertical domain scope, and multiple translation game agents are sequentially controlled under the prompt word, for any original text in the target text, the translation game agent gives the translation of the original text based on the translation of the original text and the original text's preamble. Multiple translation game agents translate based on the preamble translation and the original text, and the review agent evaluates the original text and the original text's previous context, and the original text and the original text's previous context's joint translation, and obtains the translation with the highest score as the final translation result of the original text, and the translation process simulates the discussion, decision-making and evaluation process. Through the discussion, evaluation and decision-making among multiple translation game agents, the "illusions" generated by the language model during the translation process are filtered out, and the ambiguous expressions generated by the translation process can be effectively improved based on the context connection to ensure the accuracy of the translation. The application review agent evaluates the joint translation of the original text and its previous context, and the original text and its previous context. By using the expansion of the previous context during the evaluation process, it can effectively break through the contextual limitations of the language model itself and better translate the current text. Since the context scope is expanded, the consistency of professional terminology in the translation process can be improved.
[0049] The scoring fully connected network in the review agent of the present application supports the construction of the architecture of the domain-adapted feedforward network, which enhances the review agent's ability to score vertical domain translations. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0052] Figure 1 A flowchart of a translation method combining a language model and an intelligent agent provided by an embodiment of the present invention;
[0053] Figure 2 The architecture diagram of the Transformer language model for the original encoder-decoder architecture;
[0054] Figure 3 An architecture diagram of a Transformer language model of a feedforward network improved codec architecture provided by an embodiment of the present invention;
[0055] Figure 4A schematic diagram of a feedforward network and a domain adaptation feedforward network provided in an embodiment of the present invention;
[0056] Figure 5 A schematic diagram of a training review agent provided by an embodiment of the present invention;
[0057] Figure 6 A schematic diagram of a scoring fully connected network provided by an embodiment of the present invention;
[0058] Figure 7 A schematic diagram of a translation device combining a language model and an intelligent agent provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0061] Example 1
[0062] like Figure 1 As shown, the technology of the present invention implements a translation method combining a language model and an intelligent agent, including:
[0063] We build and use large-scale parallel corpora in general fields and parallel corpora in vertical fields to train language models that include domain-adaptive feed-forward networks, and obtain language models that are adapted to machine translation in different vertical fields.
[0064] Building and training a language model with a domain-adapted feed-forward network involves:
[0065] Create a Transformer language model with an encoder-decoder architecture, and combine the feedforward network in the Transformer language model with a trainable memory mask to obtain a domain-adapted feedforward network.
[0066] like Figure 2 As shown, Figure 2 A schematic diagram of the Transformer language model with the original encoder-decoder architecture is given. The left part of the figure is the decoder, and the right part is the encoder; in the component unit of the encoder, the multi-head attention is followed by a feedforward network, and the multi-head attention and the feedforward network are connected through a residual structure; in the component unit of the decoder, two groups of multi-head attention are followed by a feedforward network, and each multi-head attention and the feedforward network are connected through a residual structure. Figure 3 As shown, in order to enhance the learning ability of the Transformer language model for knowledge in different fields and enhance the continuous incremental learning ability of the Transformer language model for knowledge, the feedforward network in the Transformer language model is combined with a trainable memory mask to obtain a domain-adapted feedforward network.
[0067] The principle of the domain adaptation feed-forward network is as follows Figure 4 As shown, the principle of the feedforward network is:
[0068] ;in, They are The output of the fully connected layer, They are The weight matrix of the fully connected layer, They are The bias and weight matrix of the fully connected layer and bias The elements of form the memory unit of the feedforward network. The selective expression of the memory unit is controlled by the memory mask:
[0069] ; They are The output of the fully connected layer. The final result after selective expression and the results of non-selective expression When they are consistent, it means that the information related to knowledge is mainly recorded by selectively expressed memory units. This can be achieved by controlling the selective recording and expression of memory units in the feedforward network through memory masks for knowledge in different fields to continuously and incrementally learn knowledge.
[0070] When training the Transformer language model, the constructed language model is first pre-trained using a large-scale parallel corpus in a general field, and then the constructed language model is fine-tuned using a vertical field parallel corpus to obtain a language model adapted to the corresponding vertical field.
[0071] In the process of training the language model, various memory masks are required to perform Hadamard products with the fully connected layer of the domain-adapted feedforward network to realize the allocation of memory units in the domain-adapted feedforward network. Specifically, during the training process, the memory mask allocates some target memory units of the feedforward network to record the parallel corpus content of the general domain; and when adding parallel corpus of additional vertical domains, based on the memory mask of the general domain, the backward propagation process of the memory unit allocated to memorize the parallel corpus of the general domain is locked, and the memory mask of the additional vertical domain is used to select the target main memory unit from the memory units of the unallocated memory of the domain-adapted feedforward network, and all memory units participate in the forward propagation process of learning the parallel corpus of the vertical domain, while the backward propagation process only updates the parameters of the target main memory unit, so that the target main memory unit memorizes the parallel corpus of the additional vertical domain.
[0072] During the training of the language model, the training methods of the trainable memory mask include:
[0073] Controlling the Transformer language model to input information , two forward passes with and without memory mask are performed, and the Transformer language model generates the corresponding input information Two translation distributions of and ;in, , For the data set, Input information output by the Transformer language model 's translation;
[0074] calculate and The average translation distribution of , and calculate the similarity between the two translation distributions:
[0075] ;
[0076] in, It means to find the KL divergence between two distributions;
[0077] Within the data set, the average similarity gradient of each feedforward network memory unit is calculated; the memory mask element corresponding to the memory unit whose average similarity gradient is greater than the set threshold is set to 1, otherwise the memory mask element is set to 0, so as to determine the memory unit activated by the memory mask for the current data set based on the similarity between the translation distributions. Enter information in The importance of discriminative ability, taking the memory units whose importance exceeds the set threshold as the record of the current data set Memory unit for content;
[0078] Among them, when any memory unit is first selected to memorize parallel corpora in any field, the memory unit will no longer memorize parallel corpora in subsequent fields.
[0079] Furthermore, the memory mask is associated with the vertical domain to which the input content belongs to adaptively control the activation of the memory mask: the features of the input content are input into the domain adaptation feedforward network with a learnable domain embedding vector, and the memory mask is represented by the domain embedding vector:
[0080] ;in, is the first Corresponding domain of feedforward networks The memory mask of For the corresponding Fields of memory masks for feed-forward networks The domain embedding vector of Initialized according to the normal distribution, is the sigmoid activation function, is the adjustment coefficient.
[0081] Construct multiple translation game agents and review agents; train the review agents so that they can evaluate the translation results of the translation game agents.
[0082] In the specific implementation process, Figure 5 As shown, the process of training the review agent includes:
[0083] An ambiguous calibration dataset is constructed for parallel corpora in various fields; the ambiguous calibration dataset includes: a training original text, several ambiguous translations of the training original text, and a reference translation.
[0084] The review agent obtains the training original text, the ambiguous translation of the training original text and the reference translation in the ambiguous calibration data set.
[0085] The review agent obtains the embedding vectors of the training original text, the ambiguous translation of the training original text and the reference translation through the Embedding model, and splices the embedding vectors of the training original text with the embedding vectors of the ambiguous translation of the training original text and the reference translation to obtain several groups of spliced embedding vectors.
[0086] The embedding vector is concatenated and mapped into several corresponding hidden states through a bidirectional gated recurrent unit.
[0087] The hidden state, the normalized representation of the length of the training original text and the ambiguous translation or the normalized representation of the length of the training original text and the reference translation, and the distance and variance of the BLEURT score between the training original text and the ambiguous translation and between the training original text and the reference translation are combined to obtain a combined feature, and the combined feature is input into a scoring fully connected network to obtain a score.
[0088] Within the scope of the ambiguous calibration data set, determine whether the translation predicted by the score is the cross entropy of the reference translation, and train the review agent through the gradient descent method with the cross entropy as the loss, so that the review agent selects the reference translation based on the training original text in the ambiguous calibration data set.
[0089] In order to enhance the review capabilities of the review agent in various fields. Figure 6 As shown, the scoring fully connected network in the review agent adopts the same architecture as the domain adaptation feedforward network and runs with a trainable scoring mask; Figure 6 In the given scoring fully connected network, except for the last layer of fully connected network, multiple fully connected networks are stacked through the residual structure to increase the overall number of neurons; various scoring masks are Hadamard products with the fully connected layer of the scoring fully connected network to realize the allocation of neurons in the scoring fully connected network.
[0090] The ambiguous calibration dataset is subdivided into general domain and vertical domain. During the training process of the review agent, the score mask is used to assign some neurons of the scoring fully connected network for the ambiguous calibration dataset in the general domain. Then, the review agent is fine-tuned using the ambiguous calibration dataset in the vertical domain. Based on the score mask in the general domain, the back propagation process of the neurons assigned the general domain score is locked, and the score mask in the vertical domain is used to select the target main neurons from the unassigned neurons. All neurons participate in the forward propagation process of scoring the ambiguous calibration dataset in the vertical domain, while the back propagation process only updates the parameters of the target main neurons, so that the target neurons can memorize the translation scores of the additional vertical domain.
[0091] The training methods for trainable rating masks include:
[0092] Review agent for any original text and translation , two forward passes with and without score masks are performed, and the review agent generates two score distributions corresponding to any original text and translation and ,in, To review the scores output by the agent;
[0093] Calculate the mean score distribution of two score distributions , and calculate the similarity between the two distributions based on the average rating distribution and the two rating distributions:
[0094] ;
[0095] in, It means to find the KL divergence between two distributions;
[0096] Within the scope of the ambiguous calibration data set, the average similarity gradient of each scoring fully connected network neuron is calculated; the scoring mask element corresponding to the neuron whose average similarity gradient is greater than the set threshold is set to 1, otherwise the scoring mask element is set to 0, so as to determine the importance of the neurons activated by the scoring mask to the scoring performance of the current ambiguous calibration data set based on the similarity between the scoring distributions, and select the neurons whose importance exceeds the set threshold to participate in the scoring;
[0097] Among them, when any neuron is first selected to score the translation of the corresponding field, the neuron will no longer score the translation of other fields.
[0098] The scoring mask is associated with the vertical domain to which the evaluated translation content belongs to adaptively control the activation of the scoring mask: the features of the translation content are input into the scoring fully connected network with the learnable domain embedding vector, and the scoring mask is represented by the domain embedding vector:
[0099] ;in, To review the agent The corresponding domain of the scoring fully connected network The scoring mask of For the corresponding The domain of the score mask of the scoring fully connected network The domain embedding vector of Initialized according to the normal distribution, is the sigmoid activation function, is the adjustment coefficient.
[0100] During translation, the translation rounds of multiple translation game agents are pre-set, and the game volume between the translation game agents is controlled according to the rounds.
[0101] The vertical field range to which the target text to be translated belongs is determined, and based on the vertical field range, several language models adapted to the corresponding vertical fields are selected as translation game agents that provide translation solutions.
[0102] In each round, the selected translation game agent is controlled by the prompt word in turn, and for any original text in the target text, the translation game agent gives a translation of the original text based on the translation of the original text and the original text's preamble.
[0103] For the translations provided by each translation game agent in each round, the pre-trained review agent evaluates the joint translations of the original text and its previous context, and the original text and its previous context, and obtains the translation with the highest score as the final translation result of the original text.
[0104] The evaluation process implemented by the review agent includes:
[0105] Get the original text and the previous text to form the original context sequence , obtain the original text and the joint translation of the original text to form the translation context sequence , where the translation of the original text is provided by the translation game agent to be evaluated, and the translation of the previous text of the original text is provided by the optimal translation selected by the evaluation agent;
[0106] Obtaining the original context sequence through the Embedding model and the translated context sequence The original context sequence embedding vector and the translated context sequence embedding vector ;
[0107] The original context sequence is embedded into the vector through a bidirectional gated recurrent unit and the translated context sequence embedding vector The concatenation result is mapped into the hidden state ;
[0108] The hidden state , the original context sequence and the translated context sequence The length of, and, the translated context sequence Sequence with original context Between and in the context of the target text The current optimal translation context sequence The distance and variance of the BLEURT scores between them are combined, and the combined features are input into the scoring fully connected network to obtain the score.
[0109] Example 2
[0110] See also Figure 7As shown, an embodiment of the present invention provides a translation device combining a language model and an intelligent agent, comprising: at least one processing unit, the processing unit is connected to a storage unit via a bus unit, the storage unit is a computer-readable storage medium, and can be used to store software programs, computer executable programs, and modules, such as the software programs, computer executable programs, and modules corresponding to a translation method combining a language model and an intelligent agent in an embodiment of the present invention. The processing unit implements the above-mentioned translation method combining a language model and an intelligent agent by running the software programs, computer executable programs, and modules stored in the storage unit, comprising:
[0111] Construct and use a large-scale parallel corpus in a general domain and a parallel corpus in a vertical domain to train a language model including a domain-adaptive feedforward network, and obtain a language model adapted for machine translation in different vertical domains, wherein the domain-adaptive feedforward network supports the adaptation of the language model to machine translation in multiple vertical domains;
[0112] During translation: determine the vertical domain scope to which the target text to be translated belongs, select several language models adapted to the corresponding vertical domain as translation game agents that provide translation solutions based on the vertical domain scope, and multiple translation game agents are sequentially controlled by prompt words to provide a translation of the original text based on the translation of the original text and the original text's preamble for any original text in the target text;
[0113] For the translations provided by each translation game agent in each round, the pre-trained review agent evaluates the joint translations of the original text and its previous context, and the original text and its previous context, and obtains the translation with the highest score as the final translation result of the original text.
[0114] Of course, the computer program stored in the storage unit of the device for implementing the translation method combining a language model and an intelligent agent provided by an embodiment of the present invention is not limited to the method operations described above, and can also execute related operations in the translation method combining a language model and an intelligent agent provided by any embodiment of the present invention.
[0115] Example 3
[0116] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed, the translation method combining a language model and an agent is implemented, including:
[0117] Construct and use a large-scale parallel corpus in a general domain and a parallel corpus in a vertical domain to train a language model including a domain-adaptive feedforward network, and obtain a language model adapted for machine translation in different vertical domains, wherein the domain-adaptive feedforward network supports the adaptation of the language model to machine translation in multiple vertical domains;
[0118] During translation: determine the vertical domain scope to which the target text to be translated belongs, select several language models adapted to the corresponding vertical domain as translation game agents that provide translation solutions based on the vertical domain scope, and multiple translation game agents are sequentially controlled by prompt words to provide a translation of the original text based on the translation of the original text and the original text's preamble for any original text in the target text;
[0119] For each translation provided by the translation game agent, the pre-trained review agent evaluates the joint translation of the original text and its previous context, and the original text and its previous context, and obtains the translation with the highest score as the final translation result of the original text.
[0120] A computer-readable storage medium provided by an embodiment of the present invention stores a computer program which is not limited to the method operations described above, but can also execute related operations in a translation method combining a language model and an intelligent agent provided by any embodiment of the present invention.
[0121] In the embodiments provided by the present invention, it should be understood that the disclosed structures and methods can be implemented in other ways. For example, the structural embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, structures or units, which can be electrical, mechanical or other forms.
[0122] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0123] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0124] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A translation method combining a language model and an agent, characterized in that: include: Construct and use a large-scale parallel corpus in a general domain and a parallel corpus in a vertical domain to train a language model including a domain-adaptive feedforward network, and obtain a language model adapted for machine translation in different vertical domains, wherein the domain-adaptive feedforward network supports the adaptation of the language model to machine translation in multiple vertical domains; Constructing and training a language model including a domain-adapted feedforward network includes: creating a Transformer language model of a codec architecture, combining the feedforward network in the Transformer language model with a trainable memory mask to obtain a domain-adapted feedforward network; during training, first pre-training the constructed language model using a large-scale parallel corpus in a general domain, and then fine-tuning the constructed language model using a vertical domain parallel corpus to obtain a language model adapted to the corresponding vertical domain; during the training process, various memory masks are Hadamard-producted with the fully connected layer of the domain-adapted feedforward network to realize the separation of memory units in the domain-adapted feedforward network. During the training process, the memory mask allocates some target memory units of the feedforward network to record the parallel corpus content of the general domain; and when adding the parallel corpus of the additional vertical domain, based on the memory mask of the general domain, the backward propagation process of the memory unit allocated to memorize the parallel corpus of the general domain is locked, and the memory mask of the additional vertical domain is used to select the target main memory unit from the memory units of the domain adaptation feedforward network that are not allocated to memory, and all memory units participate in the forward propagation process of learning the parallel corpus of the vertical domain, while the backward propagation process only updates the parameters of the target main memory unit, so that the target main memory unit memorizes the parallel corpus of the additional vertical domain; During translation: determine the vertical domain scope to which the target text to be translated belongs, select several language models adapted to the corresponding vertical domain as translation game agents that provide translation solutions based on the vertical domain scope, and multiple translation game agents are sequentially controlled by prompt words to provide a translation of the original text based on the translation of the original text and the original text's preamble for any original text in the target text; For each translation provided by the translation game agent, the pre-trained review agent evaluates the joint translation of the original text and its previous context, and the original text and its previous context, and obtains the translation with the highest score as the final translation result of the original text.
2. The translation method combining a language model and an agent according to claim 1, characterized in that: The training methods of trainable memory masks include: Controlling the Transformer language model to input information , two forward passes with and without memory mask are performed, and the Transformer language model generates the corresponding input information Two translation distributions of and ;in, , For the data set, Input information output by the Transformer language model 's translation; calculate and The average translation distribution of , and calculate the similarity between the two translation distributions: ; in, It means to find the KL divergence between two distributions; Within the data set, the average similarity gradient of each feedforward network memory unit is calculated; the memory mask element corresponding to the memory unit whose average similarity gradient is greater than the set threshold is set to 1, otherwise the memory mask element is set to 0, so as to determine the memory unit activated by the memory mask for the current data set based on the similarity between the translation distributions. Enter information in The importance of discriminative ability, taking the memory units whose importance exceeds the set threshold as the record of the current data set Memory unit for content; Among them, when any memory unit is first selected to memorize parallel corpora in any field, the memory unit will no longer memorize parallel corpora in subsequent fields.
3. The translation method combining a language model and an agent according to claim 2, characterized in that: The memory mask is associated with the vertical domain to which the input content belongs to adaptively control the activation of the memory mask: the features of the input content are input into the domain adaptation feedforward network with a learnable domain embedding vector, and the memory mask is represented by the domain embedding vector: ;in, is the first The corresponding domain of a feed-forward network The memory mask of For the corresponding Fields of memory masks for feed-forward networks The domain embedding vector of Initialized according to the normal distribution, is the sigmoid activation function, is the adjustment coefficient.
4. The translation method combining a language model and an agent according to claim 1, characterized in that: The evaluation process implemented by the review agent includes: Get the original text and the previous text to form the original context sequence , obtain the original text and the joint translation of the original text to form the translation context sequence , where the translation of the original text is provided by the translation game agent to be evaluated, and the translation of the previous text of the original text is provided by the optimal translation selected by the evaluation agent; Obtaining the original context sequence through the Embedding model and the translated context sequence The original context sequence embedding vector and the translated context sequence embedding vector ; The original context sequence is embedded into the vector through a bidirectional gated recurrent unit and the translated context sequence embedding vector The concatenation result is mapped into the hidden state ; The hidden state , the original context sequence and the translated context sequence The length of, and, the translated context sequence Sequence with original context Between and in the context of the target text The current optimal translation context sequence The distance and variance of the BLEURT scores between them are combined, and the combined features are input into the scoring fully connected network to obtain the score.
5. The translation method combining a language model and an agent according to claim 1, characterized in that: The process of training the review agent includes: Constructing an ambiguous calibration dataset for parallel corpora in various fields; the ambiguous calibration dataset includes: training original text, ambiguous translation of the training original text and reference translation; Obtain the training original text, the ambiguous translation of the training original text and the reference translation in the ambiguous calibration dataset; Obtain the embedding vectors of the training original text, the ambiguous translation of the training original text, and the reference translation through the Embedding model, and concatenate the embedding vectors of the training original text with the embedding vectors of the ambiguous translation of the training original text and the reference translation to obtain several groups of concatenated embedding vectors; Concatenate the embedding vectors into corresponding hidden states through bidirectional gated recurrent units; The hidden state, the normalized representation of the length of the training original text and the ambiguous translation or the normalized representation of the length of the training original text and the reference translation, and the distance and variance of the BLEURT score between the training original text and the ambiguous translation and between the training original text and the reference translation are combined to obtain a combined feature, and the combined feature is input into a scoring fully connected network to obtain a score; within the scope of the ambiguous calibration data set, determine whether the translation predicted according to the score is a cross entropy of the reference translation, and train the review agent through the gradient descent method with the cross entropy as the loss, so that the review agent selects a reference translation based on the training original text in the ambiguous calibration data set.
6. The translation method combining a language model and an agent according to claim 5, characterized in that: The scoring fully connected network in the review agent adopts an architecture consistent with the domain-adapted feedforward network, operates with a trainable scoring mask, and stacks multiple fully connected networks to increase the overall number of neurons; various scoring masks are Hadamard products with the fully connected layers of the scoring fully connected network to achieve the allocation of neurons in the scoring fully connected network; The ambiguous calibration dataset is subdivided into general domain and vertical domain. During the training process, the score mask is used to assign some neurons of the scoring fully connected network for the ambiguous calibration dataset in the general domain. Then, the review agent is fine-tuned using the ambiguous calibration dataset in the vertical domain. Based on the score mask in the general domain, the back propagation process of the neurons assigned with the general domain score is locked, and the score mask in the vertical domain is used to select the target main neurons from the unassigned neurons. All neurons participate in the forward propagation process of scoring the ambiguous calibration dataset in the vertical domain, while the back propagation process only updates the parameters of the target main neurons, so that the target neurons can memorize the translation scores of the additional vertical domain.
7. The translation method combining a language model and an agent according to claim 6, characterized in that: The training methods for trainable rating masks include: Review agent for any original text and translation , two forward passes with and without score masks are performed, and the review agent generates two score distributions corresponding to any original text and translation and ,in, To review the scores output by the agent; Calculate the mean score distribution of two score distributions , and calculate the similarity between the two distributions based on the average rating distribution and the two rating distributions: ; in, It means to find the KL divergence between two distributions; Within the scope of the ambiguous calibration data set, the average similarity gradient of each scoring fully connected network neuron is calculated; the scoring mask element corresponding to the neuron whose average similarity gradient is greater than the set threshold is set to 1, otherwise the scoring mask element is set to 0, so as to determine the importance of the neurons activated by the scoring mask to the scoring performance of the current ambiguous calibration data set based on the similarity between the scoring distributions, and select the neurons whose importance exceeds the set threshold to participate in the scoring; Among them, when any neuron is first selected to score the translation of the corresponding field, the neuron will no longer score the translation of other fields.
8. The translation method combining a language model and an agent according to claim 7, characterized in that: The scoring mask is associated with the vertical domain to which the evaluated translation content belongs to adaptively control the activation of the scoring mask: the features of the translation content are input into the scoring fully connected network with the learnable domain embedding vector, and the scoring mask is represented by the domain embedding vector: ;in, To review the agent The corresponding domain of the scoring fully connected network The scoring mask of For the corresponding The domain of the score mask of the scoring fully connected network The domain embedding vector of Initialized according to the normal distribution, is the sigmoid activation function, is the adjustment coefficient.
9. The translation method combining a language model and an agent according to claim 1, characterized in that: The translation rounds of multiple translation game agents are preset, and the game amount between the translation game agents is controlled according to the rounds.
