Comment generation method and device, equipment, storage medium and computer program product
By obtaining the data to be reviewed and its characteristic information and using the trained review generation model for word-by-word prediction processing, the problem of insufficient accuracy and applicability of review generation in the existing technology is solved, and highly relevant and personalized reviews are achieved. of generation.
Patent Information
- Application Number
- CN202410735999.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-06
AI Technical Summary
The existing technology is difficult to achieve complex and diverse text generation tasks when generating comments, especially when positive comments need to be generated according to specific instructions and styles, and the accuracy is low.
By obtaining the data to be reviewed and its characteristic information, the trained review generation model is used for word-by-word prediction processing to generate review data that conforms to the review indication information. The model is iteratively trained based on the commented sample data, comment indication samples and associated comment sample data, and the model parameters are adjusted to improve the accuracy and applicability of the generation.
It improves the correlation and accuracy between the comment data and the data to be commented, realizes the generation of personalized comments according to specific needs, and enhances the flexibility and accuracy of comment generation.
Smart Images

Figure CN118607481A
Abstract
Description
Technical Field
[0001] The present application relates to natural language processing technology, and in particular to a comment generation method, apparatus, device, storage medium and computer program product. Background Art
[0002] There are a certain number of official media accounts on media platforms. Official media accounts usually publicize or report some social current affairs or current political and livelihood news. For such materials, media platforms can make some positive comments in the comment area to liven up the atmosphere of the comment area and attract more users to discuss, thereby enhancing the publicity effect of official media accounts. Media platforms usually use various models to generate corresponding comments for such materials, but current models are often limited to relatively single and simple text generation tasks. When generalized to more complex and extensive data and tasks, the accuracy of generated text is usually low. Summary of the invention
[0003] The embodiments of the present application provide a comment generation method, device, storage medium and computer program product, which can improve the correlation between generated comment data and data to be commented on, and improve the accuracy of the comment data.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] An embodiment of the present application provides a comment generation method, comprising: obtaining data to be commented on and comment indication information for the data to be commented on; wherein the comment indication information includes feature information of the data to be commented on and / or feature information of comment data to be generated; based on the data to be commented on and the comment indication information, using a trained comment generation model to perform word-by-word prediction processing on the data to be commented on in accordance with the comment indication information, to obtain comment data formed by splicing a plurality of predicted words in a prediction order; wherein the comment generation model is obtained by training a preset large language model based on commented sample data, comment indication samples for the commented sample data, and comment sample data associated with the commented sample data.
[0006] An embodiment of the present application provides a comment generation device, comprising: a first acquisition module, used to acquire data to be commented on and comment indication information for the data to be commented on; wherein the comment indication information includes feature information of the data to be commented on and / or feature information of comment data to be generated; a generation module, used to perform word-by-word prediction processing on the data to be commented on in accordance with the comment indication information using a trained comment generation model based on the data to be commented on and the comment indication information, to obtain comment data formed by splicing multiple predicted words in a prediction order; wherein the comment generation model is obtained by training a preset large language model based on commented sample data, comment indication samples for the commented sample data, and comment sample data associated with the commented sample data.
[0007] In some possible implementations, the device further includes: a second acquisition module, configured to acquire a sample data set; wherein each sample data in the sample data set includes at least commented sample data, a comment indication sample for the commented sample data, and comment sample data associated with the commented sample data; wherein the comment indication sample includes feature information of the commented sample data and / or feature information of the comment sample data; an iteration module, configured to iteratively train the large language model based on the sample data set until the comment generation model is obtained by meeting the convergence condition, wherein each iterative training process includes: for each sample data, based on the commented sample data and the comment indication sample for the commented sample data, using the large language model to perform word-by-word prediction processing on the commented sample data in accordance with the comment indication sample, to obtain comment prediction data formed by splicing multiple predicted words in a prediction order; and based on the difference between the comment prediction data corresponding to each sample data and the comment sample data, fine-tuning the large language model to obtain model parameters after fine-tuning the large language model.
[0008] In some possible implementations, the second acquisition module is used to determine the commented sample data and the comment sample data in the sample data set based on the acquired historical commented data and the historical comment data associated with the historical commented data; wherein, one historical commented data is one commented sample data, and one historical comment data is one comment sample data; for each commented sample data, feature information of the associated commented sample data and / or feature information of the comment sample data is extracted, and a comment indication sample of the commented sample data is generated based on the extracted feature information.
[0009] In some possible implementations, the characteristic information of the comment sample data includes the language style characteristics of the comment sample data; the second acquisition module is used to classify the comment sample data using a preset language style classification model for each comment sample data to obtain a language style classification result of the comment sample data; wherein the language style classification result of the comment sample data is used to characterize the language style characteristics of the comment sample data; based on the language style classification result of each comment sample data, a comment indication sample including the language style characteristics of each comment sample data is generated.
[0010] In some possible implementations, the characteristic information of the comment sample data includes the sentiment polarity characteristics of the comment sample data; the second acquisition module is used to classify the comment sample data using a preset sentiment polarity classification model for each comment sample data, and obtain a sentiment polarity classification result of the comment sample data; wherein the sentiment polarity classification result of the comment sample data is used to characterize the sentiment polarity characteristics of the comment sample data; based on the sentiment polarity classification result of each comment sample data, a comment indication sample including the sentiment polarity characteristics of each comment sample data is generated.
[0011] In some possible implementations, the characteristic information of the comment sample data includes the frequency characteristics of the comment sample data; the second acquisition module is used to perform clustering processing on the comment sample data associated with the comment sample data to obtain comment sample clusters associated with comment content topics; determine the number of comment sample data included in each comment sample cluster; for each comment sample data, based on the number of comment sample data included in the comment sample cluster to which it belongs, generate a comment indication sample including the frequency characteristics of each comment sample data; wherein the number of comment sample data included in the comment sample cluster to which the comment sample data belongs is used to characterize the frequency characteristics of the comment sample data.
[0012] In some possible implementations, the characteristic information of the commented sample data includes a first user characteristic of the commented sample data, and the characteristic information of the comment sample data includes a second user characteristic of the comment sample data. The second acquisition module is used to obtain, for each comment sample data, the first user information of the commented sample data associated with the comment sample data, and / or obtain the second user information of the comment sample data; perform feature extraction on the first user information and / or the second user information associated with each comment sample data; generate a comment indication sample including the first user characteristic based on the extracted characteristics of the first user information; and / or generate a comment indication sample including the second user characteristic based on the extracted characteristics of the second user information.
[0013] In some possible implementations, the iteration module is used to generate sample data to be processed in a preset format based on the commented sample data and the comment indication sample; based on the sample data to be processed, use the large language model to perform word-by-word prediction processing, and concatenate multiple predicted words in a prediction order to form the comment prediction data.
[0014] In some possible implementations, the iteration module is used to determine, for each sample data, the difference between the comment prediction data and the comment sample data; determine a loss value based on the 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.
[0015] In some possible implementations, the iteration module is used 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 an initial parameter matrix; based on the initial parameter matrix, the first matrix and the second matrix after the matrix data are adjusted, obtain the model parameters after fine-tuning the large language model.
[0016] An embodiment of the present application provides an electronic device, including:
[0017] A memory for storing executable instructions or computer programs;
[0018] The processor is used to implement the comment generation method provided in the embodiment of the present application when executing the executable instructions or computer programs stored in the memory.
[0019] An embodiment of the present application provides a computer-readable storage medium having a computer program or executable instructions stored thereon, which is used to cause a processor to execute and implement the comment generation method provided in the embodiment of the present application.
[0020] An embodiment of the present application 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 comment generation method provided in the embodiment of the present application is implemented.
[0021] The embodiments of the present application have the following beneficial effects:
[0022] The disclosed embodiment of the method is to obtain comment data by obtaining data to be commented on and comment indication information for the comment data, and using a trained comment generation model to process the data to be commented on in accordance with the comment indication information to obtain comment data. On the one hand, since the data to be commented on and the comment indication information are obtained, and the comment indication information includes characteristic information of the data to be commented on and / or characteristic information of the comment data to be generated, the obtained comment data is obtained based on the data to be commented on and the comment indication information, which can improve the correlation between the comment data and the data to be commented on, and can generate corresponding comment data according to the comment indication information, that is, it is possible to generate personalized comment data according to specific needs, realize customization of comment data, and improve the accuracy of comment data; on the other hand, since the comment generation model in the disclosed embodiment is obtained by training a large language model based on commented sample data, comment indication samples for the commented sample data, and comment sample data associated with the commented sample data, it has the ability to generate comment data that conforms to the comment indication information according to the data to be commented on, and has strong applicability and flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic diagram of the architecture of a review generation system provided in an embodiment of the present application;
[0024] Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0025] Figure 3 It is an optional flow chart of a comment generation method provided in an embodiment of the present application;
[0026] Figure 4 It is an optional flow chart of a method for training a large language model provided in an embodiment of the present application;
[0027] Figure 5 It is an optional flow chart of a fine-tuning model method provided in an embodiment of the present application;
[0028] Figure 6 It is an optional flow chart of a matrix fine-tuning method provided in an embodiment of the present application;
[0029] Figure 7 It is a structural schematic diagram of a matrix fine-tuning method provided in an embodiment of the present application;
[0030] Figure 8 This is an optional flow chart of a method for obtaining a sample data set provided in an embodiment of the present application;
[0031] Fig. 9 It is an optional flow chart of a method for processing a sample of comment indications provided in an embodiment of the present application;
[0032] Fig.10 It is an optional flow chart of another comment generation method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0034] 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.
[0035] In the following description, the terms "first\second\third" 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\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0036] 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 this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0037] There are a certain number of official media accounts on media platforms. Official media accounts usually publicize or report some social current affairs or current political and people's livelihood news. For such materials, media platforms can make some positive comments and replies in the comment area to liven up the atmosphere of the comment area and attract more users to discuss, thereby enhancing the propaganda effect of official media accounts.
[0038] There is a text generation scheme in the related art. The scheme uses a deep learning network model including an encoder-decoder structure for modeling, and uses its own data for model training to obtain a text generation model. However, the text generation model in the scheme can only generate text according to the knowledge in the training data, and usually can only achieve relatively single and simple text generation tasks, and is difficult to generalize to more general and broader data or tasks. For example, when faced with a more complex and diverse text generation requirement such as "need to generate a positive and Weibo-style post, and reply in the tone of an old Weibo user", the text generation model finds it difficult to understand the above instructions and generate targeted text for the instructions, and the accuracy of the generated text is low.
[0039] There is also a text generation solution in the related art, which uses an open source Large Language Model (LLM) and performs supervised fine-tuning (SFT) on this basis. Since the large language model has been pre-trained using massive amounts of data, the model itself covers a large amount of knowledge and includes common natural language processing task capabilities, and can already complete some simple text generation tasks. Supervised fine-tuning on this basis can effectively improve performance on specific tasks. However, since the fine-tuning data and the design of the solution will affect the final text generation effect, it is difficult to achieve the level of controllable comment generation by simply using blog post and comment data for fine-tuning. The model still finds it difficult to understand task instructions and generate ideal comments. That is, the solution of the related art still finds it difficult to complete text generation tasks with more complex instructions, and the accuracy of the generated text is low.
[0040] In response to the above technical problems, the embodiments of the present application provide a comment generation method, apparatus, device, storage medium and computer program product, which can improve the correlation between the generated comment data and the data to be commented on, and improve the accuracy of the comment data.
[0041] The following describes an exemplary application of the electronic device provided by the embodiment of the present application. The electronic device provided by the embodiment of the present application can be implemented as various types of user terminals such as a laptop computer, a tablet computer, a desktop computer, a set-top box, a mobile device (for example, a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, a portable gaming device), and can also be implemented as a server. The following describes an exemplary application when the device is implemented as a server.
[0042] See also Figure 1 , Figure 1 Schematic diagram of the architecture of a review generation system 1 provided in an embodiment of the present application. To implement the review generation method in an embodiment of the present application, an electronic device ( Figure 1 Only two electronic devices are shown, but this does not constitute a limitation on the number of electronic devices included in the system for generating comments in the embodiment of the present application) The server 100 is connected via a network 300, and the network 300 can be a wide area network or a local area network, or a combination of the two.
[0043] In some possible implementations, user A may publish data A to be commented on through electronic device 200-1, and user B may publish data B to be commented on through electronic device 200-2. Data A to be commented on and data B to be commented on are uploaded to server 100 through network 300. Server 100 may also receive comment indication information of user A, user B or other users on data A to be commented on or data B to be commented on. It should be noted that the way in which server 100 obtains comment indication information of data to be commented on and data to be commented on may be the same or different. Server 100 may obtain comment indication information of data to be commented on and data to be commented on from the same electronic device, or server 100 may obtain comment indication information of data to be commented on and data to be commented on from different electronic devices. For example, server 100 may obtain data A to be commented on from electronic device 200-1, and obtain comment indication information of data A to be commented on from electronic device 200-2. This is not limited in the embodiments of the present invention. The server 100 can generate comment data A for the data to be commented on that complies with the comment indication information for the comment data A based on the data to be commented on and the comment indication information for the comment data A through the comment generation method provided in the embodiment of the present application, so that the comment data A can be displayed on the graphical interface 410 of the electronic device 400 (graphic interface 210-1 and graphical interface 210-2 are shown as examples).
[0044] In some embodiments, the server 100 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 speaker, 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 invention.
[0045] See also Figure 2 , Figure 2 2 is a schematic diagram of the structure of an electronic device 200 provided in an embodiment of the present application. It should be noted that: Figure 2 The electronic device 200 shown may be Figure 1Any one of the two electronic devices shown in the figure may also be other electronic devices, and the embodiments of the present application are not limited to this. 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 .
[0046] 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.
[0047] 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.
[0048] 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.
[0049] The memory 250 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile 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 application is intended to include any suitable type of memory.
[0050] 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.
[0051] 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;
[0052] 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 Fidelity (Wi-Fi), and Universal Serial Bus (USB);
[0053] 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);
[0054] 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.
[0055] In some embodiments, the device provided in the embodiments of the present application can be implemented in software. Figure 2 The comment 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: a first acquisition module 2551 and a generation 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.
[0056] In other embodiments, the device provided in the embodiments of the present application can be implemented in hardware. As an example, the device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the comment generation method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can 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.
[0057] In some embodiments, the electronic device or server can implement the comment generation method provided in the embodiments of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a local application (APP, Application), that is, a program that needs to be installed in the operating system to run, such as a text generation APP; it can also be a small program, that is, a program that can be run only by downloading it to a browser environment; it can also be a small program that can be embedded in any APP. In short, the above-mentioned computer program can be any form of application, module or plug-in.
[0058] The review generation method provided in the embodiment of the present application will be described below in conjunction with the exemplary application and implementation of the electronic device provided in the embodiment of the present application.
[0059] See also Figure 3 , Figure 3 This is an optional flow chart of a comment generation method provided in an embodiment of the present application, which will be combined with Figure 3 The steps shown are explained.
[0060] In step S301, data to be reviewed and review indication information for the data to be reviewed are obtained.
[0061] It should be noted that the comment generation method proposed in the present disclosure can be applied to electronic devices as well as servers. Here, electronic devices may include: terminal devices, for example, mobile terminals or fixed terminals. Among them, mobile terminals may include: mobile phones, tablet computers, laptop computers and other devices. Fixed terminals may include: desktop computers, smart TVs, etc. As a type of computer, a server can provide computing or application services for other clients (such as computers, smart phones, ATMs and other terminal devices, and even large devices such as train systems) in the network.
[0062] The execution subject of the embodiments of the present disclosure may be, for example, a central processing unit (CPU) in a server or electronic device in terms of hardware, or may be, for example, a related background service in a server or electronic device in terms of software, without limitation.
[0063] The comment generation method in the embodiment of the present disclosure may also be configured in a comment generation device, which may be set in a server or in an electronic device. The embodiment of the present disclosure is not limited to this. The embodiment of the present disclosure is described by taking the comment generation device as the execution subject as an example.
[0064] In the disclosed embodiment, the comment generating device obtains data to be commented on, wherein the data to be commented on includes data posted by users on a media platform. The users may be official media accounts or ordinary users. For example, when the media platform is "Weibo", the data to be commented on may be a blog post posted by an official media account on the Weibo platform.
[0065] In the embodiments of the present disclosure, the data to be commented on may be text data, such as microblog copywriting, news reports, blog articles, etc.; the data to be commented on may also be image or video data, such as photographic works, product images, movie clips, short videos, etc.; the data to be commented on may also be audio data, such as audio books, audio blogs, song clips, etc.; the embodiments of the present disclosure are not limited to this.
[0066] In the embodiments of the present disclosure, the comment generation device can obtain the data to be commented on by means of a web crawler; the comment generation device can also call the data to be commented on through a predetermined programming interface (Application Programming Interface, API); the comment generation device can also obtain the data to be commented on from a database or data set storing the data to be commented on through a data processing tool, and the embodiments of the present disclosure are not limited to this.
[0067] In the disclosed embodiment, the comment generation device also obtains comment indication information for the comment data to be commented on, wherein the comment indication information includes characteristic information of the data to be commented on and / or characteristic information of the comment data to be generated. For example, the comment indication information may include publisher information of the data to be commented on, keywords of the data to be commented on, sentiment polarity of the comment data to be generated, theme or angle of the comment data to be generated, style of the comment data to be generated, length of the comment data to be generated, keywords of the comment data to be generated, user persona of the comment data to be generated, target audience of the comment data to be generated, and other information. For example, the comment indication information may be "Given a blog post published by Xinhua News Agency, simulate the tone of a new Weibo user and write a positive comment." The data to be commented on corresponding to the comment indication information is a blog post published by Xinhua News Agency. The comment indication information includes publisher information of the data to be commented on (Xinhua News Agency), user persona of the comment data to be generated (new Weibo user), and sentiment polarity of the comment data to be generated (positive).
[0068] In the embodiments of the present disclosure, the comment generating device can obtain comment indication information through the interaction between the user and the input interface. For example, when the comment generating device is set in an electronic device, the electronic device may also include a user interface. The electronic device can receive the comment indication information input by the user through a keyboard, touch screen or other input device through the user interface, and send the comment indication information to the comment generating device. The comment generating device can also call the comment indication information through an API interface. It should be noted that the API interface called by the comment generating device to obtain the data to be commented on and the API interface called by the comment generating device to obtain the comment indication information may be the same or different. Of course, the comment generating device can also obtain the data to be commented on and the comment indication information of the data to be commented on through other methods, which is not limited by the embodiments of the present disclosure.
[0069] In step S302, based on the data to be reviewed and the review indication information, a trained review generation model is used to perform word-by-word prediction processing on the data to be reviewed that conforms to the review indication information, and review data formed by splicing multiple predicted words in a prediction order is obtained.
[0070] In the disclosed embodiment, the comment generation model is obtained by training a preset large language model based on commented sample data, comment indication samples of the commented sample data, and comment sample data associated with the commented sample data. It should be noted that the commented sample data, comment indication samples of the commented sample data, and comment sample data associated with the commented sample data can be user input or historical data. The large language model refers to a deep learning model trained based on a large amount of text data, which can generate relatively natural language text, deeply understand the meaning of the text, and handle various natural language tasks, such as text summarization, question and answer, translation, etc. There are many types of large language models. For example, based on different architectures, large language models can be divided into transformer models and recurrent neural network (RNN) models; based on scenarios or task types, large language models can be divided into specific domain models, such as models for the financial field and multimodal models (models that can process multiple modal data such as text, images, and sounds); based on the output method, large language models can be divided into generative models, discriminative models, conversational models, etc. The embodiments of the present disclosure can select a large language model for training according to specific circumstances, and the embodiments of the present disclosure do not specifically limit the large language model.
[0071] For example, in some embodiments, the preset large language model may be an open source large language model, where open source means open source code. Specifically, the preset large language model may be the Baichuan2 model. Since the Baichuan2 model uses a corpus of 2.6 trillion words or tokens, the scale of the deduplication and clustering system is large, and the word segmenter and position encoding are optimized, it can balance the computational efficiency and model performance, and the training stability is also high. The comment generation model obtained by training based on the Baichuan2 model, on the one hand, can balance the computational efficiency and model performance, has high intelligence and strong applicability and flexibility. On the other hand, training based on the preset large language model to obtain the comment generation model can save time and resources for building the model.
[0072] In some embodiments, historical commented data is used as commented sample data, and historical comment data associated with the historical commented data is used as comment sample data, and for each comment sample data, a comment indication sample of the commented sample data is determined based on the commented sample data and features of the comment sample data, and based on the commented sample data, the comment sample data and the comment indication sample, a sample data set is constructed to iteratively train the large language model, so that the large language model has the ability to understand the data to be commented on and generate comment data that conforms to the comment indication information for the data to be commented on.
[0073] In the embodiment of the present disclosure, after the comment generation device obtains the data to be commented on and the comment indications for the comment data, it uses a trained comment generation model to perform word-by-word prediction processing on the comment data in accordance with the comment indication information based on the data to be commented on and the comment indication information, and obtains comment data formed by splicing multiple predicted words in a prediction order.
[0074] In some embodiments, the comment data and comment indication information may be preprocessed first, and the preprocessed data may be input into a trained comment generation model for word-by-word prediction processing to obtain comment data formed by splicing multiple predicted words in a predicted order, wherein the preprocessing includes word segmentation, keyword extraction, removal of irrelevant characters, conversion into corresponding vector representations, etc.
[0075] In other embodiments, the comment indication information of the review data set can be directly input into a trained comment generation model, so that the comment generation model can be used to perform word-by-word prediction processing on the review data that conforms to the comment indication information, and obtain comment data formed by splicing multiple predicted words in a prediction order.
[0076] In the disclosed embodiment, the comment generation model can encode the data to be commented on and the comment indication information to obtain multiple word vector features, and the word vector features are used to symbolize context information; according to the comment generation ability for the data to be commented on and the language rules that conform to the comment indication information learned by the comment 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, the first word in the output comment data is predicted (the above words can be formed by words, numbers, letters or characters, and the word by word here is not limited to a single word, but can also be a short sentence, etc.); after obtaining the first word of the output comment data, the first word is added to the word vector features representing the context information as the basis for predicting the next word; based on this, the model can continuously perform word prediction until the predicted word is a termination character, and then all predicted words are spliced in the predicted order to output the comment data.
[0077] In the embodiments of the present disclosure, the comment generation model may also generate comment data that conforms to the comment indication information for the data to be commented on by means of whole sentence generation, template matching, speech analysis, etc., and the embodiments of the present disclosure do not impose any limitation on this.
[0078] In the disclosed embodiments, during the generation process, the review generation model may use various natural language processing technologies, such as text generation algorithms, grammatical rules, semantic understanding and other technologies, to improve the probability that the generated review data not only conforms to grammatical specifications but also can accurately convey the analysis and evaluation of the review data. After generating the review data, the review generation model may also perform post-processing on the review data, such as removing duplications and correcting grammar, to improve the fluency of the review data. It should be noted that the above-mentioned process of pre-processing the review data and the review indication information may occur within the review generation model or in other modules of the review generation device. Similarly, the above-mentioned process of post-processing the review data may occur within the review generation model or in other modules of the review generation device.
[0079] The disclosed embodiment of the method is to obtain comment data by obtaining data to be commented on and comment indication information for the comment data, and using a trained comment generation model to process the data to be commented on in accordance with the comment indication information to obtain comment data. On the one hand, since the data to be commented on and the comment indication information are obtained, and the comment indication information includes characteristic information of the data to be commented on and / or characteristic information of the comment data to be generated, the obtained comment data is obtained based on the data to be commented on and the comment indication information, which can improve the correlation between the comment data and the data to be commented on, and can generate corresponding comment data according to the comment indication information, that is, it is possible to generate personalized comment data according to specific needs, realize customization of comment data, and improve the accuracy of comment data; on the other hand, since the comment generation model in the disclosed embodiment is obtained by training a large language model based on commented sample data, comment indication samples for the commented sample data, and comment sample data associated with the commented sample data, it has the ability to generate comment data that conforms to the comment indication information according to the data to be commented on, and has strong applicability and flexibility.
[0080] In the embodiment of the present disclosure, as mentioned above, the comment generation device also needs to train the preset large language model to obtain the comment generation model. Figure 4 , Figure 4 This is an optional flow chart of a method for training a large language model provided in an embodiment of the present application. Figure 4 The steps shown illustrate the training process of a large language model.
[0081] In step S401, a sample data set is obtained.
[0082] Each sample data in the sample data set includes at least commented sample data, comment indication samples on the commented sample data, and comment sample data associated with the commented sample data; wherein the comment indication samples include feature information of the commented sample data and / or feature information of the comment sample data;.
[0083] In the disclosed embodiments, the comment generation device first obtains a sample data set. In some embodiments, the comment generation device may obtain historical commented data and comment data associated with the historical commented data, and then generate a corresponding comment indication sample based on the characteristic information of the historical commented data and / or the characteristic information of the comment data associated with the historical commented data, and use this as the sample data set.
[0084] In other embodiments, the comment generating device may directly obtain the commented sample data input by the user, the comment indication sample of the commented sample data, and the comment sample data associated with the commented sample data.
[0085] In other embodiments, the comment generation device may also obtain sample data sets based on generative models such as generative adversarial networks (GANs). For example, GANs can generate commented sample data, comment sample data associated with the commented sample data, and can generate comment indication samples for the commented sample data based on the commented sample data and the comment sample data.
[0086] In the disclosed embodiment, after acquiring the sample data set, the comment generation device formats the sample data according to a preset format that can be recognized by the large language model. That is, the sample data is processed into a format that can be recognized by the large language model.
[0087] In step S402, the large language model is iteratively trained based on the sample data set until a convergence condition is met to obtain the comment generation model.
[0088] In the embodiments of the present disclosure, the convergence condition may be that the difference between the predicted comment data generated based on the large language model and the comment sample data is less than a preset difference threshold; the convergence condition may also be that the number of times the large language model parameters are adjusted is greater than a preset number threshold; the convergence condition may also be that the number of times all sample data in the sample data set are traversed is greater than a preset traversal number threshold, wherein the preset difference threshold, the preset number threshold and the preset traversal number threshold are all set values, such as the preset traversal number threshold may be set to 2, and the embodiments of the present disclosure do not impose any restrictions on this.
[0089] Step S403 and step S404 are the process of each iterative training of the large language model.
[0090] In step S403, for each sample data, based on the commented sample data and the comment indication sample of the commented sample data, the large language model is used to perform word-by-word prediction processing on the commented sample data that conforms to the comment indication sample, and obtain comment prediction data formed by splicing multiple predicted words in a prediction order.
[0091] In the disclosed embodiment, the comment generation device performs word-by-word prediction processing on the commented sample data that conforms to the comment indication sample using a large language model for each sample data based on the commented sample data and the comment indication sample of the commented sample data, and obtains comment prediction data formed by splicing multiple predicted words in a prediction order.
[0092] In the disclosed embodiment, the large language model first encodes 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 commented sample data and the comment indication sample, the large language model performs the first prediction to determine the first predicted word; after obtaining the first predicted word, the large language model predicts the first second predicted word based on the word vector features corresponding to the commented sample data and the comment indication sample, and the word vector features corresponding to the words in the comment sample data with the same arrangement position as the first predicted word; based on this prediction method, the subsequent second predicted words are predicted again until the currently predicted second predicted word is a termination symbol, wherein the large language model can pre-set the termination symbol, such as "," or until the arrangement position of the currently predicted second predicted word corresponds to the last arrangement position in the comment sample 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 the comment prediction data. Wherein, the first predicted word and the second predicted word can both be formed by words, numbers, letters or characters, and the disclosure does not limit this.
[0093] It should be noted that the large language model can provide a context window for generating comment 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 comment sample 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.
[0094] 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.
[0095] In the disclosed embodiment, as mentioned above, the commented data and the comment indication samples may be preprocessed first so that the large language model can understand and perform subsequent processing. The preprocessing includes word segmentation, keyword extraction, removal of irrelevant characters, conversion to corresponding vector representations, etc. The large language model performs word-by-word prediction processing on the preprocessed commented sample data in accordance with the comment indication samples to obtain comment prediction data formed by splicing multiple predicted words in a predicted order. During the generation process, the large language model may use various natural language processing technologies, such as text generation algorithms, grammatical rules, semantic understanding and other technologies to improve the probability that the generated comment prediction data not only conforms to grammatical specifications, but also can accurately convey the analysis and evaluation of the commented data. After generating the comment prediction data, the large language model may also perform post-processing such as removing duplications and correcting grammar on the comment prediction data to improve the fluency of the comment prediction data.
[0096] It should be noted that the above-mentioned process of preprocessing the commented data and comment indication samples can occur within the large language model, and can also occur in other modules in the comment generation device. Similarly, the above-mentioned process of post-processing the comment prediction data can occur within the large language model, and can also occur in other modules in the comment generation device.
[0097] In step S404, based on the difference between the comment prediction data corresponding to each sample data and the comment sample data, the large language model is fine-tuned to obtain model parameters of the large language model after fine-tuning.
[0098] In the disclosed embodiment, the comment generation device fine-tunes the large language model based on the difference between the comment prediction data corresponding to each sample data and the comment sample data, wherein fine-tuning the large language model means adjusting the parameters of the large language model to obtain the model parameters of the large language model after fine-tuning, wherein the comment generation device can determine the difference between the comment prediction data and the comment sample data through methods such as bilingual evaluation understudy (BLEU), recall-oriented summary evaluation (ROUGE), cosine similarity, and Euclidean distance, and use the difference as a loss value to adjust the parameters of the large language model, such as using an optimization algorithm to update the parameters of the large language model, and the optimization algorithm can be a gradient descent method, an adaptive learning rate (Adaptive Moment Estimation, Adam) method, and the like.
[0099] Figure 5 This is an optional flow chart of a fine-tuning model method provided in an embodiment of the present application. Figure 5 The steps S501 to S503 shown in the figure introduce the implementation process of the fine-tuning model in the above step S404.
[0100] In step S501, for each sample data, the difference between the comment prediction data and the comment sample data is determined.
[0101] In the disclosed embodiment, as described above, for each sample data, the comment generation device can determine the difference between the comment prediction data and the comment sample data by using methods such as the BLEU method, the ROUGE method, the cosine similarity method, and the Euclidean distance method.
[0102] In some embodiments, the comment generation device may perform sentiment analysis on the comment prediction data and the comment sample data, determine the sentiment polarity of the comment prediction data and the comment sample data, and compare whether the sentiment tendencies of the two are consistent. If not, the similarity between the comment prediction data and the comment sample data may be low.
[0103] In other embodiments, the comment generation device may extract keywords or key phrases from the comment prediction data and sample data, and compare whether the meanings of the keywords in the two are consistent. If not, the similarity between the comment prediction data and the comment sample data may be low.
[0104] In other embodiments, the comment generation device may analyze the subject or style of the comment prediction data and the sample data, and compare whether the subject or style of the two are consistent. If not, the similarity between the comment prediction data and the comment sample data may be low.
[0105] In step S502 , a loss value is determined based on the difference of each sample data.
[0106] In the disclosed embodiment, the comment generating device determines the loss value based on the difference between the comment prediction data and the comment sample data in each sample data. The smaller the difference, the smaller the loss value is usually.
[0107] In step S503, the large language model is fine-tuned based on the loss value to obtain model parameters after fine-tuning the large language model.
[0108] In the disclosed embodiment, the comment generation device fine-tunes the large language model based on the loss value. The comment generation device can use a supervised fine-tuning (SFT) method or an unsupervised fine-tuning method to fine-tune the large language model based on the loss value. For example, the comment generation model can use an optimization algorithm to update the parameters of the large language model. The optimization algorithm can be a gradient descent method, an adaptive learning rate (Adaptive Mom ent Estimation, Adam) method, etc. The comment generation model can also fine-tune the large language model by means of an autoencoder or a generative adversarial network. This is not limited by the disclosed embodiment. It should be noted that during the fine-tuning process, the comment generation device needs to pay close attention to the changes in the loss value. As the fine-tuning proceeds, the loss value should gradually decrease, indicating that the performance of the model on the task is improving. If the loss value begins to increase after a certain point, overfitting may have occurred. At this time, it may be necessary to adjust the strategy, such as stopping training early, using regularization, etc.
[0109] In some embodiments, during the fine-tuning process of the comment generation model, a validation set can be used to evaluate the performance of the large language model, wherein the validation set is a data set different from the training sample data set, and is used to check the generalization ability of the model during the training process. For example, when the performance of the model on the validation set reaches a satisfactory level, the test set can be used for a final evaluation.
[0110] The disclosed embodiments determine the difference between comment prediction data and comment sample data, determine a loss value based on the difference, and fine-tune the large language model based on the loss value to obtain model parameters of the fine-tuned large language model, thereby improving the performance of the large language model and improving the accuracy of comment prediction data generated by the large language model.
[0111] In some embodiments, see Figure 6 , Figure 6 is an optional flow chart of a matrix fine-tuning method provided in an embodiment of the present application. Figure 5 The illustrated step S503 can be implemented through steps S601 to S602, and will be described in conjunction with each step.
[0112] In step S601, matrix data in a preset first matrix and a preset second matrix are adjusted based on the loss value.
[0113] In the disclosed embodiment, the first matrix and the second matrix are low-rank matrices of the initial parameter matrix. The comment generation device may first freeze the parameters of the initial parameter matrix, that is, during the fine-tuning process, keep the parameters of the initial parameter matrix of the large language model unchanged and do not adjust them. The comment generation device may add a preset first matrix and a preset second matrix to the large language model while freezing the parameters of the initial parameter matrix, and adjust the matrix data in the first matrix and the second matrix based on the loss value.
[0114] In some embodiments, the comment generating device may adjust only the matrix data of the first matrix based on the loss value, or may adjust only the matrix data of the second matrix based on the loss value, or may adjust both the matrix data of the first matrix and the second matrix based on the loss value. The embodiments of the present disclosure do not limit this.
[0115] In step S602, based on the initial parameter matrix, the first matrix after matrix data adjustment, and the second matrix, model parameters after fine-tuning the large language model are obtained.
[0116] In the embodiment of the present disclosure, as described above, the comment generation device has determined the initial parameter matrix, the first matrix and the second matrix after the matrix data is adjusted. The comment generation device can obtain the model parameters after fine-tuning the large language model based on the initial parameter matrix, the first matrix and the second matrix after the matrix data is adjusted.
[0117] Figure 7 is a structural diagram of a matrix fine-tuning method provided in an embodiment of the present application, such as Figure 7As shown in the figure, L1 is the initial parameter matrix, L2 is the preset first matrix, L3 is the preset second matrix, x is the input data (commented sample data, comment sample data, comment indication sample), d is the input dimension of the large language model, and h is the output data (comment prediction data). It can be seen from the figure that h is the sum of the result of the initial parameter matrix L1 and the product of the first matrix L2 and the second matrix L3, where the input dimension of the first matrix L2 is the same as the input dimension of the initial parameter matrix L1, the output dimension of the second matrix L3 is the same as the output dimension of the initial parameter matrix L1, and the output dimension of the first matrix L2 is the same as the input dimension of the second matrix L3, both of which are r. In the fine-tuning process, the comment The comment generation device can adjust the parameters of the first matrix L2 and the second matrix L3 based on the loss value of each sample data until the convergence condition is met. As mentioned above, the convergence condition can be that the difference between the predicted comment data generated based on the large language model and the comment sample data is less than a preset difference threshold; the convergence condition can also be that the number of times the parameters of the first matrix L2 and / or the second matrix L3 are adjusted is greater than a preset number threshold; the convergence condition can also be that the number of times all sample data in the sample data set are traversed is greater than a preset traversal number threshold, wherein the preset difference threshold, the preset number threshold and the preset traversal number threshold are all set values. For example, the preset traversal number threshold can be set to 2, and the embodiments of the present disclosure do not limit this.
[0118] In some embodiments, the comment generating device determines the initial parameters of the first matrix L2 by means of random Gaussian noise, and sets the initial parameters of the second matrix L3 to 0.
[0119] In the disclosed embodiment, the comment generation device only adjusts the parameters of the first matrix and / or the second matrix based on the loss value, and determines the model parameters of the large language model after fine-tuning based on the initial parameter matrix and the adjusted first matrix and second matrix. Since the first matrix and the second matrix are low-rank matrices of the initial parameter matrix, the parameter amount of the first matrix and the second matrix is much smaller than the parameter amount of the initial parameter matrix. The method of the disclosed embodiment can reduce the amount of adjusted parameters, that is, it can reduce the amount of calculation while improving the accuracy of the comment data, and is highly intelligent.
[0120] In an embodiment of the present disclosure, a sample data set is obtained, and a large language model is iteratively trained based on the sample data set until a convergence condition is met to obtain a comment generation model. On the one hand, since each sample data in the sample data set includes commented data and comment sample data associated with the commented data, training based on the sample data set can improve the correlation between the comment data generated by the comment generation model and the data to be commented on; on the other hand, through multiple iterative trainings and training based on the difference between the comment prediction data and the comment data, the risk of overfitting of the model can be reduced, the generalization ability of the model can be improved, and the accuracy of the comment data generated by the comment generation model can be improved.
[0121] In some embodiments, see Figure 8 , Figure 8 An optional flow chart of a method for obtaining a sample data set provided in an embodiment of the present application, Figure 4 The illustrated step S401 can be implemented through steps S801 to S802, which will be described in conjunction with each step.
[0122] In step S801, based on the acquired historical commented data and each historical comment data associated with the historical commented data, commented sample data and comment sample data in the sample data set are determined.
[0123] Among them, one historical commented data is one commented sample data, and one historical comment data is one comment sample data.
[0124] In the embodiments of the present disclosure, the historical commented data and each historical comment data associated with the historical commented data are historically accumulated data, which may be historical data stored in a memory space, or may be historical data captured according to preset capture conditions. For example, the historical commented data may be a blog post published historically, or may be information shared historically. The commented sample data in the sample data set may be randomly determined from the historical commented data, or may be determined according to the order of each historical data in the historical commented data, or may be determined according to the number of likes or comments on each historical data in the historical commented data, and the embodiments of the present disclosure do not impose any limitation on this.
[0125] In some embodiments, the commented sample data in the sample data set may be original blog post data, or may be preprocessed data obtained after preprocessing. Here, since the amount of data of each historical comment data associated with the historical commented data is large and the data quality varies, the comment generation device may preprocess the historical commented data and each historical comment data associated with the historical commented data to select data with higher quality as the commented sample data in the sample data set. In some embodiments, the preprocessing may be to filter out data that does not meet the preset review requirements.
[0126] In other embodiments, preprocessing can also be to unify the data volume of historical comment data associated with each commented sample data. Specifically, the comment generation device can obtain the number of likes and interactions of each historical comment data, and remove the historical comment data with the number of likes or interactions lower than a preset threshold. If the difference between the number of likes and the number of interactions of each historical comment data is small, and the data volume of the historical comment data is still large after filtering, then each historical comment data can be sorted based on the number of likes or the number of interactions of each historical comment data, and the historical comment data whose sorting result is greater than the preset sorting threshold is retained, wherein the preset threshold and the preset sorting threshold are both set values. For example, the preset sorting threshold can be set to 100, and this is not limited in the embodiments of the present disclosure.
[0127] In other embodiments, preprocessing can also be to filter out historical commented data or non-text content in historical comment data, and can also be to select content that meets preset filtering conditions from the historical commented data. For example, when the historical commented data is a blog post, blog posts with only topic words, meaningless blog posts such as voting types, blog posts containing sensitive words, filtering out blog post Uniform Resource Locators (URLs), filtering out special characters, etc. can be filtered out. It is also possible to extract content that meets preset filtering conditions after filtering out non-text content in training documents.
[0128] In other embodiments, since some users may engage in "screen swiping" behavior, that is, posting the same comment data under each commented data, the preprocessing may also be to filter the "screen swiping" comment data through a clustering algorithm, wherein the clustering algorithm includes a hierarchical clustering method, a spectral clustering method, a K-means algorithm, and the like.
[0129] The disclosed embodiment can improve the quality of commented sample data and comment sample data in the sample data set by preprocessing the historical commented data and each historical comment data associated with the commented data, thereby improving the accuracy of comments generated by the comment generation model.
[0130] In step S802, for each commented sample data, feature information of associated commented sample data and / or feature information of comment sample data is extracted, and a comment indication sample of the commented sample data is generated based on the extracted feature information.
[0131] In the disclosed embodiment, the comment generation device can extract the characteristic information of each associated commented sample data and / or the characteristic information of the comment sample data for each commented sample data, wherein the characteristic information of each associated commented sample data may include vocabulary characteristics, subject characteristics, syntactic characteristics, metadata characteristics, etc. The metadata characteristics refer to the characteristics such as the publishing time of the commented data, the identity or activity of the publisher of the commented data, etc. when the commented sample data is historical commented data, and the characteristic information of each associated comment sample data may include sentiment polarity characteristics, frequency characteristics, vocabulary characteristics, subject characteristics, syntactic characteristics, style characteristics, metadata characteristics, etc. The metadata characteristics refer to the characteristics such as the publishing time of the comment, the identity or activity of the commentator, etc. when the comment sample data is also historical comment data.
[0132] In the disclosed embodiment, the comment generation device can convert the extracted feature information into a numerical format suitable for a large language model. For example, the sentiment polarity feature can be identified as a label code (such as 0 indicates that the sentiment polarity is negative, 1 indicates that the sentiment polarity is neutral, and 2 indicates that the sentiment polarity is positive). For another example, the lexical features can also be used to convert the comment data into a numerical vector through methods such as term frequency-inverse document frequency (TF-IDF).
[0133] In the disclosed embodiment, after the comment generation device extracts features, the extracted features can be fused by splicing fusion, linear fusion, nonlinear fusion, embedded fusion, stacked fusion, etc. to generate a comment indication sample of the commented sample data. For example, if the publisher of a certain historical commented data is extracted to be "Xinhua News Agency", the sentiment polarity of the historical comment data associated with the historical commented data is positive, the style is humorous, and the metadata features represent that the identity of the commentator is a new user, the generated comment indication sample of the commented sample data can be "Based on a given blog post published by Xinhua News Agency, simulate the tone of a new user and write a positive and humorous comment."
[0134] In the disclosed embodiment, after generating a comment indication sample of the commented sample data based on the extracted feature information, the comment indication sample may be post-processed, such as removing duplications, correcting grammar, etc., to improve the fluency of the comment indication sample.
[0135] The disclosed embodiment determines commented sample data and comment sample data in a sample data set based on acquired historical commented data and each historical comment data associated with the historical commented data, and for each commented sample data, extracts feature information of each associated commented sample data and / or feature information of the comment sample data, and generates comment indication samples of the commented sample data based on the extracted feature information. On the one hand, since historical commented data and each historical comment data associated with the historical commented data are acquired, the authenticity of the data in the sample data set can be improved, thereby improving the accuracy of training; on the other hand, by extracting feature information of each commented sample data and / or feature information of the comment sample data, and generating comment indication samples based on the features, the understanding of complex instructions by the large language model can be improved, thereby improving the accuracy of comments generated by the comment generation model.
[0136] In some embodiments, the characteristic information of the comment sample data includes the language style characteristics of the comment sample data; Figure 8 The illustrated step S802 can be implemented by the following scheme:
[0137] For each comment sample data, a preset language style classification model is used to classify the comment sample data to obtain a language style classification result of the comment sample data; wherein the language style classification result of the comment sample data is used to characterize the language style characteristics of the comment sample data; based on the language style classification result of each comment sample data, a comment indication sample including the language style characteristics of each comment sample data is generated.
[0138] In the disclosed embodiment, the feature information of the comment sample data includes the language style features of the comment sample data, wherein the language style features include formal style, professional style, daily style, colloquial style, humorous style, gorgeous style, serious style, literary style, etc.
[0139] In the disclosed embodiment, the comment generation device classifies and processes the comment sample data using a preset language style classification model for each comment sample data to obtain a language style classification result of the comment sample data, wherein the preset language style classification model is a model that has been trained and can recognize and classify different language styles. For example, the historical comment data can be directly input into the preset language style classification model, and the model will process the historical comment data according to the knowledge it has learned, and output the language style classification result. The language style classification result may be one or more labels, characterizing the language style category to which the historical comment data belongs. These labels may be predefined, such as "formal", "humorous", "serious", etc., or they may be potential style categories automatically learned by the model, and the disclosed embodiment does not impose any limitation on this.
[0140] In the embodiment of the present disclosure, when the language style classification is performed on the comment sample data, the comment sample data may be preprocessed first, such as removing irrelevant characters, punctuation marks, stop words, etc. in the text, and operations such as word segmentation, stem extraction, or word form restoration may also be performed. It should be noted that the step of preprocessing the comment sample data may be performed in a preset language style classification model, or may be performed by other modules in the comment generation device, and the embodiment of the present disclosure does not limit this. The accuracy of language style recognition can be improved by preprocessing the comment sample data.
[0141] In the disclosed embodiment, after obtaining the language style classification results of the comment sample data based on the preset language style classification model, a comment indication sample including the language style features of each comment sample data can be generated based on the language style classification results of each comment sample data. For example, when the language style classification structure of a certain comment sample data is humorous, the comment indication sample may include "humor" or words with similar meanings to humor. For example, the comment indication sample may be "Based on the given blog post, write a humorous comment."
[0142] In some embodiments, the characteristic information of the comment sample data includes the sentiment polarity characteristics of the comment sample data; Figure 8 The illustrated step S802 may also be implemented by the following scheme:
[0143] For each comment sample data, a preset sentiment polarity classification model is used to classify the comment sample data to obtain a sentiment polarity classification result of the comment sample data; wherein the sentiment polarity classification result of the comment sample data is used to characterize the sentiment polarity characteristics of the comment sample data; based on the sentiment polarity classification result of each comment sample data, a comment indication sample including the sentiment polarity characteristics of each comment sample data is generated.
[0144] In the disclosed embodiment, the feature information of the comment sample data includes the sentiment polarity feature of the comment sample data, wherein the sentiment polarity feature includes positive, negative and neutral.
[0145] In the disclosed embodiment, the comment generation device classifies and processes the comment sample data using a preset sentiment polarity classification model for each comment sample data to obtain a sentiment polarity classification result of the comment sample data, wherein the preset sentiment polarity classification model is a model that has been trained to recognize and classify different sentiment polarities. For example, the historical comment data can be directly input into the preset sentiment polarity classification model, and the model will process the historical comment data according to the knowledge it has learned, and output the sentiment polarity classification result. The sentiment polarity classification result may be a label that characterizes the sentiment polarity category to which the historical comment data belongs. These labels may be predefined, such as "positive", "negative", "neutral", etc.
[0146] In the embodiment of the present disclosure, when the language style of the comment sample data is classified, the comment sample data may be preprocessed first, such as removing irrelevant characters, punctuation marks, stop words, etc. in the text, and operations such as word segmentation, stem extraction or word form restoration may also be performed. It should be noted that the step of preprocessing the comment sample data may be performed in a preset sentiment polarity classification model or by other modules in the comment generation device, and the embodiment of the present disclosure does not limit this. The accuracy of sentiment polarity recognition can be improved by preprocessing the comment sample data.
[0147] In the disclosed embodiments, after obtaining the sentiment polarity classification result of the comment sample data based on a preset sentiment polarity classification model, a comment indication sample including the sentiment polarity characteristics of each comment sample data can be generated based on the sentiment polarity classification result of each comment sample data. For example, when the sentiment polarity classification result of a certain comment sample data is positive, the comment indication sample may include "positive" or words with similar positive meanings, such as the comment indication sample may be "Based on the given blog post, write a positive comment."
[0148] In some embodiments, the characteristic information of the comment sample data includes the frequency characteristics of the comment sample data; Figure 8 The illustrated step S802 may also be implemented by the following scheme:
[0149] Clustering is performed on each comment sample data associated with the comment sample data to obtain comment sample clusters of associated comment content topics; the number of comment sample data included in each comment sample cluster is determined; for each comment sample data, based on the number of comment sample data included in the comment sample cluster to which it belongs, a comment indication sample including frequency characteristics of each comment sample data is generated; wherein the number of comment sample data included in the comment sample cluster to which the comment sample data belongs is used to characterize the frequency characteristics of the comment sample data.
[0150] In the disclosed embodiment, the feature information of the comment sample data includes the frequency feature of the comment sample data, wherein the frequency feature may include high frequency, low frequency, medium frequency, etc.
[0151] In the embodiment of the present disclosure, the comment generation device performs clustering processing on each comment sample data associated with the comment sample data to obtain a comment sample cluster associated with the comment content theme, wherein the comment content theme of each comment sample data can be determined first, specifically, each comment sample data can be processed using a preset theme classification model to determine the theme of each comment sample data, and then each comment sample data is clustered based on the theme of each comment sample data to obtain a comment sample cluster associated with the comment content theme, such as using a hierarchical clustering method, a spectral clustering method, a K-means clustering method, etc. It should be noted that it is also possible to directly cluster each comment sample data without first determining the content theme of each comment sample data, and the embodiment of the present disclosure does not limit this.
[0152] In the disclosed embodiment, after obtaining the comment sample clusters of the related comment content topics, the comment generation device determines the number of comment sample data included in each comment sample cluster. For example, if the topic of a certain comment sample data is "Come on", the name of the comment sample cluster to which it belongs may be "Come on". It is determined that the number of comment sample data under the comment sample cluster is 1500. Then, the number of comment sample data under the comment sample cluster to which the comment sample data belongs, i.e., 1500, can be identified by means of tags. The frequency characteristics of the comment sample data can be determined based on each tag. Specifically, the comment sample data whose frequency exceeds the first preset frequency threshold is recorded as high frequency, the comment sample data whose frequency is lower than the second preset frequency threshold is recorded as low frequency, and the comment sample data whose frequency is between the first preset frequency threshold and the second preset frequency threshold is recorded as medium frequency. The first preset frequency threshold and the second preset frequency threshold are both set values, and the first preset frequency threshold is greater than the second preset frequency threshold. For example, the first preset frequency threshold can be set to 2000, and the second preset frequency threshold can be set to 1000.
[0153] In the embodiment of the present disclosure, when clustering the comment sample data, the comment sample data may be preprocessed first, such as removing irrelevant characters, punctuation marks, stop words, etc. in the text, and may also perform operations such as word segmentation, stem extraction, or word form restoration. It should be noted that the step of preprocessing the comment sample data may be performed in a preset sentiment polarity classification model or by other modules in the comment generation device, and the embodiment of the present disclosure does not limit this. Preprocessing the comment sample data can improve the accuracy of sentiment polarity recognition.
[0154] In the disclosed embodiment, for each comment sample data, after determining the number of comment sample data included in the comment sample cluster to which it belongs, a comment indication sample including the frequency characteristics of each comment sample data can be generated based on the number of comment sample data included in the comment sample cluster to which it belongs. For example, when the number of comment sample data included in the comment sample cluster to which a certain comment sample data belongs is large, that is, the frequency characteristic is high frequency, the comment indication sample can include "high frequency" or words with similar meanings to high frequency, such as the comment indication sample can be "write a general comment based on a given blog post."
[0155] The disclosed embodiments, by obtaining the language style classification result and / or the sentiment polarity classification result and / or the number of comment sample data included in the comment sample cluster to which each comment sample data belongs, and based on the language style classification result and / or the sentiment polarity classification result and / or the number of comment sample data included in the comment sample cluster to which it belongs, generate a comment indication sample including the language style features and / or the sentiment polarity features and / or the frequency features of each comment sample data, can enhance the comprehension and analysis capabilities of the data and improve the efficiency of subsequent processing.
[0156] In some embodiments, the characteristic information of the commented sample data includes the first user characteristic of the commented sample data, and the characteristic information of the comment sample data includes the second user characteristic of the comment sample data. Figure 8 The illustrated step S802 may also be implemented by the following scheme:
[0157] For each comment sample data, obtain the first user information of the commented sample data associated with the comment sample data, and / or obtain the second user information of the comment sample data; perform feature extraction on the first user information and / or the second user information associated with each comment sample data; generate a comment indication sample including the first user feature based on the extracted feature of the first user information; and / or generate a comment indication sample including the second user feature based on the extracted feature of the second user information.
[0158] In the disclosed embodiment, the comment generating device obtains, for each comment sample data, first user information of the commented sample data associated with the comment sample data, wherein the first user is the user who publishes the commented data, and the first user information may include the user name of the first user, the gender of the first user, the frequency with which the first user uses the media platform that publishes the commented data, the fields covered by the first user on the media platform, and other information. Specifically, the comment generating device may obtain other commented data or comment data published by the first user, and analyze the other commented data or comment data published by the first user to determine the information of the first user based on the analysis results.
[0159] In the disclosed embodiment, the comment generating device obtains second user information of the comment sample data for each comment sample data, wherein the second user is a user who posts comment data for the commented data, and the second user information may include information such as the user name of the second user, the gender of the second user, the frequency with which the second user uses the media platform for posting comment data, and the fields covered by the second user on the media platform. Specifically, the comment generating device may obtain other commented data or comment data posted by the second user, and analyze the other commented data or comment data posted by the second user to determine the information of the second user based on the analysis result.
[0160] In the disclosed embodiment, the comment generating device extracts features of the first user information associated with each comment sample data, and generates a comment indication sample including the first user features based on the features of the extracted first user information. For example, when the first user information of the commented sample data associated with a certain comment sample data is the user name of the first user (Xinhua News Agency), the comment indication sample may include the user name of the first user. For example, the comment indication sample may be "write a comment based on a given blog post published by Xinhua News Agency."
[0161] In the disclosed embodiment, the comment generating device extracts features from the second user information associated with each comment sample data, and generates a comment indication sample including the second user features based on the features of the extracted second user information. For example, when the first user information of the commented sample data associated with a certain comment sample data is the frequency (less) of the second user using the media platform for posting comment data, the comment indication sample may include the frequency features of the second user using the media platform. For example, the comment indication sample may be "Based on a given blog post, simulate the tone of a new Weibo user and write a comment."
[0162] The disclosed embodiments can enhance the comprehensiveness of the comment indication sample, enhance the comprehension and analysis capabilities of the data, and improve the efficiency of subsequent processing by acquiring the first user information of the commented sample data associated with the comment sample data, and / or acquiring the second user information of the comment sample data, and generating a comment indication sample including the first user characteristics based on the extracted characteristics of the first user information; and / or generating a comment indication sample including the second user characteristics based on the extracted characteristics of the second user information.
[0163] In some embodiments, see Fig. 9 , Fig. 9 is an optional flow chart of a method for processing a sample comment indication provided in an embodiment of the present application. Figure 4 The illustrated step S403 can be implemented through steps S901 to S902, and will be described in conjunction with each step.
[0164] In step S901, sample data to be processed in a preset format is generated based on the commented sample data and the comment indication sample.
[0165] Among them, the preset format refers to the data structure and field specifications that the sample data to be processed should follow. According to actual needs, fields such as "title", "style", "user ID", "emotional polarity", etc. can be defined. As mentioned above, the comment generation device can obtain the comment sample data and the features of the commented sample data associated with the comment sample data, and generate a comment indication sample based on the features.
[0166] In some embodiments, the preset format of the comment indication sample can be determined first, such as generating different preset formats based on a model, or manually setting the preset format, which is not limited by the embodiments of the present disclosure. Specifically, a certain number of preset formats can be obtained by manual writing first, and then the above-mentioned certain number of preset formats can be imitated, rewritten or expanded through a large language model to generate more preset formats of different formats, wherein the large language model can be the large language model mentioned above, or other large language models, which is not limited by the embodiments of the present disclosure.
[0167] In the disclosed embodiment, the preset format may be “given a blog post published by “the user number of the user who published the commented sample data”, please simulate the tone of “the frequency of the user who published the comment sample data using the media platform for publishing the comment data” and write a comment with “emotional polarity””. The preset format may also be “given a blog post published by “the user number of the user who published the comment sample data”, please simulate the tone of “the frequency of the user who published the comment sample data using the media platform for publishing the comment data” and write a comment with “emotional polarity””. It should be noted that the change of the preset format does not affect the characteristics of the commented sample data and / or the comment sample data included in the comment indication sample, that is, the preset format only changes the description method of the comment indication sample, and does not change the substantive content.
[0168] In the disclosed embodiment, the comment generating device generates sample data to be processed in a preset format based on the commented sample data and the comment indication sample. For example, when the preset format is "given a blog post by "the user number of the user who posted the commented sample data", simulate the tone of "the frequency of the user who posted the comment sample data using the media platform for posting the comment data", and write a comment with "emotional polarity"", the user number of the user who posted the commented sample data is Xinhua News Agency, the frequency of the user who posted the comment sample data using the media platform for posting the comment data is low frequency, and the emotional polarity of the comment sample data is positive, the sample data to be processed is "given a blog post posted by Xinhua News Agency, simulate the tone of a new user and write a positive comment".
[0169] In step S902, based on the sample data to be processed, the large language model is used to perform word-by-word prediction processing, and multiple predicted words are concatenated in a prediction order to form the comment prediction data.
[0170] In the disclosed embodiment, as mentioned above, the sample data sample to be processed may be preprocessed first so that the large language model can understand and perform subsequent processing. The preprocessing includes word segmentation, keyword extraction, removal of irrelevant characters, conversion into corresponding vector representations, etc. The large language model performs word-by-word prediction processing as mentioned above based on the preprocessed sample data to be processed, and after obtaining multiple predicted words, the multiple predicted words are spliced in the prediction order to form comment prediction data for the commented sample data and in accordance with the comment indication sample. During the generation process, the large language model may use various natural language processing technologies, such as text generation algorithms, grammatical rules, semantic understanding and other technologies to improve the probability that the generated comment prediction data not only conforms to grammatical specifications, but also can accurately convey the analysis and evaluation of the commented data. After generating the comment prediction data, the large language model may also perform post-processing such as removing duplications and correcting grammar on the comment prediction data to improve the fluency of the comment prediction data.
[0171] The disclosed embodiment generates sample data to be processed in a preset format based on the commented sample data and the comment indication sample, and processes the sample data to be processed based on the large language model to obtain comment prediction data. This method can improve data integration and standardization, provide convenience for subsequent processing, and improve data processing efficiency. In addition, the generalization ability of the model can be improved by processing data to be processed in different formats.
[0172] The following is an explanation of an exemplary application of the embodiments of the present application in a practical application scenario.
[0173] See also Fig.10 , Fig.10 This is an optional flow chart of another comment generation method provided by an embodiment of the present application. In the following, the media platform is Weibo, the sample data set is the training set, the commented sample data is the historical commented data, the comment sample data is the historical comment data, the comment instruction sample is the instruction, the publisher of the historical commented data is called the blogger, the commented sample data is called the blog post, and the publisher of the historical comment data is called the user. Fig.10 The steps shown illustrate the comment generation method provided in the embodiment of the present application.
[0174] In step S1001, historical comment data is obtained.
[0175] Exemplarily, the historical comment data may be historical comment data stored in memory space, or may be historical comment data captured according to preset capture conditions, or may be official media accounts in different fields determined through manual screening, and historical commented data under the account and historical comment data associated with the historical commented data may be obtained.
[0176] In step S1002, data is cleaned.
[0177] Exemplarily, the historical comment data that has not passed the review of the official media can be filtered out first; secondly, the historical likes data and interaction data of each historical comment data can be obtained, and the historical commented data with large differences in the likes and interaction data of the historical comment data can be determined, and the historical comment data with likes or interaction data below the preset data threshold can be filtered out, wherein the preset data threshold is a set value. If the likes and interaction data of the historical comment data in the historical commented data are not much different, the historical comment data are sorted using the likes, interactions and other data, and only the top 100 historical comment data are retained; then some general data filtering and cleaning operations are performed on the content of the historical commented data, such as filtering blog posts with only topic words, filtering meaningless blog posts such as voting types, filtering blog posts containing sensitive words, removing blog post URLs, cleaning special characters, etc. In addition, under official media accounts, there are usually some users who have screen-swiping behavior, for example, regardless of the content of the blog post, only post the same comments (appeals or advertising appeals, etc.) in the comment area. Through the clustering algorithm, such user data is filtered.
[0178] It should be noted that the above filtering order is only an example, and the filtering order can be changed according to actual conditions. The embodiments of the present disclosure do not limit the specific filtering order.
[0179] In step S1003, feature mining is performed.
[0180] Exemplarily, the characteristics of historical comment data and the historical commented data associated therewith are obtained, specifically, may include blog content characteristics, blogger information, comment style, comment frequency, comment sentiment polarity, user information, wherein the blogger information may include the blogger's username, blogger's gender, blogger's frequency of using Weibo, blogger's fields of interest, etc., and the user information may include the user's username, user's gender, user's frequency of using Weibo, user's fields of interest, etc.
[0181] In step S1004, instruction construction.
[0182] Exemplarily, for each piece of historical comment data, an instruction format can be selected first, wherein the instruction format is a description method of the instruction, and the instruction format can be stored in a memory or a selector. The method of constructing the instruction format can refer to the aforementioned content, and the instruction format can be integrated according to the characteristics of the historical comment data and the historical commented data associated therewith to obtain the instructions associated with the historical comment data.
[0183] In step S1005, training set.
[0184] Exemplarily, the training set includes a large number of training samples, each of which includes historical commented data, historical comment data associated with the historical commented sample data, and instructions associated with the historical comment data constructed by the above instruction construction method.
[0185] In step S1006, supervised fine-tuning is performed.
[0186] In step S1007, a large language model.
[0187] Exemplarily, an open source large language model is selected as the base model. Specifically, the Baichuan2 model is selected as the base model. It should be noted that Baichuan2 uses a corpus of 2.6 trillion tokens and builds a large-scale deduplication and clustering system to filter and clean the pre-trained data. Through the above method, a batch of comprehensive and high-quality training samples are obtained. In terms of model architecture, the word segmenter is first optimized to balance the computational efficiency and model performance, and obtain a better text compression rate; secondly, the position encoding is optimized, and the rotation position encoding technology is used; the Switched Gated Linear Unit (SwiGLU) function is used as the activation function; layer normalization is applied to the input of the transformer, and the root mean square normalization (RMSNorm) method is used to implement it; in addition, in order to stabilize the training and improve the model performance, the input of the decoder (output embedding) is also normalized, and the maximum z loss function (max-z loss) is adopted. It should be noted that other open source large language models may also be used as the base model, and the embodiments of the present disclosure do not limit this.
[0188] Exemplarily, the large language model is supervised fine-tuned by a low-rank adaptive (LoRA) interval fine-tuning method, wherein the specific supervised fine-tuning steps can refer to the above description.
[0189] The disclosed embodiment obtains historical comment data, cleans the data, and then mines the features of the historical comment data and the historical commented data associated with the historical comment data, and constructs instructions based on the features to form a training set. Based on the large language model as the base model, the large language model is supervised and fine-tuned based on the training set to determine the comment generation model. On the one hand, according to the characteristics of Weibo and business scenarios, Weibo and comment data are finely processed through data processing to obtain a high-quality data set. On the other hand, instruction data containing the features of the historical comment data and the historical commented data associated with the historical comment data is constructed, which can effectively improve the model's instruction comprehension ability. On the other hand, since the comment generation model in the disclosed embodiment is obtained based on the training of the large language model, it has strong applicability and flexibility.
[0190] The following is a description of an exemplary structure of the review generating device 255 provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 2 As shown, the software modules stored in the comment generation device 255 of the memory 240 may include:
[0191] The first acquisition module 2551 is used to acquire data to be commented on and comment indication information for the data to be commented on; wherein the comment indication information includes feature information of the data to be commented on and / or feature information of comment data to be generated; the generation module 2552 is used to perform word-by-word prediction processing on the data to be commented on in accordance with the comment indication information using a trained comment generation model based on the data to be commented on and the comment indication information, and obtain comment data formed by splicing multiple predicted words in a prediction order; wherein the comment generation model is obtained by training a preset large language model based on commented sample data, comment indication samples for the commented sample data, and comment sample data associated with the commented sample data.
[0192] In some possible implementations, the device further includes: a second acquisition module, configured to acquire a sample data set; wherein each sample data in the sample data set includes at least commented sample data, a comment indication sample for the commented sample data, and comment sample data associated with the commented sample data; wherein the comment indication sample includes feature information of the commented sample data and / or feature information of the comment sample data; an iteration module, configured to iteratively train the large language model based on the sample data set until the comment generation model is obtained by meeting the convergence condition, wherein each iterative training process includes: for each sample data, based on the commented sample data and the comment indication sample for the commented sample data, using the large language model to perform word-by-word prediction processing on the commented sample data in accordance with the comment indication sample, to obtain comment prediction data formed by splicing multiple predicted words in a prediction order; and based on the difference between the comment prediction data corresponding to each sample data and the comment sample data, fine-tuning the large language model to obtain model parameters after fine-tuning the large language model.
[0193] In some possible implementations, the second acquisition module is used to determine the commented sample data and the comment sample data in the sample data set based on the acquired historical commented data and the historical comment data associated with the historical commented data; wherein one historical commented data is one commented sample data, and one historical comment data is one comment sample data; for each commented sample data, feature information of the associated commented sample data and / or feature information of the comment sample data is extracted, and a comment indication sample of the commented sample data is generated based on the extracted features.
[0194] In some possible implementations, the characteristic information of the comment sample data includes the language style characteristics of the comment sample data; the second acquisition module is used to classify the comment sample data using a preset language style classification model for each comment sample data to obtain a language style classification result of the comment sample data; wherein the language style classification result of the comment sample data is used to characterize the language style characteristics of the comment sample data; based on the language style classification result of each comment sample data, a comment indication sample including the language style characteristics of each comment sample data is generated.
[0195] In some possible implementations, the characteristic information of the comment sample data includes the sentiment polarity characteristics of the comment sample data; the second acquisition module is used to classify the comment sample data using a preset sentiment polarity classification model for each comment sample data, and obtain a sentiment polarity classification result of the comment sample data; wherein the sentiment polarity classification result of the comment sample data is used to characterize the sentiment polarity characteristics of the comment sample data; based on the sentiment polarity classification result of each comment sample data, a comment indication sample including the sentiment polarity characteristics of each comment sample data is generated.
[0196] In some possible implementations, the characteristic information of the comment sample data includes the frequency characteristics of the comment sample data; the second acquisition module is used to perform clustering processing on the comment sample data associated with the comment sample data to obtain comment sample clusters associated with comment content topics; determine the number of comment sample data included in each comment sample cluster; for each comment sample data, based on the number of comment sample data included in the comment sample cluster to which it belongs, generate a comment indication sample including the frequency characteristics of each comment sample data; wherein the number of comment sample data included in the comment sample cluster to which the comment sample data belongs is used to characterize the frequency characteristics of the comment sample data.
[0197] In some possible implementations, the characteristic information of the commented sample data includes a first user characteristic of the commented sample data, and the characteristic information of the comment sample data includes a second user characteristic of the comment sample data. The second acquisition module is used to obtain, for each comment sample data, the first user information of the commented sample data associated with the comment sample data, and / or obtain the second user information of the comment sample data; perform feature extraction on the first user information and / or the second user information associated with each comment sample data; generate a comment indication sample including the first user characteristic based on the extracted characteristics of the first user information; and / or generate a comment indication sample including the second user characteristic based on the extracted characteristics of the second user information.
[0198] In some possible implementations, the iteration module is used to generate sample data to be processed in a preset format based on the commented sample data and the comment indication sample; based on the sample data to be processed, use the large language model to perform word-by-word prediction processing, and concatenate multiple predicted words in a prediction order to form the comment prediction data.
[0199] In some possible implementations, the iteration module is used to determine, for each sample data, the difference between the comment prediction data and the comment sample data; determine a loss value based on the 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.
[0200] In some possible implementations, the iteration module is used 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 an initial parameter matrix; based on the initial parameter matrix, the first matrix and the second matrix after the matrix data are adjusted, obtain the model parameters after fine-tuning the large language model.
[0201] The embodiment of the present application 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 comment generation method described in the embodiment of the present application.
[0202] The present application embodiment provides a computer-readable storage medium having a computer program or executable instructions stored thereon. When the computer program or executable instructions are executed by a processor, the processor will execute the comment generation method provided by the present application embodiment, for example, Figure 3 The review generation method shown.
[0203] 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.
[0204] 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.
[0205] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts 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).
[0206] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0207] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A comment generation method, characterized in that: include: Acquire data to be reviewed and review indication information for the data to be reviewed; wherein the review indication information includes feature information of the data to be reviewed and / or feature information of review data to be generated; Based on the data to be reviewed and the review indication information, using a trained review generation model to perform word-by-word prediction processing on the data to be reviewed that conforms to the review indication information, to obtain review data formed by splicing multiple predicted words in a prediction order; The comment generation model is obtained by training a preset large language model based on the commented sample data, comment indication samples of the commented sample data, and comment sample data associated with the commented sample data.
2. The method according to claim 1, characterized in that The training method of the comment generation model includes: Acquire a sample data set; wherein each sample data in the sample data set at least includes commented sample data, a comment indication sample on the commented sample data, and comment sample data associated with the commented sample data; wherein the comment indication sample includes feature information of the commented sample data and / or feature information of the comment sample data; The large language model is iteratively trained based on the sample data set until the convergence condition is met to obtain the comment generation model, and each iterative training process includes: For each sample data, based on the commented sample data and the comment indication sample for the commented sample data, the large language model is used to perform word-by-word prediction processing on the commented sample data that conforms to the comment indication sample, to obtain comment prediction data formed by splicing multiple prediction words in a prediction order; Based on the difference between the comment prediction data corresponding to each sample data and the comment sample data, the large language model is fine-tuned to obtain model parameters of the large language model after fine-tuning.
3. The method according to claim 2, characterized in that The obtaining of the sample data set comprises: Determine the commented sample data and the comment sample data in the sample data set based on the acquired historical commented data and each historical comment data associated with the historical commented data; wherein one historical commented data is one commented sample data, and one historical comment data is one comment sample data; For each commented sample data, feature information of associated commented sample data and / or feature information of comment sample data is extracted, and a comment indication sample of the commented sample data is generated based on the extracted feature information.
4. The method according to claim 3, characterized in that The characteristic information of the comment sample data includes the language style characteristics of the comment sample data; The step of extracting the associated characteristic information of each commented sample data and / or the characteristic information of the comment sample data, and generating the comment indication sample of the commented sample data based on the extracted characteristic information, includes: For each review sample data, a preset language style classification model is used to classify the review sample data to obtain a language style classification result of the review sample data; wherein the language style classification result of the review sample data is used to characterize the language style characteristics of the review sample data; Based on the language style classification result of each comment sample data, a comment indication sample including the language style feature of each comment sample data is generated.
5. The method according to claim 3, characterized in that: The characteristic information of the comment sample data includes the sentiment polarity characteristics of the comment sample data; The step of extracting the associated characteristic information of each commented sample data and / or the characteristic information of the comment sample data, and generating the comment indication sample of the commented sample data based on the extracted characteristic information, includes: For each comment sample data, a preset sentiment polarity classification model is used to classify the comment sample data to obtain a sentiment polarity classification result of the comment sample data; wherein the sentiment polarity classification result of the comment sample data is used to characterize the sentiment polarity characteristics of the comment sample data; Based on the sentiment polarity classification result of each comment sample data, a comment indication sample including the sentiment polarity feature of each comment sample data is generated.
6. The method according to claim 3, characterized in that: The characteristic information of the comment sample data includes the frequency characteristics of the comment sample data; The step of extracting the associated characteristic information of each commented sample data and / or the characteristic information of the comment sample data, and generating the comment indication sample of the commented sample data based on the extracted characteristic information, includes: Performing clustering processing on each review sample data associated with the review sample data to obtain a review sample cluster associated with the review content theme; Determine the number of review sample data included in each review sample cluster; For each comment sample data, based on the number of comment sample data included in the comment sample cluster to which it belongs, a comment indication sample including the frequency characteristics of each comment sample data is generated; wherein the number of comment sample data included in the comment sample cluster to which the comment sample data belongs is used to characterize the frequency characteristics of the comment sample data.
7. The method according to claim 3, characterized in that The characteristic information of the commented sample data includes a first user characteristic of the commented sample data, and the characteristic information of the comment sample data includes a second user characteristic of the comment sample data; The step of extracting the associated characteristic information of each commented sample data and / or the characteristic information of the comment sample data, and generating the comment indication sample of the commented sample data based on the extracted characteristic information, includes: For each review sample data, obtaining first user information of the reviewed sample data associated with the review sample data, and / or obtaining second user information of the review sample data; Extracting features of the first user information and / or the second user information associated with each comment sample data; Generate a comment indication sample including the first user feature based on the extracted feature of the first user information; and / or generate a comment indication sample including the second user feature based on the extracted feature of the second user information.
8. The method according to claim 2 or 3, characterized in that: The method of performing word-by-word prediction processing on the commented sample data in accordance with the comment indication sample using the large language model based on the commented sample data and the comment indication sample of the commented sample data, and obtaining comment prediction data formed by splicing multiple prediction words in a prediction order, includes: Based on the commented sample data and the comment indication sample, generating sample data to be processed in a preset format; Based on the sample data to be processed, the large language model is used to perform word-by-word prediction processing, and multiple predicted words are concatenated in a prediction order to form the comment prediction data.
9. A comment generation device, characterized in that: The device comprises: A first acquisition module, used to acquire data to be reviewed and comment indication information for the data to be reviewed; wherein the comment indication information includes feature information of the data to be reviewed and / or feature information of comment data to be generated; A generation module, based on the data to be commented on and the comment indication information, uses a trained comment generation model to perform word-by-word prediction processing on the data to be commented on that conforms to the comment indication information, and obtains comment data formed by splicing multiple predicted words in a prediction order; wherein the comment generation model is obtained by training a preset large language model based on commented sample data, comment indication samples for the commented sample data, and comment sample data associated with the commented sample data.
10. An electronic device, characterized in that: The electronic device comprises: A 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, 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, 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.
Citation Information
Cited By
Text display method and device, electronic equipment and computer readable medium
CN119398061A
Text display method, device, electronic device and computer-readable medium
CN119398061B
Social network public opinion propagation key user mining method and system
CN121213274A
A social network public opinion propagation key user mining method and system
CN121213274B
