Topic content generation and model training method and device, equipment and storage medium

By fine-tuning the large language model after clustering and cleaning the original topic content, it solves the problem of difficult creation and low efficiency of topic content generation on social media platforms, improves the quality and relevance of the generated model, and achieves more efficient users. Participation value.

CN118733763APending Publication Date: 2024-10-01MICRO DREAM TECHTRONIC NETWORK TECH CHINACO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410643746.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In the existing technology, users on social media platforms face difficulties in creation and low production efficiency when generating topic content, and the topic content generated by general large language models has poor correlation with topic tags and is of unstable quality.

Method used

By obtaining the original topic content, clustering user content text and logos based on topic tags, determining the effectiveness feature values, and using pre-trained large language models to fine-tune instructions after cleaning to generate a topic content generation model.

Benefits of technology

It improves the training quality and effectiveness of the topic content generation model, makes the generated content have the value of extensive participation and the characteristics of extensive user participation, and improves the quality and efficiency of content generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733763A_ABST
    Figure CN118733763A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a topic content generation method and device, a topic content model training method and device, equipment and a storage medium. The method and device are used for improving the training quality of a topic content generation model. The scheme comprises the following steps: acquiring original topic content, wherein the original topic content comprises a topic label, a user content text and a user identifier; performing clustering on the user content text and the user identifier based on the topic tag to obtain at least one topic text cluster; determining a validity characteristic value of the target topic tag based on a target topic text cluster obtained by clustering the target topic tag, wherein the validity characteristic value represents a ratio of a user content text quantity to a user identifier quantity of the target topic text cluster; cleaning the original topic content based on the validity feature value to obtain cleaned topic content; and constructing instruction input by using a topic label in the cleaned topic content, constructing instruction output by using a user content text in the cleaned topic content, and executing instruction fine tuning on a pre-trained large language model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing, and in particular to a method, device, equipment and storage medium for generating topic content and training a model. Background Art

[0002] With the rapid development of social media, social platforms have become the main place for users to share opinions and exchange information. Due to information overload and wide topic diversity, users often face difficulties in producing content. On the one hand, it is often difficult for users to produce in-depth topic content for specific topics that they are concerned about. On the other hand, users are often less efficient in producing topic content. If a general large language model is used directly to generate topic content, there are usually defects such as poor correlation between topic content and topic tags and unstable quality of topic content.

[0003] How to improve the training quality of the topic content generation model is the technical problem to be solved by this application. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a method, device, equipment and storage medium for topic content generation and model training, so as to improve the training quality of the topic content generation model.

[0005] In a first aspect, a training method for a topic content generation model is provided, comprising:

[0006] Acquire original topic content, where the original topic content includes at least one topic tag, user content text associated with the topic tag, and a user identifier corresponding to the user content text;

[0007] Perform clustering on the original topic content based on the topic tag to obtain at least one topic text cluster;

[0008] Determine a validity feature value of the target topic tag based on the target topic text cluster to which the target topic tag belongs, wherein the validity feature value includes a ratio of the number of user content texts in the target topic text cluster to the number of user identifiers in the target topic text cluster;

[0009] Cleaning the original topic content based on the validity feature value to obtain cleaned topic content;

[0010] Use the cleaned topic content to fine-tune the pre-trained large language model to obtain a topic content generation model.

[0011] In a second aspect, a topic content generation method is provided, comprising:

[0012] Get the topic tag of the topic content to be generated;

[0013] Constructing a topic instruction based on the topic tag;

[0014] The topic instruction is input into a topic content generation model to obtain a topic content text output by the topic content generation model, wherein the topic content generation model is trained by the topic content generation model training method according to any one of claims 1 to 6.

[0015] In a third aspect, a training device for a topic content generation model is provided, comprising:

[0016] An acquisition module is configured to acquire original topic content, wherein the original topic content includes at least one topic tag, a user content text associated with the topic tag, and a user identifier corresponding to the user content text;

[0017] A clustering module, clustering the original topic content based on the topic tag to obtain at least one topic text cluster;

[0018] A determination module, which determines a validity feature value of the target topic tag based on the target topic text cluster to which the target topic tag belongs, wherein the validity feature value includes a ratio of the number of user content texts in the target topic text cluster to the number of user identifiers in the target topic text cluster;

[0019] A cleaning module, which cleans the original topic content based on the validity feature value to obtain cleaned topic content;

[0020] The training module uses the cleaned topic content to fine-tune the pre-trained large language model to obtain a topic content generation model.

[0021] In a fourth aspect, a topic content generating device is provided, comprising:

[0022] An acquisition module is used to obtain topic tags of the topic content to be generated;

[0023] A construction module, constructing a topic instruction based on the topic tag;

[0024] A generation module inputs the topic instruction into a topic content generation model to obtain a topic content text output by the topic content generation model, wherein the topic content generation model is trained by the training method for the topic content generation model described in any one of claims 1 to 6.

[0025] In a fifth aspect, an electronic device is provided, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and when the computer program is executed by the processor, the steps of the method of the first aspect or the second aspect are implemented.

[0026] In a sixth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method of the first aspect or the second aspect are implemented.

[0027] In a seventh aspect, a computer program product is provided, which includes a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is operable to cause a computer to execute part or all of the steps of the method of the first aspect or the second aspect.

[0028] In an embodiment of the present application, first, the original topic content is obtained, and the original topic content includes at least one topic tag, user content text associated with the topic tag, and a user identifier corresponding to the user content text; then, based on the topic tags in the original topic content, the user content text and the user identifier in the original topic content are clustered to obtain at least one topic text cluster; then, based on the target topic text cluster obtained by clustering the target topic tag, the validity feature value of the target topic tag is determined, and the validity feature value represents the ratio of the number of user content texts in the target topic text cluster to the number of user identifiers in the target topic text cluster, wherein the target topic tag is any topic tag in the original topic content; then, based on the validity feature values ​​corresponding to each topic tag in the original topic content, the original topic content is cleaned to obtain the cleaned topic content; finally, the topic tags in the cleaned topic content are used to construct the instruction input, and the user content text in the cleaned topic content is used to construct the instruction output, and the pre-trained large language model is fine-tuned to perform instruction fine-tuning to obtain a topic content generation model, wherein the topic tags used to construct the instruction input and the user content text used to construct the instruction output have an associated relationship. Among them, by clustering the topic tags to determine the objective validity feature value, and performing cleaning based on the topic validity feature value, the cleaned topic content can be not limited to the exclusive tags of a small number of users, but has the value of wide participation. Furthermore, using the cleaned topic content to perform instruction fine-tuning on the pre-trained large language model can make the fine-tuned topic content generation model suitable for topic content generation application scenarios, improve the training quality and effectiveness of the topic content generation model, and make the output results of the topic content generation model have effectiveness and value of wide user participation. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0030] Figure 1a This is one of the flowcharts of a method for training a topic content generation model in one embodiment of the present application;

[0031] Figure 1b This is a schematic diagram of the structure of a large language model with a decoder-only structure in one embodiment of the present application;

[0032] Figure 2 This is a second flow chart of a method for training a topic content generation model according to an embodiment of the present application;

[0033] Figure 3 This is a flowchart of a training method for a topic content generation model according to an embodiment of the present application;

[0034] Figure 4a This is a fourth flow chart of a method for training a topic content generation model according to an embodiment of the present application;

[0035] Figure 4b It is a schematic diagram of the structure of Baichuan 2, an embodiment of the present application;

[0036] Figure 5 This is a flowchart of a method for training a topic content generation model according to an embodiment of the present application;

[0037] Figure 6 This is a sixth flow chart of a method for training a topic content generation model according to an embodiment of the present application;

[0038] Figure 7 It is a flowchart of a topic content generation method according to an embodiment of the present application;

[0039] Figure 8 It is a structural schematic diagram of a training device for a topic content generation model according to an embodiment of the present application;

[0040] Fig. 9 It is a structural diagram of a topic content generating device according to an embodiment of the present application. DETAILED DESCRIPTION

[0041] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application. The numbering of the drawings in this application is only used to distinguish the various steps in the scheme, and is not used to limit the execution order of the various steps. The specific execution order is subject to the description in the specification.

[0042] In order to solve the problems existing in the prior art, the present application embodiment provides a training method for a topic content generation model, such as Figure 1aAs shown, including:

[0043] S11: Acquire original topic content, where the original topic content includes at least one topic tag, user content text associated with the topic tag, and a user identifier corresponding to the user content text.

[0044] In this step, the original topic content that has been published on the social platform can be obtained. The above topic tags can be in the form of keywords, phrases composed of multiple keywords, etc. The user content text refers to the content text produced by the user based on the topic tags, and the user identifier can include user ID, user nickname and other information that can represent the user identity.

[0045] Among them, the topic tag, user content text and user identification can be included in the original topic content in text form based on a specific format.

[0046] For example, the original topic content is such as "User A: #Energy saving and environmental protection# In life, try to reduce the energy consumed, especially the emission of carbon dioxide. You can choose an energy-saving air conditioner and turn it up one degree. The TV screen should not be too bright, which is also good for eyesight."

[0047] The topic tag is "#Energy-saving and Environmental Protection#", the user ID is "User A", and the user content text is "In life, try to reduce the energy consumption, especially the emission of carbon dioxide. You can choose energy-saving air conditioners and turn up the temperature by one degree. The TV screen should not be too bright, which is also good for eyesight."

[0048] Optionally, the original topic content may have other formats other than strings, such as being expressed in a table. The original topic content may come from the same social platform, and the topic content generation model trained thereby can be applied to the social platform to produce topic content. The topic content may also come from multiple different social platforms, and the topic content trained thereby can be widely applied to the topic content generation of multiple social platforms.

[0049] In actual applications, the massive amount of content on social platforms can be screened. For example, original topic content within a certain historical period can be selected according to actual training needs, and high-quality original topic content can be selected according to information such as the number of users participating in the discussion and user levels. Among them, the content on the social platform can be processed according to sensitive information processing rules to achieve content desensitization.

[0050] Optionally, the original topic content is formatted according to preset rules, for example, the original topic content is processed in the form of "user ID; topic tag; user content text" to improve the efficiency of subsequent information processing.

[0051] S12: Clustering the user content text and the user identification in the original topic content based on the topic tags in the original topic content to obtain at least one topic text cluster.

[0052] In this step, at least one topic text cluster is obtained by clustering, and any topic text cluster corresponds to at least one topic tag and multiple user content texts. Among them, any user content text can correspond to a user identifier, which is used to indicate which user produced and published the user content text.

[0053] Optionally, in this step, user content texts containing the same topic tag and user identifiers corresponding to these user content texts are clustered into the same topic text cluster.

[0054] Optionally, topic tags with high similarity are merged. For example, the similarity between topic tags is compared by semantic analysis, keyword comparison, etc., and multiple topic tags with similarity higher than a preset similarity are determined as topic tags in the same cluster, and then user content texts containing any topic tag in the same cluster and user identifiers corresponding to these user content texts are clustered into the same topic text cluster. Furthermore, multiple topic tags in the same cluster belonging to the same topic text cluster can be unified into one topic tag.

[0055] Optionally, on the basis of clustering based on topic tags, the clustering effectiveness can be further improved based on the relationship between users, the semantics of user content texts, etc. For example, if the content posted by a user is forwarded and commented on by platform friends, a new topic content can be constructed based on the content posted by the original user and the content commented on by platform friends, and the user content text and the corresponding user identifier in the newly constructed topic content can be clustered into the topic text cluster to which the original user content text belongs.

[0056] S13: Determine the validity feature value of the target topic tag based on the target topic text cluster obtained by clustering the target topic tag, wherein the validity feature value represents the ratio of the number of user content texts in the target topic text cluster to the number of user identifiers in the target topic text cluster, wherein the target topic tag is any topic tag in the original topic content.

[0057] In this step, the validity feature value is determined for the topic tag. For any target topic tag in the original topic content, the number of user content texts and the number of user identifiers are determined according to the target topic text clusters obtained by clustering the target topic tag. The number of user content texts can indicate how many user content texts associated with the target topic tag have been published by platform users, and the number of user identifiers can indicate how many different platform users have published user content texts for the target topic tag.

[0058] In actual applications, when a user repeatedly uses the same topic to publish content text, the topic may only be a personal label of the user and does not have the value of widespread participation. Therefore, this step calculates the number of user content texts and the number of user IDs through clustering, and determines the ratio of the number of user content texts to the number of user IDs as the effectiveness feature value. The effectiveness feature value thus determined can indicate the scale of users participating in the discussion in the target topic text cluster, and further indicates whether this target topic label has widespread user participation.

[0059] In this example, the larger the effectiveness feature value, the more diverse the user content texts published by platform users on the target topic tag. That is, among the users participating in the discussion of the target topic tag, a large number of users have published multiple user content texts on the target topic tag, which indicates that the target topic tag is widely discussed by platform users and has a high user participation value.

[0060] On the contrary, the smaller the effectiveness eigenvalue is, the smaller the number of users who post multiple user content texts among the users who participate in the discussion of the target topic tag is, which means that the target topic tag is not widely discussed by platform users and the user participation value is low.

[0061] The effectiveness feature value can objectively express the participation value of the target topic tag relative to the platform users in the form of a numerical value, thereby reflecting the value of the topic content associated with the target topic tag.

[0062] S14: Cleaning the original topic content based on the validity feature values ​​corresponding to the topic tags in the original topic content to obtain cleaned topic content.

[0063] In this step, the original topic content is cleaned based on the effectiveness feature value determined in the above step, and the topic content of topic tags with user participation value can be retained, and the topic content of topic tags with low user participation value can be deleted.

[0064] For example, the topic contents corresponding to a certain number of topic tags with larger effectiveness characteristic values ​​may be sorted according to the effectiveness characteristic values, or the topic contents corresponding to the topic tags with effectiveness characteristic values ​​greater than a preset effectiveness characteristic value may be retained.

[0065] This step cleans the original topic content based on the effectiveness feature value, which can improve the quality of the cleaned topic content based on the user participation value, and is conducive to improving the model training quality in the subsequent training steps.

[0066] S15: Use the topic tags in the cleaned topic content to construct the instruction input, and use the user content text in the cleaned topic content to construct the instruction output. Perform instruction fine-tuning on the pre-trained large language model to obtain a topic content generation model, where the topic tags used to construct the instruction input are related to the user content text used to construct the instruction output.

[0067] In this step, the instruction input and the instruction output can be constructed in pairs. Use the topic tags in the cleaned topic content to construct the instruction input, and the instruction input contains the above-mentioned cleaned topic tags. Optionally, construct the instruction input containing topic tags based on the instruction template so that the constructed instruction input can understand that the expected output is the user content text associated with the topic tags. The instruction input can specifically be a text with various sentence structures such as declarative sentences and interrogative sentences containing topic tags. For example, the instruction input can be "What's your opinion on the topic #Summer Cooling Goodies#".

[0068] Correspondingly, use the user content text in the cleaned topic content to construct the instruction output for jointly training the above-mentioned pre-trained large language model with the above instruction input. Among them, for any pair of instruction input and instruction output, the topic tags in the instruction input are related to the user content text in the instruction output in the original topic content. Optionally, the instruction output can only contain the user content text itself.

[0069] The pre-trained large language model used in this step can be flexibly selected according to actual application requirements. In the scenario of generating topic content on a social platform, a large language model can be applied to implement content generation related to topics. Among them, in terms of modeling, it can be implemented based on the encoder-decoder framework, and there is a problem of information loss. In this framework, the topic is encoded into a fixed-length vector, which may lead to loss of details of the topic information. The topics that users are concerned about often contain complex contexts and diverse information, and this method is difficult to effectively capture and express these information dynamically, thus affecting the expressiveness and richness of the model generation results.

[0070] Among them, the encoder first encodes the input topic to obtain a context vector, and then inputs it into the decoder. When the decoder outputs, it respectively performs attention allocation on the already output above text and the context vector of the topic to obtain the output of the current step. This process has isolation in the information fusion of the already output above text and the topic vector, resulting in a certain amount of information loss in the overall context fusion of the current step.

[0071] Optionally, the pre-trained large language model in the example of the present application can adopt a decoder-only (decoder only) structure, which has excellent contextual understanding and creative generation capabilities. By adopting a pre-trained large language model, the technology can better understand the context of the topic and inject more creative elements into the generation process of the user content text. Compared with the above-mentioned encoder-decoder framework, the decoder-only structure in the embodiment of the present application is not limited by a fixed-length vector, and does not distinguish between topics and already generated user content texts, but rather treats them all as the above, and can more flexibly handle variable-length context information, and can dynamically and emphatically capture the above information to generate a more expressive and personalized user content text.

[0072] This solution focuses on optimizing the style of generated user content text based on the pre-trained large language model. The ultimate goal is to narrow the gap between the content style generated by the large language model and the style of real user content text in the social platform domain, thereby reducing user perception.

[0073] Figure 1b The schematic diagram of the structure of a large language model with a decoder-only structure is shown. In this step, the correlation between the input topic tags and the output user content text is fitted to the model by fine-tuning the instructions. In the application stage, you only need to input the topic tags according to actual needs to obtain the user content text output by the topic content generation model.

[0074] The solution provided in the embodiment of the present application determines objective validity feature values ​​for topic tags by clustering, and performs cleaning based on the topic validity feature values, so that the cleaned topic content is not limited to the exclusive tags of a small number of users, but has the value of extensive participation in discussion. Furthermore, the cleaned topic content is used to perform instruction fine-tuning on the pre-trained large language model, so that the fine-tuned topic content generation model can be suitable for topic content generation application scenarios, improve the training quality and effectiveness of the topic content generation model, and make the output results of the topic content generation model have effectiveness and value for extensive user participation.

[0075] Based on the solution provided in the above embodiment, optionally, the number of topic tags in the original topic content is multiple;

[0076] Among them, Figure 2 As shown, in the above step S14, the original topic content is cleaned based on the validity feature values ​​corresponding to the topic tags in the original topic content to obtain the cleaned topic content, including:

[0077] S21: sorting the multiple topic tags in the original topic content according to the numerical values ​​based on the effectiveness feature values ​​respectively corresponding to the multiple topic tags in the original topic content;

[0078] S22: Cleaning the original topic content based on the sorting result to obtain cleaned topic content.

[0079] In this example, each topic tag is sorted based on the effectiveness feature values ​​corresponding to each of the multiple topic tags in the original topic content. Optionally, each effectiveness feature value is screened according to a preset effectiveness feature value interval before sorting, and only topic tags whose effectiveness feature values ​​fall within the preset effectiveness feature value interval are retained, and then sorting is performed to avoid interference of special topic tags in cleaning.

[0080] Based on the sorting result, the sorted topic tags are filtered according to a preset number or a preset validity feature value.

[0081] Through the solution provided in the embodiment of the present application, the topic tags are sorted based on the effectiveness feature values, which can efficiently and objectively reflect the user participation value of each topic tag, thereby efficiently realizing topic content cleaning and effectively improving the quality of the cleaned topic content.

[0082] Based on the solution provided in the above embodiment, optionally, Figure 3 As shown, in the above step S22, the original topic content is cleaned based on the sorting result to obtain the cleaned topic content, including:

[0083] S31: selecting a cleaned topic tag from a plurality of topic tags of the original topic content, wherein the validity feature value corresponding to any selected topic tag is greater than the validity feature value corresponding to any unselected topic tag;

[0084] S32: Constructing cleaned topic content based on user content text associated with the cleaned topic tag in the original topic content.

[0085] In the solution provided by the embodiment of the present application, topic tags can be screened based on a preset validity characteristic value. For example, topic tags with validity characteristic values ​​greater than the preset validity characteristic value are selected from the topic tags as cleaned topic tags.

[0086] Alternatively, topic tags may be filtered based on the arrangement order. For example, topic tags may be sorted in sequence according to the size of their effectiveness characteristic values, and topic tags with large effectiveness characteristic values ​​may be selected as cleaned topic tags according to a preset ratio or a preset number.

[0087] For example, the validity feature values ​​are arranged in descending order, and the top 10 topic tags with larger validity feature values ​​after cleaning are shown in the following table:

[0088] topic ratio Chinese 1212 Highway conditions 992 Milk's Thoughts 980 Shanghai Stock Exchange News 848 Futures [Super Topic] 521 This is Zibo 472 communication 365 Huhhot Railway Consulting 273 News 272 Daily Sayings [Super Talk] 259

[0089] Subsequently, the topic contents associated with the above 10 topic tags are constructed as cleaned topic contents, and the topic contents not associated with the above 10 topic tags are eliminated.

[0090] Furthermore, the user content text associated with the cleaned topic tags is used to construct the cleaned topic content, ensuring that the cleaned topic content has better value for extensive user participation in discussion than the original topic content.

[0091] Based on the solution provided in the above embodiment, optionally, the pre-trained large language model has a Transformer architecture with only a decoder;

[0092] like Figure 4a As shown, in the above step S15, the topic tags in the cleaned topic content are used to construct the instruction input, the user content text in the cleaned topic content is used to construct the instruction output, and the pre-trained large language model is fine-tuned to perform instruction fine-tuning to obtain the topic content generation model, including:

[0093] S41: Freeze the weight of the pre-trained large language model, and add a rank decomposition matrix to each layer of the decoder architecture of the pre-trained large language model.

[0094] S42: constructing instruction input with topic tags in the cleaned topic content, constructing instruction output with user content text in the cleaned topic content, training the rank decomposition matrix of each layer decoder architecture of the pre-trained large language model, and obtaining a topic content generation model.

[0095] In the embodiment of the present application, instruction fine-tuning can be performed through LoRA (Low-Rank Adaptation), which is an efficient training strategy for large pre-trained language models. This method is to freeze the pre-trained model weights during model training and inject a trainable rank decomposition matrix into each layer of the Transformer architecture, thereby greatly reducing the number of trainable parameters.

[0096] Compared with the full Fine-Tuning method, LoRA reduces hardware requirements and storage overhead while maintaining model quality, improves training efficiency, and does not introduce additional inference delays. LoRA can be widely used in various neural networks and downstream tasks.

[0097] The advantage of LoRA is that it can significantly reduce trainable parameters and memory requirements, which is conducive to model deployment. It improves training efficiency and lowers hardware barriers. It does not introduce additional inference delays and has the same input and output sequence lengths as the full Fine-Tune model. It can be used in combination with other methods such as prefix adjustment. It is conducive to fast switching of tasks and realizing online model customization. By studying the low-rank adaptation matrix, we can reveal the inherent mechanism of pre-trained models adapting to downstream tasks.

[0098] LoRA has been verified on models such as RoBERTa, DeBERTa and GPT-2, and can achieve performance comparable to that of full Fine-Tune in many tasks, while greatly reducing trainable parameters. This shows that LoRA has a good effect in large-scale language model adaptation.

[0099] The pre-trained large language model in this solution can use Baichuan2-7B-Base, for example. Baichuan 2 has two versions, Baichuan 2-7B and Baichuan 2-13B, which contain 7 billion and 13 billion parameters respectively. Both models are trained on a massive 2.6 trillion tokens, and in multiple benchmarks, Baichuan 2-7B shows nearly 30% performance improvement over Baichuan 1-7B.

[0100] Baichuan 2 uses the Transformer architecture as its basic structure and has made key modifications and optimizations. The schematic diagram of Baichuan 2 is shown below: Figure 4b As shown in the figure, Nx indicates that this model is repeatedly stacked multiple times. For word embedding, Baichuan 2 uses byte pair encoding (BPE) and SentencePiece technology to directly segment the original text, which helps to better process digital data. Among them, Rotary Positional Encoding (RoPE) and ALiBiPositional Encoding methods are also introduced to improve generalization ability. In terms of attention mechanism, Baichuan 2 adopts a memory-efficient implementation, which significantly reduces memory consumption.

[0101] Baichuan 2 focuses on data security, removes harmful content by strictly filtering pre-training datasets, and introduces supervised fine-tuning and reinforcement learning based on human feedback to improve the security of the model. Overall, Baichuan 2 is a large-scale language model that performs well in multiple fields and tasks, and improves the performance and training efficiency of the model by improving and optimizing the Transformer architecture.

[0102] Based on the solution provided in the above embodiment, optionally, Figure 5 As shown, in the above step S42, the topic tags in the cleaned topic content are used to construct the instruction input, the user content text in the cleaned topic content is used to construct the instruction output, and the rank decomposition matrix of each layer decoder architecture of the pre-trained large language model is trained to obtain the topic content generation model, including:

[0103] S51: Use the cleaned topic content to construct multiple topic instructions, where the topic instructions include a topic tag and at least one pre-set target feature word, where the target feature word includes at least one of the following: a target scene feature word, a target character feature word, and a target emotion feature word.

[0104] S52: Construct pairs of instruction inputs and instruction outputs to train the rank decomposition matrix of each layer of the decoder architecture of the pre-trained large language model to obtain a topic content generation model, wherein any instruction input includes a topic instruction, and the instruction output paired with the instruction input includes a user content text corresponding to the topic instruction.

[0105] In the solution provided by the embodiment of the present application, a topic instruction is first constructed based on the cleaned topic content, and then the topic instruction and the corresponding user content text are used to perform instruction fine-tuning. The instruction input and the instruction output are constructed in pairs, and a topic tag in a topic instruction included in any instruction input has an association relationship with a user content text in the paired instruction output in the original topic content.

[0106] In the process of constructing topic instruction data, a virtual persona can be introduced through the target persona feature words, aiming to stimulate the original ability of large language models in topic understanding and content text generation tasks. Similarly, virtual environment and virtual emotions can be introduced through other target feature words such as target scene feature words and target emotion feature words. Among them, persona, scene and emotion can all be set in the form of feature words, and topic instructions are constructed based on at least one of the above feature words combined with the cleaned topic content.

[0107] Optionally, the topic instruction includes a topic tag and at least one characteristic word, wherein the topic tag and the at least one characteristic word may be included in a sentence expressed in a natural language.

[0108] This solution can construct topic instructions containing feature words, so that by setting specific scenarios, the model can better understand the content text that the user expects to generate, thereby improving the performance of the generation model on specific tasks. Make the training process more effective and practical. By introducing features such as virtual characters, scenes, emotions, and optimized instruction templates, the model can better adapt to the task of topic generation and provide richer and more targeted information for the training of content text generation models. Such improvements help improve the performance of the model and make it perform better when generating content text related to specific topics. The instruction data sample is shown in the following table:

[0109]

[0110]

[0111] Optionally, in the embodiment of the present application, a large language model such as ChatGPT can also be used to rewrite the topic instructions to improve the richness of the topic instructions. This approach helps the model to understand the task of generating content text more comprehensively, while making the training process more challenging. By introducing more diverse topic instructions, we expect to improve the model's understanding of different topics and the flexibility of generating content text, thereby improving its ability to cope with diverse tasks.

[0112] Optionally, a command template can also be constructed based on massive platform content, for example, "Assuming that you are a social platform user now, please express your opinion on the topic #XXX#". Based on the pre-set and stored command template, in the step of constructing the topic command, you only need to substitute the new topic tag into the command template to replace "#XXX#" to efficiently generate a widely available topic command, effectively improving the efficiency of generating topic commands.

[0113] Through the solution provided in the embodiment of this application, the fine-tuning of instructions is combined with large language models such as ChatGPT, which can give full play to the understanding and generation capabilities of large language models with decoder-only structures, and generate content texts that are expressive and creative. The solution provided in the embodiment of this application promotes the excellent performance of the system in data cleaning and fine-tuning of instructions, improves the quality and personalization of generated content texts, and thus improves the quality of model training.

[0114] Based on the solution provided in the above embodiment, optionally, Figure 6 As shown, before the above step S12, that is, before clustering the user content text and user identification in the original topic content based on the topic tags in the original topic content, it also includes:

[0115] S61: Deduplication of user content text in the original topic content based on text similarity; and / or,

[0116] S62: Cleaning the original topic content based on preset cleaning rules, wherein the preset cleaning rules include at least one of the following: the character length of the topic tag is greater than the preset tag character length, the character length of the user content text is greater than the preset text character length, and the number of topic tags associated with the user content text is less than a preset number.

[0117] The solution provided in the embodiment of the present application performs preprocessing on the original topic content before clustering, and improves the quality of the original topic content by deduplication and cleaning. In view of the large number of repetitive situations that may exist in content text in actual applications, simhash technology can be used for deduplication.

[0118] In the step of performing the cleaning, sensitive words in the content text may be removed based on a preset sensitive word library.

[0119] Among them, too short character length contains less semantics. In this step, the original topic content whose character length of the topic tag is less than or equal to the preset tag character length or the character length of the user content text is less than or equal to the preset text character length can be deleted. Optionally, the original topic content with insufficient character length can also be expanded through a large language model such as GPT to improve the content quality used for clustering.

[0120] The number of topic tags can be flexibly set according to actual needs. For example, if the preset number is 2, then the number of topic tags associated with the cleaned user content should be 1. In the step of performing the cleaning, the original topic content containing multiple topic tags can be directly deleted, or multiple topic tags in the original topic content can be deleted into one topic tag. Among them, according to the semantic similarity between the user content text and multiple topic tags, the most similar topic tag can be retained, and then other redundant topic tags can be deleted.

[0121] The cleaned topic content can be shown in the following table:

[0122]

[0123]

[0124] Through the solution provided in the embodiment of the present application, through deduplication and cleaning and processing steps, the quality of the topic content used for clustering can be effectively improved, thereby improving the training effect of the model, ensuring that the content text content generated by the trained topic content generation model is of higher quality and relevance.

[0125] In the solution provided by the embodiments of the present application, an effectiveness eigenvalue of a topic tag is introduced. This value can demonstrate excellent effects during the data cleaning process, effectively improve the user participation value of the content after cleaning, effectively filter out data with low text relevance to the topic content, significantly improve the quality of the training data, help make the training data more representative, and provide a strong foundation for the performance of the training model.

[0126] To solve the problems existing in the prior art, the embodiments of the present application also provide a topic content generation method, as Figure 7 shown, including the following steps:

[0127] S71: Obtain the topic tag of the topic content to be generated;

[0128] S72: Construct a topic instruction based on the topic tag;

[0129] S73: Input the topic instruction into the topic content generation model to obtain the topic content output by the topic content generation model. The topic content generation model is trained by the training method of the topic content generation model described in any of the above embodiments.

[0130] Based on the trained topic content generation model, in the application stage, topic content can be efficiently generated for new topics. Assume that the topic tag of the topic content to be generated is #Summer避暑好物#. In this example, a topic instruction containing this topic tag is generated. Specifically, the above topic tag can be migrated into a preset instruction template to construct a topic instruction such as: "What's your view on the topic #Summer避暑好物#".

[0131] Optionally, a topic instruction containing feature words can also be generated based on a preset setting. For example, a topic instruction is constructed as: "Assume you are a traveler traveling in a hot summer day. What's your view on the topic #Summer避暑好物#", where "a traveler traveling in a hot summer day" is the target persona feature word. In practical applications, other feature words that can express features such as scenarios and emotions can also be used.

[0132] Subsequently, input the constructed topic instruction into the topic content generation model trained in any of the above embodiments, and the topic content text output by the model can be obtained.

[0133] The solution provided by the embodiment of the present application is based on the topic content generation model trained by any of the above embodiments, and a topic instruction is constructed based on the topic tag of the topic content to be generated, and the constructed topic instruction is input into the trained model to obtain the topic content text output by the model. Since the instruction input and instruction output for training the topic content generation model are generated based on the cleaned topic content, the cleaned topic content has the value of extensive user participation, so that the topic content text output by the model for the input topic instruction also has the value of extensive user participation, thereby generating a highly effective and high-quality topic content text.

[0134] In order to solve the problems existing in the prior art, the present application embodiment also provides a training device 80 for a topic content generation model, such as Figure 8 As shown, including:

[0135] An acquisition module 81 is configured to acquire original topic content, wherein the original topic content includes at least one topic tag, a user content text associated with the topic tag, and a user identifier corresponding to the user content text;

[0136] A clustering module 82 performs clustering on the original topic content based on the topic tag to obtain at least one topic text cluster;

[0137] A determination module 83 determines a validity feature value of the target topic tag based on the target topic text cluster to which the target topic tag belongs, wherein the validity feature value includes a ratio of the number of user content texts in the target topic text cluster to the number of user identifiers in the target topic text cluster;

[0138] A cleaning module 84, which cleans the original topic content based on the validity feature value to obtain cleaned topic content;

[0139] The training module 85 uses the cleaned topic content to perform instruction fine-tuning on the pre-trained large language model to obtain a topic content generation model.

[0140] Through the device provided by the embodiment of the present application, first, the original topic content is obtained, and the above-mentioned original topic content includes at least one topic tag, user content text associated with the topic tag, and a user identifier corresponding to the user content text; then, based on the topic tags in the original topic content, the user content text and the user identifier in the original topic content are clustered to obtain at least one topic text cluster; then, based on the target topic text cluster obtained by clustering the target topic tags, the validity feature value of the target topic tag is determined, and the validity feature value represents the ratio of the number of user content texts in the target topic text cluster to the number of user identifiers in the target topic text cluster, wherein the target topic tag is any topic tag in the original topic content; then, based on the validity feature values ​​corresponding to each topic tag in the original topic content, the original topic content is cleaned to obtain the cleaned topic content; finally, the topic tags in the cleaned topic content are used to construct the instruction input, and the user content text in the cleaned topic content is used to construct the instruction output, and the pre-trained large language model is fine-tuned to perform instruction fine-tuning to obtain a topic content generation model, wherein the topic tags used to construct the instruction input and the user content text used to construct the instruction output have an associated relationship. Among them, by clustering the topic tags to determine the objective validity feature value, and performing cleaning based on the topic validity feature value, the cleaned topic content can be not limited to the exclusive tags of a small number of users, but has the value of wide participation. Furthermore, using the cleaned topic content to perform instruction fine-tuning on the pre-trained large language model can make the fine-tuned topic content generation model suitable for topic content generation application scenarios, improve the training quality and effectiveness of the topic content generation model, and make the output results of the topic content generation model have effectiveness and value of wide user participation.

[0141] Among them, the above modules in the device provided by the embodiment of the present application can also implement the method steps provided by the above-mentioned training method embodiment of a topic content generation model. Alternatively, the device provided by the embodiment of the present application can also include other modules in addition to the above modules to implement the training method steps of a topic content generation model provided by the above method embodiment. And the device provided by the embodiment of the present application can achieve the technical effects that can be achieved by the above method embodiment.

[0142] In order to solve the problems existing in the prior art, the present application embodiment also provides a topic content generating device 90, such as Fig. 9 As shown, including:

[0143] An acquisition module 91 is used to acquire a topic tag of the topic content to be generated;

[0144] A construction module 92 constructs a topic instruction based on the topic tag;

[0145] The generation module 93 inputs the topic instruction into a topic content generation model to obtain a topic content text output by the topic content generation model, wherein the topic content generation model is trained by the training method of the topic content generation model described in any of the above embodiments.

[0146] The solution provided by the embodiment of the present application is based on the topic content generation model trained by any of the above embodiments, and a topic instruction is constructed based on the topic tag of the topic content to be generated, and the constructed topic instruction is input into the trained model to obtain the topic content text output by the model. Since the instruction input and instruction output for training the topic content generation model are generated based on the cleaned topic content, the cleaned topic content has the value of extensive user participation, so that the topic content text output by the model for the input topic instruction also has the value of extensive user participation, thereby generating a highly effective and high-quality topic content text.

[0147] Preferably, an embodiment of the present application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the above-mentioned training method of a topic content generation model or each process of an embodiment of a topic content generation method, and can achieve the same technical effect. To avoid repetition, it will not be described here.

[0148] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the training method of the topic content generation model or each process of the topic content generation method embodiment described above can be implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0149] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. The computer program can be operated to enable a computer to execute part or all of the steps of the above-mentioned training method for a topic content generation model or an embodiment of a topic content generation method, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0150] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0151] The present application is described with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, and the combination of the process and / or box in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and / or one box or multiple boxes in the block diagram.

[0152] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0153] These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0154] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0155] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

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

[0157] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0158] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0159] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A method for training a topic content generation model, characterized in that: include: Acquire original topic content, where the original topic content includes at least one topic tag, at least one user content text associated with the topic tag, and a user identifier corresponding to the user content text; Clustering the user content text and the user identifier in the original topic content based on the topic tags in the original topic content to obtain at least one topic text cluster; Determine the validity feature value of the target topic tag based on the target topic text cluster obtained by clustering the target topic tag, wherein the validity feature value represents the ratio of the number of user content texts in the target topic text cluster to the number of user identifiers in the target topic text cluster, wherein the target topic tag is any topic tag in the original topic content; Cleaning the original topic content based on the validity feature values ​​corresponding to the topic tags in the original topic content to obtain cleaned topic content; The topic tags in the cleaned topic content are used to construct the instruction input, the user content text in the cleaned topic content is used to construct the instruction output, and the pre-trained large language model is fine-tuned to obtain the topic content generation model, wherein the topic tags used to construct the instruction input are associated with the user content text used to construct the instruction output.

2. The method according to claim 1, characterized in that The number of topic tags in the original topic content is multiple; The cleaning of the original topic content based on the validity feature values ​​respectively corresponding to the topic tags in the original topic content to obtain the cleaned topic content includes: Sort the multiple topic tags in the original topic content by numerical value based on the effectiveness feature values ​​respectively corresponding to the multiple topic tags in the original topic content; The original topic content is cleaned based on the sorting result to obtain cleaned topic content.

3. The method according to claim 2, characterized in that The cleaning of the original topic content based on the sorting result to obtain the cleaned topic content includes: Selecting a cleaned topic tag from a plurality of topic tags of the original topic content, wherein a validity feature value corresponding to any selected topic tag is greater than a validity feature value corresponding to any unselected topic tag; The cleaned topic content is constructed based on the user content text associated with the cleaned topic tag in the original topic content.

4. The method according to any one of claims 1 to 3, characterized in that: The pre-trained large language model has a decoder-only Transformer architecture; The method constructs the instruction input with the topic tags in the cleaned topic content, constructs the instruction output with the user content text in the cleaned topic content, and performs instruction fine-tuning on the pre-trained large language model to obtain the topic content generation model, including: Freezing the weights of the pre-trained large language model, and adding a rank decomposition matrix to each layer of the decoder architecture of the pre-trained large language model; The topic tags in the cleaned topic content are used to construct the instruction input, the user content text in the cleaned topic content is used to construct the instruction output, and the rank decomposition matrix of each layer decoder architecture of the pre-trained large language model is trained to obtain the topic content generation model.

5. The method according to claim 4, characterized in that The topic content generation model is obtained by constructing the instruction input with the topic tags in the cleaned topic content, constructing the instruction output with the user content text in the cleaned topic content, and training the rank decomposition matrix of each layer decoder architecture of the pre-trained large language model, including: Constructing a plurality of topic instructions using the cleaned topic content, wherein the topic instructions include a topic tag and at least one preset target feature word, wherein the target feature word includes at least one of the following: a target scene feature word, a target character feature word, and a target emotion feature word; Construct pairs of instruction inputs and instruction outputs to train the rank decomposition matrix of each layer of the decoder architecture of the pre-trained large language model to obtain a topic content generation model, wherein any instruction input includes a topic instruction, and the instruction output paired with the instruction input includes a user content text corresponding to the topic instruction.

6. The method according to any one of claims 1 to 3, characterized in that: Before clustering the user content text and the user identification in the original topic content based on the topic tags in the original topic content, the method further includes: De-duplication of user content text in the original topic content based on text similarity; and / or, The original topic content is cleaned based on preset cleaning rules, wherein the preset cleaning rules include at least one of the following: the character length of the topic tag is greater than the preset tag character length, the character length of the user content text is greater than the preset text character length, and the number of topic tags associated with the user content text is less than a preset number.

7. A topic content generation method, characterized in that: include: Get the topic tag of the topic content to be generated; Constructing a topic instruction based on the topic tag; The topic instruction is input into a topic content generation model to obtain a topic content text output by the topic content generation model, wherein the topic content generation model is trained by the topic content generation model training method according to any one of claims 1 to 6.

8. A training device for a topic content generation model, characterized in that: include: An acquisition module is configured to acquire original topic content, wherein the original topic content includes at least one topic tag, at least one user content text associated with the topic tag, and a user identifier corresponding to the user content text; A clustering module, clustering the user content text and the user identifier in the original topic content based on the topic tags in the original topic content to obtain at least one topic text cluster; A determination module determines a validity feature value of a target topic tag based on a target topic text cluster obtained by clustering the target topic tag, wherein the validity feature value represents a ratio of the number of user content texts in the target topic text cluster to the number of user identifiers in the target topic text cluster, wherein the target topic tag is any topic tag in the original topic content; A cleaning module, which cleans the original topic content based on the validity feature values ​​corresponding to the topic tags in the original topic content to obtain cleaned topic content; The training module constructs instruction input with topic tags in the cleaned topic content, constructs instruction output with user content text in the cleaned topic content, performs instruction fine-tuning on the pre-trained large language model, and obtains a topic content generation model, wherein the topic tags used to construct the instruction input are associated with the user content text used to construct the instruction output.

9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method according to any one of claims 1 to 7 when executed by the processor.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

11. A computer program product, characterized in that The computer program product comprises a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is operable to cause a computer to execute part or all of the steps of the method according to any one of claims 1 to 7.