A method for character emotion recognition in Internet video scripts based on big data

By adopting the emotional recognition method of Internet video script characters in natural language processing, using technologies such as emotional semantic enhancement and propt paradigm tasks, the problem of poor emotional recognition of script characters is solved, and more efficient emotional recognition of script characters is achieved Effect.

CN116821333BInactive Publication Date: 2024-11-01徐欢
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310627896.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-30
Publication Date
2024-11-01
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing natural language processing model is not effective in the emotional recognition of script characters, especially when the script's writing style is very different from the expected news category and the deep dependence of character emotions and the semantics of the previous text, it is difficult to effectively identify the emotions of characters in the script. .

Method used

Using the emotional recognition method of Internet video script characters based on big data, the script data set is collected for pre-processing, and pre-trained using the BERT model with emotional semantic enhancement, and combined with CSOP tasks, Sentiment MASK tasks and propt paradigm tasks for joint training. Specific emotional classification tasks to improve model prediction effects.

Benefits of technology

The accuracy and effect of emotional recognition of script characters is improved, and the problem of multi-task recognition is solved through information pre-training that is more in line with actual data and the design of specific attention mechanisms, and the prediction effect of the model is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116821333B_ABST
    Figure CN116821333B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of multi-label classification of natural language processing, and specifically relates to an Internet video script role emotion recognition method based on big data; the method comprises collecting a script data set and performing preprocessing to obtain a pre-trained data set; based on the pre-trained data set, pre-training a BERT model using an emotion semantic enhancement method; using the pre-trained BERT model to perform joint training of a prompt paradigm task and an emotion classification task to obtain a trained script role emotion recognition model; collecting script data to be recognized and inputting it into the trained script role emotion recognition model, and outputting a script role emotion recognition result; the present invention interacts with different emotions, mines the correlation between emotions, and further improves the model prediction effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of multi-label classification of natural language processing, and in particular relates to a method for identifying emotions of Internet video script characters based on big data. Background Art

[0002] In the film and television industry, a good script means good reputation, huge traffic and high commercial returns. To judge the quality of a script, we first need to analyze the script, and the emotion recognition of the script characters is a very important task. This task mainly analyzes and recognizes the emotions of each character involved in each line of dialogue and action description in the script from multiple dimensions.

[0003] However, the writing style of scripts is quite different from that of ordinary news articles, and is more colloquial. At the same time, the emotions of the characters in the scripts are not only determined by the current scene, but may also be deeply dependent on the semantics of the previous text. Therefore, the conventional natural language processing model is not effective in solving the problem of script character emotion recognition. Summary of the invention

[0004] To solve the above problems, the present invention provides a method for identifying the emotions of Internet video script characters based on big data, comprising the following steps:

[0005] S1. Collect and preprocess the script dataset to obtain a pre-training dataset;

[0006] S2. Based on the pre-training dataset, the BERT model is pre-trained using the sentiment semantic enhancement method;

[0007] S3. Use the pre-trained BERT model to jointly train the prompt paradigm task and the sentiment classification task to obtain a trained script character sentiment recognition model;

[0008] S4. Collect the script data to be identified and input it into the trained script role emotion recognition model, and output the script role emotion recognition results.

[0009] Furthermore, step S1 collects the script data set and performs preprocessing, including:

[0010] S11. In the script data x i , i = 1, 2, ..., N, where N is the total number of script data;

[0011] S12. Script data x i Perform context splicing to obtain the spliced ​​text x' i , in the concatenated text x' i The end of the splicing step S11 extracts the character name to obtain the pre-training data

[0012] S13 repeats steps S11-S12 to obtain N pre-training data to form a pre-training data set.

[0013] Furthermore, the sentiment semantic enhancement method described in step S2 includes a CSOP task and a Sentiment MASK task; the BERT model is used to jointly pre-train the CSOP task and the Sentiment MASK task, and the cross-entropy loss function is used to calculate the joint pre-training loss value.

[0014] Furthermore, the CSOP task is used for context sentence order prediction, and its specific training process includes:

[0015] S211. is pre-training data Construct a text pair i The construction method includes: selecting the following text and the middle text of the pre-training data as the text pair with probability P1, and marking them with label 0; selecting the preceding text and the middle text of the pre-training data as the text pair with probability P2, and marking them with label 1; selecting the preceding text and the following text of the pre-training data as the text pair with probability 1-P1-P2, and marking them with label 2;

[0016] S212. Pre-training data Text pairs i Input BERT model, output text pair z i With pre-training data semantic relationship.

[0017] Furthermore, the training process of the Sentiment MASK task includes:

[0018] S221. Obtain pre-training data through the sentiment tendency point mutual information algorithm SO-PMI All sentiment words in

[0019] S222. For pre-training data All sentiment words in the text are replaced; the replacement process is to replace them with MASK tags with a probability of 80% and to replace them with other sentiment words with a probability of 20%;

[0020] S223. For pre-training data All words except sentiment words in the data are selected, and 15% of the words are replaced; the replacement operation is to replace with MASK mark with a probability of 80%, to replace with other sentiment words with a probability of 10%, and not to replace with a probability of 10%;

[0021] S224. Obtain the data corresponding to the pre-training data through steps S221-S223 Generated data Will generate data Input the BERT model and predict the word at its MASK token.

[0022] Furthermore, the training process of the prompt paradigm task described in step S3 includes:

[0023] S311. Construct the input script data according to the BERE vocabulary and the sentiment paradigm structure to obtain a paradigm data including a MASK tag;

[0024] S312. Input the paradigm data into the BERT model, output the predicted words at each MASK tag and concatenate them, and pass the concatenation result through the fully connected layer to obtain the label prediction result.

[0025] Furthermore, step S311 is for the input script data x i ,i=1,2,…,N The process of constructing a paradigm data is:

[0026] S3001. In script data x i Extract a character name for emotion prediction and add it to the beginning of the script data in the form of $character name$; at the same time, i The remaining character names in are also marked in the form of $character name$;

[0027] S3002. After the script data x processed in step S3001 i Insert an emotional paradigm structure into the text, wherein the emotional paradigm structure is: love [MASK] joy [MASK] surprise [MASK] anger [MASK] fear [MASK] sorrow [MASK];

[0028] S3003. Add the [unuse] tag in the BERT vocabulary as a prompt to the script data x processed in step S3002 i , the final paradigm data is: $character name$[unuse1][unuse2][unuse]love[MASK]joy[MASK]fright[MASK]anger[MASK]fear[MASK]sorrow[MASK]script datax i .

[0029] Furthermore, the training process of the sentiment classification task described in step S3 includes:

[0030] S321. Output the feature vector of the script data through the BERT model, and obtain the character name feature vector according to the feature vector;

[0031] S322. Obtaining six character emotion feature vectors corresponding to the six emotions of love, joy, surprise, anger, fear and sorrow, and obtaining six tendency scores according to the character emotion feature vectors;

[0032] S323. Obtaining 6 basic prediction probabilities corresponding to the 6 emotions of love, joy, surprise, anger, fear and sorrow, respectively;

[0033] S324. The basic prediction probability and the propensity score corresponding to each emotion are integrated to finally obtain the emotion classification prediction result.

[0034] Furthermore, step S321 obtains a character name feature vector according to the feature vector, including:

[0035] S3201. Obtain the role position index of the target role name in the script data, and extract the role name vector in the feature vector of the script data according to the role position index;

[0036] S3202. Obtain the context position index of the target character name in the script data, and extract the context vector in the feature vector of the script data according to the context position index;

[0037] S3203. Merge each character name vector with its corresponding context vectors to finally obtain the character name feature vector of the script data.

[0038] Beneficial effects of the present invention:

[0039] The present invention provides an Internet video script character emotion recognition method based on big data. The method adopts the BERT model as the base model. Firstly, two script emotion-based CSOP tasks and Sentiment MASK tasks are designed to pre-train the BERT model. The CSOP tasks and Sentiment MASK tasks are more difficult to train than traditional NSP and MLM tasks, and also provide information that is more in line with actual data.

[0040] Secondly, a prompt paradigm task was designed. Compared with the traditional BERT paradigm prediction, this prompt paradigm task combines sentiment words and role names to construct prompts in prompt technology and uses more special symbols, so that each sentiment word has a MASK in a specific position to mark it. The prediction for multiple targets is more targeted, solving the problem of multi-task recognition difficulties.

[0041] In addition, a sentiment classification task was designed, which introduced a specific attention mechanism to interact with different emotions and explore the correlation between emotions, further improving the model prediction effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1This is a flow chart of the method for identifying the role emotions in Internet video scripts based on big data of the present invention;

[0043] Figure 2 The overall training flow chart of the method for identifying the role emotions of Internet video scripts based on big data of the present invention;

[0044] Figure 3 It is a structural diagram of the pre-training method based on emotional semantic enhancement of the present invention;

[0045] Figure 4 This is a structural diagram of the emotion prediction based on the prompt paradigm of the present invention;

[0046] Figure 5 This is a structural diagram of the sentiment classification based on a specific attention mechanism of the present invention. DETAILED DESCRIPTION

[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] The present invention provides a method for identifying the emotion of Internet video script characters based on big data. Figure 1 , Figure 2 As shown, the following steps are included:

[0049] S1. Collect and preprocess the script dataset to obtain a pre-training dataset.

[0050] Specifically, step S1 collects the script data set and performs preprocessing, including:

[0051] S11. In the script data x i ,i=1,2,…,N, where N is the total number of script data.

[0052] S12. Script data x i Perform context splicing to obtain the spliced ​​text x' i , in the concatenated text x' i The end of the splicing step S11 extracts the character name to obtain the pre-training data

[0053] It is particularly noteworthy that if the same script data contains multiple different character names, a character name is randomly extracted as the object to be predicted, also called the target character name, and is concatenated at the end of the concatenated text to which it belongs; for this script data, the extracted character names are different, the pre-training data obtained are different, and the subsequent pre-training prediction objects and prediction results are also different.

[0054] S13 repeats steps S11-S12 to obtain N pre-training data to form a pre-training data set.

[0055] S2. Based on the pre-training dataset, the sentiment semantic enhancement method is used to pre-train the BERT model.

[0056] Specifically, Figure 3 As shown in the figure, the BERT model is used as the pre-trained base model, and the BERT model is pre-trained based on the pre-training dataset using the sentiment semantic enhancement method, including:

[0057] S21. Training and learning of the CSOP task based on context sentence order prediction, including:

[0058] S211. is pre-training data Construct a text pair i .

[0059] S212. Pre-training data Text pairs i Input BERT model, output text pair z i With pre-training data The semantic relationship between i With pre-training data Is it a previous relationship, a following relationship, or other relationship, and then return the prediction result.

[0060] Specifically, each piece of pre-training data corresponds to text pairs with three label types: 0, 1, and 2, as shown below:

[0061] Text pair 1: [CLS] following text [SEP] middle text [SEP]

[0062] Tags: 0

[0063] Text pair 2: [CLS] Previous text [SEP] Middle text [SEP]

[0064] Tags: 1

[0065] Text pair 3: [CLS]Previous [SEP]Next [SEP]

[0066] Tags: 2

[0067] Each piece of pre-training data selects a text pair of one label type each time and inputs it into the BERT model for semantic relationship prediction, where the probability of selecting a text pair with label 0 is P1; the probability of selecting a text pair with label 1 is P2; and the probability of selecting a text pair with label 2 is 1-P1-P2.

[0068] S22. Training and learning of the Sentiment MASK task with sentiment word masking, including:

[0069] S221. Obtain pre-training data through the sentiment tendency point mutual information algorithm SO-PMI All sentiment words in

[0070] S222. For pre-training data All sentiment words in the text are replaced, that is, there is an 80% probability of replacing sentiment words with MASK tags, and a 20% probability of replacing sentiment words with other sentiment words;

[0071] S223. For pre-training data Among all the words except sentiment words, 15% of the words are selected for replacement, that is, there is an 80% probability of replacing with MASK tags, a 10% probability of replacing with other sentiment words, and a 10% probability of not replacing;

[0072] S224. Obtain the data corresponding to the pre-training data through steps S221-S223 Generated data Will generate data Input the BERT model and predict the word at its MASK tag, and then return the prediction result;

[0073] S23. Use the cross entropy loss function to calculate the joint pre-training loss value of the BERT model joint pre-training CSOP task and Sentiment MASK task. Two cross entropy loss functions are used to calculate the loss values ​​of the CSOP task and the Sentiment MASK task respectively, and then the joint pre-training loss value is obtained according to a 1:1 weighting.

[0074] S3. Use the pre-trained BERT model to jointly train the prompt paradigm task and the sentiment classification task to obtain a trained script character emotion recognition model.

[0075] Specifically, Figure 4 As shown, the training process of the prompt paradigm task described in step S3 includes:

[0076] S311. Construct the input script data according to the BERE vocabulary and sentiment paradigm structure to obtain paradigm data containing MASK tags.

[0077] Specifically, step S311 is for the input scenario data x i ,i=1,2,…,N The process of constructing a corresponding paradigm data is:

[0078] S3001. In script data x i Extract a character name for emotion prediction and add it to the beginning of the script data in the form of $character name$; at the same time, i The remaining character names in are also marked in the form of $character name$;

[0079] S3002. After the script data x processed in step S3001 i Insert an emotional paradigm structure into the text, wherein the emotional paradigm structure is: love [MASK] joy [MASK] surprise [MASK] anger [MASK] fear [MASK] sorrow [MASK];

[0080] S3003. Add the [unuse] tag in the BERT vocabulary as a prompt to the script data x processed in step S3002 i The final structure of the paradigm data is: $role name$[unuse1][unuse2][unuse]love[MASK]joy[MASK]fright[MASK]anger[MASK]fear[MASK]sorrow[MASK]script datax i .

[0081] S312. Input the paradigm data into the BERT model for the MLM task, output the predicted words at each MASK tag in the paradigm data and concatenate them, pass the concatenation result through the fully connected layer to obtain the prediction results of the six emotional labels of love, joy, surprise, anger, fear and sadness, and calculate the loss value through the cross entropy loss function.

[0082] Specifically, Figure 5 As shown, the training process of the sentiment classification task described in step S3 includes:

[0083] S321. Output the feature vector F of the script data through the BERT model s , get the character name feature vector F according to the feature vector r .

[0084] Specifically, step S321 obtains the character name feature vector according to the feature vector, including:

[0085] S3201. Obtain the role position index of the target role name in the script data, and extract the vector at the corresponding position in the feature vector of the script data according to the role position index as the role name vector, which is expressed as (f 1x , f 2x, ..., f kx );

[0086] S3202. Obtain the context position index of the target character name in the script data, and extract the vector at the corresponding position in the feature vector of the script data as the context vector according to the context position index, expressed as (f 1x-1 , f 1x+1 , f 2x+1 , f 2x+1 , ..., f kx-1 , f kx+1 );

[0087] S3203. Each character name vector is merged with its corresponding context vector, and finally the character name feature vector F of the script data is obtained. r , the fusion calculation formula is:

[0088]

[0089] Among them, k represents the total number of times the target character name to be predicted appears in the text, and f ix The vector representing the position of the target character name that appears at the ith time, f ix+1 and f ix-1 A vector representing the next word position and previous word position of the i-th occurrence of the target character name position.

[0090] S322. Obtain six character emotion feature vectors corresponding to the six emotions of love, joy, surprise, anger, fear and sorrow through MLP, which are represented as E1, E2, E3, E4, E5 and E6 respectively, and obtain six tendency scores according to the character emotion feature vectors;

[0091] Specifically, step S322 obtains 6 tendency scores according to the character emotion feature vector, including:

[0092] The inner product of the character emotion feature vectors corresponding to each two emotions is obtained to obtain a 6×6 interaction matrix, which is expressed as:

[0093]

[0094] In this embodiment, the six emotions of love, joy, surprise, anger, fear and sorrow are numbered from 1 to 6. The element e in the interaction matrix ij Represents the character emotion feature vector E corresponding to the i=1,2,...,6th emotion i For the character emotion feature vector E corresponding to the j=1,2,...,6th emotion j The interaction score obtained by performing the inner product; where e ii =0.

[0095] Combine each element in the interaction matrix with its corresponding two emotions to obtain the combined matrix, which is expressed as:

[0096]

[0097]

[0098] in, Indicates E i and E j Inner product.

[0099] The combined matrix is ​​input into the linear layer, and the softmax activation function is used to normalize the elements of each row of the combined matrix. Finally, the tendency scores corresponding to the six emotions are obtained, which are expressed as:

[0100]

[0101]

[0102] Among them, S i ={s i1 ,s i2 ,…,s i6} represents the tendency score of the i-th emotion, where s i1 represents the tendency score of the i-th emotion to the first emotion, δ represents the softmax activation function, and w i and b i are the parameters of the linear layer with an output size of 6 dimensions, is the result of vertical concatenation of the elements in the i-th row of the matrix. S323. The feature vector F obtained in step S321 is s Through a classification layer, we get the basic prediction probability of each emotion;

[0103] S324. Each basic prediction probability is combined with the tendency score of its corresponding emotion to finally obtain the emotion classification prediction result, and the loss value is calculated by the cross entropy loss function.

[0104] Specifically, each basic prediction probability is fused with the tendency score of its corresponding emotion, expressed as:

[0105]

[0106] Among them, U=(u1,...,u i ,...,u6) is a learnable matrix, u i represents the i-th parameter in the learnable matrix, s ij represents the tendency score of emotion i to emotion j, represents the final predicted probability of the i-th emotion, r jRepresents the basic prediction probability of the jth emotion. Specifically, the loss value l1 of the prompt paradigm task and the loss value l2 of the emotion classification task are fused according to the following method:

[0107]

[0108] in, is a configurable hyperparameter.

[0109] After obtaining the final loss value, the various parameters of the model are optimized through back propagation until they converge and the model training is completed.

[0110] S4. Collect the script data to be recognized and input it into the trained BERT model, and output the emotion recognition results of the script characters.

[0111] In the present invention, unless otherwise clearly stipulated and limited, the terms such as "installation", "setting", "connection", "fixation" and "rotation" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral one; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium; it can be the internal connection of two elements or the interaction relationship between two elements. Unless otherwise clearly defined, ordinary technicians in this field can understand the specific meanings of the above terms in the present invention according to the specific circumstances.

[0112] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for identifying role emotions in Internet video scripts based on big data, characterized in that: The following steps are involved: S1. Collect and preprocess the script dataset to obtain a pre-training dataset; S2. Based on the pre-training dataset, the BERT model is pre-trained using the sentiment semantic enhancement method; The emotional semantic enhancement method described in step S2 includes a CSOP task and a Sentiment MASK task; The BERT model is used to jointly pre-train the CSOP task and the Sentiment MASK task, and the cross-entropy loss function is used to calculate the joint pre-training loss value; The CSOP task is used to predict the order of contextual sentences. Its specific training process includes: S211. is pre-training data i=1,2,…,N construct a text pair z i The construction method includes: selecting the following text and the middle text of the pre-training data as the text pair with probability P1, and marking them with label 0; selecting the preceding text and the middle text of the pre-training data as the text pair with probability P2, and marking them with label 1; selecting the preceding text and the following text of the pre-training data as the text pair with probability 1-P1-P2, and marking them with label 2; S212. Pre-training data Text pairs i Input BERT model, output text pair z i With pre-training data The semantic relationship of The training process of the Sentiment MASK task includes: S221. Obtain pre-training data through the sentiment tendency point mutual information algorithm SO-PMI All sentiment words in S222. For pre-training data All sentiment words in the text are replaced; the replacement process is to replace them with MASK tags with a probability of 80% and to replace them with other sentiment words with a probability of 20%; S223. For pre-training data All words except sentiment words in the data are selected, and 15% of the words are replaced; the replacement operation is to replace with MASK mark with a probability of 80%, to replace with other sentiment words with a probability of 10%, and not to replace with a probability of 10%; S224. Obtain the data corresponding to the pre-training data through steps S221-S223 Generated data Will generate data Input the BERT model and predict the word at its MASK tag; S3. Use the pre-trained BERT model to jointly train the prompt paradigm task and the sentiment classification task to obtain a trained script character sentiment recognition model; S4. Collect the script data to be identified and input it into the trained script role emotion recognition model, and output the script role emotion recognition results.

2. The method for identifying role emotions in Internet video scripts based on big data according to claim 1, characterized in that: Step S1 collects the script data set and performs preprocessing, including: S11. In the script data x i , i = 1, 2, ..., N, where N is the total number of script data; S12. Script data x i Perform context splicing to obtain the spliced ​​text x' i , in the concatenated text x' i The end of the splicing step S11 extracts the character name to obtain the pre-training data S13 repeats steps S11-S12 to obtain N pre-training data to form a pre-training data set.

3. The method for identifying role emotions in Internet video scripts based on big data according to claim 1, characterized in that: The training process of the prompt paradigm task described in step S3 includes: S311. Construct the input script data according to the BERE vocabulary and the sentiment paradigm structure to obtain a paradigm data including a MASK tag; S312. Input the paradigm data into the BERT model, output the predicted words at each MASK tag and concatenate them, and pass the concatenation result through the fully connected layer to obtain the label prediction result.

4. The method for identifying role emotions in Internet video scripts based on big data according to claim 3 is characterized in that: Step S311: for the input scenario data x i ,i=1,2,…,N The process of constructing a paradigm data is: S3001. In script data x i Extract a character name for emotion prediction and add it to the beginning of the script data in the form of $character name$; at the same time, i The remaining character names in are also marked in the form of $character name$; S3002. After the script data x processed in step S3001 i Insert an emotional paradigm structure into it, wherein the emotional paradigm structure is: love [MASK] joy [MASK] surprise [MASK] anger [MASK] fear [MASK] sorrow [MASK]; S3003. Add the [unuse] tag in the BERT vocabulary as a prompt to the script data x processed in step S3002 i , the final paradigm data is: $character name$[unuse1][unuse2][unuse]love[MASK]joy[MASK]fright[MASK]anger[MASK]fear[MASK]sorrow[MASK]script datax i .

5. The method for identifying role emotions in Internet video scripts based on big data according to claim 1, characterized in that: The training process of the sentiment classification task described in step S3 includes: S321. Output the feature vector of the script data through the BERT model, and obtain the character name feature vector according to the feature vector; S322. Obtaining six character emotion feature vectors corresponding to the six emotions of love, joy, surprise, anger, fear and sorrow, and obtaining six tendency scores according to the character emotion feature vectors; S323. Obtaining 6 basic prediction probabilities corresponding to the 6 emotions of love, joy, surprise, anger, fear and sorrow, respectively; S324. The basic prediction probability and the propensity score corresponding to each emotion are integrated to finally obtain the emotion classification prediction result.

6. The method for identifying role emotions in Internet video scripts based on big data according to claim 5, characterized in that: Step S321 obtains the character name feature vector according to the feature vector, including: S3201. Obtain the role position index of the target role name in the script data, and extract the role name vector in the feature vector of the script data according to the role position index; S3202. Obtain the context position index of the target character name in the script data, and extract the context vector in the feature vector of the script data according to the context position index; S3203. Merge each character name vector with its corresponding context vectors to finally obtain the character name feature vector of the script data.