Emotion classification model training method, public opinion monitoring method, and related device

By deleting and replacing key words in news texts, the sentiment classification model is explicitly optimized, solving the problems of model overfitting and training data bias, and improving the model's recognition performance and interpretability on unseen news.

CN116304053BActive Publication Date: 2026-05-29MASHANG CONSUMER FINANCE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
MASHANG CONSUMER FINANCE CO LTD
Filing Date
2023-03-24
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing sentiment classification models are prone to overfitting or training data bias when dealing with long texts, resulting in poor recognition performance on unseen news. Furthermore, implicit perturbation methods offer limited improvement and lack interpretability.

Method used

Candidate sentences are generated by removing individual words from key sentences in news texts, and keywords are identified through a sentiment classification model. Word replacement is then performed to enhance the training data, thus explicitly optimizing the sentiment classification model.

Benefits of technology

It improves the robustness and interpretability of the sentiment classification model, enabling it to more accurately identify the sentiment tendencies of news texts and support accurate monitoring of public opinion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116304053B_ABST
    Figure CN116304053B_ABST
Patent Text Reader

Abstract

The application discloses a training method of an emotion classification model, an opinion monitoring method and related equipment. The training method comprises: performing a deletion operation on a single word in a key sentence of a first text respectively to obtain a plurality of candidate sentences; performing emotion classification on the key sentence and the plurality of candidate sentences respectively by using an emotion classification model to obtain an emotion classification result of the key sentence and emotion classification results of the candidate sentences; determining a key word in the key sentence based on the emotion classification result of the key sentence and the emotion classification results of the candidate sentences; performing word replacement on the key word in the key sentence to obtain an enhanced key sentence corresponding to the key sentence; and performing optimization training on the emotion classification model based on the key sentence and the enhanced key sentence corresponding to the key sentence.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language processing technology, and in particular to a training method for an emotion classification model, a public opinion monitoring method, and related equipment. Background Technology

[0002] In financial institutions such as securities firms and banks, it is often necessary to extract information from important macroeconomic and financial news, mid-level industry news, and micro-level corporate news. Extracting information from these news items, identifying positive and negative sentiment, and conducting sentiment analysis to assist business decision-making is an important task.

[0003] However, news sentiment analysis presents numerous challenges. Generally, news sentiment analysis is a long-text classification task. Directly feeding data into a model for binary sentiment analysis yields unsatisfactory results, as the model fails to capture data features, leading to overfitting. Extracting key sentences directly from news articles for model training and then using the trained model for classification results in biased training data. For example, news about stock price increases / decreases is far more frequent than news about executives reducing their holdings. This makes the model unfamiliar with many other types of data, leading to decreased model accuracy.

[0004] In related technologies, in order to enable the model to have a good recognition effect on news that it has never seen before, some perturbation is usually added after the data is encoded. For example, multiple dropout methods are used to obtain different vector encodings of the same text, or perturbation is added during training, such as adding a perturbation along the gradient direction during each round of parameter optimization to improve the robustness of the model.

[0005] However, these methods are all implicit and lack interpretability. Even if they are effective, they cannot guide further optimization efforts. They are a complete black box for the business scenario, and the improvement effect of the aforementioned implicit methods on the model is limited. Summary of the Invention

[0006] The purpose of this application is to provide a training method for a sentiment classification model, a public opinion monitoring method, and related equipment, which are used to improve the robustness of the sentiment classification model in an explicit and controllable manner, so that the sentiment classification model can have a better recognition effect on news that it has never seen before.

[0007] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:

[0008] In a first aspect, embodiments of this application provide a method for training an emotion classification model, comprising:

[0009] By deleting individual words from the key sentences in the first text, multiple candidate sentences are obtained.

[0010] The sentiment classification model is used to classify the sentiment of the key sentence and the multiple candidate sentences respectively, so as to obtain the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence.

[0011] Based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence, the keywords in the key sentence are determined;

[0012] The keywords in the key sentence are replaced with words to obtain the enhanced key sentence corresponding to the key sentence;

[0013] The sentiment classification model is optimized and trained based on the key sentence and the corresponding enhanced key sentence.

[0014] The training method for the sentiment classification model provided in this application embodiment obtains multiple candidate sentences by deleting a single word from a key sentence in a first text. That is, each candidate sentence lacks a certain word compared to the first text. Then, considering that the sentiment tendency reflected by a sentence is influenced by the words it contains, and that the difference in sentiment tendency before and after deleting a certain word can reflect the influence of that word on the sentence to a certain extent, the sentiment classification model is used to classify the key sentence and multiple candidate sentences separately, obtaining the sentiment classification results for the key sentence and each candidate sentence. Based on the difference between the sentiment classification results of the key sentence and each candidate sentence, keywords that have a significant impact on the key sentence can be obtained. Furthermore, the method further... By replacing keywords in key sentences to obtain enhanced key sentences, and optimizing the sentiment classification model based on these enhanced key sentences, the training data for the sentiment classification model is essentially increased, thus enhancing the training data. Since this direct word replacement data augmentation method is explicit, it facilitates verification and model training by relevant personnel. It also helps personnel easily identify which training data was used for model training, thus providing interpretability and making the training effect of the sentiment classification model controllable and optimization-friendly. Furthermore, the method in this embodiment enhances keywords in key sentences that significantly influence sentiment tendencies, which improves the effectiveness of the training data and consequently enhances the robustness of the sentiment classification model.

[0015] Secondly, embodiments of this application provide a public opinion monitoring method, including:

[0016] Obtain news texts related to the target topic from the target website;

[0017] Extract the target key sentences from the news text;

[0018] The target key sentence is classified into sentiments using a sentiment classification model to obtain the sentiment classification result of the target key sentence. The sentiment classification model is trained based on the training method of the sentiment classification model described in the first aspect.

[0019] Based on the sentiment classification results of the target key sentences in the news text, the public opinion category on the target topic on the target website is determined.

[0020] The public opinion monitoring method provided in this application extracts target key sentences from news texts on a target topic on a target website, and performs sentiment classification on the target key sentences using a trained sentiment classification model to obtain the sentiment classification result of the target key sentences. Since the target key sentences are sentences that have a significant impact on the news text and can reflect the main content of the news text, the trained sentiment classification model can accurately identify the sentiment classification of the target key sentences. Therefore, the sentiment tendency of the target key sentences can accurately reflect the sentiment tendency of the news text. Furthermore, based on the sentiment classification result of the target key sentences in the news text, the public opinion category on the target topic on the target website is determined, which is conducive to achieving accurate monitoring of public opinion on the target topic on the target website.

[0021] Thirdly, embodiments of this application provide a training apparatus for an emotion classification model, comprising:

[0022] The deletion unit is used to delete individual words in the key sentences of the first text to obtain multiple candidate sentences.

[0023] The first classification unit is used to perform sentiment classification on the key sentence and the multiple candidate sentences respectively through a sentiment classification model, so as to obtain the sentiment classification result of the key sentence and the sentiment classification result of each candidate sentence;

[0024] The first determining unit is used to determine the keywords in the key sentence based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence;

[0025] An enhancement unit is used to replace keywords in the key sentence to obtain an enhanced key sentence corresponding to the key sentence.

[0026] The training unit is used to optimize and train the sentiment classification model based on the key sentence and the enhanced key sentence corresponding to the key sentence.

[0027] Fourthly, embodiments of this application provide a public opinion monitoring device, including:

[0028] The acquisition unit is used to acquire news texts related to the target topic from the target website.

[0029] Extraction unit, used to extract target key sentences from the news text;

[0030] The second classification unit is used to classify the target key sentence by sentiment using a sentiment classification model to obtain the sentiment classification result of the target key sentence. The sentiment classification model is trained based on the training method of the sentiment classification model described in the first aspect.

[0031] The second determining unit is used to determine the public opinion category on the target website regarding the target topic based on the sentiment classification results of the target key sentences in the news text.

[0032] Fifthly, embodiments of this application provide an electronic device, including: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the training method for the sentiment classification model as described in the first aspect; or, the processor is configured to execute the instructions to implement the public opinion monitoring method as described in the second aspect.

[0033] In a sixth aspect, embodiments of this application provide a computer-readable storage medium that, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the training method for the sentiment classification model as described in the first aspect; or, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the public opinion monitoring method as described in the second aspect. Attached Figure Description

[0034] 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:

[0035] Figure 1 A schematic diagram of the structure of a training device for an emotion classification model provided in one embodiment of this application;

[0036] Figure 2 A schematic diagram illustrating sentence segmentation based on a sliding window, as provided in one embodiment of this application;

[0037] Figure 3A A schematic diagram illustrating attention score information based on a multi-head attention mechanism, provided as an embodiment of this application;

[0038] Figure 3B A schematic diagram illustrating attention score information based on a single-head attention mechanism, provided as an embodiment of this application;

[0039] Figure 4 A flowchart illustrating a public opinion monitoring method provided as an embodiment of this application;

[0040] Figure 5 A schematic diagram of the structure of a training device for an emotion classification model provided in one embodiment of this application;

[0041] Figure 6 A schematic diagram of the structure of a public opinion monitoring device provided in one embodiment of this application;

[0042] Figure 7 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Detailed Implementation

[0043] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0044] The terms "first," "second," etc., used in this specification and claims are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein. Furthermore, in this specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0045] Explanation of some concepts:

[0046] BERT (Bidirectional Encoder Representations from Transformers) is a language representation model that uses a bidirectional encoder from Transformers. It consists of a pre-training part for training the language model and a fine-tuning part, where the fine-tuning part uses the pre-trained language model for fine-tuning. It is widely used in tasks such as text classification and text matching.

[0047] Sentiment analysis, also known as sentiment classification, opinion mining, or sentiment analysis, is simply the process of analyzing, processing, summarizing, and inferring from subjective text that carries emotional connotations. The internet (such as blogs, forums, and social service networks) generates a vast amount of valuable user-generated comments on topics such as people, events, and products.

[0048] TF-IDF (term frequency–inverse document frequency) is a commonly used weighting technique in information retrieval and data mining. TF-IDF is a statistical method used to evaluate the importance of a word to a document within a document set or corpus. A word's importance increases proportionally to its frequency of occurrence in the document, but decreases inversely proportionally to its frequency of occurrence in the corpus.

[0049] Logistic Regression (LR): Also known as logistic regression analysis, logistic regression is a generalized linear regression model and belongs to supervised learning in machine learning. Its derivation and calculation are similar to those of regression, but it is primarily used to solve binary classification problems.

[0050] As described in the background section, in order to enable the model to have a better recognition effect on news that it has never seen before, some perturbation is usually added after the data is encoded. For example, multiple dropout methods are used to obtain different vector encodings of the same text, or perturbation is added during training, such as adding a perturbation along the gradient direction during each round of parameter optimization to improve the robustness of the model.

[0051] In view of this, the embodiments of this application aim to propose a training method for a sentiment classification model. This method involves deleting a single word from a key sentence in a first text to obtain multiple candidate sentences; that is, each candidate sentence is missing a certain word compared to the first text. Then, considering that the sentiment tendency reflected by a sentence is influenced by the words it contains, and that the difference in sentiment tendency before and after deleting a certain word can reflect the influence of that word on the sentence to a certain extent, the sentiment classification model is used to classify the key sentence and the multiple candidate sentences separately, obtaining the sentiment classification results for the key sentence and each candidate sentence. Based on the difference between the sentiment classification results of the key sentence and each candidate sentence, keywords that have a significant impact on the key sentence can be obtained. Further... The method involves replacing keywords in key sentences to obtain enhanced key sentences, and then optimizing the sentiment classification model based on these enhanced key sentences. This effectively increases the training data used to train the sentiment classification model, thus enhancing the training data. Since this direct word replacement data augmentation method is explicit, it facilitates verification and model training by relevant personnel. It also helps them easily identify which training data was used for model training, thus providing interpretability and making the training effect of the sentiment classification model controllable and model optimization friendly. Furthermore, the method in this embodiment enhances keywords in key sentences that have a significant impact on sentiment tendency, which helps improve the effectiveness of training data and, consequently, the robustness of the sentiment classification model.

[0052] Based on a trained sentiment classification model, this application also proposes a public opinion monitoring method. This method extracts target key sentences from news texts on a target topic on a target website, and then classifies these target key sentences using the trained sentiment classification model to obtain the sentiment classification results. Since target key sentences are sentences that have a significant impact on news texts and reflect the main content of the news texts, the trained sentiment classification model can accurately identify the sentiment classification of target key sentences. Therefore, the sentiment tendency of target key sentences can accurately reflect the sentiment tendency of the news texts. Furthermore, based on the sentiment classification results of target key sentences in the news texts, the public opinion category on the target topic on the target website can be determined, which is beneficial for accurately monitoring public opinion on the target topic on the target website.

[0053] It should be understood that the training method for the sentiment classification model and the public opinion monitoring method proposed in the embodiments of this application can both be executed by electronic devices or software installed in electronic devices. The electronic devices referred to herein may include terminal devices, such as smartphones, tablets, laptops, desktop computers, intelligent voice interaction devices, smart home appliances, smartwatches, vehicle terminals, aircraft, etc.; or, the electronic devices may also include servers, such as independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing cloud computing services.

[0054] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.

[0055] Please see Figure 1 The following is a flowchart illustrating a training method for an emotion classification model, provided as an embodiment of this application. The method may include the following steps:

[0056] S102, perform deletion operations on individual words in the key sentences of the first text to obtain multiple candidate sentences.

[0057] In this embodiment, the key sentences of the first text refer to sentences that reflect the main content and intent of the first text. In this application embodiment, key sentences can be extracted from the first text through various appropriate methods, and the specific method can be selected according to actual needs; this application embodiment does not limit this. In this embodiment, the first text can be news text or non-news text, such as dialogue text; this embodiment does not limit this. In subsequent embodiments, news text will be used as an example for illustration. Optionally, the TextRank algorithm can be used to extract key sentences from the first text in an unsupervised manner. Specifically, before S102 above, the training method of the sentiment classification model provided in this application embodiment may further include:

[0058] Step A1: Segment the first text to obtain multiple sentences.

[0059] Specifically, various methods can be used to segment the first text, and this application embodiment does not limit this method. Optionally, a period segmentation method can be used to divide the first text into multiple sentences according to the periods in the first text. For example, suppose the first text is "As of the end of June, the total scale of insurance funds' direct and indirect stock investments was approximately RMB 2.5 trillion. The total scale of insurance funds' stock investments accounted for approximately 3.1% of the A-share market capitalization, making it the second largest institutional investor in the capital market after public funds." Then, the first text can be divided into two sentences: "As of the end of June, the total scale of insurance funds' direct and indirect stock investments was approximately RMB 2.5 trillion." and "The total scale of insurance funds' stock investments accounted for approximately 3.1% of the A-share market capitalization, making it the second largest institutional investor in the capital market after public funds."

[0060] Alternatively, a sliding window method can be used, where a sliding window of preset length is used to slide across the first text, combining the text within each sliding window into a long sentence. This long sentence is the sentence obtained by segmenting the first text. For example, such as... Figure 2 As shown, assuming the first text contains four sentences (sentences 1 to 4), and the preset window length is three sentences, by using a sliding window of the preset length to slide across the first text starting from sentence 1, we can obtain that sliding window 1 contains sentences 1 to 3, and sliding window 2 contains sentences 2 to 4. Therefore, the long sentence composed of sentences 1 to 3 can be considered as one long sentence (hereinafter referred to as long sentence 1), and the long sentence composed of sentences 2 to 4 can be considered as another long sentence (hereinafter referred to as long sentence 2). Thus, the first text can be divided into long sentence 1 and long sentence 2.

[0061] Optionally, in order to ensure the completeness of the key sentences extracted later, the first text can be segmented by combining the two sentence segmentation methods mentioned above.

[0062] Step A2: Determine the similarity between the first sentence and the second sentence based on the number of words contained in the first sentence, the number of words contained in the second sentence, and the number of words shared between the first sentence and the second sentence.

[0063] The first sentence is any one of the aforementioned sentences, and the second sentence is any one of the aforementioned sentences other than the first sentence. Shared words between the first and second sentences refer to words that appear in both sentences.

[0064] For example, the similarity between the first and second sentences can be calculated using the following formula (1):

[0065]

[0066] Here, Sim(xi,xj) represents the similarity between xi and xj, which is the similarity between the first and second sentences. xi represents the first sentence, xj represents the second sentence, log(|Si|) represents the logarithm of Si, where Si represents the number of words in the first sentence, log(|Sj|) represents the logarithm of Sj, where Sj represents the number of words in the second sentence, and Num_s represents the number of shared words between the first and second sentences.

[0067] Step A3: Determine the importance score of each sentence based on the co-occurrence relationship and similarity among multiple sentences.

[0068] The importance score of a sentence is used to represent its importance to the first text. Specifically, the TextRank algorithm can be used to construct an undirected graph based on the co-occurrence relationship and similarity between multiple sentences. This undirected graph includes multiple nodes and connecting edges between nodes. Each node corresponds to a sentence, and the connecting edge between two nodes indicates that the sentences corresponding to these two nodes have a co-occurrence relationship. The weight of the connecting edge is the similarity between the two sentences. Then, the importance score of each sentence is calculated using the following formula (2):

[0069]

[0070] Where WS(Vi) represents the importance score of sentence Vi; WS(Vj) represents the importance score of sentence Vj; wij is the weight of the edge connecting sentences Vi and Vj, which is the similarity between sentences Vi and Vj; d represents the damping coefficient, which ranges from 0 to 1 and represents the probability of pointing from a specific node in an undirected graph to any other node; ∑ vj wij represents the sum of the edge weights connecting sentence Vi and the other sentences it points to; ∑ Vi This indicates that the summation process is performed on all nodes pointing to the node corresponding to sentence Vi.

[0071] Step A4: Select the top M sentences with the highest importance scores from multiple sentences as the key sentences in the first text.

[0072] Where M is a positive integer. For example, suppose that after the first text is segmented into sentences, there are four sentences, from sentence 1 to sentence 4. The importance scores of these sentences are in the order of: sentence 1 > sentence 2 > sentence 3 > sentence 4. Then, sentence 1 can be selected as the key sentence in the first text.

[0073] It is understandable that using the TextRank algorithm for key sentence extraction has advantages such as no need for training data, rapid training and inference, and simple algorithm, and the extracted key sentences best express the main content and intent of the first text.

[0074] This application embodiment illustrates one specific implementation of obtaining key sentences. Of course, it should be understood that the technical solution of this application embodiment can also extract key sentences from the first text in other ways, such as the PageRank algorithm.

[0075] After identifying the key sentence in the first text, multiple candidate sentences can be obtained by deleting individual words from that key sentence. For example, suppose the key sentence is "The weather is very nice today". By segmenting the key sentence, we get the segmentation result "Today|Weather|Very Nice", which means the key sentence contains the three words "Today", "Weather", and "Very Nice". By iterating through this segmentation result and deleting individual words at each iteration, the corresponding candidate sentences can be obtained. For example, deleting the word "Today" yields candidate sentence 1 "The weather is very nice"; deleting the word "Weather" yields candidate sentence 2 "Today is very nice"; and deleting the word "Very nice" yields candidate sentence 3 "Today's weather".

[0076] S104. Sentiment classification is performed on the key sentence and multiple candidate sentences using a sentiment classification model to obtain the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence.

[0077] In this embodiment, the sentiment classification model refers to a model capable of performing preliminary sentiment classification on an input sentence, obtaining the sentiment classification result of the sentence. The sentiment classification result of the sentence is used to represent the sentiment tendency of the sentence, such as "positive" or "negative". In practical applications, the sentiment classification result of the sentence can include the probability of the sentence belonging to each sentiment tendency, such as the positive sentiment probability and the negative sentiment probability of the sentence. In S104 above, inputting the key sentence into the sentiment classification model will obtain the sentiment classification result of the key sentence; inputting each candidate sentence into the sentiment classification model will obtain the sentiment classification result corresponding to each candidate sentence. For example, inputting the key sentence "The weather is very nice today" into the sentiment classification model will yield the following sentiment classification results: positive sentiment probability of 0.99 and negative sentiment probability of 0.01; inputting the candidate sentence "The weather is nice today" into the sentiment classification model will yield the following sentiment classification results: positive sentiment probability of 0.51 and negative sentiment probability of 0.49.

[0078] In this embodiment, the sentiment classification model can have any suitable structure, and can be set according to actual needs. This embodiment does not limit this. For example, the sentiment classification model can adopt the BERT model, logistic regression model, etc.

[0079] Optionally, considering that different sentiment classification models have varying performance on sentences of different lengths, to accurately classify the sentiment of input sentences, the sentiment classification model can include long text classification models and short text classification models. Long text classification models are used for sentiment classification of longer sentences, while short text classification models are used for sentiment classification of shorter sentences. For example, the long text classification model can use the BERT model, and the short text classification model can use a logistic regression model based on TF-IDF feature extraction or a Support Vector Machine (SVM) model.

[0080] In this case, in S104 above, for any sentence among the key sentence and multiple candidate sentences, if the length of the sentence is greater than or equal to a preset length threshold, then the sentence is classified for sentiment using a long text classification model to obtain the sentiment classification result; if the length of the sentence is less than the preset length threshold, then the sentence is classified for sentiment using a short text classification model to obtain the sentiment classification result. The preset length threshold can be set according to actual needs, for example, it can be set to 12, etc., and this embodiment does not limit this setting.

[0081] Of course, it should be understood that in some other alternative solutions, the sentiment classification model may also use only a text classification model, such as only the BERT model or only the logistic regression model based on TF-IDF feature extraction, etc., and the embodiments of this application do not limit this.

[0082] S106. Based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence, determine the keywords in the key sentence.

[0083] Since the sentiment reflected in a sentence is influenced by the words it contains, and the difference in sentiment before and after deleting a certain word in the same sentence can reflect the influence of that word on the sentence to a certain extent, sentiment classification models are used to classify the sentiment of key sentences and multiple candidate sentences separately. The sentiment classification results of key sentences and each candidate sentence are obtained. Then, based on the difference between the sentiment classification results of key sentences and each candidate sentence, the keywords that have a greater influence on key sentences can be obtained.

[0084] Based on this, in order to accurately identify influential keywords from key sentences, in one optional implementation, the above S106 may include the following steps:

[0085] S161. Based on the sentiment classification results of the key sentences and the sentiment classification results of each candidate sentence, determine the sentiment change score corresponding to each candidate sentence.

[0086] The sentiment change score for each candidate sentence represents its sentiment change relative to the key sentence, reflecting the sentiment change of the key sentence before and after the deletion of the corresponding words. For example, based on the positive sentiment probability in the sentiment change results, the sentiment change score for each candidate sentence relative to the key sentence can be calculated using the following formula (3):

[0087]

[0088] Wherein, Score represents the sentiment change score of candidate sentence Sdi relative to key sentence S, M(S) represents the positive sentiment probability of key sentence S, M(Sdi) represents the positive sentiment probability of candidate sentence Sdi, and max represents taking the maximum value.

[0089] S162: Select the top N candidate sentences with the highest emotional change scores from multiple candidate sentences as the target sentences.

[0090] Where N is a positive integer.

[0091] S163, Based on the words deleted from the target sentence relative to the key sentence, determine the keywords in the key sentence.

[0092] For each candidate sentence, the higher its sentiment change score relative to the key sentence, the greater the sentiment change it caused before and after the deletion of the deleted words from the key sentence, thus indicating a greater influence of those words on the key sentence. Based on this, optionally, the deleted words in the target sentence relative to the key sentence can be identified as keywords in the key sentence.

[0093] Optionally, considering that keyword selection based solely on sentiment change scores is insufficient—for example, in practical applications, a word might cause a significant change in sentiment before and after deletion, but the sentiment tendency remains relatively clear after deleting the word from the key sentence—this word might not truly affect the key sentence. Therefore, in S163, an additional dimension can be added to measure whether the deleted word in the target sentence is a keyword relative to the key sentence: does the sentiment tendency become blurred after deleting the word from the key sentence? If so, the word can be considered a keyword. In other words, after the keyword is deleted, the self-attention scores of the key sentence will shift from a previously highly differentiated state to a more uniform level.

[0094] Specifically, S163 above may include the following steps:

[0095] Step B1 involves embedding each word in the key sentence to obtain the word vectors for each word in the key sentence.

[0096] The word embedding process can be implemented using the word-embedding method commonly used in this field, which will not be elaborated further.

[0097] Step B2: Based on the self-attention mechanism and the word vectors of each word in the key sentence, determine the first attention score information corresponding to the target word.

[0098] Among them, target words refer to words shared by the key sentence and the target sentence, and the first attention score information includes the attention score of the target words relative to other words in the key sentence.

[0099] In this embodiment, the sentiment classification model uses a self-attention mechanism for semantic encoding. The self-attention mechanism defines three matrices: q (Query), k (Key), and v (Value). q is the query matrix, k is the key vector matrix, and v is the value vector matrix. Each row in the q matrix represents the query vector for each word, each row in the k matrix represents the key vector for each word, and each row in the v matrix represents the value vector for each word. These vector matrices are calculated from the word vectors X of each word in the input sentence after a linear transformation, i.e., q = W. Q ·X, k=W k ·X, v=W v ·X, where W Q W k W v These represent the global weight matrices.

[0100] In step B2 above, based on the global weight matrix W Q W k W v After linearly transforming the word vectors of each word in the key sentence, we can obtain the three matrices q, k, and v corresponding to the key sentence; further, we can calculate the attention score of each word in the key sentence relative to other words using the following formula (4):

[0101]

[0102] Where Context represents the attention score of each word in the key sentence relative to other words, which can reflect the degree of association between each word in the key sentence and other words; q represents the query matrix corresponding to the key sentence; k represents the key vector matrix corresponding to the key sentence; V represents the value vector matrix corresponding to the key sentence; d represents the length of the key sentence; and Softmax represents the normalization function.

[0103] Furthermore, the above formula (4) yields an attention score matrix. Each row in this matrix corresponds to a word in the key sentence, and each element in that row represents the attention score of that word relative to other words in the key sentence. Thus, by extracting the row containing the target word from this attention score matrix, the attention score of the target word relative to other words in the key sentence can be obtained.

[0104] Step B3: Based on the self-attention mechanism and the word vectors of each word in the target sentence, determine the second attention score information corresponding to the target word.

[0105] The second attention score information includes the attention score of the target word relative to other words in the target sentence.

[0106] The specific implementation method of step B3 is similar to that of step B2 above, and will not be repeated here.

[0107] Step B4: Based on the first attention score information and the second attention score information, determine the uncertainty change score caused by the deleted words.

[0108] The uncertainty change score caused by the deleted word is used to quantify the uncertainty of the sentiment classification result before and after the word is deleted from the key sentence. Specifically, the uncertainty change score caused by the deleted word can be determined as follows: First, based on the attention score of the target word relative to other words in the key sentence, and the highest and second-highest attention scores in the first attention score information, a first uncertainty score of the target word for the key sentence is determined; and second, based on the attention score of the target word relative to other words in the target sentence, and the highest and second-highest attention scores in the second attention score information, a second uncertainty score of the target word for the target sentence is determined; finally, the difference between the first uncertainty score and the second uncertainty score is used as the uncertainty change score caused by the deleted word.

[0109] For example, both the first uncertainty score and the second uncertainty score can be calculated using the following formula (5):

[0110]

[0111] Where Uncertain represents the uncertainty score; for the first uncertainty score, p i This represents the attention score of the target word relative to the i-th word in the key sentence. The information entropy represents the first attention score information, n represents the number of words in the key sentence, and A represents the information entropy. maxA represents the highest attention score in the first attention score information. sec This represents the second-highest attention score in the first attention score information; similarly, for the second uncertainty score, p i This represents the attention score of the target word relative to the i-th word in the target sentence. The information entropy represents the second attention score information, where n represents the number of words in the target sentence, and A max A represents the highest attention score in the second attention score information. sec This represents the second-highest attention score in the second attention score information.

[0112] For example, suppose the key sentence is "The weather is really nice today," and the target sentence is "The weather is very nice today," meaning the deleted word is "really." "Today," "weather," and "very nice" are target words shared by both sentences. If the first attention score for the word "today" is [0.02, 0.05, 0.08, 0.85], where 0.02 represents "today"'s attention score relative to itself, 0.05 represents "today"'s attention score relative to "weather," 0.08 represents "today"'s attention score relative to "really," and 0.85 represents "today"'s attention score relative to "very nice," then n = 4, A max =0.85, A sec =0.08.

[0113] Step B5: If the uncertainty change score is greater than or equal to the preset score, the deleted words will be identified as keywords in the key sentence.

[0114] For example, if the uncertainty score caused by a deletion is large, it can be determined that the sentiment of the key sentence becomes ambiguous after the word is deleted. Therefore, it can be concluded that the "deletion" of the word is effective, meaning that the word plays an important role in the sentiment of the key sentence. Thus, the word can be considered a keyword in the key sentence.

[0115] It is worth noting that, such as Figure 3A As shown, traditional attention mechanisms typically employ multi-head attention mechanisms, which are computationally complex. For example, the commonly used BERT-Base version uses 12 multi-head attention mechanisms to calculate attention scores, thereby obtaining the local attention results for the sentence. In this application embodiment, to simplify the calculation process, an attention score calculation based on a single-head attention mechanism is proposed, such as... Figure 3BAs shown, the global sentence attention score is calculated only once. Compared to multi-head attention mechanisms, the single-head attention mechanism adopted in this application simplifies the dimension of feature transformation and attention calculation to one, thereby greatly reducing the computational difficulty in training and significantly improving training speed.

[0116] This application embodiment illustrates one specific implementation of S106 described above. It should be understood that S106 can also be implemented in other ways, and this application embodiment does not limit this implementation.

[0117] S108, replace the keywords in the key sentence with words to obtain the enhanced key sentence corresponding to the key sentence.

[0118] Optionally, words similar to the keywords can be selected from a preset dictionary to replace the keywords, and the resulting sentences can be used as the enhanced key sentences corresponding to the key sentences.

[0119] Optionally, considering that the enhanced key sentence after similar word replacement may not be fully usable in some sentiment classification tasks, in order to ensure the effectiveness of the enhanced key sentence and improve the subsequent model optimization training, words of the same category as the keyword can be selected to replace the keyword. Specifically, S108 above may include the following steps: matching the keyword with words in multiple preset dictionaries to determine the target category of the keyword, each preset dictionary corresponding to a category, which is sentiment or negation; further, using words in the preset dictionary corresponding to the target category to replace the keyword in the key sentence to obtain the enhanced key sentence corresponding to the key sentence.

[0120] For example, a sentiment dictionary can be pre-built, containing various commonly used sentiment words (such as "good," "not bad," "rising," "complaint," etc.), and a negation dictionary can be pre-built, containing negation words (such as "not good," "falling," "limit down," "reduction in holdings," etc.). Then, keywords are matched against words in both the sentiment and negation dictionaries to determine whether the keyword belongs to the sentiment or negation category. If the keyword belongs to the sentiment category, other words are selected from the sentiment dictionary to replace the keyword in the key sentence, resulting in an enhanced key sentence. If the keyword belongs to the negation category, other words are selected from the negation dictionary to replace the keyword in the key sentence, resulting in an enhanced key sentence.

[0121] Understandably, since words with a significant impact on key sentences are generally negative and sentiment words, their text features differ considerably. By determining whether keywords belong to the sentiment or negative word category, and then selecting the corresponding dictionary to replace the keywords, the effect of enhancing key sentences can be improved. This helps the sentiment classification model learn and understand the commonalities and differences between key sentences and enhanced key sentences during optimization training, thereby improving the training effect of the sentiment classification model. Furthermore, the enhanced key sentences obtained in this embodiment are entirely natural language, possessing strong interpretability and ample optimization space. Moreover, the sources of the obtained enhanced key sentences are diverse, including both short questions and longer texts, enabling the model to have strong robustness and preventing inaccurate recognition due to other reasons.

[0122] Optionally, to further improve the effect of enhancing key sentences, after S108 above, the training method of the sentiment classification model provided in this application embodiment may further include the following steps: classifying the enhanced key sentences for sentiment using the sentiment classification model to obtain the sentiment classification result of the enhanced key sentences; determining the confidence level of the enhanced key sentences based on the sentiment classification result of the enhanced key sentences; if the confidence level of the enhanced key sentences is within a preset confidence level range, sending the enhanced key sentences to the review platform for review; and determining whether to select the enhanced key sentences for training the sentiment classification model based on the review result returned by the review platform.

[0123] In this application embodiment, the determination of the confidence level of the enhanced key sentence can be achieved in a variety of ways, and this application embodiment does not limit the specific methods used.

[0124] In one alternative implementation, the positive sentiment probability of the enhanced key sentence output by any text classification model in the sentiment classification model can be used as the confidence level of the enhanced key sentence. In other words, the higher the positive sentiment probability of the enhanced key sentence, the higher the confidence level of the enhanced key sentence, and the easier it is to be recognized by the sentiment classification model.

[0125] In another alternative implementation, the positive sentiment probabilities of the enhanced key sentence outputs from the two text classification models in the sentiment classification model can be combined as the confidence score of the enhanced key sentence. For example, the positive sentiment probabilities of the enhanced key sentence outputs from the two text classification models can be weighted and summed, and the result can be used as the confidence score of the enhanced key sentence.

[0126] In another alternative implementation, considering that multiple enhanced key sentences may be obtained in practical applications, and these enhanced key sentences may have different lengths, mainly due to the different extraction methods used when extracting key sentences and the different lengths of each sentence in the natural text. Since the prediction effect of using only a single text classification model may be effective in short texts, the confidence of the enhanced key sentence can be determined as follows: If the length of the enhanced key sentence is greater than or equal to a preset length threshold, then the enhanced key sentence is classified for sentiment using a long text classification model to obtain a first positive sentiment probability, and this first positive sentiment probability is used as the confidence of the enhanced key sentence; or, if the length of the enhanced key sentence is less than the preset length threshold, then the enhanced key sentence is classified for sentiment using a long text classification model to obtain a first positive sentiment probability, and then the enhanced key sentence is classified for sentiment using a short text classification model to obtain a second positive sentiment probability, and then the first positive sentiment probability and the second positive sentiment probability are weighted and summed to obtain the confidence of the enhanced key sentence.

[0127] For example, the confidence level of a key sentence can be determined by the following formula (6):

[0128] Confidence = a*s bert +b*s lr (6)

[0129] Here, Confidence indicates the confidence level of the key sentence, s bert s represents the probability of the first positive sentiment. lr Let 'a' represent the second positive sentiment probability, 'b' represent the weight corresponding to the first positive sentiment probability, and 'a' represent the weight corresponding to the second positive sentiment probability. In practical applications, 'a' and 'b' can be set according to actual needs, and this embodiment does not limit this.

[0130] In this embodiment, the preset reliability range can be determined according to actual needs. For example, the preset reliability range can be between 0.35 and 0.65, and augmented key sentences within this range can be considered to have uncertain sentiment. In this case, the augmented key sentences are sent to the review platform, which reviews and labels them with sentiment before returning the results. If the review platform returns a result indicating that the sentiment of the augmented key sentences is ambiguous, the augmented key sentences can be discarded; otherwise, they can be used to train the sentiment classification model. This allows the review platform to determine whether to process the augmented key sentences used as backup datasets based on actual needs. Furthermore, it facilitates bad case analysis for relevant personnel, and the backup dataset for the model can also serve as the best bad case data for analysis, improving the efficiency of model optimization iteration.

[0131] In practical applications, the review of enhanced key sentences can be conducted manually by the reviewers of the review platform, or it can be automatically reviewed by the review platform based on pre-set review rules. This application embodiment does not limit this.

[0132] S110 optimizes the training of the sentiment classification model based on key sentences and their corresponding enhanced key sentences.

[0133] Optionally, the first text can be historical news text carrying sentiment tags, which are used to represent the true sentiment tendency of the first text. In this case, the sentiment tags of the first text can be used as the sentiment tags of the key sentences, and the sentiment tags corresponding to the enhanced key sentences can be determined based on the confidence of the enhanced key sentences. Furthermore, the sentiment classification model is optimized and trained based on the key sentences and their corresponding sentiment tags, as well as the enhanced key sentences and their corresponding sentiment tags.

[0134] For example, when determining the sentiment label corresponding to the enhanced key sentence, if the confidence level of the enhanced key sentence exceeds the upper limit of the preset confidence range (e.g., 0.65), the sentiment tendency of the enhanced key sentence can be determined to be positive, and a corresponding sentiment label can be set for the enhanced key sentence; if the confidence level of the enhanced key sentence is less than the lower limit of the preset confidence range (e.g., 0.35), the sentiment tendency of the enhanced key sentence can be determined to be negative, and a corresponding sentiment label can be set for the enhanced key sentence.

[0135] Optionally, the first text may be historical news text without sentiment labels. In this case, the sentiment label corresponding to the key sentence is determined based on the sentiment classification result of the sentiment classification model; the sentiment label corresponding to the enhanced key sentence is determined based on the confidence of the enhanced key sentence; and the sentiment classification model is optimized and trained based on the key sentence and its corresponding sentiment label, as well as the enhanced key sentence and its corresponding sentiment label.

[0136] For example, in determining the sentiment label corresponding to a key sentence, if the sentiment classification model indicates that the probability of positive sentiment in the key sentence is greater than a preset probability threshold (e.g., 0.5), then the sentiment tendency of the key sentence can be determined to be positive, and a corresponding sentiment label can be set for the key sentence; if the sentiment classification model indicates that the probability of positive sentiment in the key sentence is less than the preset probability threshold, then the sentiment tendency of the key sentence can be determined to be negative, and a corresponding sentiment label can be set for the key sentence.

[0137] Understandably, the second implementation method described above eliminates the need for annotation of the first text, thereby further improving the training efficiency of the sentiment classification model.

[0138] Optionally, for the second implementation described above, i.e., when the first text is historical news text without sentiment tags, in order to further improve the classification accuracy and training efficiency of the sentiment classification model, a small number of historical news texts can be pre-labeled, and the sentiment classification model can be pre-trained using these labeled historical news texts and their corresponding sentiment tags. Specifically, before S104 above, the training method of the sentiment classification model provided in this application embodiment may further include: obtaining key sentences in the second text and the sentiment tags corresponding to the second text; and pre-training the sentiment classification model based on the key sentences in the second text and the sentiment tags corresponding to the second text. Here, the second text refers to historical news text carrying sentiment tags. The second text can be historical news text carrying sentiment tags, or it can be non-news type historical text carrying sentiment tags, such as historical dialogue text. This embodiment does not limit this. In subsequent embodiments, the second text is historical news text carrying sentiment tags as an example for explanation.

[0139] It is worth noting that the pre-training of the sentiment classification model can be achieved using various model training methods commonly used in this field, such as gradient descent algorithm and backpropagation algorithm, which will not be elaborated further.

[0140] Furthermore, the above describes only one training iteration. In practical applications, steps S104 to S110 can be executed multiple times until the sentiment classification model meets the preset training stopping condition. The preset training stopping condition may include: the recognition accuracy of the sentiment classification model exceeding a preset accuracy threshold, or the number of training iterations reaching a preset number threshold, etc. The specific setting can be determined according to actual needs, and this embodiment does not limit this. Secondly, the sentiment classification model used in the first iteration of training can be called the initial sentiment classification model. It can be an existing sentiment classification model with preliminary sentiment classification capabilities, or it can be a sentiment classification model that does not yet possess sentiment classification capabilities. From the second iteration onwards, each iteration optimizes the sentiment classification model based on the previous iteration, resulting in a different sentiment classification model than the one after the previous iteration. After multiple iterations, the sentiment classification model that meets the preset training stopping condition can be used for subsequent sentiment classification.

[0141] The training method for the sentiment classification model provided in this application embodiment obtains multiple candidate sentences by deleting a single word from a key sentence in a first text. That is, each candidate sentence lacks a certain word compared to the first text. Then, considering that the sentiment tendency reflected by a sentence is influenced by the words it contains, and that the difference in sentiment tendency before and after deleting a certain word can reflect the influence of that word on the sentence to a certain extent, the sentiment classification model is used to classify the key sentence and multiple candidate sentences separately, obtaining the sentiment classification results for the key sentence and each candidate sentence. Based on the difference between the sentiment classification results of the key sentence and each candidate sentence, keywords that have a significant impact on the key sentence can be obtained. Furthermore, the method further... By replacing keywords in key sentences to obtain enhanced key sentences, and optimizing the sentiment classification model based on these enhanced key sentences, the training data for the sentiment classification model is essentially increased, thus enhancing the training data. Since this direct word replacement data augmentation method is explicit, it facilitates verification and model training by relevant personnel. It also helps personnel easily identify which training data was used for model training, thus providing interpretability and making the training effect of the sentiment classification model controllable and optimization-friendly. Furthermore, the method in this embodiment enhances keywords in key sentences that significantly influence sentiment tendencies, which improves the effectiveness of the training data and consequently enhances the robustness of the sentiment classification model.

[0142] This application also provides a public opinion monitoring method, which can perform sentiment classification analysis on key sentences in any news text based on the sentiment classification model trained using the above-described sentiment classification model training method. Please refer to... Figure 4 The following is a flowchart illustrating a public opinion monitoring method according to an embodiment of this application. The method may include the following steps:

[0143] S402, retrieve news texts related to the target topic from the target website.

[0144] For example, a web crawler can be used to extract news text related to a target topic from a target website. Here, the target topic refers to a topic that needs to be monitored for public opinion, such as the development trend of the metallurgical industry or GDP.

[0145] S404, Extract target key sentences from news text.

[0146] S406, the sentiment classification of the target key sentence is performed by a sentiment classification model to obtain the sentiment classification result of the target key sentence.

[0147] The sentiment classification model is trained using the training method provided in the embodiments of this application.

[0148] S408. Based on the sentiment classification results of target key sentences in news texts, determine the public opinion category on the target website regarding the target topic.

[0149] For example, public opinion can be categorized into positive and negative. Suppose there are 50 news articles related to the target topic on the target website. If more than half of these articles have a positive sentiment, then the public opinion category on the target website regarding the target topic can be determined to be positive. Conversely, if more than half of the news articles have a negative sentiment, then the public opinion category on the target website regarding the target topic can be determined to be negative, and so on.

[0150] The public opinion monitoring method provided in this application extracts target key sentences from news texts on a target topic on a target website, and performs sentiment classification on the target key sentences using a trained sentiment classification model to obtain the sentiment classification result of the target key sentences. Since the target key sentences are sentences that have a significant impact on the news text and can reflect the main content of the news text, the trained sentiment classification model can accurately identify the sentiment classification of the target key sentences. Therefore, the sentiment tendency of the target key sentences can accurately reflect the sentiment tendency of the news text. Furthermore, based on the sentiment classification result of the target key sentences in the news text, the public opinion category on the target topic on the target website is determined, which is conducive to achieving accurate monitoring of public opinion on the target topic on the target website.

[0151] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0152] With the above Figure 1 Corresponding to the training method of the emotion classification model shown, this application also proposes a training device for an emotion classification model. Please refer to... Figure 5 The diagram below illustrates the structure of a training device 500 for an emotion classification model, as provided in one embodiment of this application. The device 500 includes:

[0153] Deletion unit 510 is used to perform deletion operations on individual words in the key sentences of the first text to obtain multiple candidate sentences;

[0154] The first classification unit 520 is used to perform sentiment classification on the key sentence and the multiple candidate sentences respectively through a sentiment classification model, so as to obtain the sentiment classification result of the key sentence and the sentiment classification result of each candidate sentence;

[0155] The first determining unit 530 is used to determine the keywords in the key sentence based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence;

[0156] The enhancement unit 540 is used to replace the keywords in the key sentence to obtain the enhanced key sentence corresponding to the key sentence.

[0157] Training unit 550 is used to optimize and train the sentiment classification model based on the key sentence and the enhanced key sentence corresponding to the key sentence.

[0158] Optionally, when the first determining unit determines the keywords in the key sentence based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence, it performs the following steps:

[0159] Based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence, the sentiment change score corresponding to each candidate sentence is determined. The sentiment change score corresponding to the candidate sentence is used to represent the sentiment change of the candidate sentence relative to the key sentence.

[0160] The top N candidate sentences with the highest emotional change scores are selected from the plurality of candidate sentences as target sentences, where N is a positive integer;

[0161] Based on the words deleted from the target sentence relative to the key sentence, the keywords in the key sentence are determined.

[0162] Optionally, when the first determining unit determines the keywords in the key sentence based on the words deleted from the target sentence relative to the key sentence, it performs the following steps:

[0163] Each word in the key sentence is embedded to obtain the word vector of each word in the key sentence;

[0164] Based on the self-attention mechanism and the word vectors of each word in the key sentence, the first attention score information corresponding to the target word is determined. The target word refers to the word that is common to both the key sentence and the target sentence. The first attention score information includes the attention score of the target word relative to other words in the key sentence.

[0165] Based on the self-attention mechanism and the word vectors of each word in the target sentence, the second attention score information corresponding to the target word is determined, wherein the second attention score information includes the attention score of the target word relative to other words in the target sentence;

[0166] Based on the first attention score information and the second attention score information, determine the uncertainty change score caused by the deleted words;

[0167] If the uncertainty change score is greater than or equal to the preset score, then the deleted words are identified as keywords in the key sentence.

[0168] Optionally, when the first determining unit determines the uncertainty change score caused by the deleted word based on the first attention score information and the second attention score information, it performs the following steps:

[0169] Based on the attention score of the target word relative to other words in the key sentence, and the highest and second-highest attention scores in the first attention score information, the first uncertainty score of the target word for the key sentence is determined;

[0170] Based on the attention score of the target word relative to other words in the target sentence, and the highest and second-highest attention scores in the second attention score information, the second uncertainty score of the target word for the target sentence is determined;

[0171] The difference between the first uncertainty score and the second uncertainty score is determined as the uncertainty change score caused by the deleted word.

[0172] Optionally, when the enhancement unit performs word replacement on the keywords in the key sentence to obtain the enhanced key sentence corresponding to the key sentence, it performs the following steps:

[0173] The keywords are matched with words in multiple preset dictionaries to determine the target category to which the keywords belong. Each preset dictionary corresponds to a category, which is either sentiment or negation.

[0174] The keywords in the key sentence are replaced with words from the preset dictionary corresponding to the target category to obtain the enhanced key sentence corresponding to the key sentence.

[0175] Optionally, the device 500 further includes:

[0176] The sentence segmentation unit is used to segment the first text into multiple sentences before the deletion unit performs deletion operations on individual words in the key sentences of the first text.

[0177] The first determining unit is further configured to:

[0178] The similarity between the first sentence and the second sentence is determined based on the number of words contained in the first sentence, the number of words contained in the second sentence, and the number of words shared between the first sentence and the second sentence. Here, the first sentence is any one of the plurality of sentences, and the second sentence is any other sentence among the plurality of sentences except the first sentence.

[0179] Based on the co-occurrence relationship and similarity among the sentences, the importance score of each sentence is determined.

[0180] Select the top M sentences with the highest importance scores from the plurality of sentences as the key sentences in the first text, where M is a positive integer.

[0181] Optionally, the first classification unit is further configured to:

[0182] After the enhancement unit performs word replacement on the keywords in the key sentence to obtain the enhanced key sentence corresponding to the key sentence, the enhanced key sentence is classified by the sentiment classification model to obtain the sentiment classification result of the enhanced key sentence;

[0183] Based on the sentiment classification results of the enhanced key sentences, the confidence level of the enhanced key sentences is determined;

[0184] If the confidence level is within the preset confidence level range, the enhanced key sentence will be sent to the review platform for review.

[0185] Based on the review results returned by the review platform, determine whether to select the enhanced key sentence for training the sentiment classification model.

[0186] Optionally, the sentiment classification model includes a long text classification model and a short text classification model, and the sentiment classification result of the enhanced key sentence includes the positive sentiment probability of the enhanced key sentence;

[0187] When determining the confidence level of the enhanced key sentence based on the sentiment classification result of the enhanced key sentence, the first classification unit performs the following steps: if the length of the enhanced key sentence is greater than or equal to a preset length threshold, the enhanced key sentence is classified for sentiment using the long text classification model to obtain a first positive sentiment probability, and the first positive sentiment probability is used as the confidence level of the enhanced key sentence; or, if the length of the enhanced key sentence is less than the preset length threshold, the enhanced key sentence is classified for sentiment using the long text classification model to obtain a first positive sentiment probability, and the enhanced key sentence is classified for sentiment using the short text classification model to obtain a second positive sentiment probability, and the first positive sentiment probability and the second positive sentiment probability are weighted and summed to obtain the confidence level of the enhanced key sentence.

[0188] Optionally, when the training unit optimizes the sentiment classification model based on the key sentence and the corresponding enhanced key sentence, it performs the following steps:

[0189] Based on the sentiment classification results of the key sentences, the sentiment tags corresponding to the key sentences are determined;

[0190] Based on the confidence of the enhanced key sentence, the sentiment label corresponding to the enhanced key sentence is determined;

[0191] The sentiment classification model is optimized and trained based on the key sentence and its corresponding sentiment tag, as well as the enhanced key sentence and its corresponding sentiment tag.

[0192] Optionally, the training unit is further configured to: obtain the key sentence in the second text and the sentiment label corresponding to the second text before the first classification unit performs sentiment classification on the key sentence and the plurality of candidate sentences respectively through the sentiment classification model;

[0193] The sentiment classification model is pre-trained based on the key sentences in the second text and the sentiment tags corresponding to the second text.

[0194] Obviously, the training device for the sentiment classification model in the embodiments of this specification can be used as described above. Figure 1 The entity executing the training method of the sentiment classification model shown is therefore capable of implementing the training method of the sentiment classification model in... Figure 1 The functions implemented are the same, so they will not be described in detail here.

[0195] With the above Figure 4 Corresponding to the public opinion monitoring method shown, this application also proposes a public opinion monitoring device. Please refer to... Figure 6 The diagram below illustrates the structure of a public opinion monitoring device 600 according to an embodiment of this application. The device 600 includes:

[0196] Acquisition unit 610 is used to acquire news texts related to the target topic from the target website;

[0197] Extraction unit 620 is used to extract target key sentences from the news text;

[0198] The second classification unit 630 is used to classify the target key sentence by sentiment using a sentiment classification model to obtain the sentiment classification result of the target key sentence. The sentiment classification model is trained based on the training method of the sentiment classification model described in the embodiments of this application.

[0199] The second determining unit 640 is used to determine the public opinion category on the target website regarding the target topic based on the sentiment classification results of the target key sentences in the news text.

[0200] Obviously, the public opinion monitoring device in the embodiments of this specification can be used as described above. Figure 4 The entity implementing the public opinion monitoring method shown here is therefore able to realize the public opinion monitoring method in Figure 4 The functions implemented are the same, so they will not be described in detail here.

[0201] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Please refer to it. Figure 7 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and memory. The memory may include main memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the electronic device may also include other hardware required for other business operations.

[0202] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0203] Memory is used to store programs. Specifically, programs may include program code, which includes computer operation instructions. Memory may include main memory and non-volatile memory, and provides instructions and data to the processor.

[0204] The processor reads the corresponding computer program from non-volatile memory into main memory and then runs it, forming a training device for the sentiment classification model at the logical level. The processor executes the program stored in memory and specifically performs the following operations:

[0205] By deleting individual words from the key sentences in the first text, multiple candidate sentences are obtained.

[0206] The sentiment classification model is used to classify the sentiment of the key sentence and the multiple candidate sentences respectively, so as to obtain the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence.

[0207] Based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence, the keywords in the key sentence are determined;

[0208] The keywords in the key sentence are replaced with words to obtain the enhanced key sentence corresponding to the key sentence;

[0209] The sentiment classification model is optimized and trained based on the key sentence and the corresponding enhanced key sentence.

[0210] Alternatively, the processor reads the corresponding computer program from non-volatile memory into memory and runs it, forming a public opinion monitoring device at the logical level. The processor executes the program stored in memory and specifically performs the following operations:

[0211] Obtain news texts related to the target topic from the target website;

[0212] Extract the target key sentences from the news text;

[0213] The target key sentence is classified into sentiments using a sentiment classification model to obtain the sentiment classification result of the target key sentence. The sentiment classification model is trained based on the training method of the sentiment classification model described in the embodiments of this application.

[0214] Based on the sentiment classification results of the target key sentences in the news text, the public opinion category on the target topic on the target website is determined.

[0215] The above is as stated in this application. Figure 1 The illustrated embodiment discloses a method for training an emotion classification model, or the method described above in this application. Figure 4The method executed by the public opinion monitoring device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.

[0216] The electronic device can also perform Figure 1 The method, and the implementation of the training device for the sentiment classification model in Figure 1 , Figure 2 The electronic device may also perform the functions shown in the embodiment of Figure 3, or it may perform other functions as well. Figure 4 The method, and to realize the public opinion monitoring device in Figure 4 The functions of the embodiments shown are not described in detail here.

[0217] Of course, in addition to software implementation, the electronic device of this application does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. In other words, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0218] This application also proposes a computer-readable storage medium that stores one or more programs, the programs including instructions that, when executed by a portable electronic device including multiple applications, enable the portable electronic device to perform... Figure 1 The method of the illustrated embodiment is specifically used to perform the following operations:

[0219] By deleting individual words from the key sentences in the first text, multiple candidate sentences are obtained.

[0220] The sentiment classification model is used to classify the sentiment of the key sentence and the multiple candidate sentences respectively, so as to obtain the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence.

[0221] Based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence, the keywords in the key sentence are determined;

[0222] The keywords in the key sentence are replaced with words to obtain the enhanced key sentence corresponding to the key sentence;

[0223] The sentiment classification model is optimized and trained based on the key sentence and the corresponding enhanced key sentence.

[0224] Alternatively, when executed by a portable electronic device that includes multiple applications, the instruction can enable the portable electronic device to perform... Figure 4 The method of the illustrated embodiment is specifically used to perform the following operations:

[0225] Obtain news texts related to the target topic from the target website;

[0226] Extract the target key sentences from the news text;

[0227] The target key sentence is classified into sentiments using a sentiment classification model to obtain the sentiment classification result of the target key sentence. The sentiment classification model is trained based on the training method of the sentiment classification model described in the embodiments of this application.

[0228] Based on the sentiment classification results of the target key sentences in the news text, the public opinion category on the target website regarding the target topic is determined.

[0229] In summary, the above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

[0230] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.

[0231] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0232] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0233] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.

Claims

1. A training method for an emotion classification model, characterized in that, include: By deleting individual words from the key sentences in the first text, multiple candidate sentences are obtained. The sentiment classification model is used to classify the sentiment of the key sentence and the multiple candidate sentences respectively, so as to obtain the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence. Based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence, keywords in the key sentence are determined; the keywords are determined from the target sentence after the target sentence is determined from the multiple candidate sentences based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence; the target words refer to words common to the key sentence and the target sentence, the first attention score information includes the attention score of the target word relative to other words in the key sentence, and the second attention score information includes the attention score of the target word relative to other words in the target sentence; The keywords in the key sentence are replaced with words to obtain the enhanced key sentence corresponding to the key sentence; The sentiment classification model is optimized and trained based on the key sentence and the corresponding enhanced key sentence.

2. The method according to claim 1, characterized in that, The keywords in the key sentence are determined based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence, including: Based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence, the sentiment change score corresponding to each candidate sentence is determined. The sentiment change score corresponding to the candidate sentence is used to represent the sentiment change of the candidate sentence relative to the key sentence. The top N candidate sentences with the highest emotional change scores are selected from the plurality of candidate sentences as target sentences, where N is a positive integer; Based on the words deleted from the target sentence relative to the key sentence, the keywords in the key sentence are determined.

3. The method according to claim 2, characterized in that, The step of determining keywords in the key sentence based on the words deleted from the target sentence relative to the key sentence includes: Each word in the key sentence is embedded to obtain the word vector of each word in the key sentence; Based on the self-attention mechanism and the word vectors of each word in the key sentence, the first attention score information corresponding to the target word is determined; Based on the self-attention mechanism and the word vectors of each word in the target sentence, the second attention score information corresponding to the target word is determined; Based on the first attention score information and the second attention score information, determine the uncertainty change score caused by the deleted words; If the uncertainty change score is greater than or equal to the preset score, then the deleted words are identified as keywords in the key sentence.

4. The method according to claim 3, characterized in that, The step of determining the uncertainty change score caused by the deleted word based on the first attention score information and the second attention score information includes: Based on the attention score of the target word relative to other words in the key sentence, and the highest and second-highest attention scores in the first attention score information, the first uncertainty score of the target word for the key sentence is determined; Based on the attention score of the target word relative to other words in the target sentence, and the highest and second-highest attention scores in the second attention score information, the second uncertainty score of the target word for the target sentence is determined; The difference between the first uncertainty score and the second uncertainty score is determined as the uncertainty change score caused by the deleted word.

5. The method according to claim 1, characterized in that, The step of replacing keywords in the key sentence to obtain the enhanced key sentence corresponding to the key sentence includes: The keywords are matched with words in multiple preset dictionaries to determine the target category to which the keywords belong. Each preset dictionary corresponds to a category, which is either sentiment or negation. The keywords in the key sentence are replaced with words from the preset dictionary corresponding to the target category to obtain the enhanced key sentence corresponding to the key sentence.

6. The method according to claim 1, characterized in that, Before performing deletion operations on individual words in the key sentences of the first text, the method further includes: The first text is segmented into sentences to obtain multiple sentences; The similarity between the first sentence and the second sentence is determined based on the number of words contained in the first sentence, the number of words contained in the second sentence, and the number of words shared between the first sentence and the second sentence. Here, the first sentence is any one of the plurality of sentences, and the second sentence is any other sentence among the plurality of sentences except the first sentence. Based on the co-occurrence relationship and similarity among the sentences, the importance score of each sentence is determined. Select the top M sentences with the highest importance scores from the plurality of sentences as the key sentences in the first text, where M is a positive integer.

7. The method according to claim 1, characterized in that, After replacing the keywords in the key sentence to obtain the enhanced key sentence corresponding to the key sentence, the method further includes: The enhanced key sentence is classified into sentiments using the sentiment classification model to obtain the sentiment classification result of the enhanced key sentence; Based on the sentiment classification results of the enhanced key sentences, the confidence level of the enhanced key sentences is determined; If the confidence level is within the preset confidence level range, the enhanced key sentence will be sent to the review platform for review. Based on the review results returned by the review platform, determine whether to select the enhanced key sentence for training the sentiment classification model.

8. The method according to claim 7, characterized in that, The sentiment classification model includes a long text classification model and a short text classification model, and the sentiment classification result of the enhanced key sentence includes the positive sentiment probability of the enhanced key sentence; The determination of the confidence level of the enhanced key sentence based on the sentiment classification result of the enhanced key sentence includes: If the length of the enhanced key sentence is greater than or equal to a preset length threshold, then the enhanced key sentence is classified for sentiment using the long text classification model to obtain a first positive sentiment probability, and the first positive sentiment probability is used as the confidence level of the enhanced key sentence; or, If the length of the enhanced key sentence is less than the preset length threshold, then the enhanced key sentence is classified by sentiment using the long text classification model to obtain a first positive sentiment probability, and the enhanced key sentence is classified by sentiment using the short text classification model to obtain a second positive sentiment probability. Finally, the first positive sentiment probability and the second positive sentiment probability are weighted and summed to obtain the confidence level of the enhanced key sentence.

9. The method according to claim 8, characterized in that, The optimization training of the sentiment classification model based on the key sentence and the corresponding enhanced key sentence includes: Based on the sentiment classification results of the key sentences, the sentiment tags corresponding to the key sentences are determined; Based on the confidence of the enhanced key sentence, the sentiment label corresponding to the enhanced key sentence is determined; The sentiment classification model is optimized and trained based on the key sentence and its corresponding sentiment tag, as well as the enhanced key sentence and its corresponding sentiment tag.

10. The method according to claim 1, characterized in that, Before performing sentiment classification on the key sentence and the multiple candidate sentences respectively using a sentiment classification model, the method further includes: Obtain the key sentences in the second text and the corresponding sentiment tags for the second text; The sentiment classification model is pre-trained based on the key sentences in the second text and the sentiment tags corresponding to the second text.

11. A method for monitoring public opinion, characterized in that, include: Obtain news texts related to the target topic from the target website; Extract the target key sentences from the news text; The target key sentence is classified into sentiments using a sentiment classification model to obtain the sentiment classification result of the target key sentence. The sentiment classification model is trained based on the training method of the sentiment classification model according to any one of claims 1 to 10. Based on the sentiment classification results of the target key sentences in the news text, the public opinion category on the target topic on the target website is determined.

12. A training device for an emotion classification model, characterized in that, include: The deletion unit is used to delete individual words in the key sentences of the first text to obtain multiple candidate sentences. The first classification unit is used to classify the key sentence and the multiple candidate sentences according to the sentiment classification model, so as to obtain the sentiment classification result of the key sentence and the sentiment classification result of each candidate sentence. The first determining unit is used to determine the keywords in the key sentence based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence; The keywords are based on the sentiment classification results of the key sentence and the sentiment classification results of each candidate sentence. After determining the target sentence from the multiple candidate sentences, the target sentence is determined based on the first attention score information and the second attention score information corresponding to the target word. The target word refers to the word common to the key sentence and the target sentence. The first attention score information includes the attention score of the target word relative to other words in the key sentence, and the second attention score information includes the attention score of the target word relative to other words in the target sentence. An enhancement unit is used to replace keywords in the key sentence to obtain an enhanced key sentence corresponding to the key sentence. The training unit is used to optimize and train the sentiment classification model based on the key sentence and the enhanced key sentence corresponding to the key sentence.

13. A public opinion monitoring device, characterized in that, include: The acquisition unit is used to acquire news texts related to the target topic from the target website. Extraction unit, used to extract target key sentences from the news text; The second classification unit is used to classify the target key sentence by sentiment using a sentiment classification model to obtain the sentiment classification result of the target key sentence. The sentiment classification model is trained based on the training method of the sentiment classification model according to any one of claims 1 to 10. The second determining unit is used to determine the public opinion category on the target website regarding the target topic based on the sentiment classification results of the target key sentences in the news text.

14. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the training method of the sentiment classification model as described in any one of claims 1 to 10; or, the processor is configured to execute the instructions to implement the public opinion monitoring method as described in claim 11.

15. A computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the training method of the sentiment classification model as described in any one of claims 1 to 10; or, when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the public opinion monitoring method as described in claim 11.