Text data processing method and device, storage medium and electronic equipment
By generating and using first-level, second-level, and third-level samples to train the initial sentiment prediction model, the problem of low prediction accuracy caused by imbalanced training samples is solved, thereby improving the accuracy and training efficiency of the text sentiment prediction model.
Patent Information
- Application Number
- CN202410240140.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-01
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2044-03-01
AI Technical Summary
Existing text sentiment prediction models suffer from poor prediction accuracy due to an unbalanced training sample, resulting in significant differences in the number of samples for different sentiment categories.
By acquiring initial text data, inputting it into a pre-trained large language model and an initial sentiment prediction model, generating the first and second sets of sentiment category labels, and generating first-level, second-level, and third-level samples based on these labels, and using these samples to train the initial sentiment prediction model to generate the target sentiment prediction model.
It achieves a balanced training sample, improves the generalization ability and prediction accuracy of the emotion prediction model, and rapidly collects a large amount of sample data without the need for manual annotation, thereby improving training efficiency and the ability to identify different emotion types.
Smart Images

Figure CN118093871B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more specifically, to a method and apparatus for processing text data, a storage medium, and an electronic device. Background Technology
[0002] Currently, related technologies mainly employ text sentiment prediction models to achieve multi-label classification learning of text data. Specifically, text data is input into the text sentiment prediction model to map it to a pre-trained dictionary, resulting in combined word vectors. Sentence vectors are then generated from these combined word vectors for label recognition, thereby generating the corresponding sentiment category label for the text data. This achieves the goal of multi-label classification of text data. However, since these technologies simply use text sentiment prediction models for direct classification, and the training samples used in the training process are not balanced enough, with significant differences in the number of samples for different sentiment categories, the technical problems of low accuracy in identifying sentiment category labels and poor prediction accuracy of the sentiment prediction model exist when performing multi-label classification tasks.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This application provides a method and apparatus for processing text data, a storage medium, and an electronic device to at least solve the technical problem that the prediction accuracy of the emotion prediction model is poor due to the large difference in the number of samples corresponding to different emotion category labels in the training samples.
[0005] According to one aspect of the embodiments of this application, a method for processing text data is provided, comprising: acquiring initial text data; inputting the initial text data into a pre-trained large language model to obtain a first set of emotion category labels, and inputting the initial text data into a pre-trained initial emotion prediction model to obtain a second set of emotion category labels, wherein the initial emotion prediction model represents a model pre-trained using initial training samples, and the large language model represents a model pre-trained using a corpus; generating first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels, wherein the first-level samples have a first emotion category label that belongs to both the first set of emotion category labels and the second set of emotion category labels, the second-level samples have a second emotion category label that belongs to the first set of emotion category labels and does not belong to the second set of emotion category labels, and the third-level samples have a third emotion category label that belongs to the second set of emotion category labels and does not belong to the first set of emotion category labels; and training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain a target emotion prediction model.
[0006] According to another aspect of the embodiments of this application, a text data processing apparatus is also provided, comprising: an acquisition module for acquiring unlabeled initial text data; a prediction module for inputting the initial text data into a pre-trained large language model to obtain a first set of emotion category labels, and inputting the initial text data into a pre-trained initial emotion prediction model to obtain a second set of emotion category labels, wherein the initial emotion prediction model represents a model pre-trained using initial training samples, and the large language model represents a model pre-trained using a corpus; a generation module for generating first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels, wherein the first-level samples have a first emotion category label that belongs to both the first set of emotion category labels and the second set of emotion category labels, the second-level samples have a second emotion category label that belongs to the first set of emotion category labels and does not belong to the second set of emotion category labels, and the third-level samples have a third emotion category label that belongs to the second set of emotion category labels and does not belong to the first set of emotion category labels; and a training module for training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain a target emotion prediction model.
[0007] Optionally, the device is configured to generate first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels in the following manner: determining the first emotion category label, the second emotion category label, and the third emotion category label based on the first set of emotion category labels and the second set of emotion category labels; generating the first-level sample by setting the confidence level of the first emotion category label to a first preset value, wherein the first-level sample indicates that the initial text data has the first emotion category label with a confidence level of the first preset value; generating the second-level sample by setting the confidence level of the second emotion category label to a first prediction probability, wherein the first prediction probability indicates that the initial emotion prediction model predicts whether the initial text data has the second emotion category label, and the second-level sample indicates that the initial text data has the second emotion category label with a confidence level of the first prediction probability; generating the third-level sample by setting the confidence level of the third emotion category label to a second prediction probability, wherein the second prediction probability is less than the probability that the initial emotion prediction model predicts whether the initial text data has the third emotion category label, and the third-level sample indicates that the initial text data has the third emotion category label with a confidence level of the second prediction probability.
[0008] Optionally, the device is used to generate the third-level sample by setting the confidence level of the third emotion category label to a second prediction probability in the following manner: obtaining the probability that the initial emotion prediction model predicts whether the initial text data has the third emotion category label; determining the second prediction probability by multiplying the probability by a second preset value; setting the confidence level of the third emotion category label to the second prediction probability; and generating the third-level sample, wherein the value range of the second preset value is 1 / a, and a is a positive integer.
[0009] Optionally, the apparatus is configured to train the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples in the following manner to obtain a target emotion prediction model: training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain an intermediate emotion prediction model, wherein the learning rate used to train the intermediate emotion prediction model is a first learning rate; and fine-tuning the intermediate emotion prediction model using the initial training samples and the first-level samples to obtain the target emotion prediction model, wherein the learning rate used to train the target emotion prediction model is a second learning rate, and the second learning rate is less than the first learning rate.
[0010] Optionally, the device is used to fine-tune the intermediate sentiment prediction model using the initial training samples and the first-level samples to obtain the target sentiment prediction model: when the intermediate sentiment prediction model includes a basic text understanding module and a classification module, a second learning rate is set for the basic text understanding module and a third learning rate is set for the classification module, wherein the third learning rate is greater than the first learning rate; the intermediate sentiment prediction model is fine-tuned according to the second learning rate and the third learning rate to obtain the target sentiment prediction model.
[0011] Optionally, the device is used to train the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples in the following manner to obtain a target emotion prediction model: constructing target training samples based on the initial training samples, the first-level samples, the second-level samples, and the third-level samples, wherein one target training sample includes a piece of text data, a set of emotion category labels, and a set of confidence scores corresponding to the set of target emotion category labels; inputting the target training samples into the initial emotion prediction model in batches, and iteratively training the initial emotion prediction model to obtain the target emotion prediction model.
[0012] Optionally, the device is used to input the target training samples into the initial emotion prediction model in batches in the following manner, and to iteratively train the initial emotion prediction model to obtain the target emotion prediction model: The target training samples are input into the initial emotion prediction model in batches in the following manner, and the initial emotion prediction model is iteratively trained to obtain the target emotion prediction model, wherein the text data used in the current batch in the current iteration is considered as the current text data, each iteration uses the full set of the target training samples for training, and each batch uses a portion of the target training samples for training; the current text data is input into the basic text understanding module to obtain the target representation vector, wherein the dimension of the target representation vector is the same as the number of emotion categories that the initial emotion prediction model is allowed to predict. Each dimension of the target representation vector represents the confidence level of the corresponding emotion category. The initial emotion prediction model includes the basic text understanding module. The target representation vector is input into the classification module to obtain the current emotion category label and the current confidence level corresponding to the current emotion category label. The initial emotion prediction model includes the classification module, and the current emotion category label represents the emotion category label predicted by the initial emotion prediction model for the current text data. A target loss value is calculated based on the set of emotion category labels, the set of confidence levels, the current emotion category label, and the current confidence level corresponding to the current text data. The model parameters of the initial emotion prediction model are adjusted based on the target loss value until the target loss value meets a preset condition, thus obtaining the target emotion prediction model.
[0013] Optionally, the device is further configured to: after generating first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels, determine the number of samples corresponding to each initial emotion category label in the initial set of initial emotion category labels based on the initial training samples; determine the initial emotion category labels whose sample number meets a preset threshold as first initial emotion category labels, and determine the initial emotion category labels whose sample number does not meet the preset threshold as second initial emotion category labels; delete the second-level samples and the third-level samples with the first initial emotion category labels, and retain the second-level samples and the third-level samples with the second initial emotion category labels.
[0014] Optionally, the apparatus is further configured to: before inputting the initial text data into a pre-trained initial emotion prediction model to obtain a second set of emotion category labels, input sample text data from the initial training samples into the initial emotion prediction model to obtain a target prediction probability, wherein the target prediction probability represents the probability that the initial emotion prediction model predicts whether the sample text data has a sample emotion category label, and the sample text data is pre-labeled as to whether it has the sample emotion category label; obtain a set of discrimination thresholds, wherein one of the discrimination thresholds in the set of discrimination thresholds is used together with the target prediction probability to determine the target prediction result, wherein the target… The prediction result indicates whether the sample text data has the sample emotion category label; based on the target prediction probability and the set of discrimination thresholds, a target discrimination threshold for the sample emotion category label is determined, wherein the target discrimination threshold is the threshold with the highest balance score among the set of discrimination thresholds, and the balance score is jointly determined by the target prediction result and whether the sample text data is pre-labeled with the sample emotion category label; the target discrimination threshold is set as the target model parameter of the initial emotion prediction model, wherein the target discrimination threshold is used to determine the second set of emotion category labels in the initial emotion prediction model.
[0015] Optionally, the apparatus is further configured to: train the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain a target emotion prediction model; acquire a target media resource and perform text extraction on the target media resource to obtain target text data; input the target text data into the target emotion prediction model to obtain a set of target emotion category labels and a set of target confidence scores corresponding to the set of target emotion category labels; and set target sentiment markers for the target media resource based on the set of target emotion category labels and the set of target confidence scores, wherein the target sentiment markers are used to indicate the emotion category of the target media resource.
[0016] Optionally, the device is configured to set a target emotion tag for the target media resource based on the set of target emotion category tags and the set of target confidence levels in the following manner: obtaining a group of emotion category tags with opposite emotional meanings from the set of emotion category tags; setting a first emotion tag for the target media resource based on the number of the emotion category tag groups, wherein the target emotion tag includes the first emotion tag, and the first emotion tag is used to indicate the plot twists of the target media resource; obtaining target segments with the same emotion category tags from the target media information; and setting a second emotion tag for the target segments, wherein the target emotion tag includes the second emotion tag, and the second emotion tag is used to indicate that different target segments all have the same emotion category tag.
[0017] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the above-described text data processing method when running.
[0018] According to another aspect of the embodiments of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the text data processing method described above.
[0019] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-described text data processing method through the computer program.
[0020] In this embodiment, initial text data is obtained; the initial text data is input into a pre-trained large language model to obtain a first set of emotion category labels, and the initial text data is input into a pre-trained initial emotion prediction model to obtain a second set of emotion category labels. The initial emotion prediction model represents a model pre-trained using initial training samples, and the large language model represents a model pre-trained using a corpus. First-level samples, second-level samples, and third-level samples are generated based on the first and second sets of emotion category labels. The first-level samples have a first emotion category label that belongs to both the first and second sets of emotion category labels; the second-level samples have a second emotion category label that belongs to the first set of emotion category labels but not to the second set; and the third-level samples have a third emotion category label that belongs to the second set of emotion category labels but not to the first set. The initial training samples, first-level samples, and... The method of training the initial emotion prediction model using second-level and third-level samples to obtain the target emotion prediction model involves inputting the initial text data into the pre-trained large language model and the initial emotion prediction model respectively to determine the first and second sets of emotion category labels. Then, based on the first and second sets of emotion category labels, first-level, second-level, and third-level samples are generated. The initial emotion prediction model is trained using the first-level, second-level, and third-level samples to obtain the target emotion prediction model. This achieves the goal of balancing the amount of data of each sample type in the training samples, thereby enabling the initial emotion prediction model to better learn the features of various emotion types during the training process, improving the generalization ability and prediction accuracy of the target emotion prediction model. Furthermore, it solves the technical problem of poor prediction accuracy of the emotion prediction model due to the large difference in the number of samples corresponding to different emotion category labels in the training samples.
[0021] On the other hand, the first-level samples, second-level samples, and third-level samples generated based on the first set of emotion category labels and the second set of emotion category labels can all be used to train the initial emotion prediction model. That is, a large amount of sample data can be collected quickly without the need for manual labeling. This improves the training efficiency of the initial emotion prediction model while ensuring the target emotion prediction model's ability to recognize different emotion types. Attached Figure Description
[0022] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a schematic diagram of an application environment for an optional text data processing method according to an embodiment of this application; Figure 2 This is a flowchart illustrating an optional text data processing method according to an embodiment of this application; Figure 3 This is a schematic diagram of an optional text data processing method according to an embodiment of this application; Figure 4 This is a schematic diagram of another optional text data processing method according to an embodiment of this application; Figure 5 This is a schematic diagram of another optional text data processing method according to an embodiment of this application; Figure 6 This is a schematic diagram of another optional text data processing method according to an embodiment of this application; Figure 7 This is a schematic diagram of another optional text data processing method according to an embodiment of this application; Figure 8 This is a schematic diagram of another optional text data processing method according to an embodiment of this application; Figure 9 This is a schematic diagram of another optional text data processing method according to an embodiment of this application; Figure 10 This is a schematic diagram of the structure of an optional text data processing apparatus according to an embodiment of this application; Figure 11 This is a schematic diagram of the structure of an optional text data processing product according to an embodiment of this application; Figure 12 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] The present application will be described below with reference to embodiments: According to one aspect of the embodiments of this application, a method for processing text data is provided. Optionally, in this embodiment, the above-described text data processing method can be applied to, for example... Figure 1 The hardware environment shown consists of server 101 and terminal device 103. For example... Figure 1 As shown, server 101 is connected to terminal device 103 via a network and can be used to provide services to terminal device or application 107 installed on terminal device. The application can be video application, instant messaging application, browser application, educational application, game application, etc. Database 105 can be set up on the server or independently of the server to provide data storage services for server 101, such as a game data storage server. The network mentioned above can include, but is not limited to, wired networks and wireless networks. The wired network includes local area networks, metropolitan area networks, and wide area networks. The wireless network includes Bluetooth, WIFI, and other networks that enable wireless communication. Terminal device 103 can be a terminal configured with an application, and can include, but is not limited to, at least one of the following: mobile phones (such as Android phones, iOS phones, etc.), laptops, tablets, handheld computers, MID (Mobile Internet Devices), PADs, desktop computers, smart TVs, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, virtual reality (VR) terminals, augmented reality (AR) terminals, mixed reality (MR) terminals, and other computer devices. The server mentioned above can be a single server, a server cluster composed of multiple servers, or a cloud server.
[0026] Combination Figure 1As shown, the text data processing methods in various embodiments of this application can be executed by an electronic device, which can be a terminal device or a server. That is, the text data processing methods in various embodiments of this application can be implemented by the terminal device or the server respectively, or by the terminal device and the server together.
[0027] The above is merely an example, and this embodiment does not impose any specific limitations.
[0028] Alternatively, as an optional implementation, such as Figure 2 As shown, the methods for processing the above text data include: S202, Obtain initial text data; Optionally, in the embodiments of this application, the aforementioned initial text data may include, but is not limited to, script texts, novel texts, news reports, advertising copy, etc. In addition, it may also include, but is not limited to, conversation records, interview recordings, social media posts, and other spoken text data.
[0029] It should be noted that the initial text data mentioned above may include, but is not limited to, text data directly extracted from a text without annotation, or pre-annotated text data. In particular, when the initial text data is pre-annotated with emotion category labels, but the number of text data corresponding to different emotion category labels is not balanced, it can be used as the initial text data to construct a more balanced sample.
[0030] S204. Input the initial text data into the pre-trained large language model to obtain the first set of emotion category labels, and input the initial text data into the pre-trained initial emotion prediction model to obtain the second set of emotion category labels. Here, the initial emotion prediction model refers to the model trained in advance using the initial training samples, and the large language model refers to the model trained in advance using the corpus. Optionally, in the embodiments of this application, the aforementioned large language model may include, but is not limited to, a generative pre-trained model. Taking the GPT model as an example, it is pre-trained using large-scale text data and can be used for various natural language processing tasks, such as text generation, machine translation, and dialogue systems. The aforementioned initial sentiment prediction model may include, but is not limited to, a pre-trained model trained on a large-scale corpus. Taking the ERNIE 3.0 pre-trained model as an example, the ERNIE 3.0 pre-trained model is pre-trained on large-scale text data and has stronger semantic understanding and reasoning capabilities. The ERNIE 3.0 model has wide applications in the field of natural language processing, including tasks such as text classification, sentiment analysis, and named entity recognition. The aforementioned first set of sentiment category labels and the aforementioned second set of sentiment category labels may include, but are not limited to, love, trust, happiness, ecstasy, sarcasm, anger, doubt, and surprise. The aforementioned initial training samples may include, but are not limited to, sample data that has been pre-labeled with sentiment category labels. The initial training samples may also be divided into a training set, a validation set, and a test set. The training set, validation set, and test set are commonly used dataset partitioning methods in machine learning and data mining.
[0031] Specifically, both the first group of emotion category labels and the second group of emotion category labels mentioned above can include, but are not limited to, multiple emotion category labels. The initial text data corresponds to one or more emotion category labels. Each emotion category label has a confidence level, which indicates the probability that the initial text data contains that emotion category label. For example, if the initial text data is "Hello, the weather is really nice today", and the initial text data is input into the large language model and the initial emotion prediction model respectively, the output of the large language model is "The emotion category label of the current input text is: {Happy: 80; Calm: 60}", and the output of the initial emotion prediction model is "Happy: 50".
[0032] Furthermore, in the above embodiment, the first set of emotion category labels is "pleasant: 50; calm: 60", where the confidence level of the pleasant emotion category label is 80 and the confidence level of the calm emotion category label is 60; the second set of emotion category labels is "pleasant: 50", where the confidence level of the pleasant emotion category label is 50. It can be understood that the first set of emotion category labels and the second set of emotion category labels can be the same or different. That is, the emotion category labels and corresponding confidence levels predicted by the same initial text data input into the large language model and the initial emotion prediction model can be the same or different.
[0033] It should also be noted that before the initial text data is input into the large language model and the initial sentiment prediction model, it can be in the form of a question or directly input into the model for prediction. It can also include, but is not limited to, standardizing the output format of the model. After the initial text data is predicted by the model, the sentiment category label of the initial text data will be completed.
[0034] For example, sentiment prediction can be performed on the initial text data based on an initial sentiment prediction model and a large language model to generate pseudo-sentiment labels for the initial text data. Taking the GPT model as the large language model and the ERNIE 3.0 model as the initial sentiment prediction model as an example, assuming the initial text data is a dialogue from a script: "A: You, here again. I am XXX. (Seeing the red wine stain on B's hair, he frowns) What's wrong with you?", the steps for generating the first set of sentiment category labels may include, but are not limited to: Figure 3 This is a schematic diagram of an optional text data processing method according to an embodiment of this application, such as... Figure 3 As shown, in the dialog box of the GPT model, input content 302: "Which of the following emotions (love, trust, doubt, surprise, happiness, ecstasy, sarcasm, anger) does the following dialogue express? Give the emotion and confidence level, with a confidence level range of 0-100, where 100 indicates certainty of the emotion and 0 indicates absence of the emotion. Return in JSON format, if the emotion is the key, give the score; otherwise, return {"None": 100}. The dialogue is: A: You, here we go again. I am XXX. (Sees red wine stains on B's hair, frowns) What's wrong with you?" Among them, the output content 304 of the large language model is {“Concern”: 80, “Angry”: 60}, that is, the first group of emotion category labels is “Concern”: 80, “Angry”: 60.
[0035] Similarly, before inputting the initial text data into the aforementioned initial sentiment prediction model for prediction, it is possible to generate discrimination thresholds for various sentiment category labels using test set data, wherein the test set data includes text data that has been pre-labeled with sentiment category labels. Specifically, Figure 4 This is a schematic diagram illustrating another optional text data processing method according to an embodiment of this application, such as... Figure 4 As shown, the steps for generating the second set of emotion category labels may include, but are not limited to: S1, based on the initial emotion prediction model 402, inference is performed on the initial text data 404 to obtain the emotion category labels and corresponding confidence scores in the initial text data 404; S2, Due to the low accuracy of the initial emotion prediction model, it is necessary to use the test set data 406 to search for the optimal discrimination threshold 408 for each emotion category: S2-1, Input the test set data into the initial sentiment prediction model to generate the predicted probability of each sentiment category label; S2-2, within the range [0,1], generates thresholds with a step size of 0.05, such as 0.05, 0.1, 0.15, etc. S2-3, for each emotion category: (1) For each discrimination threshold: For each test sample, the relationship between the confidence score of the sample in that emotion category and the discrimination threshold 408 is first determined. If the confidence score is greater than the discrimination threshold 408, the sample is considered to contain that emotion category; if the confidence score is greater than or equal to the discrimination threshold, the sample is considered not to contain that emotion category. Then, the predicted label for that emotion category is obtained. For all samples and the predicted emotion category labels, the recall and precision are calculated based on the pre-labeled true emotion category labels of each sample in the test set data 406. Then, a harmonic mean is generated based on the recall and precision to measure the overall performance of the initial emotion prediction model. The recall, precision, and harmonic mean corresponding to each discrimination threshold are recorded. The harmonic mean can be generated, but is not limited to, by the following formula: Recall rate = TP / (TP + FN) Precision = TP / (TP + FP) Harmonic mean = 2 (accuracy) Recall rate / (Precision + Recall rate); Where TP represents the number of true positives, FN represents the number of false negatives, and FP represents the number of false positives. True positives refer to the cases where the model correctly predicts a positive sample as a positive sample, that is, a sample that is actually a positive sample is correctly predicted as a positive sample. False negatives refer to the cases where the model incorrectly predicts a positive sample as a negative sample, that is, a sample that is actually a positive sample is incorrectly predicted as a negative sample. False positives refer to the cases where the model incorrectly predicts a negative sample as a positive sample, that is, a sample that is actually a negative sample is incorrectly predicted as a positive sample.
[0036] (2) After obtaining all the discrimination thresholds and their corresponding harmonic mean, select the discrimination threshold with the highest harmonic mean as the discrimination threshold 408 for the emotion category.
[0037] S2-4, obtain the discrimination thresholds [thr1,thr2,thr3…] for all emotion categories. 408 represents the discrimination thresholds for emotion category 1, emotion category 2, and emotion category 3. When the confidence score of emotion category 1 in the initial text data exceeds the discrimination threshold thr1, it means that the initial text data contains emotion category 1. S3, compare the predicted emotion category labels and corresponding confidence scores 410 from the initial text data in S1 with the discrimination threshold 408. If the scores are greater than the discrimination threshold 40, it indicates that the emotion category exists, and the second set of emotion category labels 412 of the initial text data is obtained, including but not limited to no emotion, one emotion, or multiple emotions. S206. Generate first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels. The first-level samples have a first emotion category label that belongs to both the first and second sets of emotion category labels. The second-level samples have a second emotion category label that belongs to the first set of emotion category labels but not to the second set of emotion category labels. The third-level samples have a third emotion category label that belongs to the second set of emotion category labels but not to the first set of emotion category labels. For example, after obtaining the first set of emotion category labels and the second set of emotion category labels, a first-level sample, a second-level sample, and a third-level sample can be generated. The first-level sample corresponds to the first emotion category label, the second-level sample corresponds to the second emotion category label, and the third-level sample corresponds to the third emotion category label. The first emotion category label, the second emotion category label, and the third emotion category label can include, but are not limited to, love, trust, happiness, ecstasy, sarcasm, anger, doubt, surprise, etc.
[0038] In one exemplary embodiment, Figure 5 This is a schematic diagram illustrating another optional text data processing method according to an embodiment of this application, such as... Figure 5 As shown, the first emotion category label 506 is present in both the first group of emotion category labels 502 and the second group of emotion category labels 504. For example, if the first-level sample is "I am happy", the emotion category label obtained after the first-level sample is predicted by the above large language model is "happy: 100" and the emotion category label obtained after the first-level sample is predicted by the above initial emotion prediction model is "happy: 80". That is, the emotion category predicted by both the large language model and the initial emotion prediction model is "happy". At this time, "happy" is the above first emotion category label with a confidence level of 1.
[0039] In yet another exemplary embodiment, such as Figure 5As shown, the first group of emotion category labels 502 contains the aforementioned second emotion category label 508, while the second group of emotion category labels 504 does not contain the aforementioned second emotion category label 508. For example, the second-level sample is "It's snowing today". After the second-level sample is predicted by the aforementioned large language model, the emotion category label obtained is "calm: 60; sad: 70". After the second-level sample is predicted by the aforementioned initial emotion prediction model, the emotion category obtained is "calm: 60". That is, the emotion categories predicted by the large language model include "calm" and "sad". However, among the emotion categories predicted by the initial emotion prediction model, since the confidence score of the predicted "sad" is 40 and the discrimination threshold of "sad" is 50, and since the confidence score of "sad" is less than the discrimination threshold, the prediction result output by the initial emotion prediction model only contains "calm: 60". At this time, "sad" is the aforementioned second emotion category label, and the confidence score corresponding to "sad" can be the confidence score of "sad" predicted by the initial emotion prediction model, that is, the confidence score is 40. "Calm" is the aforementioned first emotion category label.
[0040] In another exemplary embodiment, such as Figure 5 As shown, the second group of emotion category labels 504 contains the aforementioned third emotion category label 510, while the first group of emotion category labels 502 does not contain the aforementioned third emotion category label 510. For example, the third-level sample is "It's snowing today". The emotion category labels obtained by the first-level sample after being predicted by the aforementioned large language model are "calm: 60; sad: 70". The emotion category labels obtained by the first-level sample after being predicted by the aforementioned initial emotion prediction model are "calm: 60; happy: 80". That is, the emotion categories predicted by the large language model include "calm" and "sad", while the emotion categories predicted by the initial emotion prediction model include "calm" and "happy". At this time, "happy" is the aforementioned third emotion category label. The confidence level corresponding to "happy" can be one-tenth of the confidence level of "happy" predicted by the initial emotion prediction model, that is, the confidence level is 8. "calm" is the aforementioned first emotion category label, and "sad" is the aforementioned second emotion category label.
[0041] S208. The initial emotion prediction model is trained using the initial training samples, first-level samples, second-level samples, and third-level samples to obtain the target emotion prediction model.
[0042] Optionally, in this embodiment, the target emotion prediction model is trained from the initial emotion prediction model. The initial training samples, first-level samples, second-level samples, and third-level samples can all be used to train the initial emotion prediction model to achieve accurate identification of various emotion categories. Furthermore, before training the initial emotion prediction model, the first-level samples, second-level samples, and third-level samples can be pre-screened. S1, determine the number of samples corresponding to each initial emotion category label in a set of initial emotion category labels from the initial training samples; S2, the initial emotion category label with a sample size that meets the preset threshold is determined as the first initial emotion category label, and the initial emotion category label with a sample size that does not meet the preset threshold is determined as the second initial emotion category label. The preset threshold here can be set flexibly. S3, delete the second-level and third-level samples with the first initial emotion category label, and retain the second-level and third-level samples with the second initial emotion category label.
[0043] For example, suppose the initial training samples include the initial emotion category labels "happy" and "sad". The number of samples with the initial emotion category label "happy" in the initial training samples is 10, and the number of samples with the initial emotion category label "sad" in the initial training samples is 100. The preset threshold is 50. In this case, since the number of samples with the initial emotion category label "sad" in the initial training samples is greater than the preset threshold, it means that the number of samples with the initial emotion category label "sad" meets the preset threshold of 100. Therefore, the initial emotion category label "sad" can be determined as the first initial emotion category label. Similarly, since the number of samples with the initial emotion category label "happy" in the initial training samples is less than the preset threshold, it means that the number of samples with the initial emotion category label "happy" does not meet the preset threshold of 100. Therefore, the initial emotion category label "happy" can be determined as the second initial emotion category label.
[0044] Furthermore, samples with the first initial emotion category label (“sadness”) in the second and third level samples are deleted, and only samples with the second initial emotion category label (“happiness”) are retained, in order to increase the number of samples with the second initial emotion category label (“happiness”).
[0045] Specifically, the training process for the initial sentiment prediction model may include, but is not limited to, the following: S1, using initial training samples, first-level samples, second-level samples and third-level samples for large-scale data pre-training of the initial sentiment prediction model, including but not limited to using the adam method with a low learning rate for training the initial sentiment prediction model. S2 uses initial training samples and first-level samples to fine-tune the relatively accurate data of the initial emotion prediction model, including but not limited to using different learning rates for different target learning tasks to perform discriminative task learning. For example, since the convergence performance of embedding representation metric learning and classification tasks is different, different learning rates can be used for discriminative task learning, so as to ensure that the fast-converging classification task will not harm the emotion contrast information learned in the pre-training of the initial emotion prediction model.
[0046] Furthermore, during the training process, the initial training samples, first-level samples, second-level samples, and third-level samples can be divided into specified batches. Each batch contains a specified number of samples. For example, the initial training samples, first-level samples, second-level samples, and third-level samples include N sample data. Each batch consists of bs sample data. The number of batches is the ratio of N to bs. Each N / bs batch is completed, which represents the completion of one iteration of model parameter training. Each iteration processes N sample data once until the average loss function no longer decreases in a certain round, which indicates that the initial sentiment prediction model training is over.
[0047] It should be noted that during each training session, Figure 6 This is a schematic diagram illustrating another optional text data processing method according to an embodiment of this application, such as... Figure 6 As shown, it may include, but is not limited to: S1. Convert each character in sample data 602 into symbols such as tok1, tok2, etc., and obtain the representation vector corresponding to sample data 602 through dictionary representation mapping. Then, input the representation vector into the basic module 604 of the corresponding initial sentiment prediction model to obtain the predicted probability of the sample data under each sentiment category label. This can include, but is not limited to, vector representation. Then, calculate the total loss of the corresponding initial sentiment prediction model. This can include, but is not limited to, the multi-label classification loss with confidence constraints, expressed by the following formula:
[0048] Where y represents the emotion category label of the sample data, y ic Let represent the label of the c-th emotion category for sample i, where 1 represents a certain emotion and 0 represents negative samples. Let p represent the probability of predicting the label for each emotion category. ic Let N be the probability that the i-th sample has the c-th emotion category label. cls This indicates the number of emotion category labels learned during training, where proby icThe confidence level prob represents the label confidence of each sample. In the large-scale data pre-training of the initial sentiment prediction model using initial training samples, first-level samples, second-level samples, and third-level samples, prob represents the confidence level of different data. In the relatively accurate data fine-tuning of the initial sentiment prediction model using initial training samples and first-level samples, since the sample data are all reliable, prob is 1. When prob is 1, the loss is the cross-entropy loss function of conventional multi-class classification.
[0049] S2, the total loss is fed back to calculate the gradients of the parameters of each model in the initial sentiment prediction model; S3 updates each model parameter based on the gradient of the model parameters.
[0050] In an exemplary embodiment, the text data processing method proposed in this application can be applied to scenarios involving the mining of emotion category tags. Addressing the problem of insufficient emotion category tag samples for plot statements, it obtains emotion tag data corresponding to different confidence levels through an initial emotion prediction model and a large language model for pre-prediction and scoring. Noise is graded based on the noise levels of the emotion tag data at different confidence levels. Furthermore, the learning degree of the samples can be dynamically adjusted, dynamically introducing samples of different confidence levels into the model for learning. Thus, even when the model training label data is imbalanced, it achieves the goal of improving the generalization ability of different emotion category tags and the ability to detect data lacking labels. Specifically, the text data processing method proposed in this application can include, but is not limited to, obtaining sentence emotion tags and the confidence levels of the obtained tags, rapidly collecting large amounts of data without the need for manual annotation, and grading multiple tag data with different confidence levels. Simultaneously, the learning degree of the tag data is dynamically adjusted according to different levels. This method can be applied to scenarios including, but not limited to, capturing high-energy and sweet plot points from the entire script, promoting and marketing the series, and planning and adjusting plot development.
[0051] Furthermore, for plot statements with multiple unknown labels, inference is performed using an initial sentiment prediction model and a large language model to generate sentiments with confidence in both systems. The two types of labeled data are then graded and merged. During the training of the initial sentiment prediction model, the model predicts the statements, and the loss is automatically adjusted during training using the grading method. This includes, but is not limited to, implementations based on the initial sentiment prediction model and a natural language processing model. Specifically, in the application inference, a script statement is input, and the score of that statement on a specific sentiment category label is output, such as a love score of 0.8. A sentiment score greater than 0.5 can be set to indicate the presence of that sentiment. After obtaining the graded data, the graded data is input into the initial sentiment prediction model for training, and the extracted analytical information is input into the loss calculation for joint learning of data at different grades. Figure 7This is a schematic diagram illustrating another optional text data processing method according to an embodiment of this application, such as... Figure 7 As shown, it may include, but is not limited to: S702, Data preparation, using script statements as initial text data; S704: Input the script sentences into the large language model and the initial sentiment prediction model respectively. The large language model predicts and outputs the first set of sentiment category labels, and the initial sentiment prediction model predicts and outputs the second set of sentiment category labels. S706, Data Classification: First-level samples, second-level samples, and third-level samples are generated based on the first group of emotion category labels and the second group of emotion category labels. S708 uses initial training samples, first-level samples, second-level samples, and third-level samples to train the initial sentiment prediction model. By calculating the total loss of the corresponding initial sentiment prediction model, which may include, but is not limited to, multi-label classification loss with confidence constraints, the target sentiment prediction model is obtained.
[0052] In yet another exemplary embodiment, the text data processing method proposed in this application can be applied to application scenarios that retrieve large amounts of configuration information, and may include, but is not limited to: S1, Data preparation, using configuration information as initial text data; S2, input the configuration information into the large language model and the initial configuration information prediction model (which can be understood as the initial sentiment prediction model mentioned above). The large language model predicts and outputs the first set of configuration information category labels, and the initial configuration information prediction model predicts and outputs the second set of configuration information category labels. S3, Data Classification: Generate Level 1, Level 2, and Level 3 samples based on the first set of configuration information category labels and the second set of configuration information category labels. S4. The initial configuration information prediction model is trained using the initial training samples, first-level samples, second-level samples, and third-level samples to obtain the target configuration information prediction model.
[0053] In this embodiment, initial text data is obtained; the initial text data is input into a pre-trained large language model to obtain a first set of emotion category labels, and the initial text data is input into a pre-trained initial emotion prediction model to obtain a second set of emotion category labels. Here, the initial emotion prediction model represents a model pre-trained using initial training samples, and the large language model represents a model pre-trained using a corpus. First-level samples, second-level samples, and third-level samples are generated based on the first and second sets of emotion category labels. The first-level samples have a first emotion category label belonging to both the first and second sets of emotion category labels; the second-level samples have a second emotion category label belonging to the first set of emotion category labels but not to the second set; and the third-level samples have a third emotion category label belonging to the second set of emotion category labels but not to the first set. The initial training samples and the first-level... The method of training the initial emotion prediction model with first-level, second-level, and third-level samples to obtain the target emotion prediction model involves inputting the initial text data into the pre-trained large language model and the initial emotion prediction model respectively to determine the first and second sets of emotion category labels. Then, based on the first and second sets of emotion category labels, first-level, second-level, and third-level samples are generated. The initial emotion prediction model is trained using the first-level, second-level, and third-level samples to obtain the target emotion prediction model. This achieves the goal of balancing the amount of data of each sample type in the training samples, thereby enabling the initial emotion prediction model to better learn the features of various emotion types during the training process, improving the generalization ability and prediction accuracy of the target emotion prediction model. Furthermore, it solves the technical problem of poor prediction accuracy of emotion prediction models due to large differences in the number of samples of different categories in the training samples.
[0054] On the other hand, the first-level samples, second-level samples, and third-level samples generated based on the first set of emotion category labels and the second set of emotion category labels can all be used to train the initial emotion prediction model. That is, without the need for manual labeling, a large amount of sample data can be collected quickly, which improves the training efficiency of the initial emotion prediction model while ensuring the target emotion prediction model's ability to recognize different emotion types.
[0055] As an optional approach, the above-mentioned generation of first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels includes: determining the first emotion category label, the second emotion category label, and the third emotion category label based on the first set of emotion category labels and the second set of emotion category labels; setting the confidence level of the first emotion category label to a first preset value to generate the first-level sample, wherein the first-level sample indicates that the initial text data has a confidence level of the first emotion category label of the first preset value; setting the confidence level of the second emotion category label to a first prediction probability to generate the third-level sample. The second-level sample is defined as follows: the first prediction probability represents the probability that the initial sentiment prediction model predicts whether the initial text data has the second sentiment category label; the second-level sample represents the confidence level of the initial text data having the second sentiment category label as the first prediction probability. The confidence level of the third sentiment category label is set as the second prediction probability to generate the third-level sample, wherein the second prediction probability is less than the probability that the initial sentiment prediction model predicts whether the initial text data has the third sentiment category label; the third-level sample represents the confidence level of the initial text data having the third sentiment category label as the second prediction probability.
[0056] Optionally, in the embodiments of this application, the first set of emotion category labels may include, but is not limited to, a first emotion category label, a second emotion category label, etc., and the second set of emotion category labels may include, but is not limited to, a first emotion category label, a third emotion category label, etc.
[0057] For example, the confidence level corresponding to the first emotion category label can be used as the first preset value. The emotion category label of the first sample is the first emotion category label. Furthermore, the confidence level of the emotion category label of the first sample is the first preset value. The first preset value can be set to 1, indicating that both the large language model and the initial emotion prediction model predict that the initial text data has the first emotion category label.
[0058] For example, the confidence level corresponding to the second emotion category label can be used as the first prediction probability. Assuming the first prediction probability is 0.5, it means that after inputting the initial text data into the initial emotion prediction model, the probability that the initial text data has the second emotion category label is 50%. The emotion category label of the second sample is the second emotion category label. Furthermore, the confidence level of the emotion category label of the second sample is the first prediction probability.
[0059] Similarly, the confidence level corresponding to the third emotion category label can be used as the second prediction probability mentioned above. Suppose that after inputting the initial text data into the initial emotion prediction model, the probability that the initial text data has the third emotion category label is 80%. In this case, the second prediction probability can be any probability value less than 80%, for example, it can be 8%. In this case, the emotion category label of the third sample is the third emotion category label, and the confidence level of the emotion category label of the third sample is the second prediction probability mentioned above.
[0060] Through the embodiments of this application, a first emotion category label, a second emotion category label, and a third emotion category label are determined based on a first set of emotion category labels and a second set of emotion category labels. The confidence level of the first emotion category label can be set to a first preset value, and the confidence level of the first emotion category label corresponding to the first-level sample can be set to the first preset value. Furthermore, the confidence level of the second emotion category label can be set to a first prediction probability, and the confidence level of the second emotion category label corresponding to the second-level sample can be set to the first prediction probability. The confidence level of the third emotion category label can be set to a second prediction probability, and the confidence level of the third emotion category label corresponding to the third-level sample can be set to the second prediction probability. This shortens the time required to generate the first-level, second-level, and third-level samples, thereby achieving the technical effect of improving the generation efficiency of the first-level, second-level, and third-level samples.
[0061] As an optional approach, the above-mentioned setting the confidence level of the third emotion category label as the second prediction probability to generate the third-level sample includes: obtaining the probability that the initial emotion prediction model predicts whether the initial text data has the third emotion category label; determining the product of the probability and the second preset value as the second prediction probability; setting the confidence level of the third emotion category label as the second prediction probability; and generating the third-level sample, wherein the value range of the second preset value is 1 / a, and a is a positive integer.
[0062] In an exemplary embodiment, assuming that after the initial text data is input into the initial emotion prediction model, the probability that the initial text data has the third emotion category label is predicted to be 80%, the second preset value can be flexibly set, and this application does not limit it in any way. For example, the second preset value is 1 / 10. In this case, the second prediction probability is the product of the above probability and the second preset value, which is 8%. The confidence level of the third emotion category label corresponding to the third-level sample is 8%.
[0063] In this embodiment of the application, a second preset value is pre-set, and the probability that the initial text data predicted by the initial emotion prediction model has the above-mentioned third emotion category label is obtained. The value of the second prediction probability is determined as the product of the probability that the initial text data predicted by the initial emotion prediction model has the above-mentioned third emotion category label and the second preset value. By multiplying it with the preset value, the deviation of the target emotion prediction model output can be corrected to a certain extent, so as to improve the accuracy of emotion prediction.
[0064] As an optional approach, training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain the target emotion prediction model includes: training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain an intermediate emotion prediction model, wherein the learning rate used to train the intermediate emotion prediction model is a first learning rate; and fine-tuning the intermediate emotion prediction model using the initial training samples and the first-level samples to obtain the target emotion prediction model, wherein the learning rate used to train the target emotion prediction model is a second learning rate, which is less than the first learning rate.
[0065] Optionally, in the embodiments of this application, when training the initial emotion prediction model, the training may include, but is not limited to, using initial training samples, first-level samples, second-level samples and third-level samples to train the initial emotion prediction model to obtain the intermediate emotion prediction model, and then using the initial training samples and first-level samples to train the intermediate emotion prediction model to finally complete the training of the target emotion prediction model.
[0066] It should be noted that the model learning rate used in the process of training the initial sentiment prediction model to generate the intermediate sentiment prediction model is the first learning rate mentioned above, and the model learning rate used in the process of training the intermediate sentiment prediction model to generate the target sentiment prediction model is the second learning rate mentioned above. The value of the second learning rate is less than the value of the first learning rate.
[0067] For example, Figure 8 This is a schematic diagram illustrating another optional text data processing method according to an embodiment of this application, such as... Figure 8 As shown, the initial sentiment prediction model may include, but is not limited to, the basic text understanding module 802, the basic module 804, and the classification module 806. In the process of training the initial sentiment prediction model to generate the intermediate sentiment prediction model, the basic text understanding module 802 may be trained using the first learning rate, and the basic module 804 may include, but is not limited to, the model input layer, the model hidden layer, and the model output layer.
[0068] Furthermore, the aforementioned basic text understanding module 802 may include, but is not limited to, the Chinese-BERT-wwm model. Based on the Chinese-BERT-wwm model, a text learning task paradigm is formed that pre-trains on a large scale of language data and fine-tunes it on the target task. Figure 9 This is a schematic diagram of another optional text data processing method according to an embodiment of this application. The general fine-tuning paradigm of the BERT model (short for Chinese-BERT-wwm model) is as follows: Figure 9 As shown, CLS represents the type of input statement, and tokens 1 to N represent the description of a downstream task. For example, the input is the question statement "Please give the speaker's emotion based on the following sentence". Based on the question statement, the mapping relationship in the dictionary or the embedding (vector) representation is obtained. Here, tokens 1 to M represent the specific content used to answer the question statement, and sep is used to distinguish between the question and the specific content. For example, the question statement is "Please give the speaker's emotion based on the following sentence", and the specific content is "Xiao Li said: He is a heinous person". Paragraph is the statement that needs to be answered.
[0069] For example, the basic text understanding module 802 fine-tunes the paradigm for learning downstream tasks, transforming the input text data into tokens such as tok1, and obtaining the embeddings of the tokens corresponding to the input text through dictionary representation mapping. The basic text understanding module 802 can be trained using the ADAM learning rate as the first learning rate; for example, a first learning rate of 0.005. After training, it generates a multi-label classification of emotion categories, for example, 8 emotion category labels. Each category's prediction output is either 0 or 1, where 0 indicates no emotion category and 1 indicates the presence of an emotion category. ADAM (Adaptive Moment Estimation) is an optimization algorithm widely used in deep learning to update model weights. The optimizer combines the advantages of two extended gradient descent algorithms: Momentum and RMSprop, and introduces two hyperparameters: beta1 and beta2. In the ADAM optimizer, the learning rate is not fixed, but adaptively adjusted based on the first moment estimate (i.e., mean) and second moment estimate (i.e., variance) of the gradient. Specifically, the learning rate is set as the reciprocal of the first moment estimate of the gradient, while also taking into account the second moment estimate of the gradient.
[0070] On the other hand, in the process of training the intermediate sentiment prediction model to generate the target sentiment prediction model, the training of the basic text understanding module 802, the basic module 804, and the classification module 806 may include, but is not limited to, using a second learning rate. Specifically, the training of the basic text understanding module 802 may be set to use a learning rate of 0.001 (the aforementioned second learning rate), and the training of the classification module 806 may be set to use a learning rate of 0.01. The second learning rate of 0.001 is less than the aforementioned first learning rate of 0.005. Furthermore, the first learning rate and the second learning rate may decrease sequentially with the training batches, and may include, but is not limited to, using the SGD gradient update method for training.
[0071] In this embodiment, an initial emotion prediction model is trained using a first learning rate to obtain an intermediate emotion prediction model, and a second learning rate is used to train the intermediate emotion prediction model to obtain a target emotion prediction model. The second learning rate is less than the first learning rate to achieve phased training of the initial emotion prediction model, ensuring that the initial emotion prediction model converges steadily during training. By gradually reducing the learning rate, overfitting can be avoided during training, thereby improving the robustness and reliability of the target prediction model.
[0072] As an optional approach, the above-mentioned fine-tuning of the intermediate sentiment prediction model using the initial training samples and the first-level samples to obtain the target sentiment prediction model includes: when the intermediate sentiment prediction model includes a basic text understanding module and a classification module, setting a second learning rate for the basic text understanding module and a third learning rate for the classification module, wherein the third learning rate is greater than the first learning rate; and fine-tuning the intermediate sentiment prediction model according to the second learning rate and the third learning rate to obtain the target sentiment prediction model.
[0073] In one exemplary embodiment, such as Figure 8 As shown, the aforementioned intermediate sentiment prediction model includes a basic text understanding module 802 and a classification module 806. The intermediate sentiment prediction model can be trained using a second learning rate and a third learning rate. The learning rate used to train the basic text understanding module is set to the second learning rate, and the learning rate used to train the classification module is set to the third learning rate. The third learning rate is greater than the first learning rate. For example, the basic text understanding module 802 is trained using a learning rate of 0.001 as the second learning rate, and the classification module 806 is trained using a learning rate of 0.01 as the third learning rate. The third learning rate of 0.01 is greater than the second learning rate of 0.001. Furthermore, the third learning rate can decrease sequentially with each training batch, and can be trained using methods including but not limited to the SGD gradient update method.
[0074] In this embodiment, a second learning rate is used to train the basic text understanding module in the intermediate sentiment prediction model, and a third learning rate with a larger value than the second learning rate is used to train the classification module in the intermediate sentiment prediction model. Since the training task of the classification module is more complex, a larger learning rate is needed to converge to the optimal solution more quickly. The specific values of the second and third learning rates can be adjusted according to the actual situation so that the intermediate sentiment prediction model can achieve better training results.
[0075] As an optional approach, the above-mentioned initial emotion prediction model is trained using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain the target emotion prediction model. This includes: constructing target training samples based on the initial training samples, the first-level samples, the second-level samples, and the third-level samples, wherein each target training sample includes a piece of text data, a set of emotion category labels, and a set of confidence scores corresponding to the set of target emotion category labels; inputting the target training samples into the initial emotion prediction model in batches, and iteratively training the initial emotion prediction model to obtain the target emotion prediction model.
[0076] Optionally, in this embodiment, the target training sample may include, but is not limited to, text data, emotion category labels, and confidence scores corresponding to the emotion category labels. For example, the target training sample may include, but is not limited to, "Text data: The weather is nice today! Emotion category labels: happy, cheerful; Confidence scores: {happy: 80; cheerful: 70}". Furthermore, the target training sample may include multiple text data sets, each text data set may contain multiple emotion category labels, and each emotion category label corresponds to a confidence score.
[0077] Furthermore, the target training samples can be divided into multiple batches and input into the initial sentiment prediction model to achieve iterative training of the initial sentiment prediction model. The target training samples can be divided into multiple batches, and each batch can include, but is not limited to, the same number or different number of training samples. For example, the first batch and the second batch include 20 training samples, and the third batch includes 10 training samples. One iteration of training of the initial sentiment prediction model includes input of multiple batches of target training samples.
[0078] In the embodiments of this application, target training samples are constructed using initial training samples, first-level samples, second-level samples, and third-level samples. The initial emotion prediction model is then trained iteratively in batches using the target training samples to generate the target emotion prediction model. Through batch iterative training, the performance of the target emotion prediction model can be effectively improved, making the target emotion prediction model applicable to the emotional expression of individuals in various application scenarios.
[0079] As an optional approach, the above-mentioned target training samples are input into the initial emotion prediction model in batches, and the initial emotion prediction model is iteratively trained to obtain the target emotion prediction model. This includes: inputting the target training samples into the initial emotion prediction model in batches in the following manner, and iteratively training the initial emotion prediction model to obtain the target emotion prediction model, wherein the text data used in the current batch in the current iteration is considered the current text data, each iteration uses the full set of the target training samples for training, and each batch uses a portion of the target training samples for training; inputting the current text data into the basic text understanding module to obtain the target representation vector, wherein the dimension of the target representation vector is the same as the number of emotion categories that the initial emotion prediction model is allowed to predict. Each dimension of the target representation vector is used to represent the confidence level of the corresponding emotion category. The initial emotion prediction model includes the basic text understanding module. The target representation vector is input into the classification module to obtain the current emotion category label and the current confidence level corresponding to the current emotion category label. The initial emotion prediction model includes the classification module, and the current emotion category label represents the emotion category label predicted by the initial emotion prediction model for the current text data. The target loss value is calculated based on the set of emotion category labels, the set of confidence levels, the current emotion category label, and the current confidence level corresponding to the current text data. The model parameters of the initial emotion prediction model are adjusted based on the target loss value until the target loss value meets the preset conditions to obtain the target emotion prediction model.
[0080] Optionally, in the embodiments of this application, the aforementioned current text data can be understood as the text data used in the current batch in the current iteration. When training the initial sentiment prediction model in each iteration, the samples required are all the samples included in the target training samples. The samples required for training each batch in each round are a portion of the target training samples. That is, the samples required for different batches in the same iteration training can be the same or identical.
[0081] For example, the current text data is input into the initial sentiment prediction model. The basic text understanding module in the initial sentiment prediction model will vectorize the current text data to generate a target representation vector. This target representation vector can be understood as a mathematical representation of the emotional information expressed by the current text data. The basic text understanding module analyzes the semantics, sentiment, and context of the text data to transform it into a vector representation. The target representation vector can capture information such as the emotional color and emotional tendency contained in the current text data. The number of emotion categories that the initial sentiment prediction model allows to predict determines how many dimensions the initial sentiment prediction model needs to represent the emotional features of the current text data. That is, the dimension of the target representation vector needs to be the same as the number of emotion categories.
[0082] Specifically, assuming the current text data is "Zhang San stole my money!", the target representation vector has a dimension of "anger" with a value of 80, indicating that the confidence level of the anger emotion category is 80. The target representation vector will be processed by the classification module in the initial emotion prediction model, which will output the current emotion category label and its corresponding current confidence level. The current emotion category label can include, but is not limited to, happiness, sadness, anger, resentment, hesitation, etc. After obtaining the current emotion category label, the target loss value is calculated based on the above set of emotion category labels and the confidence level corresponding to each emotion category label. The target loss value can be generated in the following ways, including but not limited to multi-label classification loss with confidence constraints.
[0083] Furthermore, the model parameters of the initial emotion prediction model are adjusted according to the target loss value to achieve the training of the initial emotion prediction model. For example, when the target loss value no longer decreases, it means that the target loss value meets the preset condition, the training of the initial emotion prediction model ends, and the training of the initial emotion prediction model is obtained.
[0084] In this embodiment, the target training samples are input into the initial emotion prediction model in batches. The target representation vector of the target training samples is obtained in the basic text understanding module. Then, the current emotion category label and the current confidence level corresponding to the current emotion category label are obtained in the classification module. The target loss value is calculated based on a set of emotion category labels, a set of confidence levels, and the current emotion category label and current confidence level corresponding to the current text data. The model parameters of the initial emotion prediction model are adjusted based on the target loss value to achieve the purpose of iterative training of the initial emotion prediction model, thereby improving the accuracy and reliability of the target emotion prediction model when making emotion predictions.
[0085] As an optional approach, after generating first-level, second-level, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels, the method further includes: determining the number of samples corresponding to each initial emotion category label in the initial set of initial emotion category labels based on the initial training samples; determining the initial emotion category labels whose sample numbers meet a preset threshold as first initial emotion category labels, and determining the initial emotion category labels whose sample numbers do not meet the preset threshold as second initial emotion category labels; deleting the second-level and third-level samples with the first initial emotion category labels, and retaining the second-level and third-level samples with the second initial emotion category labels.
[0086] It should be noted that the aforementioned preset threshold can be set manually, and this application does not impose any restrictions on it.
[0087] In an exemplary embodiment, after obtaining the number of samples corresponding to each initial emotion category label in the initial training samples, the number of samples corresponding to each initial emotion category label is compared with a preset threshold to obtain a first initial emotion category label and a second initial emotion category label. The first initial emotion category label can be understood as an initial emotion category label whose sample number is greater than or equal to the preset threshold, that is, an initial emotion category label whose sample number corresponding to the first initial emotion category label meets the preset threshold. The second initial emotion category label can be understood as an initial emotion category label whose sample number is less than the preset threshold, that is, an initial emotion category label whose sample number corresponding to the second initial emotion category label does not meet the preset threshold.
[0088] Furthermore, second-level and third-level samples with the first initial emotion category label will be deleted, while second-level and third-level samples with the second initial emotion category label will be retained. This effectively expands the sample data, i.e., increases the number of samples with the second initial emotion category label in the initial training samples, ensuring that the number of samples with the first initial emotion category label is not significantly different from the number of samples with the second initial emotion category label. This achieves the goal of balancing the number of each sample type in the training samples of the initial emotion prediction model.
[0089] As an optional approach, before inputting the initial text data into the pre-trained initial emotion prediction model to obtain the second set of emotion category labels, the method further includes: inputting sample text data from the initial training samples into the initial emotion prediction model to obtain a target prediction probability, wherein the target prediction probability represents the probability that the initial emotion prediction model predicts whether the sample text data has a sample emotion category label, and the sample text data is pre-labeled with whether it has the sample emotion category label; obtaining a set of discrimination thresholds, wherein one of the discrimination thresholds in the set of discrimination thresholds is used together with the target prediction probability to determine the target prediction result. The target prediction result indicates whether the sample text data has the sample emotion category label. Based on the target prediction probability and the set of discrimination thresholds, the target discrimination threshold for the sample emotion category label is determined. The target discrimination threshold is the threshold with the highest balance score among the set of discrimination thresholds. The balance score is jointly determined by the target prediction result and whether the sample text data is pre-labeled with the sample emotion category label. The target discrimination threshold is set as the target model parameter of the initial emotion prediction model. In the initial emotion prediction model, the target discrimination threshold is used to determine the second set of emotion category labels.
[0090] Optionally, in this embodiment, the target prediction probability can be understood as the probability that the sample text data predicted by the initial emotion prediction model has a sample emotion category label after the sample text data is input into the initial emotion prediction model. The sample text data is pre-labeled with the presence or absence of the sample emotion category label. The set of discrimination thresholds may include, but is not limited to, multiple discrimination thresholds. The target prediction result can be understood as either the sample text data having a sample emotion category label or the sample text data not having a sample emotion category label. The sample emotion category label may include, but is not limited to, anger, happiness, sadness, anxiety, fear, etc.
[0091] For example, the above target discrimination threshold can be determined by the following steps, including but not limited to:
[0092] S1, obtain a set of discrimination thresholds and target prediction probabilities; S2, Generate a set of discrimination thresholds and corresponding balance scores. The balance scores can be calculated from the real emotion category labels pre-annotated in the sample text data in the initial training samples to calculate the recall and precision. Then, generate the harmonic mean based on the recall and precision to measure the overall performance of the initial emotion prediction model, and record the recall, precision and harmonic mean corresponding to each discrimination threshold. The harmonic mean is the balance score mentioned above. S3. After obtaining all the discrimination thresholds and their corresponding balance scores, select the discrimination threshold with the highest balance score as the discrimination threshold for the sample emotion category label. This discrimination threshold will be set as the target model parameter of the initial emotion prediction model. The target model parameter may include, but is not limited to, multiple discrimination thresholds corresponding to multiple emotion category labels.
[0093] Furthermore, the emotion category label predicted in the initial emotion prediction model will only be used as the emotion category label in the second group of emotion category labels if it is greater than or equal to the target discrimination threshold.
[0094] It should be noted that after the initial emotion prediction model is trained and the target emotion prediction model is generated, the target discrimination threshold can be adjusted again. That is, the new discrimination threshold can be used as the target model parameter of the target emotion prediction model. In practical applications, the adjusted target discrimination threshold is compared with the target prediction probability of the sample emotion category label predicted by the target emotion prediction model to generate the above target prediction result.
[0095] In this embodiment, the target discrimination thresholds corresponding to the emotion category labels of each sample are determined according to a set of discrimination thresholds. Then, when the target emotion prediction model is used to predict the emotion labels of the input text data, the target prediction results are obtained. The target discrimination thresholds can be adjusted multiple times. Thus, the target discrimination thresholds can be dynamically adjusted according to the characteristics and distribution of different emotion categories, making the target emotion prediction model more flexible and adaptable to the emotion distribution of various text data.
[0096] As an optional approach, after training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain the target emotion prediction model, the method further includes: acquiring target media resources and performing text extraction operations on the target media resources to obtain target text data; inputting the target text data into the target emotion prediction model to obtain a set of target emotion category labels and a set of target confidence scores corresponding to the set of target emotion category labels; and setting target sentiment markers for the target media resources based on the set of target emotion category labels and the set of target confidence scores, wherein the target sentiment markers are used to indicate the emotion category possessed by the target media resources.
[0097] Optionally, in the embodiments of this application, the target media resources may include, but are not limited to, script texts, novel texts, news reports, advertising copy, etc. In addition, they may include, but are not limited to, conversational text data such as dialogue records, interview recordings, and social media posts. After extracting the text from the target media resources, target text data is obtained. The target text data may be unannotated text data or partially annotated text data.
[0098] Furthermore, the target sentiment prediction model is used to label the sentiment categories contained in the target text data to obtain a set of target sentiment category labels and a target confidence level corresponding to each target sentiment category label in the set of target sentiment category labels. Thus, a target sentiment marker is set for the target media resource. The target sentiment marker can be determined by the set of target sentiment category labels and the target confidence level. For example, if the target media resource is a script, the target sentiment marker can be a marker of the emotional fluctuations of the protagonist in the script or a marker of the plot development.
[0099] For example, the target media resource is a script text, in which one episode of the script contains the changes in the emotions between the protagonists from anger, surprise, doubt, trust and love. It represents the emotional setback and the warming up as a twist, in which anger, surprise and doubt are negative emotions, and love, trust and happiness are positive emotions, when multiple twists and turns occur.
[0100] As an optional approach, the above-mentioned setting of target sentiment tags for the target media resources based on the above-mentioned set of target sentiment category tags and the above-mentioned set of target confidence scores includes: obtaining a group of sentiment category tags with opposite sentiment meanings from the above-mentioned set of sentiment category tags; setting a first sentiment tag for the target media resources based on the number of the above-mentioned sentiment category tag groups, wherein the target sentiment tag includes the above-mentioned first sentiment tag, and the above-mentioned first sentiment tag is used to indicate the plot twists and turns of the target media resources; obtaining target segments in the target media information that have the same sentiment category tags; and setting a second sentiment tag for the target segments, wherein the target sentiment tag includes the above-mentioned second sentiment tag, and the above-mentioned second sentiment tag is used to indicate that different target segments all have the above-mentioned same sentiment category tags.
[0101] For example, the aforementioned emotional category label group with opposite emotional meanings can be understood as "happy" and "sad", "calm" and "excited", etc. For instance, the protagonist in the script changes from negative emotions to positive emotions, then from positive emotions to negative emotions, and then continues to change from negative emotions to positive emotions, which is two twists and turns. The positive and negative emotions here are the aforementioned emotional category label group with opposite emotional meanings.
[0102] In an exemplary embodiment, the protagonist in the script changes from a level one negative emotion to a more negative level two negative emotion, then from a level two negative emotion to a more negative level three negative emotion, and then continues to change from a level three negative emotion to a positive emotion. This indicates that multiple emotional obstacles appear and eventually intensify, and the plot takes many twists and turns. By showing the emotional twists and turns of each episode, subjective indicators such as the degree of twists and turns of different scripts and whether they are similar to the twists and turns of the most popular scripts can be compared, which is helpful for script evaluation. It can also be used by screenwriters to rearrange the plot of the script so that each episode has enough twists and turns. Level one negative emotion, level two negative emotion, level three negative emotion, and positive emotion can all be used to mark the above-mentioned first emotional marker.
[0103] In yet another exemplary embodiment, the sweet moments in each episode of the script can be obtained more accurately. These sweet moments can be understood as the target segments with the same emotional category label. The target segments have a second emotional tag, including but not limited to piecing together target segments with the same emotional category label in the form of script quick preview, sweet moment clips, etc., so that users with different needs can quickly grasp the specific emotional plot of the script.
[0104] For example, the text data processing method proposed in this application can also be used in the application scenarios of drama series promotion and marketing. For instance, love is one of the important elements to attract viewers. By using the text data processing method proposed in this application to accurately identify the episodes in which love appears in the script, the specified episode number can be used as an important selling point for drama series promotion and marketing. By emphasizing the love plot in the drama, the interest and attention of the audience can be attracted, thereby increasing the popularity and ratings of the drama series.
[0105] In one exemplary embodiment, the text data processing method proposed in this application can be applied to the processing of script text, and may include, but is not limited to, the following: S1, Data Preparation: First, obtain the unlabeled script. For the script sentences, obtain different confidence models through the following different model methods. Taking the learning of 8 emotions such as love, trust, happiness, ecstasy, sarcasm, anger, doubt, and surprise as an example, generate emotion pseudo-label 1 (the first group of emotion category labels mentioned above) and emotion pseudo-label 2 (the first group of emotion category labels mentioned above). The text model employs a large language model to assess the emotional state of script sentences and assign scores, yielding different emotions and scores. This results in the determination of the emotion and its corresponding confidence level; for example, anger is assigned a confidence level of 0.6. Furthermore, the large text model returns labels outside the range of the first pseudo-emotion label. Since these extra labels are not part of the learning objective, they do not need to be retained. The second pseudo-emotion label can be obtained as follows: S1-1, based on the original trained emotion model, infers the script sentences to obtain each emotion and the confidence level of the emotion; S1-2, Threshold Search Method: Due to the low accuracy of the original emotion model, it is necessary to use the test set to search for the optimal discrimination threshold for each emotion. This can include, but is not limited to, the following method for obtaining the judgment method for unannotated script statements: S1-2-1, First, the test set is used to predict the probability of each emotion category label by the existing model; S1-2-2, within the range [0,1], generates thresholds with a step size of 0.05, such as 0.05, 0.1, 0.15, etc. S1-2-3, for each emotion e: (1) For each threshold thr: For each test sample, first determine the relationship between the confidence score Score_i_e and the threshold thr for the sample under the emotion e. When Score_i_e is greater than thr, the sample is considered to contain emotion e. When Score_i_e is less than or equal to thr, the sample is considered not to contain emotion e. Then, obtain the predicted label of the sample for emotion e. For all samples and the predicted emotion e label, calculate the recall, precision, and the above balance score based on the true emotion category label, and record the recall, precision, and balance score corresponding to the threshold thr. (2) For all thresholds and their corresponding balance scores, select the threshold with the highest balance score as the discrimination threshold for emotion e.
[0106] S1-2-4: After obtaining the discrimination thresholds for all emotions [thr1, thr2, trh3...], emotion discrimination is performed. Here, thr1, thr2, and trh3 represent the discrimination thresholds for emotions 1, 2, and 3, respectively. If the confidence score of emotion 1 in a sentence exceeds the threshold thr1, then emotion 1 is included. S1-2-5, When the model obtains the discrimination threshold, the unlabeled script emotion prediction results obtained in step S1-2-1 are compared with the above discrimination threshold, that is, the predicted score of each emotion is compared with the threshold. If it is greater than the threshold, it means that the emotion exists, and the unlabeled script emotion pseudo-label 2 is obtained, including no emotion, one emotion, or multiple emotions. S2, Data Classification: This involves obtaining the unlabeled pseudo-labels 1 and 2 of emotion generated from the large language model and the initial emotion prediction model in S1. For the large language model, experience suggests that the accuracy of the emotion category labels generated is high, but the confidence scores are not reliable. For the initial emotion prediction model, due to the customized learning objective, the model can provide more accurate confidence scores for results it is confident in, but performs poorly for results it is uncertain in. Therefore, data classification is performed, that is, classifying the pseudo-labels 1 and 2 into completely reliable, partially reliable, and completely unreliable categories. This allows the target emotion prediction model to process emotion category labels of varying confidence levels separately. Specific classification methods can include, but are not limited to, the following: S2-1, Generate first-level samples. For each sample data, it is necessary to obtain the intersection of the label predicted by the large language model and the label predicted by the initial sentiment prediction model. When both models predict it, it is considered that the sentiment exists. The confidence level of this sentiment is 1. For example, (tag1,1), where tag1 is the sentiment category label and 1 represents the confidence level of tag1. S2-2, Generate secondary samples. For each sample data, obtain the label predicted by the large language model but not predicted by the initial sentiment prediction model as a weakly noisy label, that is, it has very little noise. At this time, the prediction probability of this label in the initial sentiment prediction model is used as the confidence level, which is (tag2, prob2). Here, tag2 is the sentiment category label, and prob2 represents the confidence level of tag2. S2-3, generate three levels of samples. For each sample data, obtain the label that the large language model did not predict but the initial sentiment prediction model predicted, as a strong noise label. At this time, the confidence level is 1 / 10 of the prediction probability of the label in the initial sentiment prediction model, i.e. (tag3, prob3 / 10). Here, tag2 is the sentiment category label, and prob3 / 10 represents the confidence level of tag3. S2-4 summarizes the first-level, second-level, and third-level samples to obtain a series of (tag, prob) data. Each data set contains samples of all 8 tags. According to the natural distribution, there will be too much data for the head tags. That is, the data increase of the head tags is greater than the increase of the missing tags. Further filtering can be performed to ensure that the number of missing tags with insufficient data is sufficient. For missing tags, all third-level samples are retained, and for non-missing tags, only first-level samples are retained.
[0107] S3, the structure of the initial sentiment prediction model may include, but is not limited to, the following two modules: a basic feature CNN module and a sentiment category label classification module. The basic CNN module uses Chinese-BERT-wwm to obtain basic text information from the training text sentences, as shown in the table below:
[0108] Specifically, the training process of the initial sentiment prediction model may include, but is not limited to, the following steps: Record the original training set S0 and the newly added noise sample S1 to obtain S2, thus obtaining data 1. In S2, all labels can appear in tag and probability form, and the default probability of the label in the original S0 (the initial training sample) is 1. From the above S2 (the first-level, second-level, and third-level samples), select the first-level sample with a confidence level of 1 as S3, which includes the first-level samples from the original training set S0 and the newly added noise sample S1, thus obtaining data 2. The initial sentiment prediction model can be learned in two stages. In the first stage, data 1 is used for large-scale pre-training, and in the second stage, data 2 is used for relatively accurate data fine-tuning. Furthermore, based on a pre-model with the same network structure, the pre-model training is the same as the above training process, except that the parameters are initialized using the Chinese-BERT-wwm pre-trained model for the basic modules, and a Gaussian normal distribution between 0 and 1 is used for the sentiment classification head. Training is conducted using data S0, and the loss is the normal multi-class cross-entropy loss. The model training process may include, but is not limited to, the following steps: S3-1, Parameter initialization, using the parameters trained by the previous model as the initialization parameters of the initial sentiment prediction model; S3-2, set the learning parameters. In the first stage, the basic text understanding module uses a learning rate of lr=0.005 (the first learning rate mentioned above) and an Adam learning rate. In the second stage, all modules are trained. The basic text understanding module uses a learning rate of lr=0.001 (the second learning rate mentioned above) and the classification module uses a learning rate of 0.01. The learning rate decreases to 0.1 times the original rate every 10 epochs, and the SGD gradient update method is used for training.
[0109] S3-3, the first stage of full sample pre-training. For the S2 data, firstly, the basic multi-label classification is trained for the first 50 epochs, and all parameters are fine-tuned. The learning rate is designed as described in S3-2, that is, the learning rate of lr=0.001 is used for the basic classification and representation modules. Since this step is to transfer the overall learning task from the original Chinese-BERT-wwm model to the script sentiment classification of this task, it is necessary to train slowly to ensure that it does not get stuck in the local optimum but not the global optimum point too quickly. Therefore, the low learning rate adam method is adopted. S3-4, the second stage of target learning, involves fine-tuning the S3 data and training all model parameters. Since the convergence performance of embedding representation metric learning and classification tasks is different, different learning rates are used for discriminative task learning to ensure that the fast-converging classification task does not harm the pre-trained emotional contrast information. S3-5: For the full dataset of N data points, each set of data points (bs) constitutes a batch, for a total of M = N / bs batches. Completion of N / bs batches represents the completion of one epoch. Each epoch processes the entire dataset once, until the average loss value no longer decreases at a certain epoch. Training is performed on each batch according to... Figure 6 The process involves inputting data into the corresponding model module to obtain the output of one or two tasks. Two tasks constitute the second stage. In the first stage, the output of one task is obtained, the corresponding total loss is calculated, and the gradient of each parameter of the network is calculated based on the total loss. S3-6, Update the model parameters of the initial sentiment prediction model. Based on the gradients of the network parameters, update each parameter of the model.
[0110] It should be noted that both stages employ a confidence-constrained multi-label classification loss, which can be summarized as the following formula, and can be understood as an optimized form of the multi-class-based cross-entropy loss function:
[0111] Furthermore, after the above model outputs multi-label emotions, the test set can be used to perform a threshold search on each label to generate the optimal threshold for each label. That is, using S1-2 above, the threshold search method is used to compare the model prediction with the threshold of each label for each statement in each scene of each episode of the script to generate the label prediction result. Thus, the emotions of the protagonist in the script in any scene can be known, such as trust, happiness, ecstasy, sarcasm, anger, doubt, surprise, etc., and then the emotional trend of the script can be analyzed, evaluated, or the plot development can be planned.
[0112] It is understood that in the specific embodiments of this application, data such as user information are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0113] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0114] According to another aspect of the embodiments of this application, a text data processing apparatus for implementing the above-described text data processing method is also provided. For example... Figure 10 As shown, the device includes: Module 1002 is used to acquire initial text data; The prediction module 1004 is used to input the initial text data into a pre-trained large language model to obtain the first set of emotion category labels, and input the initial text data into a pre-trained initial emotion prediction model to obtain the second set of emotion category labels. Here, the initial emotion prediction model refers to the model trained in advance using the initial training samples, and the large language model refers to the model trained in advance using the corpus. The generation module 1006 is used to generate first-level samples, second-level samples and third-level samples based on the first set of emotion category labels and the second set of emotion category labels. The first-level samples have a first emotion category label that belongs to both the first set of emotion category labels and the second set of emotion category labels. The second-level samples have a second emotion category label that belongs to the first set of emotion category labels and does not belong to the second set of emotion category labels. The third-level samples have a third emotion category label that belongs to the second set of emotion category labels and does not belong to the first set of emotion category labels. Training module 1008 is used to train the initial sentiment prediction model using initial training samples, first-level samples, second-level samples, and third-level samples to obtain the target sentiment prediction model.
[0115] As an optional solution, the above-mentioned device is used to generate first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels in the following manner: determining the first emotion category label, the second emotion category label, and the third emotion category label based on the first set of emotion category labels and the second set of emotion category labels; setting the confidence level of the first emotion category label to a first preset value to generate the first-level sample, wherein the first-level sample indicates that the initial text data has a confidence level of the first emotion category label of the first preset value; setting the confidence level of the second emotion category label to a first prediction probability. The second-level samples are generated as follows: the first prediction probability represents the probability that the initial sentiment prediction model predicts whether the initial text data has the second sentiment category label; the second-level samples represent the confidence level of the initial text data having the second sentiment category label as the first prediction probability. The confidence level of the third sentiment category label is set as the second prediction probability to generate the third-level samples, wherein the second prediction probability is less than the probability that the initial sentiment prediction model predicts whether the initial text data has the third sentiment category label; the third-level samples represent the confidence level of the initial text data having the third sentiment category label as the second prediction probability.
[0116] As an optional solution, the above-mentioned device is used to set the confidence level of the third emotion category label as the second prediction probability and generate the third-level sample by: obtaining the probability that the initial emotion prediction model predicts whether the initial text data has the third emotion category label; determining the product of the probability and the second preset value as the second prediction probability; setting the confidence level of the third emotion category label as the second prediction probability and generating the third-level sample, wherein the value range of the second preset value is 1 / a, and a is a positive integer.
[0117] As an optional approach, the aforementioned apparatus is used to train the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples in the following manner to obtain a target emotion prediction model: training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain an intermediate emotion prediction model, wherein the learning rate used to train the intermediate emotion prediction model is a first learning rate; and fine-tuning the intermediate emotion prediction model using the initial training samples and the first-level samples to obtain the target emotion prediction model, wherein the learning rate used to train the target emotion prediction model is a second learning rate, and the second learning rate is less than the first learning rate.
[0118] As an optional approach, the aforementioned apparatus is used to fine-tune the intermediate sentiment prediction model using the initial training samples and the first-level samples to obtain the target sentiment prediction model: when the intermediate sentiment prediction model includes a basic text understanding module and a classification module, a second learning rate is set for the basic text understanding module and a third learning rate is set for the classification module, wherein the third learning rate is greater than the first learning rate; the intermediate sentiment prediction model is fine-tuned according to the second learning rate and the third learning rate to obtain the target sentiment prediction model.
[0119] As an optional approach, the aforementioned apparatus is used to train the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples in the following manner to obtain a target emotion prediction model: constructing target training samples based on the initial training samples, the first-level samples, the second-level samples, and the third-level samples, wherein each target training sample includes a piece of text data, a set of emotion category labels, and a set of confidence scores corresponding to the set of target emotion category labels; inputting the target training samples into the initial emotion prediction model in batches, and iteratively training the initial emotion prediction model to obtain the target emotion prediction model.
[0120] As an optional approach, the aforementioned apparatus is used to input the target training samples into the initial emotion prediction model in batches, and iteratively train the initial emotion prediction model to obtain the target emotion prediction model, in the following manner: The target training samples are input into the initial emotion prediction model in batches, and iteratively trained to obtain the target emotion prediction model, wherein the text data used in the current batch in the current iteration is considered the current text data, each iteration uses the full set of the target training samples for training, and each batch uses a portion of the target training samples for training; the current text data is input into the basic text understanding module to obtain a target representation vector, wherein the dimension of the target representation vector is the same as the number of emotion categories that the initial emotion prediction model is allowed to predict. The value of each dimension of the target representation vector is used to represent the confidence level of the corresponding emotion category. The initial emotion prediction model includes the basic text understanding module. The target representation vector is input into the classification module to obtain the current emotion category label and the current confidence level corresponding to the current emotion category label. The initial emotion prediction model includes the classification module, and the current emotion category label represents the emotion category label that the initial emotion prediction model predicts the current text data to have. The target loss value is calculated based on the set of emotion category labels, the set of confidence levels, the current emotion category label, and the current confidence level corresponding to the current text data. The model parameters of the initial emotion prediction model are adjusted based on the target loss value until the target loss value meets the preset conditions to obtain the target emotion prediction model.
[0121] As an optional solution, the above-mentioned device is further configured to: after generating first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels, determine the number of samples corresponding to each initial emotion category label in the initial set of initial emotion category labels based on the initial training samples; determine the initial emotion category labels whose sample number meets a preset threshold as first initial emotion category labels, and determine the initial emotion category labels whose sample number does not meet the preset threshold as second initial emotion category labels; delete the second-level samples and the third-level samples with the first initial emotion category labels, and retain the second-level samples and the third-level samples with the second initial emotion category labels.
[0122] As an optional solution, the above-mentioned apparatus is further configured to: before inputting the initial text data into a pre-trained initial emotion prediction model to obtain a second set of emotion category labels, input sample text data from the initial training samples into the initial emotion prediction model to obtain a target prediction probability, wherein the target prediction probability represents the probability that the initial emotion prediction model predicts whether the sample text data has a sample emotion category label, and the sample text data is pre-labeled as to whether it has the sample emotion category label; and obtain a set of discrimination thresholds, wherein one of the discrimination thresholds in the set of discrimination thresholds is used together with the target prediction probability to determine the target prediction result. The target prediction result indicates whether the sample text data has the sample emotion category label. Based on the target prediction probability and the set of discrimination thresholds, the target discrimination threshold for the sample emotion category label is determined. The target discrimination threshold is the threshold with the highest balance score among the set of discrimination thresholds. The balance score is jointly determined by the target prediction result and whether the sample text data is pre-labeled with the sample emotion category label. The target discrimination threshold is set as the target model parameter of the initial emotion prediction model. In the initial emotion prediction model, the target discrimination threshold is used to determine the second set of emotion category labels.
[0123] As an optional solution, the above-mentioned apparatus is further configured to: train the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain a target emotion prediction model; acquire a target media resource and perform text extraction on the target media resource to obtain target text data; input the target text data into the target emotion prediction model to obtain a set of target emotion category labels and a set of target confidence scores corresponding to the set of target emotion category labels; and set target sentiment markers for the target media resource based on the set of target emotion category labels and the set of target confidence scores, wherein the target sentiment markers are used to indicate the emotion category possessed by the target media resource.
[0124] As an optional solution, the above-mentioned device is used to set target emotion tags for the target media resource based on the set of target emotion category tags and the set of target confidence levels in the following manner: obtaining emotion category tag groups with opposite emotional meanings from the set of emotion category tags; setting a first emotion tag for the target media resource based on the number of emotion category tag groups, wherein the target emotion tag includes the first emotion tag, and the first emotion tag is used to indicate the plot twists of the target media resource; obtaining target segments with the same emotion category tags from the target media information; and setting a second emotion tag for the target segments, wherein the target emotion tag includes the second emotion tag, and the second emotion tag is used to indicate that different target segments all have the same emotion category tags.
[0125] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0126] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0127] According to one aspect of this application, a computer program product is provided, the computer program product comprising a computer program.
[0128] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0129] Figure 11 A schematic block diagram of a computer system architecture for implementing an electronic device according to embodiments of the present application is shown.
[0130] It should be noted that, Figure 11 The computer system 1100 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0131] like Figure 11As shown, the computer system 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 1102 or programs loaded from storage section 1108 into random access memory (RAM). The RAM 1103 also stores various programs and data required for system operation. The CPU 1101, ROM 1102, and RAM 1103 are interconnected via a bus 1104. An input / output interface 1105 (I / O interface) is also connected to the bus 1104.
[0132] The following components are connected to the input / output interface 1105: an input section 1106 including a keyboard, mouse, etc.; an output section 1107 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a local area network card, modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the input / output interface 1105 as needed. Removable media 1111, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on the drive 1110 as needed so that computer programs read from them can be installed into the storage section 1108 as needed.
[0133] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1109, and / or installed from removable medium 1111. When the computer program is executed by central processing unit 1101, it performs various functions defined in the system of this application.
[0134] In such an embodiment, the computer program can be downloaded and installed from a network via communication section 1109, and / or installed from removable media 1111. When the computer program is executed by central processing unit 1101, it performs various functions provided in the embodiments of this application.
[0135] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described text data processing method is also provided. This electronic device may be... Figure 1 The terminal device or server shown. This embodiment uses this electronic device as an example for illustration. Figure 12 As shown, the electronic device includes a memory 1202 and a processor 1204. The memory 1202 stores a computer program, and the processor 1204 is configured to execute the steps of any of the above method embodiments through the computer program.
[0136] Optionally, in this embodiment, the aforementioned electronic device may be located in at least one of a plurality of network devices in a computer network.
[0137] Optionally, in this embodiment, the processor may be configured to execute the methods in the embodiments of this application via a computer program.
[0138] Alternatively, as those skilled in the art will understand, Figure 12 The structure shown is for illustrative purposes only. Figure 12 This does not limit the structure of the aforementioned electronic devices. For example, the electronic device may also include components that are more... Figure 12 The more or fewer components shown (such as network interfaces, etc.), or having the same Figure 12 The different configurations shown.
[0139] The memory 1202 can be used to store software programs and modules, such as the program instructions / modules corresponding to the text data processing method and apparatus in this embodiment. The processor 1204 executes various functional applications and data processing by running the software programs and modules stored in the memory 1202, thereby implementing the aforementioned text data processing method. The memory 1202 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1202 may further include memory remotely located relative to the processor 1204, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Specifically, the memory 1202 may be used, but is not limited to, to store information such as first-level samples, second-level samples, and third-level samples. As an example, such as... Figure 12 As shown, the memory 1202 may include, but is not limited to, the acquisition module 1002, prediction module 1004, generation module 1006, and training module 1008 from the text data processing device. Furthermore, it may include, but is not limited to, other module units from the text data processing device, which will not be elaborated upon in this example.
[0140] Optionally, the transmission device 1206 described above is used to receive or send data via a network. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 1206 includes a Network Interface Controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 1206 is a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0141] In addition, the aforementioned electronic device also includes: a display 1208 for displaying the target prediction results; and a connection bus 1210 for connecting the various module components in the aforementioned electronic device.
[0142] In other embodiments, the aforementioned terminal device or server can be a node in a distributed system, wherein the distributed system can be a blockchain system, which is a distributed system formed by connecting multiple nodes through network communication. The nodes can form a peer-to-peer network, and any form of computing device, such as a server, terminal, or other electronic device, can become a node in the blockchain system by joining this peer-to-peer network.
[0143] According to one aspect of this application, a computer-readable storage medium is provided, wherein a processor of an electronic device reads computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the electronic device to perform the text data processing method provided in various alternative implementations of the above-described text data processing aspect.
[0144] Optionally, in this embodiment, the computer-readable storage medium described above may be configured to store methods for performing the embodiments of this application.
[0145] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0146] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0147] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more electronic devices to execute all or part of the steps of the methods described in the various embodiments of this application.
[0148] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0149] In the several embodiments provided in this application, it should be understood that the disclosed application can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between units or modules may be electrical or other forms.
[0150] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0151] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0152] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for processing text data, characterized in that, include: Get the initial text data; The initial text data is input into a pre-trained large language model to obtain a first set of emotion category labels, and the initial text data is input into a pre-trained initial emotion prediction model to obtain a second set of emotion category labels. The initial emotion prediction model refers to a model trained in advance using initial training samples, and the large language model refers to a model trained in advance using a corpus. First-level samples, second-level samples, and third-level samples are generated based on the first set of emotion category labels and the second set of emotion category labels. The first-level samples have a first emotion category label that belongs to both the first set of emotion category labels and the second set of emotion category labels. The second-level samples have a second emotion category label that belongs to the first set of emotion category labels but not to the second set of emotion category labels. The third-level samples have a third emotion category label that belongs to the second set of emotion category labels but not to the first set of emotion category labels. The initial emotion prediction model is trained using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain an intermediate emotion prediction model; the intermediate emotion prediction model is then fine-tuned using the initial training samples and the first-level samples to obtain a target emotion prediction model.
2. The method according to claim 1, characterized in that, The process of generating first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels includes: The first emotion category label, the second emotion category label, and the third emotion category label are determined based on the first group of emotion category labels and the second group of emotion category labels; The confidence level of the first emotion category label is set to a first preset value to generate the first level sample, wherein the first level sample represents the initial text data having the confidence level of the first emotion category label as the first preset value; The confidence level of the second emotion category label is set to the first prediction probability to generate the second level sample. The first prediction probability represents the probability that the initial emotion prediction model predicts whether the initial text data has the second emotion category label. The second level sample represents the confidence level of the initial text data having the second emotion category label as the first prediction probability. The confidence level of the third emotion category label is set as the second prediction probability to generate the third-level sample, wherein the second prediction probability is less than the probability that the initial emotion prediction model predicts whether the initial text data has the third emotion category label, and the third-level sample indicates that the confidence level of the initial text data having the third emotion category label is the second prediction probability.
3. The method according to claim 2, characterized in that, The step of setting the confidence level of the third emotion category label as the second predicted probability to generate the third-level sample includes: Obtain the probability that the initial sentiment prediction model predicts whether the initial text data has the third sentiment category label; The product of the probability and the second preset value is determined as the second predicted probability, and the confidence level of the third emotion category label is set as the second predicted probability to generate the third-level sample. The value range of the second preset value is 1 / a, where a is a positive integer.
4. The method according to claim 1, characterized in that, The step of training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain the target emotion prediction model includes: The learning rate used to train the intermediate sentiment prediction model is the first learning rate. The learning rate used to train the target emotion prediction model is a second learning rate, which is less than the first learning rate.
5. The method according to claim 4, characterized in that, The step of fine-tuning the intermediate sentiment prediction model using the initial training samples and the first-level samples to obtain the target sentiment prediction model includes: In the case where the intermediate sentiment prediction model includes a basic text understanding module and a classification module, a second learning rate is set for the basic text understanding module and a third learning rate is set for the classification module, wherein the third learning rate is greater than the first learning rate; The intermediate emotion prediction model is fine-tuned according to the second learning rate and the third learning rate to obtain the target emotion prediction model.
6. The method according to claim 1, characterized in that, The step of training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain the target emotion prediction model includes: A target training sample is constructed based on the initial training sample, the first-level sample, the second-level sample, and the third-level sample, wherein a target training sample includes a piece of text data, a set of emotion category labels, and a set of confidence scores corresponding to the set of emotion category labels; The target training samples are input into the initial emotion prediction model in batches, and the initial emotion prediction model is iteratively trained to obtain the target emotion prediction model.
7. The method according to claim 6, characterized in that, The step of inputting the target training samples into the initial emotion prediction model in batches and iteratively training the initial emotion prediction model to obtain the target emotion prediction model includes: The target training samples are input into the initial emotion prediction model in batches in the following manner, and the initial emotion prediction model is iteratively trained to obtain the target emotion prediction model. In the current iteration, the text data used in the current batch is regarded as the current text data. Each iteration uses the full set of the target training samples for training, and each batch uses a portion of the target training samples for training. The current text data is input into the basic text understanding module to obtain the target representation vector, wherein the dimension of the target representation vector is the same as the number of emotion categories that the initial emotion prediction model allows to predict, and the value of each dimension of the target representation vector is used to represent the confidence level of the corresponding emotion category. The initial emotion prediction model includes the basic text understanding module. The target representation vector is input into the classification module to obtain the current emotion category label and the current confidence level corresponding to the current emotion category label. The initial emotion prediction model includes the classification module, and the current emotion category label represents the emotion category label that the initial emotion prediction model predicts the current text data to have. The target loss value is calculated based on the set of emotion category labels corresponding to the current text data, the set of confidence scores, and the current emotion category labels and the current confidence scores. The model parameters of the initial emotion prediction model are adjusted based on the target loss value until the target loss value meets the preset conditions, thus obtaining the target emotion prediction model.
8. The method according to claim 1, characterized in that, After generating first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels, the method further includes: Based on the initial training samples, determine the number of samples corresponding to each initial emotion category label in a set of initial emotion category labels; The initial emotion category label whose sample size meets the preset threshold is determined as the first initial emotion category label, and the initial emotion category label whose sample size does not meet the preset threshold is determined as the second initial emotion category label; Delete the second-level samples and the third-level samples that have the first initial emotion category label, and retain the second-level samples and the third-level samples that have the second initial emotion category label.
9. The method according to claim 1, characterized in that, Before inputting the initial text data into the pre-trained initial emotion prediction model to obtain the second set of emotion category labels, the method further includes: The sample text data in the initial training samples is input into the initial sentiment prediction model to obtain the target prediction probability, wherein the target prediction probability represents the probability that the initial sentiment prediction model predicts whether the sample text data has a sample sentiment category label, and the sample text data is pre-labeled with whether it has the sample sentiment category label; A set of discrimination thresholds is obtained, wherein one of the discrimination thresholds in the set of discrimination thresholds is used together with the target prediction probability to determine the target prediction result, and the target prediction result indicates whether the sample text data has the sample emotion category label; Based on the target prediction probability and the set of discrimination thresholds, the target discrimination threshold for the sample emotion category label is determined, wherein the target discrimination threshold is the threshold with the highest balance score among the set of discrimination thresholds, and the balance score is jointly determined by the target prediction result and whether the sample text data is pre-labeled with the sample emotion category label; The target discrimination threshold is set as the target model parameter of the initial emotion prediction model, wherein the target discrimination threshold is used to determine the second group of emotion category labels in the initial emotion prediction model.
10. The method according to claim 1, characterized in that, After training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain the target emotion prediction model, the method further includes: Acquire the target media resource and perform text extraction on the target media resource to obtain target text data; The target text data is input into the target sentiment prediction model to obtain a set of target sentiment category labels and a set of target confidence scores corresponding to the set of target sentiment category labels; A target sentiment marker is set for the target media resource based on the set of target sentiment category labels and the set of target confidence scores, wherein the target sentiment marker is used to indicate the sentiment category of the target media resource.
11. The method according to claim 10, characterized in that, The step of setting target sentiment tags for the target media resources based on the set of target sentiment category labels and the set of target confidence scores includes: Obtain the emotion category tag groups with opposite emotional meanings from the set of emotion category tags; set a first emotion tag for the target media resource according to the number of emotion category tag groups, wherein the target emotion tag includes the first emotion tag, and the first emotion tag is used to indicate the plot twists of the target media resource; Obtain target segments with the same emotion category label from the target media information; set a second emotion tag for the target segments, wherein the target emotion tag includes the second emotion tag, and the second emotion tag is used to indicate that different target segments all have the same emotion category label.
12. A text data processing apparatus, characterized in that, include: The acquisition module is used to acquire initial text data; The prediction module is used to input the initial text data into a pre-trained large language model to obtain a first set of emotion category labels, and to input the initial text data into a pre-trained initial emotion prediction model to obtain a second set of emotion category labels. The initial emotion prediction model refers to a model trained in advance using initial training samples, and the large language model refers to a model trained in advance using a corpus. The generation module is used to generate first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels. The first-level samples have a first emotion category label that belongs to both the first set of emotion category labels and the second set of emotion category labels. The second-level samples have a second emotion category label that belongs to the first set of emotion category labels but not to the second set of emotion category labels. The third-level samples have a third emotion category label that belongs to the second set of emotion category labels but not to the first set of emotion category labels. The device is further configured to: train the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain an intermediate emotion prediction model; and fine-tune the intermediate emotion prediction model using the initial training samples and the first-level samples to obtain a target emotion prediction model.
13. The apparatus according to claim 12, characterized in that, The device is used to generate first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels in the following manner: The first emotion category label, the second emotion category label, and the third emotion category label are determined based on the first group of emotion category labels and the second group of emotion category labels; The confidence level of the first emotion category label is set to a first preset value to generate the first level sample, wherein the first level sample represents the initial text data having the confidence level of the first emotion category label as the first preset value; The confidence level of the second emotion category label is set to the first prediction probability to generate the second level sample. The first prediction probability represents the probability that the initial emotion prediction model predicts whether the initial text data has the second emotion category label. The second level sample represents the confidence level of the initial text data having the second emotion category label as the first prediction probability. The confidence level of the third emotion category label is set as the second prediction probability to generate the third-level sample, wherein the second prediction probability is less than the probability that the initial emotion prediction model predicts whether the initial text data has the third emotion category label, and the third-level sample indicates that the confidence level of the initial text data having the third emotion category label is the second prediction probability.
14. The apparatus according to claim 13, characterized in that, The device is used to generate the third-level sample by setting the confidence level of the third emotion category label to a second predicted probability in the following manner: Obtain the probability that the initial sentiment prediction model predicts whether the initial text data has the third sentiment category label; The product of the probability and the second preset value is determined as the second predicted probability, and the confidence level of the third emotion category label is set as the second predicted probability to generate the third-level sample. The value range of the second preset value is 1 / a, where a is a positive integer.
15. The apparatus according to claim 12, characterized in that, The device is used to train the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples in the following manner to obtain a target emotion prediction model: The learning rate used to train the intermediate sentiment prediction model is the first learning rate. The learning rate used to train the target emotion prediction model is a second learning rate, which is less than the first learning rate.
16. The apparatus according to claim 15, characterized in that, The device is used to fine-tune the intermediate sentiment prediction model using the initial training samples and the first-level samples in the following manner to obtain a target sentiment prediction model: In the case where the intermediate sentiment prediction model includes a basic text understanding module and a classification module, a second learning rate is set for the basic text understanding module and a third learning rate is set for the classification module, wherein the third learning rate is greater than the first learning rate; The intermediate emotion prediction model is fine-tuned according to the second learning rate and the third learning rate to obtain the target emotion prediction model.
17. The apparatus according to claim 12, characterized in that, The device is used to train the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples in the following manner to obtain a target emotion prediction model: A target training sample is constructed based on the initial training sample, the first-level sample, the second-level sample, and the third-level sample, wherein a target training sample includes a piece of text data, a set of emotion category labels, and a set of confidence scores corresponding to the set of emotion category labels; The target training samples are input into the initial emotion prediction model in batches, and the initial emotion prediction model is iteratively trained to obtain the target emotion prediction model.
18. The apparatus according to claim 17, characterized in that, The device is used to input the target training samples into the initial emotion prediction model in batches in the following manner, and to iteratively train the initial emotion prediction model to obtain the target emotion prediction model: The target training samples are input into the initial emotion prediction model in batches in the following manner, and the initial emotion prediction model is iteratively trained to obtain the target emotion prediction model. In the current iteration, the text data used in the current batch is regarded as the current text data. Each iteration uses the full set of the target training samples for training, and each batch uses a portion of the target training samples for training. The current text data is input into the basic text understanding module to obtain the target representation vector, wherein the dimension of the target representation vector is the same as the number of emotion categories that the initial emotion prediction model allows to predict, and the value of each dimension of the target representation vector is used to represent the confidence level of the corresponding emotion category. The initial emotion prediction model includes the basic text understanding module. The target representation vector is input into the classification module to obtain the current emotion category label and the current confidence level corresponding to the current emotion category label. The initial emotion prediction model includes the classification module, and the current emotion category label represents the emotion category label that the initial emotion prediction model predicts the current text data to have. The target loss value is calculated based on the set of emotion category labels corresponding to the current text data, the set of confidence scores, and the current emotion category labels and the current confidence scores. The model parameters of the initial emotion prediction model are adjusted based on the target loss value until the target loss value meets the preset conditions, thus obtaining the target emotion prediction model.
19. The apparatus according to claim 12, characterized in that, After generating first-level samples, second-level samples, and third-level samples based on the first set of emotion category labels and the second set of emotion category labels, the device is further configured to: Based on the initial training samples, determine the number of samples corresponding to each initial emotion category label in a set of initial emotion category labels; The initial emotion category label whose sample size meets the preset threshold is determined as the first initial emotion category label, and the initial emotion category label whose sample size does not meet the preset threshold is determined as the second initial emotion category label; Delete the second-level samples and the third-level samples that have the first initial emotion category label, and retain the second-level samples and the third-level samples that have the second initial emotion category label.
20. The apparatus according to claim 12, characterized in that, Before inputting the initial text data into the pre-trained initial emotion prediction model to obtain the second set of emotion category labels, the device is further configured to: The sample text data in the initial training samples is input into the initial sentiment prediction model to obtain the target prediction probability, wherein the target prediction probability represents the probability that the initial sentiment prediction model predicts whether the sample text data has a sample sentiment category label, and the sample text data is pre-labeled with whether it has the sample sentiment category label; A set of discrimination thresholds is obtained, wherein one of the discrimination thresholds in the set of discrimination thresholds is used together with the target prediction probability to determine the target prediction result, and the target prediction result indicates whether the sample text data has the sample emotion category label; Based on the target prediction probability and the set of discrimination thresholds, the target discrimination threshold for the sample emotion category label is determined, wherein the target discrimination threshold is the threshold with the highest balance score among the set of discrimination thresholds, and the balance score is jointly determined by the target prediction result and whether the sample text data is pre-labeled with the sample emotion category label; The target discrimination threshold is set as the target model parameter of the initial emotion prediction model, wherein the target discrimination threshold is used to determine the second group of emotion category labels in the initial emotion prediction model.
21. The apparatus according to claim 12, characterized in that, After training the initial emotion prediction model using the initial training samples, the first-level samples, the second-level samples, and the third-level samples to obtain the target emotion prediction model, the device is further configured to: Acquire the target media resource and perform text extraction on the target media resource to obtain target text data; The target text data is input into the target sentiment prediction model to obtain a set of target sentiment category labels and a set of target confidence scores corresponding to the set of target sentiment category labels; A target sentiment marker is set for the target media resource based on the set of target sentiment category labels and the set of target confidence scores, wherein the target sentiment marker is used to indicate the sentiment category of the target media resource.
22. The apparatus according to claim 21, characterized in that, The device is used to set target sentiment tags for the target media resource based on the set of target sentiment category tags and the set of target confidence scores in the following manner: Obtain the emotion category tag groups with opposite emotional meanings from the set of emotion category tags; set a first emotion tag for the target media resource according to the number of emotion category tag groups, wherein the target emotion tag includes the first emotion tag, and the first emotion tag is used to indicate the plot twists of the target media resource; Obtain target segments with the same emotion category label from the target media information; set a second emotion tag for the target segments, wherein the target emotion tag includes the second emotion tag, and the second emotion tag is used to indicate that different target segments all have the same emotion category label.
23. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein the computer program can be executed by an electronic device to perform the method described in any one of claims 1 to 11.
24. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program performs the steps of the method described in any one of claims 1 to 11.
25. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 11 through the computer program.
Citation Information
Patent Citations
Text classification model training method, text classification method, equipment and medium
CN113139051A
Emotion recognition model training method and device and storage medium
CN115391531A
