A method for analyzing public opinion based on a double large model

By employing a dual-model approach to analyze netizens' opinions, utilizing text compression and clustering, the problems of poor model robustness and low cluster interpretability in existing technologies are solved. This approach achieves more efficient and accurate analysis of netizens' opinions, enabling the processing of long texts and providing in-depth insights.

CN119003769BActive Publication Date: 2026-11-27GUANGDONG HENGQIN SHUSHUSHUO STORY INFORMATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411021978.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2026-11-27
Estimated Expiration
2044-07-29

AI Technical Summary

Technical Problem

Existing methods for analyzing netizens' opinions rely on a foundational model, which has poor robustness, low interpretability of clustering, and is difficult to optimize. Furthermore, large language models are limited by a short context window when processing long texts, affecting analysis speed and accuracy.

Method used

A dual-model approach is adopted, using one large model for text compression and another large model for cluster analysis of netizens' opinions. This expands the input context length of the large model, and the two large models are used for clustering and opinion summarization, respectively.

Benefits of technology

It improves the speed and accuracy of analyzing netizens' opinions, enhances the interpretability and controllability of the analysis, can process more text at once, provides in-depth insights and clustering from specific angles, and outputs results representing opinions, sentiments and keywords.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119003769B_ABST
    Figure CN119003769B_ABST
Patent Text Reader

Abstract

The application provides a netizen opinion analysis method based on double large models, comprising: collecting netizen comment text data sets from the Internet and preprocessing; selecting a first large model and a second large model and respectively performing context length expansion; using the preprocessed netizen comment text data sets to respectively fine-tune and train the context length expanded first large model and the second large model; using the trained first and second large models to analyze the netizen comment text data sets to be analyzed; the first large model is used for long text compression, which helps the subsequent second large model to better understand the structure and semantics of the text in the netizen opinion clustering analysis, directly uses two large models for clustering and opinion summary, has strong explainability, and is easy to optimize; meanwhile, the input context length of the two large models is expanded, so that the large model can process more text at a time, thereby improving the speed and accuracy of the opinion summary.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network information processing technology, and more specifically, to a method for analyzing netizens' opinions based on a dual-model approach. Background Technology

[0002] With the development and popularization of the internet, more and more netizens are expressing their opinions and spreading their ideas through various online platforms and channels. Netizen opinion analysis aims to cluster, summarize, and analyze netizens' comments and opinions. By collecting comments and reposts on specific topics and extracting users' opinion information, and then categorizing this information, we can quickly understand netizens' attitudes and views on specific topics.

[0003] Traditional methods for 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, 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 the LLM has shown powerful capabilities in natural language processing tasks, this method suffers from low clustering interpretability, inability to cluster according to different dimensions (such as by population group, by user preferences, etc.), and most clustering algorithms rely on the underlying model, making subsequent optimization of the clustering effect difficult.

[0004] The context length of a large language model refers to the total number of characters (tokens) in the model's input and output. This number is limited; characters exceeding this length are discarded by the model. Due to the massive amount of online user opinions, there are certain requirements for the context length of large language models. Currently, open-source large language models generally have short context lengths; for example, Llama 2 only has 4K, while the Code-Llama series, requiring code input, extends to 16K. Closed-source models offer longer context lengths; for instance, OpenAI's latest model, GPT-4 Turbo, provides a 128K context length, and Anthropic's Claude 2.1 model provides a 200K context length. To extract more accurate user opinions from massive amounts of text, the context length of large models must be extended.

[0005] There are generally two ways to extend the context length of a large model: 1) One way is to set the large model as a long context in the initial stage, and then obtain a long context large model through pre-training, instruction fine-tuning, alignment training, etc. However, long text training requires a lot of GPU memory and computing resources; 2) Another way is to select a large model that has already been trained, modify 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, patent document "CN117875434A" discloses a method for extrapolating the length of large financial models to extend the input context. This scheme improves the model's ability to handle longer contexts by improving the model's positional encoding, and optimizes the model's ability to capture long-distance dependencies by introducing dynamic calculations of scaling factors and positional 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 become less efficient when processing short or medium-length texts. It is also unclear whether the scheme can maintain consistent performance across different types of long text data. Since the scheme does not involve fine-tuning with vertical domain data, if the model does not encounter enough long texts or related tasks during training, its ability to handle long texts in practical applications may be limited, and its effectiveness in scenarios such as analyzing netizens' opinions cannot be guaranteed.

[0006] In summary, traditional methods for clustering and analyzing netizens' opinions suffer from the following problems: First, they are highly dependent on the underlying model, exhibiting deficiencies in model robustness and requiring complex updates and maintenance. Second, when processing large-scale data, existing clustering algorithms (such as cosine similarity-based clustering and AP clustering) have poor performance and are difficult to optimize. Third, existing large language models (LLMs) are limited by short context windows when processing long texts, restricting their ability to understand long-distance dependencies and preventing the input of large amounts of data at once, thus affecting analysis speed and accuracy. Summary of the Invention

[0007] To overcome the shortcomings of existing technologies, such as poor model robustness, low analysis efficiency and accuracy, and difficulty in subsequent maintenance and optimization, this invention provides a method for analyzing netizens' opinions based on a dual-model approach. This method uses one large model for text compression and another large model for clustering analysis of netizens' opinions, replacing the traditional text clustering scheme. It directly utilizes two large models for clustering and opinion summarization, resulting in strong interpretability and ease of subsequent optimization. Simultaneously, it increases the input context length of the large model, enabling it to process more text at once, thereby improving the speed and accuracy of opinion summarization.

[0008] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows: A method for analyzing netizens' opinions based on a dual-model approach includes the following steps: S1: Collect and preprocess a dataset of online comments from netizens. S2: Select the first and second largest models and extend their context lengths respectively to obtain the first and second largest models after context length extension; S3: Fine-tune and train the first and second large models after the context length expansion using the preprocessed netizen comment text dataset to obtain the trained first and second large models; S4: Obtain the dataset of netizens' comments to be analyzed and input it into the trained first model for text compression to obtain the compressed dataset of netizens' comments; S5: Input the compressed online comment dataset into the trained second model to perform text clustering and obtain representative viewpoints for several online comment categories; S6: Use the trained second model to perform secondary clustering and opinion summarization on all representative viewpoints to obtain the final analysis results of netizens' opinions.

[0009] Preferably, step S1 includes: We collected several comments from netizens from various social media channels on the Internet, and cleaned the collected comments to remove pure emoji comments and useless text, thus constructing a dataset of netizens' comments text. Using the aforementioned online user comment text dataset, a text compression question-and-answer pair dataset, a text clustering dataset, and a key retrieval dataset were constructed, and preprocessing was completed; The text compression question answering dataset and the text clustering dataset are used to fine-tune and train the first and second largest models after context length expansion, respectively. The key retrieval dataset is used to expand the context length of the first and second largest models.

[0010] Preferably, in the text compression question-and-answer pair dataset, each data item is a text compression question-and-answer pair containing input and output. The input of the text compression question-and-answer pair is a text compression prompt and the original text of netizens' comments, and the output is the text compression result. The text compression prompt is used to guide large models in completing text compression tasks; Constructing the text-compressed question-and-answer pair dataset includes the following steps: Call at least two external large models, set each of the external large models to the same text compression prompt, and input the original text of netizens' comments to generate the text compression result corresponding to each external large model; For each original comment from a netizen, the text similarity between the text compression result of each external large model and other text compression results is calculated; the text similarity is calculated based on edit distance or cosine distance. If the similarity of the text compression results of two external large models is greater than a preset threshold, then the original text of the netizen's comment, the text compression prompt, and the text compression result of any one of the two external large models will be used to 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 sentence components of the original text of the netizen's comment and the text compression results of all external large models, 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; Save all the compressed text question-and-answer pairs as the compressed text question-and-answer pair dataset.

[0011] Preferably, the input to the text clustering dataset is a text clustering prompt and the original text of the numbered netizens' comments, and the output is the text clustering result; the text clustering result includes several groups and the representative viewpoint of each group and the original text number of the netizens' comments; Constructing the text clustering dataset includes the following steps: Each netizen's comment was assigned a unique number, and the original text of the numbered comment was retrieved. First clustering: Use any one of the clustering algorithms, BERTopic, hierarchical clustering and AP clustering, to cluster all the original texts of the numbered netizens' comments, and divide all the original texts of the numbered netizens' comments into multiple text groups, each of which consists of netizens' comments with similar semantics; The comments from netizens in each text group are sorted according to the number of likes or the amount of interaction. The comments from netizens ranked in the top percentage are extracted, and a preset external large model is called. The preset text clustering prompt is set as the prompt words of the external large model to summarize the text and output the representative viewpoint corresponding to each text group. Secondary clustering: Based on the clustering algorithm and external large model, secondary clustering is performed on the representative opinions corresponding to each text group obtained by the primary clustering. Similar text groups and their representative opinions are merged to obtain the final grouping and the representative opinion of each group. The results are saved together with the original text number of the netizens' comments for each group as the text clustering result. The text clustering prompt, the original text of the numbered netizens' comments, and the text clustering results are saved together as a text clustering dataset.

[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; Alternatively, a different clustering algorithm can be used than that used in the first clustering, but the same large external model can be employed. Alternatively, a different clustering algorithm can be used than that used in the first clustering, but with a different external large model; In both the secondary and primary clustering processes, the prompts used in the external large model are text clustering prompts.

[0013] Preferably, the key retrieval dataset is based on the original text of netizens' comments after numbering, the input is a key retrieval prompt, the key retrieval prompt contains several numbers; the output is the original text of netizens' comments corresponding to each number.

[0014] Preferably, in step S2, expanding the context length of the first and second large models respectively includes: For the selected first and second largest models, initialize their RoPE position encoding respectively, set an initial scaling factor for each RoPE dimension, and set the scaling factor for each RoPE dimension as a trainable parameter. The RoPE encoding calculation formula is as follows:

[0015] in, This represents the encoding of position n, where d is the text embedding dimension and n is the position index of the token. It is the rotation angle of the token at position n in the i-th dimension, satisfying ; scaling factor After being set as trainable parameters, the modified RoPE encoding calculation formula is as follows:

[0016] in, Encoding of position n after adding a scaling factor; Let be a trainable scaling factor for the i-th dimension; each of the scaling factors is a randomly initialized distinct value. Set a cosine similarity loss function, and use the key retrieval dataset to perform context length expansion training on the initialized first and second large models. 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, and the first and second large models after context length expansion are obtained.

[0017] Preferably, in step S3, the process of fine-tuning and training the first large model after context length expansion using the preprocessed netizen comment text dataset includes: Set a text compression loss function for the first large model after the context length is expanded, and use the text compression question answering dataset to fine-tune and train the first large model after the context length is expanded until the text compression loss function reaches its minimum value, and then obtain the trained first large model. The text compression loss function includes either the cross-entropy loss function or the cosine similarity loss function.

[0018] Preferably, in step S3, the process of fine-tuning and training the second large model after context length expansion using the preprocessed netizen comment text dataset includes: Based on the text clustering dataset, positive and negative sample pairs are constructed. In the positive and negative sample pairs, positive samples are other samples within the same group, and negative samples are samples from other groups. For the text clustering task, a text clustering loss function is set, and the LoRA algorithm and positive and negative sample pairs are used to fine-tune and train the second largest model after the context length expansion, so as to obtain the second largest model after one training. The text clustering loss function is specifically as follows:

[0019] in, Here, N is the value of the text clustering loss function, and M 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. For the i-th positive sample and the j-th negative sample The similarity between them, the For the i-th negative sample, the similarity is the dot product or cosine similarity; For temperature parameters; For the secondary clustering task representing viewpoints, a viewpoint summary loss function is set, and the second-largest model after the first training is fine-tuned and trained using the reinforcement learning DPO algorithm and positive and negative sample pairs to obtain the final trained second-largest model. The aforementioned viewpoint summarizes the loss function as the DPO loss function.

[0020] Preferably, the first and second large models in step S2 are any one of LLaMA, Qwen, Baichuan, Deepseek, and Mistral large language models.

[0021] Compared with the prior art, the beneficial effects of the technical solution of the present invention are: This invention provides a method for analyzing netizens' opinions based on a dual-model approach. First, a dataset of netizens' comments is collected from the internet and preprocessed. Next, a first and a second model are selected and their context lengths are expanded. Then, the preprocessed dataset of netizens' comments is used to fine-tune and train the expanded first and second models. Next, the dataset of netizens' comments to be analyzed is obtained and input into the trained first model for text compression, resulting in a compressed dataset. The compressed dataset is then input into the trained second model for text clustering, yielding representative opinions for several categories of netizens' comments. Finally, the trained second model is used to perform secondary clustering and opinion summarization on all representative opinions, resulting in the final analysis results of netizens' opinions. This invention utilizes a primary model for long text compression, which helps the secondary model better understand the text's structure and semantics during the clustering analysis of netizens' opinions. Directly using both models for clustering and opinion summarization offers strong interpretability and facilitates subsequent optimization. Simultaneously, this invention extends the input context length of both models, allowing them to process more text at once, thereby improving the speed and accuracy of opinion summarization. Furthermore, this invention not only effectively processes and analyzes long text data but also provides in-depth insights and understanding. Moreover, it allows for user-defined clustering from specific angles, enabling the output of representative netizens' opinions, as well as applications such as outputting sentiment, representative keywords, and providing analytical justifications. In short, the clustering effect of this invention can be optimized in a targeted manner, making the entire process of netizens' opinion clustering analysis more interpretable and controllable. Attached Figure Description

[0022] Figure 1 This is a flowchart of a method for analyzing netizens' opinions based on a dual-model approach, as 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 illustrating the training of the first and second large models after context length expansion, as provided in Example 2.

[0026] Figure 5 This is a flowchart of the process for analyzing netizens' opinions using the first and second trained models, as provided in Example 2. Detailed Implementation

[0027] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this patent. To better illustrate this embodiment, some parts in the accompanying drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions; It will be understood by those skilled in the art that certain well-known structures and their descriptions may be omitted in the accompanying drawings.

[0028] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0029] Example 1 like Figure 1 As shown, this embodiment provides a method for analyzing netizens' opinions based on a dual-model approach, including the following steps: S1: Collect and preprocess a dataset of online comments from netizens. S2: Select the first and second largest models and extend their context lengths respectively to obtain the first and second largest models after context length extension; S3: Fine-tune and train the first and second large models after the context length expansion using the preprocessed netizen comment text dataset to obtain the trained first and second large models; S4: Obtain the dataset of netizens' comments to be analyzed and input it into the trained first model for text compression to obtain the compressed dataset of netizens' comments; S5: Input the compressed online comment dataset into the trained second model to perform text clustering and obtain representative viewpoints for several online comment categories; S6: Use the trained second model to perform secondary clustering and opinion summarization on all representative viewpoints to obtain the final analysis results of netizens' opinions.

[0030] In the specific implementation process, this embodiment proposes a dual-model strategy. First, the context length of the two large models is expanded. Then, the text is compressed through the first large model. Then, the second large model is used to perform cluster analysis of netizens' opinions. The clustering is also divided into two stages. The first stage is to group and cluster the netizens' comments. The second stage is to perform secondary clustering on the representative opinions of each group, thereby completing the summary of opinions. Specifically, the process begins by collecting and preprocessing a dataset of online comments from the internet. Next, a first and second large-scale model are selected and their context lengths are expanded. Then, the preprocessed dataset of online comments is used to fine-tune and train the expanded models. The dataset of online comments to be analyzed is then obtained and input into the trained first large-scale model for text compression, resulting in a compressed dataset. This compressed dataset is then input into the trained second large-scale model for text clustering, yielding representative viewpoints for several categories of online comments. Finally, the trained second large-scale model is used to perform secondary clustering and viewpoint summarization on all representative viewpoints, resulting in the final analysis of online comment opinions. This method utilizes the first large model for long text compression, which helps the subsequent second large model better understand the structure and semantics of the text when performing cluster analysis of netizens' opinions. Directly using the two large models for clustering and opinion summarization provides strong interpretability and facilitates subsequent optimization. At the same time, this method extends the input context length of the two large models, allowing them to process more text at once, thereby improving the speed and accuracy of opinion summarization.

[0031] Example 2 This embodiment provides a method for analyzing netizens' opinions based on a dual-model approach, including the following steps: S1: Collect and preprocess a dataset of online comments from netizens. S2: Select the first and second largest models and extend their context lengths respectively to obtain the first and second largest models after context length extension; S3: Fine-tune and train the first and second large models after the context length expansion using the preprocessed netizen comment text dataset to obtain the trained first and second large models; S4: Obtain the dataset of netizens' comments to be analyzed and input it into the trained first model for text compression to obtain the compressed dataset of netizens' comments; S5: Input the compressed online comment dataset into the trained second model to perform text clustering and obtain representative viewpoints for several online comment categories; S6: Use the trained second model to perform secondary clustering and opinion summarization on all representative viewpoints to obtain the final analysis results of netizens' opinions; Step S1 includes: We collected several comments from netizens from various social media channels on the Internet, and cleaned the collected comments to remove pure emoji comments and useless text, thus constructing a dataset of netizens' comments text. Using the aforementioned online user comment text dataset, a text compression question-and-answer pair dataset, a text clustering dataset, and a key retrieval dataset were constructed, and preprocessing was completed; The text compression question answering dataset and the text clustering dataset are used to fine-tune and train the first and second largest models after context length expansion, respectively; the key retrieval dataset is used to expand the context length of the first and second largest models. In the text compression question-and-answer pair dataset, each data item is a text compression question-and-answer pair containing input and output. The input of the text compression question-and-answer pair is the text compression prompt and the original text of the netizens' comments, and the output is the text compression result. The text compression prompt is used to guide large models in completing text compression tasks; Constructing the text-compressed question-and-answer pair dataset includes the following steps: Call at least two external large models, set each of the external large models to the same text compression prompt, and input the original text of netizens' comments to generate the text compression result corresponding to each external large model; For each original comment from a netizen, the text similarity between the text compression result of each external large model and other text compression results is calculated; the text similarity is calculated based on edit distance or cosine distance. If the similarity of the text compression results of two external large models is greater than a preset threshold, then the original text of the netizen's comment, the text compression prompt, and the text compression result of any one of the two external large models will be used to 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 sentence components of the original text of the netizen's comment and the text compression results of all external large models, 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; Save all compressed text question-and-answer pairs as the compressed text question-and-answer pair dataset; The input to 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 viewpoint of each group and the original text number of the netizens' comments; Constructing the text clustering dataset includes the following steps: Each online comment is assigned a unique number, and the original text of the comment is retrieved after each number. First clustering: Use any one of the clustering algorithms BERTopic, hierarchical clustering and AP clustering to cluster all the original texts of the numbered netizens' comments, and divide all the original texts of the numbered netizens' comments into multiple text groups, each of which consists of netizens' comments with similar meanings; The comments from netizens in each text group are sorted according to the number of likes or the amount of interaction. The comments from netizens ranked in the top percentage are extracted, and a preset external large model is called. The preset text clustering prompt is set as the prompt words of the external large model to summarize the text and output the representative viewpoint corresponding to each text group. Secondary clustering: Based on the clustering algorithm and external large model, secondary clustering is performed on the representative opinions corresponding to each text group obtained by the primary clustering. Similar text groups and their representative opinions are merged to obtain the final grouping and the representative opinions of each group. The results are saved together with the original text number of the netizens' comments for each group as the text clustering result. The text clustering prompt, the original text of the numbered netizens' comments, and the text clustering results are saved together as a text clustering dataset; In the secondary clustering process, the same clustering algorithm as the primary clustering is used, but a different external large model is used; Alternatively, a different clustering algorithm can be used than that used in the first clustering, but the same large external model can be employed. Alternatively, a different clustering algorithm can be used than that used in the first clustering, but with a different external large model; In both the secondary and primary clustering processes, the prompts used by the external large model are text clustering prompts. The key retrieval dataset is based on the original text of netizens' comments after being numbered. The input is a key retrieval prompt, which contains several numbers. The output is the original text of netizens' comments corresponding to each number. In step S2, expanding the context length of the first and second large models respectively includes: For the selected first and second largest models, initialize their RoPE position encoding respectively, set an initial scaling factor for each RoPE dimension, and set the scaling factor for each RoPE dimension as a trainable parameter. The RoPE encoding calculation formula is as follows:

[0032] in, This represents the encoding of position n, where d is the text embedding dimension and n is the position index of the token. It is the rotation angle of the token at position n in the i-th dimension, satisfying ; scaling factor After being set as trainable parameters, the modified RoPE encoding calculation formula is as follows:

[0033] in, Encoding of position n after adding a scaling factor; Let be a trainable scaling factor for the i-th dimension; each of the scaling factors is a randomly initialized distinct value. Set a cosine similarity loss function, and use the key retrieval dataset to perform context length expansion training on the first and second large models after initialization. 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, and the first and second large models after context length expansion are obtained. In step S3, the process of fine-tuning and training the first large model after context length expansion using the preprocessed netizen comment text dataset includes: Set a text compression loss function for the first large model after the context length is expanded, and use the text compression question answering dataset to fine-tune and train the first large model after the context length is expanded until the text compression loss function reaches its minimum value, and then obtain the trained first large model. The text compression loss function includes either the cross-entropy loss function or the cosine similarity loss function; In step S3, the process of fine-tuning and training the second large model after context length expansion using the preprocessed internet user comment text dataset includes: Based on the text clustering dataset, positive and negative sample pairs are constructed. In the positive and negative sample pairs, positive samples are other samples within the same group, and negative samples are samples from other groups. For the text clustering task, a text clustering loss function is set, and the LoRA algorithm and positive and negative sample pairs are used to fine-tune and train the second largest model after the context length expansion, so as to obtain the second largest model after one training. The text clustering loss function is specifically as follows:

[0034] in, Here, N is the value of the text clustering loss function, and M 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. For the i-th positive sample and the j-th negative sample The similarity between them, the For the i-th negative sample, the similarity is the dot product or cosine similarity; For temperature parameters; For the secondary clustering task representing viewpoints, a viewpoint summary loss function is set, and the second-largest model after the first training is fine-tuned and trained using the reinforcement learning DPO algorithm and positive and negative sample pairs to obtain the final trained second-largest model. The aforementioned viewpoint summarizes the loss function as the DPO loss function. In step S2, the first and second major models are any one of the following: LLaMA, Qwen, Baichuan, Deepseek, and Mistral large language models.

[0035] In the specific implementation process, this embodiment proposes a dual-model strategy. First, the context length of the two large models is expanded. Then, the text is compressed through the first large model. Then, the second large model is used to perform cluster analysis of netizens' opinions. The clustering is also divided into two stages. The first stage is to group and cluster the netizens' comments. The second stage is to perform secondary clustering on the representative opinions of each group, thereby completing the summary of opinions. First, a large amount of long text data from social media needs to be collected. This publicly available social media data can come from different online platforms to ensure the diversity and representativeness of the data, covering different themes and styles. The collected data is then cleaned to remove useless text such as overly short text or pure emojis. The dataset required for the training task is constructed by dividing the collected data into sections with a text length of 500 characters. Texts longer than 500 characters are considered long texts, while those shorter than or equal to 500 characters are considered short texts. The ratio of long to short text data is 1:1. 1. Training Task 1: Construction of Text Compression Question Answer Pair Dataset; (1) Data format: Each data item is a question-answer pair: [Input: Text-compressed prompt + original text, Output: Text-compressed result]; (2) Prompt Design: Continuously debug and design a clear prompt to guide the model in completing the text summarization 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 according to the order of subject + predicate + object + complement + preposition + verb. The text should not exceed 50 words, and missing sentence components should be ignored. Input text: [text content]" (3) Summary of cross-generation of multiple models: By calling the paid or free interfaces of 2-3 large external models 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: Different large models will produce different text compression results for the same batch of data. For each data point, assuming that two large models are used for text compression, the content of the two compressed texts is calculated, and the edit distance or cosine distance or other methods to measure text similarity are calculated. The purpose is that when the similarity between the text compression results of the two large models is greater than 80%, the data and the output of either of the two large models will form a question-answer pair and be included in the training set. When the similarity between 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 will be syntactically analyzed to output sentence components. The sentence components of the large model results and the original sentence will be compared, and the result of the large model with the greater overlap will be selected to form a question-answer pair with the original sentence and be included in the training set. 2. Training Task 2: Construct a large-scale text clustering dataset using a secondary clustering method; (1) Construct a prompt. The specific prompt can be fine-tuned by yourself. The general meaning is: "Based on the input comment data, perform text clustering and give a representative viewpoint to each text group after clustering. The input netizens' comments are as follows: {comments_lst}"; comments_lst is all the netizens' viewpoint 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 viewpoint corresponding to each group; (2) Data format: Each data point is a question-answer pair: [Input: prompt + multiple comments from netizens with serial numbers, Output: clustered groups, the serial number of each group and the representative viewpoint]; (3) Construction method: The data is constructed using traditional methods of netizens' opinions. First, the text is clustered using methods such as BERT-topic, hierarchical clustering, and AP clustering. After clustering, the text is divided into multiple text groups. Each group of texts consists of netizens' comments with similar semantics. Finally, the top 10% of the texts in each group are extracted in reverse order based on indicators such as the number of likes or interactions. Combined with the prompt summarizing netizens' opinions, the same large model interface (closed-source large model interface or offline deployed large 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, even if the text content is related, it will still be clustered into different text groups after clustering. This results in some groups having similar representative viewpoints output by the large model. Therefore, different clustering methods can be used to perform secondary clustering on the representative viewpoints output by the large model. Then, the text groups of representative viewpoints in the same group are merged, such as (viewpoint group 1 = representative viewpoint 1 + representative viewpoint 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 text groups expressing the same content can be merged together. (5) The entire process involves two clustering operations, and different clustering methods require the use of vector models. The first clustering is for netizens' comments, and the second is for the representative opinions summarized by the large model. There are several ways to perform the two clustering operations: use the same clustering algorithm but different base vector models, or use different clustering algorithms but use the same or different base vector models. This allows the two clustering operations to cluster the text from different perspectives, thus improving the clustering effect. (6) Construct a dataset containing preference information. This dataset should contain the preferred responses and dispreferred responses corresponding to multiple prompts. This can be done by having the model generate multiple possible answers and then selecting which are the preferred and dispreferred answers based on certain criteria (such as human evaluation or automated metrics). In this embodiment, we use human review to check whether the statements representing the viewpoints are correct. We retain the answer before modification as the dispreferred answer and the answer after modification as the preferred answer for later reinforcement learning. (7) Finally, the training set question-answer pairs are generated. The input is prompt + all numbered texts. The output is multiple groups after clustering. Each group contains the corresponding comment number and the representative viewpoint of each group, as shown in Table 1. This is an example of the text clustering dataset in this embodiment. In this embodiment, several netizens' comments about a brand's new flagship series mobile phone are selected for netizens' opinion analysis. After secondary clustering of the text, the representative viewpoints of different groups are output. Table 1. Examples of Text Clustering Datasets

[0036] 3. Training Task 3: Passkey Retrieval Task. This task 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 numbered 1, 6, 78, and 9 from the input file"; the input in this embodiment is the same as that of training task 2, which is all numbered texts, and the output is several numbers and the text content of each number. The number of numbers is randomly selected from 1 to 10, allowing the model to find the text corresponding to the number in the input text and then output the text content, thus enhancing the model's memory and retrieval ability for the input text; the key retrieval dataset format is shown in Table 2: Table 2 Example of Key Retrieval Dataset

[0037] The key retrieval dataset format is equal to question-answer pairs, that is, the input on the left is one line at a time, plus the written prompt words, and the output is the result on the right. Subsequently, the first and second largest models are selected, and the context window is expanded. For pre-trained large language models, this embodiment proposes a new method to expand their context window so that they can handle longer text inputs for subsequent text clustering (as long as the window is large enough, tens of thousands of texts can be input into the large model for analysis at a time). The context window refers to the range of characters or tokens that a model can consider when processing text. In natural language processing, a larger context window usually helps the model better understand the text content, but it also brings computational challenges. Existing large language models (LLMs) are limited by a short context window when processing long texts, which limits the model's ability to understand long-distance dependencies. Traditional solutions, such as RoPE (Rotated Position Encoding), can expand the context window to some extent, but when extended to extremely long texts, they face problems such as the introduction of outliers by new position indices, difficulty in fine-tuning, scarcity of training data, and high computational costs. 1. Overall process: (1) Model building: Selecting a base model: Select a pre-trained large language model (LLaMA, qwen, baichuan, deepseek, Mistral) as the base model. In this embodiment, LLaMA is used as the base model. For the first major model, a high-quality general-purpose large language model is generally selected as the base model, and the number of parameters is generally selected to be less than 10B. In this embodiment, an LLaMA large model with 7B parameters is used as the first major model (small parameter large model). For the second major model, since secondary clustering is required and complex text data needs to be understood and generated, a larger model with more parameters is selected. In this embodiment, a large LLaMA model with 70B parameters is used as the second major model (large parameter large model). In this embodiment, the large-parameter and small-parameter base models used can be switched to other large models, and the specific number of parameters can be selected according to one's own hardware resources, without any restrictions. 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 any restrictions. Introduction to the LLama model structure: like Figure 2 As shown, starting with the input text, it will go through the following layers: 1) Input Embedding: Converts input text into a vector table, achieved through nn.Embedding; 2) Llama Decoder Layer: The decoder employs multiple Llama Decoder Layers; each layer includes self-attention (Llama Attention) and a feedforward network (Llama MLP); self-attention is used to capture long-range dependencies in the text; the feedforward network performs non-linear mapping; 3) Llama Attention: A multi-head self-attention mechanism used to model dependencies in text; it divides the input representation into multiple heads and then performs dot product attention operations within each head; attention (Self-Attention) is a mechanism that allows the model to consider information from other words in the text when processing each token, thereby capturing dependencies between tokens; 4) Llama MLP: Employs a multi-layer feedforward network with Gated Linear Units; performs non-linear transformations to capture complex patterns; typically, there is a feedforward network after the self-attention layer, which 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, serving as a preprocessing function; 6) lm_head: A linear layer that maps the output of the last layer of the Decoder to a dimension the size of the dictionary for subsequent language model Logits computation; Overall, Llama, through stacking multiple layers of self-attention and feedforward networks, enables the model to learn and represent the semantic information of the input text, namely the deep meaning and contextual information of the words in the text. `lm_head` is the final output layer of the model, responsible for converting the semantic representation within the model into a raw probability estimate for each word in the dictionary. The mapping from the semantic representation to the dictionary `Logits` converts the high-dimensional vector within the model into a vector the size of the dictionary, with each element corresponding to a word in the dictionary. `Logits` is the raw output of the model predicting each word, usually a continuous value, which needs to be converted into a probability distribution using a softmax function. Finally, each word in the dictionary has a probability number representing the likelihood that it is the next word. The entire model is trained end-to-end by minimizing the language model's 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 a language model is usually to maximize the probability of a given text sequence, i.e., to train the model to improve its accuracy in predicting the next word. In the Llama model, Llama Attention is the core layer, and its structure is as follows: Figure 3 As shown, the Attention calculation process for Llama is as follows:

[0038] The input undergoes a linear transformation to obtain the Query(Q), Key(K), and Value(V) matrices. RoPE positional encoding is applied to Q and K. RoPE includes rotated Sin and Cos encoding, which rotates the representation of each token according to its position. The dot product of the rotated Q and K is calculated to obtain the Attention Score, which is then processed by Softmax to obtain the Normalized Attention Weight. Finally, the Attention Weight is multiplied by V and summed in weights to obtain the Attention output. The output undergoes another linear transformation and is then fed into the next layer as input. In this way, through RoPE positional encoding and weighted averaging, Llama's Attention can efficiently and stably extract the contextual semantic information of text sequences. Through the above analysis of the Llama structure, we can see that there is a layer called RoPE (Rotation Position Encoding) in Llama Attention, which is mainly used to encode the position of the input, allowing the model to learn the positional relationship of each token in the input text, thereby better understanding the input; the length of the sequence that the RoPE layer can handle determines the context length of Llama. To extend the context length of Llama, the RoPE layer needs to be modified and extended. Traditional methods for expanding the input context window of large models use RoPE (Rotary Positional Embedding), a positional encoding method that encodes positional information as a series of cosine and sine function values. For each token, RoPE generates a fixed-dimensional vector containing rotation angles at different frequencies, based on its position index in the sequence. This encoding method allows the model to capture the relative positional relationships between tokens. Imagine a very long text that needs a computer to understand the positional information of each word; RoPE is like assigning each word a special encoding that varies according to its position. Each word has an encoding composed of cosine and sine values ​​that change based on its position in the text. However, this method has a problem: not all words need the same encoding strength. For example, the beginning and end of an article are more important. This embodiment improves upon this method by encoding in a more resource-efficient way. This embodiment uses the scaling factor as a trainable parameter and updates it during training. It also uses domain-specific long text data for fine-tuning. The following operational procedure can be followed, with corresponding modifications to the RoPE calculation formula: For the selected first and second largest language models (LLM), initialize the position embeddings of RoPE, determine an initial scaling factor for each dimension, and set the scaling factor of each RoPE dimension as a trainable parameter. The initial RoPE code calculation formula is:

[0039] in, This represents the encoding of position n, where d is the text embedding dimension and n is the position index of the token. It is the rotation angle of the token at position n in the i-th dimension, satisfying ; scaling factor After being set as trainable parameters, the modified RoPE encoding calculation formula is as follows:

[0040] in, Encoding of position n after adding a scaling factor; Let be a trainable scaling factor for the i-th dimension; each of the scaling factors is a randomly initialized distinct value. After initializing the parameters, long text data from a specific domain are collected. Here, the key retrieval task from Training Task 3 is used for training. This task measures the model's ability to retrieve simple keys from a large amount of irrelevant text. The dataset is divided into training and validation sets, and the loss function for the key retrieval task is set. The input to this task is a sequence number, and the model outputs the text corresponding to that sequence number. The loss function here is used to measure the similarity between the generated text and the real text. In this embodiment, cosine similarity loss is used.

[0041] in, and These are the embedding vectors of the generated and input sentences, respectively. Cosine similarity is calculated between them. In each iteration, the gradient of the loss function with respect to the model parameters is calculated, and the model parameters are updated via backpropagation to increase the realism of the generated and real texts. This long text data is used to fine-tune the LLM. During fine-tuning, the RoPE scaling factor is updated as part of the model. A suitable optimization algorithm (such as Adam or SGD) is used to train the model while simultaneously optimizing the scaling factor. The model performance is evaluated on the validation set, and the model parameters and scaling factor are adjusted based on the evaluation results. After training, the updated scaling factor is obtained, and the optimal scaling factor value is frozen and not updated in subsequent fine-tuning tasks. This allows the model to adapt to tasks with longer context windows. The trained model is then used for further fine-tuning with vertical domain data. like Figure 4 As shown, the first and second largest models with expanded context lengths are then trained. 1. Text compression task training process (full parameter fine-tuning of the first main model): Full parameter fine-tuning of the dataset using question-and-answer sessions from a text compression task; Define a loss function, such as cross-entropy loss, and optimize the model to generate compressed text; The dataset is divided into training, validation, and test sets; the model is trained by using prompts combined with the original text as input to generate compressed text; The quality of compressed text is evaluated using metrics such as accuracy and recall. 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. 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 text compression effect. 2. Training task for clustering and summarizing netizens' opinions (LoRA fine-tuning of the second model + reinforcement learning DPO); This embodiment uses the DPO (Direct Preference Optimization) algorithm: a direct preference optimization method that achieves precise control over the output of a large model by directly optimizing the language model. It can accurately judge and learn user preferences without reinforcement learning, and the effect is more outstanding. The purpose is to make the opinions of netizens generated by the model more in line with human preferences. Based on a text clustering dataset, a large model is used to generate a pair of answers for each prompt: an optimal answer (after human review and rule processing) and a non-optimal answer (the original output of the external large model); these answer pairs will be used to train a reward model to help distinguish the quality of the output; LoRA fine-tuning: LoRA (Low-Rank Adaptation) is used to fine-tune the base model. This is a computationally efficient method that updates only the low-rank adaptive matrix in the model, rather than the entire model. In this embodiment, there are two tasks for training a large model with large parameters: the first is text clustering, and the second is whether the representative viewpoints summarized in each cluster are representative. Therefore, two loss functions are set: (1) Text clustering loss function: The large model outputs the number of clusters after clustering. Each cluster contains all the indices assigned to the same group. These indices are extracted using regular expressions to find the original text corresponding to the indices. In text clustering, positive samples are defined as other samples within the same cluster, while negative samples are samples in other clusters. The goal of contrastive loss is to maximize the similarity of positive sample pairs while minimizing the similarity of negative sample pairs. The formula for the loss function is as follows:

[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, respectively; sim(u,v) is the similarity function between samples u and v, where u is a positive sample and v is a negative sample. Commonly used similarity functions include dot product and cosine similarity; τ is the temperature parameter, used to control the smoothness of the softmax distribution; in each iteration, samples are randomly selected from the dataset or selected according to a strategy; based on the results of the loss function, the parameters of the model are updated using the backpropagation algorithm; (2) Loss function for summarizing viewpoints in a text group: Using a prepared preference dataset, including optimal and non-optimal answers corresponding to each prompt; calculate the log probabilities for optimal and non-optimal answers using the current model and the reference model; and update the model parameters using the DPO loss function, combined with the log probabilities of optimal and non-optimal answers and dynamic weights.

[0043] Where D is the dataset containing preference information; These represent the prompt, the optimal answer, and the non-optimal answer, respectively. It is the strategy of the current model, used to generate the probabilities of optimal and non-optimal answers; It is a strategy of reference model, usually with Same or similar It is a hyperparameter that controls the KL divergence constraint; It is the sigmoid function, used to map the input to the interval (0, 1), representing the probability of preference; In each iteration, the gradient of the loss function with respect to the model parameters is calculated, and the model parameters are updated through backpropagation. The purpose is to increase the relative log probability of the optimal answer and reduce the relative log probability of the non-optimal answer. 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 backpropagation to complete the model training for both tasks. Finally, the trained first and second models were used to analyze netizens' opinions, such as... Figure 5 As shown, the process is as follows: 1) Data Numbering: Number all processed text data to ensure that each data item has a unique identifier; 2) Small-parameter large-model text compression: Use a well-trained first large language model with a small number of parameters to compress long texts; this small-parameter large model can quickly perform preliminary understanding and compression of text, converting long texts into part-of-speech tagging combinations, which helps the model better understand the structure and semantics of the text; with sufficient resources, the small-parameter large model can deploy multiple instance interfaces at once to segment the input text data and improve speed through parallel inference; 3) Large-scale multi-round text clustering: All numbered data are input into a second, expanded and trained large model. Utilizing the clustering capabilities of the large-parameter, large-scale model, multiple rounds of clustering analysis are performed on the text data. After 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 relationships of the text data. 4) Second-number the representative viewpoints of each group, and then input all the data after the second-numbering into the trained second large model for secondary clustering. The representative viewpoints that are assigned to the same group are merged, and the text groups obtained from the first clustering of the representative viewpoints are also merged. 5) User interaction and feedback: Display the results to users and collect user feedback. Incorporate user feedback and newly collected data into the training of the first and second 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. Furthermore, specific angles of clustering can be performed through user customization. In addition to outputting representative opinions of netizens, application scenarios such as sentiment 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 netizens' opinion clustering analysis interpretable and the effect controllable.

[0045] The same or similar labels correspond to the same or similar parts; The terms used to describe positional relationships in the accompanying drawings are for illustrative purposes only 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 implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A method for analyzing netizens' opinions based on a dual-model approach, characterized in that, Includes the following steps: S1: Collect and preprocess a dataset of online comments from netizens. Step S1 includes: We collected several comments from netizens from various social media channels on the Internet, and cleaned the collected comments to remove pure emoji comments and useless text, thus constructing a dataset of netizens' comments text. Using the aforementioned online user comment text dataset, a text compression question-and-answer pair dataset, a text clustering dataset, and a key retrieval dataset were constructed, and preprocessing was completed; The text compression question answering dataset and the text clustering dataset are used to fine-tune and train the first and second largest models after context length expansion, respectively; the key retrieval dataset is used to expand the context length of the first and second largest models. S2: Select the first and second largest models and extend their context lengths respectively to obtain the first and second largest models after context length extension; In step S2, expanding the context length of the first and second large models respectively includes: For the selected first and second largest models, initialize their RoPE position encoding respectively, set an initial scaling factor for each RoPE dimension, and set the scaling factor for each RoPE dimension as a trainable parameter. The RoPE encoding calculation formula is as follows: in, This represents the encoding of position n, where d is the text embedding dimension and n is the position index of the token. It is the rotation angle of the token at position n in the i-th dimension, satisfying ; scaling factor After being set as trainable parameters, the modified RoPE encoding calculation formula is as follows: in, Encoding of position n after adding a scaling factor; Let be a trainable scaling factor for the i-th dimension; each of the scaling factors is a randomly initialized distinct value. Set a cosine similarity loss function, and use the key retrieval dataset to perform context length expansion training on the first and second large models after initialization. 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, and the first and second large models after context length expansion are obtained. S3: Fine-tune and train the first and second large models after the context length expansion using the preprocessed netizen comment text dataset to obtain the trained first and second large models; S4: Obtain the dataset of netizens' comments to be analyzed and input it into the trained first model for text compression to obtain the compressed dataset of netizens' comments; S5: Input the compressed online comment dataset into the trained second model to perform text clustering and obtain representative viewpoints for several online comment categories; S6: Use the trained second model to perform secondary clustering and opinion summarization on all representative viewpoints to obtain the final analysis results of netizens' opinions.

2. The method for analyzing netizens' opinions based on a dual-model according to claim 1, characterized in that, In the text compression question-and-answer pair dataset, each data item is a text compression question-and-answer pair containing input and output. The input of the text compression question-and-answer pair is the text compression prompt and the original text of the netizens' comments, and the output is the text compression result. The text compression prompt is used to guide large models in completing text compression tasks; Constructing the text-compressed question-and-answer pair dataset includes the following steps: Call at least two external large models, set each of the external large models to the same text compression prompt, and input the original text of netizens' comments to generate the text compression result corresponding to each external large model; For each original comment from a netizen, the text similarity between the text compression result of each external large model and other text compression results is calculated; the text similarity is calculated based on edit distance or cosine distance. If the similarity of the text compression results of two external large models is greater than a preset threshold, then the original text of the netizen's comment, the text compression prompt, and the text compression result of any one of the two external large models will be used to 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 sentence components of the original text of the netizen's comment and the text compression results of all external large models, 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; Save all the compressed text question-and-answer pairs as the compressed text question-and-answer pair dataset.

3. The method for analyzing netizens' opinions based on a dual-model according to claim 1, characterized in that, The input to 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 viewpoint of each group and the original text number of the netizens' comments; Constructing the text clustering dataset includes the following steps: Each online comment is assigned a unique number, and the original text of the comment is retrieved after each number. First clustering: Use any one of the clustering algorithms BERTopic, hierarchical clustering and AP clustering to cluster all the original texts of the numbered netizens' comments, and divide all the original texts of the numbered netizens' comments into multiple text groups, each of which consists of netizens' comments with similar meanings; The comments from netizens in each text group are sorted according to the number of likes or the amount of interaction. The comments from netizens ranked in the top percentage are extracted, and a preset external large model is called. The preset text clustering prompt is set as the prompt words of the external large model to summarize the text and output the representative viewpoint corresponding to each text group. Secondary clustering: Based on the clustering algorithm and external large model, secondary clustering is performed on the representative opinions corresponding to each text group obtained by the primary clustering. Similar text groups and their representative opinions are merged to obtain the final grouping and the representative opinions of each group. The results are saved together with the original text number of the netizens' comments for each group as the text clustering result. The text clustering prompt, the original text of the numbered netizens' comments, and the text clustering results are saved together as a text clustering dataset.

4. The method for analyzing netizens' opinions based on a dual-model according to claim 3, 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; Alternatively, a different clustering algorithm can be used than that used in the first clustering, but the same large external model can be employed. Alternatively, a different clustering algorithm can be used than that used in the first clustering, but with a different external large model; In both the secondary and primary clustering processes, the prompts used by the external large model are text clustering prompts.

5. The method for analyzing netizens' opinions based on a dual-model according to claim 1, characterized in that, The key retrieval dataset is based on the original text of netizens' comments after being numbered. The input is the key retrieval prompt, which contains several numbers. The output is the original text of netizens' comments corresponding to each number.

6. The method for analyzing netizens' opinions based on a dual-model according to claim 1, characterized in that, In step S3, the process of fine-tuning and training the first large model after context length expansion using the preprocessed internet user comment text dataset includes: Set a text compression loss function for the first large model after the context length is expanded, and use the text compression question answering dataset to fine-tune and train the first large model after the context length is expanded until the text compression loss function reaches its minimum value, and then obtain the trained first large model. The text compression loss function includes either the cross-entropy loss function or the cosine similarity loss function.

7. The method for analyzing netizens' opinions based on a dual-model according to claim 1, characterized in that, In step S3, the process of fine-tuning and training the second large model after context length expansion using the preprocessed internet user comment text dataset includes: Based on the text clustering dataset, positive and negative sample pairs are constructed. In the positive and negative sample pairs, positive samples are other samples within the same group, and negative samples are samples from other groups. For the text clustering task, a text clustering loss function is set, and the LoRA algorithm and positive and negative sample pairs are used to fine-tune and train the second largest model after the context length expansion, so as to obtain the second largest model after one training. The text clustering loss function is specifically as follows: in, Here, N is the value of the text clustering loss function, and M 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. For the i-th positive sample and the j-th negative sample The similarity between them, the For the i-th negative sample, the similarity is the dot product or cosine similarity; For temperature parameters; For the secondary clustering task representing viewpoints, a viewpoint summary loss function is set, and the second-largest model after the first training is fine-tuned and trained using the reinforcement learning DPO algorithm and positive and negative sample pairs to obtain the final trained second-largest model. The aforementioned viewpoint summarizes the loss function as the DPO loss function.

8. A method for analyzing netizens' opinions based on a dual-model according to any one of claims 1 to 7, characterized in that, In step S2, the first and second major models are any one of the following: LLaMA, Qwen, Baichuan, Deepseek, and Mistral large language models.

Citation Information

Patent Citations

  • Financial large model length extrapolation method for expanding input context length

    CN117875434A

  • Microblog-based big data analysis model system and implementation method thereof

    CN111694952A

  • Clustering optimization method based on large model

    CN117688414A