Text processing method and device, and computer device
By using a gated encoder and decoder in a pre-trained text recognition model, the problem of traditional models' dependence on specific text features is solved, achieving higher accuracy in text recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INDUSTRIAL AND COMMERCIAL BANK OF CHINA
- Filing Date
- 2023-03-06
- Publication Date
- 2026-07-03
AI Technical Summary
Traditional text recognition models require pre-designed specific text features, making them unsuitable for recognizing text content in other topic contexts and resulting in insufficient accuracy.
By employing the encoder in a pre-trained text recognition model and utilizing the gating parameters of the gating structure to control the fusion of coding layer feature information and text coding feature information, more accurate text recognition results are generated through multiple processing steps by the encoder and decoder.
By making full use of the feature information of the coding layer without the need for pre-designed text features, more accurate feature extraction and text recognition are achieved, thus improving the accuracy of text processing.
Smart Images

Figure CN116226385B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of artificial intelligence technology and financial technology technology, and in particular to a text processing method, apparatus, computer equipment, storage medium and computer program product. Background Technology
[0002] With the development of computer technology, more and more text processing technologies have emerged.
[0003] Currently, text recognition models are often used to process large amounts of text content. However, traditional text recognition models often require pre-designed specific text features, which makes them unsuitable for recognizing text content in other topic contexts, resulting in inaccurate text recognition.
[0004] Therefore, traditional technologies suffer from inaccurate text recognition. Summary of the Invention
[0005] Therefore, it is necessary to provide a text processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the accuracy of text processing in response to the above-mentioned technical problems.
[0006] A text processing method, characterized in that the method includes:
[0007] Obtain the text to be recognized;
[0008] The text to be recognized is input into the encoder of the pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized; the encoder has a gating structure; the gating parameters of the gating structure are used to indicate whether to fuse the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information;
[0009] The encoder-encoded feature information is input into the decoder in the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized.
[0010] In one embodiment, the encoder includes N encoding layers, where N is greater than or equal to 2. The text to be recognized is input into the encoder of a pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized, including:
[0011] The text to be recognized is input into N encoding layers for N encoding processes, resulting in N encoding matrices output by the encoding layers. The encoding matrix output by the first encoding layer is the result of inputting the representation matrix corresponding to the text to be recognized into the first encoding layer. The encoding matrix output by the Nth encoding layer is the result of inputting the encoding matrix output by the (N-1)th encoding layer into the Nth encoding layer.
[0012] The encoding matrix output by the Nth encoding layer is used as the text encoding feature information corresponding to the text to be identified.
[0013] In one embodiment, the gating structure includes gating units corresponding to each coding layer, and the method further includes:
[0014] When the gating parameter corresponding to the coding layer is the target gating value, the coding layer feature information output by the coding layer is fused with the text coding feature information to obtain the coding layer coding feature information corresponding to the coding layer.
[0015] If the gating parameter corresponding to the coding layer is not the target gating value, the coding layer feature information output by the coding layer shall be used as the coding layer coding feature information corresponding to the coding layer.
[0016] The encoder coding feature information is generated based on the coding feature information of each coding layer.
[0017] In one embodiment, the decoder includes N decoding layers, which input the encoder-encoded feature information into the decoder of a pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized, including:
[0018] The encoder's encoded feature information is input into N decoding layers for N decoding processes, resulting in N decoding matrices output by the decoding layers. The decoding matrix output by the first decoding layer is the result of inputting the encoded feature information of the first encoding layer into the first decoding layer. The decoding matrix output by the Nth decoding layer is the result of inputting the decoding matrix output by the (N-1)th decoding layer and the encoded feature information of the Nth encoding layer into the Nth decoding layer.
[0019] Based on the decoding matrix output by the Nth decoding layer, the text recognition result corresponding to the text to be recognized is obtained.
[0020] In one embodiment, the method further includes:
[0021] Obtain the text recognition model to be trained;
[0022] Obtain a text training sample set, and use the text training sample set to train the text recognition model to be trained, to obtain the first text recognition model;
[0023] The first text recognition model is structurally optimized to obtain a second text recognition model, which is used as a pre-trained text recognition model; the model accuracy of the second text recognition model is higher than that of the first text recognition model.
[0024] In one embodiment, a text recognition model to be trained is trained using a text training sample set to obtain a first text recognition model, including:
[0025] The text training sample set is input into the encoder of the text recognition model to be trained, and the encoder output feature information is obtained;
[0026] The encoder output feature information is input into the decoder in the text recognition model to be trained, and the decoder output feature information is obtained.
[0027] Based on the decoder output feature information, the loss information is determined; the loss information is used to determine the impact of the encoder output feature information on the decoder output feature information.
[0028] Based on the loss information, the text recognition model to be trained is trained to obtain the first text recognition model.
[0029] In one embodiment, the decoder includes N decoding layers, where N is greater than or equal to 2. The encoder output feature information is input into the decoder of the text recognition model to be trained, resulting in decoder output feature information, including:
[0030] The encoder output feature information is input into N decoding layers for N decoding processes, resulting in N decoding matrices output by the decoding layers. The decoding matrix output by the first decoding layer is the result of inputting the encoder output feature information into the first decoding layer. The decoding matrix output by the Nth decoding layer is the result of inputting the decoding matrix output by the (N-1)th decoding layer and the encoder output feature information into the Nth decoding layer.
[0031] The decoding matrix output by the Nth decoding layer is used as the decoder output feature information.
[0032] In one embodiment, the loss information includes decoding layer loss information corresponding to each decoding layer. Based on the loss information, the text recognition model to be trained is trained to obtain a first text recognition model, including:
[0033] Based on the decoding layer loss information corresponding to each decoding layer, determine the gating parameters of each gating unit;
[0034] Based on the gating parameters of each gating unit, a first text recognition model containing a gating structure is determined.
[0035] A text processing device, characterized in that the device comprises:
[0036] The acquisition module is used to acquire the text to be recognized;
[0037] The input module is used to input the text to be recognized into the encoder of the pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized; the encoder has a gating structure; the gating parameters of the gating structure are used to indicate whether to fuse the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information;
[0038] The recognition module is used to input the encoder-encoded feature information into the decoder in the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized.
[0039] A computer device includes a memory and a processor, the memory storing a computer program, characterized in that the processor executes the computer program to implement the steps of the method described above.
[0040] A computer-readable storage medium having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements the steps of the above-described method.
[0041] A computer program product includes a computer program, characterized in that the computer program, when executed by a processor, implements the steps of the above-described method.
[0042] In the above text processing method, the text to be recognized is obtained and input into the encoder of a pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized. The encoder has a gating structure. The gating parameters of the gating structure are used to indicate whether to fuse the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information. Then, the encoder encoding feature information is input into the decoder in the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized. In this way, it is possible to input the text to be recognized into the pre-trained text recognition model without pre-designing the text features. The encoder of the text recognition model fuses the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information. This fully utilizes the encoding layer encoding feature information of each encoding layer, so that the encoder encoding feature information input into the decoder of the text recognition model can be fully utilized in the decoding stage, achieving more accurate feature extraction, which is conducive to obtaining more accurate text recognition results and improving the accuracy of text processing. Attached Figure Description
[0043] Figure 1 This is a diagram illustrating the application environment of a text processing method in one embodiment.
[0044] Figure 2 This is a flowchart illustrating a text processing method in one embodiment;
[0045] Figure 3 This is a schematic diagram illustrating the design process of a text recognition system in one embodiment.
[0046] Figure 4 This is a schematic diagram of the backend design logic of a text recognition system in one embodiment;
[0047] Figure 5 This is a schematic diagram of the training process of a text recognition model in one embodiment;
[0048] Figure 6 This is a diagram illustrating the internal structure of a text recognition model in one embodiment.
[0049] Figure 7 This is a structural diagram of a portion of a text recognition model in one embodiment;
[0050] Figure 8 This is a model structure diagram of an improved text recognition model in one embodiment;
[0051] Figure 9 This is a flowchart illustrating a text processing method in another embodiment;
[0052] Figure 10 This is a structural block diagram of a text processing device in one embodiment;
[0053] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0055] It should be noted that the present application discloses a text processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can be applied to the field of financial technology.
[0056] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure.
[0057] The text processing method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. Server 104 acquires the text to be recognized; server 104 then inputs the text to be recognized into the encoder of a pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized; the encoder has a gating structure; the gating parameters of the gating structure are used to indicate whether to fuse the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information; server 104 inputs the encoder encoding feature information into the decoder of the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized. Server 104 sends the text recognition result to terminal 102. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0058] In one embodiment, such as Figure 2 As shown, a text processing method is provided, which can be applied to... Figure 1 Taking server 104 as an example, the following steps are included:
[0059] Step S202: Obtain the text to be recognized.
[0060] The text to be identified can refer to text that requires text processing. Specifically, the text to be identified can refer to text that needs to be processed, such as text sentiment word extraction, text sentiment word classification, or text sentiment feature retrieval. In practical applications, the text to be identified can refer to the evaluation text content generated after course participants evaluate the course content.
[0061] In practice, the server obtains the text that needs to be processed.
[0062] Step S204: Input the text to be recognized into the encoder in the pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized; the encoder has a gating structure; the gating parameters of the gating structure are used to indicate whether to fuse the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information.
[0063] Among them, text recognition models can refer to models for extracting sentiment words from text, models for classifying sentiment in text, models for extracting topics from text, models for retrieving sentiment features from text, and models for matching topic-related sentiments in text.
[0064] Here, the encoder can refer to the encoding structure in a text recognition model used to encode information from the text to be recognized.
[0065] The text encoding feature information refers to the encoded information obtained after the text to be recognized is encoded by the encoder. Specifically, the text encoding feature information is the encoding matrix output by the last encoding layer in the encoder. In practical applications, before the server inputs the text to be recognized into the encoder, it needs to be converted into a representation matrix. The server then inputs the representation matrix corresponding to the text to be recognized into the encoder for encoding, obtaining the encoding matrix output by the encoder. This encoding matrix is the text encoding feature information.
[0066] The gating structure can be a threshold structure used to control whether to fuse the coding layer feature information output by each coding layer in the encoder with the text coding feature information. The gating structure can include multiple gating units, each controlling a corresponding coding layer.
[0067] Among them, the gating parameter can be a value used in the gating structure to control the fusion of the coding layer feature information output by each coding layer with the text coding feature information.
[0068] Among them, the coding layer feature information can refer to the coding matrix obtained after each coding layer in the encoder encodes the text to be recognized.
[0069] The encoder's coding feature information includes the coding feature information corresponding to each coding layer. The coding feature information can be text coding feature information, or it can be fused information obtained by fusing the feature information of each coding layer with the text coding feature information.
[0070] In the specific implementation, the server inputs the text to be recognized into the encoder of the pre-trained text recognition model to obtain text encoding feature information. In addition, it also obtains the encoding layer feature information corresponding to each encoding layer. Based on the gating parameters corresponding to each gating unit, the server determines whether to fuse the encoding layer feature information corresponding to each encoding layer with the text encoding feature information to obtain the encoding layer encoding feature information corresponding to each encoding layer. Based on the encoding layer encoding feature information corresponding to each encoding layer, the server generates encoder encoding feature information.
[0071] Step S206: Input the encoder-encoded feature information into the decoder in the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized.
[0072] In this context, a decoder can refer to the encoding structure in a text recognition model used to decode text information. In practical applications, a decoder can refer to the decoding structure that decodes the encoding matrix output by the encoder.
[0073] Among them, text recognition results can refer to text sentiment word extraction results, text classification results, and text topic extraction results.
[0074] In practice, the server inputs the encoder's encoded feature information into the decoder in the pre-trained text recognition model to obtain the decoded information corresponding to the text to be recognized. Based on the decoded information, the server obtains the text recognition result corresponding to the text to be recognized.
[0075] In practical applications, when performing text recognition on a large amount of text, a text recognition system is built to facilitate text recognition. Figure 3 An exemplary logical design flow for a text recognition system used to identify user course evaluation text is provided. This text recognition system includes front-end / back-end design modules and a database design module.
[0076] The front-end / back-end design modules include an administrator system and a user-end system. The administrator system includes user information management, model management, data management, feedback processing, and recognition data visualization. The user-end system includes user registration, user login, text sentiment recognition, recognition data visualization, and problem feedback. Figure 4The system also provides an exemplary implementation logic flow for the backend. First, it needs to determine whether the user already has a login account. If not, the user needs to register and then log in; otherwise, the user logs in directly. Then, the user uploads the text to be recognized through the user-side interface, supporting batch input or sentence-by-sentence input. Next, the recognition results are displayed through a visual interface. If the recognition results are incorrect or unsatisfactory, the user can provide feedback through the feedback interface. The administrator can optimize and update the training evaluation sentiment analysis model based on the collected user feedback. During the operation of the text recognition system, the system database stores user information, model management information, and course evaluation recognition result information generated by the interactive system.
[0077] The database design module includes a text sentiment recognition result form, a text data management form, a model management form, a user registration form, and an administrator permission form.
[0078] In the above text processing method, the text to be recognized is obtained and input into the encoder of a pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized. The encoder has a gating structure. The gating parameters of the gating structure are used to indicate whether to fuse the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information. Then, the encoder encoding feature information is input into the decoder in the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized. In this way, it is possible to input the text to be recognized into the pre-trained text recognition model without designing text features. Through the encoder of the text recognition model, the encoding layer feature information output by each encoding layer in the encoder is fused with the text encoding feature information to generate encoder encoding feature information. This fully utilizes the encoding layer encoding feature information of each encoding layer, so that the encoder encoding feature information input into the decoder of the text recognition model can be fully utilized in the decoding stage, achieving more accurate feature extraction, which is conducive to obtaining more accurate text recognition results and improving the accuracy of text processing.
[0079] In another embodiment, the encoder includes N encoding layers, where N is greater than or equal to 2. The text to be recognized is input into the encoder of a pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized. This includes: inputting the text to be recognized into the N encoding layers for N encoding processes to obtain encoding matrices output by the N encoding layers; wherein, the encoding matrix output by the first encoding layer is the result obtained by inputting the representation matrix corresponding to the text to be recognized into the first encoding layer; the encoding matrix output by the Nth encoding layer is the result obtained by inputting the encoding matrix output by the (N-1)th encoding layer into the Nth encoding layer; and the encoding matrix output by the Nth encoding layer is used as the text encoding feature information corresponding to the text to be recognized.
[0080] The encoding matrix can refer to the matrix obtained by the encoder after encoding the text to be recognized. Each encoding layer of the encoder will output the corresponding encoding matrix.
[0081] In the specific implementation, the server inputs the representation matrix of the text to be recognized into the first encoding layer for the first encoding process, obtaining the encoding matrix output by the first encoding layer. When the encoder has six encoding layers, the server inputs the encoding matrix output by the first encoding layer into the second encoding layer for the second encoding process, obtaining the encoding matrix output by the second encoding layer. The server inputs the encoding matrix output by the second encoding layer into the third encoding layer for the third encoding process, obtaining the encoding matrix output by the third encoding layer. The server inputs the encoding matrix output by the third encoding layer into the fourth encoding layer for the fourth encoding process, obtaining the encoding matrix output by the fourth encoding layer. The server inputs the encoding matrix output by the fourth encoding layer into the fifth encoding layer for the fifth encoding process, obtaining the encoding matrix output by the fifth encoding layer. The server inputs the encoding matrix output by the fifth encoding layer into the sixth encoding layer for the sixth encoding process, obtaining the encoding matrix output by the sixth encoding layer. The server uses the encoding matrix output by the sixth encoding layer as the text encoding feature information of the text to be recognized.
[0082] The technical solution of this embodiment involves inputting the text to be recognized into N encoding layers for N encoding processes to obtain the encoding matrix output by the N encoding layers. The encoding matrix output by the Nth encoding layer is used as the text encoding feature information corresponding to the text to be recognized. In this way, the text to be recognized is encoded multiple times, and the data features of the text to be recognized can be extracted layer by layer, making the extracted data features more accurate. This is conducive to accurately recognizing the text to be recognized and improving the accuracy of text processing.
[0083] In another embodiment, the gating structure includes gating units corresponding to each coding layer, and the method further includes: when the gating parameter corresponding to the coding layer is a target gating value, fusing the coding layer feature information output by the coding layer with the text coding feature information to obtain the coding layer coding feature information corresponding to the coding layer; when the gating parameter corresponding to the coding layer is not a target gating value, using the coding layer feature information output by the coding layer as the coding layer coding feature information corresponding to the coding layer; and generating encoder coding feature information based on the coding layer coding feature information corresponding to each coding layer.
[0084] Among them, the gating unit can be a threshold structure unit used to control the fusion of coding layer feature information and text coding feature information output by the coding layer.
[0085] The target gating value can be 1.
[0086] In the specific implementation, when the gate parameter value corresponding to the coding layer is 1, the server fuses the coding layer feature information output by the coding layer with the text coding feature information to obtain the coding layer coding feature information corresponding to the coding layer. When the gate parameter value corresponding to the coding layer is 1, the server does not fuse the coding layer feature information output by the coding layer with the text coding feature information, and uses the text coding feature information as the coding layer coding feature information corresponding to the coding layer. The server generates encoder coding feature information from the coding layer coding feature information corresponding to each coding layer.
[0087] The technical solution of this embodiment, when the gate parameter corresponding to the encoding layer is the target gate value, fuses the encoding layer feature information output by the encoding layer with the text encoding feature information to obtain the encoding layer encoding feature information corresponding to the encoding layer; when the gate parameter corresponding to the encoding layer is not the target gate value, the encoding layer feature information output by the encoding layer is used as the encoding layer encoding feature information corresponding to the encoding layer; based on the encoding layer encoding feature information corresponding to each encoding layer, encoder encoding feature information is generated. In this way, the encoding layer encoding feature information corresponding to each encoding layer can be determined, the valid encoding layer feature information can be input to the corresponding decoding layer, and the invalid encoding layer feature information can be excluded, which can achieve more accurate feature extraction, which is conducive to accurately recognizing the text to be recognized and improving the accuracy of text processing.
[0088] In another embodiment, the decoder includes N decoding layers. Encoder-encoded feature information is input into the decoder of a pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized. This includes: inputting encoder-encoded feature information into the N decoding layers for N decoding processes to obtain decoding matrices output by the N decoding layers; wherein, the decoding matrix output by the first decoding layer is the result obtained by inputting the encoder-encoded feature information corresponding to the first encoding layer into the first decoding layer; the decoding matrix output by the Nth decoding layer is the result obtained by inputting the decoding matrix output by the (N-1)th decoding layer and the encoder-encoded feature information corresponding to the Nth encoding layer into the Nth decoding layer; and the text recognition result corresponding to the text to be recognized is obtained based on the decoding matrix output by the Nth decoding layer.
[0089] The decoding layer can be a decoding structure in the decoder that decodes the encoder's encoded feature information.
[0090] The decoding matrix can be a matrix obtained by the decoding layer after decoding the encoder's encoded feature information.
[0091] In practice, the server inputs the encoded feature information of each encoding layer into the corresponding decoding layer for decoding. Specifically, the server inputs the encoded feature information of the first encoding layer into the first decoding layer to obtain the decoding matrix output by the first decoding layer. When the decoder includes six decoding layers, the server inputs the encoded feature information of the second encoding layer and the decoding matrix output by the first decoding layer into the second decoding layer to obtain the decoding matrix output by the second decoding layer. The server then inputs the encoded feature information of the third encoding layer and the decoding matrix output by the second decoding layer into the third decoding layer to obtain the decoding matrix output by the third decoding layer. The server inputs the encoded feature information from the fourth encoding layer and the decoding matrix output from the third decoding layer into the fourth decoding layer for decoding, obtaining the decoding matrix output from the fourth decoding layer. The server then inputs the encoded feature information from the fifth encoding layer and the decoding matrix output from the fourth decoding layer into the fifth decoding layer for decoding, obtaining the decoding matrix output from the fifth decoding layer. The server then inputs the encoded feature information from the sixth encoding layer and the decoding matrix output from the fifth decoding layer into the sixth decoding layer for decoding, obtaining the decoding matrix output from the sixth decoding layer. Based on the decoding matrix output from the sixth decoding layer, the server determines the text recognition result of the text to be recognized.
[0092] The technical solution of this embodiment involves inputting the encoder's encoded feature information into N decoding layers for N decoding processes to obtain the decoding matrix output by the N decoding layers. Based on the decoding matrix output by the Nth decoding layer, the text recognition result corresponding to the text to be recognized is obtained. In this way, multi-layer decoding processing of the encoder's encoded feature information is realized, which can extract more accurate feature information, which is conducive to more accurate text recognition of the text to be recognized and improves the accuracy of text processing.
[0093] In another embodiment, the method further includes: obtaining a text recognition model to be trained; obtaining a text training sample set, using the text training sample set to train the text recognition model to be trained to obtain a first text recognition model; optimizing the structure of the first text recognition model to obtain a second text recognition model, which is used as a pre-trained text recognition model; the model accuracy of the second text recognition model is higher than that of the first text recognition model.
[0094] The text training sample set can be a collection of text samples used to train a text recognition model.
[0095] The first text recognition model can be a model obtained by training a text recognition model.
[0096] The second text recognition model can be a model obtained by optimizing the structure and computational accuracy of the first text recognition model using TensorRT (a high-performance deep learning inference optimizer).
[0097] In the specific implementation, the server obtains the text recognition model to be trained and the text sample training dataset. The server uses the text training sample set as input to train the text recognition model to obtain the trained text recognition model, which is used as the first text recognition model. The server then optimizes the structure of the first text recognition model to obtain the optimized text recognition model, which is the second text recognition model, and uses it as the pre-trained text recognition model.
[0098] In practical applications, Figure 5 An exemplary flowchart of the text recognition model training process is provided, and the training process is as follows:
[0099] Step 1: Preprocess the data in the original text dataset. This includes denoising, word segmentation, stop word removal, N-gram removal, and text concatenation.
[0100] Step 2: Annotate the text data. Divide the text data into three sentiment categories: positive, neutral, and negative. Construct a sentiment dictionary, and divide the annotated data into a training set and a test set, generating a corpus.
[0101] Step 3: Train the initial text recognition model. Based on the initial text recognition model, construct a new text recognition model, i.e., an improved text recognition model. Train the improved text recognition model using a text training sample set, and test the trained model using a text test set to generate training files;
[0102] Step 4: Optimize the trained text recognition model. Use TensorRT to optimize the structure and computational accuracy of the trained model.
[0103] The text recognition model obtained through steps 1 to 4 can be applied to multiple text recognition tasks. Specifically, based on a sentiment lexicon and corpus, different classifiers can be used to implement different sentiment recognition tasks, including sentiment word extraction, sentiment word classification, and sentiment retrieval. The sentiment extraction task extracts sentiment opinion words to obtain a set of sentiment words corresponding to the text; the sentiment classification task classifies the text into positive and negative categories based on the extracted sentiment word set; and the sentiment retrieval task determines the sentiment theme of the text based on the sentiment word set and the sentiment classification results. Specifically, the sentiment extraction task, as the foundation of text sentiment recognition, extracts key and useful information units from the text and then transforms the text into structured text information that is easily recognized by computers. The extracted information units mainly include the opinion holder, the evaluation object (e.g., teacher, course), attribute words (e.g., class, lecture), sentiment words (e.g., good, bad), and the polarity determination of sentiment words (assigning a positive or negative label to the sentiment word, such as positive for positive and negative for negative). Sentiment classification tasks involve judging the subjective opinions expressed in text, typically categorizing them into two (positive and negative) or three (positive, negative, and neutral). Furthermore, it can be categorized at different granularities: document-level, sentence-level, and attribute-level sentiment classification. Sentiment retrieval involves searching for the viewpoints contained within a vast amount of textual information and ranking the results based on topic relevance and viewpoint bias. The results returned by sentiment retrieval must simultaneously satisfy both topic relevance and viewpoint bias.
[0104] The technical solution of this embodiment involves obtaining a text recognition model to be trained; obtaining a text training sample set; using the text training sample set to train the text recognition model to be trained to obtain a first text recognition model; optimizing the structure of the first text recognition model to obtain a second text recognition model, which serves as a pre-trained text recognition model; thus, the text recognition model is trained to obtain a text recognition model that can accurately recognize text information, and the text recognition model is optimized to obtain a text recognition model with a better structure and higher computational accuracy, which is beneficial for more accurate text recognition and improves the accuracy of text processing.
[0105] In another embodiment, training a text recognition model to be trained using a text training sample set to obtain a first text recognition model includes: inputting the text training sample set into the encoder of the text recognition model to be trained to obtain encoder output feature information; inputting the encoder output feature information into the decoder of the text recognition model to be trained to obtain decoder output feature information; determining loss information based on the decoder output feature information; the loss information is used to determine the influence of the encoder output feature information on the decoder output feature information; and training the text recognition model to be trained based on the loss information to obtain the first text recognition model.
[0106] The encoder output feature information can be the output feature information of each coding layer during the training of the text recognition model. Alternatively, the output feature information of each coding layer can be the fused feature information obtained by fusing the feature information of each coding layer with the coding matrix output by the last coding layer of the encoder. Finally, the feature information of each coding layer can be the feature information extracted during the coding operation of each coding layer.
[0107] The decoder output feature information can be the output feature information of each decoding layer during the training of the text recognition model. Specifically, the output feature information of each decoding layer can be obtained by processing the feature information of each decoding layer with the decoding matrix output by the last decoding layer of the decoder. Alternatively, the feature information of each decoding layer can be the feature information extracted during the decoding operation of each decoding layer.
[0108] The loss information can be determined based on the feature information corresponding to each decoding layer and the decoding matrix output by the last decoding layer of the decoder. Alternatively, the loss information can be used to determine whether the output feature information of each coding layer affects the output feature information of the decoder.
[0109] In the specific implementation, the server inputs the text training sample set into the encoder of the text recognition model to be trained to obtain the encoder output feature information. The server then inputs the encoder output feature information into the decoder of the text recognition model to be trained to obtain the decoder output feature information. Based on the decoder output feature information, the server determines the influence of the encoder output feature information on the decoder output feature information, thereby determining the loss information. Based on the loss information, the server trains the text recognition model to be trained to obtain the trained text recognition model, which serves as the first text recognition model.
[0110] For the convenience of those skilled in the art, Figure 6An internal structure diagram of a text recognition model is provided as an example. The model includes 6 encoding layers and 6 decoding layers. In this model, the final recognition result only uses the encoded information output by the last encoding layer, which means that the feature layers of the encoding and decoding parts do not establish a sufficient connection.
[0111] To establish a sufficient connection between the feature layers of the encoding and decoding parts of this text recognition model, in practical applications, the output of each encoding layer of the text recognition model is output using a text_head structure (a partial model structure of a deep learning model) to display the feature information obtained by that encoding layer. This output is then fused with the output of the last encoding layer in the encoding stage through a residual structure. The processing flow of the text_head structure for the input information is as follows: Figure 7 As shown, matrices 1, 2, and 3 are actually obtained by linear transformations of the input representation matrices. Matrix 1 is the query vector Q corresponding to the representation matrix, matrix 2 is the query vector K corresponding to the representation matrix, and matrix 3 is the content vector V corresponding to the representation matrix. After transforming matrices 1 and 2, the transformation results are standardized and masked. The masked result is input to the activation layer, and the matrix output by the activation layer is multiplied by matrix 3, then normalized before output. Since it is uncertain whether the feature information of each encoding layer obtained by the encoder is beneficial to the overall recognition accuracy of the model, it is necessary to filter the output feature information of the encoding layer to select beneficial feature information for input into the decoding stage. In practical applications, the output feature information of the encoding layer is selected by adding a feedback method for auxiliary training combined with a sparse threshold.
[0112] For the convenience of those skilled in the art, Figure 8 An exemplary text recognition model structure is provided, which effectively utilizes the output information of the encoding layer through auxiliary training feedback combined with sparse thresholding. Specifically, a text_head structure (structure 1) is added to each decoding layer for improvement, and the text_head structure (structure 2) of the decoding layer is incorporated into the model training strategy. A softmax layer (an activation layer in a neural network model) is used to ensure that the output dimension of the text_head structure (structure 2) of the decoding layer is the same as the dimension of the final output of the model. Therefore, each text_head structure (structure 2) of the decoding layer can output a loss information corresponding to that layer during training. The loss value learned by each decoding layer in this round of training is denoted as l. t Compare it with the loss value from the previous round. If l t <=lt-1 Then, the threshold parameter G of the threshold unit of the coding layer feature information is set to 1, and the feature information of this layer and the corresponding coding layer are selected for concatenation and fusion in the actual model application stage. Otherwise, the threshold parameter G of the coding layer feature information is set to 0, that is, the feature information of the coding layer is not output to the decoding layer.
[0113] The overall loss function expression for the model is:
[0114]
[0115] Where t is the current training round number, and loss t The loss of the text recognition model for the current number of training epochs, Output the loss value for the i-th decoding layer in the current training epoch t. The loss value output by the i-th decoding layer in the previous training epoch t-1 is g. i The threshold parameter is the limit of the feature information of the coding layer. When g i =1 indicates that the feature information of the cascaded encoding layer corresponding to the i-th decoding layer is used in the model training.
[0116] The technical solution of this embodiment involves inputting a text training sample set into the encoder of a text recognition model to be trained to obtain encoder output feature information; inputting the encoder output feature information into the decoder of the text recognition model to be trained to obtain decoder output feature information; determining loss information based on the decoder output feature information; using the loss information to determine the impact of encoder output feature information on decoder output feature information; and training the text recognition model to be trained based on the loss information to obtain a first text recognition model. In this way, during the training phase, the encoding layer feature information corresponding to each encoding layer in the encoder can be input into the decoder, and the encoding layer feature information that affects the decoding result can be determined through the loss information. This allows for setting threshold parameters for each encoding layer, enabling the determination of a more accurate text recognition model, which is beneficial for more accurate text recognition and improves text processing accuracy.
[0117] In another embodiment, the decoder includes N decoding layers, where N is greater than or equal to 2. The encoder output feature information is input into the decoder in the text recognition model to be trained to obtain decoder output feature information. This includes: inputting the encoder output feature information into the N decoding layers for N decoding processes to obtain N decoding matrices output by the decoding layers; wherein the decoding matrix output by the first decoding layer is the result obtained by inputting the encoder output feature information into the first decoding layer; the decoding matrix output by the Nth decoding layer is the result obtained by inputting the decoding matrix output by the (N-1)th decoding layer and the encoder output feature information into the Nth decoding layer; and the decoding matrix output by the Nth decoding layer is used as the decoder output feature information.
[0118] In the specific implementation, the server inputs the encoder output feature information into the first decoding layer to obtain the decoding matrix output by the first decoding layer. When the decoder has six decoding layers, the server inputs the decoding matrix output by the first decoding layer and the encoder output feature information into the second decoding layer to obtain the decoding matrix output by the second decoding layer. The server inputs the decoding matrix output by the second decoding layer and the encoder output feature information into the third decoding layer to obtain the decoding matrix output by the third decoding layer. The server inputs the decoding matrix output by the third decoding layer and the encoder output feature information into the fourth decoding layer to obtain the decoding matrix output by the fourth decoding layer. The server inputs the decoding matrix output by the fourth decoding layer and the encoder output feature information into the fifth decoding layer to obtain the decoding matrix output by the fifth decoding layer. The server inputs the decoding matrix output by the fifth decoding layer and the encoder output feature information into the sixth decoding layer to obtain the decoding matrix output by the sixth decoding layer. The server uses the decoding matrix output by the sixth decoding layer as the decoder output feature information.
[0119] The technical solution of this embodiment involves inputting the encoder output feature information into N decoding layers for N decoding processes to obtain the decoding matrix output by the N decoding layers. The decoding matrix output by the Nth decoding layer is then used as the decoder output feature information. In this way, multi-layer decoding processing of the encoder output feature information is achieved during the training phase, which is beneficial for training the text recognition model more accurately and enabling more accurate text recognition of the text to be recognized, thereby improving the accuracy of text processing.
[0120] In another embodiment, the loss information includes decoding layer loss information corresponding to each decoding layer. Based on the loss information, the text recognition model to be trained is trained to obtain a first text recognition model, including: determining the gating parameters of each gating unit based on the decoding layer loss information corresponding to each decoding layer; and determining a first text recognition model containing a gating structure based on the gating parameters of each gating unit.
[0121] The decoding layer loss information refers to the information determined based on the feature information corresponding to the decoding layer and the decoding matrix output by the last decoding layer of the decoder. The loss information of each decoding layer characterizes whether the feature information of the corresponding coding layer affects the output of the decoder.
[0122] In the specific implementation, the server determines the gating parameters of the gating unit corresponding to each decoding layer based on the decoding layer loss information. When the gating parameter is 1, the server determines that the feature information of the encoding layer corresponding to the gating parameter has an impact on the output result of the decoder. When the gating parameter is 0, the server determines that the feature information of the encoding layer corresponding to the gating parameter has a small impact on the output result of the decoder. The server determines the first text recognition model based on the value of each gating parameter.
[0123] The technical solution of this embodiment determines the gating parameters of each gating unit based on the decoding layer loss information corresponding to each decoding layer; and determines the first text recognition model containing the gating structure based on the gating parameters of each gating unit. In this way, it is possible to determine effective coding layer feature information, accurately determine each gating parameter, and thus train a more accurate text recognition model, which is conducive to more accurate text recognition of the text to be recognized and improves the accuracy of text processing.
[0124] In another embodiment, such as Figure 9 As shown, a text processing method is provided, which can be applied to... Figure 1 Taking server 104 as an example, the following steps are included:
[0125] Step S902: Obtain the text to be recognized.
[0126] Step S904: Obtain the text recognition model to be trained.
[0127] Step S906: Obtain a text training sample set, and use the text training sample set to train the text recognition model to be trained, thereby obtaining the first text recognition model.
[0128] Step S908: Optimize the structure of the first text recognition model to obtain the second text recognition model, which is used as a pre-trained text recognition model; the model accuracy of the second text recognition model is higher than that of the first text recognition model.
[0129] Step S910: Input the text to be recognized into the encoder in the pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized; the encoder has a gating structure; the gating parameters of the gating structure are used to indicate whether to fuse the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information.
[0130] Step S912: Input the encoder-encoded feature information into the decoder in the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized.
[0131] It should be noted that the specific limitations of the above steps can be found in the specific limitations of a text processing method described above.
[0132] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0133] Based on the same inventive concept, this application also provides a text processing apparatus for implementing the text processing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more text processing apparatus embodiments provided below can be found in the limitations of the text processing method described above, and will not be repeated here.
[0134] In one embodiment, such as Figure 10 As shown, a text processing apparatus is provided, comprising:
[0135] Module 1002 is used to acquire the text to be recognized;
[0136] The input module 1004 is used to input the text to be recognized into the encoder of the pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized; the encoder has a gating structure; the gating parameters of the gating structure are used to indicate whether to fuse the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information;
[0137] The recognition module 1006 is used to input the encoder-encoded feature information into the decoder in the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized.
[0138] In one embodiment, the encoder includes N encoding layers, where N is greater than or equal to 2. The input module 1004 is specifically used to input the text to be recognized into the N encoding layers for N encoding processes to obtain encoding matrices output by the N encoding layers. The encoding matrix output by the first encoding layer is the result of inputting the representation matrix corresponding to the text to be recognized into the first encoding layer. The encoding matrix output by the Nth encoding layer is the result of inputting the encoding matrix output by the (N-1)th encoding layer into the Nth encoding layer. The encoding matrix output by the Nth encoding layer is used as the text encoding feature information corresponding to the text to be recognized.
[0139] In one embodiment, the gating structure includes gating units corresponding to each coding layer and an input module 1004, specifically used to fuse the coding layer feature information output by the coding layer with the text coding feature information when the gating parameter corresponding to the coding layer is the target gating value, to obtain the coding layer coding feature information corresponding to the coding layer; when the gating parameter corresponding to the coding layer is not the target gating value, to use the coding layer feature information output by the coding layer as the coding layer coding feature information corresponding to the coding layer; and to generate encoder coding feature information based on the coding layer coding feature information corresponding to each coding layer.
[0140] In one embodiment, the decoder includes N decoding layers. The input module 1004 is specifically used to input the encoder-encoded feature information into the N decoding layers for N decoding processes to obtain the decoding matrices output by the N decoding layers. The decoding matrix output by the first decoding layer is the result obtained by inputting the encoder-encoded feature information corresponding to the first encoding layer into the first decoding layer. The decoding matrix output by the Nth decoding layer is the result obtained by inputting the decoding matrix output by the (N-1)th decoding layer and the encoder-encoded feature information corresponding to the Nth encoding layer into the Nth decoding layer. Based on the decoding matrix output by the Nth decoding layer, the text recognition result corresponding to the text to be recognized is obtained.
[0141] In one embodiment, the apparatus further includes: a training module, specifically configured to acquire a text recognition model to be trained; acquire a text training sample set, and use the text training sample set to train the text recognition model to be trained to obtain a first text recognition model; perform structural optimization on the first text recognition model to obtain a second text recognition model, which serves as a pre-trained text recognition model; the model accuracy of the second text recognition model is higher than that of the first text recognition model.
[0142] In one embodiment, the training module is specifically used to input the text training sample set into the encoder of the text recognition model to be trained to obtain encoder output feature information; input the encoder output feature information into the decoder of the text recognition model to be trained to obtain decoder output feature information; determine loss information based on the decoder output feature information; the loss information is used to determine the influence of encoder output feature information on decoder output feature information; and train the text recognition model to be trained based on the loss information to obtain a first text recognition model.
[0143] In one embodiment, the decoder includes N decoding layers, where N is greater than or equal to 2. The training module is specifically used to input the encoder output feature information into the N decoding layers for N decoding processes to obtain the decoding matrices output by the N decoding layers. The decoding matrix output by the first decoding layer is the result obtained by inputting the encoder output feature information into the first decoding layer. The decoding matrix output by the Nth decoding layer is the result obtained by inputting the decoding matrix output by the (N-1)th decoding layer and the encoder output feature information into the Nth decoding layer. The decoding matrix output by the Nth decoding layer is used as the decoder output feature information.
[0144] In one embodiment, the loss information includes decoding layer loss information corresponding to each decoding layer. The training module is specifically used to determine the gating parameters of each gating unit based on the decoding layer loss information corresponding to each decoding layer; and to determine a first text recognition model containing a gating structure based on the gating parameters of each gating unit.
[0145] Each module in the aforementioned text processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.
[0146] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores text processing data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a text processing method.
[0147] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0148] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, which, when executed by the processor, causes the processor to perform the steps of the text processing method described above. The steps of the text processing method described here may be steps from one of the text processing methods in the various embodiments described above.
[0149] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, causes the processor to perform the steps of the text processing method described above. The steps of the text processing method described here may be steps from one of the text processing methods in the various embodiments described above.
[0150] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, causes the processor to perform the steps of the text processing method described above. The steps of the text processing method described here may be steps from one of the text processing methods in the various embodiments described above.
[0151] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0152] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0153] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0154] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A text processing method, characterized in that, The method includes: Obtain the text to be recognized; The text to be recognized is input into the encoder of a pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized; the encoder has a gating structure; the gating parameters of the gating structure are used to indicate whether to fuse the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information; The encoder-encoded feature information is input into the decoder in the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized; The decoder includes N decoding layers. The process of inputting the encoder-encoded feature information into the decoder of the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized includes: The encoder's encoded feature information is input into the N decoding layers for N decoding processes to obtain the decoding matrices output by the N decoding layers; wherein, the decoding matrix output by the first decoding layer is the result obtained by inputting the encoding feature information of the first encoding layer into the first decoding layer; the decoding matrix output by the Nth decoding layer is the result obtained by inputting the decoding matrix output by the (N-1)th decoding layer and the encoding feature information of the Nth encoding layer into the Nth decoding layer; Based on the decoding matrix output by the Nth decoding layer, the text recognition result corresponding to the text to be recognized is obtained.
2. The method according to claim 1, characterized in that, The encoder comprises N encoding layers, where N is greater than or equal to 2. The step of inputting the text to be recognized into the encoder of a pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized includes: The text to be recognized is input into the N encoding layers for N encoding processes to obtain the encoding matrix output by the N encoding layers; wherein, the encoding matrix output by the first encoding layer is the result obtained by inputting the representation matrix corresponding to the text to be recognized into the first encoding layer; the encoding matrix output by the Nth encoding layer is the result obtained by inputting the encoding matrix output by the (N-1)th encoding layer into the Nth encoding layer; The encoding matrix output by the Nth encoding layer is used as the text encoding feature information corresponding to the text to be identified.
3. The method according to claim 2, characterized in that, The gating structure includes gating units corresponding to each of the coding layers, and the method further includes: When the gating parameter corresponding to the coding layer is the target gating value, the coding layer feature information output by the coding layer is fused with the text coding feature information to obtain the coding layer coding feature information corresponding to the coding layer. If the gate parameter corresponding to the coding layer is not the target gate value, the coding layer feature information output by the coding layer shall be used as the coding layer coding feature information corresponding to the coding layer. The encoder coding feature information is generated based on the coding feature information corresponding to each coding layer.
4. The method according to claim 1, characterized in that, The method further includes: Obtain the text recognition model to be trained; Obtain a text training sample set, and use the text training sample set to train the text recognition model to be trained, to obtain a first text recognition model; The first text recognition model is structurally optimized to obtain a second text recognition model, which serves as the pre-trained text recognition model; the model accuracy of the second text recognition model is higher than that of the first text recognition model.
5. The method according to claim 4, characterized in that, The step of training the text recognition model to be trained using the text training sample set to obtain the first text recognition model includes: The text training sample set is input into the encoder of the text recognition model to be trained to obtain the encoder output feature information; The encoder output feature information is input into the decoder in the text recognition model to be trained to obtain the decoder output feature information; Based on the decoder output feature information, loss information is determined; the loss information is used to determine the impact of the encoder output feature information on the decoder output feature information. Based on the loss information, the text recognition model to be trained is trained to obtain the first text recognition model.
6. The method according to claim 5, characterized in that, The decoder comprises N decoding layers, where N is greater than or equal to 2. The step of inputting the encoder output feature information into the decoder of the text recognition model to be trained, to obtain decoder output feature information, includes: The encoder output feature information is input into the N decoding layers for N decoding processes to obtain the decoding matrix output by the N decoding layers; wherein, the decoding matrix output by the first decoding layer is the result obtained by inputting the encoder output feature information into the first decoding layer; the decoding matrix output by the Nth decoding layer is the result obtained by inputting the decoding matrix output by the (N-1)th decoding layer and the encoder output feature information into the Nth decoding layer; The decoding matrix output by the Nth decoding layer is used as the output feature information of the decoder.
7. The method according to claim 5, characterized in that, The loss information includes decoding layer loss information corresponding to each decoding layer. The step of training the text recognition model to be trained based on the loss information to obtain the first text recognition model includes: Based on the decoding layer loss information corresponding to each decoding layer, determine the gating parameters of each gating unit; Based on the gating parameters of each gating unit, the first text recognition model containing the gating structure is determined.
8. A text processing device, characterized in that, The text processing apparatus is used to implement the text processing method according to any one of claims 1-7, the apparatus comprising: The acquisition module is used to acquire the text to be recognized; An input module is used to input the text to be recognized into the encoder of a pre-trained text recognition model to obtain the text encoding feature information corresponding to the text to be recognized; the encoder has a gating structure; the gating parameters of the gating structure are used to indicate whether to fuse the encoding layer feature information output by each encoding layer in the encoder with the text encoding feature information to generate encoder encoding feature information; The recognition module is used to input the encoder-encoded feature information into the decoder in the pre-trained text recognition model to obtain the text recognition result corresponding to the text to be recognized.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.