Text recognition method, model training method, device, equipment and storage medium

By using a single model to preprocess and train both the comparison text and the target text, and combining bidirectional memory network layers and classification layers, the information transmission error problem in multiple text recognition tasks is solved, thereby improving recognition accuracy and user experience.

CN119003761BActive Publication Date: 2026-11-20TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310553718.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-16
Publication Date
2026-11-20
Estimated Expiration
2043-05-16

AI Technical Summary

Technical Problem

When existing technologies use different models to perform recognition tasks for each type of text, the recognition accuracy is easily reduced due to information transmission errors, which affects the user experience.

Method used

A single model is used to preprocess text by comparing text, target text, and classification information to generate text sequences. The target model is then used for training to output text association labels, classification labels, and subject information. By combining bidirectional memory network layers and classification layers to process character vectors, label paths are determined to improve recognition accuracy.

Benefits of technology

This effectively avoids information transmission errors, ensures the accuracy and efficiency of the model when performing multiple recognition tasks, and improves the user's experience in obtaining text information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119003761B_ABST
    Figure CN119003761B_ABST
Patent Text Reader

Abstract

The application discloses a text recognition method and device, a model training method and device, equipment and a storage medium. Contrast text, target text and target text classification information are obtained. The contrast text, the target text and the target text classification information are preprocessed to obtain a text sequence. The text sequence is input into a target model to obtain a target label sequence, the target label sequence at least including a text association label of the target text relative to the contrast text, a text classification label and text body information. The target model is obtained by contrast training based on an output result corresponding to a sample text sequence and a sample label sequence. The sample text sequence is obtained by preprocessing a sample contrast text, a sample target text and sample target text classification information. The sample label sequence includes a sample association label of the sample target text relative to the sample contrast text, a sample text classification label and sample text body information. Thus, a single model can be used to perform multiple recognition tasks on the same text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a text recognition method, a model training method, an apparatus, a device, and a storage medium. Background Technology

[0002] Artificial intelligence (AI) has been applied to a wide range of fields, encompassing technologies such as computer vision, speech processing, and natural language processing. Among these, natural language processing technology has profound significance in the application of text semantic understanding. For example, it can identify the degree of correlation between texts, recognize the main information of a text, and analyze the sentiment attributes of a text. Therefore, text semantic understanding can be used to complete different types of text recognition tasks.

[0003] In order to complete various types of text recognition tasks, related technologies have built corresponding models for each type of text recognition task, so as to complete each type of text recognition task by constructing different models.

[0004] In the process of researching and practicing related technologies, the inventors of this application discovered that when related technologies use different models to complete text recognition tasks of each type of text, for text recognition tasks of multiple types of text that are related to the same text, errors will occur when different models transmit information, which can easily reduce the recognition accuracy of the model and affect the user experience. Summary of the Invention

[0005] This application provides a text recognition method, model training method, apparatus, device, and computer-readable storage medium, which can simultaneously perform multiple text recognition tasks associated with the same text using a single model, effectively avoiding information transmission errors, ensuring the recognition accuracy of the model when performing multiple recognition tasks, and improving the user's experience in obtaining text information.

[0006] This application provides a text recognition method, including:

[0007] Obtain comparison text, target text, and target text classification information;

[0008] The comparison text, target text, and target text classification information are preprocessed to obtain a text sequence;

[0009] The text sequence is input into the target model to obtain the target label sequence, which at least includes the text association label, text classification label and text body information of the target text relative to the comparison text;

[0010] The target model is obtained by training a preset model by comparing the output of the sample text sequence with the sample label sequence. The sample text sequence is obtained by preprocessing the sample comparison text, the sample target text, and the sample target text classification information. The sample label sequence includes the sample association label of the sample target text relative to the sample comparison text, the sample text classification label, and the sample text main information.

[0011] Accordingly, embodiments of this application provide a text recognition device, including:

[0012] The acquisition unit is used to acquire the comparison text, the target text, and the target text classification information.

[0013] The preprocessing unit is used to preprocess the comparison text, target text, and target text classification information to obtain a text sequence;

[0014] The recognition unit is used to input the text sequence into the target model to obtain a target label sequence, wherein the target label sequence contains at least the text association label, text classification label and text body information of the target text relative to the comparison text;

[0015] The target model is obtained by training a preset model by comparing the output of the sample text sequence with the sample label sequence. The sample text sequence is obtained by preprocessing the sample comparison text, the sample target text, and the sample target text classification information. The sample label sequence includes the sample association label of the sample target text relative to the sample comparison text, the sample text classification label, and the sample text main information.

[0016] In some embodiments, the identification unit is further configured to:

[0017] Based on the target model, semantic enhancement representation is performed on each character in the text sequence to obtain a character vector sequence, which contains a character representation vector corresponding to each character.

[0018] Each character representation vector is fused and transformed with the features of the character vector sequence during bidirectional propagation to obtain the label scoring sequence corresponding to each character representation vector;

[0019] Based on multiple label categories in each label scoring sequence and the label score corresponding to each label category, a target label path is determined, which is used to instruct the target model to output a target label sequence.

[0020] In some implementations, the target model includes an encoding layer, and the recognition unit is further configured to:

[0021] The text sequence is processed by vector embedding through the encoding layer to obtain an embedding vector sequence, which contains the embedding representation vector corresponding to each character.

[0022] Based on the bidirectional features of each embedding representation vector in the embedding vector sequence, each embedding representation vector is encoded to obtain a character vector sequence with semantically enhanced representation.

[0023] In some embodiments, the target model further includes a bidirectional memory network layer connected to the coding layer, and the recognition unit is further configured to:

[0024] The bidirectional memory network layer is used to perform forward propagation on each character representation vector in the character vector sequence to obtain the context feature corresponding to each character representation vector.

[0025] By backpropagating each character representation vector in the character vector sequence, the context feature corresponding to each character representation vector is obtained;

[0026] Each character representation vector is fused with its corresponding preceding context feature and its corresponding following context feature to obtain the fused feature corresponding to each character representation vector;

[0027] The fused features are linearly transformed to obtain the label score sequence corresponding to each character representation vector.

[0028] In some embodiments, the target model further includes a classification layer connected to the bidirectional memory network layer, and the recognition unit is further configured to:

[0029] The classification layer combines any selected tag category in each tag scoring sequence according to the character sorting relationship of the text sequence to obtain multiple candidate tag paths, each candidate tag path containing the tag category of each character;

[0030] Based on multiple tag categories in each tag scoring sequence and the tag score corresponding to each tag category, determine the tag score for each tag category indicated in each candidate tag path;

[0031] Calculate the path score of the corresponding candidate label path based on the label score of each label category indicated in each candidate label path and the category transfer relationship between adjacent label categories;

[0032] The target label path is determined from the plurality of candidate label paths based on the path score.

[0033] In some embodiments, the identification unit is further configured to:

[0034] Calculate the tag status score corresponding to each candidate tag path based on the tag scores in each of the tag scoring sequences;

[0035] The label transition score is determined based on the state transition relationship between multiple label categories in each candidate label path;

[0036] Calculate the path score based on the label status score and label transition score corresponding to each candidate label path.

[0037] In some embodiments, the preprocessing unit is further configured to:

[0038] The comparison text, the target text, and the target text classification information are concatenated to obtain the concatenated text.

[0039] The concatenated text is segmented to obtain a text sequence.

[0040] In some embodiments, the text recognition device further includes a training unit for:

[0041] Obtain sample comparison text, sample target text, and sample target text classification information;

[0042] The sample text sequence is obtained by preprocessing the sample comparison text, sample target text, and sample target text classification information.

[0043] The sample text sequence is input into a preset model, and multiple candidate label paths generated by the preset model when processing the sample text sequence are obtained;

[0044] Obtain a sample label sequence, and instruct the preset model to select a target candidate label path from the plurality of candidate label paths according to the sample label sequence, so as to output a target predicted label sequence;

[0045] A target loss function is constructed based on the proportion of path scores of the target predicted label sequence, and the preset model is iteratively trained based on the target loss function until convergence is obtained to obtain the trained target model.

[0046] In some implementations, the training unit is further configured to:

[0047] Determine the predicted label state score and predicted label transition score for each candidate label path, and calculate the candidate path score for the corresponding candidate label path based on the predicted label state score and predicted label transition score.

[0048] Determine the total candidate path score corresponding to the multiple candidate path scores, and query the target path score corresponding to the target prediction label sequence from the multiple candidate path scores;

[0049] A target loss function is constructed based on the weight ratio between the target path score and the total score of the predicted candidate paths.

[0050] In some implementations, the training unit is further configured to:

[0051] Obtain the predicted label score sequence when the preset model processes each character in the sample text sequence. The predicted label score sequence includes multiple predicted label categories and the predicted category score corresponding to each predicted label category.

[0052] Determine the target predicted label category corresponding to each character in each candidate label path, and calculate the predicted label state score of the corresponding candidate label path based on the predicted category score corresponding to each target predicted label category;

[0053] Determine the category transfer score between any two adjacent target predicted label categories in each candidate label path, and calculate the predicted label transfer score of the corresponding candidate label path based on the multiple category transfer scores.

[0054] Accordingly, embodiments of this application also provide a model training method, including:

[0055] Obtain sample comparison text, sample target text, and sample target text classification information;

[0056] The sample text sequence is obtained by preprocessing the sample comparison text, sample target text, and sample target text classification information.

[0057] The sample text sequence is input into a preset model, and multiple candidate label paths generated by the preset model when processing the sample text sequence are obtained;

[0058] Obtain a sample label sequence, and instruct the preset model to select a target candidate label path from the plurality of candidate label paths according to the sample label sequence, so as to output a target predicted label sequence;

[0059] A target loss function is constructed based on the proportion of path scores of the target predicted label sequence, and the preset model is iteratively trained based on the target loss function until convergence is obtained to obtain the trained target model.

[0060] Accordingly, embodiments of this application also provide a model training apparatus, including:

[0061] The first acquisition unit is used to acquire sample comparison text, sample target text, and sample target text classification information;

[0062] The processing unit is used to preprocess the sample comparison text, sample target text, and sample target text classification information to obtain a sample text sequence;

[0063] The second acquisition unit is used to input the sample text sequence into a preset model and acquire multiple candidate label paths generated by the preset model when processing the sample text sequence.

[0064] The selection unit is used to acquire a sample label sequence and, according to the sample label sequence, instruct the preset model to select a target candidate label path from the plurality of candidate label paths to output a target predicted label sequence.

[0065] The training unit is used to construct a target loss function based on the proportion of path scores of the target predicted label sequence, and to iteratively train the preset model based on the target loss function until convergence, thereby obtaining the trained target model.

[0066] Furthermore, embodiments of this application also provide a computer device, including a processor and a memory, wherein the memory stores a computer program, and the processor is used to run the computer program in the memory to implement the steps in any of the text recognition methods or model training methods provided in embodiments of this application.

[0067] Furthermore, embodiments of this application also provide a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute steps in any of the text recognition methods or model training methods provided in embodiments of this application.

[0068] Furthermore, this application also provides a computer program product, including computer instructions, which, when executed, implement the steps in any text recognition method or model training method provided in this application.

[0069] This application embodiment can obtain comparison text, target text, and target text classification information; preprocess the comparison text, target text, and target text classification information to obtain a text sequence; input the text sequence into a target model to obtain a target label sequence, the target label sequence containing at least the text association label, text classification label, and text body information of the target text relative to the comparison text; wherein, the target model is obtained by training a preset model based on the output of the sample text sequence and the sample label sequence, the sample text sequence is obtained by preprocessing the sample comparison text, sample target text, and sample target text classification information, and the sample label sequence includes the sample association label, sample text classification label, and sample text body information of the sample target text relative to the sample comparison text. Therefore, this scheme, after obtaining the comparison text, target text, and target text classification information, preprocesses the text sequence to serve as the input to the target model. Combining the feature processing characteristics of each processing layer in the target model framework, the characters in the input text sequence are processed synchronously. This allows the model to comprehensively consider the vector information of all characters in the text sequence, strengthening the information correlation between multiple text recognition tasks. Furthermore, after processing the text sequence, the scheme outputs recognition result labels for multiple text tasks, including the text body information and text classification label of the target text, as well as the text association label between the target text and the comparison text. Thus, by using a single model to simultaneously execute multiple recognition tasks related to the same text, the scheme effectively avoids information transmission errors, ensuring the accuracy and efficiency of the model when performing multiple recognition tasks on the same text, and improving the user's experience in obtaining text information. Attached Figure Description

[0070] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0071] Figure 1 This is a schematic diagram of a scenario for the text recognition system provided in an embodiment of this application;

[0072] Figure 2 This is a flowchart illustrating the steps of the text recognition method provided in the embodiments of this application;

[0073] Figure 3 This is a flowchart illustrating the processing flow of the bidirectional coding layer provided in an embodiment of this application.

[0074] Figure 4 This is a schematic diagram of the embedded representation vector provided in the embodiments of this application;

[0075] Figure 5 This is a flowchart illustrating the processing flow of the bidirectional memory network layer provided in this embodiment of the application.

[0076] Figure 6 This is a flowchart illustrating the processing flow of the Long Short-Term Memory (LSTM) network layer provided in an embodiment of this application.

[0077] Figure 7 This is a schematic diagram of the feature processing flow of the target model framework provided in the embodiments of this application;

[0078] Figure 8 This is a schematic flowchart of the model training method provided in the embodiments of this application;

[0079] Figure 9 This is a schematic diagram of another step in the text recognition method provided in the embodiments of this application;

[0080] Figure 10 This is a schematic diagram of the tag state transition matrix provided in the application embodiment;

[0081] Figure 11 This is a schematic diagram of the structure of the text recognition device provided in the embodiments of this application;

[0082] Figure 12 This is a schematic diagram of the structure of the model training device provided in the embodiments of this application;

[0083] Figure 13 This is a schematic diagram of the structure of the computer device provided in the embodiments of this application. Detailed Implementation

[0084] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0085] In some processes described in the specification, claims, and the foregoing drawings, multiple steps are included in a specific order. However, it should be clearly understood that these steps may be performed in any order or in parallel. The step numbers are merely used to distinguish different steps and do not represent any execution order. Furthermore, descriptions such as "first" and "second" in this document are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0086] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0087] This application provides a text recognition method, a model training method, an apparatus, a device, and a computer-readable storage medium. Specifically, this application will describe the text recognition apparatus from the perspective of the text recognition device, which can be integrated into a computer device, such as a server or a user terminal. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The user terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, smart home appliance, vehicle terminal, smart voice interaction device, aircraft, etc., but is not limited to these.

[0088] It is understood that in the specific implementation of this application, data related to user information, user usage records, and user status are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0089] It should be noted that the text recognition method provided in this application can be applied to any text task or multiple text task recognition scenarios. These scenarios are not limited to implementation through cloud services, big data, artificial intelligence, or a combination thereof. The following embodiments illustrate this further:

[0090] The text recognition method provided in this application relates to Artificial Intelligence (AI) technology. AI utilizes digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceiving the environment, acquiring knowledge, and using that knowledge to obtain optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce new intelligent machines capable of reacting in a manner similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess perception, reasoning, and decision-making capabilities.

[0091] Natural Language Processing (NLP) is an important area within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language people use in daily life—and thus it has a close connection with linguistic research. NLP technologies typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.

[0092] However, embodiments of this application can achieve text recognition through text processing and / or semantic understanding techniques in natural language processing technology, in order to complete one or more text recognition tasks for the same text. This is specifically illustrated through the following embodiments:

[0093] It should be noted that in this text recognition scenario, it is mainly implemented through Artificial Neural Networks (ANNs) models, hereinafter referred to as "models". The text recognition process can include a training phase (A) and an application phase (B) of the model. The training phase and the application phase can be implemented through a combination of one or more devices in the text recognition system.

[0094] For example, see Figure 1 The diagram below illustrates a scenario of a text recognition system provided in this application. The system may include a server and / or a terminal. When the system includes only a server or a terminal, the server or terminal includes a target database, a model training device, and a model application device. When the system is a combination of a terminal and a server, the server may include a target database, a model training device, and a model application device.

[0095] The target database can store a large amount of data, including but not limited to unstructured text data, as sample text data for the model training phase.

[0096] (A) Model training phase:

[0097] During the model training phase, the model training device can train a pre-defined model based on the obtained sample text data. Specifically, the training phase may include preparing training data and model training.

[0098] The process of preparing training data involves obtaining training data from the target database. Specifically, after obtaining the sample text data, it is processed such as concatenation and word segmentation to obtain the sample text sequence input for model training. Furthermore, a sample label sequence needs to be established for this sample text sequence; for example, each character in the sample text sequence can be labeled to obtain the sample label sequence. A mapping relationship between the sample text sequence and the sample label sequence is then established, using the sample label sequence as an indicator during the training phase to indicate that the model training has reached convergence. This completes the acquisition of training data.

[0099] The training of the model can be understood as a comparative learning training between the model's output prediction results and the sample label sequences. Specifically, the model training process is as follows: A sample text sequence is input into a pre-defined model to obtain the predicted label sequence output by the pre-defined model. Then, the predicted label sequence is compared with the corresponding sample label sequences of the sample text sequence. When differences exist, a target loss function is constructed for the pre-defined model based on the sample text sequence. The pre-defined model is iteratively trained based on the target loss function until preset conditions are met, such as the predicted label sequence output by the pre-defined model being the same as the sample label sequence, or the number of iterations reaching a certain number, or the weight of the sample label sequence in the prediction results of the pre-defined model no longer changing according to the target loss function, etc., thus obtaining the trained target model. This target model can be used in the text recognition process of this application.

[0100] For example, suppose multiple text recognition tasks are set for the same text, such as recognizing the correlation between the current text and other texts, recognizing the main information of the current text, and recognizing the text category of the current text. To avoid errors in the transmission of text information, this application uses the same model framework to process the above three text recognition tasks for the same text. Specifically, firstly, a first text to be used to complete the above text recognition tasks and a second text for comparison are obtained. In addition, text classification information is also included to guide the output semantic sentiment category. The first text, the second text, and the text classification information are preprocessed to obtain a sample text sequence, and a sample label sequence corresponding to the sample text sequence is set. At this point, one example of training data is obtained. It should be noted that multiple examples of training data can be prepared for model training, and there is no specific limitation. Then, by inputting the sample text sequence into the preset model, the predicted label sequence output by the preset model is obtained. The network parameters of the preset model are adjusted according to the differences between the predicted label sequence and the labels in the sample label sequence for training. After iterative training until convergence, the trained target model is obtained. Subsequently, the trained target model can be used to identify the main text information, text category, and the relationship between the target text and other texts.

[0101] (B) Application phase of the model:

[0102] In the application phase of the model, the model training device can upload or install the trained target model to the model application device, so that the model application device can run the target model to perform the relevant text recognition process. Specifically, after acquiring text data for multiple recognition tasks of the same text, the model application device can preprocess the text data to obtain a text sequence, and input the text sequence into the trained target model to obtain the target label sequence output by the target model. This target label sequence includes the label results corresponding to each text recognition task.

[0103] Through the training and application scenarios of the above model, the text recognition method of this application can be realized.

[0104] For example, assuming a server or terminal includes a target database, a model training device, and a model application device, the server or terminal can prepare training data based on sample text data in the target database, train a preset model using the training data through the model training device, and then transfer the trained target model to the model application device for execution. In this case, the terminal or server can achieve the following: acquire comparison text, target text, and target text classification information; preprocess the comparison text, target text, and target text classification information to obtain a text sequence; input the text sequence into the target model to obtain a target label sequence, which at least includes text association labels, text classification labels, and text body information of the target text relative to the comparison text; wherein, the target model is obtained by comparing and training the output of the preset model based on the sample text sequence with the sample label sequence; the sample text sequence is obtained by preprocessing the sample comparison text, sample target text, and sample target text classification information; and the sample label sequence includes sample association labels, sample text classification labels, and sample text body information of the sample target text relative to the sample comparison text.

[0105] For example, consider a system combining a terminal and a server, where a communication connection is established between the terminal and the server. The server can be a distributed service system composed of multiple physical service providers, containing at least a target database, a model training device, and a model application device. After training the model on the server, the trained target model can be run on the server. Specifically, in the application phase, the client on the terminal can send reference comparison text, the target text to be recognized, and / or target text classification information to the server. The server receives the comparison text, target text, and target text classification information, preprocesses them to obtain a text sequence, and inputs the text sequence into the target model to obtain a target label sequence. The target label sequence includes at least the text association label of the target text relative to the comparison text, the text classification label, and the text body information. Afterward, the server can return the target label sequence containing the labels for each text recognition task to the terminal. It should be noted that the client on the terminal can send only the comparison text and target text to the server; the server can directly obtain the target text classification information set during the training phase, which is not limited here.

[0106] For example, in combination Figure 1 As shown, assuming a text recognition application (client) is installed on the terminal, the user can select multiple text recognition tasks within the application. These tasks may include: identifying the correlation between the current text and other texts, identifying the main body information of the current text, and identifying the semantic sentiment category of the current text. The text recognition process is as follows: First, the user can select the above multiple text recognition tasks on the client's page on the terminal, and set the target text to be recognized and the comparison text used for reference during the text recognition process. Simultaneously, the client obtains the pre-set target text classification information for the semantic sentiment category recognition task. Then, the client transmits the target text classification information, along with the user-defined target text and comparison text, to the server. Next, the server obtains the comparison text, target text, and target text classification information; preprocesses the comparison text, target text, and target text classification information to obtain a text sequence; inputs the text sequence into the target model to obtain a target label sequence, which at least includes the text association label, text classification label, and main body information of the target text relative to the comparison text. Finally, the server returns multiple pieces of information corresponding to the target label sequence to the client, so that the client can display multiple related text recognition results on the relevant client pages based on the target label sequence, such as text association labels, text body information, and text classification labels, thereby improving the user's experience in obtaining text information.

[0107] For ease of understanding, each step of the text recognition method will be described in detail below. It should be noted that the order of the following embodiments is not intended to limit the preferred order of the embodiments.

[0108] In this application embodiment, the description will focus on the text recognition device, specifically, the text recognition device that can be integrated into a computer device such as a terminal or server. See also Figure 2 , Figure 2 This is a flowchart illustrating the steps of a text recognition method provided in this application embodiment. Taking the text recognition device specifically integrated on a server as an example, the specific process when the processor on the server executes the program instructions corresponding to the text recognition method is as follows:

[0109] 101. Obtain the comparison text, target text, and target text classification information.

[0110] In this embodiment of the application, in order to complete multiple text recognition tasks of the same text through the same model framework, the input and output contents of the model framework can be set based on the characteristics of each processing layer within the model framework, and the model can be trained so that the trained model can complete multiple text recognition tasks of the same text.

[0111] For example, in this embodiment of the application, the text recognition task can be: identifying whether there is a relationship between the target text and other texts, identifying the text subject information corresponding to the target text, and identifying the classification label of the target text. For the above recognition task, the target text to be recognized can be determined first, and whether there is a comparison text that is related to the target text can be determined, as well as the target text classification information used to guide the output text classification label can be determined.

[0112] The target text can be a textual description of the event to be identified, representing the semantic information of the event. This target text can be understood as the basic text corresponding to the text recognition task, and the relevant text recognition task can be completed by recognizing this target text. For example, the target text can be a description of a message or comment on a forum. Taking a message on a forum as an example, to determine whether there is a connection between the message and a certain event text, and to analyze the main information and semantic classification tags of the message, the title, a sentence, or the entire content of the message can be used as the target text. Similarly, taking an academic paper as an example, to identify and analyze the academic paper, the title, abstract, a sentence, or the entire content of the academic paper can be used as the target text. These are merely examples and are not intended to limit the implementation of the text recognition method of this application.

[0113] The comparison text can be text containing descriptions of relevant events, representing the semantic information of those events, to identify whether the event content of the target text is semantically related to the target text. For example, taking a trending news event as an example, the text representing the semantic information of the event could be the event title, which could be used as the comparison text; similarly, taking an academic paper as an example, the paper title can represent the semantic information of the academic paper, so it could be used as the comparison text. These are merely examples and are not intended to limit the implementation of the text recognition method of this application.

[0114] The target text classification information can be information used to indicate the category label of the output target text, and the target text classification information can be of any form. For example, taking character-based information as an example, the target text classification information can be any form of character such as letters, numbers, symbols, or labels, or it can be information obtained by combining multiple forms of characters. For example, the letter "L" can be used as the target text classification information, or the "%" symbol can be used as the target text classification information; the above are merely examples and do not constitute a specific limitation on the implementation of the embodiments of this application.

[0115] It should be noted that the target text classification information, as part of the model's input, can only be used to instruct the neural network model to output information representing the text category in the corresponding output character position. That is, the target text classification information itself may not contain semantics associated with the target text or the comparison text, and there are no specific limitations.

[0116] In some implementations, the server can obtain the comparison text, target text, and target text classification information by receiving information. For example, suppose a user sends a text recognition request to the server through a text recognition application (client) on a terminal. This text recognition request carries the comparison text, target text, and target text classification information, and the server obtains the comparison text, target text, and target text classification information based on this text recognition request.

[0117] Furthermore, the server can set up message queues for multiple different text recognition requests, add recognition request messages to the message queues according to the text recognition requests, consume recognition request messages one by one from the message queues in sequence, and determine the comparison text, target text, and target text classification information based on the consumed recognition request messages. In this way, effective management of recognition requests for different target texts can be achieved.

[0118] By using the above methods, we can obtain comparison text, target text, and target text classification information for multiple recognition tasks of target text. This information can then be used to cleverly design the input data of the model, thereby completing multiple recognition tasks of target text.

[0119] 102. Preprocess the comparison text, target text, and target text classification information to obtain a text sequence.

[0120] In this embodiment, to enable a single model to complete multiple text recognition tasks for the target text, the input data of the model can be cleverly designed based on the feature processing characteristics of the model framework. Specifically, the acquired comparison text, target text, and target text classification information can be preprocessed so that the input data can be processed by the model subsequently to complete multiple text recognition tasks for the target text.

[0121] The text sequence can be a preprocessed text character sequence that conforms to the input format of the model in this application. This text sequence may contain multiple characters and / or words arranged in sequence. For example, the preprocessed text sequence may be in the format "[CLS]comparison text[SEP]target text[SEP]target text classification information". Here, "[CLS]" is a classification marker, specifically representing a classification character located at the beginning of the text sequence, used to instruct the model to output the correlation label between the comparison text and the target text in the corresponding character output position. "[SEP]" represents a separation marker, specifically a separation character used to separate the comparison text from the target text, and to separate the target text from the target text classification information, thus distinguishing different sentences in the text sequence.

[0122] For example, suppose "XX News" publishes a sports news article titled "The Decisive Moment of the Basketball Game Between Region 1 and Region 2," and a user posts an inference article in a sports forum titled "Region 1 Can Win in the Decisive Moment." Let the target text classification information be "L," where "L" instructs the model to output information representing the text category in the corresponding output character position. After preprocessing these three text pieces of information, the resulting text sequence can be represented as "[CLS]The Decisive Moment of the Basketball Game Between Region 1 and Region 2[SEP]Region 1 Can Win in the Decisive Moment[SEP]L." This is just an example; the preprocessing results for the comparison text, target text, and target text classification information for other events can be represented similarly.

[0123] Specifically, when using a single model to complete multiple text recognition tasks on a target text, these tasks are performed simultaneously. Therefore, the data involved in multiple text recognition tasks needs to be input into the same model at the same time. To meet the model's input requirements, the input data needs to be preprocessed to obtain specific data that conforms to the model's input format.

[0124] In some implementations, this preprocessing may involve splicing, word segmentation, and other processing. For example, step 102 may include:

[0125] (102.1) The comparison text, the target text, and the target text classification information are concatenated to obtain the concatenated text;

[0126] (102.2) Perform word segmentation on the concatenated text to obtain a text sequence.

[0127] Specifically, in the preprocessing of the model's input data, the first step is to concatenate the comparison text, target text, and target text classification information. This concatenation process involves sequentially linking the comparison text, target text, and target text classification information according to a specific concatenation order to form a single text dataset, i.e., the concatenated text. Next, the concatenated text undergoes word segmentation. This segmentation process can be implemented at different granularities, such as word-level or character-level segmentation, to obtain a segmented text sequence. At this point, input data conforming to the model's input format is obtained, facilitating the subsequent execution of multiple text recognition tasks on the target text using the same model.

[0128] It should be noted that when concatenating the comparison text, target text, and target text classification information, the concatenation order depends on the input format set during model training. For example, it can be concatenated in the order of "comparison text, target text, target text classification information" or "target text, comparison text, target text classification information". In addition, other specific orders can be used to concatenate the above data, which are not limited here.

[0129] It should be noted that when performing word segmentation on concatenated text, the results of word segmentation at different granularities are different. In the representation of word segmentation results, “ / ” can be used as the word segmentation symbol to indicate word segmentation between words, and the space character can also be used to indicate word segmentation.

[0130] In this context, word granularity can be understood as treating words as units of segmentation, such as using the smallest or largest word as the segmentation unit, so that segmentation is performed according to these units during the segmentation process. For example, taking a concatenated Chinese text as an example, suppose the concatenated text contains "the decisive moment of the basketball game between the first region and the second region", "the first region can win at the decisive moment", and "L". If segmentation is performed according to the smallest word granularity, the resulting text sequence will be represented as "[CLS] / first region / and / second region / of / basketball / game decisive / moment / [SEP] / first region / can / at / decisive / moment / [SEP] / L". The above is only an example and is not intended to limit the implementation of this application.

[0131] In word segmentation, "character granularity" refers to segmenting words according to the smallest character or symbol. For example, taking concatenated Chinese text as an example, suppose the concatenated text contains "the decisive moment of the basketball game between the first and second regions", "the first region can win at the decisive moment", and "L". According to character granularity segmentation, the resulting text sequence would be "[CLS] / the first / region / and / the second / region / of / the / basketball / game / decisive / moment / [SEP] / the first / region / can / win / at / the / decisive / moment / [SEP] / L". The above is only an example and is not intended to limit the implementation of this application.

[0132] Using the above methods, the acquired comparison text, target text, and target text classification information can be concatenated and segmented to obtain a text sequence that conforms to the model's input format. This allows multiple sentences to be concatenated to obtain a single, consistent input data for the model. This overall data can then be fed into the model for further processing, enabling the model to perform multiple text recognition tasks on the target text.

[0133] 103. Input the text sequence into the target model to obtain the target label sequence.

[0134] In this embodiment of the application, after preprocessing to obtain a text sequence containing overall data corresponding to multiple text recognition tasks, the text sequence can be input into the target model for processing, so as to realize the execution of multiple text recognition tasks of the target text through the same model according to the target label sequence output by the target model, which contains the label information corresponding to each text recognition task.

[0135] The target label sequence can be a sequence of multiple characters, and the labels in the sequence can be obtained by combining one or more characters to represent the recognition result corresponding to each text recognition task. For example, in this embodiment of the application, the multiple text recognition tasks for the target text are: recognizing the correlation between the target text and other texts, the main information of the target text, and the text category of the target text. Then, the target label sequence contains at least the text correlation label of the target text relative to the comparison text, the text category label, and the main information of the text.

[0136] The text association label can be a label indicating the association between the target text and the comparison text, and the label can be any form of character. For example, when outputting text association labels in the target label sequence, the target model can output the number "0" or "1" to indicate whether there is an association between the target text and the comparison text. For instance, the number "0" indicates that there is an association between the target text and the comparison text, and the number "1" indicates that there is no association. Alternatively, the target model can also output character labels indicating the degree of association. For example, outputting the character "small" indicates a low degree of association between the target text and the comparison text, outputting the character "medium" indicates a moderate degree of association, and outputting the character "large" indicates a high degree of association. Furthermore, probability values ​​representing association can also be used as text association labels. These are merely examples and are not intended to limit the specific implementation of this application.

[0137] The main text information can be entity information from the target text, specifically determined by the target model based on its semantic understanding of the target text. However, the type of entity information is not limited to people, addresses, times, events, etc. It should be noted that the type of entity information can be determined based on the semantic information in the target text. For example, if the target text is "The first region can win in the final moment," then the corresponding main text information could be "The first region." Furthermore, the type of entity information corresponding to the target text can be determined by combining the semantic information of the comparison text and the target text. For example, assuming the comparison text is "The first and second regions jointly held a knowledge debate," and the target text is "The target object in the second region can handle the debate with ease," then combining the semantic information of the comparison text and the target text, the main text information corresponding to the target text could be "The second region" or "The target object in the second region." The above are merely examples.

[0138] The text classification label can be a label representing the attribute category of the target text. Specifically, the text classification label can be any other form of character. For example, the output format of the label can be "0" or "1", "positive" or "negative", to indicate whether the target text belongs to a certain category. For instance, "1" or "positive" indicates that the target text belongs to the target category, and "0" or "negative" indicates that the target text does not belong to the target category. It should be noted that the text classification label can be any category of label, such as text sentiment category, style category, semantic category, or content category. The meaning of the label is specifically determined based on the recognition task set during the model training phase and the output. For example, if the text classification label output by the model is set to represent the semantic sentiment tendency of the sample target text during the model training phase, then the text classification label in the application phase can be a semantic sentiment category label or a text sentiment category label, used to represent the sentiment tendency of the target text. The above are merely examples and are not intended to limit the specific implementation of this application's embodiments.

[0139] In this embodiment, after preprocessing to obtain the text sequence, the text sequence can be input into the target model for processing to obtain the target label sequence output by the target model. It is understood that the target model needs to be obtained through iterative training. Specifically, the target model is obtained by comparing the output of a preset model with the sample label sequence. The sample text sequence is obtained by preprocessing the sample comparison text, the sample target text, and the sample target text classification information. The sample label sequence includes the sample association label of the sample target text relative to the sample comparison text, the sample text classification label, and the sample text body information. It should be noted that the sample comparison text, sample target text, sample target text classification information, sample association label, sample text classification label, and sample text body information all belong to the training phase data, and their explanation is similar to the description in the aforementioned application phase. For details, please refer to the description in the aforementioned application phase; this embodiment will not elaborate further.

[0140] It should be noted that for multiple text recognition tasks involving the same text, these tasks are interconnected. During the training phase, the multiple text data used to complete these interconnected tasks can be preprocessed and merged into data conforming to the model's input format, thus cleverly designing the model's input. Furthermore, by combining the processing characteristics of each layer within the model framework, the characters in the text sequence input to the model are processed synchronously. This allows the model to comprehensively consider the vector information of all characters in the text sequence, strengthening the information correlation between multiple text recognition tasks and effectively avoiding information transmission errors. In this way, the label results of each text recognition task output by the trained target model are correlated, improving the model's text recognition accuracy. Moreover, it enables a single target model to simultaneously complete multiple text recognition tasks related to the same target text, improving the model's recognition efficiency.

[0141] In the embodiments of this application, the processing of multiple text recognition tasks can be implemented through natural language processing, specifically the process of named entity recognition (NER), which can be based on text processing, semantic understanding and other technologies to recognize the target text.

[0142] In some implementations, the text sequence contains multiple characters. When processing the text sequence, the target model needs to perform semantically enhanced vector representation on each character and fuse the features of each vector representation to predict the output result corresponding to each character. Specifically, step 103 may include:

[0143] (103.1) Based on the target model, semantic enhancement representation is performed on each character in the text sequence to obtain a character vector sequence, which contains the character representation vector corresponding to each character;

[0144] (103.2) The features of each character representation vector and the character vector sequence in bidirectional propagation are fused and transformed to obtain the label score sequence corresponding to each character representation vector;

[0145] (103.3) Based on multiple label categories in each label score sequence and the label score corresponding to each label category, determine the target label path, which is used to instruct the target model to output the target label sequence.

[0146] The semantic enhancement representation can be achieved by encoding each character in the text sequence with semantic enhancement. This encoding process can be bidirectional encoding. Specifically, during the encoding process, a self-attention mechanism and a fully connected processing method can be combined to encode each character in the text sequence. This ensures that the features of other characters in the sequence are considered simultaneously during the encoding of each character, thus performing bidirectional semantic enhancement encoding on each character and obtaining the enhanced representation vector corresponding to each character, i.e., the character representation vector. It should be noted that during the encoding process, bidirectional encoding can be performed on each character in the text sequence simultaneously, which can be understood as an asynchronous process. After the semantic enhancement bidirectional encoding, the encoding result can be output in a sequential manner, i.e., a character vector sequence. This character vector sequence contains multiple character representation vectors, and each character representation vector corresponds to one character.

[0147] This bidirectional propagation involves spreading the features of each character representation vector in both directions, allowing each vector to be combined with the features of other character representation vectors to represent the semantic information of the entire sentence as a single vector matrix. Specifically, the bidirectional propagation of features for each character representation vector in the character vector sequence can proceed in both forward and backward directions. Forward propagation means spreading the features of each character representation vector to any subsequent character representation vector according to the sentence's forward-to-back understanding order. Backward propagation means spreading the features of each character representation vector to any preceding character representation vector according to the sentence's backward-to-foreign understanding order. This allows each character representation vector to be fused with its forward and backward features, further encoding it according to both forward and backward sentence understanding, thus achieving semantically enhanced representation of each character identifier vector from the perspective of sentence text semantics.

[0148] The label score sequence can contain multiple sequences of label scores. Each label score in the sequence corresponds to a label category, representing the score by which the current character is predicted to belong to a certain label category after encoding and fusion processing. This label score can also be understood as the probability that each character is predicted to belong to the corresponding label category during model processing. The higher the label score, the greater the likelihood that the current character is classified as belonging to the corresponding label category.

[0149] The target label path can consist of multiple label categories. It can be understood as a label path formed by multiple correct label categories arranged in a specific order, representing the final label path determined by the target model after processing the text sequence. Each label category in the target label path corresponds to a character at a specific position in the text sequence. It should be noted that when processing the text sequence, the target model can generate multiple different candidate label paths. The final target label path needs to be determined from these candidate paths to instruct the target model to output the target label sequence.

[0150] Specifically, to perform multiple text recognition tasks on the target text using the target model, after obtaining the text sequence, the text sequence is input into the target model for processing. First, the target model performs semantic enhancement representation on each character in the text sequence using a bidirectional encoding method, converting each character into a vector, i.e., a character representation vector. Multiple character representation vectors constitute a character vector sequence. Thus, each character can be replaced by a vector, which facilitates model processing. At the same time, the semantic features of other characters in the text sequence can be combined to enhance the vector representation of each character, improving the accuracy of the vector representation of each character. Then, the target model propagates the features of each character representation vector in the character vector sequence from front to back and from back to front, so that each character representation vector can be fused with the features of other character representation vectors. This achieves further semantic enhancement representation of each character representation vector according to the forward and backward understanding of the sentence, and the fused features are converted into a label scoring sequence. Finally, the target model combines multiple candidate label paths based on the multiple label categories and the corresponding label scores in each label scoring sequence. It then selects the target label path from these candidate paths and outputs a target label sequence containing multiple label categories. This target label sequence includes label information corresponding to each text recognition task. In this way, multiple text recognition tasks for the target text can be performed using the same model, effectively avoiding information transmission errors during text recognition and outputting valid labels, thus ensuring the accuracy of the target model in text recognition.

[0151] To facilitate understanding, the following will describe the text sequence processing process in conjunction with the architecture of the target model.

[0152] First, the framework structure of the target model will be introduced, as follows:

[0153] The target model in this application embodiment can be composed of multiple sub-models connected together. Specifically, the target model includes at least an encoding layer, a bidirectional memory network layer, and a classification layer in its framework architecture. These sub-models can be connected sequentially and trained iteratively to obtain the target model. To better understand the target model of this application, the various sub-models in the model framework are described below:

[0154] The encoding layer can be any network model used to encode characters, such as, but not limited to, models like the One-Hot Model, Bag of Words Model, Term Frequency-Inverse Document Frequency (TF-IDF), N-gram, Word2vec, and Doc2vec to encode each character in the text sequence into a character representation vector. In this embodiment, to accurately vectorize each character, the vector features of other characters in the text sequence can be considered. These vector features are then combined to semantically enhance the current character's vector representation. Therefore, the Bidirectional Encoder Representation from Transformers (BERT) model is selected as the encoding layer in the target model to perform semantically enhanced encoding processing on each character in the text sequence.

[0155] Specifically, the bidirectional memory network layer can propagate the features of each character representation vector in two directions: from front to back and from back to front. This allows each character representation vector to be fused with the features from the bidirectional propagation, and the fused feature vector is then subjected to linear classification. This achieves classification of the vector corresponding to each character by combining the semantic understanding of the entire sentence. For example, this bidirectional memory network layer can specifically be a bidirectional long short-term memory (Bi-LSTM) network layer. By learning the relationship between vectors based on the features from the forward and backward propagation, it is beneficial to encode each character representation vector through the understanding of the semantics of the entire text.

[0156] The classification layer can be a sub-model with classification capabilities within the target model framework, such as a softmax layer for logistic regression, a Label Attention Network (LAN) classification layer, or a Conditional Random Field (CRF) classification layer. In this embodiment, the classification layer can construct multiple possible label paths based on multiple label score sequences output by the bidirectional memory network layer and the label category transfer relationships between labels. It then evaluates the final target label path from these multiple paths and outputs the corresponding target label sequence based on the target label path, representing the label results for multiple text recognition tasks.

[0157] It should be noted that within the framework of the target model, the above sub-models are interconnected, specifically: encoding layer - bidirectional memory network layer - classification layer, which is applicable to label annotation in text recognition. Specifically, after inputting a text sequence into the target model, firstly, the encoding layer in the target model framework performs semantically enhanced vector representation on each character in the text sequence. Then, the bidirectional memory network layer learns the relationships between text characters according to a bidirectional propagation method. Finally, the classification layer outputs classification labels for multiple text recognition tasks. To better understand the various processing layers (sub-models) in the target model framework of this application embodiment, the feature processing procedures of each processing layer in the target model framework will be described in conjunction with the following:

[0158] (A) The encoding process of the encoding layer is described in detail below:

[0159] In some implementations, the target model includes an encoding layer. To achieve deep semantic representation of each character in the text sequence, the semantics of each character can be determined by combining the relationship between each character and its context, such as combining the positional relationship of each character in the text sequence. This allows for the creation of an enhanced semantic vector representation for each character, ensuring the accuracy of the vector representation after encoding. Specifically, step (103.1) may include:

[0160] (103.1.1) The text sequence is processed by vector embedding through the encoding layer to obtain the embedding vector sequence, which contains the embedding representation vector corresponding to each character;

[0161] (103.1.2) Based on the bidirectional features of each embedding representation vector in the embedding vector sequence, each embedding representation vector is encoded to obtain a character vector sequence with semantically enhanced representation.

[0162] Specifically, when each character is subjected to enhanced semantic encoding processing by the encoding layer, this process mainly includes two stages: (A.1) embedding processing and (A.2) encoding processing. Wherein, the encoding layer may be a bidirectional encoding layer, see Figure 3 as shown, the bidirectional encoding layer may include an embedding layer and an encoding processing layer. To better understand this encoding processing procedure, the processing procedures of the embedding processing and the encoding processing will be described below in combination with the embedding layer and the encoding processing layer respectively.

[0163] (A.1) The embedding processing for characters is specifically described as follows:

[0164] The embedding processing can be understood as performing vectorized representation on each character through a word embedding manner, so as to replace the character with a vector, realize the vector representation of each character in the initial stage, and obtain vector data in a format conforming to the model encoding processing procedure. Wherein, the embedding processing procedure is not limited to including processing manners such as token embedding, sentence segment embedding, and position embedding. Through the vector embedding processing, each character can be converted into a corresponding vector, that is, an embedding representation vector.

[0165] Wherein, the embedding representation vector can be understood as the initial vector corresponding to each character, which belongs to the initial stage when each character is represented as a vector, and is mainly used to convert each character into a vector form for representation. For example, assuming that the text sequence is "[CLS] the motherland is getting better and better [Sep] we love the motherland [Sep] L", during the embedding representation processing, each character such as "[CLS]", "Zu", "Guo", "Yue", "Lai", "Yue", "Hao", "[Sep]", "Wo"... can be converted into a vector form respectively, so as to realize the initial stage representation of each character. The embedding representation vector obtained from the embedding processing is not limited to including a token embedding vector (Token Embeddings), a segment embedding vector (Segment Embeddings) and a position embedding vector (Position Embeddings).

[0166] Specifically, in combination with Figure 4 , the embedding processing procedure is described. Assume that "hot topic" represents the comparison text, "comment text" is taken as the target text, and "L" is taken as the target text classification information, then the corresponding text sequence is "[CLS] hot topic [Sep] comment text [Sep] L". This embedding representation processing procedure is: firstly, perform token embedding processing on each character in the text sequence to obtain the token embedding vector of each character, which are respectively represented as "E [CLS] ", "E_hot", "E_topic", "E [Sep] ", "E_comment", "E_describe", "E_text", "E_body", "E [Sep] ", "E LThen, sentence segmentation and embedding are performed on each character in the text sequence. During segmentation and embedding, any character can be used to represent different sentence segments, such as using letters "A, B, C..." to distinguish them, resulting in the segment embedding vector for each character, represented as "E". A “E” A “E” A “E” A “E” B “E” B “E” B “E” B “E” B “E” C Furthermore, position embedding processing is performed on each character in the text sequence to obtain the position embedding vector of each character, represented as "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "E1", "E8", "E9", "E1", "E9", "E1", "E1", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8 ... 10 It should be noted that there is no restriction on the order of processing tag embedding, sentence fragment embedding, and positional embedding; they can be processed simultaneously. After the above embedding processes, the obtained tag embedding vector, fragment embedding vector, and positional embedding vector can be accumulated and fused to obtain a character vector sequence containing the embedding representation vector corresponding to each character. The length of each embedding representation vector can be 1*512. In this way, each character has a corresponding label, which facilitates contextual understanding between characters and between different sentence fragments based on the labeled embedding representation vectors during the encoding stage.

[0167] For example, suppose the text sequence is “[CLS]The motherland is getting better and better[Sep]We love the motherland[Sep]L”. The embedding representation process is as follows: First, perform a label embedding process on each character in the text sequence to obtain the label embedding vector of each character, represented as “E”. [CLS] “E-ancestor”, “E-country”, “E-more”, “E-come”, “E-more”, “E-good”, “E- [Sep] “E I”, “E us”, “E love”, “E motherland”, “E country” [Sep] “E” L Then, sentence segmentation and embedding are performed on each character in the text sequence. During segmentation and embedding, any character can be used to represent different sentence segments, such as using letters "A, B, C..." or Arabic numerals "0, 1, 2, 3...". Taking letter-based segmentation as an example, the segment embedding vector for each character is obtained, represented as "E". A “E” A “E” A “E” A“E” A “E” A “E” A “E” A “E” B “E” B “E” B “E” B “E” B “E” B “E” C Furthermore, position embedding processing is performed on each character in the text sequence to obtain the position embedding vector of each character, represented as "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "E1", "E8", "E9", "E1", "E9", "E1", "E1", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8 ... 10 “E” 11 “E” 12 “E” 13 “E” 14 “E” 15 The above is just an example of embedding. For other content such as comparison text, target text, and target text classification information, the above method can be used to embed each character of the corresponding text sequence.

[0168] (A.2) Encoding process stage, described in detail below:

[0169] See Figure 3 As shown, the encoding processing layer may structurally include a two-layer transformation encoder (Trm), the output of the embedding layer is fully connected to the input of each transformation encoder "Trm" in the first layer, and the output of each transformation encoder "Trm" in the first layer is fully connected to the input of each transformation encoder "Trm" in the second layer.

[0170] Therefore, after embedding each character in the text sequence into an embedding representation in the embedding layer, the encoding process is as follows: based on the fully connected relationship between the output of the embedding layer and each transformation encoder in the first layer, each embedding representation vector is transmitted to each transformation encoder in the first layer for encoding processing; then, based on the fully connected relationship between the output of each transformation encoder in the first layer and the input of each transformation encoder in the second layer, the encoding vector output by each transformation encoder in the first layer is input to each transformation encoder in the second layer for encoding processing; thus, each transformation encoder, based on self-attention and fully connected relationships, considers the context when encoding the corresponding embedding representation vector to capture the long-distance dependencies between different vectors, obtaining a character representation vector with deep semantic representation, where the length of each character representation vector can be 1*512.

[0171] Thus, the encoding of each character is achieved by combining the context of each character, completing the vector representation of each character in the text sequence with enhanced semantics.

[0172] (B) The feature processing procedure of the bidirectional memory network layer is described in detail below:

[0173] In some implementations, the target model further includes a bidirectional memory network layer connected to the encoding layer. This bidirectional memory network layer can learn vector relationships based on the bidirectional propagation features of each character vector sequence, thereby achieving a bidirectional understanding of text semantics and performing linear classification of each character representation vector based on text semantics. Specifically, step (103.2) may include:

[0174] (103.2.1) By performing forward propagation on each character representation vector in the character vector sequence through a bidirectional memory network layer, the context features corresponding to each character representation vector are obtained;

[0175] (103.2.2) Perform backpropagation on each character representation vector in the character vector sequence to obtain the context features corresponding to each character representation vector;

[0176] (103.2.3) Fuse each character representation vector with the corresponding preceding context feature and the corresponding following context feature to obtain the fused feature corresponding to each character representation vector;

[0177] (103.2.4) Perform a linear transformation on the fused features to obtain the label score sequence corresponding to each character representation vector.

[0178] To better understand the bidirectional memory network layer, we first combine... Figure 5 The structure of this bidirectional memory network layer is described. For example... Figure 5As shown, this Bi-LSTM network layer mainly consists of two Long Short Term Memory (LSTM) layers. The feature propagation directions between the LSTM layers differ. For example, the first LSTM layer propagates feature vectors from front to back of the sentence text, while the second LSTM layer propagates them from back to front. This allows each character representation vector to be encoded using both front-to-back and back-to-front features. These two encoded feature vectors are then fused to obtain a fused feature, which can be considered an enhanced representation vector for each character representation vector in conjunction with full-text features for semantic understanding. This achieves further enhancement of each character representation vector based on semantic understanding from both directions of the sentence.

[0179] Forward propagation refers to processing each character representation vector in the forward order of the character vector sequence. Specifically, it involves processing each character representation vector in the character vector sequence from front to back, and propagating the resulting feature state to the next character representation vector processing step. This ensures that the contextual features propagated from the forward propagation are obtained for each character representation vector. For example, suppose the character vector sequence obtained after encoding is "E1 / E2 / E3 / E4 / E5 / E6 / E7 / E8 / E9 / E 10 / E 11 / E 12 / E 13 / E 14 / E 15 Following a front-to-back propagation approach, the features obtained from processing "E1" become the context features of "E2". When processing "E2", these features are combined with the context features passed from processing "E1" and fused. The resulting target feature becomes the context feature for processing "E3". In other words, the context features of "E3" contain all or part of the features from "E1" and "E2", the context features of "E4" contain all or part of the features from "E1", "E2", and "E3", and so on, until the first layer of the Long Short-Term Memory network combines the features from "E1" and "E2". 15 The features above “E” 15 "Processing complete."

[0180] Backpropagation specifically refers to processing each character representation vector and propagating its features in reverse order of the character vector sequence. Specifically, it involves processing each character representation vector in the character vector sequence from back to front, and then propagating the resulting features to the next character representation vector in the sequence. This ensures that each character representation vector receives the backpropagated features. For example, suppose the character vector sequence obtained after encoding is "E1 / E2 / E3 / E4 / E5 / E6 / E7 / E8 / E9 / E 10 / E 11 / E 12 / E 13 / E 14 / E 15 According to the back-to-front propagation method, "E" 15 The features obtained from the processing are used as "E" 14 The following features of “E”, and in processing “E” 14 "Time combined processing" E 15 The features transmitted in real time are fused together, and the resulting target features are used for processing "E". 13 The following text features of "E" can be understood as follows: 13 The following features include "E" 15 "and "E 14 "All or part of the characteristics of "E" 12 The following features include "E" 15 “E” 14 "and "E 13 The features of “E1” are processed in whole or in part, and so on, until the second layer of the long short-term memory network has finished processing “E1” in combination with the features of the following text.

[0181] Furthermore, to better understand the feature processing and bidirectional propagation process of the bidirectional memory network layer, this application will describe the processing process of a Long Short-Term Memory (LSM) network with "forward propagation" as an example. Specifically, this LSM network has the abilities of forgetting, remembering, and updating, which is mainly achieved through the various gate structures within the LSM network. A gate structure typically contains σ (Sigmod) neurons. For example, see... Figure 6 As shown, the Long Short-Term Memory (LSTM) network includes at least a forget gate Ft, a memory gate It, and an output gate Ot. In addition, the parameters involved include the hidden output ht-1 and cell state Ct-1 of the previous time sequence, as well as the input Xt and cell state Ct of the current time sequence. The input Xt represents the character representation vector input in the current time sequence, and the cell state Ct-1 records the contextual features of the forward propagation. The hidden output ht-1 can also be regarded as contextual features.

[0182] Specifically, the forgetting gate Ft contains σ (Sigmod) units. The forgetting gate calculates weights based on the input character representation vector Xt and the hidden output ht-1 from the previous time step, and then normalizes the result through a Sigmod neuron, yielding a result Ft with values ​​between (0, 1). This result Ft is then multiplied by the cell state Ct-1 from the previous time step to achieve fusion, thus forgetting unwanted information. The weight calculation based on the input character representation vector Xt and the hidden output ht-1 from the previous time step is as follows: F t =σ(W f ·[h t-1 X t ]+b f ), where W f The weight matrix parameters of the forget gate, b f This represents the bias parameter of the forget gate.

[0183] Specifically, the memory gate contains σ (Sigmod) units and tanh units, used to determine how many features of the character representation vector input at the current time step need to be stored in the cell state Ct at the current time step. Specifically, the memory gate calculates weights based on the character representation vector Xt input at this time step and the hidden output ht-1 from the previous time step, and then normalizes the weights through the σ unit to obtain a result I with values ​​between (0, 1). t To represent the feature information that needs to be updated using memory, the calculation process is as follows:

[0184] I t =σ(W i ·[h t-1 X t ]+b i )

[0185] Among them, W i b represents the parameters of the weight matrix. i This represents the bias parameter.

[0186] Furthermore, the memory gate performs weight calculations based on the character representation vector Xt input at this time step and the hidden output ht-1 from the previous time step, and then performs normalization processing through tanh units to obtain results with values ​​between (-1, 1). The memory information representing the candidates can be understood as temporary cell states. The weight calculation process is as follows:

[0187]

[0188] W C The weight matrix parameters of the memory gate, b CThis represents the bias parameters of the memory gate.

[0189] Furthermore, the candidate memory information With the feature information I that needs to be updated in memory t Multiplication is performed to fuse the two, yielding the final information that the memory gate needs to remember in the current time sequence. Then, based on this final information, the cell state Ct-1 from the previous time sequence, and the forgetting information F... t The cell state Ct at the current time series is determined. The specific calculation process is as follows:

[0190]

[0191] It should be noted that the F output of this forget gate t Multiplying by the cell state Ct-1 from the previous time step indicates the portion of the contextual features passed in from the previous time step that needs to be forgotten. The memory gate output I... t Memory information of the current candidate Multiplication indicates that the memory gate needs to remember the feature information of the cell state at the current time sequence. Thus, the forgetting of information in the cell state and the memorization of new information enable the transfer of information useful for calculation in subsequent time steps, while useless information is discarded, resulting in the cell state Ct at the current time sequence.

[0192] Specifically, the output gate includes a σ (Sigmod) unit, a tanh unit, and a fusion unit, used to determine the hidden output result in the current time series. The output gate calculates weights based on the character representation vector Xt input in this time series and the hidden output ht-1 from the previous time series, and then normalizes the result O through the σ unit to obtain a value between (0, 1). t The result was O t This represents the cell state features that need to be output in the current time series. The calculation process is as follows:

[0193]

[0194] W O b represents the weight matrix parameters of the output gate. O This represents the bias parameter of the output gate.

[0195] Furthermore, the output gate undergoes a nonlinear transformation using the tanh function based on the current cell state Ct, and the result of this nonlinear transformation is compared with the cell state feature O output at the current time step. t Multiply and fuse the results to obtain the hidden output ht at the current time step. ht is the feature vector after the cell state Ct has decayed. Furthermore, ht also serves as the input to the hidden state at the next time step. The specific calculation process is as follows: h t =Ot ·tanh(C t ).

[0196] Thus, the forward propagation process of the first layer of the bidirectional memory network has been described. The backward propagation process of the second layer of the long short-term memory network is the same as the forward propagation process, differing only in the direction of the input character representation vectors. Specifically, each character representation vector is processed from back to front in reverse order of the character vector sequence as input. This embodiment will not elaborate on the backward propagation process; please refer to the aforementioned processing procedure for the second layer of the long short-term memory network.

[0197] It should be noted that the contextual features are relative to each character representation vector; that is, different character representation vectors have different contextual features, which can include cell state features and hidden output features propagated from the previous time step. Similarly, different character representation vectors have different contextual features, which include cell state features and hidden output features propagated from the previous time step.

[0198] Based on the detailed description of the forward propagation process above, step (103.2.3) "fusing each character representation vector with its corresponding contextual features and contextual features to obtain the fused features corresponding to each character representation vector" can include: performing feature learning on the character representation vector based on the contextual features corresponding to each character representation vector to obtain the forward hidden output features corresponding to each character representation vector; performing feature learning on the character representation vector based on the contextual features corresponding to each character representation vector to obtain the backward hidden output features corresponding to each character representation vector; and then fusing the forward hidden output features and backward hidden output features of each character representation vector to obtain the fused features.

[0199] Furthermore, the fusion features corresponding to each character representation vector are linearly processed. This linear processing can be performed by the σ (Sigmod) unit of the linear processing layer in the bidirectional memory network layer to obtain a label score sequence. This label score sequence can be understood as a 1*5 matrix, which contains the label category of the corresponding character and the label score belonging to each label category.

[0200] (C) The classification layer can be a conditional random field classification layer, and its processing procedure is as follows:

[0201] In some implementations, the target model further includes a classification layer connected to the bidirectional memory network layer. This classification layer can construct multiple candidate label paths based on each label score sequence, and select the highest-scoring candidate label path as the target label path, thereby instructing the target model to output the corresponding target label sequence. Specifically, step (103.3) may include:

[0202] (103.3.1) By classifying the characters of the text sequence according to the character sorting relationship, any selected label category in each label scoring sequence is combined to obtain multiple candidate label paths, and each candidate label path contains the label category of each character;

[0203] (103.3.2) Based on multiple label categories in each label scoring sequence and the label score corresponding to each label category, determine the label score of each label category indicated in each candidate label path;

[0204] (103.3.3) Calculate the path score of the corresponding candidate label path based on the label score of each label category indicated in each candidate label path and the category transfer relationship between adjacent label categories;

[0205] (103.3.4) Determine the target label path from multiple candidate label paths based on the path score.

[0206] The character sorting relationship can be the order of characters in a text sequence, used to limit the order of labels for each character when constructing candidate label paths in the classification layer. Specifically, a candidate label path consists of label categories for multiple characters, where each character's label category can be any label category in the corresponding label scoring sequence, and the ordering relationship between the label categories in the candidate label path is determined by the character sorting relationship.

[0207] The path score can be the score of the corresponding candidate label path, used to evaluate whether the current candidate label path is the correct label path. It can be understood that the higher the path score of the candidate label path, the greater the probability that the path is the correct label path.

[0208] To improve the accuracy of the target model in outputting the label results for each text recognition task, after obtaining the label score sequence corresponding to each character representation vector, different candidate label paths can be constructed based on the label categories contained in each label score sequence, so as to select the target label path from the candidate label paths.

[0209] Specifically, the process of constructing candidate label paths is as follows: First, determine the ordering relationship between label categories when constructing the candidate label path. Since each label category in the candidate label path corresponds to a character, the ordering relationship between the label categories in the candidate label path can be determined based on the character ordering relationship in the text sequence. Then, select one label category from each label scoring sequence and sort the selected label categories according to the ordering relationship to obtain the corresponding candidate label path. In this way, multiple candidate label paths can be obtained by following the above process. It should be noted that during the construction of candidate label paths, the trained classification layer learns some constraints. These constraints can be the transition relationships between the label categories in the label path, specifically used to constrain the pairing between adjacent label categories. This can be used to restrict the classification layer from selecting label categories from each label scoring sequence, so that the constructed candidate label paths meet the constraints, reducing the amount of data computation during model processing.

[0210] To select the optimal tag path from multiple candidate tag paths, a path score ranking method can be used. Therefore, it's necessary to calculate the path score for each candidate tag path. Specifically, when calculating the path score for each candidate tag path, the tag score for each tag category within the current candidate tag path can be determined first. This tag score can be based on the score of that tag category in the tag score sequence of the corresponding character. Furthermore, the transition relationship between any two adjacent tag categories within the candidate tag path is considered to calculate the path score for the current candidate tag path. Then, based on the ranking of the path scores for each candidate tag path, the path with the highest score can be selected as the target tag path, thus achieving the selection of the optimal tag path from multiple candidate tag paths.

[0211] In some implementations, the path score for each candidate label path is primarily calculated based on the label state score and label transition score of the candidate label path. Specifically, step (103.3.3) may include: calculating the label state score corresponding to each candidate label path based on the label scores in each label score sequence; determining the label transition score based on the state transition relationship between multiple label categories in each candidate label path; and calculating the path score based on the label state score and label transition score corresponding to each candidate label path.

[0212] The tag status score can be the status score when each tag category is included in the corresponding candidate tag path. Specifically, when calculating the tag status score for each candidate tag path, the character corresponding to each tag category indicated in the current candidate tag path can be determined first. Then, the tag score of each tag category in the tag score sequence of the corresponding character can be queried. In this way, the tag score of each tag category indicated in the current candidate tag path can be determined. Finally, the tag scores of each tag category indicated in the candidate tag path are added together to obtain the tag status score of the current candidate tag path.

[0213] The label transition score can be the state transition score between various label categories in the candidate label path. The label transition score can be obtained by adding the state transition scores between any two adjacent label categories in the candidate label path. For example, determine the state transition score for the transition from one label category to another in the candidate label path, and add each state transition score to obtain the label transition score of the candidate label path. This label transition score represents the category transition value between any two adjacent label categories in the current candidate label path.

[0214] Furthermore, after determining the label state score and label transition score for each candidate label path, the label state score and label transition score can be summed to obtain the path score of the current candidate label path. Additionally, after summing the label state score and label transition score, a logarithmic function can be applied to the summation result to obtain the path score of the current candidate label path. This allows the candidate label path with the highest path score to be selected as the target label path, instructing the target model to output the corresponding target label sequence.

[0215] By using the above method, the preprocessed text sequence can be input into the target model, enabling the target model to perform deep semantic learning representation on each character in the text sequence. Then, the semantics of each character is understood in two directions: from front to back and from back to front. The valuable feature information is then fused and updated with the representation vector of each character, and a label scoring sequence for each character is obtained based on linear processing. Finally, based on multiple label scoring sequences, the final target label path is determined to instruct the target model to output the label result corresponding to each text recognition task. In this way, multiple text recognition tasks can be executed within the same target model framework, effectively avoiding errors in information transmission and improving the accuracy of text recognition.

[0216] To better understand the processing procedure of the target model in the embodiments of this application, combined with Figure 7 The processing flow of the target model is described in detail below:

[0217] For example, using trending events as comparison text, such as "hot topic" as comparison text, and commentary text of "hot topic events" as target text, and using relevant characters set during the training phase (let's say "L") as target text classification information, the resulting text sequence after preprocessing is "[CLS]hot topic [SEP]commentary text [SEP]L". Then, the text sequence "[CLS]hot topic [SEP]commentary text [SEP]L" is input into the target model, which includes a bidirectional encoding layer, a bidirectional memory network layer, and a classification layer. It should be noted that in the example, "hot topic" and "commentary text" refer to trending events and commentary events, respectively. In practical applications, the comparison text and target text can be set according to actual needs. For example, they could be the actual titles or other text content corresponding to a specific trending event and commentary text; this is not limited here.

[0218] The embedding layer in the bidirectional coding layer performs embedding representation processing on each character in the text sequence, obtaining an embedding representation vector corresponding to each character. The dimension of this embedding representation vector is 1*512, as shown in the diagram E1, E2, E3...E N Each embedding representation vector has a dimension of 1*512. These embedding representation vectors are bidirectionally encoded using a transformation encoder (Trm) in a two-layer coding layer. This allows for deep semantic representation by combining the positional relationships of each embedding representation vector within the sequence, resulting in a character representation vector of size 1*512, as shown in the diagram (T1, T2, T3...T). N Each of these represents a character representation vector with a dimension of 1*512.

[0219] In this bidirectional memory network layer, the first layer of the Long Short-Term Memory (LSTM) network processes each character representation vector and propagates the features from front to back. The second layer of the LSTM network processes each character representation vector and propagates the features from back to front. The processing results of each character representation vector from the first and second layers of the LSTM network are fused together, and the fused features are linearly processed by the Sigmoid layer to obtain the label score sequence corresponding to each character. The dimension of each label score sequence is 1*5, and each label score sequence contains the label scores of five labels: B-cor, B-com, I-com, O, and B-emo.

[0220] The classification layer can be a Conditional Random Field (CRF) classification layer. This layer can construct multiple candidate label paths based on the multiple label categories contained in each label scoring sequence and the label scores corresponding to each label category. It then selects the target label path with the highest score from these candidate paths. This target label path contains the target label category corresponding to each character, as shown in the diagram as C1, C2, C3...C... N These represent the target label categories for the target label path. Finally, based on the indication of the target label path, the corresponding target label sequence is output, such as... Figure 7 As shown, the target label sequence includes "B-cor, O, O, O, B-com, I-com, O, O, O, B-emo" in sequence.

[0221] Among them, B-cor is the [CLS] character output, which is a label indicating the association between the commentary text and the hot topic. It is used to indicate whether there is a relationship between the commentary text and the hot topic event. For example, when B-cor is B-cor1, it can be indicated that there is a relationship between the commentary text and the hot topic event, and when B-cor is B-cor0, it can be indicated that there is no relationship between the commentary text and the hot topic event.

[0222] Among them, B-com and I-com are the tag sequences of text body information output by the character positions of the comment text, which are used to represent the body information of the comment text, specifically the name, such as the name of an entity, person, or group.

[0223] Wherein, O refers to a non-entity label, whose output may be unrelated to the multiple text recognition tasks in this application embodiment and has no actual referential meaning.

[0224] Here, B-emo is the text classification information output by the character position of the target text classification information. Taking the analysis of text semantic sentiment as an example, B-emo can represent the semantic sentiment classification label of the commentary text. For example, when B-emo is B-emo1, it can be represented that the semantic sentiment category of the commentary text is positive, and when B-emo is B-emo0, it can be represented that the semantic sentiment category of the commentary text is negative.

[0225] The above are merely examples and are not intended to limit the specific implementation of the embodiments of this application.

[0226] As can be seen from the above, the embodiments of this application can obtain comparison text, target text, and target text classification information; preprocess the comparison text, target text, and target text classification information to obtain a text sequence; input the text sequence into the target model to obtain a target label sequence, the target label sequence containing at least the text association label, text classification label, and text body information of the target text relative to the comparison text; wherein, the target model is obtained by training a preset model based on the output result of the sample text sequence and the sample label sequence, the sample text sequence is obtained by preprocessing the sample comparison text, sample target text, and sample target text classification information, and the sample label sequence includes the sample association label, sample text classification label, and sample text body information of the sample target text relative to the sample comparison text. Therefore, this scheme, after obtaining the comparison text, target text, and target text classification information, preprocesses the text sequence to serve as the input to the target model. Combining the feature processing characteristics of each processing layer in the target model framework, the characters in the input text sequence are processed synchronously. This allows the model to comprehensively consider the vector information of all characters in the text sequence, strengthening the information correlation between multiple text recognition tasks. Furthermore, after processing the text sequence, the scheme outputs recognition result labels for multiple text tasks, including the text body information and text classification label of the target text, as well as the text association label between the target text and the comparison text. Thus, a single model can simultaneously execute multiple recognition tasks related to the same text, effectively avoiding information transmission errors and improving the model's accuracy and efficiency when performing multiple recognition tasks on the same text, thereby enhancing the user's experience in obtaining text information.

[0227] Regarding the text recognition method provided in this application, the text recognition process can be implemented in conjunction with a relevant trained target model. In this regard, embodiments of this application also provide a training method for the aforementioned target model, described from the perspective of a model training device integrated into a computer device such as a server. Figure 8 The diagram shown is a flowchart illustrating the steps of the model training method provided in this embodiment. When the processor on the computer device executes the program corresponding to the model training method, the specific process of the model training method is as follows:

[0228] 201. Obtain the sample comparison text, sample target text, and sample target text classification information.

[0229] The target text can be a textual description of the target event to be identified, representing the semantic information of the target event. The target text can be understood as the basic text corresponding to the target text recognition task.

[0230] The sample comparison text can be text containing a textual description of the sample event, which represents the semantic information of the sample event, in order to identify whether the event content of the sample target text is semantically related.

[0231] The target text classification information can be information used to indicate the category label of the output target text. This target text classification information can be in any form; for example, it can be character-based information, including letters, numbers, symbols, labels, and other characters, or it can be information obtained by combining multiple character types. For instance, the letter "L" can be used as the target text classification information, or the "%" symbol can be used as the target text classification information. These are merely examples and do not constitute a specific limitation on the implementation of this application.

[0232] For example, taking the title of a hot news event as a sample event, the title of the hot news event can be used as the sample comparison text; taking the commentary text or non-commentary text of the hot news event as the sample target event, the title, a sentence or the whole text of the commentary text or non-commentary text can be used as the sample target text; in addition, any form of character can be used as the sample target text classification information, such as the letter "L" or the symbol "%" as the sample target text classification information.

[0233] 202. The sample text sequence is obtained by preprocessing the sample comparison text, sample target text, and sample target text classification information.

[0234] In this embodiment, to enable a single model to complete multiple text recognition tasks for the target text, the input data of the model can be cleverly designed during the training phase based on the feature processing characteristics of the model framework. Specifically, the sample comparison text, the sample target text, and the sample target text classification information are preprocessed to obtain a sample text sequence.

[0235] The preprocessing process can include concatenation and word segmentation. Specifically, firstly, the comparison text, target text, and target text classification information can be concatenated. This concatenation refers to sequentially piecing together the text according to a specific order, such as concatenating the comparison text, target text, and target text classification information in that order. Next, the concatenated text is segmented. This segmentation can be done at the character level, meaning segmentation is performed based on the smallest possible character or symbol. After concatenation and word segmentation, a sample text sequence is obtained.

[0236] For example, let "hotspot" refer to any sample event, i.e., the sample comparison text, and "commentary text" refer to any sample target event, i.e., the sample target text. Let "L" represent the sample target text classification information. Then, the preprocessed sample text sequence is "[CLS] / hotspot / [SEP] / commentary / text / [SEP] / L". Thus, the training data for the preset model input during the training phase is obtained.

[0237] It should be noted that the above are merely general examples. For specific sample text sequences, the specific criteria can be determined based on the actual event situation. For instance, the title of a "hot topic event" can be used as the comparison text to replace "hot topic" in the text sequence, and the title or any content of the text to be identified can be used as the target text to replace "commentary text." The target text classification information "L" can remain unchanged. In subsequent application phases, the settings for comparison text, target text, and target text classification information are the same as those for the training data input during the training phase. The setting of the target text classification information can remain consistent with the "L" set during the training phase, and will not be elaborated further.

[0238] In this embodiment, after obtaining the sample text sequence input to the preset model, each character in the sample text sequence can be labeled to obtain the corresponding sample label sequence. For example, assuming the sample text sequence is “[CLS] / hot / point / [SEP] / review / text / [SEP] / L”, after labeling, the sample label sequence is “B-cor、O、O、O、B-com、I-com、O、O、O、B-emo”; this can be used as an indicator in the model training phase to instruct the model to iteratively train according to the indicator direction.

[0239] It should be noted that "B-cor1" and "B-cor0" can be used to represent the "association" or "lack of association" between the sample comparison text and the sample target text, respectively, and "B-emo1" and "B-emo0" can be used to represent the "positive" or "negative" label of the sample target text, respectively. Therefore, in the data preparation phase of training, multiple training data sets can be set according to training needs. Each training data set includes a sequence of sample texts and a corresponding sequence of sample labels. The specific sample label sequence can be set according to the actual situation of the sample comparison texts and sample target texts. For example, the sample label sequence is not limited to including: "B-cor1, O, O, O, B-com, I-com, O, O, O, B-emo1", "B-cor0, O, O, O, B-com, I-com, O, O, O, B-emo1", "B-cor1, O, O, O, B-com, I-com, O, O, O, B-emo0", "B-cor0, O, O, O, B-com, I-com, O, O, O, B-emo0". By training different sample text sequences in combination with one of the corresponding sample label sequences, the model can output "B-cor1" or "B-cor0" in the character output position corresponding to "[CLS]" to indicate whether the comparison text and the target text are "related" or "not related", and output "B-emo1" or "B-emo0" in the character output position corresponding to "L" to indicate the text classification information of the target text, such as the semantic sentiment category label of "positive" or "negative" in the semantic sentiment tendency classification.

[0240] 203. Input the sample text sequence into the preset model and obtain multiple candidate label paths generated by the preset model when processing the sample text sequence.

[0241] In this embodiment, the processing of multiple text recognition tasks can be implemented through natural language processing, specifically through Named Entity Recognition (NER). This process can be based on text processing, semantic understanding, and other technologies to recognize the target text. Therefore, during the training phase, the pre-built model framework can include an encoding layer, a bidirectional memory network layer, and a classification layer.

[0242] The encoding layer can be a bidirectional encoding model (BERT) used to perform deep semantic learning on each character in the text sequence. Specifically, the bidirectional encoding model can combine the relationship between each character and the context to determine its semantics. For example, it can combine the positional relationship of each character in the context to generate a vector representation of each character with enhanced semantics, ensuring the accuracy of the vector representation of each character after encoding.

[0243] The bidirectional long short-term memory (Bi-LSTM) network layer consists of two layers: a forward-to-backward propagation Bi-LSTM layer and a backward-to-foreign propagation Bi-LSTM layer. Specifically, the forward-to-backward propagation Bi-LSTM layer propagates features along the text from front to back. When processing each character representation vector, it incorporates the preceding context features, which may include forgetting or updating features. This allows for the representation of the current character representation vector by combining the forward-propagated features. Similarly, the backward-to-foreign propagation Bi-LSTM layer propagates features along the text from back to front. When processing each character representation vector, it incorporates the following context features, which may also include forgetting or updating features. This allows for the representation of the current character representation vector by combining the backward-propagated features. Furthermore, the features obtained from the forward and backward propagation processes corresponding to each character representation vector are fused. This fusion process can be additive to obtain fused features. Finally, the fused features are linearly processed by a linear processing layer in the bidirectional memory network layer to obtain the sample label score sequence corresponding to each character representation vector.

[0244] It should be noted that each sample label scoring sequence can contain multiple label categories, such as B-cor, B-com, I-com, O, and B-emo. Each sample label scoring sequence contains the label score for each label category. B-cor is the label output at the [CLS] character position, representing the association between the commentary text and the hot topic. This B-cor association label can be further subdivided into "B-cor1" and "B-cor0" to represent association and non-association, respectively. B-com and I-com are the label sequences of the sample text body information output at the character positions of the commentary text. Specifically, they represent sample text body information consisting of two characters. B-com represents the first character label of the sample text body information, and I-com represents the second character label. For sample text body information consisting of multiple characters, a corresponding number of I-com labels can be output. O refers to a non-entity class label, whose output is irrelevant to the multiple text recognition tasks in this application embodiment and has no actual referential meaning. Here, B-emo represents the text classification information output by the character bits of the target text classification information. Taking the analysis of text semantic sentiment as an example, B-emo can represent the semantic sentiment classification label of the commentary text. For this B-emo label, it can be further subdivided into "B-emo1" and "B-emo0" labels to represent the positive and negative sentiment semantics, respectively. Any of the above labels can be labeled on the sample text sequence during the training phase and learned through model training.

[0245] The classification layer can be a Conditional Random Field (CRF) classification layer, which constructs candidate label paths for each sample based on any label category in the label scoring sequence. It's important to note that the CRF can learn constraints regarding label category transitions, which are used to constrain the relationships between adjacent label categories when constructing the candidate label path for each sample. For example, the first label category in the constructed candidate label path cannot be "I-com", "I-com" can only follow "B-com", "I-com" cannot be paired with "B-cor" or "B-emo", and so on.

[0246] To facilitate understanding of the classification layer's processing, we will use the Conditional Random Field (CRF) classification layer as an example to describe its process. Specifically, the CRF classification layer can construct candidate label paths for each sample based on any label category in the label scoring sequence, combined with constraints, resulting in multiple predicted candidate label paths. For example, using “[CLS] / Hot / Points / [SEP] / Comment / Text / [SEP] / L” as the sample text sequence, the multiple sample candidate label paths can be: “O, B-cor, O, O, O, B-com, I-com, O, O, B-emo”, “B-cor, O, O, O, O, B-com, I-com, O, O, B-emo”, “B-cor, O, O, O, B-com, I-com, O, O, O, O”, “O, O, O, O, B-com, I-com, O, O, O, B-emo”, “B-cor, O, O, O, B-com, I-com, O, O, O, B-emo”, etc. The above only lists a portion of the predicted candidate label sequences; other predicted candidate label sequences that meet the constraints can also be included, but they are not listed here.

[0247] In this embodiment of the application, after inputting the sample text sequence into the preset model, multiple candidate label paths generated by the preset model when processing the sample text sequence can be obtained, so that the target candidate label path can be selected from the multiple predicted candidate label paths to indicate the output of the preset model.

[0248] 204. Obtain the sample label sequence, and select the target candidate label path from multiple candidate label paths according to the sample label sequence to output the target predicted label sequence.

[0249] Specifically, obtaining the sample label sequence involves obtaining a pre-defined sample label sequence for the sample text sequence. The sample label sequence is obtained by labeling each character in the sample text sequence.

[0250] In this embodiment, since the preset model generates multiple candidate label paths when processing sample text sequences (specifically, the classification layer in the preset model may generate multiple candidate label paths, but the preset model will ultimately only output the label sequence corresponding to one of these candidate label paths), the output of the preset model can be instructed based on this sample label sequence during the training phase. Specifically, based on this sample label sequence, the preset model can be instructed to select a target candidate label path from the multiple candidate label paths and output the corresponding target predicted label sequence according to this target candidate label path. This allows for the subsequent construction of a target loss function based on the target predicted label sequence, enabling iterative training of the preset model.

[0251] 205. Construct a target loss function based on the proportion of path scores of the target predicted label sequence, and iteratively train the preset model based on the target loss function until convergence, to obtain the trained target model.

[0252] In this embodiment, since the preset model generates multiple candidate label paths when processing sample text sequences, specifically, the classification layer in the preset model may generate multiple candidate label paths. The model generally needs to make a judgment and select one of the candidate label paths to indicate the model's output based on the judgment result. Therefore, to ensure that the model can accurately select the candidate label path to indicate the output, after instructing the preset model to output the target predicted label sequence based on the sample label sequence, a target loss function can be constructed based on the target predicted label sequence. This allows the preset model to be iteratively trained by minimizing the target loss function until convergence, thus obtaining the trained target model.

[0253] It should be noted that the preset model in this embodiment can calculate a path score for each candidate label path through a classification layer. The preset model can select a candidate label path based on the path score to indicate the model's output. Therefore, after instructing the preset model to output a target predicted label sequence based on the sample label sequence, in order for the preset model to select the target candidate label path corresponding to the target predicted label sequence based on the path score, a target loss function can be constructed based on the proportion of the path scores of the target candidate label paths corresponding to the target predicted label sequence. This allows for iterative training of the preset model based on the target loss function, maximizing the path score of the target candidate label path among multiple candidate label paths, or maximizing the proportion of the path score of the target candidate label path relative to the total score of other candidate label paths. This ensures that the preset model can accurately output the target predicted label sequence during the training phase, leading to model training convergence and the acquisition of the target model. Subsequently, in the application phase, the target model can be used to perform multiple text recognition tasks targeting the target text.

[0254] In some implementations, the candidate path score for each candidate label path can be calculated first. After determining the total candidate path score for multiple candidate label paths, the target path score for the target candidate label path corresponding to the target predicted label sequence can be determined. Then, the target loss function is constructed based on the ratio between the target path score and the total candidate path score. Specifically, the construction process of the target loss function can be as follows: determine the predicted label state score and predicted label transition score for each candidate label path, and calculate the candidate path score for the corresponding candidate label path based on the predicted label state score and predicted label transition score; determine the total candidate path score corresponding to multiple candidate path scores, and query the target path score corresponding to the target predicted label sequence from the multiple candidate path scores; construct the target loss function based on the weight ratio between the target path score and the total predicted candidate path score.

[0255] In some implementations, to construct the target loss function, it is necessary to first calculate the predicted label state score and predicted label transition score for each candidate label path. This calculation process may specifically include: obtaining a sequence of predicted label scores for each character in a sample text sequence processed by a preset model; the predicted label score sequence includes multiple predicted label categories and a corresponding predicted category score for each predicted label category; determining the target predicted label category for each character in each candidate label path, and calculating the predicted label state score for the corresponding candidate label path based on the predicted category score for each target predicted label category; determining the category transition score between any two adjacent target predicted label categories in each candidate label path, and calculating the predicted label transition score for the corresponding candidate label path based on multiple category transition scores.

[0256] For example, suppose there are N candidate label paths, with P i The candidate path score for each candidate tag path can be calculated using a logarithmic function, specifically as follows: P i =e Si .

[0257] Where Si represents the predicted label state score S of the i-th candidate label path. Emission And predicted label transfer score S Transition The sum of all candidate path scores, i.e., the candidate path score of the i-th candidate label path, is calculated as follows: Si = S Emission +S Transition .

[0258] For example, taking one of the candidate label paths "B-cor, O, O, O, B-com, I-com, O, O, O, B-emo" as an example, in order to make the matrix for calculating the predicted label transition score more powerful, START and END can be added to the beginning and end of the label path respectively. START is the beginning of the label path, not the first label, and END indicates the end of the label path.

[0259] The predicted label status score refers to the sum of label scores for multiple label categories in the corresponding candidate label path. The calculation process for this predicted label status score is as follows:

[0260] S Emission =x 0,START +x 1,B-cor +x 2,O +x 3,O +x 4,O +x 5,B-com +x 6,I-com +x 7,O +x 8,O +x 9,O +x 10,B-emo +x 11,END

[0261] The predicted label transition score refers to the overall label state transition score when any two adjacent labels in the corresponding candidate label path transition from one label category to the next. The calculation process for this predicted label transition score is as follows:

[0262] S Transition =T START→B-cor +T B-cor→O +T O→O +T O→O +T O→B-com +T B-com→I-com +T I-com→O +T O→O +T O→O +T O→B-emo +T B-em→END

[0263] Therefore, following the above calculation process, the candidate path score P for each candidate label path can be calculated. i .

[0264] Furthermore, based on the candidate path score for each candidate tag path, the total candidate path score is calculated. The calculation process for this total candidate path score is as follows:

[0265] P total =e S1 +e S2 +e S3 +......+e SN

[0266] Finally, the target candidate label path corresponding to the target predicted label sequence is taken as the true path, and P is used as the ground truth path. real The target loss function, representing the score of the true path, is expressed as follows:

[0267]

[0268] At this point, the target loss function is complete. Based on this target loss function, the network parameters of the preset model can be adjusted and iterative training can be performed until the preset conditions are met. For example, the predicted label sequence output by the preset model is the same as the sample label sequence, or the number of iterations reaches a certain number, or the score weight of the true path determined by the target loss function no longer changes. At this point, the training can be considered to have converged, and the trained target model is obtained.

[0269] As can be seen from the above, the embodiments of this application can obtain data such as sample comparison text, sample target text, and sample target text classification information, and concatenate the above data to obtain a sample text sequence. In addition, each character in the sample text sequence is labeled to obtain a sample label sequence. Then, the sample text sequence is used as input for the model training stage, and the preset model is instructed to output a target prediction label sequence according to the sample label sequence. The target prediction label sequence includes the predicted text association label, predicted text classification label, and predicted text main information of the sample target text relative to the sample comparison text. In this way, the output format of the model can be set during the training stage. Finally, a target loss function is constructed based on the ratio of the label path score corresponding to the target prediction label sequence to the total score of all candidate label paths. The preset model is iteratively trained according to the target loss function until the preset convergence condition is reached to obtain the trained target model. By employing the above methods, the input and output formats of this model are cleverly designed during the model training phase. Combined with the feature processing characteristics of the model framework, the characters in the text sequence input to the model are processed synchronously. This allows the model to comprehensively consider the vector information of all characters in the text sequence, strengthening the information correlation between multiple text recognition tasks. As a result, the trained target model can subsequently complete multiple text recognition tasks related to the same target text, improving the model's recognition efficiency and accuracy.

[0270] Based on the method described in the above embodiments, the following examples will provide further detailed explanations.

[0271] This application takes text recognition as an example to further describe the text recognition method provided in this application.

[0272] Figure 9 This is a schematic diagram of another step in the text recognition method provided in the embodiments of this application. Figure 10This is a schematic diagram of the tag state transition matrix provided in an embodiment of this application. For ease of understanding, this embodiment of the application combines... Figure 3-10 Describe it.

[0273] In this embodiment, the description will focus on the text recognition device, which can be integrated into a computer device such as a server. For example, when the processor on the computer device executes the program corresponding to the text recognition method, the specific flow of the text recognition method is as follows:

[0274] It should be noted that the text recognition method provided in this application includes a model training stage and a model application stage. The model training stage corresponds to steps 301-205, through which a target model can be trained. The model application stage corresponds to steps 306-308, which mainly describes the text recognition process and enables the execution of multiple text recognition tasks using the same target model.

[0275] 301. Obtain the sample comparison text, sample target text, and sample target text classification information.

[0276] The target text can be a textual description of the target event to be identified, representing the semantic information of the target event. The target text can be understood as the basic text corresponding to the target text recognition task.

[0277] The sample comparison text can be text containing a textual description of the sample event, which represents the semantic information of the sample event, in order to identify whether the event content of the sample target text is semantically related.

[0278] The target text classification information can be information used to indicate the category label of the output target text. This target text classification information can be in any form; for example, it can be character-based information, including letters, numbers, symbols, labels, and other characters, or it can be information obtained by combining multiple character types. For instance, the letter "L" can be used as the target text classification information, or the "%" symbol can be used as the target text classification information. These are merely examples and do not constitute a specific limitation on the implementation of this application.

[0279] For example, taking the title of a hot news event as a sample event, the title of the hot news event can be used as the sample comparison text; taking the commentary text or non-commentary text of the hot news event as the sample target event, the title, a sentence or the whole text of the commentary text or non-commentary text can be used as the sample target text; in addition, any form of character can be used as the sample target text classification information, such as the letter "L" or the symbol "%" as the sample target text classification information.

[0280] 302. The sample text sequence is obtained by preprocessing the sample comparison text, sample target text, and sample target text classification information.

[0281] In this embodiment, to enable a single model to complete multiple text recognition tasks for the target text, the input data of the model can be cleverly designed during the training phase based on the feature processing characteristics of the model framework. Specifically, the sample comparison text, the sample target text, and the sample target text classification information are preprocessed to obtain a sample text sequence.

[0282] The preprocessing process can include concatenation and word segmentation. Specifically, firstly, the comparison text, target text, and target text classification information can be concatenated. This concatenation refers to sequentially piecing together the text according to a specific order, such as concatenating the comparison text, target text, and target text classification information in that order. Next, the concatenated text is segmented. This segmentation can be done at the character level, meaning segmentation is performed based on the smallest possible character or symbol. After concatenation and word segmentation, a sample text sequence is obtained.

[0283] For example, let "hotspot" refer to any sample event, i.e., the sample comparison text, and "commentary text" refer to any sample target event, i.e., the sample target text. Let "L" represent the sample target text classification information. Then, the preprocessed sample text sequence is "[CLS] / hotspot / [SEP] / commentary / text / [SEP] / L". Thus, the training data for the preset model input during the training phase is obtained.

[0284] It should be noted that the above are merely general examples. For specific sample text sequences, the specific criteria can be determined based on the actual event situation. For instance, the title of a "hot topic event" can be used as the comparison text to replace "hot topic" in the text sequence, and the title or any content of the text to be identified can be used as the target text to replace "commentary text." The target text classification information "L" can remain unchanged. In subsequent application phases, the settings for comparison text, target text, and target text classification information are the same as those for the training data input during the training phase. The setting of the target text classification information can remain consistent with the "L" set during the training phase, and will not be elaborated further.

[0285] In this embodiment, after obtaining the sample text sequence input to the preset model, each character in the sample text sequence can be labeled to obtain the corresponding sample label sequence. For example, assuming the sample text sequence is “[CLS] / hot / point / [SEP] / review / text / [SEP] / L”, after labeling, the sample label sequence is “B-cor、O、O、O、B-com、I-com、O、O、O、B-emo”; this can be used as an indicator in the model training phase to instruct the model to iteratively train according to the indicator direction.

[0286] It should be noted that "B-cor1" and "B-cor0" can be used to represent the "association" or "lack of association" between the sample comparison text and the sample target text, respectively, and "B-emo1" and "B-emo0" can be used to represent the "positive" or "negative" label of the sample target text, respectively. Therefore, in the data preparation phase of training, multiple training data sets can be set according to training needs. Each training data set includes a sequence of sample texts and a corresponding sequence of sample labels. The specific sample label sequence can be set according to the actual situation of the sample comparison texts and sample target texts. For example, the sample label sequence is not limited to including: "B-cor1, O, O, O, B-com, I-com, O, O, O, B-emo1", "B-cor0, O, O, O, B-com, I-com, O, O, O, B-emo1", "B-cor1, O, O, O, B-com, I-com, O, O, O, B-emo0", "B-cor0, O, O, O, B-com, I-com, O, O, O, B-emo0". By training different sample text sequences in combination with one of the corresponding sample label sequences, the model can output "B-cor1" or "B-cor0" in the character output position corresponding to "[CLS]" to indicate whether the comparison text and the target text are "related" or "not related", and output "B-emo1" or "B-emo0" in the character output position corresponding to "L" to indicate the text classification information of the target text, such as the semantic sentiment category label of "positive" or "negative" in the semantic sentiment tendency classification.

[0287] 303. Input the sample text sequence into the preset model and obtain multiple candidate label paths generated by the preset model when processing the sample text sequence.

[0288] In this embodiment, the processing of multiple text recognition tasks can be implemented through natural language processing, specifically through Named Entity Recognition (NER). This process can be based on text processing, semantic understanding, and other technologies to recognize the target text. Therefore, during the training phase, the pre-built model framework can include an encoding layer, a bidirectional memory network layer, and a classification layer.

[0289] The encoding layer can be a bidirectional encoding model (BERT) used to perform deep semantic learning on each character in the text sequence. Specifically, the bidirectional encoding model can combine the relationship between each character and the context to determine its semantics. For example, it can combine the positional relationship of each character in the context to generate a vector representation of each character with enhanced semantics, ensuring the accuracy of the vector representation of each character after encoding.

[0290] The bidirectional long short-term memory (Bi-LSTM) network layer consists of two layers: a forward-to-backward propagation Bi-LSTM layer and a backward-to-foreign propagation Bi-LSTM layer. Specifically, the forward-to-backward propagation Bi-LSTM layer propagates features along the text from front to back. When processing each character representation vector, it incorporates the preceding context features, which may include forgetting or updating features. This allows for the representation of the current character representation vector by combining the features from the forward propagation. Similarly, the backward-to-foreign propagation Bi-LSTM layer propagates features along the text from back to front. When processing each character representation vector, it incorporates the following context features, which may also include forgetting or updating features. This allows for the representation of the current character representation vector by combining the features from the backward propagation. Furthermore, the features obtained from the forward and backward propagation processes corresponding to each character representation vector are fused. This fusion process can be additive to obtain fused features. Finally, the fused features are linearly processed by a linear processing layer in the bidirectional memory network layer to obtain the sample label score sequence corresponding to each character representation vector.

[0291] It should be noted that each sample label scoring sequence can contain multiple label categories, such as B-cor, B-com, I-com, O, and B-emo. Each sample label scoring sequence contains the label score for each label category. B-cor is the label output at the [CLS] character position, representing the association between the commentary text and the hot topic. This B-cor association label can be further subdivided into "B-cor1" and "B-cor0" to represent association and non-association, respectively. B-com and I-com are the label sequences of the sample text body information output at the character positions of the commentary text. Specifically, they represent sample text body information consisting of two characters. B-com represents the first character label of the sample text body information, and I-com represents the second character label. For sample text body information consisting of multiple characters, a corresponding number of I-com labels can be output. O refers to a non-entity class label, whose output is irrelevant to the multiple text recognition tasks in this application embodiment and has no actual referential meaning. Here, B-emo represents the text classification information output by the character bits of the target text classification information. Taking the analysis of text semantic sentiment as an example, B-emo can represent the semantic sentiment classification label of the commentary text. For this B-emo label, it can be further subdivided into "B-emo1" and "B-emo0" labels to represent the positive and negative sentiment semantics, respectively. Any of the above labels can be labeled on the sample text sequence during the training phase and learned through model training.

[0292] The classification layer can be a Conditional Random Field (CRF) classification layer, which constructs candidate label paths for each sample based on any label category in the label scoring sequence. It's important to note that the CRF can learn constraints regarding label category transitions, which are used to constrain the relationships between adjacent label categories when constructing the candidate label path for each sample. For example, the first label category in the constructed candidate label path cannot be "I-com", "I-com" can only follow "B-com", "I-com" cannot be paired with "B-cor" or "B-emo", and so on.

[0293] To facilitate understanding of the classification layer's processing, we will use the Conditional Random Field (CRF) classification layer as an example to describe its process. Specifically, the CRF classification layer can construct candidate label paths for each sample based on any label category in the label scoring sequence, combined with constraints, resulting in multiple predicted candidate label paths. For example, using “[CLS] / Hot / Points / [SEP] / Comment / Text / [SEP] / L” as the sample text sequence, the multiple sample candidate label paths can be: “O, B-cor, O, O, O, B-com, I-com, O, O, B-emo”, “B-cor, O, O, O, O, B-com, I-com, O, O, B-emo”, “B-cor, O, O, O, B-com, I-com, O, O, O, O”, “O, O, O, O, B-com, I-com, O, O, O, B-emo”, “B-cor, O, O, O, B-com, I-com, O, O, O, B-emo”, etc. The above only lists a portion of the predicted candidate label sequences; other predicted candidate label sequences that meet the constraints can also be included, but they are not listed here.

[0294] In this embodiment of the application, after inputting the sample text sequence into the preset model, multiple candidate label paths generated by the preset model when processing the sample text sequence can be obtained, so that the target candidate label path can be selected from the multiple predicted candidate label paths to indicate the output of the preset model.

[0295] 304. Obtain the sample label sequence, and select the target candidate label path from multiple candidate label paths according to the sample label sequence to output the target predicted label sequence.

[0296] Specifically, obtaining the sample label sequence involves obtaining a pre-defined sample label sequence for the sample text sequence. The sample label sequence is obtained by labeling each character in the sample text sequence.

[0297] In this embodiment, since the preset model generates multiple candidate label paths when processing sample text sequences (specifically, the classification layer in the preset model may generate multiple candidate label paths, but the preset model will ultimately only output the label sequence corresponding to one of these candidate label paths), the output of the preset model can be instructed based on this sample label sequence during the training phase. Specifically, based on this sample label sequence, the preset model can be instructed to select a target candidate label path from the multiple candidate label paths and output the corresponding target predicted label sequence according to this target candidate label path. This allows for the subsequent construction of a target loss function based on the target predicted label sequence, enabling iterative training of the preset model.

[0298] 305. Construct a target loss function based on the proportion of path scores of the target predicted label sequence, and iteratively train the preset model based on the target loss function until convergence, to obtain the trained target model.

[0299] In this embodiment, since the preset model generates multiple candidate label paths when processing sample text sequences, specifically, the classification layer in the preset model may generate multiple candidate label paths. The model generally needs to make a judgment and select one of the candidate label paths to indicate the model's output based on the judgment result. Therefore, to ensure that the model can accurately select the candidate label path to indicate the output, after instructing the preset model to output the target predicted label sequence based on the sample label sequence, a target loss function can be constructed based on the target predicted label sequence. This allows the preset model to be iteratively trained by minimizing the target loss function until convergence, thus obtaining the trained target model.

[0300] It should be noted that the preset model in this embodiment can calculate a path score for each candidate label path through a classification layer. The preset model can select a candidate label path based on the path score to indicate the model's output. Therefore, after instructing the preset model to output a target predicted label sequence based on the sample label sequence, in order for the preset model to select the target candidate label path corresponding to the target predicted label sequence based on the path score, a target loss function can be constructed based on the proportion of the path scores of the target candidate label paths corresponding to the target predicted label sequence. This allows for iterative training of the preset model based on the target loss function, maximizing the path score of the target candidate label path among multiple candidate label paths, or maximizing the proportion of the path score of the target candidate label path relative to the total score of other candidate label paths. This ensures that the preset model can accurately output the target predicted label sequence during the training phase, leading to model training convergence and the acquisition of the target model. Subsequently, in the application phase, the target model can be used to perform multiple text recognition tasks targeting the target text.

[0301] In some implementations, the candidate path score for each candidate label path can be calculated first. After determining the total candidate path score for multiple candidate label paths, the target path score for the target candidate label path corresponding to the target predicted label sequence can be determined. Then, the target loss function is constructed based on the ratio between the target path score and the total candidate path score. Specifically, the construction process of the target loss function can be as follows: determine the predicted label state score and predicted label transition score for each candidate label path, and calculate the candidate path score for the corresponding candidate label path based on the predicted label state score and predicted label transition score; determine the total candidate path score corresponding to multiple candidate path scores, and query the target path score corresponding to the target predicted label sequence from the multiple candidate path scores; construct the target loss function based on the weight ratio between the target path score and the total predicted candidate path score.

[0302] In some implementations, to construct the target loss function, it is necessary to first calculate the predicted label state score and predicted label transition score for each candidate label path. This calculation process may specifically include: obtaining a sequence of predicted label scores for each character in a sample text sequence processed by a preset model; the predicted label score sequence includes multiple predicted label categories and a corresponding predicted category score for each predicted label category; determining the target predicted label category for each character in each candidate label path, and calculating the predicted label state score for the corresponding candidate label path based on the predicted category score for each target predicted label category; determining the category transition score between any two adjacent target predicted label categories in each candidate label path, and calculating the predicted label transition score for the corresponding candidate label path based on multiple category transition scores.

[0303] For example, suppose there are N candidate label paths, with P i The candidate path score for each candidate tag path can be calculated using a logarithmic function, specifically as follows: P i =e Si .

[0304] Where Si represents the predicted label state score S of the i-th candidate label path. Emission And predicted label transfer score S Transition The sum of all candidate path scores, i.e., the candidate path score of the i-th candidate label path, is calculated as follows: Si = S Emission +S Transition .

[0305] For example, taking one of the candidate label paths "B-cor, O, O, O, B-com, I-com, O, O, O, B-emo" as an example, in order to make the matrix for calculating the predicted label transition score more powerful, START and END can be added to the beginning and end of the label path respectively. START is the beginning of the label path, not the first label, and END indicates the end of the label path.

[0306] The predicted label status score refers to the sum of label scores for multiple label categories in the corresponding candidate label path. The calculation process for this predicted label status score is as follows:

[0307] S Emission =x 0,START +x 1,B-cor +x 2,O +x 3,O +x 4,O +x 5,B-com +x 6,I-com +x 7,O +x 8,O +x 9,O +x 10,B-emo +x 11,END

[0308] The predicted label transition score refers to the overall label state transition score when any two adjacent labels in the corresponding candidate label path transition from one label category to the next. The calculation process for this predicted label transition score is as follows:

[0309] S Transition =T START→B-cor +T B-cor→O +T O→O +T O→O +T O→B-com +T B-com→I-com +T I-com→O +T O→O +T O→O +T O→B-emo +T B-emo→END

[0310] Therefore, following the above calculation process, the candidate path score P for each candidate label path can be calculated. i .

[0311] Furthermore, based on the candidate path score for each candidate tag path, the total candidate path score is calculated. The calculation process for this total candidate path score is as follows:

[0312] P total =e S1 +e S2 +e S3 +......+e SN

[0313] Finally, the target candidate label path corresponding to the target predicted label sequence is taken as the true path, and P is used as the ground truth path. real The target loss function, representing the score of the true path, is expressed as follows:

[0314]

[0315] At this point, the target loss function is complete. Based on this target loss function, the network parameters of the preset model can be adjusted and iterative training can be performed until the preset conditions are met. For example, the predicted label sequence output by the preset model is the same as the sample label sequence, or the number of iterations reaches a certain number, or the score weight of the true path determined by the target loss function no longer changes. At this point, the training can be considered to have converged, and the trained target model is obtained.

[0316] 306. Obtain the comparison text, target text, and target text classification information.

[0317] In this embodiment, the text recognition task can be: identifying whether there is a relationship between the target text and other texts, identifying the text subject information corresponding to the target text, and identifying the classification label of the target text. For the above multiple text recognition tasks, the target text to be recognized is first determined, and whether there are related comparison texts is determined, as well as the target text classification information used to guide the output text classification label, is determined. This allows for the subsequent design of the model's input data based on the comparison text, the target text, and the target text classification information, thereby enabling the target model to complete multiple recognition tasks of the target text.

[0318] 307. Preprocess the comparison text, target text, and target text classification information to obtain a text sequence.

[0319] In this embodiment, to enable a single model to complete multiple text recognition tasks for a target text, the input data of the target model can be cleverly designed based on the feature processing characteristics of the model framework. Specifically, the acquired comparison text, target text, and target text classification information can be preprocessed so that the input data can be processed by the model subsequently to complete multiple text recognition tasks for the target text.

[0320] This preprocessing step may include concatenation and word segmentation. Specifically, firstly, the comparison text, target text, and target text classification information can be concatenated in a specific order to form a single text data, i.e., concatenated text. Then, the concatenated text is segmented at the smallest character or symbol level to obtain a text sequence.

[0321] In this way, the input data of the target model can be cleverly designed so that multiple text recognition tasks of the target text can be completed through a single model.

[0322] 308. Input the text sequence into the target model to obtain the target label sequence.

[0323] In this embodiment of the application, after preprocessing to obtain a text sequence containing overall data corresponding to multiple text recognition tasks, the text sequence can be input into the target model for processing, so as to realize the execution of multiple text recognition tasks of the target text through the same model according to the target label sequence output by the target model, which contains the label information corresponding to each text recognition task.

[0324] The target label sequence can be a sequence of multiple characters, and the labels in the sequence can be obtained by combining one or more characters to represent the recognition result corresponding to each text recognition task. For example, if the multiple text recognition tasks for the target text are: recognizing the correlation between the target text and other texts, the main information of the target text, and the text category of the target text, then the target label sequence shall at least contain the text correlation label of the target text relative to the comparison text, the text category label, and the main information of the text.

[0325] It should be noted that the specific processing procedure of the target model for the text sequence can be found in the description of the foregoing embodiments, and will not be repeated here.

[0326] To facilitate understanding of the embodiments of this application, specific application scenario examples will be used to describe the embodiments of this application. Specifically, by performing the above steps 301-308, and in conjunction with... Figures 3-10 This section describes an example of the application scenario.

[0327] Specifically, the following are specific scenario examples of this text recognition method:

[0328] I. Combination Figure 3 , Figure 5 , Figure 6 , Figure 7 As shown, the target model for text recognition, in its framework structure, may include a Bidirectional Encoding Layer (BERT), a Bidirectional Memory Network Layer (Bi-LSTM), and a Conditional Random Field (CRF) classification layer. During the model's training phase, these layers are responsible for pre-encoding, context encoding, and sentence component annotation (learning), respectively. Furthermore, the model framework may also include a tokenization layer, which performs sentence component annotation before BERT pre-encoding. To facilitate understanding of this model framework structure, each layer will be described in detail below:

[0329] (1) The word segmentation layer (TOKEN) can concatenate the comparison text, the target text and the target text classification information, and perform word segmentation on the concatenated text to obtain a text sequence.

[0330] (2) The bidirectional encoding layer (BERT) is used only as a pre-training tool in this application to encode each character in the text sequence. The parameters of the bidirectional encoding layer are not updated during training. Encoding through this bidirectional encoding firstly allows for comprehensive consideration of the context during word encoding based on the self-attention mechanism; secondly, contextual labels between sentences are added to the loss function to achieve contextual understanding between sentences.

[0331] (3) The Bi-LSTM (Bi-Long Short-Term Memory) network layer is a bidirectional word vector encoding model constructed from two layers of Long Short-Term Memory (LSTM) networks. The LSTM model consists of the input word Xt at time t, the cell state Ct, the hidden layer Ht, the forget gate Ft, the memory gate It, and the output gate Ot. This LSTM model can be used to: calculate the forget gate Ft, the memory gate It, and the output gate Ot using the hidden state Ht-1 at this time and the current Xt; and, based on the control of the forget gate Ft, the memory gate It, and the output gate Ot, to achieve the forgetting of information in the cell state and the memorization of new information, allowing useful information to be passed on for subsequent calculations, while useless information is discarded, and outputting the hidden state Ht at each time step. Based on this, by combining two LSTM networks, the word encoding results are concatenated from both directions of the sentence to achieve contextual understanding of the word. It should be noted that the Bi-LSTM outputs a label-score sequence corresponding to each character.

[0332] (4) The Conditional Random Field (CRF) classification layer learns the constraints between the labels corresponding to the text sequence, and constructs multiple candidate label paths under the constraints. The path score is calculated based on the label state score (Emission score) and label transition score (Transition score) of each candidate label path. The true path, i.e. the target label path, is determined based on the size of the path score.

[0333] The label status score (Emission score) for each candidate label path can be determined based on the label score sequence corresponding to each character.

[0334] The process for determining the label transition score for each candidate label path is as follows: First, determine the sub-score for the transition from one label category to the next between any two adjacent labels in the path. Then, accumulate these scores to obtain the label transition score for each candidate label path. For the sub-score for the component transition between any two adjacent labels, please refer to... Figure 9 As shown.

[0335] The candidate path score is calculated based on the label status score and label transition score for each candidate label path, and can be expressed as follows: It is understandable that the scoring path P for the true components of a sentence... real It was calculated in the same way.

[0336] Then, calculate the total score P for all candidate label paths. total =P1+P2+P3+......+P N The constructed target loss function is expressed as follows: LossFunction = P real / P total .

[0337] II. Examples of application scenarios for the above target models in text recognition:

[0338] For example, suppose "XX News" publishes a sports news article titled "The Decisive Moment of the Basketball Game Between the First and Second Regions," and a user posts a reasoning article in a sports forum titled "The First Region Can Win in the Decisive Moment." Assuming the target text classification information is "L," after concatenating and segmenting these three pieces of information, the resulting text sequence can be represented as "[CLS] / The First / Region / and / The Second / Region / of / Basketball / Game / Decisive / Moment / [SEP] / The First / Region / Can / Win / In / The Decisive / Moment / [SEP] / L". It should be noted that " / " is used as a segmentation symbol to indicate the existence of segmentation between characters; in actual application, the " / " symbol may not be present.

[0339] Then, the text sequence “[CLS] / First / Region / and / Second / Region / of / Basketball / Game / Final / Moment / [SEP] / First / Region / Can / Win / In / Final / Moment / [SEP] / L” is input into the target model for processing. Specifically, this processing involves embedding each character in the text sequence “[CLS] / First / Region / and / Second / Region / of / Basketball / Game / Final / Moment / [SEP] / First / Region / Can / Win / In / Final / Moment / [SEP] / L”, including but not limited to one or more embedding methods such as token embedding, sentence fragment embedding, and positional embedding, to obtain an embedding representation vector. Furthermore, based on the self-attention mechanism and fully connected relationships of "Trm" in BERT, the context is considered when encoding the corresponding embedded representation vectors to capture the long-distance dependencies between different vectors, thus obtaining character representation vectors with deep semantic representation.

[0340] Furthermore, a bidirectional memory network layer (Bi-LSTM) is used to encode and propagate the representation vector of each character in the input in two directions, from front to back and from back to front, in order to achieve contextual understanding of the characters and output a labeled score sequence for each character.

[0341] For example, suppose the tag categories include B-cor, B-com, I-com, B-emo, and O. Taking the characters "[CLS]" from the text sequence as an example, the output tag score sequence can be as follows:

[0342]

[0343] For example, suppose the tag categories include B-cor0, B-cor1, B-com, I-com, B-emo0, B-emo1, and O. Taking the characters "[CLS]" in the text sequence as an example, the output tag score sequence can be as follows:

[0344]

[0345]

[0346] The above is just an example of the label scoring sequence for the character "[CLS]" in the text sequence; other characters also have corresponding label scoring sequences. They will not be listed here one by one.

[0347] Finally, a Conditional Random Field (CRF) classification layer is used to determine sentence components based on each label scoring sequence, and the target label sequence for recognizing multiple texts is output. The output target label sequence can be “B-cor, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, B-com, I-com, I-com, I-com, O, O, O, O, O, O, O, O, B-emo”, where B-cor represents the association label between the comparison text “the decisive moment of the basketball game between the first and second regions” and the target text “the first region can win in the decisive moment”, B-com, I-com, I-com, I-com represent the textual information “the first region” in the target text, and B-emo represents the semantic sentiment category label of the target text “the first region can win in the decisive moment”.

[0348] Furthermore, "B-cor" in the output target label sequence can be replaced by "B-cor0" or "B-cor1" to indicate whether the comparison text and the target text are unrelated or related. Similarly, "B-emo" can be replaced by "B-emo1" or "B-emo0" to indicate whether the semantic sentiment category of the target text is positive or negative. For example, "B-emo1" can be interpreted as the semantic sentiment of the target text "The first region can win in the decisive moment" being positive, while "B-emo0" can be interpreted as the semantic sentiment of the target text "The first region can win in the decisive moment" being negative.

[0349] Through the above application scenarios, the following effects can be achieved: By combining the three tasks of identifying the association between hot topics and target events, identifying the sentiment of target events, and extracting the subject of target events through the improved named entity recognition algorithm, the task of identifying negative events associated with hot topics is simplified, and the model accuracy and running efficiency are improved.

[0350] As can be seen from the above, the embodiments of this application can obtain a text sequence as input to the target model after obtaining the comparison text, target text, and target text classification information through preprocessing. Combining the feature processing characteristics of each processing layer in the target model framework, the characters in the text sequence input to the model are processed synchronously, so that the model comprehensively considers the vector information of the full-text characters in the text sequence, strengthening the information correlation between multiple text recognition tasks. Furthermore, after processing the text sequence, the recognition result labels of multiple text tasks are output, such as the text body information and text classification label of the target text, as well as the text association label between the target text and the comparison text. In this way, multiple recognition tasks of the same text association can be executed simultaneously by a single model, thereby effectively avoiding the phenomenon of information transmission error, improving the recognition accuracy and efficiency of the model when executing multiple recognition tasks of the same text, and improving the user's experience in obtaining text information.

[0351] To better implement the above methods, embodiments of this application also provide a text recognition device. For example, such as... Figure 11 As shown, the text recognition device may include an acquisition unit 501, a preprocessing unit 502, and a recognition unit 503.

[0352] The acquisition unit 501 is used to acquire the comparison text, the target text, and the target text classification information;

[0353] Preprocessing unit 502 is used to preprocess the comparison text, target text, and target text classification information to obtain a text sequence;

[0354] The recognition unit 503 is used to input the text sequence into the target model to obtain the target label sequence. The target label sequence contains at least the text association label of the target text relative to the comparison text, the text classification label, and the text body information.

[0355] The target model is obtained by comparing the output of the sample text sequence with the sample label sequence based on the preset model. The sample text sequence is obtained by preprocessing the sample comparison text, the sample target text, and the sample target text classification information. The sample label sequence includes the sample association label of the sample target text relative to the sample comparison text, the sample text classification label, and the sample text main information.

[0356] In some implementations, the recognition unit 503 is further configured to: perform semantic enhancement representation on each character in the text sequence based on the target model to obtain a character vector sequence, wherein the character vector sequence contains a character representation vector corresponding to each character; fuse and transform the features of each character representation vector and the character vector sequence in bidirectional propagation to obtain a label score sequence corresponding to each character representation vector; and determine a target label path based on multiple label categories in each label score sequence and the label score corresponding to each label category, wherein the target label path is used to instruct the target model to output a target label sequence.

[0357] In some implementations, the target model includes an encoding layer and a recognition unit 503, which is further configured to: perform vector embedding processing on each character in the text sequence through the encoding layer to obtain an embedding vector sequence, wherein the embedding vector sequence contains an embedding representation vector corresponding to each character; and perform encoding processing on each embedding representation vector based on the bidirectional features of each embedding representation vector in the embedding vector sequence to obtain a character vector sequence with semantically enhanced representation.

[0358] In some implementations, the target model further includes a bidirectional memory network layer connected to the encoding layer. The recognition unit 503 is also used to: perform forward propagation on each character representation vector in the character vector sequence through the bidirectional memory network layer to obtain the context feature corresponding to each character representation vector; perform backward propagation on each character representation vector in the character vector sequence to obtain the context feature corresponding to each character representation vector; fuse each character representation vector with the corresponding context feature and the corresponding context feature to obtain the fused feature corresponding to each character representation vector; and perform a linear transformation on the fused feature to obtain the label scoring sequence corresponding to each character representation vector.

[0359] In some implementations, the target model further includes a classification layer connected to the bidirectional memory network layer. The recognition unit 503 is further configured to: combine any selected label category in each label scoring sequence according to the character sorting relationship of the text sequence through the classification layer to obtain multiple candidate label paths, each candidate label path containing the label category of each character; determine the label score of each label category indicated in each candidate label path based on the multiple label categories in each label scoring sequence and the label score corresponding to each label category; calculate the path score of the corresponding candidate label path according to the label score of each label category indicated in each candidate label path and the category transfer relationship between adjacent label categories; and determine the target label path from the multiple candidate label paths based on the magnitude of the path score.

[0360] In some implementations, the identification unit 503 is further configured to: calculate the label status score corresponding to each candidate label path based on the label scores in each label scoring sequence; determine the label transition score based on the state transition relationship between multiple label categories in each candidate label path; and calculate the path score based on the label status score and label transition score corresponding to each candidate label path.

[0361] In some implementations, the preprocessing unit 502 is further configured to: concatenate the comparison text, the target text, and the target text classification information to obtain concatenated text; and perform word segmentation on the concatenated text to obtain a text sequence.

[0362] In some embodiments, the text recognition device further includes a training unit, configured to: acquire sample comparison text, sample target text, and sample target text classification information; preprocess the sample comparison text, sample target text, and sample target text classification information to obtain a sample text sequence; input the sample text sequence into a preset model and acquire multiple candidate label paths generated by the preset model when processing the sample text sequence; acquire a sample label sequence and instruct the preset model to select a target candidate label path from the multiple candidate label paths according to the sample label sequence, so as to output a target predicted label sequence; construct a target loss function according to the proportion of path scores of the target predicted label sequence, and iteratively train the preset model according to the target loss function until convergence, thereby obtaining the trained target model.

[0363] In some implementations, the training unit is further configured to: determine the predicted label state score and the predicted label transition score for each candidate label path, and calculate the candidate path score for the corresponding candidate label path based on the predicted label state score and the predicted label transition score; determine the total candidate path score corresponding to multiple candidate path scores, and query the target path score corresponding to the target predicted label sequence from the multiple candidate path scores; and construct a target loss function based on the weight ratio between the target path score and the total predicted candidate path score.

[0364] In some implementations, the training unit is further configured to: obtain a predicted label score sequence when a preset model processes each character in a sample text sequence, the predicted label score sequence including multiple predicted label categories and a predicted category score corresponding to each predicted label category; determine the target predicted label category corresponding to each character in each candidate label path, and calculate the predicted label state score of the corresponding candidate label path based on the predicted category score corresponding to each target predicted label category; determine the category transfer score between any two adjacent target predicted label categories in each candidate label path, and calculate the predicted label transfer score of the corresponding candidate label path based on multiple category transfer scores.

[0365] As can be seen from the above, the embodiments of this application can obtain a text sequence as input to the target model after obtaining the comparison text, target text, and target text classification information through preprocessing. Combining the feature processing characteristics of each processing layer in the target model framework, the characters in the text sequence input to the model are processed synchronously, so that the model comprehensively considers the vector information of the full-text characters in the text sequence, strengthening the information correlation between multiple text recognition tasks. Furthermore, after processing the text sequence, the recognition result labels of multiple text tasks are output, such as the text body information and text classification label of the target text, as well as the text association label between the target text and the comparison text. In this way, multiple recognition tasks of the same text association can be executed simultaneously by a single model, thereby effectively avoiding the phenomenon of information transmission error, improving the recognition accuracy and efficiency of the model when executing multiple recognition tasks of the same text, and improving the user's experience in obtaining text information.

[0366] To better implement the above methods, embodiments of this application also provide a model training apparatus. For example, such as Figure 12 As shown, the model training device may include a first acquisition unit 601, a processing unit 602, a second acquisition unit 603, a selection unit 604, and a training unit 603.

[0367] The first acquisition unit 601 is used to acquire sample comparison text, sample target text and sample target text classification information;

[0368] Processing unit 602 is used to preprocess the sample comparison text, sample target text, and sample target text classification information to obtain a sample text sequence;

[0369] The second acquisition unit 603 is used to input the sample text sequence into a preset model and acquire multiple candidate label paths generated by the preset model when processing the sample text sequence.

[0370] Selection unit 604 is used to acquire sample label sequence and instruct the preset model to select target candidate label path from the plurality of candidate label paths according to the sample label sequence, so as to output target predicted label sequence;

[0371] Training unit 605 is used to construct a target loss function based on the proportion of path scores of the target predicted label sequence, and to iteratively train the preset model based on the target loss function until convergence, thereby obtaining the trained target model.

[0372] In some embodiments, the training unit 605 is further configured to: determine the predicted label state score and the predicted label transition score for each candidate label path, and calculate the candidate path score for the corresponding candidate label path based on the predicted label state score and the predicted label transition score; determine the total candidate path score corresponding to the multiple candidate path scores, and query the target path score corresponding to the target predicted label sequence from the multiple candidate path scores; and construct a target loss function based on the weight ratio between the target path score and the total predicted candidate path score.

[0373] In some embodiments, the training unit 605 is further configured to: obtain a predicted label score sequence when the preset model processes each character in the sample text sequence, the predicted label score sequence including multiple predicted label categories and a predicted category score corresponding to each predicted label category; determine the target predicted label category corresponding to each character in each candidate label path, and calculate the predicted label state score of the corresponding candidate label path based on the predicted category score corresponding to each target predicted label category; determine the category transfer score between any two adjacent target predicted label categories in each candidate label path, and calculate the predicted label transfer score of the corresponding candidate label path based on the multiple category transfer scores.

[0374] As can be seen from the above, the embodiments of this application can obtain data such as sample comparison text, sample target text, and sample target text classification information, and concatenate the above data to obtain a sample text sequence. In addition, each character in the sample text sequence is labeled to obtain a sample label sequence. Then, the sample text sequence is used as input for the model training stage, and the preset model is instructed to output a target prediction label sequence according to the sample label sequence. The target prediction label sequence includes the predicted text association label, predicted text classification label, and predicted text main information of the sample target text relative to the sample comparison text. In this way, the output format of the model can be set during the training stage. Finally, a target loss function is constructed based on the ratio of the label path score corresponding to the target prediction label sequence to the total score of all candidate label paths. The preset model is iteratively trained according to the target loss function until the preset convergence condition is reached to obtain the trained target model. By employing the above methods, the input and output formats of this model are cleverly designed during the model training phase. Combined with the feature processing characteristics of the model framework, the characters in the text sequence input to the model are processed synchronously. This allows the model to comprehensively consider the vector information of all characters in the text sequence, strengthening the information correlation between multiple text recognition tasks. As a result, the trained target model can subsequently complete multiple text recognition tasks related to the same target text, improving the model's recognition efficiency and accuracy.

[0375] This application also provides a computer device, such as... Figure 13 As shown, it illustrates a structural schematic diagram of the computer device involved in the embodiments of this application, specifically:

[0376] The computer device may include components such as a processor 701 with one or more processing cores, a memory 702 with one or more computer-readable storage media, a power supply 703, and an input unit 704. Those skilled in the art will understand that... Figure 13 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

[0377] The processor 701 is the control center of the computer device, connecting various parts of the computer device through various interfaces and lines. It performs various functions and processes data by running or executing software programs and / or modules stored in the memory 702, and by calling data stored in the memory 702. Optionally, the processor 701 may include one or more processing cores; preferably, the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 701.

[0378] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and text recognition processes by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 702 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.

[0379] The computer device also includes a power supply 703 that supplies power to the various components. Preferably, the power supply 703 can be logically connected to the processor 701 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 703 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0380] The computer device may also include an input unit 704, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0381] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically, in the embodiments of this application, the processor 701 in the computer device loads the executable files corresponding to the processes of one or more application programs into the memory 702 according to the following instructions, and the processor 701 runs the application programs stored in the memory 702 to realize various functions, as follows:

[0382] The process involves acquiring comparison text, target text, and target text classification information; preprocessing the comparison text, target text, and target text classification information to obtain a text sequence; inputting the text sequence into the target model to obtain a target label sequence, which includes at least the text association label, text classification label, and text body information of the target text relative to the comparison text; wherein, the target model is obtained by training a pre-defined model based on the output of the sample text sequence and the sample label sequence, the sample text sequence is obtained by preprocessing the sample comparison text, sample target text, and sample target text classification information, and the sample label sequence includes the sample association label, sample text classification label, and sample text body information of the sample target text relative to the sample comparison text.

[0383] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0384] Therefore, this solution can obtain a text sequence as input to the target model after preprocessing the comparison text, target text, and target text classification information. Then, the target model processes the text sequence and outputs recognition result labels for multiple text tasks, such as the text body information and text classification label of the target text, as well as the text association label between the target text and the comparison text. In this way, multiple recognition tasks of the same text association can be performed simultaneously by a single model, thereby effectively avoiding the phenomenon of information transmission error, improving the recognition accuracy and efficiency of the model when performing multiple recognition tasks of the same text, and improving the user's experience in obtaining text information.

[0385] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0386] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the text recognition methods provided in embodiments of this application. For example, the instructions can execute the following steps:

[0387] The process involves acquiring comparison text, target text, and target text classification information; preprocessing the comparison text, target text, and target text classification information to obtain a text sequence; inputting the text sequence into the target model to obtain a target label sequence, which includes at least the text association label, text classification label, and text body information of the target text relative to the comparison text; wherein, the target model is obtained by training a pre-defined model based on the output of the sample text sequence and the sample label sequence, the sample text sequence is obtained by preprocessing the sample comparison text, sample target text, and sample target text classification information, and the sample label sequence includes the sample association label, sample text classification label, and sample text body information of the sample target text relative to the sample comparison text.

[0388] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0389] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0390] Since the instructions stored in the computer-readable storage medium can execute the steps of any of the text recognition methods provided in the embodiments of this application, the beneficial effects that any of the text recognition methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.

[0391] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations of the above embodiments.

[0392] The foregoing has provided a detailed description of a text recognition method, model training method, apparatus, device, and computer-readable storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A text recognition method, characterized in that, include: Obtain comparison text, target text, and target text classification information; The comparison text, target text, and target text classification information are preprocessed to obtain a text sequence; Based on the target model, semantic enhancement representation is performed on each character in the text sequence to obtain a character vector sequence, which contains a character representation vector corresponding to each character. Each character representation vector is fused and transformed with the features of the character vector sequence during bidirectional propagation to obtain the label scoring sequence corresponding to each character representation vector; Based on multiple label categories and the label scores corresponding to each label category in each label scoring sequence, a target label path is determined. The target label path is used to instruct the target model to output a target label sequence. The target label sequence at least includes text association labels, text classification labels, and text body information of the target text relative to the comparison text. The target model is obtained by training a preset model by comparing the output of the sample text sequence with the sample label sequence. The sample text sequence is obtained by preprocessing the sample comparison text, the sample target text, and the sample target text classification information. The sample label sequence includes the sample association label of the sample target text relative to the sample comparison text, the sample text classification label, and the sample text main information.

2. The method according to claim 1, characterized in that, The target model includes an encoding layer, wherein semantically enhanced representation is performed on each character in the text sequence to obtain a character vector sequence, including: The text sequence is processed by vector embedding through the encoding layer to obtain an embedding vector sequence, which contains the embedding representation vector corresponding to each character. Based on the bidirectional features of each embedding representation vector in the embedding vector sequence, each embedding representation vector is encoded to obtain a character vector sequence with semantically enhanced representation.

3. The method according to claim 2, characterized in that, The target model further includes a bidirectional memory network layer connected to the encoding layer. The process of fusing and transforming the features of each character representation vector and the character vector sequence during bidirectional propagation to obtain a label-score sequence corresponding to each character representation vector includes: The bidirectional memory network layer is used to perform forward propagation on each character representation vector in the character vector sequence to obtain the context feature corresponding to each character representation vector. By backpropagating each character representation vector in the character vector sequence, the context feature corresponding to each character representation vector is obtained; Each character representation vector is fused with its corresponding preceding context feature and its corresponding following context feature to obtain the fused feature corresponding to each character representation vector; The fused features are linearly transformed to obtain the label score sequence corresponding to each character representation vector.

4. The method according to claim 3, characterized in that, The target model further includes a classification layer connected to the bidirectional memory network layer. The determination of the target label path based on multiple label categories in each label scoring sequence and the label score corresponding to each label category includes: The classification layer combines any selected tag category in each tag scoring sequence according to the character sorting relationship of the text sequence to obtain multiple candidate tag paths, each candidate tag path containing the tag category of each character; Based on multiple tag categories in each tag scoring sequence and the tag score corresponding to each tag category, determine the tag score for each tag category indicated in each candidate tag path; Calculate the path score of the corresponding candidate label path based on the label score of each label category indicated in each candidate label path and the category transfer relationship between adjacent label categories; The target label path is determined from the plurality of candidate label paths based on the path score.

5. The method according to claim 4, characterized in that, The step of calculating the path score for each candidate label path based on the label score of each label category indicated in each candidate label path and the category transfer relationship between adjacent label categories includes: Calculate the tag status score corresponding to each candidate tag path based on the tag scores in each of the tag scoring sequences; The label transition score is determined based on the state transition relationship between multiple label categories in each candidate label path; Calculate the path score based on the label status score and label transition score corresponding to each candidate label path.

6. The method according to claim 1, characterized in that, The step of preprocessing the comparison text, target text, and target text classification information to obtain a text sequence includes: The comparison text, the target text, and the target text classification information are concatenated to obtain the concatenated text. The concatenated text is segmented to obtain a text sequence.

7. The method according to any one of claims 1 to 6, characterized in that, include: Obtain sample comparison text, sample target text, and sample target text classification information; The sample text sequence is obtained by preprocessing the sample comparison text, sample target text, and sample target text classification information. The sample text sequence is input into a preset model, and multiple candidate label paths generated by the preset model when processing the sample text sequence are obtained; Obtain a sample label sequence, and instruct the preset model to select a target candidate label path from the plurality of candidate label paths according to the sample label sequence, so as to output a target predicted label sequence; A target loss function is constructed based on the proportion of path scores of the target predicted label sequence, and the preset model is iteratively trained based on the target loss function until convergence is obtained to obtain the trained target model.

8. The method according to claim 7, characterized in that, The construction of the target loss function based on the proportion of path scores in the target predicted label sequence includes: Determine the predicted label state score and predicted label transition score for each candidate label path, and calculate the candidate path score for the corresponding candidate label path based on the predicted label state score and predicted label transition score. Determine the total candidate path score corresponding to the multiple candidate path scores, and query the target path score corresponding to the target prediction label sequence from the multiple candidate path scores; A target loss function is constructed based on the weight ratio between the target path score and the total score of the predicted candidate paths.

9. The method according to claim 8, characterized in that, The determination of the predicted label state score and predicted label transition score for each candidate label path includes: Obtain the predicted label score sequence when the preset model processes each character in the sample text sequence. The predicted label score sequence includes multiple predicted label categories and the predicted category score corresponding to each predicted label category. Determine the target predicted label category corresponding to each character in each candidate label path, and calculate the predicted label state score of the corresponding candidate label path based on the predicted category score corresponding to each target predicted label category; Determine the category transfer score between any two adjacent target predicted label categories in each candidate label path, and calculate the predicted label transfer score of the corresponding candidate label path based on the multiple category transfer scores.

10. A text recognition device, characterized in that, include: The acquisition unit is used to acquire the comparison text, the target text, and the target text classification information. The preprocessing unit is used to preprocess the comparison text, target text, and target text classification information to obtain a text sequence; The recognition unit is configured to perform semantic enhancement representation on each character in the text sequence based on the target model to obtain a character vector sequence, wherein the character vector sequence contains a character representation vector corresponding to each character; fuse and transform each character representation vector with the features of the character vector sequence in bidirectional propagation to obtain a label scoring sequence corresponding to each character representation vector; determine a target label path based on multiple label categories in each label scoring sequence and the label score corresponding to each label category, wherein the target label path is used to instruct the target model to output a target label sequence; the target label sequence at least includes text association labels, text classification labels, and text subject information of the target text relative to the comparison text. The target model is obtained by training a preset model by comparing the output of the sample text sequence with the sample label sequence. The sample text sequence is obtained by preprocessing the sample comparison text, the sample target text, and the sample target text classification information. The sample label sequence includes the sample association label of the sample target text relative to the sample comparison text, the sample text classification label, and the sample text main information.

11. A computer device, characterized in that, It includes a processor and a memory, the memory storing a computer program, and the processor running the computer program in the memory to implement the steps of the text recognition method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the steps of the text recognition method according to any one of claims 1 to 9.

13. A computer program product, characterized in that, It includes computer instructions that, when executed, implement the steps of the text recognition method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Event subject identification method and device, electronic equipment, medium and program

    CN113591467A

  • Text classification model training method and device, text classification method and device, equipment and medium

    CN114741517A