A text recognition model training method, a text recognition method, and related devices

By constructing an initial text recognition model and using multiple base models to make multiple predictions on the training text and labeled text, and aggregating the soft label results to adjust the parameters, the problem of noise data influence in the security industry is solved, improving the accuracy and robustness of text recognition, and making it suitable for entity extraction from security knowledge graphs.

CN116821671BActive Publication Date: 2026-03-03ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310435928.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-12
Publication Date
2026-03-03
Estimated Expiration
2043-04-12

AI Technical Summary

Technical Problem

In industries with high confidentiality requirements, such as security, it is difficult to obtain a large amount of labeled data for training named entity recognition models. This results in noisy data affecting model training and reducing text recognition accuracy.

Method used

By constructing an initial text recognition model, multiple base models are used to make multiple predictions on the training text and the labeled text. The multiple prediction results are aggregated as soft label results, and the model parameters are adjusted based on the loss between the soft label results and the prediction results to reduce the impact of noisy data.

Benefits of technology

It improves the robustness of the text recognition model, prevents overfitting to noisy labels, and obtains more accurate prediction results, making it suitable for entity extraction from security knowledge graphs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116821671B_ABST
    Figure CN116821671B_ABST
Patent Text Reader

Abstract

The application discloses a text recognition model training method, a text recognition method and related devices, and the text recognition model training method comprises the following steps: obtaining training text and label text of the training text; inputting the training text and the label text into a text recognition initial model, extracting the correlation between the training text and the label text, and obtaining a plurality of prediction results; aggregating the plurality of prediction results to obtain a soft label result; and adjusting the text recognition initial model based on the loss between the soft label result and the prediction result. In the foregoing manner, the application can reduce the influence of noise data on model training and improve the text recognition accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a text recognition model training method, a text recognition method, and related apparatus. Background Technology

[0002] Entities are the basic units of knowledge graphs and important information carriers in text. Entity extraction is an important and fundamental task in natural language processing, and a subtask of information extraction. Its purpose is to extract predefined entity information from text data.

[0003] Generally, it's assumed that a sufficient amount of labeled data is available to train a NER (Named Entity Recognition) model. For example, in the encoding stage, a pre-trained BERT (Bidirectional Encoder Representation from Transformers) model is used, fine-tuned on the training set to obtain the representation of each character in the sentence within the embedding space. In the decoding stage, a CRF (Conditional Random Field) model is used to train the label transition probabilities, thereby obtaining the label for each character in the text. Because natural language text has contextual dependencies, most NER methods are time-series based, such as Recurrent Neural Networks (RNNs, LSTMs). These NER methods require a large amount of high-quality labeled data, but in practical applications, especially in high-secrecy environments like security, it's difficult to obtain a large amount of labeled data for training. Furthermore, data augmentation can easily introduce labeling errors, i.e., noisy labels. Summary of the Invention

[0004] The main technical problem solved by this invention is to provide a text recognition model training method, a text recognition method and related apparatus, which can reduce the impact of noisy data on model training and improve the accuracy of text recognition.

[0005] To solve the above-mentioned technical problems, one technical solution adopted by the present invention is: to provide a text recognition model training method, which includes: obtaining training text and label text of the training text; inputting the training text and label text into an initial text recognition model, extracting the correlation between the training text and the label text, and obtaining multiple prediction results; aggregating the multiple prediction results to obtain soft label results; and adjusting the initial text recognition model based on the loss between the soft label results and the prediction results.

[0006] The initial text recognition model includes multiple base models. The training text and the label text are input into the initial text recognition model to extract the correlation between the training text and the label text, and obtain multiple prediction results. The model uses multiple base models to extract the correlation between the training text and the label text, and obtains multiple prediction results. Different base models have different initialization parameters.

[0007] The process involves extracting the correlation between training text and label text using multiple base models to obtain multiple prediction results, including: extracting the correlation matrix between training text and label text using the neural network layers of the base models; calculating the label score of each label text using the correlation matrix; obtaining the label text with the highest score and the highest label score to obtain the prediction result of the corresponding base model.

[0008] Among them, adjusting the initial text recognition model based on the loss between the soft label results and the prediction results also includes: obtaining the task loss of the initial text recognition model for prediction, and the consistency loss between the soft label results and the prediction results; and adjusting the initial text recognition model by combining the task loss and the consistency loss.

[0009] The task loss for obtaining the initial text recognition model for prediction includes: calculating the task loss of each base model using the label scores of each labeled text and the label text with the highest score; weighting the task losses of multiple base models to obtain the task loss for the initial text recognition model for prediction; the task loss of the base model includes the sum of the task scores of each character in the training text, the task score of each character is the sum of the task scores of each labeled text in the character, the task score of the label text with the highest score is the highest label score minus one, and the task score of the label text that is not the highest score is the label score.

[0010] The consistency loss between the soft label results and the prediction results includes: calculating the relative entropy using the difference between the soft label results and each prediction result to obtain the consistency loss.

[0011] The process of adjusting the initial text recognition model by combining task loss and consistency loss includes: weighting and summing the task loss and consistency loss to obtain the joint loss; and using the joint loss to adjust the initial text recognition model.

[0012] The process of obtaining training text and its label text includes: obtaining training text and performing BIO annotation on the training text to obtain annotation labels; and expanding the annotation labels into natural language form to obtain label text.

[0013] The process of aggregating multiple prediction results to obtain soft label results includes: averaging multiple prediction results to obtain soft label results.

[0014] To solve the above-mentioned technical problems, another technical solution adopted by the present invention is to provide a text recognition method, which further includes: acquiring target text containing entity characters; inputting the target text into a text recognition model for entity character recognition, wherein the text recognition model is trained by the above-mentioned text recognition model training method on the initial text recognition model training method.

[0015] The text recognition model includes multiple base models. Entity text recognition involves using these base models to predict entity text in the target text and obtaining multiple predicted labels.

[0016] To solve the above-mentioned technical problems, another technical solution adopted by the present invention is to provide a data device, which includes a processor for executing the above-mentioned text recognition model training method or text recognition method.

[0017] To solve the above-mentioned technical problems, another technical solution adopted by the present invention is to provide a computer-readable storage medium for storing instruction / program data, which can be executed to implement the above-mentioned text recognition model training method or text recognition method.

[0018] The beneficial effects of this invention are as follows: Unlike existing technologies, this invention utilizes an initial text recognition model to make multiple predictions on text and label data, obtaining multiple prediction results. These multiple prediction results are then aggregated into a single soft label result. The parameters of the initial text recognition model are adjusted using the loss between the soft label result and the multiple prediction results, ensuring that the initial text recognition model produces similar prediction results across multiple predictions. This is equivalent to a soft pruning method, reducing the impact of noisy data on model training and preventing the model from overfitting to noisy labels. The text recognition model trained using this method exhibits high robustness in text prediction and can obtain more accurate prediction results. Attached Figure Description

[0019] Figure 1 This is a flowchart illustrating one implementation method of the text recognition model training method of this application;

[0020] Figure 2 This is a flowchart illustrating another implementation of the text recognition model training method of this application;

[0021] Figure 3 This is a flowchart illustrating a specific implementation method of the text recognition model training method of this application;

[0022] Figure 4 This is a schematic diagram of the structure of the initial text recognition model of this application;

[0023] Figure 5This is a schematic diagram of the prediction process using the base model in this application;

[0024] Figure 6 This is a flowchart illustrating one embodiment of the text recognition method of this application;

[0025] Figure 7 This is a schematic diagram of the structure of the text recognition model training device in the embodiments of this application;

[0026] Figure 8 This is a schematic diagram of the structure of the data device in the embodiments of this application;

[0027] Figure 9 This is a schematic diagram of the structure of a computer-readable storage medium in an embodiment of this application. Detailed Implementation

[0028] To make the objectives, technical solutions, and effects of the present invention clearer and more explicit, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.

[0029] This application provides a text recognition model training method. By using an initial text recognition model to make multiple predictions on text data and label data, multiple prediction results are obtained. These multiple prediction results are aggregated into a soft label result. The parameters of the initial text recognition model are adjusted using the loss between the soft label result and the multiple prediction results, so that the initial text recognition model has similar prediction results in multiple predictions. This is equivalent to a soft pruning method, which reduces the impact of noisy data on model training and prevents the model from overfitting to noisy labels. The text recognition model trained using this method has high robustness in text prediction and can obtain more accurate prediction results.

[0030] Please see Figure 1 , Figure 1 This is a flowchart illustrating one implementation method of the text recognition model training method of this application. It should be noted that if substantially the same result is obtained, this embodiment does not necessarily reflect that result. Figure 1 The illustrated process sequence is limited. For example... Figure 1 As shown, this embodiment includes:

[0031] S110: Obtain the training text and the label text of the training text.

[0032] A training set is constructed, consisting of training text and labeled text. First, text is obtained from a text corpus, with each sentence serving as a training text. The characters in the training text are manually labeled to obtain the corresponding labeled text.

[0033] S130: Input the training text and label text into the initial text recognition model, extract the correlation between the training text and the label text, and obtain multiple prediction results.

[0034] This application constructs an initial text recognition model, extracts features from the training text and label text using this model, and detects the correlation between the two features. Based on the correlation data, a prediction result is selected from the label text for each character in the training text. After multiple predictions, multiple prediction results are obtained for each character. Due to the potential influence of noisy data, the multiple prediction results may differ.

[0035] S150: Aggregate multiple prediction results to obtain soft label results.

[0036] Multiple prediction results for each character are aggregated to obtain the soft label result for each character. The soft label result is used to characterize the general level of the initial text recognition model's recognition result for each character.

[0037] S170: Adjust the initial text recognition model based on the loss between the soft label results and the prediction results.

[0038] The larger the gap between the soft-label result and each prediction result, the greater the fluctuation in the prediction results of the initial text recognition model, leading to inaccurate predictions. Conversely, the smaller the gap between the soft-label result and each prediction result, the smaller the fluctuation in the prediction results of the initial text recognition model, resulting in more accurate predictions. Therefore, based on the loss between the soft-label result and the prediction result, this loss is minimized to adjust the parameters in the initial text recognition model, so that multiple prediction results are closer.

[0039] In this implementation, multiple predictions are made on the text and label data using the initial text recognition model, resulting in multiple prediction results. These multiple prediction results are then aggregated into a single soft label result. The parameters of the initial text recognition model are adjusted using the loss between the soft label result and the multiple prediction results, ensuring that the initial text recognition model produces similar prediction results in multiple predictions. This is equivalent to a soft pruning method, which reduces the impact of noisy data on model training and prevents the model from overfitting to noisy labels. The text recognition model trained using this method exhibits high robustness in text prediction and can obtain more accurate prediction results.

[0040] The text recognition initial model of this application includes multiple base models, each with different initialization parameters. The correlation between the training text and the label text is extracted using the multiple base models to obtain multiple prediction results.

[0041] Please see Figure 2 , Figure 2 This is a flowchart illustrating another implementation of the text recognition model training method of this application. It should be noted that if substantially the same result is obtained, this embodiment does not necessarily reflect that outcome. Figure 2 The illustrated process sequence is limited. For example... Figure 2As shown, this embodiment includes:

[0042] S210: Obtain the training text and the label text of the training text.

[0043] First, obtain the training text, perform BIO annotation on each character in the training text to obtain the annotation label. The annotation label is a single letter or English abbreviation. Expand the annotation label into natural language form to obtain the tagged text with semantic information.

[0044] S230: Input the training text and the label text into the base model of the initial text recognition model, and use multiple base models to extract the correlation between the training text and the label text to obtain multiple prediction results.

[0045] Each base model includes two encoders: a document encoder and a label encoder. These can be pre-trained language models such as BERT. The document encoder encodes each character in the training text, resulting in a sequence of text vectors. The label encoder encodes each category in the labeled text, resulting in a sequence of label vectors.

[0046] The correlation matrix between training text and label text is extracted using a neural network layer of the base model. Specifically, a neural network layer is constructed to represent the relationship between two vectors. This layer measures the correlation between the text vector of each character in the training text and the label vector of each category in the label text, resulting in a correlation matrix. The label score for each label text is then calculated using this correlation matrix. The label text with the highest score and the highest label score are obtained, corresponding to the prediction result of the base model. This prediction result includes the label category and probability of each label category for each character in the base model.

[0047] Because each base model has different parameters, when there is noisy data in the training text and / or label text, the prediction results obtained by each base model will differ.

[0048] S250: Aggregate multiple prediction results to obtain soft label results.

[0049] Using the method described above, each base model obtains the label probability corresponding to each character in the training text, and a soft label result is calculated for each character. Specifically, the average label probability of the character in each base model is calculated to obtain the soft label result corresponding to the character. This soft label result is used to characterize the prediction accuracy of the entire model and represents the general level of prediction accuracy of multiple base models.

[0050] S270: Adjust the initial text recognition model based on the loss between the soft label results and the prediction results.

[0051] The loss between the soft-label results and the predicted results includes the consistency loss between them. The consistency loss is calculated using the difference between the soft-label results and the predicted results of each base model. This consistency loss characterizes the overall level of the base models, i.e., the degree of fluctuation in the predictions made by each base model. A larger consistency loss indicates a greater difference between the predicted results of each base model and the average level, resulting in lower prediction accuracy.

[0052] In another implementation, the loss between the soft-label result and the prediction result also includes the task loss of the initial text recognition model. The task loss of each base model is calculated separately. Specifically, first, the task score of a character is calculated. The task score of a character is the sum of the task scores of all the labeled texts within that character. The task score of the highest-scoring labeled text is the highest label score minus one, and the task score of the other labeled texts is their respective label scores. The task scores of each character are summed to obtain the task score of that base model, which serves as its task loss. The task losses of multiple base models are then weighted and averaged to obtain the task loss of the initial text recognition model. This task loss is used to characterize the prediction accuracy of each base model itself.

[0053] In the embodiments of this application, the initial text recognition model can be adjusted based on task loss, consistency loss, or a combination of task loss and consistency loss. Specifically, by minimizing task loss, or minimizing consistency loss, or minimizing the weighted sum of task loss and consistency loss to adjust the parameters in the initial text recognition model, the text recognition model trained using this method exhibits high robustness in text prediction, and the predicted results are closer to the true category.

[0054] In this implementation, multiple base models with different parameters are set. The initial text recognition model is used to make multiple predictions on the text data and label data in the multiple base models to obtain multiple prediction results. The parameters of the initial text recognition model are adjusted by the task loss inside the base model to improve the prediction accuracy of the base model. Then, the multiple prediction results are aggregated into a soft label result. The parameters of the initial text recognition model are adjusted by the consistency loss between the soft label result and the multiple prediction results to ensure that the multiple base models have similar prediction results. At the same time, it is equivalent to a soft pruning method, which reduces the impact of noisy data on model training and prevents the model from overfitting to noisy labels, so as to obtain more accurate prediction results.

[0055] Entities are the basic units of knowledge graphs and important information carriers in text. Entity extraction is an important and fundamental task in natural language processing, and a subtask of information extraction. Its purpose is to extract predefined entity information from text data. Therefore, entity extraction based on security scenarios is a crucial link in the construction of security knowledge graphs. The basic description of the Named Entity Recognition (NER) task is: given a text, identify meaningful text fragments of interest from an industry perspective, including their location and type within the text.

[0056] For example, in the security industry, if we want to search for "males who were on the same flight as Wang Ming on April 30th" from a constructed image library, we first need to extract meaningful entities from this text to fill the corresponding slots. "April 30th" is a time-type entity, "Wang Ming" is a name entity, and "same flight" is a specific behavior entity. Therefore, a text recognition model can be constructed for entity recognition. This application first constructs an initial text recognition model and trains it to obtain a text recognition model.

[0057] Specifically, please refer to Figure 3 , Figure 3 This is a flowchart illustrating a specific implementation of the text recognition model training method of this application. It should be noted that if substantially the same result is obtained, this embodiment does not necessarily reflect that result. Figure 3 The illustrated process sequence is limited. For example... Figure 3 As shown, this embodiment includes:

[0058] S310: Construct the training set.

[0059] The training set consists of labeled training text. First, text data is obtained from a security scenario text corpus, with sentences as training text. Characters in the training text are labeled using the BIO format, where "B" and "O" precede the entity type label, respectively indicating the beginning and interior of the entity, and "O" indicates that the character does not belong to an entity. The annotations are manually modified to natural language form, such as "PER" becoming "person" and "LOC" becoming "location". Then, the BIO labels are also modified to natural language form: "B" becomes "begin", "I" becomes "inside", and "O" becomes "other". Therefore, "B-PER" becomes "begin person". This modified natural language form is used as the labeled text. This labeled text has semantic information and can be used for semantic recognition. If there are N types of entities in the training text, there are 2N+1 labeled texts. Therefore, the labeled text has semantic information and must be similar to the semantic representation of the entity, rather than being similar to most of the sample data.

[0060] S330: Construct an initial text recognition model and perform entity prediction on the data in the training set.

[0061] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of the initial text recognition model of this application. The initial text recognition model of this application includes multiple base models, each with different initialization parameters. The correlation between the training text and the label text is extracted using these multiple base models, resulting in multiple prediction results. For details, please refer to [link to relevant documentation]. Figure 5 , Figure 5 This is a schematic diagram of the prediction process using the base model in this application.

[0062] S510: Encode the training text using a document encoder to generate a sequence of text vectors.

[0063] The base model includes two encoders: a document encoder and a tag encoder. In this implementation, a BERT pre-trained language model is used as the document encoder. For each character in a text, the document encoder encodes it to obtain the character's embedding vector. Let the text of length n be X = (x1, x2, ..., x...). n After being encoded by the document encoder, a text vector sequence (e1, e2, ..., e) is generated. n ).

[0064] S530: Use a tag encoder to encode the tag text and generate a tag vector sequence.

[0065] Similarly, a BERT pre-trained language model is used as the tag editor. For each tag, a tag encoder is used to encode it, obtaining the tag embedding vector. The tag text with 2N+1 tags is denoted as Y = (y1, y2, ..., y...). 2N+1 After being encoded by the tag encoder, the generated tag vector sequence is (l1, l2, ..., l 2N+1 ).

[0066] S550: Construct a fully connected network to calculate the relationship score between the text vector and each label vector, and select the label category with the highest score.

[0067] For a base model, the text vector e that measures the i-th character is... i The correlation between each labeled text and its corresponding label is used to output a label score. Specifically, a neural network layer is constructed to represent the relationship between two vectors. This neural network layer measures the correlation between the text vector of each word in the training text and the label vector of each category in the labeled text, resulting in a correlation matrix.

[0068] v(l j,e i )=f(l j T M [k] e i ),

[0069] Where f is the activation function, M [k] Let e ​​be the parameter matrix. i Let l be the text vector of the i-th character. j Let be the label vector of the j-th label text. Add a fully connected layer and use the sigmoid activation function to calculate the label score:

[0070] r ji =sigmoid(W r v(l j ,e i )+b r ),

[0071] Where W is the parameter matrix. r b r r is a coefficient ji Calculate the tag score for the i-th character in the j-th tag text. Calculate the tag category with the highest tag score:

[0072]

[0073] Using the above method, the label category with the highest label score for each base model is calculated. When the initial text recognition model includes M base models, the label text sequence with the highest label score among the M base models is (y1, y2, ..., y...). M ).

[0074] S350: Aggregates the predictions from multiple base models into a single soft-label result.

[0075] Using the above method, each base model obtains the label probability corresponding to each character in the training text, and calculates a soft label result for each character. Specifically, the average of the label probabilities of the character's label category in each base model is used to obtain the soft label result corresponding to that character. The prediction structure of the k-th base model is as follows: When there are M base models, their prediction results are combined as follows: The average of the prediction results is calculated to obtain a soft label result:

[0076] The soft-label results represent the general results of all base model predictions.

[0077] S370: Calculate the relative entropy between the prediction results of the base model and the soft-label results, and construct the consistency loss.

[0078] like Figure 5 As shown, the difference between the prediction results of each base model and the soft label is calculated based on KL divergence (Kullback-Leibler divergence, relative entropy), and a consistency loss function is constructed as follows:

[0079]

[0080]

[0081] S390: Construct a task loss and combine it with a consistency loss to train an initial text recognition model.

[0082] like Figure 5 As shown, the task loss of each base model is constructed using the real labeled text of each base model. When the j-th label text is the label category with the highest score for the i-th character label... The value is 1 when the tag category with the highest score is not the tag category with the j-th character text. The value is 0. The task loss of the initial text recognition model is obtained by weighted averaging of the task losses of multiple base models. Specifically, the task loss function is:

[0083] Weighted summation of task loss and consistency loss yields the joint loss as follows:

[0084] L = L sup +γL agg .

[0085] Backpropagation is performed with the goal of minimizing the joint loss function to calculate the gradient. At the same time, the learnable parameters of the M base models are updated, and the trained model parameters are saved to obtain the text recognition model.

[0086] In this implementation, natural language labels are used as label data. Since the name of the label contains the semantic information represented by the category, it provides additional information for the model when the amount of data is insufficient. Furthermore, by utilizing the semantic similarity between the label and the text data, the sample distribution is more similar when calculating the similarity in the subsequent similarity calculation, so as to make the prediction results more accurate.

[0087] Simultaneously, the initial text recognition model is used to make multiple predictions on both text and label data across multiple base models, yielding multiple prediction results. The parameters of the initial text recognition model are adjusted using the task loss within each base model, improving its prediction accuracy. These multiple prediction results are then aggregated into a single soft label result. A collaborative regularization method is used to adjust the parameters of the initial text recognition model based on the consistency loss between the soft label result and the multiple prediction results, ensuring similar prediction results across multiple base models. This also acts as a soft pruning method, reducing the impact of noisy data on model training and preventing overfitting to noisy labels, resulting in more accurate predictions. Furthermore, the use of learnable parameters in the neural network improves the neural network representation of cross-domain instances, thus exhibiting stronger domain adaptability. The text recognition model trained using this method demonstrates high robustness in text prediction and achieves more accurate results.

[0088] The trained text recognition model is used to identify entities in the text. For details, please refer to [link to relevant documentation]. Figure 6 , Figure 6 This is a flowchart illustrating one embodiment of the text recognition method of this application. It should be noted that if substantially the same result is obtained, this embodiment does not necessarily reflect that outcome. Figure 6 The illustrated process sequence is limited. For example... Figure 6 As shown, this embodiment includes:

[0089] S610: Obtain the target text containing entity text.

[0090] S630: Input the target text into the text recognition model for entity character recognition.

[0091] The M base models in the trained text recognition model are used to predict the entity text in the target text, resulting in M ​​predicted labels. The predicted label that appears most frequently is selected as the entity type of the entity text using a voting method.

[0092] In this embodiment, using the trained text recognition model described above to recognize the target text can yield more accurate entity text recognition results.

[0093] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a text recognition model training device according to an embodiment of this application. In this embodiment, the text recognition model training device includes an acquisition module 71, a prediction module 72, an aggregation module 73, and an adjustment module 74.

[0094] The text recognition model training device comprises several modules: an acquisition module 71 for acquiring training text and its label text; a prediction module 72 for inputting the training text and label text into the initial text recognition model, extracting the correlation between the training text and the label text, and obtaining multiple prediction results; and an aggregation module 73 for aggregating the multiple prediction results to obtain a soft label result. An adjustment module 74 is used to adjust the initial text recognition model based on the loss between the soft label result and the prediction results. This method involves using the initial text recognition model to make multiple predictions on text and label data, obtaining multiple prediction results, aggregating these multiple prediction results into a single soft label result, and adjusting the parameters of the initial text recognition model using the loss between the soft label result and the multiple prediction results. This ensures that the initial text recognition model produces similar prediction results in multiple predictions, essentially a soft pruning method. This reduces the impact of noisy data on model training, prevents the model from overfitting to noisy labels, and results in a text recognition model trained using this method that exhibits high robustness in text prediction and yields more accurate prediction results.

[0095] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of a data device according to an embodiment of this application. In this embodiment, the data device 81 includes a processor 82.

[0096] Processor 82 can also be referred to as a CPU (Central Processing Unit). Processor 82 may be an integrated circuit chip with signal processing capabilities. Processor 82 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor, or processor 82 can be any conventional processor.

[0097] Data device 81 may further include memory (not shown) for storing instructions and data required for the operation of processor 82.

[0098] The processor 82 is used to execute instructions to implement the methods provided by any embodiment of the text recognition model training method or text recognition method of the present application and any non-conflicting combination thereof.

[0099] Please see Figure 9 , Figure 9This is a schematic diagram of the structure of a computer-readable storage medium in an embodiment of this application. The computer-readable storage medium 91 in this embodiment stores instruction / program data 92. When executed, this instruction / program data 92 implements the methods provided by any embodiment of the text recognition model training method or text recognition method, and any non-conflicting combination thereof. The instruction / program data 92 can be formed into a program file and stored in the storage medium 91 in the form of a software product, so that a computer device (which may be a personal computer, server, or network device, etc.) or processor can execute all or part of the steps of the methods in various embodiments of this application. The aforementioned storage medium 91 includes various media capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, or terminal devices such as computers, servers, mobile phones, and tablets.

[0100] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.

[0101] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0102] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A method for training a text recognition model, characterized in that, The method includes: Obtain the training text and its label text; The training text and the label text are input into the initial text recognition model, and the correlation between the training text and the label text is extracted to obtain multiple prediction results; The initial text recognition model includes multiple base models. The process involves inputting the training text and the labeled text into the initial text recognition model, extracting the correlation between the training text and the labeled text, and obtaining multiple prediction results, including: The correlation between the training text and the label text is extracted using the multiple base models respectively to obtain the multiple prediction results. The different base models have different initialization parameters. The soft label result is obtained by aggregating multiple prediction results; Based on the loss between the soft label result and the prediction result, the parameters of the initial text recognition model are adjusted; The step of adjusting the parameters of the initial text recognition model based on the loss between the soft-label result and the prediction result includes: Obtain the task loss of the initial text recognition model for prediction, and the consistency loss between the soft label result and the prediction result; The initial text recognition model is adjusted by combining the task loss and the consistency loss. The task loss for obtaining the initial text recognition model for prediction includes: Calculate the task loss of each base model using the label scores of each labeled text and the label text with the highest label score; The task loss of the initial text recognition model is obtained by weighted averaging of the task losses of multiple base models. The task loss of the base model includes the sum of the task scores of each character in the training text, where the task score of each character is the sum of the task scores of each label text in the character, the task score of the label text with the highest label score is the highest label score minus one, and the task score of the label text without the highest score is the label score.

2. The text recognition model training method according to claim 1, characterized in that, The step of extracting the correlation between the training text and the labeled text using the multiple base models to obtain the multiple prediction results includes: The correlation matrix between the training text and the labeled text is extracted using the neural network layers of the base model; The tag score for each of the tag texts is calculated using the correlation matrix. Obtain the label text with the highest label score and the highest label score to get the prediction result of the corresponding base model.

3. The text recognition model training method according to claim 1, characterized in that, The consistency loss between the soft label acquisition result and the prediction result includes: The relative entropy is calculated using the difference between the soft label result and each of the prediction results to obtain the consistency loss.

4. The text recognition model training method according to claim 1, characterized in that, The adjustment of the initial text recognition model by combining the task loss and the consistency loss includes: The joint loss is obtained by weighted summing of the task loss and the consistency loss. The initial text recognition model is adjusted using the joint loss.

5. The text recognition model training method according to any one of claims 1-4, characterized in that, The acquisition of training text and the label text of the training text includes: Obtain the training text and perform BIO annotation on the training text to obtain annotation labels; The labels are expanded into natural language form to obtain the label text.

6. The text recognition model training method according to claim 1, characterized in that, Aggregating multiple prediction results to obtain soft label results includes: The soft label result is obtained by averaging the multiple prediction results.

7. A text recognition method, characterized in that, The method further includes: Retrieve the target text containing entity text; The target text is input into a text recognition model for entity character recognition. The text recognition model is obtained by training an initial text recognition model using the text recognition model training method according to any one of claims 1-6.

8. The text recognition method according to claim 7, characterized in that, The text recognition model includes multiple base models, and the entity text recognition process includes: The entity text in the target text is predicted using the multiple base models in the text recognition model to obtain multiple predicted labels; The predicted label that appears most frequently is selected as the entity type of the entity text.

9. A data device, characterized in that, The system includes a processor for executing instructions to implement the text recognition model training method as described in any one of claims 1-6 or the text recognition method as described in any one of claims 7-8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store instruction / program data that can be executed to implement the text recognition model training method as described in any one of claims 1-6 or the text recognition method as described in any one of claims 7-8.

Citation Information

Patent Citations

  • Text classification method and device, text processing method and device, computer equipment and storage medium

    CN114443847A

  • Aggregating results from named entity recognition services

    US20150154284A1