Retrieval-enhanced neural machine translation methods, devices, and equipment

By introducing a retrieval enhancement semantic alignment layer into neural machine translation and fusing feature vectors from source language text and retrieved knowledge fragments, the accuracy problem in professional domain translation is solved, achieving high-precision translation results.

CN123070140APending Publication Date: 2026-11-10深圳云译科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611098071.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

Existing neural machine translation technology is not accurate enough in translating specialized terminology, making it difficult to meet the needs of high-precision translation, and it suffers from semantic bias and translation errors.

Method used

A neural machine translation method based on retrieval enhancement is adopted. The source language text and the retrieved knowledge fragments are encoded by an encoder. The semantic alignment layer generated by retrieval enhancement is used to fuse the text feature vector and the retrieval result vector to generate the target language translation result.

Benefits of technology

It improves the accuracy and fluency of translation of professional terminology and contextual expressions, reduces semantic bias, and significantly improves the generation quality and scene adaptability of neural machine translation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123070140A_ABST
    Figure CN123070140A_ABST
Patent Text Reader

Abstract

This application discloses a neural machine translation method, apparatus, and device based on retrieval enhancement generation, relating to the field of natural language processing technology. The method includes: acquiring source language text and retrieval knowledge fragments associated with the source language text, wherein the retrieval knowledge fragments include source language expressions and corresponding target language expressions; encoding the source language text using an encoder to obtain a text feature vector; encoding the retrieval knowledge fragments using an encoder to obtain a retrieval result vector; fusing the text feature vector and the retrieval result vector in a retrieval enhancement generation semantic alignment layer to obtain an enhanced feature vector; and generating a target language translation result corresponding to the source language text using a decoder based on the enhanced feature vector.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language processing technology, and more specifically, to a method, apparatus, and device for neural machine translation based on retrieval enhancement generation. Background Technology

[0002] Neural Machine Translation (NMT), a core technology in the field of natural language processing, plays a crucial role in enabling automatic translation between different languages, providing an efficient and convenient solution for cross-language communication. Specifically, NMT constructs deep neural network models to perform semantic understanding, feature extraction, and reorganization of the input source language text, ultimately outputting a translation that conforms to the expression habits of the target language. It is widely used in scenarios such as international trade, cross-border communication, and academic exchange.

[0003] Currently, in professional fields (such as medicine, law, engineering, etc.), existing neural machine translation technology suffers from insufficient accuracy in translating professional terminology. For industry-specific terms and expressions, semantic deviations and translation errors are prone to occur, making it difficult to meet the needs of high-precision translation. Summary of the Invention

[0004] The main objective of this application is to provide a neural machine translation method, apparatus, and device based on retrieval enhancement generation, in order to address the problem of insufficient accuracy in the translation of professional terminology in existing neural machine translation technologies.

[0005] To achieve the above objectives, a first aspect of this application proposes a retrieval-enhanced generative neural machine translation method applied to a large-scale translation model, wherein the large-scale translation model includes an encoder, a decoder, and a retrieval-enhanced generative semantic alignment layer embedded between the encoder and the decoder, comprising: Obtain source language text and retrieval knowledge fragments associated with the source language text, wherein the retrieval knowledge fragments include source language expressions and corresponding target language expressions; The source language text is encoded using the encoder to obtain a text feature vector; the retrieved knowledge fragment is encoded using the encoder to obtain a retrieval result vector. In the retrieval enhancement semantic alignment layer, the text feature vector and the retrieval result vector are fused to obtain the enhanced feature vector; Based on the enhanced feature vector, the decoder generates the target language translation result corresponding to the source language text.

[0006] Secondly, a retrieval-enhanced generative neural machine translation device is proposed and applied to a large-scale translation model. The large-scale translation model includes an encoder, a decoder, and a retrieval-enhanced generative semantic alignment layer embedded between the encoder and the decoder, comprising: The acquisition module is used to acquire source language text and retrieval knowledge fragments associated with the source language text, wherein the retrieval knowledge fragments include source language expressions and corresponding target language expressions; The encoding module is used to encode the source language text using the encoder to obtain a text feature vector; and to encode the retrieved knowledge fragment using the encoder to obtain a retrieval result vector. The fusion module is used to fuse the text feature vector and the retrieval result vector in the retrieval enhancement semantic alignment layer to obtain an enhanced feature vector; The generation module is used to generate the target language translation result corresponding to the source language text through the decoder based on the enhanced feature vector.

[0007] Thirdly, an electronic device is proposed, comprising: At least one processor; and The memory is communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform any of the methods described in the present disclosure.

[0008] The technical solutions provided by the embodiments of this application may include the following beneficial effects: In this application, an enhanced feature vector is obtained by fusing the text feature vector and the retrieval result vector in a retrieval enhancement semantic alignment layer. The decoder is then driven by the enhanced feature vector to generate translation results. This approach can accurately introduce bilingual retrieval knowledge fragments associated with the source language text for semantic assistance, enhance cross-language semantic alignment, improve the accuracy and fluency of translation of professional domain terms and contextual expressions, reduce translation semantic bias and model illusion problems, and significantly improve the overall generation quality and scene adaptability of neural machine translation. Attached Figure Description

[0009] The accompanying drawings, which form part of this application, are used to provide a further understanding of the application and to make other features, objects, and advantages of the application more apparent. The illustrative embodiments and descriptions of this application are used to explain the application and do not constitute an undue limitation of the application. In the drawings: Figure 1 A flowchart illustrating a neural machine translation method based on retrieval enhancement provided in this application; Figure 2 This application provides an architectural diagram of a neural machine translation system based on retrieval enhancement generation. Figure 3 A schematic diagram of a neural machine translation device based on retrieval enhancement generation is provided in this application; Figure 4 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation

[0010] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0011] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0012] In this application, the terms "upper," "lower," "left," "right," "front," "rear," "top," "bottom," "inner," "outer," "middle," "vertical," "horizontal," "lateral," and "longitudinal" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. These terms are primarily for the purpose of better describing this application and its embodiments, and are not intended to limit the indicated device, element, or component to having a specific orientation, or to be constructed and operated in a specific orientation.

[0013] Furthermore, in addition to indicating location or positional relationship, some of the aforementioned terms may also have other meanings. For example, the term "above" may also be used in some cases to indicate a certain dependency or connection relationship. Those skilled in the art can understand the specific meaning of these terms in this application based on the specific circumstances.

[0014] Furthermore, the terms "installation," "setup," "equipped with," "connection," "linked," and "socketing" should be interpreted broadly. For example, "connection" can be a fixed connection, a detachable connection, or an integral structure; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or an internal connection between two devices, components, or parts. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.

[0015] In practical applications in vertical professional fields such as medicine, law, and industrial equipment, traditional neural machine translation methods and large-scale model translation solutions have significant technical shortcomings. They are generally unable to meet the stringent requirements of professional translation scenarios for terminology accuracy, semantic standardization, and scenario adaptability. Specifically, there are three core technical bottlenecks: First, the ability to integrate domain knowledge is insufficient. The training data of general translation models mainly consists of open-domain general text, which cannot accurately adapt to the professional terminology, industry semantic logic and text specifications specific to each vertical domain. It is difficult to effectively capture the implicit contextual information of professional scenarios, and it is prone to problems such as terminology translation errors, semantic deviation from industry standards, and imprecise professional expressions, making it unable to meet the needs of high-precision professional translation.

[0016] Second, translation performance is limited for low-resource languages. For low-resource languages ​​where parallel corpora are scarce, most existing translation solutions rely on back-translation algorithms and unsupervised neural machine translation to expand training data. However, such data expansion methods are prone to introducing semantic noise and sentence structure bias, resulting in semantic distortion, terminology confusion, and awkward sentences in the model-generated translations. The translation stability and accuracy are poor, making it difficult to support professional translation applications for low-resource languages.

[0017] Third, the retrieval and generation processes are deeply separated. Existing Retrieval Augmented Generation (RAG) translation architectures mostly adopt a loosely coupled design pattern. The retrieval module only provides external knowledge fragments to the model. The retrieval results lack deep interaction and adaptive fusion with the model's internal encoding, semantic reasoning, and feature generation processes. This results in problems such as stiff knowledge injection, low fusion efficiency, and poor knowledge adaptability. It cannot fully leverage the empowering effect of external professional knowledge and greatly limits the accuracy and scenario adaptability of professional machine translation.

[0018] Figure 1 This application provides a flowchart illustrating a retrieval-enhanced neural machine translation method applied to a large-scale translation model. The large-scale translation model includes an encoder, a decoder, and a retrieval-enhanced semantic alignment layer embedded between the encoder and the decoder. The method includes: S110. Obtain source language text and retrieval knowledge fragments associated with the source language text, wherein the retrieval knowledge fragments include source language expressions and corresponding target language expressions.

[0019] In this embodiment, the source language text can be the original language text to be translated, including single sentences, paragraphs, documents, etc. The retrieved knowledge fragment is a bilingual comparative knowledge unit that is highly related to the source language text in terms of semantics, domain, and context. It contains the source language expression and the corresponding target language standard expression. For example, in the medical field, a retrieved knowledge fragment can be the term pair "myocardial infarction".

[0020] It receives the source language text to be translated and simultaneously acquires bilingual comparative knowledge fragments that are semantically or terminologically related to the source language text.

[0021] S120. The source language text is encoded by the encoder to obtain a text feature vector; the retrieval knowledge fragment is encoded by the encoder to obtain a retrieval result vector.

[0022] In this embodiment, the same or independent encoders are used to perform semantic encoding operations on the source language text and the retrieved knowledge fragments, respectively, to complete the mapping and transformation of text information into high-dimensional semantic vectors. Encoding the source language text allows for the extraction of lexical features, syntactic features, and global semantic features, resulting in a text feature vector that fully represents the core meaning of the source language text, serving as the basic semantic representation for translation generation. Specifically, for a given source language text x... s =(x s,1 ,x s,2 ,…,x s,n The encoder converts each word or subword into a corresponding embedding vector, and further generates a sequence of text feature vectors of dimension d through positional encoding or self-attention. , where n is the sequence length, and this text feature vector preserves the semantic information and word order structure of the source language.

[0023] Encoding the retrieved knowledge fragments can convert them, which contain bilingual information, into high-dimensional semantic vectors of uniform dimension, resulting in a retrieval result vector. This vector represents the bilingual semantic features of the retrieved knowledge fragments. , where m is the length of the knowledge segment.

[0024] The encoder obtains the text feature vectors of the source language text. And the vector of retrieval results for translated knowledge fragments It is important to note that the search result vector It is obtained by encoding the source language representation in the translated knowledge fragment, which also contains the corresponding target language representation. The encoding result is denoted as... , as a reference representation for the target language.

[0025] In practice, an encoder can be built based on a word embedding layer and a multi-layer neural network. The word embedding layer is responsible for mapping the input words to initial vector representations. Subsequent self-attention layers and feedforward network layers further encode the initial vectors contextually, ultimately outputting a high-dimensional semantic vector sequence. It should be noted that when using the same encoder, the source language text and the retrieved knowledge fragments share the same set of encoding parameters, which helps maintain consistency between the two in the semantic space. When using independent encoders, both can have their parameters optimized separately to better adapt to the characteristics of their respective inputs.

[0026] S130. In the retrieval enhancement semantic alignment layer, the text feature vector and the retrieval result vector are fused to obtain the enhanced feature vector.

[0027] In this embodiment, the retrieval enhancement generation semantic alignment layer is a core knowledge fusion unit embedded between the encoder and decoder of the large translation model, used to achieve deep coupling and native fusion of source language text semantics and external translation knowledge semantics.

[0028] The text feature vector output by the encoder and the retrieval result vector are jointly input into the retrieval enhancement generative semantic alignment layer (SAL) embedded between the encoder and decoder. In this layer, a bidirectional cross-lingual attention mechanism is used to achieve deep interaction and semantic fusion between the two, generating an enhanced feature vector that incorporates external retrieval knowledge, which serves as the input to the decoder.

[0029] S140. Based on the enhanced feature vector, the target language translation result corresponding to the source language text is generated by the decoder.

[0030] In this embodiment, the decoder is the generation execution unit of the large translation model. It takes the enhanced feature vector output by the enhanced semantic alignment layer as input and performs autoregressive generation inference based on the enhanced feature vector. It sequentially decodes and generates vocabulary, sentences and complete text of the target language. During the generation process, it continuously relies on the fused professional knowledge features and prioritizes the use of domain standard terms, normative sentence patterns and common expressions of the target language. The generated target language translation results achieve the translation effect of unified professional terminology, fluent semantic logic and conformity to domain expression norms while retaining the core semantics of the source language text.

[0031] According to the embodiments of this application, an enhanced feature vector is obtained by fusing the text feature vector and the retrieval result vector in the retrieval enhancement semantic alignment layer. The decoder is then driven by the enhanced feature vector to generate translation results. This can accurately introduce bilingual retrieval knowledge fragments associated with the source language text for semantic assistance, strengthen the cross-language semantic alignment effect, improve the translation accuracy and fluency of professional domain terms and contextual expressions, reduce translation semantic bias and model illusion problems, and significantly improve the overall generation quality and scene adaptability of neural machine translation.

[0032] In one implementation, fusing the text feature vector with the retrieval result vector to obtain an enhanced feature vector may include: A scaling dot product attention mechanism is adopted. The first attention is calculated using the text feature vector as the query vector and the retrieval result vector as the key vector and value vector to obtain the knowledge-enhanced text feature vector. The second attention is calculated using the retrieval result vector as the query vector and the text feature vector as the key vector and value vector to obtain the context-calibrated retrieval result vector. The enhanced text feature vector is combined with the context-calibrated retrieval result vector to obtain the enhanced feature vector.

[0033] In this embodiment, attention calculation is performed using the text feature vector as the query vector (Q), the retrieval result vector as the key vector (K), and the value vector (V). With the source language text semantics as the core, key information such as professional terms and bilingual comparisons related to the source language is accurately matched and extracted from the retrieval knowledge. External translation knowledge is injected into the source language semantics to obtain a knowledge-enhanced text feature vector. For example, in the medical field, the source language text is "patient has ST-segment elevation myocardial infarction," and the retrieval knowledge fragment includes "ST-segment elevation myocardial infarction → ST-segment elevation myocardial infarction." The first attention calculation aligns the word "myocardial infarction" in the source language with "myocardial infarction" in the retrieval knowledge fragment and integrates the target language translation information "myocardial infarction" into the source language representation to obtain a knowledge-enhanced text feature vector.

[0034] Attention is calculated using the retrieval result vector as the query vector (Q), the text feature vector as the key vector (K), and the value vector (V). Centered on the retrieved knowledge, the model filters, corrects, and adapts the retrieved knowledge in conjunction with the specific context of the source language text, eliminating irrelevant and redundant retrieved knowledge to obtain a context-calibrated retrieval result vector. This ensures a high degree of match between the retrieved knowledge and the current translation context. Taking the aforementioned medical case as an example, the abbreviation "STEMI" in the retrieved knowledge fragment may have different meanings in different contexts. However, after performing a second attention calculation with the source language text "the patient presented with symptoms of ST-segment elevation myocardial infarction," the translation model can associate "STEMI" with "ST-segment elevation myocardial infarction," thereby calibrating the semantic representation of the retrieved knowledge in this specific context and obtaining a context-calibrated retrieval result vector.

[0035] The knowledge-enhanced text feature vector is combined with the context-calibrated retrieval result vector to generate an enhanced feature vector. The combination method can be vector addition, weighted summation, or linear transformation after concatenation, etc., and there are no specific limitations here.

[0036] In the semantic alignment layer for enhanced retrieval, the source language representation and the retrieval representation are fused through bidirectional cross-lingual attention computation and a semantic space adaptive alignment mechanism. On the one hand, adaptive weights are assigned to translation knowledge based on semantic relevance, strengthening key knowledge features such as professional terminology and standard bilingual expressions that are highly matched with the source language text. On the other hand, cross-lingual semantic bias is eliminated, and external translation knowledge is accurately injected into the semantic representation of the source language text. The enhanced feature vector obtained after fusion not only fully preserves the core semantic information of the source language text but also deeply integrates professional domain translation knowledge, thereby providing the decoder with an enhanced semantic context rich in external knowledge.

[0037] According to the embodiments of this application, bidirectional interactive calibration of source language semantics and retrieved knowledge is achieved through bidirectional scaling dot product attention calculation. This not only enhances the professionalism and accuracy of source language representation through external professional knowledge, but also calibrates the adaptability and effectiveness of retrieved knowledge through source language context, thereby improving the accuracy and efficiency of cross-language semantic fusion.

[0038] In one embodiment, before fusing the text feature vector with the retrieval result vector, the method may further include: The text feature vector and the retrieval result vector are mapped to the same semantic space through a cross-language mapping function to achieve semantic alignment. The cross-language mapping function is obtained by training based on the alignment loss between the text feature vector of the source language text and the reference representation of the target language.

[0039] In this embodiment of the application, the cross-language mapping function (M The `Simplified` property is a learnable semantic space transformation function used to project semantic vectors from different languages ​​into a unified high-dimensional space, eliminating representational differences between the source and target languages. The alignment loss serves as the supervisory loss for training the cross-language mapping function. It is constructed by calculating the semantic distance between the text feature vectors of the source language text and the reference representation of the target language, with the training objective being to minimize this loss. The target language reference representation can be a baseline semantic vector obtained by encoding translated text from the standard target language, providing a standard supervisory signal for cross-language mapping.

[0040] Call the cross-language mapping function after training is complete. M The text feature vectors of the source language text are respectively And the vector of retrieval results for translated knowledge fragments Perform vector transformation to obtain the mapped vector. and By projecting two types of vectors belonging to different language systems and encoding sources into the same semantic space, basic cross-linguistic semantic alignment is achieved, eliminating the vector space misalignment problem caused by language differences.

[0041] The cross-lingual mapping function takes the text feature vectors of the source language text as input and the target language reference representation as the supervision standard. It constructs an optimization objective by calculating the alignment loss between the two, and continuously updates the mapping function parameters using the backpropagation algorithm until the alignment loss converges, thus completing the training and optimization of the cross-lingual mapping function. By minimizing the alignment loss, the semantic vectors of the source language and the target language are made closer to each other in the vector space.

[0042] In practice, alignment loss ,in, This represents the text feature vector of the source language text. For the target language reference representation.

[0043] According to the embodiments of this application, the spatial unification of source language semantics and translation knowledge semantics is achieved through cross-language mapping functions, which solves the problems of misalignment of semantic representations of different languages ​​and incompatibility of vector spaces, effectively improves the feature fusion accuracy, ensures the cross-language alignment effect of professional terms, and improves the terminology accuracy and semantic consistency of translation results.

[0044] In one implementation, the calculation formula for the scaling dot product attention mechanism can be: Where Q can be the query vector, K can be the key vector, V can be the value vector, d can be the dimension of the key vector, and T can be the transpose of the key vector. The expression for the knowledge-enhanced text feature vector can be: The expression for the context-calibrated retrieval result vector can be: , where x s x is the text feature vector. r For the retrieval result vector, These can be projection matrices for queries, keys, and values, respectively.

[0045] In one embodiment, the retrieved knowledge fragment includes retrieved knowledge fragments from multiple different knowledge sources; before encoding the retrieved knowledge fragment by the encoder, the method further includes: By using a multi-source data fusion reasoning network model, gated attention weighted fusion is performed on the retrieved knowledge fragments from various knowledge sources to obtain the target retrieved knowledge fragments associated with the source language text.

[0046] In this embodiment, the multi-source knowledge fusion reasoning network is a dedicated network module designed for the integration of multi-source translation knowledge, used for adaptive filtering and fusion of heterogeneous knowledge from multiple sources. Knowledge sources may include domain-specific terminology databases, standard bilingual corpora, industry-standard document databases, and historical high-quality translation databases, each providing translation knowledge from different dimensions.

[0047] This process retrieves relevant knowledge fragments from multiple independent knowledge sources in batches, based on the characteristics of the source language text. These sources differ in knowledge type, professional attributes, and expression formats, allowing for the supplementation of translation knowledge from multiple dimensions, including terminology, sentence structure, and norms. Specifically, each retrieval result fragment is represented as a vector. Assuming there are k knowledge sources, the retrieval result vector output by the i-th knowledge source is denoted as r. i .

[0048] Multi-source retrieved knowledge fragments are input into the data multi-source fusion inference network model. Gating units remove semantically irrelevant and redundant knowledge fragments from the source language text. Based on an attention mechanism, fusion weights are dynamically calculated and assigned according to the semantic relevance and professional matching degree between each knowledge source and the source language text. Specifically, the data multi-source fusion inference network model obtains the hidden state h of the current decoder. For the i-th knowledge source, the formula for calculating the gating weight is: ,in, W is the gating weight for the i-th knowledge source. r and W h For a learnable projection matrix, For the weight vector, This is the hidden state of the decoder.

[0049] The effective knowledge fragments are weighted and fused according to their weights to generate a target retrieval knowledge fragment that is highly adapted to the source language text and is concise in information. Specifically, the expression of the weighted and fused target retrieval knowledge fragment is: ,in, This is the weighted and fused target retrieval knowledge fragment vector. The total number of knowledge sources. It is the sum of the weights of all k knowledge sources.

[0050] According to the embodiments of this application, a multi-source data fusion inference network model is used to realize the gated attention weighted fusion of multi-source retrieved knowledge, which effectively integrates high-quality translation knowledge from different knowledge sources, dynamically adapts to the context of the source language text, and removes redundant interference information, thereby improving the accuracy and adaptability of retrieved knowledge.

[0051] In one implementation, prior to acquiring the retrieval knowledge fragment associated with the source language text, the method may further include: A dual-encoder structure is used to encode high-frequency bilingual term pairs in the domain, and a multilayer perceptron is used to compress the encoded features to generate compact semantic vectors; the dual-encoder structure includes a source language encoder and a target language encoder. Based on the compact semantic vector, construct the dynamic translation knowledge vector base; The acquisition of retrieval knowledge fragments associated with the source language text includes: By employing a hybrid retrieval strategy, a search is performed in the dynamic translation knowledge vector database to obtain retrieval knowledge fragments associated with the source language text.

[0052] In this embodiment, the high-frequency bilingual terminology pair can be source-target language terms that are frequently used in professional scenarios such as medicine, law, and engineering, and whose translations are fixed and consistent. Hybrid retrieval includes: precise terminology matching, semantic vector retrieval, and family-based assisted retrieval. Precise terminology matching can quickly locate standard terminology pairs through precise string matching of keywords or phrases; semantic vector retrieval can encode source language text into query vectors and perform approximate nearest neighbor search in a dynamic translation knowledge vector base to find semantically similar knowledge fragments; for low-resource languages, family-based assisted retrieval can leverage vector representations of high-resource languages ​​within the same language family for cross-language transfer retrieval.

[0053] A dual-encoder structure, comprising a source language encoder and a target language encoder, is employed to semantically encode high-frequency bilingual terminology pairs within the domain, fully extracting the unique features of the bilingual terms. Specifically, this involves extracting frequently occurring bilingual terminology pairs from professional corpora (such as medical literature, legal provisions, and technical manuals). s ,t t ), to use the source language term t s Input source language encoder E s Target language terminology t t Input target language encoder E tThis yields two original vectors E. s (t) s ) and E t (t) t ).

[0054] The high-dimensional encoded features are reduced in dimensionality and refined using a multilayer perceptron (MLP), eliminating redundant features and generating compact semantic vectors that retain the core bilingual semantics. Specifically, the two vectors are concatenated and input into the MLP for compression and nonlinear transformation. The calculation formula is as follows: ,in, For vector concatenation, an MLP typically contains one or two fully connected layers and an activation function (such as ReLU). The output z t The dimension is much smaller than the original dimension, thus achieving compact storage.

[0055] A unified index and storage system is established for the compact semantic vectors corresponding to high-frequency bilingual terms across all domains, forming a dynamic translation knowledge vector library (TKVL). Specifically, the compact vectors z of all term pairs are indexed and stored. t The corresponding original terminology text, language tags, and other information are stored in the vector library and indexed for quick retrieval later.

[0056] A hybrid retrieval strategy is employed to perform searches in a dynamic translation knowledge vector base. By precisely matching standard terms and using semantic similarity to match related contextual knowledge, the retrieved knowledge fragments are obtained that are highly adapted to the source language text in terms of semantics, domain, and context.

[0057] According to the embodiments of this application, high-density representation of terminology knowledge is achieved through dual encoder encoding and multilayer perceptron compression, constructing a lightweight and efficient dynamic translation knowledge vector library. Then, hybrid retrieval is used to balance accurate matching and semantic association, ensuring the professionalism, standardization, and adaptability of translation knowledge from the source of knowledge.

[0058] In one embodiment, after encoding the retrieved knowledge fragment using the encoder to obtain a retrieval result vector, the method further includes: Using the retrieved matching bilingual knowledge fragments as positive samples and the semantically similar non-matching knowledge fragments as negative samples, a contrastive learning loss function is used to perform contrastive learning optimization on the retrieval result vector in order to update the dynamic translation knowledge vector database.

[0059] In this embodiment, standard bilingual knowledge fragments that match the source language text retrieval and are semantically completely corresponding are used as positive samples; non-matching bilingual knowledge fragments that are semantically similar to the source language text, easily causing confusion, but do not match the current translation scenario are selected as negative samples to construct a dedicated sample pair for contrastive learning. Specifically, retrieval result vectors that are manually annotated or determined based on known bilingual alignment information and truly match the source language text are used as positive samples. Fragments that are semantically similar to the source language text but are not correctly matched, as well as fragments randomly sampled from the knowledge base, are selected from the retrieval results as negative samples.

[0060] The retrieval result vector and the positive and negative sample vectors are input together. A contrastive learning loss function is used to calculate the semantic representation loss. By optimizing the objective of reducing the semantic distance between the retrieval result vector and the positive samples, and increasing the semantic distance between the retrieval result vector and the negative samples, the semantic representation of the retrieval result vector is optimized, improving its semantic accuracy and anti-confusion ability. Specifically, the expression for the contrastive learning loss function is: ,in, This is the cosine similarity calculation function. For temperature parameters, For positive sample knowledge vectors, This is the knowledge vector for negative samples.

[0061] The retrieved result vectors optimized through comparative learning are synchronously updated to the dynamic translation knowledge vector base, replacing the original vectors with insufficient representation accuracy or supplementing them with new optimized vectors, thereby realizing the dynamic iteration and continuous optimization of the dynamic translation knowledge vector base.

[0062] According to the embodiments of this application, by constructing positive and negative samples and optimizing the contrastive learning loss function, the semantic discriminability and representation accuracy of the retrieval result vector are significantly improved, thereby realizing the continuous iterative update of the dynamic translation knowledge vector base.

[0063] In practical applications, a dedicated knowledge feedback mechanism is set up, relying on the Straight-Through Estimator (STE) to achieve reverse feedback and parameter iteration of retrieved professional knowledge to the large-scale translation model. Specifically, the gradient approximation calculation formula is as follows: The gradient transfer calculation is completed; among them, The model loss function, For the model's learnable parameters, This mechanism retrieves semantic feature vectors corresponding to the knowledge being retrieved. It effectively establishes a gradient propagation link between retrieved knowledge and model parameters, avoiding gradient interruption issues in discrete retrieval scenarios. This enables the continuous penetration and iterative updating of domain terminology and industry standard knowledge, allowing model parameters to continuously adapt to the translation features of the professional domain, further improving the accuracy of professional terminology translation and the model's adaptability to various scenarios.

[0064] To achieve the continuous integration of terminological knowledge into model parameters.

[0065] To facilitate understanding, let's take the German-English translation of an industrial equipment safety manual as an example, as follows: 1. Input the source language text to be translated. The standard German phrase from the Industrial Equipment Safety Technical Manual was selected as the source text to be translated. The specific input content is: "Die Sicherheitsvorrichtung muss gemäß DIN EN ISO 13849-1 auf PerformanceLevel d ausgelegt sein."

[0066] 2. Multi-source knowledge retrieval and fusion The search enhancement module is activated, and a hybrid search strategy is used to retrieve multi-source professional knowledge fragments that match the industry standard statement from the dynamic translation knowledge vector base. The search resources cover the industry standard terminology database, the equipment manufacturer's customized document database, and the historical translation record database of industrial technical texts, accurately acquiring three types of highly adaptable knowledge resources: (1) Industry standard terminology: Performance Level d corresponds to the industry-standard abbreviation PLd; (2) Equipment manufacturer document preferred terminology: Sicherheitsvorrichtung is a preferred translation for enterprise customization as safety mechanism; (3) Historical translation record of industrial regulations: The standard translation of the German fixed phrase muss...ausgelegt sein is shall comply.

[0067] Furthermore, the above-mentioned multi-source heterogeneous industrial knowledge fragments are further gated attention-weighted fusion through a data multi-source fusion reasoning network model. This filters out redundant knowledge that is generalized and not industry-specific, integrates three types of core information—industry standards, enterprise customization preferences, and regulations—and generates standardized target retrieval knowledge fragments adapted to industrial technical manual scenarios.

[0068] 3. Retrieval Enhancement: Semantic Alignment Layer Enhancement The encoder encodes the German source text and the fused industrial target retrieval knowledge fragments separately, generating corresponding source language text feature vectors and retrieval result vectors. A semantic alignment layer is generated through retrieval enhancement to achieve cross-language semantic alignment and professional knowledge enhancement. Specifically: it accurately identifies the semantic equivalence between "Performance Level d" and the industry standard abbreviation "PLd," achieving a semantic similarity of 0.94, thus realizing accurate semantic matching between the full name and the industry abbreviation; it injects the equipment manufacturer's specific terminology preferences into the source language semantic representation, correcting the standardized expression bias of general translations; and it aligns with the fixed sentence structure features of industrial regulatory texts, optimizing sentence structure to adapt to the rigorous writing standards of industrial technical documents.

[0069] 4. Generate translation results The decoder generates a highly reliable feature vector that has undergone semantic alignment, knowledge enhancement, and sentence structure optimization. It integrates industry standard terminology, enterprise-customized expressions, and regulatory normative sentence structures to ultimately output a precise and compliant professional translation: "The safety mechanism shall comply with DIN EN ISO 13849-1 PL drequirements."

[0070] The translation output in this application is accurate in terminology, consistent in style, and conforms to standards. However, when the same sentence is translated using a traditional machine translation model, the output is: "The safety device must be designed according to DIN EN ISO 13849-1 for performance level d." This translation only achieves a literal semantic conversion and has defects such as non-standard industrial terminology, expressions that do not conform to industry standards, and failure to fit the enterprise's translation paradigm. It cannot meet the rigor and standardization requirements of industrial technical manuals.

[0071] In one embodiment, after generating the target language translation result corresponding to the source language text through the decoder, the method further includes: Based on the semantic similarity between the target word generation probability and the retrieval result vector, a first confidence score is obtained by evaluating the target language translation result. Based on the semantic alignment between the sequence-level translation results and the retrieved knowledge fragments, a second confidence score is obtained by evaluating the target language translation results. The first confidence score and the second confidence score are weighted and fused to obtain the overall confidence score of the target language translation result; Determine whether the overall confidence level is greater than or equal to a preset confidence threshold; If the overall confidence level is greater than or equal to the preset confidence threshold, the target language translation result is determined as a valid language translation result, and the valid language translation result is output.

[0072] In this embodiment, the target word generation probability is the predicted probability of the current word output by the model when the decoder generates target language vocabulary through autoregression, reflecting the reliability of individual word generation. The sequence-level translation result is the complete sentence or paragraph-level target language translated text generated by the decoder, i.e., the overall translation.

[0073] Based on the target word generation probability and combined with the semantic similarity between the translation result and the retrieval result vector, a lexical-level local confidence assessment is performed on the translation to obtain a first confidence score, which is used to verify the translation accuracy of individual technical terms and core vocabulary. Specifically, for each decoded target word, its generation probability and its semantic similarity with the corresponding target word in the retrieved knowledge fragment are obtained. The formula for calculating the first confidence score of the target word is as follows: ,in, Let be the first confidence score of the t-th target word. For target words, This refers to all target language sequence fragments generated by the decoder before time position t. Let be the semantic similarity between the t-th target word and the corresponding target language word in the retrieved knowledge fragment. t is the scaling factor, and t is the index of the current generated target word position (time step). This represents the generation probability. The first confidence score for the entire sentence is the average of the scores of each word, calculated using the following formula: , where n is the total number of words in the target language translation result, i.e. the length of the generated sequence.

[0074] For the complete sequence-level translation result, its overall semantic alignment with the retrieved knowledge fragment is calculated, and a global confidence assessment is conducted to obtain a second confidence score, which is used to verify the overall semantic, logical, and sentence structure compliance and consistency of the translation. Specifically, the entire target language translation result y 1:t Sequence-level alignment assessment is performed with the target language portion of the retrieved knowledge fragment. Similarity can be calculated using the BLEU metric, with the second confidence score calculated using the following formula: ,in, The complete sequence of target language translation results generated by the decoder.

[0075] The first confidence score and the second confidence score are weighted and fused according to preset weights to obtain a comprehensive confidence score that takes into account both lexical accuracy and overall semantic reasonableness, thus achieving an organic combination of local and global evaluation. Specifically, the formula for calculating the comprehensive confidence score is: ,in, These are the weight parameters.

[0076] The calculated overall confidence level is compared with a preset confidence threshold to determine whether the overall confidence level meets the preset qualification standard. If the overall confidence level is greater than or equal to the preset confidence threshold, the target language translation result is determined to be a valid language translation result and is output as the final qualified translation; if it does not meet the standard, a secondary search and manual verification process can be triggered.

[0077] In practical applications, user feedback can be recorded, and the confidence threshold θ can be dynamically adjusted through online learning. The formula for calculating the updated confidence threshold is: ,in, The current confidence threshold, The updated confidence threshold. For the accuracy loss based on user feedback, This is the learning rate.

[0078] According to the embodiments of this application, a comprehensive confidence calibration of the translation results is achieved through two-level evaluation, weighted fusion and threshold determination of lexical-level local confidence and sequence-level global confidence, which not only ensures the accuracy of the translation of core professional terms, but also ensures the semantic consistency and logical rationality of the overall translation.

[0079] To facilitate understanding, a specific application scenario of medical report translation is used as an example for illustration, as follows: 1. Input the source language text to be translated. Typical source language texts from clinical medical reports are selected as translation inputs, such as: "The patient presented with symptoms of ST-segment elevation myocardial infarction".

[0080] 2. Obtaining knowledge fragments through multi-source knowledge retrieval By employing a hybrid retrieval strategy within the dynamic translation knowledge vector base through the retrieval enhancement module, relevant knowledge fragments from multiple source knowledge bases in the medical field were retrieved. The retrieval successfully identified two types of highly applicable medical knowledge resources: a terminology database and a clinical case database. The specific retrieval results are as follows: (1) Medical terminology database matching standard bilingual term pair: ST-segment elevation myocardial infarction; (2) Matching and associating clinical case database with diagnostic and treatment knowledge fragments: STEMI patients need to undergo PCI treatment immediately.

[0081] Furthermore, a multi-source data fusion inference network model is used to perform gated attention-weighted fusion of the aforementioned multi-source retrieved knowledge fragments, eliminating redundant and invalid information to obtain target retrieved knowledge fragments adapted to the current medical text context. Combining the adaptation weight allocation rules of multi-source knowledge, the weight of the medical terminology database is set to 0.7, and the weight of the clinical case database auxiliary knowledge is set to 0.3, ensuring the accuracy of terminology translation.

[0082] 3. Encoding and Cross-Language Semantic Alignment Enhancement An encoder is used to encode the source language medical text and the fused target retrieval knowledge fragment, generating corresponding text feature vectors and retrieval result vectors. Then, a cross-language mapping function for semantic alignment is generated through retrieval enhancement to map the text feature vectors and retrieval result vectors to the same semantic space, achieving semantic alignment. A bidirectional scaling dot product attention mechanism is used to calculate the semantic relevance. The attention matching score between the source language text feature vector and the retrieval knowledge vector corresponding to "STEMI" is 0.92, indicating extremely high semantic matching. Finally, an enhanced feature vector incorporating professional medical knowledge is generated.

[0083] 4. The decoder generates the target language translation result. The decoder performs autoregressive decoding based on the enhanced feature vectors to generate the corresponding target language translation result: "The patient shows symptoms of ST-segment elevation myocardial infarction (STEMI)".

[0084] 5. Multi-dimensional confidence verification and result output The generated translation is evaluated for confidence using a confidence calibration module. Lexical-level terminology matching confidence and sequence-level overall semantic alignment confidence are calculated separately, and then weighted and fused to obtain a comprehensive confidence score. This comprehensive confidence score is compared with a preset confidence threshold. The core medical terminology matching score of the translation result is 0.95, higher than the preset confidence threshold of 0.85. Based on a comprehensive assessment, the translation result is semantically accurate, uses standardized terminology, and is relevant to the clinical medical scenario, thus passing the verification and being output as a valid translation.

[0085] Figure 2 This is a schematic diagram of the architecture of a neural machine translation system based on retrieval enhancement generation, provided for this application. Figure 2 As shown, the system architecture of the embodiments in this specification mainly includes the following parts: Input layer: includes source language input module 201, where users input the professional field text to be translated (i.e., source language text).

[0086] The knowledge preparation layer includes a retrieval enhancement module 202, a dynamic translation knowledge vector library 203, and an encoder 204. The retrieval enhancement module 202 uses the source language text as a query command and retrieves relevant retrieval knowledge fragments from the dynamic translation knowledge vector library 203 using a hybrid strategy of precise terminology matching and semantic similarity retrieval. The dynamic translation knowledge vector library 203 transforms the original bilingual corpus into compact semantic vectors and binds them to the original text, supporting efficient retrieval and dynamic updates through comparative learning. The dynamic translation knowledge vector library 203 simultaneously receives offline database construction data from the retrieval corpus and real-time retrieval requests from the retrieval enhancement module 202, outputting standardized professional knowledge vectors. The retrieval corpus serves as an external offline raw data source for the entire system, storing terminology databases and bilingual corpora in fields such as medicine, law, and engineering, providing offline data materials for constructing the dynamic vector library. The encoder 204 encodes the source language text and the target retrieval knowledge fragments separately, obtaining text feature vectors and retrieval result vectors.

[0087] The core processing layer, the semantic alignment layer 205, enhances retrieval and generates semantic alignment. It unifies text feature vectors and retrieval result vectors into the same semantic space through a cross-language mapping function. A bidirectional scaling dot product attention mechanism is employed to achieve interactive fusion of the two types of vectors: using the source language vector as the query, it strengthens the semantic injection of external knowledge; using the knowledge vector as the query, it calibrates the adaptability of knowledge to the source language context; and outputs an enhanced feature vector that integrates source language semantics and professional knowledge.

[0088] The generation layer includes a decoder 206 and a confidence calibration module 207. The decoder 206 takes the enhanced feature vector as input and performs autoregressive generation, decoding word by word to generate the target language text. The target language text generated by the decoder 206 is then verified by the confidence calibration module 207 through confidence evaluation to obtain the effective language translation result, which is then output as the final result.

[0089] In practical applications, a compact dynamic translation knowledge vector library (TKVL) can be pre-generated using a knowledge distillation module, with its data size controlled within 500MB, which can be directly deployed on the NPU accelerator card of an edge server. The core module of the large translation model (retrieval enhancement and semantic alignment layer) is packaged into a TensorRT inference engine after model pruning and quantization compression, enabling real-time translation with end-to-end latency of less than 50ms on edge devices such as Jetson AGX Orin. The retrieval enhancement module achieves offline retrieval based on a localized terminology database (such as a subset of SNOMED CT medical terms), without relying on cloud services. The confidence calibration module is simplified to a two-stage verification mechanism: when the terminology matching degree is lower than a preset threshold, a cloud review process is automatically triggered to balance low latency at the edge and reliability of translation results. This allows for basic translation services to be provided in environments with no or weak network coverage, and the quality of results can be further improved through cloud review when conditions permit, making it suitable for edge terminal scenarios such as medical and industrial applications where response time and availability are critical.

[0090] Furthermore, the retrieval enhancement module can be deployed on an Elasticsearch cluster, supporting a hybrid strategy of multilingual vector retrieval and keyword retrieval, and achieving automatic scaling of the service through Kubernetes. The core module of the large-scale translation model adopts a model parallel strategy, deploying the encoder, retrieval enhancement generation semantic alignment layer, and decoder on NVIDIA A100 GPU node groups to achieve low-latency inference under high-concurrency requests. The knowledge distillation module is built on the Faiss vector database and uses the Spark distributed computing framework to achieve large-scale comparative learning training. The confidence calibration module is deployed as an API gateway plugin to monitor and verify the confidence index of translation requests in real time. It is suitable for multinational enterprises' batch processing scenarios of multilingual documents. By dynamically allocating computing resources through a load balancer, it can effectively ensure system throughput and service stability during peak periods. At the same time, the system supports interface with existing translation management platforms (such as TMS) through standard APIs, achieving seamless integration with enterprise workflows, making it easy for users to directly embed it into existing business processes.

[0091] In one implementation, an incremental learning online optimization framework is set up for fields requiring continuous updates of specialized terminology (such as legal provisions and industry standard translation), enabling dynamic iteration and knowledge updates of the system. Specific implementations include: 1) New term pairs are generated into vectors in real time via dual encoders and embedded into incremental partitions of the Dynamic Translation Knowledge Vector Library (TKVL), eliminating the need for a full reconstruction of the entire vector library; 2) An online comparative learning engine optimizes and updates the vector representations daily, retaining semantic snapshots of historical versions and supporting rollback and auditing; 3) A retrieval enhancement semantic alignment layer is equipped with pluggable attention heads, supporting dynamic loading of domain-specific parameter modules (such as medical and legal adapters) to adapt to different professional scenarios; 4) A confidence calibration module records user feedback data and dynamically adjusts multi-source fusion weights using a bandit algorithm, improving the model's adaptability to user preferences. Suitable for fields such as legal technology and industry compliance, the model can be adaptively adjusted within 24 hours of regulatory or standard updates, eliminating the need for full retraining or deployment of new versions, significantly reducing the maintenance cost and iteration cycle of professional translation systems.

[0092] In one implementation, for scenarios involving the translation of mixed text and images in documents, the system supports the translation of multimodal content containing both text and images, such as technical drawings and product manuals. Specifically, the retrieval enhancement module integrates an OCR recognition unit and an image feature extractor, enabling it to identify terminology labels (such as "Fig. 3A") from technical drawings and establish associations with corresponding terms in the text. The retrieval enhancement generates a semantic alignment layer that extends the cross-modal attention mechanism, achieving semantic alignment between text descriptions and the spatial relationships of image elements. The dynamic translation knowledge vector library (TKVL) stores text-image comparison fragments, including precise matching pairs based on terminology and semantically based photo segments, such as the association vector between molecular structure diagrams and indication text in drug manuals. The confidence calibration module includes a visual consistency evaluation unit to detect the matching degree between the text translation results and the illustration annotations, avoiding inconsistent translation deviations in text-image related terms. For the automatic multilingual generation of medical device manuals, this significantly improves the translation consistency of text-image related terms, enhancing the overall quality and readability of professional document translation.

[0093] In one implementation, several specific optimization strategies are set up for low-resource languages ​​with scarce corpora (such as Swahili) to overcome the translation performance bottleneck caused by insufficient parallel corpora. Specifically: Hybrid retrieval strategy: Construct a three-tiered retrieval mechanism that integrates precise terminology matching, semantic vector retrieval, and linguistic family-assisted retrieval. Retrieval weights are allocated based on terminology priority, and results are rearranged. This not only locks in the standard translations of specialized terms but also leverages linguistic family data to supplement contextual information for low-resource languages, effectively improving the completeness and adaptability of retrieval results.

[0094] Language-specific bias terms: In the attention computation module and cross-language mapping function of the retrieval enhancement semantic alignment layer, language-specific learnable bias matrices or vectors are embedded. Parameters are initialized based on features from the same language family and dynamically updated during training to correct vector alignment biases caused by word order and grammatical differences in low-resource languages, thereby improving the accuracy of cross-language semantic matching.

[0095] Asymmetric knowledge distillation: A strong-weak dual-encoder architecture is employed. A high-resource language (e.g., English) serves as the teacher model, preserving complete knowledge, while terminology and semantic knowledge are transferred unidirectionally to a lightweight, low-resource language student model. Differential loss weights and data compression ratios are set, and model parameters are updated through gradient pass-through estimation, achieving effective knowledge transfer without relying on a large amount of low-resource parallel corpora.

[0096] Adaptive Confidence Calibration: The confidence calibration module sets adaptive thresholds for low-resource languages, appropriately relaxes the confidence requirements for local terms, but strengthens the checks on global sentence consistency and domain compliance, ensuring translation fluency while avoiding serious deviations between terminology and core semantics.

[0097] The accuracy of terminology translation in low-resource language professional translation is increased to 2.3 times that of the general model, which significantly improves the translation effectiveness and model robustness in low-resource language professional translation scenarios, and effectively solves the industry pain points of scarce low-resource corpora, large terminology translation deviations, and inaccurate semantic alignment.

[0098] Figure 3 This application provides a schematic diagram of a neural machine translation device based on retrieval-enhanced generation, applied to a large translation model. The large translation model includes an encoder, a decoder, and a retrieval-enhanced generation semantic alignment layer embedded between the encoder and the decoder. The device may include: The acquisition module 310 is used to acquire source language text and retrieval knowledge fragments associated with the source language text, wherein the retrieval knowledge fragments include source language expressions and corresponding target language expressions; The encoding module 320 is used to encode the source language text using the encoder to obtain a text feature vector; and to encode the retrieved knowledge fragment using the encoder to obtain a retrieval result vector. The fusion module 330 is used to fuse the text feature vector and the retrieval result vector in the retrieval enhancement semantic alignment layer to obtain an enhanced feature vector; The generation module 340 is used to generate the target language translation result corresponding to the source language text through the decoder based on the enhanced feature vector.

[0099] Based on the same idea, this application also provides a device corresponding to the above method.

[0100] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 4 As shown in the figure, a neural machine translation device 400 based on retrieval enhancement generation provided in this application embodiment includes a memory 430, a processor 410 and a computer program 420 stored in the memory. The processor 410 executes the computer program 420 to implement the neural machine translation method based on retrieval enhancement generation described in any of the above embodiments.

[0101] This application provides a retrieval-enhanced neural machine translation device, which may include a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the retrieval-enhanced neural machine translation method described in any of the above embodiments.

[0102] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0103] Obviously, those skilled in the art should understand that the various units or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device, or fabricating them separately as individual integrated circuit modules, or fabricating multiple modules or steps into a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.

[0104] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A neural machine translation method based on retrieval enhancement generation, characterized in that, Applied to a large-scale translation model, the large-scale translation model including an encoder, a decoder, and a retrieval-enhanced semantic alignment layer embedded between the encoder and the decoder, the method includes: Obtain source language text and retrieval knowledge fragments associated with the source language text, wherein the retrieval knowledge fragments include source language expressions and corresponding target language expressions; The source language text is encoded using the encoder to obtain a text feature vector; the retrieved knowledge fragment is encoded using the encoder to obtain a retrieval result vector. In the retrieval enhancement semantic alignment layer, the text feature vector and the retrieval result vector are fused to obtain the enhanced feature vector; Based on the enhanced feature vector, the decoder generates the target language translation result corresponding to the source language text.

2. The method according to claim 1, characterized in that, The process of fusing the text feature vector with the retrieval result vector to obtain the enhanced feature vector includes: A scaling dot product attention mechanism is adopted. The first attention is calculated using the text feature vector as the query vector and the retrieval result vector as the key vector and value vector to obtain the knowledge-enhanced text feature vector. The second attention is calculated using the retrieval result vector as the query vector and the text feature vector as the key vector and value vector to obtain the context-calibrated retrieval result vector. The enhanced text feature vector is combined with the context-calibrated retrieval result vector to obtain the enhanced feature vector.

3. The method according to claim 1, characterized in that, Before fusing the text feature vector with the retrieval result vector, the method further includes: The text feature vector and the retrieval result vector are mapped to the same semantic space through a cross-language mapping function to achieve semantic alignment. The cross-language mapping function is obtained by training based on the alignment loss between the text feature vector of the source language text and the reference representation of the target language.

4. The method according to claim 2, characterized in that, The calculation formula for the scaled dot product attention mechanism is as follows: Where Q is the query vector, K is the key vector, V is the value vector, d is the dimension of the key vector, and T is the transpose of the key vector; The expression for the knowledge-enhanced text feature vector is: The expression for the context-calibrated retrieval result vector is: , where x s x is the text feature vector. r For the retrieval result vector, These are the projection matrices for the query, key, and value, respectively.

5. The method according to claim 1, characterized in that, The retrieved knowledge fragments include retrieved knowledge fragments from multiple different knowledge sources; before encoding the retrieved knowledge fragments using the encoder, the method further includes: By using a multi-source data fusion reasoning network model, gated attention weighted fusion is performed on the retrieved knowledge fragments from various knowledge sources to obtain the target retrieved knowledge fragments associated with the source language text.

6. The method according to claim 1, characterized in that, Before obtaining the retrieval knowledge fragment associated with the source language text, the method further includes: A dual-encoder structure is used to encode high-frequency bilingual term pairs in the domain, and a multilayer perceptron is used to compress the encoded features to generate compact semantic vectors; the dual-encoder structure includes a source language encoder and a target language encoder. Based on the compact semantic vector, construct the dynamic translation knowledge vector base; The acquisition of retrieval knowledge fragments associated with the source language text includes: By employing a hybrid retrieval strategy, a search is performed in the dynamic translation knowledge vector database to obtain retrieval knowledge fragments associated with the source language text.

7. The method according to claim 6, characterized in that, After encoding the retrieved knowledge fragment using the encoder to obtain the retrieval result vector, the method further includes: Using the retrieved matching bilingual knowledge fragments as positive samples and the semantically similar non-matching knowledge fragments as negative samples, a contrastive learning loss function is used to perform contrastive learning optimization on the retrieval result vector in order to update the dynamic translation knowledge vector database.

8. The method according to claim 1, characterized in that, After generating the target language translation result corresponding to the source language text through the decoder, the method further includes: Based on the semantic similarity between the target word generation probability and the retrieval result vector, a first confidence score is obtained by evaluating the target language translation result. Based on the semantic alignment between the sequence-level translation results and the retrieved knowledge fragments, a second confidence level assessment is performed on the target language translation results to obtain a second confidence level score. The first confidence score and the second confidence score are weighted and fused to obtain the overall confidence score of the target language translation result; Determine whether the overall confidence level is greater than or equal to a preset confidence threshold; If the overall confidence level is greater than or equal to the preset confidence threshold, the target language translation result is determined as a valid language translation result, and the valid language translation result is output.

9. A neural machine translation device based on retrieval enhancement generation, characterized in that, Applied to a large translation model, the large translation model including an encoder, a decoder, and a retrieval-enhanced semantic alignment layer embedded between the encoder and the decoder, the apparatus includes: The acquisition module is used to acquire source language text and retrieval knowledge fragments associated with the source language text, wherein the retrieval knowledge fragments include source language expressions and corresponding target language expressions; The encoding module is used to encode the source language text using the encoder to obtain a text feature vector; and to encode the retrieved knowledge fragment using the encoder to obtain a retrieval result vector. The fusion module is used to fuse the text feature vector and the retrieval result vector in the retrieval enhancement semantic alignment layer to obtain an enhanced feature vector; The generation module is used to generate the target language translation result corresponding to the source language text through the decoder based on the enhanced feature vector.

10. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.