Online public opinion multi-task analysis method based on large language model
Through a multi-task analysis method based on a large language model, combined with data preprocessing, multi-task model and collaboration engine, the accuracy and adaptability of traditional network public opinion analysis are solved, and efficient semantic understanding and real-time public opinion monitoring are achieved.
Patent Information
- Application Number
- CN202510589007.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-08-12
AI Technical Summary
Traditional network public opinion analysis methods have problems such as low accuracy, poor domain adaptability, response delay, computational redundancy and loss of context information, especially when dealing with long-tail distributed data and dynamic data.
A multi-task analysis method based on large language models is adopted to use data preprocessing, construct multi-task models, dynamic domain adapters and rule-model collaboration engines, combined with sentiment analysis and correlation recognition, and use lightweight models for real-time processing.
It improves semantic understanding efficiency and accuracy, enhances the vertical field term recognition capabilities, realizes low-latency streaming data processing, and adapts to the needs of large-scale public opinion monitoring.
Smart Images

Figure CN120470166A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent operation and maintenance of communication networks, and in particular to a multi-task analysis method for network public opinion based on a large language model. Background Art
[0002] Online public opinion analysis refers to the method of monitoring, statistics, research and response to Internet information. It aims to capture and analyze public emotions, attitudes and opinions through digital technology to provide a basis for decision-making.
[0003] There are some problems with traditional online public opinion analysis methods:
[0004] (1) Pure rule-based methods rely on keyword matching, resulting in low accuracy (e.g., they cannot distinguish between “poor signal” and “excellent customer service”);
[0005] (2) The pure large-model API calling method has poor domain adaptability. The general pre-trained model has insufficient recognition ability for professional terms in vertical fields (such as the communications industry) (such as "5G base station" and "number portability"). It is costly, has delayed responses, and cannot be customized and iterated.
[0006] (3) Traditional single-task fine-tuning does not integrate domain knowledge bases, and usually processes sentiment analysis and entity association recognition independently, without utilizing the semantic associations between multiple tasks. The limitations of a single task lead to computational redundancy and loss of contextual information, and the classification effect of long-tail distribution data (such as the "neutral" label) is poor.
[0007] (4) Static rule engines are difficult to adapt to real-time changes in online public opinion (such as emerging online terms and ironic expressions), and dynamic data responses are delayed.
[0008] Based on the above problems, the present invention proposes a multi-task analysis method for network public opinion based on a large language model. Summary of the Invention
[0009] In order to overcome the shortcomings of the prior art, the present invention provides a simple and efficient multi-task analysis method for network public opinion based on a large language model.
[0010] The present invention is achieved through the following technical solutions:
[0011] A multi-task analysis method for online public opinion based on a large language model includes the following steps:
[0012] Step S1, data preparation and preprocessing;
[0013] Crawl data from social media, news websites, forums, and Tieba forums with information access permissions, and preprocess the crawled data, including data cleaning, word segmentation, and keyword matching;
[0014] If the keyword matches successfully, it is marked as pre-association, otherwise jump to step S2 to enter model reasoning;
[0015] In step S1, Apache Kafka is used as a message queue to support high-throughput streaming data access;
[0016] Configure the crawler parameters, set the request interval delay to 1s, and the concurrency to 50 to avoid IP blocking.
[0017] Data cleaning methods include:
[0018] Denoising: Use regular expressions to filter HTML tags and custom special symbols;
[0019] Standardization: converting traditional Chinese characters into simplified Chinese characters, and restoring pinyin abbreviations into simplified Chinese characters;
[0020] Segmentation: split long text into segments according to punctuation marks, with each segment not exceeding 128 characters;
[0021] Set the maximum text length parameter max_length to 512. If it exceeds the parameter setting, it will be truncated.
[0022] Word segmentation and keyword matching methods include:
[0023] Word segmentation: Use bert-base-chinese word segmenter to expand domain terms;
[0024] Keyword matching: custom-build regional vocabulary K_loc and corporate vocabulary K_com;
[0025] If the text hits both the regional vocabulary K_loc and the corporate vocabulary K_com, the relevance is determined to be 1. Otherwise, the process jumps to step S2 to enter model inference and output the relevance probability.
[0026] Step S2: Build a multi-task model to jointly output sentiment and relevance results;
[0027] Using the pre-trained BERT model as the base model, the output layer is modified to a dual-task head, including a sentiment analysis head and a relevance head;
[0028] Among them, the sentiment analysis head is a fully connected layer (768→256→3) that outputs the probability of [negative, neutral, positive];
[0029] The relevance head is a fully connected layer (768→128→2) that outputs the probability of [irrelevant, relevant];
[0030] Configure the multi-task model training parameters, start training and save the trained multi-task model;
[0031] Use layered knowledge distillation (HKD) to compress the 12-layer pre-trained BERT model into a 4-layer TinyBERT model, retaining key layer parameters. Convert the model to ONNX format and integrate it into the streaming framework.
[0032] Based on the compressed integrated multi-task model, the sentiment tendency and relevance of the input text are judged;
[0033] In step S2, the multi-task model training parameters are configured:
[0034] Set the step size parameter for updating model parameters, i.e. learning rate, to 3e-5;
[0035] Set the batch size of training samples on each GPU / CPU, i.e. the inference batch size parameter batch_size, to 16;
[0036] Set the number of rounds of complete traversal of the training data to 4;
[0037] Customize the configuration output path and log path.
[0038] In step S2, when the multi-task model is initially trained, the weight distribution between sentiment analysis and subject relevance recognition is coordinated through a multi-task loss function, and the multi-task loss function is weighted summed to enable the multi-task model to simultaneously optimize the two tasks during the training process;
[0039] The multi-task loss function is:
[0040] L=αLsen+(1-α)Lrel+λ||θ|| 2
[0041] Among them, Lsen is the cross entropy loss function, Lrel is the binary classification relevance loss function, α is the weight coefficient, the value is 0.7, λ is the L2 regularization parameter λ, the value is 0.01, ||θ|| 2 The value is 1.2.
[0042] In step S2, sentiment tendency determination and relevance determination are performed on the input Tokenized text based on the trained multi-task model;
[0043] When judging the sentiment tendency, the sentiment tendency result ("positive", "negative", "neutral") and confidence level output by the multi-task model are used. The confidence threshold is set to 0.6. If the confidence probability is lower than the threshold, it is marked as neutral. Otherwise, the model output result is used directly.
[0044] When making a correlation judgment, if the multi-task model output probability is not less than 0.7, it is judged to be relevant.
[0045] Step S3: manually screen and update the rule vocabulary to improve process efficiency;
[0046] First, improve the relevant keywords;
[0047] If the input text does not find relevance through the keyword matching rules, but the multi-task model determines that there is relevance, then manually extract keywords and update and improve the regional vocabulary K_loc and corporate vocabulary K_com;
[0048] Correct sentiment keywords, detect negation words and degree words, and if double negation words exist in the same text, reverse the sentiment polarity and adjust the confidence score;
[0049] In step S3, the emotional keyword correction formula is as follows:
[0050] Sfinal=Smodel×(1+β-Intensity(x))
[0051] Among them, Sfinal represents the corrected sentiment tendency probability, Smodel represents the basic sentiment tendency probability output by the multi-task model, β is the intensity coefficient, and Intensity(x) represents the degree value when calculated according to the degree dictionary, which can be -1 or 1.
[0052] Step S4: Output a structured public opinion report based on the custom structure.
[0053] A multi-task network public opinion analysis system based on a large language model, used to implement the above method, includes:
[0054] The data collection and preprocessing module is responsible for crawling data from social media, news websites, forums, and Tieba forums with information access permissions, and preprocessing the crawled data, including data cleaning, word segmentation, and keyword matching. If the keyword match is successful, it is marked as pre-association; otherwise, the multi-task model is called for inference.
[0055] The dynamic domain adapter (DDA) is responsible for loading the pre-trained BERT model as the base model, injecting the industry knowledge base, and modifying the output layer to a dual-task head, including a sentiment analysis head and a relevance head. It updates the parameters through the layered learning rate, starts training after the multi-task model training parameters are configured, and saves the trained multi-task model.
[0056] The lightweight deployment module is responsible for using the layered knowledge distillation (HKD) compression model to compress the 12-layer pre-trained BERT model into a 4-layer TinyBERT model, retaining key layer parameters, converting the model to ONNX format, and integrating it into the streaming processing framework;
[0057] The Rule-Model Collaboration Engine (RMCE) is responsible for determining whether the input text is relevant to the target company in two steps. If the input text contains both regional keywords and company keywords, it skips the model prediction and directly determines the relevance as 1. Otherwise, it calls the trained multi-task model to determine the sentiment tendency and relevance of the input text.
[0058] The rule correction module is responsible for improving relevant keywords and correcting emotional keywords through manual screening to improve process efficiency;
[0059] The report output modules all output structured public opinion reports based on custom structures.
[0060] A multi-task analysis device for online public opinion based on a large language model, characterized by comprising a memory and a processor; the memory is used to store a computer program, and the processor is used to implement the above-mentioned method steps when executing the computer program.
[0061] A readable storage medium, characterized in that: a computer program is stored on the readable storage medium, and the computer program implements the above method steps when executed by a processor.
[0062] The beneficial effects of the present invention are as follows: the multi-task analysis method of online public opinion based on a large language model improves the efficiency and accuracy of semantic understanding through multi-task joint modeling of sentiment analysis and subject relevance identification; enhances the recognition ability of vertical field terms through the dynamic domain adapter DDA and the rule-model collaborative engine RMCE; realizes lightweight real-time reasoning, supports low-latency streaming data processing, and can adapt to large-scale public opinion monitoring needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0064] Figure 1 Schematic diagram of the multi-task analysis method of network public opinion based on a large language model of the present invention. DETAILED DESCRIPTION
[0065] To enable those skilled in the art to better understand the technical solutions in the present invention, the following will describe the technical solutions in the embodiments of the present invention clearly and completely in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of protection of the present invention.
[0066] The multi-task analysis method for online public opinion based on a large language model includes the following steps:
[0067] Step S1, data preparation and preprocessing;
[0068] Crawl data from social media, news websites, forums, and Tieba with information acquisition permissions, and preprocess the crawled data, including data cleaning, word segmentation, and keyword matching;
[0069] If the keyword matching is successful, it is marked as pre-associated, otherwise, jump to step S2 for model inference;
[0070] In the above step S1, Apache Kafka is used as the message queue to support high-throughput streaming data access;
[0071] Configure the crawler parameters, set the request interval delay to 1s, and the concurrency to 50 to avoid IP bans.
[0072] The data cleaning means include:
[0073] Denoising: Use regular expressions to filter HTML tags and custom special symbols (such as r"<.*?>");
[0074] Standardization: Convert traditional Chinese characters to simplified Chinese characters (OpenCC library), and restore pinyin abbreviations to simplified Chinese characters (such as "yyds" → "forever god");
[0075] Segmentation processing: Split long texts by punctuation, with each segment not exceeding 128 characters (to adapt to BERT input);
[0076] Set the maximum text length parameter max_length to 512, and truncate if it exceeds the parameter setting.
[0077] The means of word segmentation and keyword matching include:
[0078] Word segmentation: Use the bert-base-chinese tokenizer to expand domain terms (such as "5G base station", "number portability");
[0079] Keyword matching: Customized regional vocabulary K_loc (including the names of cities in several custom regions) and corporate vocabulary K_com (including 200+ communications industry terms such as "mobile", "package", "customer service", "10086", etc.);
[0080] If the text hits both the regional vocabulary K_loc and the corporate vocabulary K_com (the input text contains both regional keywords and corporate keywords), the correlation is determined to be 1. Otherwise, jump to step S2 to enter the model inference and output the correlation probability.
[0081] The formula is as follows:
[0082]
[0083] Among them, Kloc represents the matching regional keywords, Kcom represents the enterprise keywords, and Modelrel(x) represents the model layer matching function.
[0084] Step S2: Build a multi-task model to jointly output sentiment and relevance results;
[0085] Using the pre-trained BERT model as the base model, the output layer is modified to a dual-task head, including a sentiment analysis head and a relevance head;
[0086] Among them, the sentiment analysis head is a fully connected layer (768→256→3) that outputs the probability of [negative, neutral, positive];
[0087] The relevance head is a fully connected layer (768→128→2) that outputs the probability of [irrelevant, relevant];
[0088] Configure the multi-task model training parameters, start training and save the trained multi-task model;
[0089] Use layered knowledge distillation (HKD) to compress the 12-layer pre-trained BERT model into a 4-layer TinyBERT model, retaining key layer parameters. Convert the model to ONNX format and integrate it into the streaming framework.
[0090] Based on the compressed integrated multi-task model, the sentiment tendency and relevance of the input text are judged;
[0091] In step S2, the multi-task model training parameters are configured:
[0092] Set the step size parameter for updating model parameters, i.e. learning rate, to 3e-5;
[0093] Set the batch size of training samples on each GPU / CPU, i.e. the inference batch size parameter batch_size, to 16 (GPU memory optimization);
[0094] Set the number of rounds of complete traversal of the training data to 4;
[0095] Customize the configuration output path and log path.
[0096] In step S2, when the multi-task model is initially trained, the weight distribution between sentiment analysis (classification task) and subject relevance identification (binary classification task) is coordinated through a multi-task loss function. The multi-task loss function optimizes the two tasks simultaneously during the training process through weighted summation. The multi-task loss function is:
[0097] L=αLsen+(1-α)Lrel+λ||θ|| 2
[0098] Among them, Lsen is the cross entropy loss function, Lrel is the binary classification relevance loss function, α is the weight coefficient, the value is 0.7, λ is the L2 regularization parameter λ, the value is 0.01, ||θ|| 2 The value is 1.2.
[0099] In step S2, sentiment tendency and relevance determination are performed on the input Tokenized text (such as [CLS] Mobile package in A is too expensive [SEP]) based on the trained multi-task model;
[0100] When judging the sentiment tendency, the sentiment tendency result ("positive", "negative", "neutral") and confidence level output by the multi-task model are used. The confidence threshold is set to 0.6. If the confidence probability is lower than the threshold, it is marked as neutral. Otherwise, the model output result is used directly.
[0101] When making a correlation judgment, if the multi-task model output probability is not less than 0.7, it is judged to be relevant.
[0102] Example output:
[0103] {"text":"The 5G package charges of China Mobile in Location A are too high!","sentiment":"negative","related_prob":0.92}
[0104] Step S3: manually screen and update the rule vocabulary to improve process efficiency;
[0105] First, improve the relevant keywords;
[0106] If the input text does not find relevance through the keyword matching rules, but the multi-task model determines that there is relevance, then manually extract keywords and update and improve the regional vocabulary K_loc and corporate vocabulary K_com;
[0107] Modify sentiment keywords, detect negation words (such as "not", "no", "lack") and degree words (such as "extremely" and "slightly"). If double negation words exist in the same text, reverse the sentiment polarity (such as "not bad" → positive) and adjust the confidence score;
[0108] In step S3, the emotional keyword correction formula is as follows:
[0109] Sfinal=Smodel×(1+β-Intensity(x))
[0110] Among them, Sfinal represents the corrected sentiment tendency probability, Smodel represents the basic sentiment tendency probability output by the multi-task model, β is the intensity coefficient, and Intensity(x) represents the degree value when calculated according to the degree dictionary, which can be -1 or 1.
[0111] Step S4: Output a structured public opinion report (JSON / CSV format) based on the custom structure.
[0112] The multi-task network public opinion analysis system based on a large language model is used to implement the above method, including:
[0113] The data collection and preprocessing module is responsible for crawling data from social media, news websites, forums, and Tieba forums with information access permissions, and preprocessing the crawled data, including data cleaning, word segmentation, and keyword matching. If the keyword match is successful, it is marked as pre-association; otherwise, the multi-task model is called for inference.
[0114] The dynamic domain adapter (DDA) is responsible for loading the pre-trained BERT model as the base model, injecting the industry knowledge base (such as the communications field glossary), and modifying the output layer to a dual-task head, including a sentiment analysis head and a relevance head; updating the parameters through the layered learning rate, starting the training after the multi-task model training parameters are configured, and saving the trained multi-task model.
[0115] The lightweight deployment module is responsible for using the layered knowledge distillation (HKD) compression model to compress the 12-layer pre-trained BERT model into a 4-layer TinyBERT model, preserving key layer parameters. This reduces the computational effort by 70% while retaining 95% accuracy. The model is converted to ONNX format and integrated into the streaming processing framework.
[0116] The Rule-Model Collaboration Engine (RMCE) is responsible for determining whether the input text is relevant to the target company in two steps. If the input text contains both regional keywords and company keywords, it skips the model prediction and directly determines the relevance as 1. Otherwise, it calls the trained multi-task model to determine the sentiment tendency and relevance of the input text.
[0117] The rule correction module is responsible for improving relevant keywords and correcting emotional keywords through manual screening to improve process efficiency;
[0118] The report output module outputs structured public opinion reports (JSON / CSV format) based on custom structures.
[0119] The network public opinion multi-task analysis device based on a large language model includes a memory and a processor; the memory is used to store a computer program, and the processor is used to implement the above-mentioned method steps when executing the computer program.
[0120] The readable storage medium stores a computer program, which implements the above method steps when executed by a processor.
[0121] The embodiment described above is only one specific implementation of the present invention. Common changes and substitutions made by those skilled in the art within the scope of the technical solution of the present invention should be included in the protection scope of the present invention.
Claims
1. A multi-task analysis method for online public opinion based on a large language model, characterized by: The following steps are involved: Step S1, data preparation and preprocessing; Crawl data from social media, news websites, forums, and Tieba forums with information access permissions, and preprocess the crawled data, including data cleaning, word segmentation, and keyword matching; If the keyword matches successfully, it is marked as pre-association, otherwise jump to step S2 to enter model reasoning; Step S2: Build a multi-task model to jointly output sentiment and relevance results; Using the pre-trained BERT model as the base model, the output layer is modified to a dual-task head, including a sentiment analysis head and a relevance head; Among them, the sentiment analysis head is a fully connected layer that outputs [negative, neutral, positive] probabilities; The relevance head is a fully connected layer that outputs the probability of [irrelevant, relevant]; Configure the multi-task model training parameters, start training and save the trained multi-task model; Use layered knowledge distillation (HKD) to compress the 12-layer pre-trained BERT model into a 4-layer TinyBERT model, retaining key layer parameters. Convert the model to ONNX format and integrate it into the streaming framework. Based on the compressed integrated multi-task model, the sentiment tendency and relevance of the input text are judged; Step S3: manually screen and update the rule vocabulary to improve process efficiency; First, improve the relevant keywords; If the input text does not find relevance through the keyword matching rules, but the multi-task model determines that there is relevance, then manually extract keywords and update and improve the regional vocabulary K_loc and corporate vocabulary K_com; Correct sentiment keywords, detect negation words and degree words, and if double negation words exist in the same text, reverse the sentiment polarity and adjust the confidence score; Step S4: Output a structured public opinion report based on the custom structure.
2. The multi-task analysis method for online public opinion based on a large language model according to claim 1 is characterized by: In step S1, Apache Kafka is used as a message queue to support high-throughput streaming data access; Configure the crawler parameters, set the request interval delay to 1s and the concurrency to 50 to avoid IP blocking; Data cleaning methods include: Denoising: Use regular expressions to filter HTML tags and custom special symbols; Standardization: converting traditional Chinese characters into simplified Chinese characters, and restoring pinyin abbreviations into simplified Chinese characters; Segmentation: split long text into segments according to punctuation marks, with each segment not exceeding 128 characters; Set the maximum text length parameter max_length to 512. If it exceeds the parameter setting, it will be truncated; Word segmentation and keyword matching methods include: Word segmentation: Use bert-base-chinese word segmenter to expand domain terms; Keyword matching: custom-build regional vocabulary K_loc and corporate vocabulary K_com; If the text hits both the regional vocabulary K_loc and the corporate vocabulary K_com, the relevance is determined to be 1. Otherwise, the process jumps to step S2 to enter model inference and output the relevance probability.
3. The multi-task analysis method for online public opinion based on a large language model according to claim 1 is characterized by: In step S2, the multi-task model training parameters are configured: Set the step size parameter for updating model parameters, i.e. learning rate, to 3e-5; Set the batch size of training samples on each GPU / CPU, i.e. the inference batch size parameter batch_size, to 16; Set the number of rounds of complete traversal of the training data to 4; Customize the configuration output path and log path.
4. The multi-task analysis method for online public opinion based on a large language model according to claim 1 is characterized by: In step S2, when the multi-task model is initially trained, the weight distribution between sentiment analysis and subject relevance recognition is coordinated through a multi-task loss function, and the multi-task loss function is weighted summed to enable the multi-task model to simultaneously optimize the two tasks during the training process; The multi-task loss function is: L=αLsen+(1-α)Lrel+λ||θ|| 2 Among them, Lsen is the cross entropy loss function, Lrel is the binary classification relevance loss function, α is the weight coefficient, the value is 0.7, λ is the L2 regularization parameter λ, the value is 0.01, ||θ|| 2 The value is 1.
2.
5. The multi-task analysis method for online public opinion based on a large language model according to claim 1 is characterized by: In step S2, sentiment tendency determination and relevance determination are performed on the input Tokenized text based on the trained multi-task model; When judging the sentiment tendency, the sentiment tendency result ("positive", "negative", "neutral") and confidence level output by the multi-task model are used. The confidence threshold is set to 0.
6. If the confidence probability is lower than the threshold, it is marked as neutral. Otherwise, the model output result is used directly. When making a correlation judgment, if the multi-task model output probability is not less than 0.7, it is judged to be relevant.
6. The multi-task analysis method for online public opinion based on a large language model according to claim 1 is characterized by: In step S3, the emotional keyword correction formula is as follows: Sfinal=Smodel×(1+β-Intensity(x)) Among them, Sfinal represents the corrected sentiment tendency probability, Smodel represents the basic sentiment tendency probability output by the multi-task model, β is the intensity coefficient, and Intensity(x) represents the degree value when calculated according to the degree dictionary, which can be -1 or 1.
7. A multi-task network public opinion analysis system based on a large language model, characterized by: The method for implementing any one of claims 1 to 6 comprises: The data collection and preprocessing module is responsible for crawling data from social media, news websites, forums, and Tieba forums with information access permissions, and preprocessing the crawled data, including data cleaning, word segmentation, and keyword matching. If the keyword match is successful, it is marked as pre-association; otherwise, the multi-task model is called for inference. The dynamic domain adapter (DDA) is responsible for loading the pre-trained BERT model as the base model, injecting the industry knowledge base, and modifying the output layer to a dual-task head, including a sentiment analysis head and a relevance head. It updates the parameters through the layered learning rate, starts training after the multi-task model training parameters are configured, and saves the trained multi-task model. The lightweight deployment module is responsible for using the layered knowledge distillation (HKD) compression model to compress the 12-layer pre-trained BERT model into a 4-layer TinyBERT model, retaining key layer parameters, converting the model to ONNX format, and integrating it into the streaming processing framework; The Rule-Model Collaboration Engine (RMCE) is responsible for determining whether the input text is relevant to the target company in two steps. If the input text contains both regional keywords and company keywords, it skips the model prediction and directly determines the relevance as 1. Otherwise, it calls the trained multi-task model to determine the sentiment tendency and relevance of the input text. The rule correction module is responsible for improving relevant keywords and correcting emotional keywords through manual screening to improve process efficiency; The report output modules all output structured public opinion reports based on custom structures.
8. A multi-task analysis device for online public opinion based on a large language model, characterized by: The method comprises a memory and a processor; the memory is used to store a computer program, and the processor is used to implement the method according to any one of claims 1 to 6 when executing the computer program.
9. A readable storage medium, characterized in that: The readable storage medium stores a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 6.