Text conversion method and device, storage medium and electronic equipment
By introducing residual extraction and feature generation modules into the text conversion model, and using weight parameter weighting to process decoded features, the problem of degradation of translation effect in the deep model is solved, and the translation quality is significantly improved.
Patent Information
- Application Number
- CN202310545527.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-15
- Publication Date
- 2024-11-15
AI Technical Summary
The existing text conversion method has significantly reduced the translation effect when the number of model layers is high, and there are technical problems with poor conversion effect, and there is no effective solution.
By introducing residual extraction module and feature generation module in the feature decoding model, the decoding features of the main branch and residual branch are processed by weighting parameter weighting, the model's effect on text sequence conversion is improved, and the poorer effect in the existing technology is solved question.
By weighting the weights of the main branches and residual branches, the translation quality of the text conversion model is significantly improved, the problem of deep model degradation into width widening is alleviated, and the translation effect is improved.
Smart Images

Figure CN118966155A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a text conversion method and device, a storage medium and an electronic device. Background Art
[0002] Machine translation can make communication between people unrestricted by language, thereby promoting economic and cultural exchanges between countries and regions, and facilitating the mutual dissemination of various knowledge. Existing machine translation is usually based on the traditional Transformer model. In order to obtain better translation results, it is usually necessary to provide more high-quality data or increase the number of model parameters, such as increasing the number of model layers.
[0003] When the number of layers of the model is high, the effect of machine translation through the Transformer model will be significantly reduced. In other words, the existing text conversion method has the technical problem of poor conversion effect.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a text conversion method and device, a storage medium and an electronic device, so as to at least solve the technical problem that the existing text conversion method has a poor conversion effect.
[0006] According to one aspect of an embodiment of the present invention, a text conversion method is provided, comprising: obtaining a target text feature obtained by extracting a feature of a first text sequence to be converted; repeating the following steps until N feature decoding layers in a feature decoding model are traversed, wherein the feature decoding model is used to determine a second text sequence matching the first text sequence according to the target text feature, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: obtaining the i-1th reference decoding feature output by the i-1th feature decoding layer, and inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; .... The first weight parameter and the second weight parameter matched by the i-th feature decoding layer, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in the first feature generation module, the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer; when the i is equal to the N, the second text sequence matching the first text sequence is determined based on the i-th reference decoding feature.
[0007] According to another aspect of an embodiment of the present invention, a training method for a text conversion model is provided, comprising: obtaining target sample text features obtained by extracting features from a first sample text sequence to be converted; repeating the following steps until N feature decoding layers in a feature decoding model in training are traversed, wherein the feature decoding model in training is used to determine a second sample text sequence matching the first sample text sequence according to the target sample text features, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: obtaining the i-1th reference decoding feature output by the i-1th feature decoding layer, and inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtaining a first weight parameter and a second weight parameter matching the i-th feature decoding layer. Weight parameters, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in the first feature generation module, the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer; when the i is equal to the N, the second sample text sequence matching the first sample text sequence is determined based on the i-th reference decoding feature; when it is determined according to the second sample text that the feature decoding model in the training meets the convergence condition, the feature decoding model in the training is determined as the target feature decoding model.
[0008] According to another aspect of an embodiment of the present invention, a text conversion device is further provided, comprising: an acquisition unit, used to acquire target text features obtained by extracting features from a first text sequence to be converted; a traversal unit, used to repeat the following steps until N feature decoding layers in a feature decoding model are traversed, wherein the feature decoding model is used to determine a second text sequence matching the first text sequence based on the target text features, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: acquiring the i-1th reference decoding feature output by the i-1th feature decoding layer, and inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtaining Take the first weight parameter and the second weight parameter that match the above-mentioned i-th feature decoding layer, wherein the above-mentioned first weight parameter is used to indicate the feature weight of the above-mentioned i-1th reference decoding feature, and the above-mentioned second weight parameter is used to indicate the feature weight of the above-mentioned i-th residual decoding feature, and the ratio between the above-mentioned first weight parameter and the above-mentioned second weight parameter is greater than or equal to the first target threshold; in the above-mentioned first feature generation module, determine the weighted decoding feature of the above-mentioned i-1th reference decoding feature and the above-mentioned i-th residual decoding feature according to the above-mentioned first weight parameter and the second weight parameter, and determine the above-mentioned weighted decoding feature as the i-th reference decoding feature output by the above-mentioned i-th feature decoding layer; a determination unit is used to determine the above-mentioned second text sequence matching the above-mentioned first text sequence based on the above-mentioned i-th reference decoding feature when the above-mentioned i is equal to the above-mentioned N.
[0009] According to another aspect of an embodiment of the present invention, a training model of a text conversion model is provided, comprising: an acquisition unit, used to acquire target sample text features obtained by extracting features from a first sample text sequence to be converted; a training unit, used to repeat the following steps until N feature decoding layers in the feature decoding model in training are traversed, wherein the feature decoding model in training is used to determine a second sample text sequence matching the first sample text sequence according to the target sample text features, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: acquiring the i-1th reference decoding feature output by the i-1th feature decoding layer, and inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; acquiring a first weight parameter matching the i-th feature decoding layer and a second weight parameter, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in the first feature generation module, the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer; when the i is equal to the N, the second sample text sequence matching the first sample text sequence is determined based on the i-th reference decoding feature; a determination unit is used to determine the feature decoding model in the training as the target feature decoding model when it is determined according to the second sample text that the feature decoding model in the training meets the convergence condition.
[0010] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned text conversion method or the above-mentioned text conversion model training method when running.
[0011] According to another aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above text conversion method or the above text conversion model training method.
[0012] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-mentioned text conversion method or the above-mentioned text conversion model training method through the above-mentioned computer program.
[0013] In an embodiment of the present invention, a target text feature is obtained by extracting a feature of a first text sequence to be converted; the following steps are repeated until N feature decoding layers in a feature decoding model are traversed, wherein the feature decoding model is used to determine a second text sequence matching the first text sequence according to the target text feature, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: the i-1th reference decoding feature output by the i-1th feature decoding layer is obtained, and the i-1th reference decoding feature is input into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; the i-1th reference decoding feature is obtained by extracting a feature of the first text sequence to match the first text sequence according to the target text feature; the i-1th residual ... A first weight parameter and a second weight parameter for code layer matching, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in a first feature generation module, a weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer; when i is equal to N, a second text sequence matching the first text sequence is determined based on the i-th reference decoding feature, thereby completing the text conversion.
[0014] In the above-mentioned text conversion method, when the target text features corresponding to the first text sequence are obtained, they can be processed in sequence in multiple feature decoding layers in the feature decoding model. Specifically, the decoding features of the trunk branch and the decoding features of the residual branch in the processing process can be weighted and summed, and by constraining the ratio between the first weight parameter corresponding to the trunk branch and the second weight parameter corresponding to the residual branch, the weight of the trunk branch in the above-mentioned feature decoding model is improved, thereby improving the conversion effect of the conversion operation on the text sequence through the above-mentioned feature decoding model, thereby solving the technical problem that the existing text conversion method has poor effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0016] Figure 1 is a schematic diagram of a hardware environment of an optional text conversion method according to an embodiment of the present invention;
[0017] Figure 2 is a flow chart of an optional text conversion method according to an embodiment of the present invention;
[0018] Figure 3 is a schematic diagram of an optional text conversion method according to an embodiment of the present invention;
[0019] Figure 4 is a schematic diagram of an interface of an optional text conversion method according to an embodiment of the present invention;
[0020] Figure 5 is a structural schematic diagram of an optional text conversion model according to an embodiment of the present invention;
[0021] Figure 6 is a structural schematic diagram of another optional text conversion model according to an embodiment of the present invention;
[0022] Figure 7 is a structural schematic diagram of another optional text conversion model according to an embodiment of the present invention;
[0023] Figure 8 is a structural schematic diagram of another optional text conversion model according to an embodiment of the present invention;
[0024] Fig. 9 A schematic structural diagram of an optional text conversion device according to an embodiment of the present invention;
[0025] Fig.10 is a schematic structural diagram of an optional electronic device according to an embodiment of the present invention;
[0026] Fig.11 A schematic structural diagram of an optional text conversion model training device according to an embodiment of the present invention;
[0027] Fig.12 is a schematic structural diagram of another optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme 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 only 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 should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] According to one aspect of an embodiment of the present invention, a text conversion method is provided. As an optional implementation, the text conversion method can be applied to, but is not limited to, Figure 1 In the text conversion system shown in FIG. 1 , a terminal device 102, a server 104 and a network 110 are formed. Figure 1 As shown, the terminal device 102 is connected and communicated with the server 104 through the network 110. The above network may include but is not limited to: a wired network, a wireless network, wherein the wired network includes: a local area network, a metropolitan area network and a wide area network, and the wireless network includes: Bluetooth, WIFI and other networks that realize wireless communication. The above terminal device may include but is not limited to at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop, a tablet computer, a PDA, a MID (Mobile Internet Devices), a PAD, a desktop computer, a smart TV, a car-mounted device, etc. The above terminal device 102 may be installed with a client for providing a text conversion function, such as an instant messaging client (which can provide a text conversion function even during a conversation), a translation client, etc.
[0031] The terminal device 102 is also provided with a display, a processor and a memory. The display can be used to display the program interface of the text conversion program. The processor can use the target text conversion model to identify and convert the acquired text sequence to be converted; the memory is used to store the target text conversion model trained by the server 104. It can be understood that when the server 104 completes the training of the target text conversion model, the terminal device 102 receives the target text conversion model sent by the server 104 through the network 110. When the terminal device 102 receives the text conversion request sent by the user, the text sequence carried in the recognition request is recognized and converted by the received target text conversion model.
[0032] The server 104 may be a single server, a server cluster consisting of multiple servers, or a cloud server. The server includes a database and a processing engine. The processing engine is used to process the model training process; the database may be used to store a sample text library for training the text conversion model.
[0033] According to one aspect of the embodiment of the present invention, the text conversion system may further perform the following steps: first, the terminal device 102 performs step S102 to receive a text conversion request; then performs step S104 to send the text conversion request to the server 104 via the network 110;
[0034] Next, in the server 104, steps S106 to S110 are executed to obtain target text features obtained by extracting features from the first text sequence to be converted, wherein the first text sequence is a text sequence extracted from the text conversion request; the following steps are repeated until N feature decoding layers in the feature decoding model are traversed, wherein the feature decoding model is used to determine a second text sequence matching the first text sequence based on the target text features, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: the i-1th reference decoding feature output by the i-1th feature decoding layer is obtained, and the i-1th reference decoding feature is input into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein In which, i is an integer greater than 1 and less than or equal to N; obtain a first weight parameter and a second weight parameter matching the i-th feature decoding layer, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in the first feature generation module, determine the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature according to the first weight parameter and the second weight parameter, and determine the weighted decoding feature as the i-th reference decoding feature output by the i-th feature decoding layer; when i is equal to N, determine a second text sequence matching the first text sequence based on the i-th reference decoding feature;
[0035] Next, the server 104 executes step S112 to send the second text sequence to the terminal device 102 via the network 110 ; the terminal device 102 executes step S114 to display the second text sequence.
[0036] In the above-mentioned embodiment of the present application, a first recognition result is obtained after an image recognition model is used to recognize a first sample image in a sample image set, the sample image set includes multiple sample images, each sample image includes at least one image object, and the first recognition result is used to indicate the image category of the first sample image; a target segmented image corresponding to the first recognition result is determined from a segmented image set, the segmented image set includes multiple segmented images obtained after image segmentation of the sample images in the sample image set, and each segmented image corresponds to an image object in the sample image; a second sample image obtained by synthesizing the target segmented image and the first sample image is recognized by the image recognition model to obtain a second recognition result, and the second recognition result indicates the image category of the second sample image and the image category of the target segmented image; the image recognition model is trained according to a first training loss corresponding to the first recognition result and a second training loss corresponding to the second recognition result, and when the first training loss and the second training loss meet the convergence condition, the trained image recognition model is determined as the target image recognition model, thereby completing the text conversion.
[0037] In the above-mentioned text conversion method, when the target text features corresponding to the first text sequence are obtained, they can be processed in sequence in multiple feature decoding layers in the feature decoding model. Specifically, the decoding features of the trunk branch and the decoding features of the residual branch in the processing process can be weighted and summed, and by constraining the ratio between the first weight parameter corresponding to the trunk branch and the second weight parameter corresponding to the residual branch, the weight of the trunk branch in the above-mentioned feature decoding model is improved, thereby improving the conversion effect of the conversion operation on the text sequence through the above-mentioned feature decoding model, thereby solving the technical problem that the existing text conversion method has poor effect.
[0038] The above is only an example and is not limited in this embodiment.
[0039] As an optional implementation, Figure 2 As shown, the above text conversion method may include the following steps:
[0040] S202, obtaining target text features obtained by extracting features from the first text sequence to be converted;
[0041] S204, repeat the following steps until N feature decoding layers in the feature decoding model are traversed: obtain the i-1th reference decoding feature output by the i-1th feature decoding layer, and input the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature; obtain the first weight parameter and the second weight parameter that match the i-th feature decoding layer; in the first feature generation module, determine the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature according to the first weight parameter and the second weight parameter, and determine the weighted decoding feature as the i-th reference decoding feature output by the i-th feature decoding layer;
[0042] Wherein, the feature decoding model is used to determine a second text sequence matching the first text sequence according to the target text feature, the feature decoding layer includes a first residual extraction module and a first feature generation module, the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold, N is an integer greater than or equal to 2, and i is an integer greater than 1 and less than or equal to N;
[0043] S206: When i is equal to N, determine a second text sequence matching the first text sequence based on the i-th reference decoding feature.
[0044] The specific application scenarios of the above text conversion method are described below. The above text conversion method can be applied to, but not limited to, a text translation scenario and a voice translation scenario. The above translation scenario can be, but not limited to, a translation operation between different languages, and a translation operation between an enemy language and an official language.
[0045] For example, the above-mentioned text conversion method can be in a translation scenario provided by a translation software, in response to a translation request received by a terminal, converting the first text sequence carried in the translation request into a second text sequence in a different language; for another example, the above-mentioned text conversion method can also be in a translation scenario provided by an instant messaging software, in response to a triggering operation on the first text sequence displayed in the above-mentioned instant messaging application interface, triggering a translation request for the first text sequence, and then converting the first text sequence carried in the translation request into a second text sequence in a different language; for another example, in the process of navigating through navigation software, when receiving the user's dialect voice, the dialect voice can be converted into dialect text through the voice recognition function of the navigation software, and then the dialect text is converted into a standard text (such as Mandarin text) using the above-mentioned text conversion method. The above application scenarios are only exemplary descriptions, and do not limit the actual technical scenarios in which the above-mentioned text conversion method can be applied.
[0046] In addition, the execution subject of the above method may be a terminal or a server. In the case where the execution subject of the above text conversion method is a terminal, the conversion model corresponding to the above conversion method may be pre-built into the above terminal, and when the terminal receives the first text sequence to be converted, the pre-built-in conversion model is used to complete the above text conversion process; in the case where the execution subject of the above text conversion method is a server, the conversion model corresponding to the above conversion method may be pre-stored in the server. In the case where the terminal receives the first text sequence to be converted, the first text sequence may be sent to the above server via the above terminal, and then the text conversion process may be completed via the server using the pre-built-in conversion model.
[0047] Specifically, in the above step S202, the process of extracting features from the first text sequence to be converted may be completed in a feature encoding model, for example, the target text features may be extracted in an encoder of a Transformer model based on the first text sequence to be converted.
[0048] It is understandable that the above step S204 can be implemented using N feature decoding layers in the feature decoding model. In a specific embodiment, the above feature decoding model can be a decoder in a Transformer model, and the decoder can include multiple decoding modules.
[0049] In an optional manner, the process of feature extraction and feature decoding of the above-mentioned first text sequence can be completed by two submodules in the same model. For example, the above-mentioned step S202 can be completed by an encoder in a trained Transformer model, and the above-mentioned step S204 can be completed using a decoder in the above-mentioned trained Transformer model. In another optional manner, the process of feature extraction and feature decoding of the above-mentioned first text sequence can be completed by different functional modules in two different models. For example, the above-mentioned feature extraction method can be completed by an encoder in a trained FlowSeq model, and then the above-mentioned step S204 can be completed using a decoder in a trained Transformer model. In this embodiment, the model types and model relationships corresponding to the above-mentioned feature extraction process and feature decoding process are not limited.
[0050] It should be further explained that the feature decoding layer in the above step S204 may include at least a first residual extraction module for extracting residual features and a first feature generation module for performing residual connection. In the i-th feature decoding layer, the residual features can be obtained by the first residual extraction module, and then the changed or newly added changed decoding features, i.e., the i-th residual decoding features, are obtained by further decoding the decoding features transmitted in the previous layer, and then the output result of the i-th feature decoding layer is determined by combining the decoding features transmitted in the previous layer, i.e., the i-1th reference decoding features.
[0051] In the above implementation, the above i-1th reference decoding feature is a backbone feature, and the i-th residual decoding feature is a residual feature, and different weight parameters can be configured for the backbone feature and the residual feature, respectively. In this implementation, the ratio between the weight parameters corresponding to the backbone feature and the residual feature is greater than or equal to the target threshold, thereby achieving the improvement of the weight of the backbone feature.
[0052] In the above S206, when i is equal to N, the method for determining the second text sequence matching the first text sequence based on the i-th reference decoding feature can be to process the i-th reference decoding feature through a linear layer and then output a word (i.e., the characters included in the second text sequence) through Softmax prediction.
[0053] The following combination Figure 3 , Figure 4 A specific application scenario of the above-mentioned implementation mode of the present application is described. Figure 3 As shown, it is an interactive schematic diagram of providing a translation function in an instant messaging application that can provide a translation function based on the above implementation method, such as Figure 3 As shown, the user triggers a translation request by long pressing the communication text on the instant messaging application or through the mini program, and the language detection and translation request distribution module forwards the translation request and calls the translation model, and then forwards the translation result provided by the translation model to the application interface for display to the user. It can be understood that the above-mentioned translation model can include the above-mentioned feature decoding model.
[0054] like Figure 4 As shown, a conversation interface between object accounts is displayed in an instant messaging application that can provide a translation function. In response to the trigger operation of the conversation "Thursday deadline", it is determined that a text conversion request for the first text sequence "Thursday deadline" is received. In this embodiment, the first text sequence can be sent to the corresponding server through the instant messaging application to complete the conversion operation of the first text sequence in the server. For example Figure 4In the case where the server converts the first text sequence into the second text sequence “The deadline is Thursday”, the second text sequence “The deadline is Thursday” may be displayed on the current interface.
[0055] The following combination Figure 5 The structure of a feature decoding layer in the above-mentioned embodiment of the present application is described. Figure 5 As shown, it is a structural schematic diagram of a feature decoding layer in the above-mentioned feature decoding model, including a first residual extraction module 501 and a first feature generation module 502, wherein the first residual extraction module 501 is used to obtain the i-th residual decoding feature according to the i-1-th reference decoding feature, and the first feature generation module 502 is used to determine the reference decoding feature output by the current feature decoding layer according to the i-th residual decoding feature and the i-1-th reference decoding feature.
[0056] In this embodiment, the first weight parameter α can be configured for the backbone feature, i.e., the i-1th reference decoding feature, and the second weight parameter 1 can be configured for the i-th residual decoding feature, and then the weight of the backbone feature can be directly adjusted according to the value of the first weight parameter α.
[0057] Assume that the i-1th reference decoding feature output by the i-1th feature decoding layer is x i-1 The i-th residual decoding feature obtained by the first residual extraction module 501 based on the i-1-th reference decoding feature can be f(x i-1 ), and then determine the i-th reference decoding feature x output by the i-th feature decoding layer i It can be determined by the following formula:
[0058] x i =αx i-1 +f(x i-1 )
[0059] In the above-mentioned text conversion method, when the target text features corresponding to the first text sequence are obtained, they can be processed in sequence in multiple feature decoding layers in the feature decoding model. Specifically, the decoding features of the trunk branch and the decoding features of the residual branch in the processing process can be weighted and summed, and by constraining the ratio between the first weight parameter corresponding to the trunk branch and the second weight parameter corresponding to the residual branch, the weight of the trunk branch in the above-mentioned feature decoding model is improved, thereby improving the conversion effect of the conversion operation on the text sequence through the above-mentioned feature decoding model, thereby solving the technical problem that the existing text conversion method has poor effect.
[0060] In an optional implementation, the step of inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature includes:
[0061] S1, normalize the i-1th reference decoding feature to obtain the i-1th standard decoding feature;
[0062] S1, determine the i-th residual decoding feature based on the i-1-th standard decoding feature.
[0063] In this embodiment, the feature decoding model can be a feature decoding layer based on the Pre-LN (pre-layer normalization) form. It should be noted that in this embodiment, the stability of model training can be improved by adding the feature generation module (for residual connection) and the normalization processing module in each feature decoding layer. However, in the Transformer model in the Pre-LN form, since it relies more on residual connection, when the number of model layers is large, the model will degenerate into increasing the width, limiting the effect of the model.
[0064] In the above-mentioned embodiments of the present application, Figure 5 As shown, the i-1th reference decoding feature can be normalized by the layer-Norm module to obtain a normalized result, and then the i-th residual decoding feature can be obtained by using a subsequent processing module.
[0065] As an optional implementation, in the first feature generation module, determining the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature according to the first weight parameter and the second weight parameter includes:
[0066] S1, determining a backbone reference feature according to the product of a first weight parameter and an i-1th reference decoding feature;
[0067] S2, determining a residual reference feature according to the product of the second weight parameter and the i-th residual decoding feature;
[0068] S3, determining a weighted decoding feature according to the sum of the backbone reference feature and the residual reference feature.
[0069] Correspondingly, in this embodiment, the first weight parameter α can be configured for the backbone feature, i.e., the i-1th reference decoding feature, and the second weight parameter 1 can be configured for the i-th residual decoding feature, and then the weight of the backbone feature can be directly adjusted according to the value of the first weight parameter α.
[0070] Assume that the i-1th reference decoding feature output by the i-1th feature decoding layer is x i-1The i-th residual decoding feature obtained by the first residual extraction module 501 based on the i-1-th reference decoding feature can be f(LN(x i-1 )), and then determine the i-th reference decoding feature x output by the i-th feature decoding layer i It can be determined by the following formula:
[0071] x i =αx i-1 +f(LN(x i-1 ))
[0072] In this embodiment, by increasing the weight of the main branch in the decoder of the Pre-LN Transformer, it is possible to avoid degenerating into a form of increasing width as the model depth increases, thereby effectively improving the translation effect of the Pre-LN Transformer in scenarios with very deep layers.
[0073] In an optional implementation, the determining of the i-th residual decoding feature based on the i-1-th standard decoding feature includes:
[0074] S1, when the feature decoding submodule included in the first residual extraction module is a masked multi-head self-attention submodule, inputting the i-1th standard decoding feature into the masked multi-head self-attention submodule to obtain the i-th residual decoding feature;
[0075] S2, when the feature decoding submodule included in the first residual extraction module is a multi-head self-attention submodule, inputting the i-1th standard decoding feature into the multi-head self-attention submodule to obtain the i-th residual decoding feature;
[0076] S3, when the feature decoding submodule included in the first residual extraction module is a feedforward fully connected submodule, the i-1th standard decoding feature is input into the feedforward fully connected submodule to obtain the i-th residual decoding feature.
[0077] It can be understood that in this embodiment, the submodule for determining the residual decoding features included in the above-mentioned first residual extraction module can be any one of the masked multi-head self-attention submodule, the multi-head self-attention submodule and the feedforward fully connected submodule.
[0078] Therefore, in this embodiment, the feature decoding layer can be used to indicate any model structure of the decoder consisting of a masked multi-head self-attention submodule, a multi-head self-attention submodule, and a feedforward fully connected submodule, as well as a normalization module and a feature generation module, such as Figure 5 shown.
[0079] In a specific embodiment, the feature decoding model may be a decoder in a Transformer in a Pre-LN form. The decoder may be composed of multiple decoding modules, each of which may include the masked multi-head self-attention submodule, the multi-head self-attention submodule, and the feedforward fully connected submodule.
[0080] The specific structure of the above feature decoding model can be as follows Figure 6 As shown in Figure 1, a decoding module may include three interconnected submodules, including a feedforward fully connected module, a multi-head self-attention module, and a masked multi-head self-attention module. A normalization module is connected before each submodule to normalize the decoding features before subsequent decoding processing. Figure 6 In this implementation, the weight parameters of the trunk branches in the above decoding module can determine the same parameter value α.
[0081] Through the above implementation of the present application, by configuring the weight parameters, the dependence of the Pre-LN Transformer on the trunk branch can be enhanced, and the performance and generalization of the model can be improved. At the same time, in extremely deep scenarios, the problem of the Pre-LN Transformer model degenerating into a widened width is alleviated, and the translation quality is significantly improved.
[0082] In an optional implementation, the above-mentioned obtaining the target text features obtained by extracting the features of the first text sequence to be converted includes:
[0083] S1, determining a text vector matrix corresponding to the first text sequence according to character vectors corresponding to each of a plurality of characters included in the first text sequence;
[0084] S2, repeat the following steps until M feature coding layers in the feature coding model are traversed, wherein the feature coding model is used to determine the target text features corresponding to the first text sequence according to the text vector matrix, the feature coding layer includes a second residual extraction module and a second feature generation module, and M is an integer greater than or equal to 2:
[0085] 1) obtaining the j-1th reference coding feature output by the j-1th feature coding layer, and inputting the j-1th reference coding feature into the second residual extraction module in the j-th feature coding layer to obtain the j-th residual coding feature, where j is an integer greater than 1 and less than or equal to M;
[0086] 2) obtaining a third weight parameter and a fourth weight parameter matching the j-th feature coding layer, wherein the third weight parameter is used to indicate the feature weight of the j-1-th reference coding feature, the fourth weight parameter is used to indicate the feature weight of the j-th residual coding feature, and the ratio between the third weight parameter and the fourth weight parameter is greater than or equal to the second target threshold;
[0087] 3) In the second feature generation module, a weighted coding feature of the j-1th reference coding feature and the jth residual coding feature is determined according to the third weight parameter and the fourth weight parameter, and the weighted coding feature is determined as the jth reference coding feature output by the jth feature coding layer;
[0088] S3-1, when j is less than N, the jth reference coding feature is input into the j+1th feature coding layer;
[0089] S3-2, when j is equal to N, the jth reference coding feature is determined as the target text feature.
[0090] It can be understood that, in this embodiment, obtaining the target text features obtained by extracting the features of the first text sequence to be converted can be completed based on the encoder in the Transformer model. The structure of the above Transformer model can be as follows: Figure 7 As shown in the figure, the Transformer model usually consists of an encoder and a decoder, in which the encoder and decoder have a multi-layer complex structure. The structure of each layer is consistent. Each layer of the encoder includes a multi-head self-attention module (Multi-Head Attention Module) and a feed-forward fully connected module (FFN). Each layer of the decoder usually includes a mask multi-head self-attention module (Mask Multi-Head Attention Module), a cross encoder and decoder self-attention module, also known as a cross self-attention module (Cross Self-Attention Module) and a feed-forward fully connected module. Each of these modules requires a residual connection and a LayerNorm layer to stabilize the training of the model.
[0091] In this embodiment, each structure in the above-mentioned encoder consisting of a normalization layer and a multi-head self-attention module consisting of a normalization layer and a feed-forward fully connected module can be determined as a feature coding layer in the above-mentioned encoding feature model, and then the weight parameters of the trunk branches in a feature coding layer are adjusted to improve the performance of the model encoding.
[0092] In an optional implementation, the above-mentioned inputting the j-1th reference coding feature into the second residual extraction module in the jth feature coding layer to obtain the jth residual coding feature includes:
[0093] S1, normalize the j-1th reference coding feature to obtain the j-1th standard coding feature;
[0094] S2, determine the jth residual coding feature based on the j-1th standard coding feature.
[0095] In an optional implementation, the determining of the j-th residual coding feature based on the j-1-th standard coding feature includes:
[0096] S1, when the feature encoding submodule included in the second residual extraction module is a multi-head self-attention submodule, inputting the j-1th standard encoding feature into the multi-head self-attention submodule to obtain the jth residual encoding feature;
[0097] S2, when the feature encoding submodule included in the second residual extraction module is a feedforward fully connected submodule, the j-1th standard encoding feature is input into the feedforward fully connected submodule to obtain the jth residual encoding feature.
[0098] It can be understood that, in this embodiment, the feature encoding layer can be specifically a partially repeated module structure in the encoder of the Transformer model in the Pre-LN form, such as Figure 8 As shown in , in an encoding module, two interconnected submodules can be included, including a feedforward fully connected module and a multi-head self-attention module. And a normalization module is connected before each submodule to normalize the decoding features before subsequent encoding processing. Figure 8 In this implementation, the weight parameters of the trunk branches in the above-mentioned one encoding module can determine the same parameter value α.
[0099] In an optional implementation, the obtaining of the first weight parameter and the second weight parameter matching the i-th feature decoding layer includes one of the following:
[0100] Method 1: obtaining a first weight parameter and a second weight parameter configured for the i-th feature decoding layer;
[0101] Method 2: When N is an integer greater than or equal to 10, Determine as a first weight parameter matching the i-th feature decoding layer, and determine 1 as a second weight parameter matching the i-th feature decoding layer;
[0102] Method 3: Determine as the first weight parameter matching the i-th feature decoding layer, and determine 1 as the second weight parameter matching the i-th feature decoding layer.
[0103] In an optional implementation, the third weight parameter and the fourth weight parameter matched with the j-th feature coding layer include one of the following:
[0104] Method 1: obtaining a third weight parameter and a fourth weight parameter configured for the j-th feature coding layer;
[0105] Method 2: When N is an integer greater than or equal to 10, Determine as a third weight parameter matching the j-th feature coding layer, and determine 1 as a fourth weight parameter matching the j-th feature coding layer;
[0106] Method 3: A third weight parameter is determined to match the j-th feature coding layer, and 1 is determined to match the fourth weight parameter of the j-th feature coding layer.
[0107] In this embodiment, three optional methods for determining weight parameters are provided.
[0108] Among them, in the first method, the pre-trained α can be obtained as the weight parameter corresponding to each layer. For example, after α is initialized during the training process, α can be made a learnable variable rather than a constant value during the training process. In this way, the model can dynamically adjust the weights of each branch during the training process and converge to a better effect. The method for initializing α can adopt the following second method or third method;
[0109] In the second method, α can be set to That is, the α of all layers is the same value;
[0110] In the third method, α can be set to Where N i represents the i-th layer, that is, the α of each layer i All of them are related to the number of layers at this time. As the number of layers increases, the degradation of Pre-LN will become more serious, so a larger α is required.
[0111] In an optional manner, multiple submodules included in an encoding module or a decoding module may be regarded as submodules of the same layer, for example Figure 6 and Figure 8 As shown, the weight parameters of the trunk branches in an encoding module or a decoding module may be the same;
[0112] In another optional manner, the multiple submodules included in the encoding module or the decoding module can be each regarded as a submodule of an independent layer, and the trunk branches in each layer of the submodules are configured with respective weight parameters in the above manner;
[0113] It should be noted that, in an optional implementation, a method for determining weight parameters of each encoding layer in the encoder in the Transformer model may be the same as or different from a method for determining weight parameters of each decoding layer in the decoder in the Transformer model.
[0114] For example, in a specific implementation, when the method of determining the weight parameters of each encoding layer in the encoder in the Transformer model is different from the method of determining the weight parameters of each decoding layer in the decoder in the Transformer model:
[0115] Assuming that the target Transformer model has 1000 encoding modules in the encoder and 1000 decoding modules in the decoder, each encoding layer in the encoder can be classified according to Determine a fixed weight parameter, that is That is, the weight parameters of the trunk branch in the encoder of the above target Transformer model are The weight parameter corresponding to the residual branch is 1; each decoding layer in the decoder can be A fixed weight parameter is determined, that is, the weight parameters of the trunk branches in different layers are different from each other, and as the number of layers increases, the weight corresponding to the trunk branch also increases, while the weight parameter corresponding to the residual branch is fixed to 1.
[0116] For example, in another specific implementation, when the weight parameters of each encoding layer in the encoder in the Transformer model are determined in the same manner as the weight parameters of each decoding layer in the decoder in the Transformer model:
[0117] Assuming that the target Transformer model has 1000 encoding modules in the encoder and 1000 decoding modules in the decoder, each encoding layer in the encoder can be classified according to Determine a fixed weight parameter, that is That is, the weight parameters of the trunk branch in the encoder of the above target Transformer model are The weight parameter corresponding to the residual branch is 1; at the same time, each decoding layer in the decoder can be Determine the fixed weight parameters This controls the weights of the trunk branches in the encoder and decoder to be the same.
[0118] A specific method of the above-mentioned implementation method of the present application is described below.
[0119] In this embodiment, the above text conversion method can be used in the language translation process. The overall process of translation is to first divide the received sentence into individual sentences, and then perform word segmentation on each sentence, such as "I love China", which is divided into "I / love / China". Then the segmented words are sent to the model, and the model outputs the corresponding translation. Then the punctuation marks, spaces, etc. of the translation are simply post-processed, and then the translation is returned.
[0120] This method is mainly based on the Transformer model. On this basis, the weight of the main branch is increased to enhance the representation ability of the model and improve the translation effect of the model. Figure 8 As shown in Figure 1, it is a schematic diagram of the structure of the weighted Pre-LN Transformer. Each LayerNorm layer is placed in front of the input. The structure of each submodule can be simplified as follows: Figure 5 shown.
[0121] like Figure 5 As shown, the calculation formula of each such submodule can be expressed as:
[0122] x l+1 =F(LN(x l ))+αx l
[0123] Among them, x l+1 is the output of the current submodule, x l is the output of the previous submodule, LN(x l ) is the result of normalizing the output of the previous submodule, F(LN(x l )) is the processing result of the encoding module or decoding module in the current submodule. α is a parameter used to increase the weight of the main branch of the model.
[0124] According to the derivation of the update amount of the Transformer model, the update amount of Pre-LN is of the order of O(logN), where N is the number of layers of the model. Therefore, α can be set to various variations of logN.
[0125] In the first form, α can be set to That is, the α of all layers is the same value.
[0126] In the second form, α can be set to Where N i represents the i-th layer, that is, the α of each layeri All of them are related to the number of layers at this time. As the number of layers increases, the degradation of Pre-LN will become more serious, so a larger α is required.
[0127] In the third form, α can be initialized using the first two methods, and during the training process, α is made a learnable variable rather than a constant value. This allows the model to dynamically adjust the weights of each branch during the training process and converge to a better effect.
[0128] Through the above implementation, the dependence of the Pre-LN Transformer on the trunk branch can be effectively enhanced, and the performance and generalization of the model can be improved. At the same time, in extremely deep scenarios, the problem of the Pre-LN Transformer model degenerating into a widened width can be alleviated, significantly improving the translation quality.
[0129] As an optional implementation, the training method of the above text conversion model may include the following steps:
[0130] S1, obtaining target sample text features obtained by extracting features from a first sample text sequence to be converted;
[0131] S2, repeat the following steps until N feature decoding layers in the feature decoding model in training are traversed, wherein the feature decoding model in training is used to determine a second sample text sequence matching the first sample text sequence according to the target sample text feature, the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2:
[0132] Obtain the i-1th reference decoding feature output by the i-1th feature decoding layer, and input the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtain a first weight parameter and a second weight parameter matching the i-th feature decoding layer, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in the first feature generation module, determine the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature according to the first weight parameter and the second weight parameter, and determine the weighted decoding feature as the i-th reference decoding feature output by the i-th feature decoding layer; when i is equal to N, determine a second sample text sequence matching the first sample text sequence based on the i-th reference decoding feature;
[0133] S3, when it is determined according to the second sample text that the feature decoding model in training meets the convergence condition, the feature decoding model in training is determined as the target feature decoding model.
[0134] In an optional implementation manner, before obtaining the target sample text features obtained by extracting the features of the first sample text sequence to be converted, the method further includes:
[0135] S1, determining a sample text vector matrix corresponding to the first sample text sequence according to character vectors corresponding to each of a plurality of characters included in the first sample text sequence;
[0136] S2, repeat the following steps until M feature coding layers in the feature coding model in training are traversed, wherein the feature coding model is used to determine the target sample text features corresponding to the first sample text sequence according to the sample text vector matrix, the feature coding layer includes a second residual extraction module and a second feature generation module, and M is an integer greater than or equal to 2:
[0137] Obtain the j-1th reference coding feature output by the j-1th feature coding layer, and input the j-1th reference coding feature into the second residual extraction module in the j-th feature coding layer to obtain the j-th residual coding feature, wherein j is an integer greater than 1 and less than or equal to M; obtain a third weight parameter and a fourth weight parameter matching the j-th feature coding layer, wherein the third weight parameter is used to indicate the feature weight of the j-1th reference coding feature, the fourth weight parameter is used to indicate the feature weight of the j-th residual coding feature, and the ratio between the third weight parameter and the fourth weight parameter is greater than or equal to the second target threshold; in the second feature generation module, determine the weighted coding feature of the j-1th reference coding feature and the j-th residual coding feature according to the third weight parameter and the fourth weight parameter, and determine the weighted coding feature as the j-th reference coding feature output by the j-th feature coding layer;
[0138] S3-1, when j is less than N, the jth reference coding feature is input into the j+1th feature coding layer;
[0139] S3-2, when j is equal to N, determining the jth reference coding feature as the target sample text feature;
[0140] S4, when the feature coding model in training determined according to the target sample text features meets the convergence condition, the feature coding model in training is determined as the target feature coding model.
[0141] It is understandable that during the training process, a translation model can be obtained by training with bilingual data of a language (or multiple languages) (such as English-Chinese). The translation model is then deployed to the online service, and the model is derived by receiving online translation calls and returning the translation.
[0142] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0143] According to another aspect of the embodiments of the present invention, a text conversion device for implementing the above text conversion method is also provided. Fig. 9 As shown, the device comprises:
[0144] An acquisition unit 902 is used to acquire target text features obtained by extracting features from the first text sequence to be converted;
[0145] The traversal unit 904 is used to repeat the following steps until N feature decoding layers in the feature decoding model are traversed, wherein the feature decoding model is used to determine a second text sequence matching the first text sequence according to the target text feature, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: obtain the i-1th reference decoding feature output by the i-1th feature decoding layer, and input the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N. number; obtaining a first weight parameter and a second weight parameter matching the i-th feature decoding layer, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in the first feature generation module, determining the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature according to the first weight parameter and the second weight parameter, and determining the weighted decoding feature as the i-th reference decoding feature output by the i-th feature decoding layer;
[0146] The determining unit 906 is configured to determine, when i is equal to N, a second text sequence matching the first text sequence based on the i-th reference decoding feature.
[0147] Optionally, in this embodiment, the embodiments to be implemented by the above-mentioned various unit modules can refer to the above-mentioned various method embodiments, which will not be repeated here.
[0148] According to another aspect of the embodiment of the present invention, an electronic device for implementing the above text conversion method is also provided. The electronic device may be Fig.10 The terminal device or server shown in the figure. This embodiment is described by taking the electronic device as a terminal device as an example. Fig.10 As shown, the electronic device includes a memory 1002 and a processor 1004. The memory 1002 stores a computer program, and the processor 1004 is configured to execute the steps in any of the above method embodiments through the computer program.
[0149] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0150] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0151] S1, obtaining target text features obtained by extracting features from a first text sequence to be converted;
[0152] S2, repeat the following steps until N feature decoding layers in the feature decoding model are traversed, wherein the feature decoding model is used to determine a second text sequence matching the first text sequence according to the target text feature, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: obtain the i-1th reference decoding feature output by the i-1th feature decoding layer, and input the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtain A first weight parameter and a second weight parameter matched with the i-th feature decoding layer, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in a first feature generation module, a weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer;
[0153] S3: When i is equal to N, determine a second text sequence matching the first text sequence based on the i-th reference decoding feature.
[0154] Alternatively, a person skilled in the art may understand that: Fig.10 The structure shown is for illustration only, and the electronic device may also be a vehicle-mounted terminal, a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Fig.10 The structure of the electronic device is not limited. Fig.10 More or fewer components (such as network interfaces, etc.) as shown in, or with Fig.10 Different configurations are shown.
[0155] Among them, the memory 1002 can be used to store software programs and modules, such as the program instructions / modules corresponding to the text conversion method and device in the embodiment of the present invention. The processor 1004 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002, that is, realizing the above-mentioned text conversion method. The memory 1002 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1002 may further include a memory remotely arranged relative to the processor 1004, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1002 can be specifically, but not limited to, used to store file information such as target logical files. As an example, such as Fig.10 As shown, the memory 1002 may include but is not limited to the acquisition unit 902, the traversal unit 904, and the determination unit 906 in the text conversion device. In addition, it may also include but is not limited to other module units in the text conversion device, which will not be repeated in this example.
[0156] Optionally, the transmission device 1006 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wired network and a wireless network. In one example, the transmission device 1006 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 1006 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0157] In addition, the electronic device mentioned above further includes: a display 1008, and a connection bus 1010, which is used to connect various module components in the electronic device mentioned above.
[0158] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes through network communication. Among them, the nodes may form a peer-to-peer (P2P, Peer To Peer) network, and any form of computing device, such as a server, terminal and other electronic devices, may become a node in the blockchain system by joining the peer-to-peer network.
[0159] According to one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program / instruction, the computer program / instruction comprising a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part, and / or installed from a removable medium. When the computer program is executed by a central processing unit, various functions provided by the embodiments of the present application are executed.
[0160] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0161] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned text conversion method.
[0162] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0163] S1, obtaining target text features obtained by extracting features from a first text sequence to be converted;
[0164] S2, repeat the following steps until N feature decoding layers in the feature decoding model are traversed, wherein the feature decoding model is used to determine a second text sequence matching the first text sequence according to the target text feature, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: obtain the i-1th reference decoding feature output by the i-1th feature decoding layer, and input the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtain A first weight parameter and a second weight parameter matched with the i-th feature decoding layer, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in a first feature generation module, a weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer;
[0165] S3: When i is equal to N, determine a second text sequence matching the first text sequence based on the i-th reference decoding feature.
[0166] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0167] According to another aspect of the embodiments of the present invention, there is also provided a text conversion model training device for implementing the above-mentioned text conversion model training method. Fig.11 As shown, the device comprises:
[0168] An acquisition unit 1102 is used to acquire target sample text features obtained by extracting features from the first sample text sequence to be converted;
[0169] The training unit 1104 is used to repeat the following steps until N feature decoding layers in the feature decoding model in training are traversed, wherein the feature decoding model in training is used to determine a second sample text sequence that matches the first sample text sequence according to the target sample text feature, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: obtain the i-1th reference decoding feature output by the i-1th feature decoding layer, and input the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtain the i-th residual decoding feature that matches the i-th feature decoding layer a first weight parameter and a second weight parameter, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in a first feature generation module, a weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer; when i is equal to N, a second sample text sequence matching the first sample text sequence is determined based on the i-th reference decoding feature;
[0170] The determination unit 1106 is used to determine the feature decoding model in training as the target feature decoding model when it is determined according to the second sample text that the feature decoding model in training meets the convergence condition.
[0171] Optionally, in this embodiment, the embodiments to be implemented by the above-mentioned various unit modules can refer to the above-mentioned various method embodiments, which will not be repeated here.
[0172] According to another aspect of the embodiments of the present invention, an electronic device for implementing the training method of the text conversion model is also provided. The electronic device may be Fig.12 The terminal device or server shown in the figure. This embodiment is described by taking the electronic device as a terminal device as an example. Fig.12 As shown, the electronic device includes a memory 1202 and a processor 1204. The memory 1202 stores a computer program, and the processor 1204 is configured to execute the steps in any of the above method embodiments through the computer program.
[0173] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0174] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0175] S1, obtaining target sample text features obtained by extracting features from a first sample text sequence to be converted;
[0176] S2, repeat the following steps until N feature decoding layers in the feature decoding model in training are traversed, wherein the feature decoding model in training is used to determine a second sample text sequence matching the first sample text sequence according to the target sample text feature, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: obtain the i-1th reference decoding feature output by the i-1th feature decoding layer, and input the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtain the first weighted decoding feature matching the i-th feature decoding layer. A weight parameter and a second weight parameter, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in the first feature generation module, the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer; when i is equal to N, a second sample text sequence matching the first sample text sequence is determined based on the i-th reference decoding feature;
[0177] S2, when it is determined according to the second sample text that the feature decoding model in training meets the convergence condition, the feature decoding model in training is determined as the target feature decoding model.
[0178] Alternatively, a person skilled in the art may understand that: Fig.12 The structure shown is for illustration only, and the electronic device may also be a vehicle-mounted terminal, a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Fig.12 The structure of the electronic device is not limited. Fig.12 More or fewer components (such as network interfaces, etc.) as shown in, or with Fig.12 Different configurations are shown.
[0179] Among them, the memory 1202 can be used to store software programs and modules, such as the program instructions / modules corresponding to the training method and device of the text conversion model in the embodiment of the present invention. The processor 1204 executes various functional applications and data processing by running the software programs and modules stored in the memory 1202, that is, realizing the above-mentioned training method of the text conversion model. The memory 1202 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1202 may further include a memory remotely arranged relative to the processor 1204, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1202 can be specifically, but not limited to, used to store file information such as target logical files. As an example, such as Fig.12 As shown, the memory 1202 may include, but is not limited to, the acquisition unit 1102, the training unit 1104, and the determination unit 1106 in the training device for the text conversion model. In addition, other module units in the training device for the text conversion model may also be included but are not limited to, which will not be repeated in this example.
[0180] Optionally, the transmission device 1206 is used to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one example, the transmission device 1206 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 1206 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0181] In addition, the electronic device further includes: a display 1208, and a connection bus 1210, which is used to connect various module components in the electronic device.
[0182] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes through network communication. Among them, the nodes may form a peer-to-peer (P2P, Peer To Peer) network, and any form of computing device, such as a server, terminal and other electronic devices, may become a node in the blockchain system by joining the peer-to-peer network.
[0183] According to one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program / instruction, the computer program / instruction comprising a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part, and / or installed from a removable medium. When the computer program is executed by a central processing unit, various functions provided by the embodiments of the present application are executed.
[0184] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0185] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned text conversion model training method.
[0186] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0187] S1, obtaining target sample text features obtained by extracting features from a first sample text sequence to be converted;
[0188] S2, repeat the following steps until N feature decoding layers in the feature decoding model in training are traversed, wherein the feature decoding model in training is used to determine a second sample text sequence matching the first sample text sequence according to the target sample text feature, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: obtain the i-1th reference decoding feature output by the i-1th feature decoding layer, and input the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtain the first weighted decoding feature matching the i-th feature decoding layer. A weight parameter and a second weight parameter, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to the first target threshold; in the first feature generation module, the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer; when i is equal to N, a second sample text sequence matching the first sample text sequence is determined based on the i-th reference decoding feature;
[0189] S2, when it is determined according to the second sample text that the feature decoding model in training meets the convergence condition, the feature decoding model in training is determined as the target feature decoding model.
[0190] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0191] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which can be personal computers, servers or network devices, etc.) to perform all or part of the steps of the above methods of various embodiments of the present invention.
[0192] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0193] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation. For example, 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 through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0194] The units described above 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.
[0195] 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.
[0196] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A text conversion method, characterized in that: include: Obtain target text features obtained by performing feature extraction on the first text sequence to be converted; Repeat the following steps until N feature decoding layers in the feature decoding model are traversed, wherein the feature decoding model is used to determine a second text sequence matching the first text sequence according to the target text feature, the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: Obtaining the i-1th reference decoding feature output by the i-1th feature decoding layer, and inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; Acquire a first weight parameter and a second weight parameter matching the i-th feature decoding layer, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and a ratio between the first weight parameter and the second weight parameter is greater than or equal to a first target threshold; In the first feature generation module, a weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer; When i is equal to N, the second text sequence matching the first text sequence is determined based on the i-th reference decoding feature.
2. The method according to claim 1, characterized in that The step of inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature comprises: Normalizing the i-1th reference decoding feature to obtain the i-1th standard decoding feature; The i-th residual decoding feature is determined based on the i-1-th standard decoding feature.
3. The method according to claim 2, characterized in that The determining the i-th residual decoding feature based on the i-1-th standard decoding feature comprises: In a case where the feature decoding submodule included in the first residual extraction module is a masked multi-head self-attention submodule, inputting the i-1th standard decoding feature into the masked multi-head self-attention submodule to obtain the i-th residual decoding feature; In a case where the feature decoding submodule included in the first residual extraction module is a multi-head self-attention submodule, inputting the i-1th standard decoding feature into the multi-head self-attention submodule to obtain the i-th residual decoding feature; In the case where the feature decoding submodule included in the first residual extraction module is a feedforward fully connected submodule, the i-1th standard decoding feature is input into the feedforward fully connected submodule to obtain the i-th residual decoding feature.
4. The method according to claim 2, characterized in that In the first feature generation module, determining the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature according to the first weight parameter and the second weight parameter includes: Determine a backbone reference feature according to a product of the first weight parameter and the i-1th reference decoding feature; Determine a residual reference feature according to the product of the second weight parameter and the i-th residual decoding feature; The weighted decoding feature is determined according to the sum of the backbone reference feature and the residual reference feature.
5. The method according to claim 1, characterized in that The step of obtaining target text features obtained by extracting features from the first text sequence to be converted comprises: Determine a text vector matrix corresponding to the first text sequence according to character vectors corresponding to each of a plurality of characters included in the first text sequence; Repeat the following steps until M feature coding layers in the feature coding model are traversed, wherein the feature coding model is used to determine the target text feature corresponding to the first text sequence according to the text vector matrix, the feature coding layer includes a second residual extraction module and a second feature generation module, and M is an integer greater than or equal to 2: Obtaining the j-1th reference coding feature output by the j-1th feature coding layer, and inputting the j-1th reference coding feature into the second residual extraction module in the j-th feature coding layer to obtain the j-th residual coding feature, wherein j is an integer greater than 1 and less than or equal to M; Acquire a third weight parameter and a fourth weight parameter matching the j-th feature coding layer, wherein the third weight parameter is used to indicate the feature weight of the j-1-th reference coding feature, the fourth weight parameter is used to indicate the feature weight of the j-th residual coding feature, and a ratio between the third weight parameter and the fourth weight parameter is greater than or equal to a second target threshold; In the second feature generation module, a weighted coding feature of the j-1th reference coding feature and the jth residual coding feature is determined according to the third weight parameter and the fourth weight parameter, and the weighted coding feature is determined as the jth reference coding feature output by the jth feature coding layer; When j is less than N, inputting the jth reference coding feature into the j+1th feature coding layer; When j is equal to N, the j-th reference coding feature is determined as the target text feature.
6. The method according to claim 5, characterized in that The step of inputting the j-1th reference coding feature into the second residual extraction module in the jth feature coding layer to obtain the jth residual coding feature comprises: Normalizing the j-1th reference coding feature to obtain the j-1th standard coding feature; The j-th residual coding feature is determined based on the j-1-th standard coding feature.
7. The method according to claim 6, characterized in that The determining the jth residual coding feature based on the j-1th standard coding feature comprises: In a case where the feature encoding submodule included in the second residual extraction module is a multi-head self-attention submodule, inputting the j-1th standard encoding feature into the multi-head self-attention submodule to obtain the jth residual encoding feature; In the case where the feature encoding submodule included in the second residual extraction module is a feedforward fully connected submodule, the j-1th standard encoding feature is input into the feedforward fully connected submodule to obtain the jth residual encoding feature.
8. The method according to claim 1, characterized in that The acquiring of the first weight parameter and the second weight parameter matching the i-th feature decoding layer comprises one of the following: Obtaining the first weight parameter and the second weight parameter configured for the i-th feature decoding layer; When N is an integer greater than or equal to 10, Determine the first weight parameter that matches the i-th feature decoding layer, and determine 1 as the second weight parameter that matches the i-th feature decoding layer; Will The first weight parameter is determined to match the i-th feature decoding layer, and 1 is determined to match the second weight parameter matching the i-th feature decoding layer.
9. The method according to claim 5, characterized in that The acquiring of the third weight parameter and the fourth weight parameter matching the j-th feature coding layer comprises one of the following: Obtaining the third weight parameter and the fourth weight parameter configured for the j-th feature coding layer; When N is an integer greater than or equal to 10, Determine as the third weight parameter matching the j-th feature coding layer, and determine 1 as the fourth weight parameter matching the j-th feature coding layer; Will The third weight parameter is determined to match the j-th feature coding layer, and 1 is determined to match the fourth weight parameter matching the j-th feature coding layer.
10. A training method for a text conversion model, characterized in that: include: Acquire target sample text features obtained by extracting features from the first sample text sequence to be converted; Repeat the following steps until N feature decoding layers in the feature decoding model in training are traversed, wherein the feature decoding model in training is used to determine a second sample text sequence matching the first sample text sequence according to the target sample text feature, the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: Obtaining the i-1th reference decoding feature output by the i-1th feature decoding layer, and inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; Acquire a first weight parameter and a second weight parameter matching the i-th feature decoding layer, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and a ratio between the first weight parameter and the second weight parameter is greater than or equal to a first target threshold; In the first feature generation module, a weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer; In a case where the i is equal to the N, determining the second sample text sequence matching the first sample text sequence based on the i-th reference decoding feature; When it is determined according to the second sample text that the feature decoding model in training meets a convergence condition, the feature decoding model in training is determined as a target feature decoding model.
11. The method according to claim 10, characterized in that Before obtaining the target sample text features obtained by extracting the features of the first sample text sequence to be converted, the method further includes: Determine a sample text vector matrix corresponding to the first sample text sequence according to character vectors corresponding to each of a plurality of characters included in the first sample text sequence; Repeat the following steps until M feature coding layers in the feature coding model in training are traversed, wherein the feature coding model is used to determine the target sample text features corresponding to the first sample text sequence according to the sample text vector matrix, the feature coding layer includes a second residual extraction module and a second feature generation module, and M is an integer greater than or equal to 2: Obtaining the j-1th reference coding feature output by the j-1th feature coding layer, and inputting the j-1th reference coding feature into the second residual extraction module in the j-th feature coding layer to obtain the j-th residual coding feature, wherein j is an integer greater than 1 and less than or equal to M; Acquire a third weight parameter and a fourth weight parameter matching the j-th feature coding layer, wherein the third weight parameter is used to indicate the feature weight of the j-1-th reference coding feature, the fourth weight parameter is used to indicate the feature weight of the j-th residual coding feature, and a ratio between the third weight parameter and the fourth weight parameter is greater than or equal to a second target threshold; In the second feature generation module, a weighted coding feature of the j-1th reference coding feature and the jth residual coding feature is determined according to the third weight parameter and the fourth weight parameter, and the weighted coding feature is determined as the jth reference coding feature output by the jth feature coding layer; When j is less than N, inputting the jth reference coding feature into the j+1th feature coding layer; In the case where j is equal to N, determining the j-th reference coding feature as the target sample text feature; In the case where the feature coding model in training is determined according to the target sample text feature to meet a convergence condition, the feature coding model in training is determined as a target feature coding model.
12. A text conversion device, characterized in that: include: An acquisition unit, used for acquiring target text features obtained by extracting features from the first text sequence to be converted; A traversal unit is used to repeat the following steps until N feature decoding layers in the feature decoding model are traversed, wherein the feature decoding model is used to determine a second text sequence matching the first text sequence according to the target text feature, and the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: obtaining the i-1th reference decoding feature output by the i-1th feature decoding layer, and inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtaining the i-1th reference decoding feature output by the i-1th feature decoding layer, and inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtaining the i-1th residual decoding feature output by the i-1th feature decoding layer, and inputting the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein i is an integer greater than 1 and less than or equal to N; obtaining the i-1th residual decoding feature output by the i-1th feature decoding layer, and inputting the i-1th residual ... a first weight parameter and a second weight parameter matched by the i-th feature decoding layer, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to a first target threshold; in the first feature generation module, a weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature is determined according to the first weight parameter and the second weight parameter, and the weighted decoding feature is determined as the i-th reference decoding feature output by the i-th feature decoding layer; A determining unit is configured to determine, when i is equal to N, the second text sequence matching the first text sequence based on the i-th reference decoding feature.
13. A training device for a text conversion model, characterized in that: include An acquisition unit, used for acquiring target sample text features obtained by extracting features from the first sample text sequence to be converted; A training unit is used to repeat the following steps until N feature decoding layers in the feature decoding model in training are traversed, wherein the feature decoding model in training is used to determine a second sample text sequence matching the first sample text sequence according to the target sample text feature, the feature decoding layer includes a first residual extraction module and a first feature generation module, and N is an integer greater than or equal to 2: Obtain the i-1th reference decoding feature output by the i-1th feature decoding layer, and input the i-1th reference decoding feature into the first residual extraction module in the i-th feature decoding layer to obtain the i-th residual decoding feature, wherein the i is an integer greater than 1 and less than or equal to N; obtain a first weight parameter and a second weight parameter matching the i-th feature decoding layer, wherein the first weight parameter is used to indicate the feature weight of the i-1th reference decoding feature, the second weight parameter is used to indicate the feature weight of the i-th residual decoding feature, and the ratio between the first weight parameter and the second weight parameter is greater than or equal to a first target threshold; in the first feature generation module, determine the weighted decoding feature of the i-1th reference decoding feature and the i-th residual decoding feature according to the first weight parameter and the second weight parameter, and determine the weighted decoding feature as the i-th reference decoding feature output by the i-th feature decoding layer; when the i is equal to the N, determine the second sample text sequence matching the first sample text sequence based on the i-th reference decoding feature; A determination unit is used to determine the feature decoding model in training as a target feature decoding model when it is determined according to the second sample text that the feature decoding model in training meets a convergence condition.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 9 or 10 to 11 when executed.
15. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method described in any one of claims 1 to 9 or 10 to 11 are implemented.
16. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method described in any one of claims 1 to 9 or 10 to 11 through the computer program.
