Text generation method and device, electronic equipment and storage medium
By analyzing the user's historical data, determining their text creation style and preferences, and generating personalized target text, it solves the problem of lack of personalization in comment generation in the existing technology, and achieves real and personalized text generation effects.
Patent Information
- Application Number
- CN202411616926.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-02-28
AI Technical Summary
The prior art lacks personalization in the generation of comments, which is difficult to reflect the user's true emotions, especially negative emotions, and often lacks personalized characteristics.
By obtaining the user's historical data, including historical text data and historical behavior data, we determine the user's text creation style and preferences, and generate target text based on this information, ensuring that the generated text is both personalized and authentic.
The generated text is achieved both personalized and authentic, which can reflect the user's true emotions and style, and solves the problem of lack of personalization in comment generation in the prior art.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a text generation method, device, electronic device and storage medium. Background Art
[0002] In e-commerce and recommendation systems, user reviews are an important factor influencing other users' purchasing decisions. However, many users tend to only provide ratings without writing reviews after purchasing a product, resulting in the recommendation system lacking sufficient user feedback to optimize its recommendation algorithm.
[0003] Among existing technical solutions, a common method is to use a neural network model based on an encoder-decoder architecture to generate reviews. These models generate text by analyzing the user's historical behavior and product attributes. For example, some studies use recurrent neural networks or long short-term memory networks to process sequence data and generate reviews that match user behavior and product characteristics. However, the above existing technologies are usually pre-trained at the expected level and cannot capture personal preferences and styles, resulting in a lack of personalization in the generated text. Summary of the invention
[0004] In view of this, the present application provides a text generation method, device, electronic device and storage medium to solve the problem of lack of personalization of text generated in the prior art.
[0005] In a first aspect of the present application, a text generation method is provided, comprising: obtaining historical data of a user, the historical data comprising historical text data of the user for a historical object and historical behavior data of the user for the historical object; determining the text creation style of the user based on the historical text data and the historical behavior data; determining the user's preference for a target object, and determining a target text for describing the target object based on the preference and the text creation style.
[0006] According to a second aspect of the present application, a text generation device is provided, comprising: an acquisition module configured to acquire historical data of a user, the historical data comprising historical text data of the user for a historical object and historical behavior data of the user for the historical object; a style determination module configured to determine the text creation style of the user based on the historical text data and the historical behavior data; and a text generation module configured to determine the user's preference for a target object, and determine a target text for describing the target object based on the preference and the text creation style.
[0007] According to a third aspect of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0008] According to a fourth aspect of the present application, a storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0009] At least one of the above technical solutions adopted in this application can achieve the following beneficial effects:
[0010] By collecting historical data related to the user and historical objects, which historical data includes historical text data and historical behavior data, and determining the user's text creation style based on the historical text data and historical behavior data, and at the same time determining the user's preference for the target object, the user's target text for the target object can be generated based on the user's preference for the target object and the user's text creation style. In this way, the target text can be generated using the identified user style and preference, ensuring that the generated target text is both personalized and authentic. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0012] Figure 1 It is a flowchart of a text generation method provided in an embodiment of the present application;
[0013] Figure 2 It is a flowchart of another text generation method provided in an embodiment of the present application;
[0014] Figure 3 It is a structural schematic diagram of a text generation device provided in an embodiment of the present application;
[0015] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0016] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0017] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0018] In addition, it should be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "includes..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0019] Text generation technology is widely used today, such as translation, content creation, etc. However, the existing technology still has many shortcomings in generating text. Taking the generation of comment text as an example, the existing large language model (LLM) is "too polite" when generating comments, which makes it difficult to reflect the user's true emotions, especially negative emotions, and often lacks personalized features. For this reason, the present application proposes a method for generating a user's target text for a target object based on the user's preference and historical data for the target object. The present application takes the comment text birthday of an e-commerce platform as an example, and constructs personalized input prompts by analyzing the user's historical purchasing behavior, product title, rating and comments, and guides the large language model to generate personalized comments to ensure that the user generates a comment text that matches the emotion when he is dissatisfied. At the same time, the large model is fine-tuned to improve the relevance and personalization of the comment text. Of course, the present application scheme is applicable to other text generation scenarios, such as generating product introductions and instructions.
[0020] A text generation method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0021] Figure 1 Schematic diagram of a text generation method provided in an embodiment of the present application. Figure 1 As shown, the text generation method includes:
[0022] S101, obtaining historical data of a user, where the historical data includes historical text data of the user for a historical object and historical behavior data of the user for the historical object.
[0023] Specifically, the system can collect historical data of users. Historical data can be relevant historical data for historical objects. The historical data can include historical text data and historical behavior data. The historical objects can be understood as specific things, entities or topics that users have created texts or interacted with. For example, in the field of e-commerce, historical objects can be products that users have commented on or have other operations (such as clicks, purchases, browsing, etc.). Historical text data can be comments, feedback and any other written expressions left by users when they purchased or evaluated products in the past. These text records can reflect the user's views, emotions and expressions. Historical behavior data can include users' purchase records, browsing behaviors, ratings, etc. for products, but no restrictions are made here.
[0024] S102, determining the user's text creation style based on historical text data and historical behavior data.
[0025] Specifically, after obtaining historical text data and historical behavior data, the user's historical text data and historical behavior data can be analyzed through machine learning and natural language processing technology, that is, keywords, phrases, sentence structure, word usage habits and other features can be extracted from the historical text data, and the historical object information contained in the historical behavior can be extracted. The historical text data and historical behavior data are further analyzed to obtain the user's text creation style, which can include the user's interest points and language style in commenting on historical objects, and there is no limitation here.
[0026] S103, determining the user's preference for the target object, and determining a target text for describing the target object according to the preference and the text creation style.
[0027] Specifically, after determining the user's preference for the target object, a target text describing the target object by the user may be generated based on the preference and the user's text creation style.
[0028] The target object may represent the object to be generated as the target text. In the e-commerce field, the target object may be any sales product. In the news field, the target object may be a news report. There is no restriction here. The preference degree may be expressed as the user's emotional tendency towards the target product. It may be expressed as positive, neutral, or negative. It may also be mapped by a 10-point system. For example, 1-4 points represent negative emotional tendency, 4-6 points represent neutral emotional tendency, and 7-10 points represent positive emotional tendency. There is no restriction here.
[0029] According to the technical solution provided in the above embodiment, by analyzing the user's historical data, the user's text creation style and the user's preference for the target object can be identified, and finally a target text reflecting the user's personalization is generated. This not only meets the accuracy and personalization of text generation, but also can be applied to the recommendation system to improve the accuracy of the recommendation system and user experience.
[0030] In some embodiments, the user's text creation style is determined based on historical text data and historical behavior data, including: extracting key information from the historical text data based on the word frequency method to obtain a target phrase; determining the user's text creation style based on the target phrase and the historical object corresponding to the target phrase, the text creation style including the user's text creation preference and language style.
[0031] Specifically, key information can be extracted from historical text data based on the word frequency method, that is, high-frequency words and phrases are identified to generate target phrases, which can represent concepts, themes or emotions repeatedly mentioned by users in their comments, such as "reasonable price", "good quality", etc.
[0032] Furthermore, the system can associate the target phrase with the corresponding historical object, which can help the user to comment on the historical object or generate other text creation styles. The text creation style can include text creation preferences and language styles, where the text creation preference can be understood as the user's focus when generating historical text data for the historical object, and then analyze the user's focus or specific features when analyzing goods or other objects, such as the quality and price of the goods; the objectivity and immediacy of the news; the parameters of specific products (such as the depth of field and pixels of the camera), etc. The language style can represent the user's language expression style, including tone, emotional color, specific vocabulary or sentence patterns, etc., and also includes direct and euphemistic analysis. For example, a direct language style may make a clear evaluation (such as this product is of poor quality and not worth it at all), while a euphemistic style may use more implicit words (such as it does not conform to my aesthetics). Of course, there is no restriction here.
[0033] According to the technical solution provided in the above embodiment, by analyzing historical text data, we can gain an in-depth understanding of the user's text creation style, thereby obtaining the user's text creation preferences and language style, which will provide an important basis for the subsequent generation of personalized comments or other target texts, so that the final output target text is more in line with the user's expectations and style.
[0034] In some embodiments, determining the user's preference for the target object includes: obtaining the user's current behavior toward the target object and mapping the current behavior to an emotion tag; and obtaining the user's preference for the target object based on the emotion tag and the language style.
[0035] Specifically, the user's preference for the target object can be analyzed through the user's current behavior towards the target object. When generating a review text, the current behavior may include the user's rating, browsing, click times, purchase times, etc. of the target object. These current behaviors can reflect the user's interest and satisfaction with the target object. After obtaining the user's current behavior, the current behavior can be converted into a sentiment label based on its learning model or rule algorithm. The sentiment label can include: positive, negative, and neutral. As an example, if the user's rating of the target object is 1 point (out of 5 points), the rating can be converted into a negative sentiment label.
[0036] Furthermore, the user's preference for the target object can be obtained based on the analysis of the emotional label and language style corresponding to the user's current behavior. The language style can analyze the user's style and habits in expressing emotions, so as to better interpret the emotional meaning of the current behavior. For example, some users prefer to use more implicit language when expressing negative emotions, while other users may be more direct. By learning user ratings or other current behaviors, the user's true emotional state can be fully analyzed to help the model generate target text that can reflect the user's true attitude.
[0037] According to the technical solution provided in the above embodiment, the user's emotional tendency towards the target object can be identified by analyzing the user's current behavior. Combined with the user's language style analyzed previously, the user's preference for the target object can be comprehensively judged, thereby helping to generate a more personalized target text in the subsequent generation.
[0038] In some embodiments, a target text for describing a target object is determined based on the preference and text creation style, including: generating a prompt text based on the preference and text creation style, the prompt text being used to guide a large language model to generate the target text, the large language model being used to perform a target text generation task; and generating the target text based on the prompt text and the target object.
[0039] Specifically, after obtaining the user's preference for the target object and the text creation style, a target text describing the target object may be generated.
[0040] Furthermore, the user's preferences and text creation style can be comprehensively considered to generate prompt text for guiding the large language model. The prompt text may include the user's focus on the target (parameters, quality, price, etc.), the user's language style (such as the desire to express dissatisfaction in a euphemistic way), and the user's preference for the target object. The prompt text can then be used to instruct the large language model to generate the target text. It should be noted that when generating the prompt text, the user's emotional tendency can also be paid attention to, that is, the user's comment method when generating text for products or other historical objects based on historical data analysis, such as giving detailed feedback corresponding to the score.
[0041] When generating target text, you can use a trained large language model to improve the quality of the model output results.
[0042] As an example, let's say the user is Zhang San, who recently purchased a new digital camera and gave it a 4-star rating. Zhang San also previously purchased the following items, with corresponding reviews and ratings:
[0043] Product: Portable Photo Printer
[0044] Comments: "Prints quickly, but colors are sometimes not vivid enough."
[0045] Rating: 4 stars;
[0046] Product: Professional-grade tripod
[0047] Comments: "Very stable, great for long exposure photography."
[0048] Rating: 5 stars;
[0049] Product: Photography backpack
[0050] Comments: "Great capacity, but a bit heavy."
[0051] Rating: 3 stars;
[0052] Analyze the user's historical data:
[0053] By analyzing Zhang San’s purchase history and comments, we can extract the following features:
[0054] Focus: High requirements for functionality and durability of photographic equipment.
[0055] Text writing style: direct, practical, and focused on the specific performance of the product.
[0056] Sentiment tendency: Tends to give specific feedback, and the ratings and comments are relatively balanced.
[0057] Constructing hint text
[0058] Based on Zhang San’s behavior analysis results, we can construct the following prompt text:
[0059] "Your previous purchases of a portable photo printer and a professional-grade tripod demonstrate your interest in professional and practical photographic equipment. You were pleased with the speed of the photo printer but wished the colors were more vivid; you rated the tripod's stability highly. You recently purchased a digital camera, which you rated 4 stars. Please share your specific thoughts on this new camera, including its functionality and any specific experiences you had with it."
[0060] LLM Generate Comments
[0061] Using the above prompt text, LLM generates the following comment:
[0062] "This new digital camera performs well in low-light conditions and its ability to capture details is impressive. Although it is a bit larger than expected, the overall operation interface is intuitive and easy to carry. I am satisfied with its versatility and image quality, especially its fast autofocus function, which is perfect for dynamic photography."
[0063] According to the technical solution provided in the above embodiment, a prompt text is generated based on the user's preference for the target object and the text creation style, and a target is generated based on the prompt text. This not only satisfies the user's real preferences and avoids "polite" comments, but also showcases the user's unique style, thereby enhancing the relevance and authenticity of the comments.
[0064] In some embodiments, historical data includes at least two historical objects, and obtaining the user's historical data includes: obtaining historical objects and calculating the similarity between each historical object and the target object; obtaining historical objects whose similarity is greater than a preset value, and extracting historical text data corresponding to the historical objects whose similarity is greater than the preset value and historical behavior data corresponding to the historical objects whose similarity is greater than the preset value.
[0065] Specifically, for the richness of historical data, historical data corresponding to multiple historical objects can be selected. When selecting historical data, historical data corresponding to historical objects similar to the target object can be preferentially selected. That is, by analyzing the similarity between the historical object and the target object, historical objects with a similarity greater than a preset value (e.g., 0.7) are selected as the objects for extracting historical data. When analyzing the similarity, calculations can be performed using algorithms such as pre-similarity and Euclidean distance. Similarity factors that can be considered in the e-commerce field may include product type, price range, user rating, and description keywords.
[0066] Of course, if there are too many historical objects with similarities exceeding the preset value, historical objects with higher similarity can be selected based on the descending order of similarity. If the number of samples with similarities exceeding the threshold is too small, historical objects with similarities lower than the preset value can also be selected as historical data extraction objects.
[0067] According to the technical solution provided in the above embodiment, the system can obtain historical data related to the target object, and use these data to provide a basis for subsequent text creation style, preference and emotional expression, which can help the model generate more personalized target text.
[0068] In some embodiments, after obtaining the user's historical data, it also includes: if the historical data is returned as empty, obtaining the user's current behavior with respect to the target object; determining the user's preference for the target object based on the current behavior, and generating the target text based on the preference and a pre-trained model, wherein the pre-trained model represents a general text generation model.
[0069] Specifically, after the system completes the acquisition of historical data, the system needs to check whether the historical data has been successfully acquired. If the historical data is empty or insufficient, the user's preference for the target object can be directly determined based on the user's current behavior, and the target text can be generated based on the preference. For example, when obtaining the user's instructions or surveys on the target product, even if there is no historical data, personalized text generation can be maximized.
[0070] The current behavior may include the user's interactive behavior with the target object, including the number of views, clicking on the target object to view detailed information, etc. Even if there is no such behavior, the preference analysis can be performed by analyzing the time the user stays on the corresponding interface. For example, if the user clicks repeatedly multiple times (such as 8 times) within one minute, it is considered that the user has a positive preference for the target object. Of course, there is no limitation here.
[0071] Furthermore, after determining the user's preference, the target text can be generated using a pre-trained text generation model. The text generation model can also be said to have the ability to generate natural language after being trained on multiple text generation tasks.
[0072] According to the technical solution provided in the above embodiment, by identifying the user's current behavior, even in the absence of the user's historical data, the system can still use the user's current behavior to infer his or her preferences and generate relevant target text. This flexibility ensures that the system can adapt to the needs of different users and improves the user experience and the effectiveness of the recommendation system.
[0073] In some embodiments, after determining the target text for describing the target object based on the preference and text creation style, it also includes: returning the target text to the user through a visual interface, and receiving user feedback on the target text; and fine-tuning the large language model based on the feedback to obtain a fine-tuned large language model.
[0074] Specifically, after the target text is generated, the generated target text can be displayed through a visual interface. When the text is displayed, the generated target text can be presented directly, and an image of the target object, a rating star, etc. can also be included.
[0075] Furthermore, user feedback on the target text is received, and the feedback can be received through user description and rating. For example, user feedback is received through a rating system, when 5 points (out of 5 points) are received, it means that the user approves the generated target text, and when 1 point is received, it means that the user does not approve the generated target text.
[0076] Based on user feedback, we can understand whether the target text meets user expectations, which can help identify deficiencies in the generated text. User feedback can be incorporated into the model training data to enhance the model's understanding of user preferences.
[0077] According to the technical solution provided in the above embodiment, through visual display and feedback mechanism, users can actively participate in the target text generation process, enhance user satisfaction, and through the factual application of user feedback, the generated target text can be continuously optimized to ensure that it better meets the user's actual needs and expectations.
[0078] Figure 2 This is a flow chart of another text generation method provided in an embodiment of the present application. Figure 2 This application is further described.
[0079] First, we can obtain the user's historical data, including product information (i.e. historical objects) and user historical data, and build a data set to supervise and fine-tune the large language model to obtain a large language model with efficient processing capabilities.
[0080] At the same time, user behavior analysis is performed based on historical data to obtain the score of the target object. At this time, the target object means that the user has scored but has not published a text comment. Based on the score integration, a prompt text for generating a text comment (ie, the target text) is obtained.
[0081] Furthermore, by inputting the prompt text into the trained large language model, a text review based on the score can be generated. After that, the user's feedback on the text review is accepted to adjust the parameters of the large language model to improve the personalization and accuracy of the review.
[0082] In this way, by analyzing the user's historical purchase behavior and comments, we can construct personalized prompt text that contains the user's interest characteristics and writing style, and use this prompt text to guide the large language model to generate text comments, so that the generated text comments can more accurately reflect each user's unique style and preferences. And based on the score integration, it ensures that the generated text comments match the user's actual satisfaction in terms of emotional expression, solving the problem of "too polite" generated text in the existing technology.
[0083] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0084] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0085] Figure 3 Schematic diagram of a text generation device provided in an embodiment of the present application. Figure 3 As shown, the text generation device includes:
[0086] An acquisition module 301 is configured to acquire historical data of a user, where the historical data includes historical text data of the user for a historical object and historical behavior data of the user for a historical object;
[0087] A style determination module 302 is configured to determine the user's text creation style based on the historical text data and the historical behavior data;
[0088] The text generation module 303 is configured to determine the user's preference for the target object, and determine a target text for describing the target object according to the preference and the text creation style.
[0089] In some embodiments, the style determination module 302 is specifically used to extract key information from historical text data based on word frequency analysis to obtain a target phrase; based on the target phrase and the historical object corresponding to the target phrase, determine the user's text creation style, which includes the user's text creation preferences and language style.
[0090] In some embodiments, the text generation module 303 is specifically used to obtain the user's current behavior towards the target object, and map the current behavior to an emotion label; based on the emotion label and the language style, obtain the user's preference for the target object.
[0091] In some embodiments, the text generation module 303 is specifically used to generate prompt text based on preference and text creation style, the prompt text is used to guide the large language model to generate target text, and the large language model is used to perform the target text generation task; based on the prompt text and the target object, the target text is generated.
[0092] In some embodiments, the acquisition module 301 is specifically used to acquire historical objects, calculate the similarity between each historical object and the target object; acquire historical objects whose similarity is greater than a preset value, and extract historical text data corresponding to historical objects whose similarity is greater than the preset value and historical behavior data corresponding to historical objects whose similarity is greater than the preset value.
[0093] In some embodiments, the acquisition module 301 is specifically used to obtain the user's current behavior with respect to the target object if the historical data returned is empty; determine the user's preference for the target object based on the current behavior, and generate the target text based on the preference and a pre-trained text generation model, wherein the pre-trained text generation model represents a text generation model with the ability to generate natural language.
[0094] In some embodiments, the text generation module 303 is specifically used to return the target text to the user through a visual interface, and receive user feedback on the target text; fine-tune the large language model based on the feedback to obtain a fine-tuned large language model.
[0095] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0096] Figure 4 Schematic diagram of an electronic device 4 provided in an embodiment of the present application. Figure 4 As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 401 executes the computer program 403, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0097] The electronic device 4 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 4 may include, but is not limited to, a processor 401 and a memory 402. Those skilled in the art will appreciate that Figure 4 The electronic device 4 is merely an example and does not limit the electronic device 4 , and may include more or less components than those shown in the figure, or different components.
[0098] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0099] The memory 402 may be an internal storage unit of the electronic device 4, for example, a hard disk or memory of the electronic device 4. The memory 402 may also be an external storage device of the electronic device 4, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 4. The memory 402 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 402 is used to store computer programs and other programs and data required by the electronic device.
[0100] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0101] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. Computer-readable media may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0102] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A text generation method, characterized in that: include: Acquire historical data of a user, wherein the historical data includes historical text data of the user for a historical object and historical behavior data of the user for the historical object; Determining the text creation style of the user according to the historical text data and the historical behavior data; The user's preference for the target object is determined, and a target text for describing the target object is determined based on the preference and the text creation style.
2. The method according to claim 1, characterized in that The determining the text creation style of the user according to the historical text data and the historical behavior data includes: Extract key information from the historical text data based on word frequency analysis to obtain a target phrase; The text creation style of the user is determined according to the target phrase and the historical object corresponding to the target phrase, where the text creation style includes the text creation preference and language style of the user.
3. The method according to claim 2, characterized in that Determining the user's preference for the target object includes: Acquire the user's current behavior with respect to the target object, and map the current behavior into an emotion label; Based on the emotion label and the language style, the user's preference for the target object is obtained.
4. The method according to claim 3, characterized in that The step of determining a target text for describing the target object according to the preference and the text creation style includes: Generate a prompt text based on the preference and the text creation style, wherein the prompt text is used to guide the large language model to generate the target text, and the large language model is used to perform the target text generation task; The target text is generated based on the prompt text and the target object.
5. The method according to claim 2, characterized in that: The historical data includes at least two historical objects, and the acquiring of the historical data of the user includes: Acquire the historical objects, and calculate the similarity between each of the historical objects and the target object; The historical objects whose similarity is greater than a preset value are acquired, and the historical text data corresponding to the historical objects whose similarity is greater than the preset value and the historical behavior data corresponding to the historical objects whose similarity is greater than the preset value are extracted.
6. The method according to claim 4, characterized in that After obtaining the user's historical data, the method further includes: If the historical data returned is empty, obtaining the current behavior of the user with respect to the target object; The user's preference for the target object is determined based on the current behavior, and the target text is generated based on the preference and a pre-trained text generation model, wherein the pre-trained text generation model represents a text generation model capable of generating natural language.
7. The method according to claim 4, characterized in that After determining the target text for describing the target object according to the preference and the text creation style, the method further includes: Returning the target text to the user through a visual interface, and receiving feedback from the user on the target text; The large language model is fine-tuned based on the feedback to obtain the fine-tuned large language model.
8. A text generation device, characterized in that: include: An acquisition module is configured to acquire historical data of a user, wherein the historical data includes historical text data of the user for a historical object and historical behavior data of the user for the historical object; A style determination module, configured to determine the text creation style of the user according to the historical text data and the historical behavior data; The text generation module is configured to determine the user's preference for the target object, and determine a target text for describing the target object based on the preference and the text creation style.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.