Controllable comment generation method and system based on multi-agent cooperation

Through a controllable comment generation method based on multi-agent collaboration, a large-scale language model is used to generate multiple subjective agents and select the most suitable agents to generate comments based on constraints, the problem of limited constraints in understanding complex news content and controlling tasks is solved, and high controllability and text quality of generated comments are achieved.

CN119862962AActive Publication Date: 2025-04-22KUNMING UNIV OF SCI & TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411953365.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-22
Estimated Expiration
2044-12-27

AI Technical Summary

Technical Problem

Large-scale language models have limited ability to understand complex news content and control task constraints, resulting in the generated comments that may not match the news content or fail to meet the control conditions set by the task, and the generated stories are insufficiently relevant and coherent.

Method used

A controllable comment generation method based on multi-agent collaboration is adopted, and a comment data set is downloaded for preprocessing. A large-scale language model is used to generate multiple subjective agents, and each agent generates comments of different emotions from different angles. Then, based on the keywords and emotional constraints set by the task, the most suitable agent is selected from the generated agent to generate comments, and the generated comments are selected through the settings review agent to ensure that they are smooth and meet the news content and control conditions.

Benefits of technology

Significantly improve the controllability and text quality of large-scale language models to generate comments, ensuring that the generated comments strictly follow the specified control conditions while maintaining high standards of text quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119862962A_ABST
    Figure CN119862962A_ABST
Patent Text Reader

Abstract

The invention relates to a controllable comment generation method and system based on multi-agent cooperation, and belongs to the technical field of natural language processing. The method comprises the following steps: downloading a comment data set, and preprocessing the data set; a large-scale language model is utilized to generate a plurality of subjective agents at the same time according to the news text, and each subjective agent generates comments of different emotions from different perspectives of the news content; selecting a subjective agent most conforming to the constraint condition from the generated agents, and enabling the subjective agent to simulate a real news reader to generate comments; and the review agent is set to select the generated multiple comments, and the smooth comments which most conform to the news content and the control conditions are selected. The method provided by the invention achieves an ideal result on the news data set of the Tencent fast report.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a controllable comment generation method and system based on multi-agent collaboration, belonging to the technical field of natural language processing. Background Art

[0002] Controllable comment generation refers to guiding the model to generate text through specific constraints to achieve precise control over the content, style, and sentiment of the generated text while maintaining high standards of text quality. Unlike traditional comment generation tasks, controllable comment generation not only requires the model to understand the news content and generate coherent and logically rigorous comments, but also requires that the comments strictly comply with the set constraints. Controllable comment generation has a wide range of application scenarios in many fields such as news dissemination and public opinion guidance.

[0003] In recent years, the use of large-scale language models and prompt learning has become a new paradigm for generative tasks. Contextual learning based on a few sample examples can effectively help large models adapt to different tasks. However, even if a certain number of contextual examples are provided to the model, the event-driven story generation task still faces the problem of insufficient relevance and coherence of the generated stories. Therefore, how to make the stories generated by the large model have a clear logical framework and improve the quality of the story texts generated by the large model is the core task of the present invention. Prompt learning and contextual learning based on large-scale language models provide new ideas for solving controllable comment generation tasks. Prompt learning guides the model to generate text that meets the requirements by designing appropriate instructions or templates. Contextual learning allows the model to learn task patterns by providing examples in the input. However, the ability of large-scale language models to understand complex news content and control task constraints is still limited, and the generated comments may not match the news content or cannot meet the control set by the task. Therefore, how to make the comments generated by the large model strictly follow the specified control conditions while maintaining high standards of text quality is the core task of the present invention. Summary of the invention

[0004] The present invention provides a controllable comment generation method and system based on multi-agent collaboration, which are used to improve the controllability and text quality of comments generated by large-scale language models.

[0005] The technical solution of the present invention is: a controllable comment generation method based on multi-agent collaboration, the method comprising:

[0006] Step 1, download the comment data set, pre-process the data set to form the experimental data set of the present invention;

[0007] Step 2: Use a large-scale language model to generate multiple subjective agents based on news texts. Each subjective agent generates comments with different emotions from different perspectives of the news content.

[0008] Step 3: In order to meet the keyword and sentiment constraints set by the task, the subjective agent that best meets the constraints is selected from the generated agents, and the subjective agent is asked to simulate real news readers to generate comments;

[0009] Step 4: To ensure the quality of generated comments and the stability of control, set the review agent to select the multiple comments generated and select the comments that are smooth and most consistent with the news content and control conditions.

[0010] Furthermore, the Step 1 includes:

[0011] Step 1.1, download the public review dataset from the Internet;

[0012] Step 1.2: Label each news comment in the dataset with sentiment labels and keywords.

[0013] Furthermore, the Step 2 includes:

[0014] Step 2.1, in order to ensure that the generated comments meet the control conditions defined by the task (such as the emotional constraints C of the present invention), sen and keyword constraint C key ), and keep the relevance of comments to news; according to the input news text T, the large-scale language model is prompted to dynamically generate a group of agents R s = {R1, R2, R3, …, R n}, where R i represents the i-th generated subjective agent. The format of each generated subjective agent is: <agent type, agent description>. Different subjective agents express different emotions and comments on different objects according to their own views.

[0015] Step 2.2: Prompt the large-scale language model to constrain C according to the input keywords key , the subjective agents are divided into subjective agents R that are positive about keywords pos = {R1, R2, R3, …, R n} and subjective agent R that is negative to the keyword neg = {R1, R2, R3, …, R n}.

[0016] Furthermore, the Step 3 includes:

[0017] Step 3.1. From the generated subjective agent R pos and R neg Filter out the emotional constraints C that are consistent with the task input sen A consistent subjective agent to ensure that the generated reviews have the same sentiment polarity as the task requires;

[0018] Step 3.2: To ensure that the generated comments meet the keyword constraint C key Constraints, using the multilingual pre-trained language model Sentence-BERT to map each subjective agent and keyword constraint C that meets the sentiment constraints key Encoded into a semantic vector; then, the cosine similarity between the keyword and each subjective agent that meets the sentiment constraint is calculated and used as the relevance score between the keyword and the subjective agent; the calculation formula of the relevance score is as follows:

[0019]

[0020] Where d represents the number of all subjective agents;

[0021] Step 3.3, from the calculated relevance score re Select the subjective agent R with the highest score best As the most relevant agent for generating reviews, its formula is as follows:

[0022] R best =argmaxscore re

[0024] Furthermore, the Step 4 includes:

[0025] Step 4.1. Since controllable generation tasks usually contain multiple objective dimensions, a review agent R is manually designed for each objective dimension. o , to ensure that the generated reviews meet these objective dimensions; each review agent format is: <agent type, agent description>, where each review agent is responsible for one or more specific objective dimensions, and the agent description details the key points that the agent focuses on when evaluating the review;

[0026] Step 4.2, the review agent scores the comments generated by each subjective agent according to the set agent description;

[0027] Step 4.3. Calculate the total score of each comment and select the comment with the highest score as the final answer.

[0028] The present invention also provides a controllable comment generation system based on multi-agent collaboration, and the system includes: a module for executing the above-mentioned controllable comment generation method based on multi-agent collaboration.

[0029] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned controllable comment generation method based on multi-agent collaboration when executing the program.

[0030] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the computer program implements the above-mentioned controllable comment generation method based on multi-agent collaboration.

[0031] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the above-mentioned controllable comment generation method based on multi-agent collaboration.

[0032] The beneficial effects of the present invention are:

[0033] The present invention proposes a controllable comment generation method based on multi-agent collaboration, which mainly includes three aspects: first, a group of emotional agents are generated according to the news text through prompt learning, and each subjective agent generates comments with different emotions from different angles of news content; second, in order to meet the keywords and emotional constraints set by the task, the present invention selects the agent that best meets the constraints from the generated agents, and allows the agent to simulate real news readers to generate comments; finally, in order to ensure the quality of generated comments and the stability of control. The present invention selects smooth comments that best meet the news content and control conditions from the multiple comments generated by artificially setting review agents;

[0034] The present invention improves the controllability and text quality of reviews generated by large-scale language models;

[0035] The controllable comment generation method based on multi-agent collaboration proposed in the present invention is superior to previous methods, which verifies the effectiveness of the method of the present invention for the controllable comment generation task. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 This is an overall framework diagram of a controllable comment generation method based on multi-agent collaboration of the present invention;

[0037] Figure 2 An example diagram of a prompt mechanism generated by a subjective agent of the present invention;

[0038] Figure 3 This is an example diagram of a review agent scoring mechanism of the present invention. DETAILED DESCRIPTION

[0039] Example 1: Figure 1-Figure 3 As shown, a controllable comment generation method based on multi-agent collaboration includes:

[0040] Step 1, download the Tencent Express comment data set, which contains 207117 news texts and 666566 news comments, and preprocess the data set to form the experimental data set of the present invention;

[0041] Furthermore, the Step 1 includes:

[0042] Step 1.1, download the public Tencent Express comment dataset from the Internet;

[0043] Step 1.2: Label each news comment in the dataset with sentiment labels and keywords.

[0044] Step 2: Use a large-scale language model to generate multiple subjective agents based on news texts. Each subjective agent generates comments with different emotions from different perspectives of the news content.

[0045] Furthermore, the Step 2 includes:

[0046] Step 2.1, in order to ensure that the generated comments meet the control conditions defined by the task (such as the emotional constraints C of the present invention), sen and keyword constraint C key ), and keep the relevance of comments to news; according to the input news text T, the large-scale language model is prompted to dynamically generate a group of agents R s = {R1, R2, R3, …, R n}, where R i represents the i-th generated subjective agent. The format of each generated subjective agent is: <agent type, agent description>. Different subjective agents express different emotions and comments on different objects according to their own views.

[0047] Step 2.2: Prompt the large-scale language model to constrain C according to the input keywords key , the subjective agents are divided into subjective agents R that are positive about keywords pos = {R1, R2, R3, …, R n} and subjective agent R that is negative to the keyword neg = {R1, R2, R3, …, R n}.

[0048] Step 3: In order to meet the keyword and sentiment constraints set by the task, the subjective agent that best meets the constraints is selected from the generated agents, and the subjective agent is asked to simulate real news readers to generate comments;

[0049] Furthermore, the Step 3 includes:

[0050] Step 3.1. From the generated subjective agent R pos and R neg Filter out the emotional constraints C that are consistent with the task input sen A consistent subjective agent to ensure that the generated reviews have the same sentiment polarity as the task requires;

[0051] Step 3.2: To ensure that the generated comments meet the keyword constraint C key Constraints, using the multilingual pre-trained language model Sentence-BERT to map each subjective agent and keyword constraint C that meets the sentiment constraints key Encoded into a semantic vector; then, the cosine similarity between the keyword and each subjective agent that meets the sentiment constraint is calculated and used as the relevance score between the keyword and the subjective agent; the calculation formula of the relevance score is as follows:

[0052]

[0053] Where d represents the number of all subjective agents;

[0054] Step 3.3, from the calculated relevance score re Select the subjective agent R with the highest score best As the most relevant agent for generating reviews, its formula is as follows:

[0055] R best =argmaxscore re

[0057] Step 4: To ensure the quality of generated comments and the stability of control, set the review agent to select the multiple comments generated and select the comments that are smooth and most consistent with the news content and control conditions.

[0058] Furthermore, the Step 4 includes:

[0059] Step 4.1. Since controllable generation tasks usually contain multiple objective dimensions, a review agent R is manually designed for each objective dimension. o , to ensure that the generated reviews meet these objective dimensions; each review agent format is: <agent type, agent description>, where each review agent is responsible for one or more specific objective dimensions, and the agent description details the key points that the agent focuses on when evaluating the review;

[0060] Step 4.2, the review agent scores the comments generated by each subjective agent according to the set agent description;

[0061] Step 4.3. Calculate the total score of each comment and select the comment with the highest score as the final answer.

[0062] The present invention also provides a controllable comment generation system based on multi-agent collaboration, the system comprising:

[0063] The preprocessing module is used to download the comment dataset and preprocess the dataset;

[0064] The comment module is used to use a large-scale language model to generate multiple subjective agents based on news texts. Each subjective agent generates comments with different emotions from different perspectives of the news content.

[0065] The simulated comment module selects the subjective agent that best meets the constraints from the generated agents, and lets the subjective agent simulate real news readers to generate comments;

[0066] The selection module is used to set the review agent to select multiple comments generated and select the comments that are fluent and most consistent with the news content and control conditions.

[0067] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned controllable comment generation method based on multi-agent collaboration when executing the program.

[0068] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the computer program implements the above-mentioned controllable comment generation method based on multi-agent collaboration.

[0069] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the above-mentioned controllable comment generation method based on multi-agent collaboration.

[0070] The generation tasks of the present invention are usually dynamic and complex, and news content at different levels needs to be considered from multiple angles. Therefore, the present invention allows a large-scale language model to dynamically generate multiple subjective agents based on the input news content, and each subjective agent generates comments with different emotions from news content from different angles; in order to meet the keywords and emotional constraints set by the task, the present invention selects the agent that best fits the constraints from the generated agents, and allows the agent to simulate real news readers to generate comments; ensuring the quality of generated comments and the stability of control. The present invention selects smooth comments that best meet the news content and control conditions from the multiple generated comments by manually setting review agents. For complex controllable generation tasks, the quality of text generation can be evaluated from multiple dimensions, including content coherence, consistency with news text, and controllability of specific constraints. Therefore, the present invention designs a review agent for each objective dimension to simulate real comment reviewers to ensure that the generated comments meet the task requirements.

[0071] In order to verify the effectiveness of the present invention, the present invention conducted the following experiments for verification. In order to compare with the existing methods, the present invention uses the public Tencent Express data set, and for each sample, it is labeled with emotion tags and keywords to ensure that the evaluation of the model in the experiment can accurately reflect the constraint control of emotions and keywords. Due to cost constraints, the present invention randomly selects 200 samples related to sports topics from the test set for testing the performance of the method. The selected existing comparison methods include: GPT-3.5, Gemma, and Llama2. GPT-3.5 is a large-scale language model developed by OpenAI, which is improved on the basis of GPT-3 and can understand and generate natural language or code. Gemma is a series of lightweight open source large-scale language models launched by Google. Llama2 is a large-scale language model series released by MetaAI, with parameter scales ranging from 7 billion to 70 billion. The present invention uses ROUGE-n (Rn), BERTScore (BES) and GPT score (Key, Sen) as indicators for evaluating the results of model generation. For Rn, the present invention uses 1-gram, 2-gram and l-gram. For BES, the bert-base-multilingual-cased model is used. For GPT score, Key represents keyword constraints and Sen represents sentiment constraints. The results of the compared methods and the method of the present invention on the sports-related Tencent Express dataset are shown in Table 1 below. The best performing part of each indicator is highlighted in bold:

[0072] Table 1 Experimental results

[0073]

[0074] As shown in Table 1, the proposed method outperforms the zero-shot and contextual learning prompt methods in all indicators. In particular, for the GPT-3.5 model, the proposed method improves by 3.09% and 4.79% respectively on the ROUGE-1 indicator compared with the contextual prompt and prompt learning methods; and improves by 5.5% and 6.17% respectively on the keyword constraint (Key) and sentiment constraint (Sen) indicators compared with prompt learning. In addition, the proposed method also performs well in the ROUGE-2, ROUGE-1 and BERTScore indicators, surpassing other comparison methods. These results show that the proposed method can better understand complex tasks, and can still generate more coherent and contextual comments in the face of multiple constraints, significantly improving the quality of generated text.

[0075] In order to demonstrate the effectiveness of the proposed method, an ablation experiment was conducted on the best performing GPT-3.5 model. The experimental results are shown in Table 2. "(-) Subjective agent" directly prompts the large language model to generate comments, and then lets the review agent select the best comment. "(-) Review agent" lets the subjective agent directly generate comments. "(-) Subjective agent and review agent" means that only the large language model is prompted to generate comments.

[0076] Table 2 Ablation experiment results

[0077]

[0078] As shown in Table 2, each module of the method of the present invention has produced positive effects. Taking the "method of the present invention" as a benchmark, when there is only a review agent, the Key index decreased by 9.5% and the Sen index decreased by 9.34%; when there is only a subjective agent, R-1 decreased by 3.86% and BES decreased by 4.14%; when comments are generated only by prompts, the performance of the model decreases most significantly. In general, the subjective agent plays a key role in the constraint control of the prompt model. By acting as a subjective agent, the model can generate comments that are more in line with the constraints from the reader's point of view. The review agent selects the most fluent and most consistent comments with the news text based on the description. These results show that the combination of subjective agents and review agents can effectively improve the controllability, accuracy and quality of generated comments.

[0079] In order to further verify the effectiveness of the method proposed in the present invention, since the comment styles of different news topics vary greatly, the present invention conducts experiments on the data of entertainment topics, where the data of entertainment topics comes from the Tencent Express dataset.

[0080] Table 3 Experimental results on other news topics

[0081]

[0082] As shown in Table 3, the multi-agent collaboration proposed in the present invention also performs well in the generation of entertainment news reviews, significantly outperforming the prompt learning and context learning methods, which further proves the wide applicability of this method under various news topics.

[0083] In order to better illustrate the effect of the method of the present invention on the controllable comment generation task, volunteers were recruited to manually evaluate the method and the three methods of the best performing GPT-3.5 model in Table 1. The present invention randomly selected 50 comments from the experimental results and invited 3 college students to evaluate the comments from three aspects: (1) Fluency: measure the quality of the sentence, whether it is fluent and whether it follows grammar. (2) Relevance: measure the degree of relevance between the comment and the news text. (3) Controllability: measure whether the comment meets the control conditions of the task, which is the sum and average of the accuracy of the sentiment constraint and the keyword constraint. The score range of each indicator of fluency and relevance is from 1 (worst) to 5 points (best). The indicator of controllability is the accuracy from 0% to 100%. The results of the manual evaluation are shown in Table 4. Overall, the method of the present invention surpasses other methods in fluency, relevance and controllability.

[0084] Table 4. Manual evaluation results

[0085] method Fluency Relevance Controllability Tips for learning 3.27 3.38 85.5% Contextual Learning 3.48 3.54 83% Method of the present invention 4.13 4.25 92%

[0086] The specific implementation modes of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above implementation modes, and various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.

Claims

1. A controllable comment generation method based on multi-agent collaboration, characterized by: The method comprises: Step 1. Download the comment dataset and preprocess the dataset; Step 2: Use a large-scale language model to generate multiple subjective agents based on news texts. Each subjective agent generates comments with different emotions from different perspectives of the news content. Step 3: Select the subjective agent that best meets the constraints from the generated agents, and let the subjective agent simulate real news readers to generate comments; Step 4: Set the review agent to select the multiple comments generated and select the comments that are fluent and most consistent with the news content and control conditions.

2. According to claim 1, a controllable comment generation method based on multi-agent collaboration is characterized in that: The Step 1 includes: Step 1.1, download the public review dataset from the Internet; Step 1.2: Label each news comment in the dataset with sentiment labels and keywords.

3. The controllable comment generation method based on multi-agent collaboration according to claim 1 is characterized by: The Step 2 includes: Step 2.1: Based on the input news text T, the large-scale language model is prompted to dynamically generate a group of agents R s = {R1, R2, R3, …, R n }, where R i represents the generated i-th subjective agent. The format of each generated subjective agent is: <agent type, agent description>. Different subjective agents express different emotions and comments on different objects according to their own views. Step 2.2: Prompt the large-scale language model to constrain C according to the input keywords key , the subjective agents are divided into subjective agents R that are positive about keywords pos = {R1, R2, R3, …, R n } and subjective agent R that is negative to the keyword neg = {R1, R2, R3, …, R n }.

4. The controllable comment generation method based on multi-agent collaboration according to claim 1 is characterized in that: The Step 3 includes: Step 3.

1. From the generated subjective agent R pos and R neg Filter out the emotional constraints C that are consistent with the task input sen consistent subjective agent; Step 3.2, use the multilingual pre-trained language model Sentence-BERT to map each subjective agent and keyword constraint C that meets the sentiment constraint key Encoded into a semantic vector; then, the cosine similarity between the keyword and each subjective agent that meets the sentiment constraint is calculated and used as the relevance score between the keyword and the subjective agent; the calculation formula of the relevance score is as follows: Where d represents the number of all subjective agents; Step 3.3, from the calculated relevance score re Select the subjective agent R with the highest score best As the most relevant agent for generating reviews, its formula is as follows: R best =argmaxscore re 。 5. The controllable comment generation method based on multi-agent collaboration according to claim 1 is characterized by: The Step 4 includes: Step 4.

1. Manually design the review agent R for each objective dimension o ,The format of each review agent is: <agent type, agent description>, where each review agent is responsible for one or more specific objective dimensions, and the agent description details the key points that the agent focuses on when evaluating the review; Step 4.2, the review agent scores the comments generated by each subjective agent according to the set agent description; Step 4.

3. Calculate the total score of each comment and select the comment with the highest score as the final answer.

6. A controllable comment generation system based on multi-agent collaboration, characterized in that: The system includes: a module for executing a controllable comment generation method based on multi-agent collaboration as described in any one of claims 1 to 5.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, it implements a controllable comment generation method based on multi-agent collaboration as described in any one of claims 1 to 5.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements a controllable comment generation method based on multi-agent collaboration as described in any one of claims 1 to 5.

9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it implements a controllable comment generation method based on multi-agent collaboration as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Emotion analysis and generation method for news comments

    CN114444481A

  • Chinese media comment text automatic generation method, system, device and client

    CN116431803A

  • Intelligent question and answer method and device, computer equipment and program product

    CN118820436A