Net citizen viewpoint analysis method based on double large models
By employing a dual-model approach to analyze netizens' opinions, and utilizing text compression and improved RoPE encoding technology, the problems of low model robustness and low clustering efficiency in existing technologies are solved, achieving efficient and accurate analysis and clustering of netizens' opinions.
Patent Information
- Application Number
- CN202411021978.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-11-22
AI Technical Summary
Existing methods for analyzing netizens' opinions suffer from poor model robustness, low analysis efficiency and accuracy, poor clustering algorithm performance and high optimization difficulty, and large language models are limited by short context windows when processing long texts, making it difficult to effectively understand long-distance dependencies.
We employ a dual-model-based analysis approach. The first model is used for text compression, while the second model is used for clustering and opinion summarization. This extends the context length of the large model, and we enhance the model's context processing capabilities through improved RoPE encoding and fine-tuning techniques.
It improves the speed and accuracy of analyzing netizens' opinions, enhances the interpretability and controllability of the analysis, can process more text at once, and provides in-depth insights and targeted optimization of clustering effects.
Smart Images

Figure CN119003769A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network information processing, and more specifically, to a method for analyzing netizens' opinions based on a dual-major model. Background Art
[0002] With the development and popularization of the Internet, more and more netizens express their opinions and spread their ideas through various platforms and channels on the Internet. Netizen opinion analysis aims to cluster, summarize and analyze netizens' comments and opinions. By collecting comments and forwarded content under a specific topic, mining user opinion information from it, and classifying this opinion information, we can quickly understand netizens' attitudes and views on a specific topic.
[0003] Traditional methods of analyzing netizens' opinions can be mainly divided into manual intervention and non-manual intervention: 1) Manual intervention refers to clustering texts into multiple groups through various clustering methods, and then manually summarizing representative opinions for each group. This method is time-consuming and labor-intensive, and has low scalability; 2) Non-manual intervention refers to clustering texts into multiple groups through various clustering methods, and then using a large language model (LLM) to summarize opinions for each group. Although large language models have shown powerful capabilities in natural language processing tasks, this method has the problems of low clustering interpretability and inability to cluster according to different dimensions (such as by population, by user preferences, etc.), and most clustering algorithms rely on base models, making it difficult to optimize the clustering effect later.
[0004] The context length of a large language model refers to the total number of characters (Tokens) in the input plus the output of the large model. This number will be limited, and characters exceeding this length will be discarded by the large model. Since there are a large amount of netizens' opinion texts on the Internet, there are certain requirements for the context length of large models. At present, the context length of open source large language models is generally not long. For example, Llama 2 is only 4K, and the Code-Llama series has been extended to 16K because of the need to input code; closed-source series models provide longer context lengths, such as OpenAI's latest model GPT-4 Turbo provides a context length of 128K, and Anthropic's Claude 2.1 model provides a context length of 200K. In order to summarize netizens' opinions with higher accuracy from massive texts, the context length of the large model must be extended.
[0005] There are generally two ways to extend the context length of a large model: 1) One is that the large model is set to a long context in the initial stage, and then a long-context large model is obtained through pre-training, instruction fine-tuning, alignment training, etc. However, long text training requires a large amount of video memory and computing resources; 2) Another way is to select an already trained large model, transform its encoding method through technology to extend its context length, and then perform fine-tuning training to obtain a long-context large model. For example, the patent document "CN117875434A" discloses a length extrapolation method for large financial models for extending the length of input context. This scheme improves the model's position encoding to enhance the model's ability to handle longer contexts, and optimizes the model's ability to capture long-distance dependencies by introducing dynamic calculation of scaling factors and position biases, while avoiding the need for large-scale fine-tuning of the model. However, the problem with this scheme is that while extending the context length, it may affect other aspects of the model's performance. For example, the model may be less efficient when processing short or medium-length texts. It is unclear whether the scheme can maintain consistent performance on different types of long text data. Since the scheme does not fine-tune vertical field data, if the model is not exposed to enough long texts or related tasks during training, its ability to process long texts in actual applications may be limited, and its effectiveness in the scenario of netizen opinion analysis cannot be guaranteed.
[0006] In general, traditional clustering analysis schemes for netizens' opinions have the following problems: they are highly dependent on the base model, have defects in model robustness, and are complex to update and maintain later; secondly, when processing large-scale data, the clustering algorithms used in existing technologies (such as clustering based on cosine similarity and AP clustering algorithms) have poor performance and are difficult to optimize; in addition, existing large language models (LLMs) are limited by shorter context windows when processing long texts, which limits the model's ability to understand long-distance dependencies and makes it impossible to input a lot of data into the model for analysis at a time, affecting the analysis speed and accuracy. Summary of the invention
[0007] In order to overcome the defects of the above-mentioned prior art, such as poor model robustness, low analysis efficiency and accuracy, and difficulty in subsequent maintenance and optimization, the present invention provides a method for analyzing netizens' opinions based on dual large models. One large model is used to compress text, and then another large model is used to perform clustering analysis of netizens' opinions, replacing the original traditional text clustering scheme. Two large models are directly used for clustering and opinion summarization respectively, which has strong interpretability and is easy to optimize subsequently. At the same time, the input context length of the large model is increased, so that the large model can process more text at one time, thereby improving the speed and accuracy of opinion summarization.
[0008] In order to solve the above technical problems, the technical solution of the present invention is as follows: A method for analyzing netizens' opinions based on the dual-major model includes the following steps: S1: Collect and preprocess the text dataset of netizens’ comments from the Internet; S2: Select the first largest model and the second largest model and perform context length extension respectively to obtain the first largest model and the second largest model after the context length extension respectively; S3: fine-tuning and training the first large model and the second large model after the context length expansion respectively using the preprocessed netizen comment text dataset to obtain the trained first large model and the second large model; S4: Obtain a text dataset of netizens’ comments to be analyzed and input the trained first model to perform text compression, thereby obtaining a text-compressed dataset of netizens’ comments; S5: inputting the compressed text data set of netizens' comments into the trained second largest model to perform text clustering, and obtaining representative opinions of several categories of netizens' comments; S6: Use the trained second largest model to perform secondary clustering and opinion summary on all representative opinions to obtain the final analysis results of netizens' opinions.
[0009] Preferably, the step S1 comprises: Collect a number of netizen comments from various social media channels on the Internet, clean the collected netizen comments, remove pure expression comments and useless text, and build a netizen comment text dataset; Using the netizen comment text dataset, a text compression question-answer pair dataset, a text clustering dataset, and a key retrieval dataset are constructed to complete preprocessing; The text compression question-answer pair dataset and the text clustering dataset are respectively used to fine-tune and train the first large model and the second large model after context length expansion, and the key retrieval dataset is used to expand the context length of the first large model and the second large model.
[0010] Preferably, in the text compression question-answer pair data set, each piece of data is a text compression question-answer pair including an input and an output, the input of the text compression question-answer pair is a text compression prompt and the original text of the netizen's comment, and the output is a text compression result; The text compression prompt is used to guide the large model to complete the text compression task; Constructing the text compression question-answer pair dataset includes the following steps: Call at least two external large models, set each called external large model to the same text compression prompt, and input the original text of netizens' comments respectively to generate text compression results corresponding to each external large model; For each original text of a netizen's comment, respectively calculate the text similarity between the text compression result of each external large model and the other text compression results; calculate the text similarity based on the edit distance or the cosine distance; If the similarity of the text compression results of two external large models is greater than the preset threshold, the original comment of the netizen, the text compression prompt, and the text compression result output by any of the two external large models will form a text compression question-answer pair; Otherwise, perform manual syntactic analysis on the original text of the netizen's comment and the text compression results of all external large models, compare the overlap between the sentence components of the original text of the netizen's comment and the text compression results of all external large models, and select the text compression result with the highest overlap, the original text of the netizen's comment, and the text compression prompt to form a text compression question-answer pair; All text-compressed question-answer pairs are saved as the text-compressed question-answer pair dataset.
[0011] Preferably, the input of the text clustering data set is the text clustering prompt and the numbered original text of the netizens' comments, and the output is the text clustering result; the text clustering result includes several groups and the representative viewpoints of each group and the original number of the netizens' comments; Constructing the text clustering dataset includes the following steps: Number each netizen's comment one by one, and obtain the original text of the numbered netizen's comment; Primary clustering: using any clustering algorithm among BERTopic, hierarchical clustering and AP clustering to cluster all the numbered original netizen comments, and dividing all the numbered original netizen comments into multiple text groups, each of which is a netizen comment with similar semantics; Sort the comments of netizens in each of the text groups by the number of likes or the amount of interaction, extract the comments of netizens ranked before a certain percentage, call the preset external big model, set the preset text clustering prompt to the prompt word of the external big model to perform text summary, and output the representative viewpoint corresponding to each text group; Secondary clustering: Based on the clustering algorithm and the external large model, the representative opinions corresponding to each text group obtained by the primary clustering are clustered again, similar text groups and their representative opinions are merged, the final grouping and the representative opinions of each group are obtained, and they are saved together with the original text number of the netizens' comments in each group as the text clustering result; The text clustering prompt, the numbered original comments of netizens and the text clustering results are saved together as a text clustering data set.
[0012] Preferably, in the secondary clustering process, the same clustering algorithm as the primary clustering is used, but a different external large model is used; Or use a different clustering algorithm than the primary clustering, but use the same external large model; Or use a different clustering algorithm than the primary clustering, but use a different external large model; In the secondary clustering and primary clustering processes, the prompt words of the external large model used are all text clustering prompts.
[0013] Preferably, the key search data set is based on the original text of the netizens' comments after being numbered, and the input is a key search prompt, and the key search prompt includes a number of numbers; the output is the original text of the netizens' comments corresponding to each of the numbers.
[0014] Preferably, in step S2, respectively extending the context length of the first large model and the second large model comprises: For the first and second largest models selected, respectively, initialize the position encoding of their RoPEs, set an initial scaling factor for each RoPE dimension, and set the scaling factor of each RoPE dimension as a trainable parameter; The RoPE encoding calculation formula is:
[0015] in, represents the encoding of position n, d is the text embedding dimension, n is the position index of the token, is the rotation angle of the token in the i-th dimension at position n, satisfying ; The scaling factor After setting as a trainable parameter, the modified RoPE encoding calculation formula is:
[0016] in, The encoding after adding the scaling factor to position n; is a trainable scaling factor of the i-th dimension; each of the scaling factors is a different value randomly initialized; A cosine similarity loss function is set, and context length expansion training is performed on the initialized first large model and the second large model using the key retrieval data set. During the context length expansion training process, the scaling factor of each RoPE dimension is iteratively updated until the scaling factor that minimizes the cosine similarity loss function is obtained and saved, thereby obtaining the first large model and the second large model after context length expansion.
[0017] Preferably, in step S3, the process of fine-tuning and training the first model after the context length expansion using the preprocessed netizen comment text dataset includes: Setting a text compression loss function for the first largest model after the context length expansion, using the text compression question-answer pair dataset to fine-tune and train all parameters of the first largest model after the context length expansion until the text compression loss function reaches a minimum value, thereby obtaining the trained first largest model; The text compression loss function includes any one of a cross entropy loss function and a cosine similarity loss function.
[0018] Preferably, in step S3, the process of fine-tuning and training the second largest model after the context length expansion using the preprocessed netizen comment text dataset includes: Constructing positive and negative sample pairs based on the text clustering data set, wherein the positive samples are other samples in the same group, and the negative samples are samples in other groups; For the text clustering task, a text clustering loss function is set, and the second largest model after the context length expansion is fine-tuned and trained using the LoRA algorithm and positive and negative sample pairs to obtain the second largest model after one training; The text clustering loss function is specifically:
[0019] in, is the text clustering loss function value, N is the number of samples in a training batch; M is the total number of positive and negative samples to be compared for each sample; is the i-th positive sample and the jth negative sample The similarity between is the i-th negative sample, and the similarity is the dot product or cosine similarity; is the temperature parameter; For the secondary clustering task representing opinions, a opinion summary loss function is set, and the second largest model after the first training is fine-tuned and trained using a reinforcement learning DPO algorithm and positive and negative sample pairs to obtain a final trained second largest model; The viewpoint summary loss function is specifically a DPO loss function.
[0020] Preferably, the first large model and the second large model in step S2 are any one of LLaMA, Qwen, Baichuan, Deepseek and Mistral large language models.
[0021] Compared with the prior art, the technical solution of the present invention has the following beneficial effects: The present invention provides a method for analyzing netizens' opinions based on dual large models. First, a text data set of netizens' comments is collected from the Internet and preprocessed; then a first large model and a second large model are selected and context length expansion is performed respectively; then the preprocessed text data set of netizens' comments is used to fine-tune and train the first large model and the second large model after context length expansion respectively; then the text data set of netizens' comments to be analyzed is obtained and input into the trained first large model for text compression to obtain the text-compressed netizen comment data set; the text-compressed netizen comment data set is input into the trained second large model for text clustering to obtain representative opinions of several netizen comment categories; the trained second large model is used to perform secondary clustering and opinion summary on all representative opinions to obtain the final netizen opinion analysis result; The present invention utilizes the first large model to compress long texts, which helps the subsequent second large model to better understand the structure and semantics of the text during the clustering analysis of netizens' opinions. The two large models are directly used for clustering and opinion summarization, which has strong interpretability and is easy to optimize later. At the same time, the present invention extends the input context length of the two large models, allowing the large models to process more texts at one time, thereby improving the speed and accuracy of opinion summarization. In addition, the present invention can not only effectively process and analyze long text data, but also provide in-depth insights and understanding, and can later perform clustering at specific angles through user customization. In addition to outputting the representative opinions of netizens, it can also be applied to outputting application scenarios such as emotions and representative keywords, and output analysis reasons. In short, the clustering effect of the present invention can be optimized in a targeted manner, thereby making the entire process of clustering analysis of netizens' opinions more interpretable and controllable in effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 This is a flow chart of a method for analyzing netizens’ opinions based on a dual-major model provided in Example 1.
[0023] Figure 2 This is a structural diagram of the Llama large model provided in Example 2.
[0024] Figure 3 This is a structural diagram of the Llama Attention layer provided in Example 2.
[0025] Figure 4 This is a schematic diagram of training the first and second largest models after context length expansion provided in Example 2.
[0026] Figure 5 This is a flow chart of analyzing netizens’ opinions using the trained first and second large models provided in Example 2. DETAILED DESCRIPTION
[0027] The drawings are for illustrative purposes only and should not be construed as limiting the present patent; In order to better illustrate the present embodiment, some parts in the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product; It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0028] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0029] Example 1 like Figure 1 As shown, this embodiment provides a method for analyzing netizens' opinions based on the dual-major model, comprising the following steps: S1: Collect and preprocess the text dataset of netizens’ comments from the Internet; S2: Select the first largest model and the second largest model and perform context length extension respectively to obtain the first largest model and the second largest model after the context length extension respectively; S3: fine-tuning and training the first large model and the second large model after the context length expansion respectively using the preprocessed netizen comment text dataset to obtain the trained first large model and the second large model; S4: Obtain a text dataset of netizens’ comments to be analyzed and input the trained first model to perform text compression, thereby obtaining a text-compressed dataset of netizens’ comments; S5: inputting the compressed text data set of netizens' comments into the trained second largest model to perform text clustering, and obtaining representative opinions of several categories of netizens' comments; S6: Use the trained second largest model to perform secondary clustering and opinion summary on all representative opinions to obtain the final analysis results of netizens' opinions.
[0030] In the specific implementation process, this embodiment proposes a dual-large model strategy, firstly, the context length of the two large models is extended, then the text is compressed by the first large model, and then the second large model is used to perform cluster analysis of netizens' opinions. The clustering is also divided into two stages. In the first stage, the comments of netizens are grouped and clustered, and in the second stage, the representative opinions of each group are clustered again, so as to complete the opinion summary. Specifically, firstly, a text dataset of netizens' comments is collected from the Internet and preprocessed; then, the first and second largest models are selected and context lengths are extended respectively; then, the preprocessed text dataset of netizens' comments is used to fine-tune and train the first and second largest models after context length extension respectively; then, the text dataset of netizens' comments to be analyzed is obtained and input into the trained first largest model for text compression, so as to obtain the text-compressed netizens' comment dataset; the text-compressed netizens' comment dataset is input into the trained second largest model for text clustering, so as to obtain representative opinions of several categories of netizens' comments; all representative opinions are secondary clustered and opinion summarization is performed using the trained second largest model, so as to obtain the final analysis results of netizens' opinions; This method uses the first large model to compress long texts, which helps the subsequent second large model to better understand the structure and semantics of the text when clustering and analyzing netizens' opinions. The two large models are directly used for clustering and opinion summarization, which has strong interpretability and easy subsequent optimization. At the same time, this method extends the input context length of the two large models, allowing the large models to process more text at one time, thereby improving the speed and accuracy of opinion summarization.
[0031] Example 2 This embodiment provides a method for analyzing netizens' opinions based on the dual-major model, comprising the following steps: S1: Collect and preprocess the text dataset of netizens’ comments from the Internet; S2: Select the first largest model and the second largest model and perform context length extension respectively to obtain the first largest model and the second largest model after the context length extension respectively; S3: fine-tuning and training the first large model and the second large model after the context length expansion respectively using the preprocessed netizen comment text dataset to obtain the trained first large model and the second large model; S4: Obtain a text dataset of netizens’ comments to be analyzed and input the trained first model to perform text compression, thereby obtaining a text-compressed dataset of netizens’ comments; S5: inputting the compressed text data set of netizens' comments into the trained second largest model to perform text clustering, and obtaining representative opinions of several categories of netizens' comments; S6: performing secondary clustering and opinion summarization on all representative opinions using the trained second largest model to obtain the final analysis results of netizens’ opinions; The step S1 comprises: Collect a number of netizen comments from various social media channels on the Internet, clean the collected netizen comments, remove pure expression comments and useless text, and build a netizen comment text dataset; Using the netizen comment text dataset, a text compression question-answer pair dataset, a text clustering dataset, and a key retrieval dataset are constructed to complete preprocessing; The text compression question-answer pair dataset and the text clustering dataset are respectively used to fine-tune and train the first large model and the second large model after the context length expansion, and the key retrieval dataset is used to expand the context length of the first large model and the second large model; In the text compression question-answer pair data set, each piece of data is a text compression question-answer pair including an input and an output, the input of the text compression question-answer pair is a text compression prompt and the original text of the netizen's comment, and the output is a text compression result; The text compression prompt is used to guide the large model to complete the text compression task; Constructing the text compression question-answer pair dataset includes the following steps: Call at least two external large models, set each called external large model to the same text compression prompt, and input the original text of netizens' comments respectively to generate text compression results corresponding to each external large model; For each original text of a netizen's comment, respectively calculate the text similarity between the text compression result of each external large model and the other text compression results; calculate the text similarity based on the edit distance or the cosine distance; If the similarity of the text compression results of two external large models is greater than the preset threshold, the original comment of the netizen, the text compression prompt, and the text compression result output by any of the two external large models will form a text compression question-answer pair; Otherwise, perform manual syntactic analysis on the original text of the netizen's comment and the text compression results of all external large models, compare the overlap between the sentence components of the original text of the netizen's comment and the text compression results of all external large models, and select the text compression result with the highest overlap, the original text of the netizen's comment, and the text compression prompt to form a text compression question-answer pair; Saving all text-compressed question-answer pairs as the text-compressed question-answer pair dataset; The input of the text clustering dataset is the text clustering prompt and the original text of the netizens' comments after numbering, and the output is the text clustering result; the text clustering result includes several groups and the representative views of each group and the original number of the netizens' comments; Constructing the text clustering dataset includes the following steps: Number each netizen's comment one by one, and obtain the original text of the numbered netizen's comment; Primary clustering: using any clustering algorithm among BERTopic, hierarchical clustering and AP clustering to cluster all the numbered original netizen comments, and dividing all the numbered original netizen comments into multiple text groups, each of which is a netizen comment with similar semantics; Sort the comments of netizens in each of the text groups by the number of likes or the amount of interaction, extract the comments of netizens ranked before a certain percentage, call the preset external big model, set the preset text clustering prompt to the prompt word of the external big model to perform text summary, and output the representative viewpoint corresponding to each text group; Secondary clustering: Based on the clustering algorithm and the external large model, the representative opinions corresponding to each text group obtained by the primary clustering are clustered again, similar text groups and their representative opinions are merged, the final grouping and the representative opinions of each group are obtained, and they are saved together with the original text number of the netizens' comments in each group as the text clustering result; The text clustering prompt, the numbered original comments of netizens and the text clustering results are saved together as a text clustering data set; In the secondary clustering process, the same clustering algorithm as the primary clustering is used, but a different external large model is used; Or use a different clustering algorithm than the primary clustering, but use the same external large model; Or use a different clustering algorithm than the primary clustering, but use a different external large model; In the secondary clustering and primary clustering processes, the prompt words of the external large model used are all text clustering prompts; The key search data set is based on the original text of the netizens' comments after being numbered, and the input is the key search prompt, which contains a number of numbers; the output is the original text of the netizens' comments corresponding to each number; In step S2, respectively extending the context length of the first large model and the second large model includes: For the first and second largest models selected, respectively, initialize the position encoding of their RoPEs, set an initial scaling factor for each RoPE dimension, and set the scaling factor of each RoPE dimension as a trainable parameter; The RoPE encoding calculation formula is:
[0032] in, represents the encoding of position n, d is the text embedding dimension, n is the position index of the token, is the rotation angle of the token in the i-th dimension at position n, satisfying ; The scaling factor After setting as a trainable parameter, the modified RoPE encoding calculation formula is:
[0033] in, The encoding after adding the scaling factor to position n; is a trainable scaling factor of the i-th dimension; each of the scaling factors is a different value randomly initialized; A cosine similarity loss function is set, and context length extension training is performed on the initialized first large model and the second large model using the key retrieval data set. During the context length extension training, the scaling factor of each RoPE dimension is iteratively updated until the scaling factor that minimizes the cosine similarity loss function is obtained and saved, and the first large model and the second large model after context length extension are obtained; In step S3, the process of fine-tuning and training the first model after the context length expansion using the pre-processed netizen comment text dataset includes: Setting a text compression loss function for the first largest model after the context length expansion, using the text compression question-answer pair dataset to fine-tune and train all parameters of the first largest model after the context length expansion until the text compression loss function reaches a minimum value, thereby obtaining the trained first largest model; The text compression loss function includes any one of a cross entropy loss function and a cosine similarity loss function; In step S3, the process of fine-tuning and training the second largest model after the context length expansion using the pre-processed netizen comment text dataset includes: Constructing positive and negative sample pairs based on the text clustering data set, wherein the positive samples are other samples in the same group, and the negative samples are samples in other groups; For the text clustering task, a text clustering loss function is set, and the second largest model after the context length expansion is fine-tuned and trained using the LoRA algorithm and positive and negative sample pairs to obtain the second largest model after one training; The text clustering loss function is specifically:
[0034] in, is the text clustering loss function value, N is the number of samples in a training batch; M is the total number of positive and negative samples to be compared for each sample; is the i-th positive sample and the jth negative sample The similarity between is the i-th negative sample, and the similarity is the dot product or cosine similarity; is the temperature parameter; For the secondary clustering task representing opinions, a opinion summary loss function is set, and the second largest model after the first training is fine-tuned and trained using a reinforcement learning DPO algorithm and positive and negative sample pairs to obtain a final trained second largest model; The viewpoint summary loss function is specifically a DPO loss function; The first large model and the second large model in step S2 are any one of the large language models of LLaMA, Qwen, Baichuan, Deepseek and Mistral.
[0035] In the specific implementation process, this embodiment proposes a dual-large model strategy, firstly, the context length of the two large models is extended, then the text is compressed by the first large model, and then the second large model is used to perform cluster analysis of netizens' opinions. The clustering is also divided into two stages. In the first stage, the comments of netizens are grouped and clustered, and in the second stage, the representative opinions of each group are clustered again, so as to complete the opinion summary. First, we need to collect a large amount of long text data from social media. These public social media data can come from different network platforms to ensure the diversity and representativeness of the data to cover different topics and styles. We need to clean the collected data to remove useless texts such as those that are too short or pure expressions. We need to construct the data set required for the training task and divide the collected data into 500 text lengths. Texts greater than 500 are long texts and texts less than or equal to 500 are short texts. The ratio of long text to short text is 1:1. 1. Training Task 1: Construction of Text Compression Question and Answer Dataset; (1) Data format: Each piece of data is a question-answer pair: [input: text-compressed prompt + original text, output: text compression result]; (2) Prompt design: Continuously debug and design clear prompts to guide the model to complete the text summary task. For example: "You are a natural language processing expert. I will give you a text. First analyze the sentence components, and then summarize the text in one sentence in the order of subject + predicate + object + complement + preposition + verb. The text should not exceed 50 words, and missing sentence components are ignored. Input text: [text content]"; (3) Multi-model cross-generation summary: By calling 2-3 external large-model paid or free interfaces or open source large models, each large model uses the same prompt combined with the original text as input to generate the corresponding text compression result; (4) Voting mechanism: The same batch of data will get different text compression results when running different large models. For each piece of data, assuming that two large models are used for text compression, the contents of the two text compressions are calculated, and the edit distance or cosine distance or a method for measuring text similarity is calculated. The purpose is that when the similarity of the text compression results of the two large models is greater than 80%, the data and the output of any one of the two large models constitute a question-answer pair and are put into the training set; when the similarity of the text compression results of the two large models is less than 80%, the sentence and the text compression results of the two large models are syntactically analyzed and the sentence components are output respectively. The sentence components of the large model results are compared with those of the original sentence, and the result of the large model with the greater overlap is selected to form a question-answer pair with the original sentence and put into the training set; 2. Training Task 2: Constructing a large model text clustering dataset using the secondary clustering method; (1) Construct a prompt. The specific prompt can be fine-tuned by yourself. The general meaning is: "Cluster the text according to the input comment data, and summarize a representative opinion for each clustered text group. The input netizen comments are as follows: {comments_lst}"; comments_lst is all the netizen comments, one per line, and then together with this prompt, it is used as the input of the large model. The output of the large model is all the text groups, the comment number and representative opinion corresponding to each group; (2) Data format: Each piece of data is a question-answer pair: [Input: prompt + multiple netizens’ comments with serial numbers, Output: clustered groups, serial numbers and representative opinions corresponding to each group]; (3) Construction method: Use traditional methods to construct data. First, use bert-topic, hierarchical clustering, AP clustering and other methods to cluster the text. After clustering, the text will be divided into multiple text groups. Each group of texts is a netizen comment with similar semantics. Finally, the top 10% of the data in each group of texts is extracted in reverse order according to indicators such as the number of likes or the amount of interaction. Combined with the prompt of the netizen’s opinion summary, the same big model interface (closed source big model interface or offline deployed big model) is called to summarize the text and output the representative opinion corresponding to each text group (text group 1: representative opinion 1, text group 2: representative opinion 2...); (4) Due to the defects of clustering algorithms, after clustering, although the text contents are related, they are still clustered into different text groups. This leads to the fact that the representative opinions of some groups output by the large model are relatively similar. Therefore, different clustering methods can be used here to perform secondary clustering on the representative opinions output by the large model, and then merge the text groups of representative opinions in the same group, such as (opinion group 1 = representative opinion 1 + representative opinion 2 = text group 1 + text group 2). The purpose of merging is to merge the text groups that were not merged in the first round in the second round, so that the text groups expressing the same content can be merged together; (5) The whole process involves two clusterings, and different clustering methods require the use of vector models. The first clustering is for netizens’ comments, and the second clustering is for representative opinions summarized by the large model. There are many ways to perform the two clusterings: using the same clustering algorithm but using different base vector models, or using different clustering algorithms twice but using the same or different base vector models. This allows the two clusterings to cluster the text from different perspectives and improve the clustering effect. (6) Construct a data set containing preference information. This data set should contain the preferred responses and non-preferred responses corresponding to multiple prompts. This can be done by allowing the model to generate multiple possible responses, and then selecting which are the preferred responses and which are the non-preferred responses based on certain criteria (such as manual evaluation or automated indicators). Here, this embodiment uses manual review to determine whether the representation of the viewpoint is correct. The answer before modification is retained as the non-preferred answer, and the answer after modification is retained as the preferred answer for subsequent reinforcement learning. (7) Finally, a training set question-answer pair is generated. The input is prompt + all numbered texts. The output is multiple groups after clustering. Each group contains a corresponding comment number and a representative opinion of each group. Table 1 is an example of a text clustering data set in this embodiment. In this embodiment, several netizen comments on a new flagship series of mobile phones of a certain brand are selected for netizen opinion analysis. After secondary text clustering, representative opinions of different groups are output; Table 1 Text clustering dataset examples
[0036] 3. Training Task 3: Passkey retrieval task, which measures the model’s ability to retrieve simple keys from a large amount of irrelevant text; Construct a prompt: roughly meaning "output the text content of texts with serial numbers 1, 6, and 789 from the input file"; the input designed in this embodiment is the same as training task 2, which is all the serial numbered text, and the output is a number of serial numbers and the text content of each serial number. The number of serial numbers is randomly selected from 1 to 10, so that the model can find the text with the corresponding serial number from the input text, and then output the text content, which enhances the model's memory and retrieval ability for the input text; the format of the key retrieval data set is shown in Table 2: Table 2 Key retrieval dataset example
[0037] The format of the key retrieval dataset is equal to the question-answer pair, that is, the input on the left is one line per line, plus the written prompt word, and the output is the result on the right; Then, the first largest model and the second largest model are selected, and the context window is expanded. For the pre-trained large language model, this embodiment proposes a new method for expanding its context window so that it can process longer text input for subsequent text clustering (as long as the window is large enough, tens of thousands of texts can be input into the large model at a time for analysis); The context window refers to the range of characters or tokens that the model can consider when processing text. In natural language processing, larger context windows usually help the model better understand the text content, but it also brings computational challenges. Existing large language models (LLMs) are limited to shorter context windows when processing long texts, which limits the model's ability to understand long-distance dependencies. Traditional solutions, such as RoPE (rotational position encoding), can expand the context window to a certain extent, but when extended to very long texts, they face problems such as the introduction of outliers by new position indexes, difficulty in fine-tuning, scarce training data, and high computational costs. 1. Overall process: (1) Model construction: Select a basic model: Select a pre-trained large language model (LLaMA, qwen, baichuan, deepseek, Mistral) as the basic large model. This embodiment uses LLaMA as the basic large model; For the first large model, a high-quality general large language model is generally selected as the basic model, and the parameter amount is generally selected to be less than 10B. In this embodiment, the LLaMA large model with 7B parameters is used as the first large model (small parameter large model); For the second largest model, since secondary clustering is required and complex text data needs to be understood and generated, a large model with a larger number of parameters is selected. In this embodiment, the LLaMA large model with 70B parameters is used as the second largest model (large parameter large model); In this embodiment, the base large model with large parameter amount and small parameter amount can be switched to other large models, and the specific parameter amount can also be selected according to one's own hardware resources, without limitation here; moreover, the closed source large model interface used to construct training data or the external large model deployed offline can be selected according to the business scenario, without limitation here; Introduction to LLama model structure: like Figure 2 As shown, we start with the input text and go through the following layers: 1) Input Embedding: Convert the input text into a vector table, implemented through nn.Embedding; 2) Llama Decoder Layer: The decoder uses a multi-layer Llama Decoder Layer. Each layer includes self-attention (Llama Attention) and a feed-forward network (Llama MLP). Self-attention is used to capture long-range dependencies in text. The feed-forward network performs nonlinear mapping. 3) Llama Attention: A multi-head self-attention mechanism used to model dependencies in text. The input representation is split into multiple heads, and then a dot product attention operation is performed within each head. Self-Attention is a mechanism that allows the model to consider the information of other tokens in the text when processing each token, thereby capturing the dependencies between tokens. 4) Llama MLP: A multi-layer feed-forward network using Gated Linear Units; nonlinear transformations are performed to capture complex patterns; after the self-attention layer, there is usually a feed-forward network that further processes the output of the self-attention layer to extract deeper features; 5) Llama RMSNorm: A normalization method used to regularize the input of each layer and play a role in preprocessing; 6) lm_head: A linear layer that maps the output of the last layer of the Decoder to the dimension of the dictionary size for subsequent language model Logits calculation; In general, Llama stacks multiple layers of self-attention and feedforward networks, so that the model can learn and represent the semantic information of the input text, that is, the deep meaning and contextual information of the word in the text; lm_head is the final output layer of the model, which is responsible for converting the semantic representation inside the model into the original probability estimate of each word in the dictionary. The mapping from the semantic representation to the dictionary Logits is to convert the high-dimensional vector inside the model into a vector of the size of the dictionary, and each element corresponds to a word in the dictionary; Logits is the original output of the model predicting each word, which is usually a continuous value and needs to be converted into a probability distribution through the softmax function; finally, each word in the dictionary will have a probability number, representing the possibility that they are the next word; the entire model is trained end-to-end by minimizing the language model objective function; this means that the entire process from input text to predicted output is continuous, and all parameters of the model are updated simultaneously through optimization algorithms such as gradient descent. The goal of the language model is usually to maximize the probability of a given text sequence, that is, to train the model to improve its accuracy in predicting the next word; In the Llama model, Llama Attention is the core. The structure of this layer is as follows: Figure 3 As shown, Llama's Attention calculation process is as follows:
[0038] The input will be linearly transformed to obtain the Query (Q), Key (K) and Value (V) matrices; RoPE position encoding is applied to Q and K; RoPE contains rotated Sin and Cos encoding, which will rotate the representation of each Token according to its position; the dot product is calculated with the rotated Q and K to obtain the Attention Score, and the Normalized Attention Weight is obtained after Softmax calculation; the Attention Weight is then multiplied by V and weighted summed to obtain the Attention output; The output undergoes a linear transformation and is then output to the next layer as input. In this way, through RoPE position encoding and weighted averaging, Llama's Attention can efficiently and stably extract contextual semantic information of text sequences. Through the above analysis of the Llama structure, we can see that there is a layer called RoPE (Rotational Position Encoding) in Llama Attention, which is mainly used to positionally encode the input, so that the model can learn the positional relationship of each token in the input text, so as to better understand the input; the length of the sequence that the RoPE layer can process determines the context length of Llama. To extend the context length of Llama, the RoPE layer needs to be modified and extended; The traditional method of expanding the input context window of a large model uses the Rope (Rotary Positional Embedding) method, i.e., rotational position encoding. RoPE is a position encoding method that encodes position information as a series of cosine and sine function values. For each token, RoPE generates a fixed-dimensional vector containing rotation angles of different frequencies according to its position index in the sequence. This encoding method enables the model to capture the relative position relationship between tokens. It can be imagined that there is a very long text and the computer needs to understand the position information of each word in the text. Then RoPE is like a way of assigning a special encoding to each word that changes according to its position. Each word has a code composed of cosine and sine values, which change according to the position of the word in the text. However, this method has a problem, that is, not all words require the same encoding strength. For example, the beginning and end of an article are relatively important. This embodiment improves this method and encodes in a more resource-saving way. In this embodiment, the scaling factor is used as a trainable parameter and updated during training. At the same time, long text data in a specific field is used for fine-tuning. The following operation process can be followed and the calculation formula of RoPE can be modified accordingly. The operation process is as follows: For the selected first and second largest language models (LLMs), initialize the positional embedding of RoPE and determine an initial scaling factor for each dimension; set the scaling factor of each RoPE dimension as a trainable parameter; The initial RoPE encoding calculation formula is:
[0039] in, represents the encoding of position n, d is the text embedding dimension, n is the position index of the token, is the rotation angle of the token in the i-th dimension at position n, satisfying ; The scaling factor After setting as a trainable parameter, the modified RoPE encoding calculation formula is:
[0040] in, The encoding after adding the scaling factor to position n; is a trainable scaling factor of the i-th dimension; each of the scaling factors is a different value randomly initialized; After initializing the parameters, long text data in a specific field is collected. Here, the passkey retrieval task in training task 3 is used. This task measures the model's ability to retrieve simple keys from a large amount of irrelevant text for training. The data set is divided into a training set and a validation set, and the loss function of the passkey retrieval task is set. The task input here is a sequence number, and the model outputs the text corresponding to the sequence number. The loss function here is used to measure the similarity between the generated text and the real text. This embodiment uses the cosine similarity loss:
[0041] in, and They are the embedding vectors of the generated sentence and the input sentence respectively, and cosine calculates the cosine similarity between them. In each round of iteration, the gradient of the above loss function with respect to the model parameters is calculated, and the model parameters are updated through back propagation, in order to increase the authenticity of the generated text and the real text, and the LLM is fine-tuned using this long text data; during the fine-tuning process, the scaling factor of RoPE is updated as part of the model, and a suitable optimization algorithm (such as Adam or SGD) is used to train the model and optimize the scaling factor at the same time; the model performance is evaluated on the validation set, and the model parameters and scaling factor are adjusted according to the evaluation results. Finally, the updated scaling factor is obtained after the training is completed, and then the value of the optimal scaling factor is frozen, and it will no longer be updated in subsequent fine-tuning tasks, and the model can also adapt to tasks with longer context windows; the trained model is used for the next step of vertical field data fine-tuning; like Figure 4 As shown, the first and second largest models after the context length expansion are then trained; 1. Text compression task training process (fine-tuning all parameters of the first model): Fine-tune all parameters on the dataset using question answering for text compression tasks; Define a loss function, such as cross entropy loss, to optimize the model to generate compressed text; Divide the data set into a training set, a validation set, and a test set; train the model, use prompt combined with the original text as input, and generate compressed text; The quality of the compressed text is evaluated using indicators such as accuracy and recall rate. In this embodiment, a base vector model is used for evaluation. The bge-m3 vector model is used to convert the generated compressed text and the manually reviewed compressed text into text vectors, and the cosine similarity is calculated. If the text similarity is above 90%, it is considered to be generated correctly. The model parameters are adjusted according to the evaluation results to improve the effect of text compression. 2. Netizens’ opinion clustering and summary training task (LoRA fine-tuning + reinforcement learning DPO for the second largest model); This embodiment uses the DPO (Direct Preference Optimization) algorithm: a direct preference optimization method that directly optimizes the language model to achieve precise control of the output of the large model. Without reinforcement learning, it can also accurately judge and learn the user's preferences, and the effect is more prominent; the purpose is to make the netizen representative opinions generated by the model more in line with human preferences; Based on the text clustering dataset, a large model is used to generate a pair of answers for each prompt: an optimal answer (after manual review and rule processing) and a non-optimal answer (native external large model output); these answer pairs will be used to train the reward model to help distinguish the quality of the output; LoRA fine-tuning: The basic model is fine-tuned using LoRA (Low-Rank Adaptation) technology, which is a method for saving computing resources. Only the low-rank adaptation matrix in the model is updated instead of the entire model. In this embodiment, there are two tasks for training large models with large parameters. The first is text clustering, and the second is whether the representative opinions summarized by each group after clustering are representative. Therefore, there are also two loss functions set: (1) Text clustering loss function: The large model will output how many clusters there are after clustering. Each cluster contains all the serial numbers that are grouped in the same group. These serial numbers are extracted through regular expressions, and the original text corresponding to the serial numbers is found. In text clustering, positive samples are defined as other samples in the same cluster, while negative samples are samples in other clusters. The goal of contrast loss is to maximize the similarity of positive sample pairs and minimize the similarity of negative sample pairs. The following is the formula of the loss function:
[0042] Where N is the number of samples in the batch; M is the total number of samples to be compared for each sample (including positive and negative samples); i is the text representation of the i-th sample in the batch and its corresponding positive sample text representation; sim(u,v) is the similarity function between samples u and v, u is a positive sample, v is a negative sample, and commonly used similarity functions include dot product, cosine similarity, etc.; τ is a temperature parameter, which is used to control the smoothness of the softmax distribution; in each iteration, a batch of samples is randomly selected from the dataset or selected according to a strategy; according to the result of the loss function, the parameters of the model are updated using the back propagation algorithm; (2) Loss function for text group opinion summary: Through the prepared preference data set, including the optimal answer and non-optimal answer corresponding to each prompt; use the current model and the reference model to calculate the logarithmic probability of the optimal answer and the non-optimal answer; use the DPO loss function, combined with the logarithmic probability of the optimal answer and the non-optimal answer, and the dynamic weight to update the model parameters;
[0043] Where D is a data set containing preference information; Represent prompt, optimal answer and non-optimal answer respectively; is the strategy of the current model, used to generate the probability of optimal and non-optimal answers; is the strategy of the reference model, usually related to The same or similar, is a hyperparameter that controls the KL divergence constraint; is the sigmoid function, which is used to map the input to the (0, 1) interval, indicating the probability of preference; In each iteration, the gradient of the above loss function with respect to the model parameters is calculated and the model parameters are updated by back propagation, with the goal of increasing the relative logarithmic probability of the optimal answer and reducing the relative logarithmic probability of the non-optimal answer; The total loss function :
[0044] In each iteration, the gradient of the above loss function with respect to the model parameters is calculated, and the model parameters are updated through back propagation to complete the model training of the two tasks; Finally, the trained first and second models are used to analyze netizens’ opinions, such as Figure 5 As shown, the process is as follows: 1) Data numbering: All processed text data are numbered to ensure that each data item has a unique identifier; 2) Text compression with a small parameter and large model: Use a well-trained first-class language model with a small number of parameters to compress long texts. This small parameter and large model can quickly perform preliminary understanding and compression of the text, converting the long text into part-of-speech combinations after part-of-speech tagging, which helps the model better understand the structure and semantics of the text. When resources are sufficient, the small parameter and large model can deploy multiple instance interfaces at one time, segment the input text data, and increase the speed of parallel reasoning. 3) Large model multi-round text clustering: All the numbered data are input into the second largest model that has been expanded and trained, and the clustering ability of the large parameter large model is used to perform multiple rounds of clustering analysis on the text data; after the clustering is completed, the number of clustered groups, the data sequence number contained in each text group, and the representative viewpoint of each group are output; this will help users understand the internal structure and relationship of the text data; 4) Renumber the representative opinions of each group, and then input all the renumbered data into the trained second largest model for secondary clustering. The representative opinions in the same group are merged, and the text groups obtained from the first clustering corresponding to the representative opinions are also merged; 5) User interaction and feedback: Display the results to users and collect their feedback. Incorporate user feedback and newly collected data into the training of the first and second largest models to achieve continuous iteration and optimization of the models. Through the above process, not only can long text data be effectively processed and analyzed, but also in-depth insights and understanding can be provided. Moreover, clustering at specific angles can be performed through user customization. In addition to outputting the representative opinions of netizens, application scenarios such as emotions and representative keywords can also be output. The clustering effect can also be optimized in a targeted manner, and the analysis reasons can also be output, making the entire process of clustering analysis of netizens' opinions explainable and the effect controllable.
[0045] The same or similar reference numerals correspond to the same or similar components; The terms used in the drawings to describe positional relationships are only used for illustrative purposes and should not be construed as limiting this patent; Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A method for analyzing netizens’ opinions based on the dual-major model. It is characterized in that The following steps are involved: S1: Collect and preprocess the text dataset of netizens’ comments from the Internet; S2: Select the first largest model and the second largest model and perform context length extension respectively to obtain the first largest model and the second largest model after the context length extension respectively; S3: fine-tuning and training the first large model and the second large model after the context length expansion respectively using the preprocessed netizen comment text dataset to obtain the trained first large model and the second large model; S4: Obtain a text dataset of netizens’ comments to be analyzed and input the trained first model to perform text compression, thereby obtaining a text-compressed dataset of netizens’ comments; S5: inputting the compressed text data set of netizens' comments into the trained second largest model to perform text clustering, and obtaining representative opinions of several categories of netizens' comments; S6: Use the trained second largest model to perform secondary clustering and opinion summary on all representative opinions to obtain the final analysis results of netizens' opinions.
2. According to the method for analyzing netizens' opinions based on the dual-major model as described in claim 1, It is characterized in that The step S1 comprises: Collect a number of netizen comments from various social media channels on the Internet, clean the collected netizen comments, remove pure expression comments and useless text, and build a netizen comment text dataset; Using the netizen comment text dataset, a text compression question-answer pair dataset, a text clustering dataset, and a key retrieval dataset are constructed to complete preprocessing; The text compression question-answer pair dataset and the text clustering dataset are respectively used to fine-tune and train the first large model and the second large model after context length expansion, and the key retrieval dataset is used to expand the context length of the first large model and the second large model.
3. According to the method for analyzing netizens' opinions based on the dual-major model as described in claim 2, It is characterized in that In the text compression question-answer pair data set, each piece of data is a text compression question-answer pair including an input and an output, the input of the text compression question-answer pair is a text compression prompt and the original text of the netizen's comment, and the output is a text compression result; The text compression prompt is used to guide the large model to complete the text compression task; Constructing the text compression question-answer pair dataset includes the following steps: Call at least two external large models, set each called external large model to the same text compression prompt, and input the original text of netizens' comments respectively to generate text compression results corresponding to each external large model; For each original text of a netizen's comment, respectively calculate the text similarity between the text compression result of each external large model and the other text compression results; calculate the text similarity based on the edit distance or the cosine distance; If the similarity of the text compression results of two external large models is greater than the preset threshold, the original comment of the netizen, the text compression prompt, and the text compression result output by any of the two external large models will form a text compression question-answer pair; Otherwise, perform manual syntactic analysis on the original text of the netizen's comment and the text compression results of all external large models, compare the overlap between the sentence components of the original text of the netizen's comment and the text compression results of all external large models, and select the text compression result with the highest overlap, the original text of the netizen's comment, and the text compression prompt to form a text compression question-answer pair; All text-compressed question-answer pairs are saved as the text-compressed question-answer pair dataset.
4. According to the method for analyzing netizens' opinions based on the dual-major model as described in claim 2, It is characterized in that The input of the text clustering dataset is the text clustering prompt and the original text of the netizens' comments after numbering, and the output is the text clustering result; the text clustering result includes several groups and the representative views of each group and the original number of the netizens' comments; Constructing the text clustering dataset includes the following steps: Number each netizen's comment one by one, and obtain the original text of the numbered netizen's comment; Primary clustering: using any clustering algorithm among BERTopic, hierarchical clustering and AP clustering to cluster all the numbered original netizen comments, and dividing all the numbered original netizen comments into multiple text groups, each of which is a netizen comment with similar semantics; Sort the comments of netizens in each of the text groups by the number of likes or the amount of interaction, extract the comments of netizens ranked before a certain percentage, call the preset external big model, set the preset text clustering prompt to the prompt word of the external big model to perform text summary, and output the representative viewpoint corresponding to each text group; Secondary clustering: Based on the clustering algorithm and the external large model, the representative opinions corresponding to each text group obtained by the primary clustering are clustered again, similar text groups and their representative opinions are merged, the final grouping and the representative opinions of each group are obtained, and they are saved together with the original text number of the netizens' comments in each group as the text clustering result; The text clustering prompt, the numbered original comments of netizens and the text clustering results are saved together as a text clustering data set.
5. According to the method for analyzing netizens' opinions based on the dual-major model as described in claim 4, It is characterized in that In the secondary clustering process, the same clustering algorithm as the primary clustering is used, but a different external large model is used; Or use a different clustering algorithm than the primary clustering, but use the same external large model; Or use a different clustering algorithm than the primary clustering, but use a different external large model; In the secondary clustering and primary clustering processes, the prompt words of the external large model used are all text clustering prompts.
6. According to the method for analyzing netizens' opinions based on the dual-major model as described in claim 2, It is characterized in that The key search data set is based on the original text of the netizens' comments after being numbered, and the input is the key search prompt, which contains a number of numbers; the output is the original text of the netizens' comments corresponding to each of the numbers.
7. According to claim 2, a method for analyzing netizens' opinions based on a dual-major model, It is characterized in that In step S2, respectively extending the context length of the first large model and the second large model includes: For the first and second largest models selected, respectively, initialize the position encoding of their RoPEs, set an initial scaling factor for each RoPE dimension, and set the scaling factor of each RoPE dimension as a trainable parameter; The RoPE encoding calculation formula is: Among them, RoPE(n) represents the encoding of position n, d is the text embedding dimension, n is the position index of the token, and θ i is the rotation angle of the token in the i-th dimension at position n, satisfying After setting the scaling factor β as a trainable parameter, the modified RoPE encoding calculation formula is: Among them, RoPE′(n) is the code after adding the scaling factor to position n; β i is a trainable scaling factor of the i-th dimension; each of the scaling factors is a different value randomly initialized; A cosine similarity loss function is set, and context length expansion training is performed on the initialized first large model and the second large model using the key retrieval data set. During the context length expansion training process, the scaling factor of each RoPE dimension is iteratively updated until the scaling factor that minimizes the cosine similarity loss function is obtained and saved, thereby obtaining the first large model and the second large model after context length expansion.
8. According to the method for analyzing netizens' opinions based on the dual-major model as described in claim 2, It is characterized in that In step S3, the process of fine-tuning and training the first model after the context length expansion using the pre-processed netizen comment text dataset includes: Setting a text compression loss function for the first largest model after the context length expansion, using the text compression question-answer pair dataset to fine-tune and train all parameters of the first largest model after the context length expansion until the text compression loss function reaches a minimum value, thereby obtaining the trained first largest model; The text compression loss function includes any one of a cross entropy loss function and a cosine similarity loss function.
9. According to the method for analyzing netizens' opinions based on the dual-major model as described in claim 2, It is characterized in that In step S3, the process of fine-tuning and training the second largest model after the context length expansion using the pre-processed netizen comment text dataset includes: Constructing positive and negative sample pairs based on the text clustering data set, wherein the positive samples are other samples in the same group, and the negative samples are samples in other groups; For the text clustering task, a text clustering loss function is set, and the second largest model after the context length expansion is fine-tuned and trained using the LoRA algorithm and positive and negative sample pairs to obtain the second largest model after one training; The text clustering loss function is specifically: Among them, L cluster is the text clustering loss function value, N is the number of samples in a training batch; M is the total number of positive and negative samples to be compared for each sample; sim(u i ·v j ) is the i-th positive sample u i and the jth negative sample v j The similarity between i is the i-th negative sample, the similarity is the dot product or cosine similarity; τ is the temperature parameter; For the secondary clustering task representing opinions, a opinion summary loss function is set, and the second largest model after the first training is fine-tuned and trained using a reinforcement learning DPO algorithm and positive and negative sample pairs to obtain a final trained second largest model; The viewpoint summary loss function is specifically a DPO loss function.
10. A method for analyzing netizens' opinions based on a dual-major model according to any one of claims 1 to 9, It is characterized in that The first large model and the second large model in step S2 are any one of the large language models of LLaMA, Qwen, Baichuan, Deepseek and Mistral.
Citation Information
Patent Citations
Microblog-based big data analysis model system and implementation method thereof
CN111694952A
Pre-trained language model quantification method and device
CN111814448A
Local document summarization method based on large model
CN117112779A
Text sentiment classification method for multiple fields
CN117390131A
Model compression method and device, equipment and storage medium
CN117408302A
Cited By
Dynamic hotspot clue accurate extraction method based on multi-source text
CN119719342A
Refined user viewpoint extraction and analysis method based on large model
CN119961423A
