Text recognition model training method, text recognition method, medium, and device

By using a pre-trained language model to update the parameters of the text recognition model and optimizing based on the loss value, the problem of low accuracy caused by the lack of pre-set labels in traditional text sentiment analysis is solved, and efficient sentiment recognition and object information prediction are achieved.

CN115688903BActive Publication Date: 2026-02-06TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211347800.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-31
Publication Date
2026-02-06
Estimated Expiration
2042-10-31

AI Technical Summary

Technical Problem

In traditional text sentiment analysis, the accuracy of sentiment recognition results is low when sentiment labels are not pre-set for the text.

Method used

By acquiring a sample text training set, including sample text sequences, actual object information, actual ability information, and actual sentiment type, the parameters of the text recognition model are updated using a pre-trained language model, and the model parameters are optimized using the loss value until the training termination condition is met, thereby generating predicted object information, predicted ability information, and predicted sentiment type.

Benefits of technology

It improves the accuracy and efficiency of sentiment recognition in text, and can accurately predict the sentiment type and object information of text without pre-labeling object information and ability information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115688903B_ABST
    Figure CN115688903B_ABST
Patent Text Reader

Abstract

The application relates to a training method of a text recognition model. The method comprises the following steps: obtaining a sample text training set and an updated text recognition model; the sample text training set comprises a sample text sequence, actual object information, actual ability information and an actual emotion type of the sample text sequence; the updated text recognition model is obtained by updating model parameters in a text recognition model to be trained; the sample text training set is input into the updated text recognition model to obtain predicted object information, predicted ability information and a predicted emotion type of the sample text training set; and the updated text recognition model is trained according to differences between the actual object information and the predicted object information, differences between the actual ability information and the predicted ability information, and differences between the actual emotion type and the predicted emotion type, so as to obtain a trained text recognition model. The method can improve the emotion recognition accuracy of the text.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, in particular to a text recognition model training method, a text recognition method, a computer device, a storage medium and a computer program product. BACKGROUND

[0002] Text sentiment analysis, as an important technology in the field of natural language processing, is widely used in various e-commerce, news community and music platforms with online comment communities to help users understand the sentiment conveyed by the comments.

[0003] In the traditional technology, the sentiment of the text is usually recognized according to the association relationship between the text and the known sentiment label, but this method needs to set the sentiment label of the text in advance, and when the sentiment label of the text is not set in advance, the accuracy of the obtained sentiment recognition result is low. SUMMARY

[0004] Therefore, it is necessary to provide a text recognition model training method, a text recognition method, a computer device, a computer readable storage medium and a computer program product capable of improving the accuracy of text sentiment recognition to solve the above technical problems.

[0005] In a first aspect, the present application provides a text recognition model training method. The method comprises:

[0006] obtaining a sample text training set and an updated text recognition model; the sample text training set comprises a sample text sequence and actual object information, actual ability information and actual sentiment type of the sample text sequence; the updated text recognition model is obtained by updating model parameters in a text recognition model to be trained;

[0007] inputting the sample text training set into the updated text recognition model to obtain predicted object information, predicted ability information and predicted sentiment type of the sample text training set;

[0008] According to the differences between the actual object information and the predicted object information, the differences between the actual ability information and the predicted ability information, and the differences between the actual sentiment type and the predicted sentiment type, the updated text recognition model is trained to obtain a trained text recognition model.

[0009] In one embodiment, the updated text recognition model is obtained by the following method:

[0010] obtaining a pre-trained language model; the type of model parameters in the pre-trained language model is the same as the type of model parameters in the text recognition model to be trained;

[0011] According to the model parameters in the pre-trained language model, the model parameters in the text recognition model to be trained are updated to obtain an updated text recognition model.

[0012] In one of the embodiments, the model parameters in the pre-trained language model include text mapping parameters, semantic mapping parameters and character prediction parameters.

[0013] According to the model parameters in the pre-trained language model, the model parameters in the text recognition model to be trained are updated to obtain an updated text recognition model.

[0014] According to the text mapping parameters, the semantic mapping parameters and the character prediction parameters of the pre-trained language model, the text mapping parameters, the semantic mapping parameters and the character prediction parameters of the text recognition model to be trained are updated to obtain the updated text recognition model.

[0015] In one of the embodiments, the sample text training set is input into the updated text recognition model to obtain predicted object information, predicted ability information and predicted sentiment type of the sample text training set, including:

[0016] According to the text mapping parameters of the updated text recognition model, the sample text training set is subjected to text mapping processing to obtain a text vector of the sample text training set.

[0017] According to the semantic mapping parameters of the updated text recognition model, the text vector of the sample text training set is subjected to semantic mapping processing to obtain a semantic vector of the sample text training set.

[0018] According to the character prediction parameters of the updated text recognition model, the semantic vector of the sample text training set is subjected to character prediction processing to obtain predicted object information, predicted ability information and predicted sentiment type of the sample text training set.

[0019] In one of the embodiments, according to the difference between the actual object information and the predicted object information, the difference between the actual ability information and the predicted ability information, and the difference between the actual sentiment type and the predicted sentiment type, the updated text recognition model is trained to obtain a trained text recognition model, including:

[0020] According to the difference between the actual object information and the predicted object information, a first loss value is obtained, according to the difference between the actual ability information and the predicted ability information, a second loss value is obtained, and according to the difference between the actual sentiment type and the predicted sentiment type, a third loss value is obtained.

[0021] According to the first loss value, the second loss value and the third loss value, gradient updates are performed on text mapping parameters, semantic mapping parameters and character prediction parameters in the updated text recognition model respectively until a training end condition is reached.

[0022] The text recognition model that is updated again to reach the training end condition is taken as the trained text recognition model.

[0023] In one of the embodiments, a sample text training set is obtained, comprising:

[0024] A preset data interval symbol, the sample text sequence, and actual object information, actual capability information and actual sentiment type of the sample text sequence are obtained.

[0025] According to the preset data interval symbol, the sample text sequence, the actual object information, the actual capability information and the actual sentiment type are fused to obtain the sample text training set.

[0026] In a second aspect, the present application provides a text recognition method. The method comprises:

[0027] Obtaining a text to be recognized;

[0028] Inputting the text to be recognized into the trained text recognition model to obtain target object information, target capability information and target sentiment type of the text to be recognized as a sentiment analysis result of the text to be recognized; the trained text recognition model is obtained by training an updated text recognition model through a sample text training set; the sample text training set comprises a sample text sequence, actual object information, actual capability information and actual sentiment type of the sample text sequence; the updated text recognition model is obtained by updating model parameters in a text recognition model to be trained.

[0029] In one of the embodiments, inputting the text to be recognized into the trained text recognition model to obtain target object information, target capability information and target sentiment type of the text to be recognized comprises:

[0030] According to text mapping parameters of the trained text recognition model, performing text mapping processing on the text to be recognized to obtain a text vector of the text to be recognized;

[0031] According to semantic mapping parameters of the trained text recognition model, performing semantic mapping processing on the text to be recognized to obtain a semantic vector of the text to be recognized;

[0032] According to the character prediction parameter of the trained text recognition model, the semantic vector of the to-be-recognized text is subjected to character prediction processing, so as to obtain the target object information, the target capability information and the target sentiment type of the to-be-recognized text.

[0033] In a third aspect, the present application further provides a computer device. The computer device comprises a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0034] obtaining a sample text training set and an updated text recognition model; the sample text training set comprises a sample text sequence and actual object information, actual capability information and actual sentiment type of the sample text sequence; the updated text recognition model is obtained by updating model parameters in a to-be-trained text recognition model;

[0035] inputting the sample text training set into the updated text recognition model to obtain predicted object information, predicted capability information and predicted sentiment type of the sample text training set;

[0036] training the updated text recognition model according to differences between the actual object information and the predicted object information, between the actual capability information and the predicted capability information, and between the actual sentiment type and the predicted sentiment type, to obtain a trained text recognition model.

[0037] In a fourth aspect, the present application further provides a computer readable storage medium. The computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the following steps:

[0038] obtaining a sample text training set and an updated text recognition model; the sample text training set comprises a sample text sequence and actual object information, actual capability information and actual sentiment type of the sample text sequence; the updated text recognition model is obtained by updating model parameters in a to-be-trained text recognition model;

[0039] inputting the sample text training set into the updated text recognition model to obtain predicted object information, predicted capability information and predicted sentiment type of the sample text training set;

[0040] training the updated text recognition model according to differences between the actual object information and the predicted object information, between the actual capability information and the predicted capability information, and between the actual sentiment type and the predicted sentiment type, to obtain a trained text recognition model.

[0041] In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the following steps:

[0042] obtaining a sample text training set and an updated text recognition model; the sample text training set comprises sample text sequences and actual object information, actual ability information and actual sentiment types of the sample text sequences; the updated text recognition model is obtained by updating model parameters in a text recognition model to be trained;

[0043] inputting the sample text training set into the updated text recognition model to obtain predicted object information, predicted ability information and predicted sentiment types of the sample text training set;

[0044] training the updated text recognition model according to differences between the actual object information and the predicted object information, between the actual ability information and the predicted ability information, and between the actual sentiment types and the predicted sentiment types, to obtain a trained text recognition model.

[0045] The training method of the text recognition model, the computer device, the storage medium and the computer program product described above, obtain a sample text training set and an updated text recognition model; the sample text training set comprises sample text sequences and actual object information, actual ability information and actual sentiment types of the sample text sequences; the updated text recognition model is obtained by updating model parameters in a text recognition model to be trained, so that the updated text recognition model also has a high sentiment recognition accuracy without training; then the sample text training set is input into the updated text recognition model to obtain predicted object information, predicted ability information and predicted sentiment types of the sample text training set; the updated text recognition model is trained according to differences between the actual object information and the predicted object information, between the actual ability information and the predicted ability information, and between the actual sentiment types and the predicted sentiment types, to obtain a trained text recognition model, so that the trained text recognition model can not only predict the sentiment types of the text, but also predict the predicted object information and the predicted ability information of the text, without pre-labeling the object information and the ability information of the text, improving the sentiment recognition accuracy of the text while improving the sentiment recognition efficiency of the text. BRIEF DESCRIPTION OF DRAWINGS

[0046] Figure 1 a flowchart of a training method of a text recognition model of an embodiment;

[0047] Figure 2A schematic diagram of the principle of a training method of a text recognition model and a text recognition method in an embodiment;

[0048] Figure 3 A schematic diagram of the process of obtaining a sample text training set in an embodiment;

[0049] Figure 4 A schematic diagram of a text recognition method in an embodiment;

[0050] Figure 5 A schematic diagram of the process of obtaining a sentiment analysis result of a text to be recognized in an embodiment;

[0051] Figure 6 A schematic diagram of a training method of a text recognition model in another embodiment;

[0052] Figure 7 A schematic diagram of an application scenario of a text recognition method in an embodiment;

[0053] Figure 8 A schematic diagram of the hardware structure of a computer device in an embodiment. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.

[0055] In an embodiment, as shown in Figure 1 , a training method of a text recognition model is provided, and the present embodiment takes the method applied to a terminal as an example. It should be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is realized through the interaction of the terminal and the server. In the present embodiment, the method includes the following steps:

[0056] Step S101, obtaining a sample text training set and an updated text recognition model; the sample text training set includes a sample text sequence, and actual object information, actual ability information and actual sentiment type of the sample text sequence; the updated text recognition model is obtained by updating the model parameters in the text recognition model to be trained.

[0057] Among them, the sample text training set refers to a text data set used to train the text recognition model.

[0058] Among them, the sample text sequence refers to a sample text that needs to recognize object information, ability information and sentiment type, including a plurality of characters with an ordering relationship. For example, the sample text sequence is represented as X=[x1,...x N ]N N is the number of characters of the sample text sequence.

[0059] The actual object information refers to the object actually described by the sample text sequence. In other words, in order to distinguish from the object information recognized by the text recognition model (i.e., predicted object information) described below, the object described by the sample text sequence is referred to as actual object information.

[0060] The actual ability information refers to the ability of a certain aspect or a certain attribute of the object actually described by the sample text sequence. For example, it can be the creation ability, the shooting ability, or the singing ability of the object. In other words, in order to distinguish from the ability information recognized by the text recognition model (i.e., predicted ability information) described below, the ability information of the object described by the sample text sequence is referred to as actual ability information.

[0061] The actual sentiment type refers to the sentiment type actually represented by the sample text sequence. For example, the sentiment type can be positive, negative, or neutral. The sentiment type can also be represented using discrete values, such as [-1, 0, 1], where -1 represents a negative sentiment polarity, 0 represents a neutral sentiment polarity, and 1 represents a positive sentiment polarity. In other words, in order to distinguish from the sentiment type recognized by the text recognition model (i.e., predicted sentiment type) described below, the sentiment type represented by the sample text sequence is referred to as actual sentiment type.

[0062] For example, assume that the sample text sequence is "The song created by Zhang San is really top, leading the entire era!", where "Zhang San" belongs to the actual object information, "creation ability" belongs to the actual ability information, and the actual sentiment type is positive.

[0063] Specifically, the terminal obtains a sample text sequence, and actual object information, actual ability information, and actual sentiment type of the sample text sequence. The terminal performs data preprocessing on the sample text sequence, and the actual object information, the actual ability information, and the actual sentiment type of the sample text sequence to obtain a sample text training set. Further, the terminal updates model parameters in the text recognition model to be trained according to model parameters in the pre-trained language model to obtain an updated text recognition model.

[0064] The pre-trained language model refers to a language model that is of the same type as the model parameters of the text recognition model to be trained and has been trained. For example, the pre-trained language model and the text recognition model to be trained can both be language models based on a Transformer text generator, such as a GPT-2 (Language models are unsupervised multitask learners) language model, a CPM (Chinese pretrained model) model, or other one-way pre-trained language models.

[0065] The text recognition model refers to a model for generating object information, capability information, and sentiment types of text data.

[0066] The text recognition model to be trained refers to an untrained text recognition model.

[0067] The updated text recognition model refers to a text recognition model with updated model parameters.

[0068] In step S102, the sample text training set is input into the updated text recognition model to obtain predicted object information, predicted capability information, and predicted sentiment types of the sample text training set.

[0069] The predicted object information refers to an object described by the sample text sequence generated by the updated text recognition model.

[0070] The predicted capability information refers to an aspect or attribute of the object described by the sample text sequence generated by the updated text recognition model.

[0071] The predicted sentiment type refers to a sentiment type represented by the sample text sequence generated by the updated text recognition model.

[0072] Specifically, the terminal inputs the sample text training set into the updated text recognition model, and performs text generation processing on the sample text sequence in the sample text training set using the model parameters of the updated text recognition model, i.e., the model parameters of the pre-trained language model in step S102 above. The updated text recognition model performs text generation processing on the sample text sequence in the sample text training set using the model parameters of the pre-trained language model in step S102 above to obtain predicted object information, predicted capability information, and predicted sentiment types of the sample text sequence.

[0073] In step S103, the updated text recognition model is trained according to the differences between the actual object information and the predicted object information, the differences between the actual capability information and the predicted capability information, and the differences between the actual sentiment types and the predicted sentiment types to obtain a trained text recognition model.

[0074] The text recognition model trained refers to the text recognition model obtained after the updated text recognition model is iteratively trained.

[0075] Specifically, the loss values of the respective model parameters are constructed according to the differences between the actual object information and the predicted object information in the sample text training set, the differences between the actual ability information and the predicted ability information in the sample text training set, and the differences between the actual sentiment type and the predicted sentiment type in the sample text training set. The model parameters in the updated text recognition model are iteratively updated based on the loss values of the respective model parameters. When the updated text recognition model converges, the text recognition model trained is obtained.

[0076] Figure 2 For the principle of the training method and the text recognition method of the text recognition model, as shown in Figure 2 As shown, the aspect-level sentiment recognition task is converted into a text generation task. The sample text sequence, the actual object information, the actual ability information and the actual sentiment type of the sample text sequence are fused into a sample text training set through data preprocessing, i.e., the sample text training set can be regarded as a complete text data. The model parameters in the pre-trained language model are used to update the model parameters in the text recognition model to be trained to obtain an updated text recognition model. Then, the sample text training set is used to train the updated text recognition model to obtain a text recognition model trained.

[0077] It should be noted that the text recognition model in the present application is essentially a text generator (or a text generation model), i.e., the text recognition model is used to predict the text content (such as the predicted object information, the predicted ability information and the predicted sentiment type) after the sample text sequence. Further, the text recognition model in the present application generates the text information of the predicted sentiment type of the sample text sequence, and also achieves the function of recognizing the sentiment type of the sample text sequence.

[0078] In the training method of the text recognition model, a sample text training set and an updated text recognition model are obtained; the sample text training set includes a sample text sequence, actual object information, actual ability information, and an actual sentiment type of the sample text sequence; the updated text recognition model is obtained by updating model parameters in the text recognition model to be trained, so that the updated text recognition model also has a high sentiment recognition accuracy without training; then the sample text training set is input into the updated text recognition model to obtain predicted object information, predicted ability information, and a predicted sentiment type of the sample text training set; the updated text recognition model is trained according to differences between the actual object information and the predicted object information, between the actual ability information and the predicted ability information, and between the actual sentiment type and the predicted sentiment type, to obtain a trained text recognition model, so that the trained text recognition model can not only predict the sentiment type of the text, but also predict the predicted object information and the predicted ability information of the text, without pre-labeling the object information and the ability information of the text, thereby improving the sentiment recognition accuracy and efficiency of the text.

[0079] In one embodiment, the updated text recognition model is obtained by: obtaining a pre-trained language model; the types of model parameters in the pre-trained language model are the same as those of the text recognition model to be trained; and the model parameters in the text recognition model to be trained are updated according to the model parameters in the pre-trained language model to obtain the updated text recognition model.

[0080] Specifically, the terminal constructs a text recognition model to be trained; the terminal can directly obtain a pre-trained language model with the same type of model parameters as the text recognition model to be trained from a third-party platform or a database, or can first train a language model to be trained to obtain a pre-trained language model; then the values of the model parameters in the pre-trained language model are used to update the values of the model parameters in the text recognition model to be trained, that is, the pre-trained language model is used to initialize the text recognition model to be trained to obtain an updated text recognition model. It can be understood that by directly assigning the trained model parameters in the pre-trained language model to the model parameters in the untrained text recognition model to be trained, the text recognition model to be trained also has good text generation capability without training, and then performing model training on the updated text recognition model can further improve the performance of the trained text recognition model, thereby greatly improving the sentiment recognition accuracy of the trained text recognition model on the text to be recognized.

[0081] In an embodiment, the model parameters in the pre-trained language model include text mapping parameters, semantic mapping parameters, and character prediction parameters.

[0082] The text mapping parameters refer to mapping parameters capable of mapping text into a text vector. For example, the text mapping parameters can be a mapping function of an Embedding (embedding layer).

[0083] The semantic mapping parameters refer to mapping parameters capable of mapping a text vector into a semantic vector. For example, the semantic mapping parameters can be a mapping function of a multi-layer stacked neural network.

[0084] The character prediction parameters refer to mapping parameters capable of predicting the next character of a text vector. For example, the character prediction parameters can be a mapping function for character prediction in a Transformer text generator.

[0085] The step S102 updates the model parameters in the text recognition model to be trained according to the model parameters in the pre-trained language model to obtain an updated text recognition model, and specifically includes the following content: the text mapping parameters, the semantic mapping parameters, and the character prediction parameters in the text recognition model to be trained are updated according to the text mapping parameters, the semantic mapping parameters, and the character prediction parameters in the pre-trained language model, respectively, to obtain the updated text recognition model.

[0086] Specifically, the terminal extracts the text mapping parameters, the semantic mapping parameters, and the character prediction parameters from the pre-trained language model, and then updates the text mapping parameters in the text recognition model to be trained to the text mapping parameters in the pre-trained language model, updates the semantic mapping parameters in the text recognition model to be trained to the semantic mapping parameters in the pre-trained language model, and updates the character prediction parameters in the text recognition model to be trained to the character prediction parameters in the pre-trained language model, to obtain the updated text recognition model.

[0087] In this embodiment, the corresponding model parameters (text mapping parameters, semantic mapping parameters, and character prediction parameters) in the text recognition model to be trained are updated according to the text mapping parameters, the semantic mapping parameters, and the character prediction parameters in the pre-trained language model, respectively, to obtain the updated text recognition model, so that the updated text recognition model also has a high accuracy without training, thereby further improving the accuracy of the text recognition model processed by the text recognition model after training.

[0088] In one embodiment, the step S103 of inputting the sample text training set into the updated text recognition model to obtain the predicted object information, the predicted ability information and the predicted sentiment type of the sample text training set comprises the following contents: performing text mapping processing on the sample text training set according to the text mapping parameters of the updated text recognition model to obtain the text vector of the sample text training set; performing semantic mapping processing on the text vector of the sample text training set according to the semantic mapping parameters of the updated text recognition model to obtain the semantic vector of the sample text training set; and performing character prediction processing on the semantic vector of the sample text training set according to the character prediction parameters of the updated text recognition model to obtain the predicted object information, the predicted ability information and the predicted sentiment type of the sample text training set.

[0089] Specifically, the terminal converts each character in the sample text sequence in the sample text training set into a text vector through the text mapping parameters of the updated text recognition model; converts the text vector of the sample text sequence into a semantic vector of the sample text sequence through the semantic mapping parameters of the updated text recognition model; performs character prediction processing on the semantic vector of the sample text sequence through the character prediction parameters of the updated text recognition model to obtain the next character of the semantic vector of the sample text sequence; performs character prediction processing on the semantic vector of the sample text sequence and the next character of the semantic vector of the sample text sequence through the character prediction parameters of the updated text recognition model to obtain the character after the next character; and takes the character prediction processing result of the current round of character prediction processing and the input parameters as the input of the next round of character prediction processing until the updated text recognition model outputs the predicted object information of the sample text training set. Similarly, the semantic vector and the predicted object information are processed through the character prediction function to sequentially predict the characters of each ability information to obtain the predicted ability information. Finally, the semantic vector, the predicted object information and the predicted ability information are processed through the character prediction function to obtain the predicted sentiment type.

[0090] In actual application, it is assumed that the sample text sequence is represented as X = [x1,...xN], xN is the character of the sample text sequence, and N is the number of characters of the sample text sequence; it is assumed that the actual object information of the sample text sequence is represented as T = [t1,...t|T|], T represents a character sequence, t|T| is the character of the actual object information, and |T| is the number of characters of the actual object information; it is assumed that the actual ability information is represented as A = [a1,...a|A|], A represents a character sequence, a|A| is the character of the actual ability information, and |A| is the number of characters of the actual ability information; and it is assumed that the actual sentiment type is represented as S = [s1,...s|S|], S represents a character sequence, s|S| is the character of the actual sentiment type, and |S| is the number of characters of the actual sentiment type. N N ], x |T| |T| ], t |A| |A| ​​​|A| is the number of characters of the actual capability information; it is assumed that the actual sentiment type is represented as P e [-1, 0, 1], wherein -1 represents that the sentiment polarity of the sample text sequence is negative, 0 represents that the sentiment polarity of the sample text sequence is neutral, and 1 represents that the sentiment polarity of the sample text sequence is positive; and [X, T, A, P] is taken as a sample text training set.

[0091] The terminal takes the sample text training set [X, T, A, P] as an input of the updated text recognition model, and then converts each character in the sample text sequence X into a text vector through a semantic mapping function Emb() of the updated text recognition model. The text vector E can be obtained in the following manner:

[0092]

[0093] wherein d e represents the dimension of the text vector; represents a real number in a d e dimensional vector space.

[0094] The text vector E is converted into a semantic vector H through a semantic mapping function Enc() of the updated text recognition model. The semantic vector H can be obtained in the following manner:

[0095]

[0096] wherein d h represents the dimension of the semantic vector; represents a real number in a d h dimensional vector space.

[0097] The semantic vector H is subjected to character prediction processing through a character prediction function of the updated text recognition model to predict the probability of the next character. Since the sample text training set is [X, T, A, P], the predicted next character is the first character of T, which is marked as t'1. Then, the semantic vector H and t'1 are subjected to character prediction processing through the character prediction function again to predict the probability of the next character, i.e., the second character of T, which is marked as t'2. This process is repeated until the updated text recognition model predicts all the predicted object information T'. Similarly, the semantic vector H and the predicted object information T' are subjected to character prediction processing through the character prediction function to obtain predicted capability information A'. Finally, the semantic vector H, the predicted object information T', and the predicted capability information A' are subjected to character prediction processing through the character prediction function to obtain a predicted sentiment type P'.

[0098] In the embodiment, the sample text training set is subjected to text mapping processing according to the text mapping parameters of the updated text recognition model, to obtain a text vector of the sample text training set; the text vector of the sample text training set is subjected to semantic mapping processing according to the semantic mapping parameters of the updated text recognition model, to obtain a semantic vector of the sample text training set; the semantic vector of the sample text training set is subjected to character prediction processing according to the character prediction parameters of the updated text recognition model, to obtain the prediction object information, the prediction ability information and the prediction sentiment type of the sample text training set, so that the aspect-level sentiment recognition task of the sample text training set is reasonably converted into a text generation task, the trained text recognition model can not only predict the sentiment type of the text, but also predict the prediction object information and the prediction ability information of the text without pre-labeling the object information and the ability information of the text, thereby improving the sentiment recognition efficiency of the text, meanwhile, the error caused by processing the object information and the ability information by the model respectively is reduced, and the sentiment recognition accuracy of the text is further improved.

[0099] In one embodiment, the step S104 includes the following steps: obtaining a first loss value according to the difference between the actual object information and the prediction object information, obtaining a second loss value according to the difference between the actual ability information and the prediction ability information, and obtaining a third loss value according to the difference between the actual sentiment type and the prediction sentiment type; performing gradient update on the text mapping parameters, the semantic mapping parameters and the character prediction parameters in the updated text recognition model according to the first loss value, the second loss value and the third loss value respectively until a training end condition is reached; and taking the updated text recognition model that reaches the training end condition as the trained text recognition model.

[0100] The first loss value is a loss value calculated by a first loss function (a loss function for optimizing the text mapping parameters in the updated text recognition model).

[0101] The second loss value is a loss value calculated by a second loss function (a loss function for optimizing the semantic mapping parameters in the updated text recognition model).

[0102] The third loss value is a loss value calculated by a third loss function (a loss function for optimizing the character prediction parameters in the updated text recognition model).

[0103] Specifically, the terminal constructs a first loss value according to the difference between the actual object information and the predicted object information, constructs a second loss value according to the difference between the actual ability information and the predicted ability information, and constructs a third loss value according to the difference between the actual sentiment type and the predicted sentiment type; wherein the first loss value, the second loss value and the third loss value can be constructed based on a gradient descent optimization algorithm or a variant algorithm of the gradient descent optimization algorithm, such as an Adafactor (Adaptive Learning Rates with Sublinear Memory Cost) optimizer, an Adam (Adaptive Moment Estimation) optimizer. The terminal iteratively optimizes the text mapping parameters, the semantic mapping parameters and the character prediction parameters in the updated text recognition model according to the first loss value, the second loss value and the third loss value, until the iteratively optimized training text recognition model converges; the text recognition model at the time of model convergence is taken as the training completed text recognition model.

[0104] In the present embodiment, the first loss value is obtained according to the difference between the actual object information and the predicted object information, the second loss value is obtained according to the difference between the actual ability information and the predicted ability information, and the third loss value is obtained according to the difference between the actual sentiment type and the predicted sentiment type; the text mapping parameters, the semantic mapping parameters and the character prediction parameters in the updated text recognition model are respectively updated by gradient according to the first loss value, the second loss value and the third loss value, until the training end condition is reached; the text recognition model updated again when the training end condition is reached is taken as the training completed text recognition model, so that the training completed text recognition model learns the actual object information, the actual ability information and the actual sentiment type of the sample text training set, and further causes the training completed text recognition model to not only be able to predict the sentiment type of the text, but also be able to predict the predicted object information and the predicted ability information of the text, thereby improving the accuracy and efficiency of the training completed text recognition model in performing sentiment recognition on the text.

[0105] In one embodiment, the above step S101 of obtaining the sample text training set specifically includes the following contents: obtaining a preset data interval symbol, a sample text sequence and actual object information, actual ability information and actual sentiment type of the sample text sequence; performing fusion processing on the sample text sequence, the actual object information, the actual ability information and the actual sentiment type according to the preset data interval symbol, to obtain the sample text training set.

[0106] The data interval symbol is a symbol used to distinguish different character data in the sample text training set.

[0107] Specifically, the terminal acquires a preset data interval symbol, a sample text sequence, and actual object information, actual capability information, and an actual sentiment type of the sample text sequence; the terminal fuses the sample text sequence and the actual object information through the preset data interval symbol to obtain a first fusion result, fuses the first fusion result and the actual capability information through the preset data interval symbol again to obtain a second fusion result, and fuses the second fusion result and the actual sentiment type through the preset data interval symbol again to obtain a sample text training set.

[0108] Figure 3 For the flowchart of the step of acquiring the sample text training set, as shown in Figure 3 , the data interval symbol can be set as [sep], the terminal acquires a sample text sequence X = [x1,...x N ], actual object information T = [t1,...t |T| ] of the sample text sequence, actual capability information A = [a1,...a |A| ], and an actual sentiment type P, and then fuses X, T, A, and P in sequence through the data interval symbol [sep] to obtain a sample text training set S. The sample text training set S can be expressed in the following form:

[0109] S = X [sep] T [sep] A [sep] P

[0110] In this embodiment, a preset data interval symbol, a sample text sequence, and actual object information, actual capability information, and an actual sentiment type of the sample text sequence are acquired; the sample text sequence, the actual object information, the actual capability information, and the actual sentiment type are fused according to the preset data interval symbol to obtain a sample text training set, and the updated text recognition model is trained according to the sample text training set in subsequent steps, so that the trained text recognition model can learn the actual object information, the actual capability information, and the actual sentiment type of the sample text training set, thereby improving the accuracy and efficiency of the trained text recognition model in performing sentiment recognition on text.

[0111] In one embodiment, as shown in Figure 4 , a text recognition method is provided, and this embodiment takes the method applied to a terminal as an example. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through interaction between the terminal and the server. The method includes the following steps in this embodiment:

[0112] Step S401, acquiring a text to be recognized.

[0113] The text to be recognized refers to text data whose object information, capability information, and sentiment type need to be recognized.

[0114] Step S402, input the text to be recognized into the trained text recognition model to obtain the target object information, target ability information and target sentiment type of the text to be recognized as the sentiment analysis result of the text to be recognized; the trained text recognition model is obtained by training the updated text recognition model through the sample text training set; the sample text training set includes a sample text sequence, actual object information, actual ability information and actual sentiment type of the sample text sequence; the updated text recognition model is obtained by updating the model parameters in the text recognition model to be trained.

[0115] The target object information is the object described by the trained text recognition model for the text to be recognized.

[0116] The target ability information is an aspect or attribute of the object described by the trained text recognition model for the text to be recognized. For example, the ability information can be the creation ability, shooting ability or singing ability of the object.

[0117] The target sentiment type is the sentiment type represented by the text sequence to be recognized generated by the trained text recognition model. For example, the sentiment type can be positive, negative or neutral; the sentiment type can also be represented by discrete values, such as [-1, 0, 1], where -1 represents a negative sentiment polarity, 0 represents a neutral sentiment polarity, and 1 represents a positive sentiment polarity.

[0118] Specifically, the terminal obtains a sample text training set carrying a sample text sequence, actual object information, actual ability information and actual sentiment type of the sample text sequence, and trains the text recognition model to be trained through the sample text training set to obtain the trained text recognition model. Further, as shown in Figure 2 The terminal inputs the text to be recognized into the trained text recognition model for text generation processing to obtain the target object information, target ability information and target sentiment type of the text to be recognized, and the target object information, target ability information and target sentiment type are used as the sentiment analysis result of the text to be recognized.

[0119] Figure 5 As shown in Figure 5 , assuming that the text to be recognized S is "Zhang San's song is really top, leading the entire era!", the text to be recognized S is input into the trained text recognition model to obtain the sentiment analysis result output by the trained text recognition model sentiment analysis result The sentiment analysis result can be regarded as a text sequence The target object information The target ability information And the target sentiment type That is Wherein, is "Zhang San", is "creative ability", is 1, that is

[0120] The above text recognition method, by obtaining the text to be recognized; then the text to be recognized is input into the trained text recognition model, and the target object information, target ability information and target sentiment type of the text to be recognized are obtained as the sentiment analysis result of the text to be recognized; wherein the trained text recognition model is obtained by training the updated text recognition model through the sample text training set; the sample text training set includes sample text sequence, and actual object information, actual ability information and actual sentiment type of the sample text sequence; the updated text recognition model is obtained by updating the model parameters in the text recognition model to be trained. By using this method, the trained text recognition model can not only predict the sentiment type of the text, but also predict the predicted object information and predicted ability information of the text, without pre-labeling the object information and ability information of the text. The accuracy of the sentiment recognition of the text to be recognized is improved, and the efficiency of the sentiment recognition of the text to be recognized is also improved.

[0121] In one embodiment, the above step S402, the text to be recognized is input into the trained text recognition model, and the target object information, target ability information and target sentiment type of the text to be recognized are obtained, which specifically includes the following contents: according to the text mapping parameters of the trained text recognition model, the text to be recognized is subjected to text mapping processing to obtain the text vector of the text to be recognized; according to the semantic mapping parameters of the trained text recognition model, the text to be recognized is subjected to semantic mapping processing to obtain the semantic vector of the text to be recognized; according to the character prediction parameters of the trained text recognition model, the semantic vector of the text to be recognized is subjected to character prediction processing to obtain the target object information, target ability information and target sentiment type of the text to be recognized.

[0122] Specifically, the terminal converts each character in the text to be recognized into a text vector by using the text mapping parameter of the trained text recognition model; converts the text vector of the text to be recognized into a semantic vector by using the semantic mapping parameter of the trained text recognition model; performs character prediction processing on the semantic vector of the text to be recognized by using the character prediction parameter of the trained text recognition model, to obtain the next character of the semantic vector of the text to be recognized; performs character prediction processing on the semantic vector of the text to be recognized and the next character of the semantic vector of the text to be recognized by using the character prediction parameter of the trained text recognition model, to obtain the character after the next character; and in a manner of taking the character prediction processing result of the current round of character prediction processing and the input parameter as the input of the next round of character prediction processing, until the trained text recognition model outputs the target object information of the text to be recognized; similarly, the character prediction function is used to perform character prediction processing on the semantic vector of the text to be recognized and the target object information, to sequentially predict the characters of each capability information, and obtain the target capability information; and finally, the character prediction function is used to perform character prediction processing on the semantic vector of the text to be recognized, the target object information, and the target capability information, to obtain the target sentiment type.

[0123] In the embodiment, the text mapping parameter of the trained text recognition model is used to perform text mapping processing on the text to be recognized, to obtain a text vector of the text to be recognized; the semantic mapping parameter of the trained text recognition model is used to perform semantic mapping processing on the text to be recognized, to obtain a semantic vector of the text to be recognized; and the character prediction parameter of the trained text recognition model is used to perform character prediction processing on the semantic vector of the text to be recognized, to obtain the target object information, the target capability information, and the target sentiment type of the text to be recognized, thereby reasonably converting the aspect-level sentiment recognition task of the text to be recognized into a text generation task, enabling the trained text recognition model to not only predict the target sentiment type of the text to be recognized, but also predict the target object information and the target capability information of the text to be recognized, reducing errors caused by processing the object information and the capability information by the model respectively, and thereby improving the sentiment recognition accuracy of the text.

[0124] In one embodiment, as shown in Figure 6 Another method for training a text recognition model is provided, which is described by taking a terminal as an example and includes the following steps.

[0125] In step S601, a preset data interval symbol, a sample text sequence, and actual object information, actual capability information, and an actual sentiment type of the sample text sequence are obtained; the sample text sequence, the actual object information, the actual capability information, and the actual sentiment type are fused according to the preset data interval symbol, to obtain a sample text training set.

[0126] Step S602, respectively according to the text mapping parameters, the semantic mapping parameters and the character prediction parameters of the pre-trained language model, update the text mapping parameters, the semantic mapping parameters and the character prediction parameters of the text recognition model to be trained, and obtain an updated text recognition model.

[0127] Step S603, according to the text mapping parameters of the updated text recognition model, perform text mapping processing on the sample text training set, and obtain a text vector of the sample text training set.

[0128] Step S604, according to the semantic mapping parameters of the updated text recognition model, perform semantic mapping processing on the text vector of the sample text training set, and obtain a semantic vector of the sample text training set.

[0129] Step S605, according to the character prediction parameters of the updated text recognition model, perform character prediction processing on the semantic vector of the sample text training set, and obtain predicted object information, predicted ability information and predicted sentiment type of the sample text training set.

[0130] Step S606, according to the difference between the actual object information and the predicted object information, obtain a first loss value, according to the difference between the actual ability information and the predicted ability information, obtain a second loss value, and according to the difference between the actual sentiment type and the predicted sentiment type, obtain a third loss value.

[0131] Step S607, according to the first loss value, the second loss value and the third loss value, respectively update the gradient of the text mapping parameters, the semantic mapping parameters and the character prediction parameters in the updated text recognition model until a training end condition is reached.

[0132] Step S608, the text recognition model updated again that reaches the training end condition is taken as a trained text recognition model.

[0133] The above-mentioned text recognition model training method can achieve the following beneficial effects: (1) the updated text recognition model also has a high sentiment recognition accuracy without training; (2) the trained text recognition model can not only predict the sentiment type of the text, but also predict the predicted object information and the predicted ability information of the text, without pre-labeling the object information and the ability information of the text, which improves the sentiment recognition accuracy of the text and also improves the sentiment recognition efficiency of the text.

[0134] In order to more clearly illustrate the text recognition method provided by the embodiments of the present disclosure, the above-mentioned text recognition method is specifically described in the following specific embodiments. Another text recognition method is provided, which can be applied to a terminal and specifically includes the following contents:

[0135] Figure 7 As shown in the application scenario diagram of the text recognition method, Figure 7 The text recognition method in the present application can be applied in various e-commerce comment platforms, news comment communities, music comment platforms and other application scenarios with online comments. Users can input personal comments into a terminal according to the goods or works displayed on the terminal and display the comments on a comment page. The terminal obtains the comment text of the comment page, inputs the comment text into the trained text recognition model, obtains the target object information, target ability information and target emotion type of the comment text, and displays the target object information, target ability information and target emotion type as the comment summary of the comment text on the comment page for users to view.

[0136] In the present embodiment, the trained text recognition model can not only predict the target emotion type of the text to be recognized, but also predict the target object information and target ability information of the text to be recognized, reducing the errors caused by the model processing object information and ability information respectively, improving the accuracy of text emotion recognition, and extracting the target object information, target ability information and target emotion type of each comment text in the online comment application scenario to assist users to quickly understand the emotional preferences of other users and the core information of the comment text.

[0137] It should be understood that although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be alternately or alternately executed with at least part of other steps or steps or stages in other steps.

[0138] In one embodiment, a computer device is provided, which can be a terminal, and its internal structure diagram can be as shown in Figure 8As shown in the figure. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The communication interface of the computer device is used for wired or wireless communication with external terminals. Wireless mode can be achieved through WIFI, mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by the processor to implement a text recognition model training method and / or a text recognition method. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device. It can also be an external keyboard, touchpad or mouse, etc.

[0139] Those skilled in the art can understand that, Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.

[0140] In one embodiment, a computer device is also provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps in the above method embodiments.

[0141] In one embodiment, a computer readable storage medium is provided, which stores a computer program, and the computer program is executed by a processor to implement the steps in the above method embodiments.

[0142] In one embodiment, a computer program product is provided, including a computer program, and the computer program is executed by a processor to implement the steps in the above method embodiments.

[0143] It should be noted that the user information (including but not limited to user equipment information, user personal information and actual object information, etc.) and data (including but not limited to data for analysis, stored data, displayed data and text data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties.

[0144] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.

[0145] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.

[0146] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A method for training a text recognition model, characterized in that, The method includes: A sample text training set and an updated text recognition model are obtained; the sample text training set is obtained by fusing sample text sequences with the actual object information, actual ability information and actual emotion type of the sample text sequences; the updated text recognition model is obtained by updating the model parameters in the text recognition model to be trained. The updated text recognition model converts each character in the sample text sequence into a text vector and each text vector into a semantic vector. The semantic vector is subjected to character prediction processing to obtain the predicted object information of the sample text sequence; The semantic vector and the prediction object information are subjected to character prediction processing to obtain the prediction capability information of the sample text sequence; The semantic vector, the prediction object information, and the prediction ability information are subjected to character prediction processing to obtain the predicted sentiment type of the sample text sequence; Based on the differences between the actual object information and the predicted object information, the differences between the actual ability information and the predicted ability information, and the differences between the actual sentiment type and the predicted sentiment type, the updated text recognition model is trained to obtain a trained text recognition model.

2. The method according to claim 1, characterized in that, The updated text recognition model is obtained in the following way: Obtain a pre-trained language model; the type of the model parameters in the pre-trained language model is the same as the type of the model parameters in the text recognition model to be trained; The model parameters in the text recognition model to be trained are updated based on the model parameters in the pre-trained language model to obtain the updated text recognition model.

3. The method according to claim 2, characterized in that, The model parameters in the pre-trained language model include text mapping parameters, semantic mapping parameters, and character prediction parameters; The step of updating the model parameters in the text recognition model to be trained based on the model parameters in the pre-trained language model to obtain the updated text recognition model includes: The text mapping parameters, semantic mapping parameters, and character prediction parameters of the text recognition model to be trained are updated according to the text mapping parameters, semantic mapping parameters, and character prediction parameters of the pre-trained language model, respectively, to obtain the updated text recognition model.

4. The method according to claim 1, characterized in that, The step of training the updated text recognition model based on the differences between the actual object information and the predicted object information, the differences between the actual ability information and the predicted ability information, and the differences between the actual sentiment type and the predicted sentiment type, to obtain a trained text recognition model, includes: A first loss value is obtained based on the difference between the actual object information and the predicted object information; a second loss value is obtained based on the difference between the actual ability information and the predicted ability information; and a third loss value is obtained based on the difference between the actual emotion type and the predicted emotion type. Based on the first loss value, the second loss value, and the third loss value, the text mapping parameters, semantic mapping parameters, and character prediction parameters in the updated text recognition model are updated using gradients until the training termination condition is met. The text recognition model that meets the training termination condition is considered the completed text recognition model.

5. The method according to claim 1, characterized in that, The acquisition of the sample text training set includes: Obtain the preset data separator, the sample text sequence, and the actual object information, actual ability information, and actual emotion type of the sample text sequence; The sample text sequence, the actual object information, the actual ability information, and the actual emotion type are fused according to the preset data separator to obtain the sample text training set.

6. A text recognition method, characterized in that, The method includes: Obtain the text to be recognized; The text to be identified is input into the trained text recognition model to obtain the target object information, target ability information and target sentiment type of the text to be identified, which are used as the sentiment analysis results of the text to be identified; the trained text recognition model is obtained by the steps of the method described in any one of claims 1 to 5.

7. The method according to claim 6, characterized in that, The step of inputting the text to be identified into the trained text recognition model to obtain the target object information, target ability information, and target sentiment type of the text to be identified includes: Based on the text mapping parameters of the trained text recognition model, the text to be recognized is processed by text mapping to obtain the text vector of the text to be recognized. Based on the semantic mapping parameters of the trained text recognition model, the text to be recognized is subjected to semantic mapping processing to obtain the semantic vector of the text to be recognized. Based on the character prediction parameters of the trained text recognition model, character prediction processing is performed on the semantic vector of the text to be recognized to obtain the target object information, the target ability information, and the target sentiment type of the text to be recognized.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Emotion recognition model training method and device, voice interaction method and device, equipment and medium

    CN114120978A