Text generation method and device, equipment, storage medium and computer program product

Through a text generation model based on sample users and topics, text data related to specified topics is generated, which solves the problems of low creative efficiency and decreased attention of network platform users, and improves user creative efficiency and user satisfaction.

CN118536479APending Publication Date: 2024-08-23MICRO DREAM TECHTRONIC NETWORK TECH CHINACO
View PDF 0 Cites 1 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

When special users on the network platform manually create and publish text content, the creation efficiency is low, resulting in a decrease in attention and views.

Method used

A text generation model trained based on sample user identity sample data, sample topic data and historical text data is used to predict and splice multiple predicted words to generate text data that is relevant to the specified topic and consistent with the user's identity.

Benefits of technology

It improves the user's creative efficiency and topic sensitivity, increases the user's attention and views on the network platform, and enhances the user's satisfaction with the generated text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118536479A
    Figure CN118536479A
Patent Text Reader

Abstract

The invention provides a text generation method and device, equipment, a storage medium and a computer program product. The text generation method comprises the steps of obtaining topic data of a specified topic and identity data of a specified user; on the basis of the topic data and the identity data, utilizing a trained text generation model to carry out prediction and splicing processing on a plurality of prediction words to obtain text data; the text data aims at the specified topic and conforms to the identity of the specified user; wherein the text generation model is obtained by training a preset large language model based on identity sample data of a sample user, sample topic data of a sample topic and historical text data associated with the sample topic. Through the method and the device, the text data which is related to the specified topic and conforms to the identity of the specified user can be effectively provided for the specified user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a text generation method, apparatus, device, storage medium and computer program product. Background Art

[0002] At present, with the continuous development of computer technology and big data, many network platforms have emerged. These network platforms can provide users with information acquisition, social interaction and entertainment, etc.

[0003] For users of the online platform, there are some special users. These special users are users with high attention and high browsing volume in different fields of the online platform. These users need to constantly create and publish texts on topics on the online platform to attract the attention of other users.

[0004] However, for these special users who constantly manually create and publish text content on different topics, the creation efficiency is low, which can easily lead to a decrease in the attention and page views of the special users over time. Summary of the invention

[0005] The embodiments of the present disclosure provide a text generation method, apparatus, device, storage medium and computer program product, which can effectively provide a specified user with text data related to a specified topic and consistent with the specified user's identity.

[0006] The disclosed embodiment provides a text generation method, comprising: obtaining topic data of a specified topic and identity data of a specified user; based on the topic data and the identity data, using a trained text generation model to predict and concatenate multiple predicted words to obtain text data; the text data is targeted at the specified topic and consistent with the identity of the specified user; wherein the text generation model is obtained by training a preset large language model based on identity sample data of sample users, sample topic data of sample topics, and historical text data associated with the sample topics.

[0007] In some embodiments, the designated user is a target user of a social media platform; the text data includes multiple pieces of social text data; the method further includes: in response to detecting a selection instruction for the multiple pieces of social text data, determining the social text data indicated by the selection instruction as target social text data; and publishing the target social text data based on the account of the target user.

[0008] In some embodiments, based on the topic data and the identity data, a trained text generation model is used to predict and concatenate multiple predicted words to obtain text data, including: based on the topic data and the identity data, generating data to be processed in a preset format; inputting the data to be processed into the trained text generation model for word-by-word prediction, and concatenating the predicted multiple predicted words in a prediction order to obtain output text data.

[0009] In some embodiments, the topic data includes at least one of the following: topic name, topic introduction, and topic keywords; the identity data includes at least one of the following: the name of the specified user, the gender of the specified user, the occupation of the specified user, the education level of the specified user, and the area of ​​expertise of the specified user.

[0010] In some embodiments, the training method of the text generation model includes: obtaining a sample data set; wherein each sample data in the sample data set includes at least identity sample data of a sample user, sample topic data of a sample topic, and historical text data associated with the sample topic; iteratively training the large language model based on the sample data set until the convergence condition is met to obtain the text generation model, and each iterative training process includes: for each sample data, based on the identity sample data and the sample topic data, using the large language model to predict and concatenate multiple predicted words to obtain text prediction data; wherein the text prediction data is for the sample topic and consistent with the identity of the sample user; based on the difference between the text prediction data corresponding to each sample data and the historical text data, fine-tuning the large language model to obtain model parameters after fine-tuning the large language model.

[0011] In some embodiments, for each sample data, based on the identity sample data and the sample topic data, the large language model is used to predict and concatenate multiple prediction words to obtain text prediction data, including: for each sample data, based on the identity sample data and the sample topic data, the large language model is used to perform an initial prediction to obtain a first prediction word; and the identity sample data and the sample topic data are predicted word by word using the historical text data to obtain each second prediction word; wherein the word in the historical text data that is arranged in the same position as the first prediction word is used to guide the prediction of the first second prediction word, and the designated word in the historical text data is used to guide the prediction of the subsequent second prediction word, and the designated word is the word in the arrangement position of the currently predicted second prediction word in the historical text data and the word before the arrangement position of the currently predicted second prediction word; the first prediction word and each second prediction word are concatenated in the prediction order to obtain the text prediction data.

[0012] In some embodiments, the method of fine-tuning the large language model based on the difference between the text prediction data corresponding to each sample data and the historical text data to obtain the model parameters of the large language model after fine-tuning includes: for each sample data, determining the difference between the text prediction data and the words in the same arrangement position in the historical text data, and determining the total difference corresponding to each sample data based on the differences; determining a loss value based on the total difference of each sample data; and fine-tuning the large language model based on the loss value to obtain the model parameters of the large language model after fine-tuning.

[0013] In some embodiments, the fine-tuning of the large language model based on the loss value to obtain model parameters of the large language model after fine-tuning includes: adjusting matrix data in a preset first matrix and a preset second matrix based on the loss value, wherein the first matrix and the second matrix are low-rank matrices of an initial parameter matrix; obtaining model parameters of the large language model after fine-tuning based on the initial parameter matrix and the first matrix and the second matrix after the matrix data are adjusted.

[0014] The disclosed embodiment also provides a text generation device, including: an acquisition module, configured to acquire topic data of a specified topic and identity data of a specified user; a processing module, configured to predict and concatenate multiple predicted words based on the topic data and the identity data using a trained text generation model to obtain text data; the text data is targeted at the specified topic and consistent with the identity of the specified user; wherein the text generation model is obtained by training a preset large language model based on identity sample data of sample users, sample topic data of sample topics, and historical text data associated with the sample topics.

[0015] In some embodiments, the designated user is a target user of a social media platform; the text data includes multiple pieces of social text data; the device also includes: a publishing module, configured to, in response to detecting a selection instruction for the multiple pieces of social text data, determine the social text data indicated by the selection instruction as the target social text data; and publish the target social text data based on the account of the target user.

[0016] In some embodiments, the processing module is further configured to generate data to be processed in a preset format based on the topic data and the identity data; input the data to be processed into the trained text generation model for word-by-word prediction processing, and concatenate the predicted multiple predicted words in a prediction order to obtain output text data.

[0017] In some embodiments, the topic data includes at least one of the following: topic name, topic introduction, and topic keywords; the identity data includes at least one of the following: the name of the specified user, the gender of the specified user, the occupation of the specified user, the education level of the specified user, and the area of ​​expertise of the specified user.

[0018] In some embodiments, the device also includes: a training module, configured to obtain a sample data set; wherein each sample data in the sample data set includes at least identity sample data of a sample user, sample topic data of a sample topic, and historical text data associated with the sample topic; based on the sample data set, the large language model is iteratively trained until the convergence condition is met to obtain the text generation model, and each iterative training process includes: for each sample data, based on the identity sample data and the sample topic data, using the large language model to predict and concatenate multiple predicted words to obtain text prediction data; wherein the text prediction data is for the sample topic and consistent with the identity of the sample user; based on the difference between the text prediction data corresponding to each sample data and the historical text data, the large language model is fine-tuned to obtain the model parameters after the large language model is fine-tuned.

[0019] In some embodiments, the training module is also configured to perform an initial prediction for each sample data based on the identity sample data and the sample topic data using the large language model to obtain a first predicted word; and use the historical text data to perform word-by-word prediction on the identity sample data and the sample topic data to obtain each second predicted word; wherein the word in the historical text data that has the same arrangement position as the first predicted word is used to guide the prediction of the first second predicted word, and the designated word in the historical text data is used to guide the prediction of subsequent second predicted words, and the designated word is the word in the arrangement position of the currently predicted second predicted word in the historical text data and the word before the arrangement position of the currently predicted second predicted word; the first predicted word and each second predicted word are concatenated in the prediction order to obtain the text prediction data.

[0020] In some embodiments, the training module is further configured to determine, for each sample data, the difference between the words in the same arrangement position in the text prediction data and the historical text data, and determine the total difference corresponding to each sample data based on the differences; determine a loss value based on the total difference of each sample data; and fine-tune the large language model based on the loss value to obtain model parameters after fine-tuning the large language model.

[0021] In some embodiments, the training module is further configured to adjust the matrix data in a preset first matrix and a preset second matrix based on the loss value, wherein the first matrix and the second matrix are low-rank matrices of the initial parameter matrix; based on the initial parameter matrix and the first matrix and the second matrix after the matrix data are adjusted, the model parameters of the large language model after fine-tuning are obtained.

[0022] The present disclosure also provides an electronic device, comprising: a memory for storing executable instructions or computer programs; and a processor for implementing the text generation method in the above embodiment when executing the executable instructions or computer programs stored in the memory.

[0023] An embodiment of the present disclosure provides a computer-readable storage medium on which a computer program or executable instructions are stored. When the computer program or the executable instructions are executed by a processor, the text generation method in the above embodiment is implemented.

[0024] An embodiment of the present disclosure provides a computer program product, including a computer program or executable instructions. When the computer program or executable instructions are executed by a processor, the text generation method in the above embodiment is implemented.

[0025] The embodiments of the present disclosure have the following beneficial effects:

[0026] In the text generation method proposed in the embodiment of the present disclosure, since the trained text generation model is trained based on the identity sample data of the sample user, the sample topic data of the sample topic, and the historical text data associated with the sample topic, it has the ability to solve topics and imitate user text generation. In this way, the present disclosure uses the text data model to predict and splice predicted words for the topic data and identity data, which can effectively provide the specified user with text data related to the specified topic and consistent with the identity of the specified user; in this way, the present disclosure improves the creation efficiency and topic sensitivity of the specified user by helping the specified user to pay attention to the specified topic and create text in a timely manner, and further improves the attention and browsing volume of the specified user on the network platform; and since the text data generated by the text generation model conforms to the style of the specified user, the present disclosure can effectively improve the satisfaction of the specified user in receiving text data. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 It is a schematic diagram of the architecture of a text generation system provided by an embodiment of the present disclosure.

[0028] Figure 2 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0029] Figure 3 It is a flowchart of the text generation method provided by an embodiment of the present disclosure.

[0030] Figure 4 It is a schematic diagram of the principle of model fine-tuning provided by an embodiment of the present disclosure.

[0031] Figure 5 It is a scheme architecture diagram of the text generation method provided by the embodiment of the present disclosure.

[0032] Figure 6 is a training flow chart of a text generation model provided by an embodiment of the present disclosure;

[0033] Figure 7 It is an architectural diagram for constructing a sample data set provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0034] In order to make the objectives, technical solutions and advantages of the present disclosure clearer, the present disclosure will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present disclosure. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.

[0035] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0036] In the following description, the terms "first\second" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.

[0037] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present disclosure belongs. The terms used herein are only for the purpose of describing the embodiments of the present disclosure and are not intended to limit the present disclosure.

[0038] With the continuous development of computer technology and big data, many network platforms, such as Weibo platforms and educational platforms, can be used by users to obtain information, socialize and entertain, etc. Some special users on the network platform are big V users or annual member users with high number of fans / views / professional field certification. These users may not be able to capture hot topics in time, and they cannot output hot topics. In addition, the way these users manually edit text for output makes the creation efficiency of these users too low, which can easily cause the attention and views of the special user to decline after a long time. In response to the above technical problems, the embodiments of the present disclosure provide a text generation method, device, equipment, storage medium and computer program product, which can effectively provide a specified user with text data related to a specified topic and in line with the style of the specified user.

[0039] The electronic device for implementing the above-mentioned text generation method provided by the embodiment of the present disclosure is described below. The electronic device provided by the embodiment of the present disclosure can be implemented as various types of terminal devices such as a laptop computer, a desktop computer, a mobile device, etc., and can also be implemented as a background server of a network platform (hereinafter referred to as a server). Below, an exemplary application when the electronic device is implemented as a server of a network platform will be described.

[0040] See also Figure 1 , Figure 1 It is an architectural diagram of a text generation system provided in an embodiment of the present disclosure. To implement the text generation method provided in an embodiment of the present disclosure, a terminal device 101 (the number of terminal devices included in the text generation system of the embodiment of the present disclosure is not limited) is connected to a server 102 via a network 103. The network 103 can be a wide area network or a local area network, or a combination of the two.

[0041] In one embodiment, a user logs in to an application corresponding to the network platform through a terminal device 101, and the terminal device 101 interacts with a server 102 through a network 103; the server 102 obtains the user's identity data and topic data through the network 103; and based on the topic data and identity data, a trained text generation model is used to predict and concatenate multiple predicted words to obtain text data; the text data can also be sent to the user through the network 103, so that it can be displayed on the graphical interface of the terminal device 101.

[0042] In some embodiments, the server 102 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms. The electronic device 400 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart watch, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present disclosure.

[0043] See also Figure 2 , Figure 2 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure; wherein, Figure 2 The electronic device 200 shown includes: at least one processor 210, a memory 250, at least one network interface 220 and a user interface 230. The various components in the electronic device 200 are coupled together via a bus system 240. It is understood that the bus system 240 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 240 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 240 is not described in detail. Figure 2 Various buses are labeled as bus system 240 .

[0044] The processor 210 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0045] The user interface 230 includes one or more output devices 231 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 230 also includes one or more input devices 232, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.

[0046] The memory 250 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 250 may optionally include one or more storage devices that are physically remote from the processor 210.

[0047] The memory 250 includes a volatile memory or a nonvolatile memory, and may also include both volatile and nonvolatile memories. The nonvolatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 250 described in the embodiments of the present disclosure is intended to include any suitable type of memory.

[0048] In some embodiments, memory 250 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.

[0049] Operating system 251, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;

[0050] A network communication module 252, for reaching other computing devices via one or more (wired or wireless) network interfaces 220, exemplary network interfaces 220 include: Bluetooth, wireless compatibility certification (WiFi), and universal serial bus (USB), etc.;

[0051] a presentation module 253 for enabling presentation of information via one or more output devices 231 (e.g., display screen, speaker, etc.) associated with the user interface 230 (e.g., a user interface for operating peripherals and displaying content and information);

[0052] The input processing module 254 is used to detect one or more user inputs or interactions from one of the one or more input devices 232 and translate the detected inputs or interactions.

[0053] In some embodiments, the text generation device provided by the embodiments of the present disclosure may be implemented in software. Figure 2 The text generation device 255 stored in the memory 250 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: an acquisition module 2551 and a processing module 2552. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.

[0054] In other embodiments, the text generation device provided by the embodiments of the present disclosure may be implemented in hardware. As an example, the device provided by the embodiments of the present disclosure may be a processor in the form of a hardware decoding processor, which is programmed to execute the text generation method provided by the embodiments of the present disclosure. For example, the processor in the form of a hardware decoding processor may adopt one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.

[0055] The text generation method provided by the embodiment of the present disclosure will be described below in conjunction with exemplary applications and implementations of the electronic device provided by the embodiment of the present disclosure.

[0056] See also Figure 3 , Figure 3 It is a flow chart of the text generation method provided by an embodiment of the present disclosure, and the method includes: step 301, obtaining topic data of a specified topic and identity data of a specified user; step 302, based on the topic data and identity data, using a trained text generation model to predict and concatenate multiple predicted words to obtain text data; the text data is for the specified topic and conforms to the identity of the specified user; wherein the text generation model is obtained by training a preset large language model based on identity sample data of sample users, sample topic data of sample topics, and historical text data associated with the sample topics.

[0057] In the embodiments of the present disclosure, the text generation method can be applied to social scenarios, advertising recommendation scenarios, text teaching scenarios, etc., and can be executed by electronic devices related to a network platform; the above-mentioned network platform includes a social media platform, an education platform, etc., and the above-mentioned electronic device may include a server of the network platform.

[0058] In step 301, the server may obtain topic data and identity data in response to a text acquisition instruction issued by a designated user on the client, or an event in which a designated user opens a function page or window related to text generation, or in response to a login message from a designated user.

[0059] In the disclosed embodiment, a topic is a title or subject for discussion; a designated topic may be a highly discussed topic, i.e., a hot topic, a latest topic, or a recently browsed topic of a designated user. The data of the designated topic includes at least one of the following: topic name, discussion volume, and field to which it belongs; here, the field to which it belongs includes but is not limited to social hot spots, lifestyles, course subjects, etc.

[0060] In the embodiment of the present disclosure, the designated user is a user of the network platform; the designated user may be any user or a special user; taking the network platform as an education platform as an example, the special user may be a user with a teacher's identity; taking the network platform as a social media platform as an example, the special user may be a big V user with a large number of fans / high page views / professional field certification or an annual member user, etc. The identity data of the designated user includes at least one of the following: nickname, real name, occupation, age, field of expertise, etc.

[0061] It should be noted that when the online platform obtains the identity data of a specified user, it can obtain it directly based on the personal information filled in by the user, such as a nickname, etc., or it can obtain it through data analysis based on the user's historical articles / pictures / videos or personal introduction, such as areas of expertise, personal skills, etc.

[0062] In an exemplary example, when the network platform is an education platform, the designated topic can be the teaching subject of a certain subject, etc., and the designated user can be a teacher on the education platform. At this time, the education platform server can obtain the name of the teaching subject and the name and area of ​​expertise of the teacher. In this way, the server can subsequently automatically generate a teaching text for the teacher based on the name of the teaching subject of a certain subject.

[0063] In step 302, the server can obtain a text generation model trained according to a preset large language model, and use the text generation model to process the acquired topic data and identity data, thereby generating text data that conforms to the style of a specified user for a specified topic.

[0064] Here, the preset large language model (LLM) is a natural language processing technology based on deep learning, which is applied to chatbots, text summarization, machine translation and other fields. LLM calculates the probability of a word after a given input sentence and is trained based on self-supervised learning technology; LLM includes a forward feedback neural network or a transformer model (Transformer); LLM in the present disclosure can be a Transformer. In the embodiment of the present disclosure, the natural language generation ability of LLM can be used to conduct targeted training on LLM, so that LLM learns to identify and internalize the inherent connections between various language patterns, thereby creating an internal representation of the language.

[0065] The disclosed embodiment uses the identity data of registered users of the network platform as the identity sample data of sample users, historical topics as sample topics, and text data corresponding to historical topics as historical text data associated with sample topics, to construct a sample data set to iteratively train the large language model, so that the large language model has the ability to understand topics and learn the styles of different registered users to write texts.

[0066] It should be noted that the user style that the text generation model can learn includes the text writing style; the text writing style is formed by the individual differences between users and is distinguished by user identity, such as the user names of different users, the user's field of expertise, or the differences between the user's age and gender. In some examples, the user name uniquely identifies the user, and each user has his or her own text writing format, for example, different users like to use different punctuation marks as separators; in this way, when training the text, the model can learn its text writing format based on the user name in the training sample, so that when the user is a designated user, the text data that conforms to the user's text writing format is output. In other examples, the text writing style can be distinguished based on the field of expertise, for example, users in the literary field like to use idioms and ancient poems, while users in non-literary fields like to use popular words; when there are users who are good at the literary field in the training samples of the text generation model, the text generation model can output text data including poems and idioms according to the writing style of users who are good at the literary field in actual application.

[0067] It should be noted that the embodiments of the present disclosure can directly input the topic data and identity data into the trained text generation model to use the text generation model to predict the topic data and identity data for prediction of the predicted words; the embodiments of the present disclosure can also pre-process the topic data and identity data, and input the pre-processed data into the trained text generation model for prediction of the predicted words. Here, the above-mentioned pre-processing process includes sorting, typo processing, format adjustment, etc., and the present disclosure does not limit this.

[0068] In actual implementation, the text generation model can encode the topic data and identity data to obtain multiple word vector features, and the word vector features are used to symbolize context information; according to the text creation ability for the specified topic and the language rules that conform to the specified user identity learned by the text generation model during the training process, word prediction is performed based on the word vector features; the word prediction process is: based on the word vector features, predict the first word in the output text data (the above words can be formed by words, numbers, letters or characters); after obtaining the first word of the output text data, add the first word to the word vector features that represent the context information as the basis for predicting the next word; based on this, the model can continuously predict words until the predicted word is a termination character, then concatenate all predicted words and output text data.

[0069] In the text generation method proposed in the embodiment of the present disclosure, since the trained text generation model is trained based on the identity sample data of the sample user, the sample topic data of the sample topic, and the historical text data associated with the sample topic, it has the ability to solve topics and imitate user text generation. In this way, the present disclosure uses the text data model to predict and splice predicted words for the topic data and identity data, which can effectively provide the specified user with text data related to the specified topic and consistent with the identity of the specified user; in this way, the present disclosure improves the creation efficiency and topic sensitivity of the specified user by helping the specified user to pay attention to the specified topic and create text in a timely manner, and further improves the attention and browsing volume of the specified user on the network platform; and since the text data generated by the text generation model conforms to the style of the specified user, the present disclosure can effectively improve the satisfaction of the specified user in receiving text data.

[0070] In some embodiments, a designated user is a target user of a social media platform; the text data includes multiple pieces of social text data; the text generation method proposed in the embodiments of the present disclosure also includes: in response to detecting a selection instruction for multiple pieces of social text data, determining the social text data indicated by the selection instruction as the target social text data; based on the account of the target user, publishing the target social text data.

[0071] Here, taking the network platform to which the text generation method proposed in the present disclosure is applied as a social media platform as an example, the above-mentioned designated user is the target user of the social media platform, and the target user may be a special user proposed in the above embodiments of the present disclosure, such as a user with a high number of fans / views, or a big V user with professional field certification, an annual member user, etc. In this way, the above-mentioned text data may include multiple pieces of social text data, i.e., multiple pieces of blog post data.

[0072] In the embodiment of the present disclosure, the selection instruction may be generated by a client of a target user of the social media platform, or may be generated by a server of the social media platform; wherein the selection instruction is used to indicate which of multiple pieces of social text data is the selected data.

[0073] In some examples, the server of the social media platform can select a piece of social text data with the highest text conciseness from multiple social texts, or select a piece of social text data based on the score of multiple social text data by the recommendation model, and generate a selection instruction after encoding the selection result. In other examples, the server of the social media platform can push multiple pieces of social text data to the client where the target user is located; the target user can view these social text data and select at least one piece of social text data, so that the client of the target user generates a selection instruction based on the user's selection; at this time, the server of the social media platform can receive and respond to the selection instruction sent by the target user client to determine the target social text data.

[0074] Here, the server determines the target social text data according to the selection instruction, including: taking the social text data selected by the user as the target text data; or, determining the target text data after filtering multiple social text data selected by the user; the filtering can be filtering of social text data carrying topic tags, wherein the topic tag can be a field with the "#" character as the first and last characters and the topic name as the middle content.

[0075] In the disclosed embodiment, after the server of the social platform determines the target social text data, it can send the target social text data to the client, at which time the designated user can store it locally, such as saving it in a draft box; the server can also directly publish the target social text data under the target user's account.

[0076] In the disclosed embodiments, the server of the social media platform can select and publish target social text data from multiple social text data based on selection instructions. In this way, it can provide users with more suitable target social text data for publication, improve the quantity and efficiency of text publications on designated topics by designated users, and also improve the user satisfaction of designated users with the social media platform.

[0077] In some embodiments, the above-mentioned prediction and splicing processing of multiple predicted words based on topic data and identity data using a trained text generation model to obtain text data includes: generating data to be processed in a preset format based on topic data and identity data; inputting the data to be processed into a trained text generation model for word-by-word prediction processing, and splicing the predicted multiple predicted words in the prediction order to obtain output text data.

[0078] In some examples of the present disclosure, the preset format may be a preset arrangement; for example, the preset arrangement may be in a manner in which the topic data comes first and the identity data comes later. In other examples of the present disclosure, the preset format may also be a data format formed by using preset instruction words as connectors of different data; the present disclosure may concatenate the topic data and the identity data through the above instruction words to obtain the data to be processed; for example, the instruction words may be "please imitate", "identity information is", "user", "generate text", "targeted at", "start a discussion" and "topic data is"; the data to be processed may be: please imitate the user whose identity information is field A and gender B to generate text, start a discussion on topic C, and the topic data is C1. In this way, when the data to be processed is data including preset instruction words, the text generation model can quickly and effectively understand the intrinsic connection between the topic data and the identity data.

[0079] In the embodiment of the present disclosure, the data to be processed in a preset format is input into a text generation model for word-by-word prediction processing to obtain a plurality of predicted words, and the plurality of predicted words are concatenated in a prediction order to form text data.

[0080] In the disclosed embodiment, by processing topic data and identity data into data that meets a preset format, the input data can be made more regular, so that the text generation model can reduce the steps and time for organizing the internal logic of the input data, thereby increasing the efficiency of generating text data.

[0081] In some embodiments, the topic data includes at least one of the following: topic name, topic introduction, and topic keywords; the identity data includes at least one of the following: the name of the specified user, the gender of the specified user, the occupation of the specified user, the education level of the specified user, and the area of ​​expertise of the specified user.

[0082] In the disclosed embodiment, the topic name is the topic title; the topic introduction is the introduction or quotation, which is used to explain the main idea of ​​the topic, render the background of the topic, and represent the core information of the topic; the topic keywords are words associated with the semantics of the topic, and the keywords are brief summaries of the topic title and introduction. In the disclosed embodiment, the topic data also includes the host identity data of the specified topic, the main blog post data under the specified topic, and the main blog post data is the text data published by the host. Exemplarily, the specified topic is life perception, and the topic name is "Which choice in life makes you regret"; the topic introduction is "It's time to make New Year's plans again. There is no correct answer to life choices. Don't worry about how much you have accomplished in a year, but do things that will create greater value in the next ten years"; the topic keywords are "life choices", "regret", "future" and "creation".

[0083] It should be noted that the topic data obtained by the server includes one or more of the above-mentioned topic names, topic introductions and topic keywords. In the actual implementation process, the amount of topic data obtained can be adjusted as needed; for example, if it is necessary to increase the rate of providing text data to a specified user, then only one type of topic data mentioned above can be obtained.

[0084] In the disclosed embodiments, the name of the designated user includes the nickname and / or real name of the designated user; the gender of the designated user includes male or female; the occupation of the designated user reflects the type of work performed by the designated user, such as teacher, doctor, etc.; the educational background of the designated user reflects the stage and level of education received by the designated user, such as bachelor's degree, master's degree, etc.; the field of expertise of the designated user represents the field with which the designated user is familiar, wherein the designated user's familiarity with the field means that the user can independently express opinions on topics related to the field.

[0085] It should be noted that the areas of expertise of the designated user can be obtained based on the personal information filled in by the designated user on the network platform, or can be obtained by data analysis based on historical articles, historical visit records, or personal introductions published by the designated user. In the disclosed embodiment, the areas of expertise can be expressed as ability labels, for example, the first-level ability label is the literature field, and the second-level ability label is the music field.

[0086] In the disclosed embodiment, the identity data acquired by the server includes one or more of the name, gender, occupation, education background, and areas of expertise of the specified user. In the actual implementation process, the amount of identity data acquired can be adjusted as needed. For example, if it is necessary to improve the correlation between the text data provided for the specified user and the user style, the above-mentioned multiple identity data can be acquired.

[0087] In the embodiments of the present disclosure, the topic data and identity data that can be obtained by the server may include one or more, which can not only enrich the diversity of the solutions of the present disclosure, but also increase the flexibility of the text generation model in generating text data.

[0088] In some embodiments, the training method of the above-mentioned text generation model includes: obtaining a sample data set; wherein each sample data in the sample data set includes at least identity sample data of a sample user, sample topic data of a sample topic, and historical text data associated with the sample topic; iteratively training the large language model based on the sample data set until a convergence condition is met to obtain a text generation model, and each iterative training process includes: for each sample data, based on the identity sample data and the sample topic data, using the large language model to predict and concatenate multiple predicted words to obtain text prediction data; wherein the text prediction data is for the sample topic and consistent with the identity of the sample user; based on the difference between the text prediction data corresponding to each sample data and the historical text data, fine-tuning the large language model to obtain model parameters after fine-tuning the large language model.

[0089] Here, each sample data includes at least the sample user's identity sample data, the sample topic data of the sample topic, and the historical text data associated with the sample topic; wherein the sample users include ordinary users and special users; the sample topic is a historical topic on the network platform, and the historical text data associated with the sample topic is the historical published text written by ordinary users and special users on the network platform for the sample topic. Taking the Weibo platform as an example, the sample users include ordinary users and big V users; the sample topic is a historical topic on the Weibo platform, and the historical text data is the historical blog posts published by ordinary users and big V users on the Weibo platform.

[0090] In the embodiment of the present disclosure, the sample data in the sample data set is divided into two types of data.

[0091] The first type of sample data is data related to the topic. Among them, the data related to the sample topic includes topic introduction, topic keywords and host information, etc., historical text data under the sample topic and its corresponding sample user identity data. The first type of sample data also includes the first type of instruction words, and is obtained by concatenating the identity sample data of the sample user, the topic data of the sample topic, and the historical text data associated with the sample topic by the first type of instruction words; wherein the first type of instruction words are used to instruct the large language model to generate text around the sample topic; in this way, the large language model can fully learn the topic understanding and the relationship between the sample topic and the historical text data. Exemplarily, the first type of sample data includes: "Input: Please discuss the topic #Which choice in life made you regret# and post a microblog. The introduction of the topic is: It's time to make New Year's plans again. There is no correct answer to life choices. Don't dwell on how much you have accomplished in a year, but do things that will create greater value in the next ten years. The gender of the sample user is: male, and the first-level ability is: emotion. His self-introduction is: No matter why you feel confused, don't lose hope in life. No matter how heavy the rain is, it will stop. Isn't it?" and "Output: Don't compare prices after buying, don't regret after eating, don't guess after loving, don't slander after breaking up, everything is paying for your own choice #Which choice in life made you regret#". Among them, "Please discuss the topic" and "start a discussion" and other instruction words are used to connect the identity sample data of the sample user and the topic data of the sample topic, and "output" and other instruction words are used to connect the historical text data associated with the sample topic.

[0092] The second type of sample data is data related to special users. The second type of sample data also includes the second type of instruction words, which are obtained by connecting the identity sample data of special users and the historical text data published by special users on sample topics; the second type of instruction words are used to instruct the large language model to generate text around special users; such a large language model can fully learn the personal style of special users and the text writing style of special users in specific fields. For example: the second type of sample data includes: "Input: Please imitate the female user in the emotional field, Xiao Ming, and post a Weibo. Her first-level ability is: emotional gender. Her self-introduction is: Doctor of emotional psychology, lecturer", and "Output: "What should girls pay attention to when they fall in love? Of course, be sweet-mouthed and provide more emotional value to the other party." Instructions such as "Please imitate" and "Post a Weibo" are used to connect the identity data of special users, and instructions such as "output" are used to connect the historical text data associated with sample topics.

[0093] It should be noted that in the second type of sample data, the name of the special user is used to enable the large language model to learn the personal style, and other identity data of the special user, such as gender, field of expertise, etc., is used to enable the large language model to learn the style of a specific field.

[0094] In an embodiment of the present disclosure, in the second type of sample data, the topic data of the designated topic may include a topic tag formed with the "#" character as the first and last characters and the topic name as the middle content; the designated topic content may be internalized into the historical text data of a special user, with the semantic representation of the historical text data, that is, in the second type of sample data, the historical text data may or may not carry the topic tag.

[0095] In actual implementation, the disclosure can construct more than 400,000 sample data of the first type and 4.31 million sample data of the second type, with a time span of about four years. In the disclosure, the sample users in the above sample data set may include the specified user or not include the specified user; wherein, if the sample users include the specified user, the text generation model can better imitate the personal style of the specified user, and if the sample users do not include the specified user, the text generation model can output text data based on the identity data of the specified user and imitate the style of the special user with the same identity data.

[0096] In the disclosed embodiment, after constructing a sample data set, the pre-trained large language model is iteratively trained using the sample data set until a text generation model is obtained by meeting convergence conditions.

[0097] The pre-trained large language model can be an open source large language model, such as the Baichuan-7B model; Baichuan-7B is a large-scale pre-trained model developed by Baichuan Intelligence. Based on the Transformer structure, the 7 billion parameter model trained on 1.2 trillion tokens supports Chinese and English, and the context window length is 4096. In this disclosure, Baichuan-7B is selected as the preset large language model, and fine-tuned using a sample data set, so that the large language model can converge faster, thereby achieving the expected usable effect.

[0098] For each sample data, a large language model is used to predict and splice the predicted words based on the identity sample data and the sample topic data to obtain the predicted text data; after obtaining the text prediction data, the historical text data is used as a label to guide the training of the large language model, and the large language model is fine-tuned by the supervised fine-tuning (SFT) technology to update the model parameters of the large language model. Among them, SFT aims to further improve the large language model's adaptation to the text generation task of the present disclosure and the language pattern and rules of the sample data set. Among them, the embodiment of the present disclosure fine-tunes the large language model by comparing the difference between the text prediction data and the historical text data. In this way, after multiple iterations of training, the difference between the text prediction results of the large language model and the historical text data gradually becomes smaller until the preset convergence condition is met to obtain the text generation model, so that the text generation model can better complete the text generation task of imitating the style of the specified user for the specified topic to perform text prediction.

[0099] The above convergence conditions include: the difference between the text prediction result and the historical text data is less than the convergence threshold, or the number of iterative training reaches a preset number.

[0100] Here, word-by-word prediction processing is performed based on a large language model, including: extracting user features of identity sample data and topic features in sample topic data based on the large language model, and performing word-by-word prediction according to the user features and the topic features; a method based on the difference between text prediction data corresponding to each sample data and historical text data includes: determining text similarity between text prediction data and historical text data; wherein determining text similarity includes determining Euclidean distance, cosine similarity or cross entropy, etc.

[0101] The large language model in the embodiment of the present disclosure is provided with a target loss function, which is constructed based on the difference between the above-mentioned text prediction data and the historical text data, and is positively correlated with the difference between the text prediction data and the historical text data. In actual implementation, the present disclosure determines the loss value of the target loss function based on the difference between the text prediction data and the historical text data corresponding to each sample data, and back-propagates the loss value layer by layer in the large language model. When reaching each layer, the gradient (that is, the partial derivative of the target loss function to the parameters of this layer) is solved in combination with the loss value to update the parameters.

[0102] In this way, the server iteratively trains the preset large language model based on the sample data set, so that the large language model can fully learn the text writing style, topic understanding and writing ability of sample users with different identities, and the correlation between sample users with different identities and different sample topics. In this way, the text generation model obtained after training can generate text data that meets the style of a specified user under a specified topic.

[0103] In some embodiments, for each sample data, based on the identity sample data and the sample topic data, a large language model is used to predict and concatenate multiple prediction words to obtain text prediction data, including: for each sample data, based on the identity sample data and the sample topic data, a large language model is used to perform an initial prediction to obtain a first prediction word; the identity sample data and the sample topic data are predicted word by word using historical text data to obtain each second prediction word; wherein the word in the historical text data that has the same arrangement position as the first prediction word is used to guide the prediction of the first second prediction word, and the designated word in the historical text data is used to guide the prediction of subsequent second prediction words, and the designated word is the word in the arrangement position of the currently predicted second prediction word in the historical text data and the word before the arrangement position of the currently predicted second prediction word; the first prediction word and each second prediction word are concatenated in the prediction order to obtain text prediction data.

[0104] In the disclosed embodiment, for each sample data, the large language model can predict the next word (token) based on the context information; different from the pre-training process of the large language model, the historical text data can be used as a label during the iterative training of the disclosed embodiment to guide the prediction of each word in the text and the updating of the model parameters.

[0105] In combination with the above description of the present disclosure, each sample data is generated by a preset format, and the preset format may be a format of a series of instruction words. Exemplarily, the sample data of the preset format in the present disclosure may be characterized as an instruction data in the following manner: Input: <s> instruction response; labels labels: -100...-100response< / s> ;in, <s> Represents the start identifier,< / s> Represents the end identifier, instruction represents the input token predicted based on context information, and response represents the expected output token; "-100" is a mask identifier, which represents the instruction word, such as "Please imitate" and "Start a discussion" mentioned above. "-100" means that the tokens of instruction do not need to participate in the calculation when determining the difference between the text prediction data and the historical text data in the subsequent determination, which does not affect the determination of the subsequent loss value.

[0106] Among them, the large language model will first encode the sample data to obtain multiple word vector features, wherein the word vector features are used to symbolize context information; when the word vector features include the word vector features corresponding to the identity data and the sample topic, the large language model performs the first prediction to determine the first predicted word; after obtaining the first predicted word, the large language model will predict the first second predicted word based on the word vector features corresponding to the identity data and the sample topic, and the word vector features corresponding to the words in the historical text data with the same arrangement position as the first predicted word; based on this prediction method, the subsequent second predicted words are predicted until the currently predicted second predicted word is the termination symbol "", or until the arrangement position of the currently predicted second predicted word corresponds to the last arrangement position in the historical text data, at which time the word-by-word prediction is terminated, and the first predicted word and each second predicted word are spliced ​​in the predicted order to obtain text prediction data. Among them, the first predicted word and the second predicted word can both be formed by words, numbers, letters or characters, and the present disclosure does not limit this.

[0107] It should be noted that the large language model can provide a context window for generating text prediction data; here, the arrangement order of the first predicted word and each second predicted word corresponds to the order of appearance of the prediction order of each predicted word in the context window; in the present disclosure, the first word of the historical text data is aligned with the context window, so that the embodiment of the present disclosure can guide the word-by-word prediction process based on the alignment relationship of the arrangement position.

[0108] It should also be noted that the word vector features used for predicting the first predicted word and the second preset word represent the current predicted word and its previous context information, wherein the process of predicting the word includes: determining multiple candidate words according to the word vector features representing the current context information, and scoring each candidate word to obtain a scoring result for the multiple candidate words, at which time the word with the highest score result is used as the corresponding predicted word (the first predicted word or the second predicted word). The scoring result obtained by scoring each candidate word can also be implemented as determining the conditional probability of each candidate word appearing in an existing large language vocabulary.

[0109] In the disclosed embodiment, the large language model guides the output of each predicted word in the text prediction data through historical text data, and can fully train the large language model to learn the text logic in the historical text data. The text generation model obtained in this way can effectively generate text data that meets the style of a specified user under a specified topic.

[0110] In some embodiments, based on the difference between text prediction data corresponding to each sample data and the historical text data, the large language model is fine-tuned to obtain model parameters of the large language model after fine-tuning, including: for each sample data, determining the difference between the text prediction data and the words in the same arrangement position in the historical text data, and determining the total difference corresponding to each sample data based on each difference; determining a loss value based on the total difference of each sample data; and fine-tuning the large language model based on the loss value to obtain model parameters of the large language model after fine-tuning.

[0111] In combination with the above, the first predicted word in the text prediction data is compared with the word at the same arrangement position in the historical text data to determine the difference corresponding to the first predicted word; then, based on each second predicted word, the words at the same arrangement position in the historical text data are respectively compared to obtain the difference corresponding to each second predicted word. In some examples, each difference includes cosine similarity, Euclidean distance, or dot product results. In another example, each difference includes the conditional probability of each word in the historical text data appearing in the existing large language vocabulary, and the conditional probability of the predicted word at the same position appearing in the existing large language vocabulary.

[0112] After obtaining each difference, the embodiment of the present disclosure determines the total difference; wherein, for example, it is obtained based on the sum of each difference. The present disclosure determines the loss value of the target loss function after calculating the total difference of the sample data of each iteration training. The large language model is fine-tuned using the loss value; the fine-tuning process includes: back-propagating the loss value layer by layer in the large language model, and when reaching each layer of the large language model, solving the gradient of the layer in combination with the loss value, and updating the parameters of the layer to the corresponding gradient value.

[0113] In the disclosed embodiment, the large language model can update the model parameters based on the loss value corresponding to the total difference, and can gradually reduce the difference between the text prediction data predicted by the large language model and the historical text data, thereby improving the accuracy and pertinence of the text prediction results output by the large language model.

[0114] In the embodiments of the present disclosure, historical text data can be used as labeled data, and the large language model can be fine-tuned through the SFT technology, thereby improving the performance and adaptability of the language model, so that the language model can better handle natural language processing tasks. However, the SFT technology also requires certain computing resources and time costs, so it includes different fine-tuning strategies, such as full parameter fine-tuning, LoRA (Low-Rank Adaptation) efficient fine-tuning, Q-LoRA efficient fine-tuning, etc., because different fine-tuning strategies have differences in efficiency and effect, and the overall fine-tuning time usually increases with the increase of model size, the length of training data, the increase of training data, and the shortage of machine resources. Therefore, the present disclosure can select the LoRA efficient fine-tuning technology for supervised fine-tuning, thereby improving the performance of the large language model and reducing computing resources and memory requirements.

[0115] In some embodiments, fine-tuning a large language model based on a loss value to obtain model parameters of the large language model after fine-tuning includes: adjusting matrix data in a preset first matrix and a preset second matrix based on the loss value, wherein the first matrix and the second matrix are low-rank matrices of an initial parameter matrix; obtaining model parameters of the large language model after fine-tuning based on the initial parameter matrix and the first matrix and the second matrix after the matrix data are adjusted.

[0116] The process of adjusting the matrix data in the first matrix and the second matrix in the embodiment of the present disclosure is a process of fine-tuning the large language model based on the LoRA efficient fine-tuning technology provided above. Among them, the LoRA efficient fine-tuning is to use low-rank matrix decomposition to approximate the weight matrix corresponding to the model parameters in the preset large language model, and in the model parameter update step, fix the initial parameter matrix and only update the low-rank matrix.

[0117] Among them, the large language model contains many dense layers, and the weight matrices in these layers usually have full rank. That is, the initial parameter matrix of the large language model is usually full rank. The first matrix and the second matrix have the same number of rows and columns as the initial parameter matrix, but the rank is lower than the rank of the initial parameter matrix, and the initial parameter matrix can be obtained after point multiplication. Among them, the first matrix can be Gaussian initialized, and the second matrix can be zero initialized.

[0118] See also Figure 4 , Figure 4 is a schematic diagram of the principle of model fine-tuning provided by an embodiment of the present disclosure; Figure 4 The initial weight matrix W0∈Rd×k of the dense layer is shown, and the following formula (1) can represent the model parameter update process:

[0119]

[0120] Among them, W0 represents the initial parameter matrix, A represents the first matrix, B represents the second matrix, ΔW is the dot product result of the first matrix A and the second matrix B, which is used to reflect the change of the matrix data of the initial parameter matrix in parameter update; here, the rank r of the matrix corresponding to BA is much smaller than min(d,k). In each iterative training process, when the loss value is back-propagated in the above dense layer, the initial parameter matrix W0 is fixed, and the matrix data in A and B are updated. These matrix data represent the trainable model parameters in A and B.

[0121] It should be noted that Figure 4 The forward propagation process of a model is also illustrated in FIG, where x is the input feature vector of a certain layer, h is the output feature vector of the layer, and d is the model parameter (weight matrix) of the layer; the forward propagation process of the large language model can be illustrated by formula (2):

[0122] h=dx=W0x+ΔWx=W0x+BAx (2);

[0123] In this way, the embodiment of the present disclosure replaces the update of the initial parameter matrix with the update of the low-rank first matrix and the second matrix, which reduces the number of trainable parameters, makes fine-tuning more efficient, and reduces hardware resource requirements. When the present disclosure applies the LoRA efficient fine-tuning technology, because the large language model has a lower intrinsic dimension, the model can still be effectively learned even when randomly projected to a smaller subspace.

[0124] In other embodiments, fine-tuning the large language model based on the loss value further includes: adjusting the matrix data of the preset first matrix based on the loss value; obtaining the fine-tuned model parameters based on the initial parameter matrix, the second matrix, and the adjusted first matrix. In other embodiments, fine-tuning the large language model based on the loss value further includes: adjusting the matrix data of the preset second matrix based on the loss value; obtaining the fine-tuned model parameters based on the initial parameter matrix, the first matrix, and the adjusted second matrix.

[0125] Below, taking the social media platform to which the text generation method proposed in the above embodiment of the present disclosure is applied as the Weibo platform as an example, an exemplary application of the embodiment of the present disclosure is described.

[0126] In the disclosed embodiments, the Weibo platform proposes a generative artificial intelligence (AIGC) creation assistant that implements the above-mentioned text generation method. The AIGC creation assistant is a functional module provided by the Weibo platform for users and is implemented by a server. The AIGC creation assistant can respond to the needs of big V users through a text generation model and generate text for hot topics.

[0127] See also Figure 5 , Figure 5 It is a scheme architecture diagram of the text generation method provided by the embodiment of the present disclosure. The online process of the Weibo platform is: generating blog posts on hot topics for big Vs; the background (offline) process of the Weibo platform is: training the text generation model. The online process specifically includes: the server obtains the topic data of the hot topics and the identity data of the big V users, and uses the text generation model to perform word-by-word prediction processing to obtain multiple predicted words spliced ​​in the prediction order, which conform to the style of the big V users and have multiple social text data with hot topic information. Here, the server can send multiple social text data to the client device of the big V user; the server can determine the target social text data among the multiple social text data based on the selection instruction of the big V user; and publish the target social text data under the account of the big V user.

[0128] See also Figure 6 , Figure 6 is a training flow chart of a text generation model provided by an embodiment of the present disclosure; Figure 6 yes Figure 5 The specific process of the mid- and back-end (offline) process, the training process of the text generation model includes obtaining a preset large language model, and fine-tuning the preset large language model based on the constructed sample data set, so as to obtain a training plan for training the text generation model. The training plan will be further explained below. Figure 6 In the pre-training phase shown, a preset large language model LLM is obtained. The basic structure of LLM is a GPT structure, which is obtained by the decoder in the Transformer structure and uses the given context to predict the next token. Exemplarily, the context length of the predicted output is 4 words, such as [A, B, C, D]; wherein LMM predicts the next token B based on the input text using A, and then uses [A, B] to predict the next token C, and uses [A, B, C] to predict the next token D. In the pre-training process, LLM performs model training by traversing large-scale unsupervised corpus data and using LLM's preset loss function (maximum likelihood estimation of parameters) to maximize the likelihood of the predicted token, wherein the preset loss function L U The loss function of LLM is shown in the following formula (3). Where k is the size of the context window of the LLM type prediction output text, U is the unlabeled corpus, P is the conditional probability of the next token appearing under the known context, Θ is the parameter of the conditional probability, wherein the parameter includes the above-mentioned model parameters of the present disclosure, and the update method thereof is gradient update.

[0129]

[0130] Here, since the pre-training stage requires tens of billions of corpora and large resource consumption, the present disclosure uses the open source Baichuan-7B model as the base model; Figure 6 It is shown that the fine-tuning stage uses the sample data set and the LoRA fine-tuning technology in the SFT technology to fine-tune the Baichuan-7B model to obtain a text generation model.

[0131] See also Figure 7 , Figure 7 It is an architectural diagram for constructing a sample data set provided by an embodiment of the present disclosure. Figure 7 Yes Figure 5 Further explanation of the sample data of the sample data set in . Here, in order to enable the Baichuan-7B model to have the ability to understand hot topics and learn the relationship between topics and the content of the blog post, we construct two types of sample data; the first type of sample data is the general blog post data under the hot topics, including: data representing the topic features of the hot topics and actual blog posting data representing the hot topics. Here, the data representing the topic features of the hot topics include but are not limited to the topic name, topic introduction, host information, main blog post information; the actual blog posting data representing the hot topics include but are not limited to historical blog posts, the identity information of the posters corresponding to the historical blog posts, etc.; the identity information of the posters includes gender, name, and field of expertise, etc. Among them, the first type of sample data has a preset format and can be obtained by concatenating the first type of instruction words; the second type of sample data is the daily blog posting data of big V users, including: data representing the characteristics of big V users and historical blog posting data of big V users. Here, the data characterizing the characteristics of the big V user include but are not limited to the name, gender, field of expertise and personal profile of the big V user; wherein, the name of the big V user is used to enable the Baichuan-7B model to learn the style of the big V user, and other features (gender, field of expertise and personal introduction, etc.) are used to enable the Baichuan-7B model to learn the style of a specific field. The historical blogging data of the big V user is the data that has been cleaned for the original blog posts published by the big V user. The cleaning process here can be to remove forwarded blog posts, remove blog posts with text length less than a preset length, etc. The historical blogging data of the big V user includes data carrying topic tags and data without topic tags. The second type of sample data has a preset format and can be obtained by concatenating the second type of instruction words.

[0132] In the embodiment of the present disclosure, the sample data of the first type and the second type are randomly shuffled to form sub-datasets of multiple batches, and the sub-datasets are used to iteratively train the Baichuan-7B model in sequence. The historical text data in the sample data can guide the word-by-word prediction of the text prediction data, and the difference between the text prediction data and the historical text data can be used to determine the loss value, so as to update the model parameters (weight matrix) of the Baichuan-7B model based on the LoRA efficient fine-tuning method. The present disclosure can update the parameters of the Baichuan-7B model with the purpose of minimizing the loss value of the generated response tokens.

[0133] The solution proposed in the disclosed embodiment is different from the robot dialogue system. The text generation model is internalized into the AIGC creation assistant. It does not require big V users to have interactive dialogues and knowledge injection with the robot every time. It can automatically generate multiple blog content for big V users based on hot topics on Weibo for big V users to screen, edit and confirm publication. In this way, the convenience, flexibility and efficiency of big V users in text creation are improved, and the number of big V posts is increased. In addition, the disclosed embodiment uses the historical posts of big V users to learn their style, and at the same time introduces historical blog posts under hot topics to enable the large language model to learn topic understanding capabilities, which can cope with rapidly changing hot spots and hot topics in Weibo, and improve the participation of big V users in hot topics, thereby effectively improving the attention and views of the big V users. At the same time, because the model parameters of the large language model are adjusted through the model training process, the Weibo style is retained to the maximum extent without losing the original large language model's ability to obey instructions. This can well support the business of the creative assistant. Compared with directly modifying the input prompt word method to imitate the style of big Vs for creation, it can not only effectively understand hot topics for text creation, but also fully preserve the style of the Weibo platform.

[0134] The following is a description of an exemplary structure of the text generation device 255 provided in the application embodiment implemented as a software module. In some embodiments, Figure 2 As shown, the software modules stored in the text generation device 255 of the memory 250 may include: an acquisition module 2551, configured to acquire topic data of a specified topic and identity data of a specified user; a processing module 2552, configured to predict and concatenate multiple predicted words based on the topic data and identity data using a trained text generation model to obtain text data; the text data is for the specified topic and conforms to the identity of the specified user; wherein the text generation model is obtained by training a preset large language model based on identity sample data of sample users, sample topic data of sample topics, and historical text data associated with the sample topics.

[0135] In some embodiments, the designated user is a target user of a social media platform; the text data includes multiple pieces of social text data; the text generation device 255 also includes: a publishing module, configured to, in response to detecting a selection instruction for multiple pieces of social text data, determine the social text data indicated by the selection instruction as the target social text data; and publish the target social text data based on the target user's account.

[0136] In some embodiments, the processing module 2552 also generates data to be processed in a preset format based on the topic data and the identity data; inputs the data to be processed into a trained text generation model for word-by-word prediction processing, and concatenates the predicted multiple predicted words in the prediction order to obtain the output text data.

[0137] In some embodiments, the topic data includes at least one of the following: topic name, topic introduction, and topic keywords; the identity data includes at least one of the following: the name of the specified user, the gender of the specified user, the occupation of the specified user, the education level of the specified user, and the area of ​​expertise of the specified user.

[0138] In some embodiments, the text generation device 255 also includes: a training module, configured to obtain a sample data set; wherein each sample data in the sample data set includes at least identity sample data of a sample user, sample topic data of a sample topic, and historical text data associated with the sample topic; based on the sample data set, the large language model is iteratively trained until a text generation model is obtained by meeting the convergence conditions, and each iterative training process includes: for each sample data, based on the identity sample data and the sample topic data, using the large language model to predict and concatenate multiple predicted words to obtain text prediction data; wherein the text prediction data is for the sample topic and consistent with the identity of the sample user; based on the difference between the text prediction data corresponding to each sample data and the historical text data, the large language model is fine-tuned to obtain the model parameters after the large language model is fine-tuned.

[0139] In some embodiments, the training module is further configured to perform an initial prediction for each sample data using a large language model based on the identity sample data and the sample topic data to obtain a first predicted word; and to perform a word-by-word prediction on the identity sample data and the sample topic data using historical text data to obtain each second predicted word; wherein the word in the historical text data that has the same arrangement position as the first predicted word is used to guide the prediction of the first second predicted word, and the designated word in the historical text data is used to guide the prediction of subsequent second predicted words, and the designated word is the word in the arrangement position of the currently predicted second predicted word in the historical text data and the word before the arrangement position of the currently predicted second predicted word; the first predicted word and each second predicted word are concatenated in the prediction order to obtain text prediction data.

[0140] In some embodiments, the training module is further configured to determine, for each sample data, the difference between the words in the same arrangement position in the text prediction data and the historical text data, and determine the total difference corresponding to each sample data based on the differences; determine the loss value based on the total difference of each sample data; and fine-tune the large language model based on the loss value to obtain the model parameters after fine-tuning the large language model.

[0141] In some embodiments, the training module is further configured to adjust the matrix data in a preset first matrix and a preset second matrix based on the loss value, wherein the first matrix and the second matrix are low-rank matrices of the initial parameter matrix; based on the initial parameter matrix and the first matrix and the second matrix after the matrix data are adjusted, the model parameters after fine-tuning the large language model are obtained.

[0142] The embodiment of the present disclosure provides a computer program product, which includes: a computer program or executable instructions, which are stored in a computer-readable storage medium. The processor of the computer device reads the computer program or executable instructions from the computer-readable storage medium, and the processor executes the computer program or executable instructions, so that the computer device executes the text generation method described in the embodiment of the present disclosure.

[0143] The present disclosure provides a computer-readable storage medium on which a computer program or executable instruction is stored. When the computer program or executable instruction is executed by a processor, the processor will execute the text generation method provided by the present disclosure. For example, Figure 3 The text generation method shown.

[0144] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EP ROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.

[0145] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0146] As an example, executable instructions may, but need not necessarily, correspond to a file in a file system, may be stored as part of a file storing other programs or data, for example, in one or more scripts stored in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions). As an example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected by a communication network.

[0147] The above description is only an embodiment of the present disclosure and is not intended to limit the protection scope of the present disclosure. Any modification, equivalent replacement and improvement made within the spirit and scope of the present disclosure are included in the protection scope of the present disclosure.

Claims

1. A text generation method, It is characterized in that The method comprises: Get the topic data of the specified topic and the identity data of the specified user; Based on the topic data and the identity data, a trained text generation model is used to predict and concatenate multiple prediction words to obtain text data; the text data is targeted at the designated topic and conforms to the identity of the designated user; The text generation model is obtained by training a preset large language model based on identity sample data of sample users, sample topic data of sample topics, and historical text data associated with the sample topics.

2. The method according to claim 1, It is characterized in that The designated user is a target user of a social media platform; the text data includes a plurality of pieces of social text data; the method further includes: In response to detecting a selection instruction for the plurality of pieces of social text data, determining the social text data indicated by the selection instruction as target social text data; Based on the target user's account, the target social text data is published.

3. The method according to claim 1 or 2, It is characterized in that The method of predicting and concatenating a plurality of predicted words based on the topic data and the identity data using a trained text generation model to obtain text data includes: Based on the topic data and the identity data, generating data to be processed in a preset format; The data to be processed is input into the trained text generation model for word-by-word prediction processing, and the predicted multiple predicted words are spliced ​​in the prediction order to obtain output text data.

4. The method according to claim 1 or 2, It is characterized in that The topic data includes at least one of the following: topic name, topic introduction, topic keywords; The identity data includes at least one of the following: the name of the designated user, the gender of the designated user, the occupation of the designated user, the educational background of the designated user, and the field of expertise of the designated user.

5. The method according to claim 1 or 2, It is characterized in that The training method of the text generation model comprises: Acquire a sample data set; wherein each sample data in the sample data set includes at least identity sample data of a sample user, sample topic data of a sample topic, and historical text data associated with the sample topic; The large language model is iteratively trained based on the sample data set until the text generation model is obtained by meeting the convergence condition, and each iterative training process includes: For each sample data, based on the identity sample data and the sample topic data, the large language model is used to predict and concatenate multiple prediction words to obtain text prediction data; wherein the text prediction data is targeted at the sample topic and conforms to the identity of the sample user; Based on the difference between the text prediction data corresponding to each sample data and the historical text data, the large language model is fine-tuned to obtain model parameters of the large language model after fine-tuning.

6. The method according to claim 5, It is characterized in that The method of predicting and concatenating multiple predicted words using the large language model for each sample data based on the identity sample data and the sample topic data to obtain text prediction data includes: For each sample data, based on the identity sample data and the sample topic data, the large language model is used to make a first prediction to obtain a first predicted word; and the identity sample data and the sample topic data are predicted word by word using the historical text data to obtain each second predicted word; The word in the historical text data that is in the same arrangement position as the first predicted word is used to guide the prediction of the first second predicted word, and the designated word in the historical text data is used to guide the prediction of the subsequent second predicted word, and the designated word is the word in the historical text data that is in the arrangement position of the currently predicted second predicted word and the word in the position before the arrangement position of the currently predicted second predicted word; The first predicted word and each second predicted word are concatenated in a prediction order to obtain the text prediction data.

7. The method according to claim 6, It is characterized in that The method of fine-tuning the large language model based on the difference between the text prediction data corresponding to each sample data and the historical text data to obtain the model parameters of the large language model after fine-tuning includes: For each sample data, determine the difference between the words in the same arrangement position in the text prediction data and the historical text data, and determine the total difference corresponding to each sample data based on the differences; Determine the loss value based on the total difference of each sample data; The large language model is fine-tuned based on the loss value to obtain model parameters of the large language model after fine-tuning.

8. The method according to claim 7, It is characterized in that The fine-tuning of the large language model based on the loss value to obtain model parameters after fine-tuning the large language model includes: Adjusting matrix data in a preset first matrix and a preset second matrix based on the loss value, wherein the first matrix and the second matrix are low-rank matrices of the initial parameter matrix; Based on the initial parameter matrix, the first matrix and the second matrix after the matrix data are adjusted, the model parameters of the large language model are obtained after fine-tuning.

9. A text generation device, It is characterized in that The device comprises: an acquisition module configured to acquire topic data of a specified topic and identity data of a specified user; A processing module configured to predict and concatenate multiple prediction words based on the topic data and the identity data using a trained text generation model to obtain text data; the text data is for the specified topic and conforms to the identity of the specified user; The text generation model is obtained by training a preset large language model based on identity sample data of sample users, sample topic data of sample topics, and historical text data associated with the sample topics.

10. An electronic device, It is characterized in that include: Memory for storing executable instructions or computer programs; A processor, configured to implement the method according to any one of claims 1 to 8 when executing the executable instructions or computer programs stored in the memory.

11. A computer-readable storage medium having a computer program or executable instructions stored thereon, It is characterized in that When the computer program or the executable instruction is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

12. A computer program product comprising a computer program or executable instructions, It is characterized in that When the computer program or the executable instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • Text display method and device, electronic equipment and computer readable medium

    CN119398061A