Marketing text generation method and device, electronic equipment and storage medium
By using large language models and retrieval enhancement technology, multi-style prompt words are constructed, which solves the problems of inaccurate descriptions and monotonous styles in the content of bank wealth management product disclosure sheets, and realizes the efficient generation and personalized output of multi-style marketing texts.
Patent Information
- Application Number
- CN202410460070.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-17
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-04-17
AI Technical Summary
Existing technologies often contain inaccurate descriptions, misunderstandings, and a lack of diversity in marketing styles in the informational materials for bank wealth management products and newly launched business products. They also cannot be processed in batches, and the traditional machine learning models used for generation are unstable and difficult to migrate.
By employing a large language model combined with search enhancement design specifications for prompt words, constructing multi-style prompt words and using vector database retrieval, utilizing the LLM large language model for multi-style transfer generation, and combining it with a multi-style marketing classification model for review, multi-style marketing text generation is achieved.
It enables the generation of marketing texts in various styles, improves the stability and personalization of the generated results, reduces the amount of training data required, supports multi-scenario applications of long and short texts, and improves generation efficiency and consistency.
Smart Images

Figure CN118350348B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large language model technology, and in particular to a marketing text generation method, apparatus, electronic device, and storage medium. Background Technology
[0002] Explanatory sheets can transform complex and highly technical text into easily understandable expressions. They are commonly found in bank wealth management products and newly launched business products.
[0003] In related technologies, the informational materials for bank wealth management products and newly launched business products, such as personal pension plans, require manual explanation and clarification, which leads to problems such as inaccurate descriptions, misunderstandings, and a lack of diverse marketing styles. Furthermore, batch processing is not feasible. Summary of the Invention
[0004] This application provides a marketing text generation method, apparatus, electronic device, and storage medium to achieve the generation of various marketing styles.
[0005] The embodiments of this application adopt the following technical solutions:
[0006] In a first aspect, embodiments of this application provide a marketing text generation method, wherein the method includes:
[0007] Receives raw text and text generation instructions in different styles;
[0008] Based on the original text and the texts of different styles, construct prompt words;
[0009] Based on the provided prompts, the large language model is engineered;
[0010] Based on the aforementioned large language model, the target marketing text is output.
[0011] In some embodiments, the original text includes long text and / or short text, constructing cue words including:
[0012] If the original text includes short text and is highly relevant to the target marketing text, construct at least the short text including the original text, style words, text generation sample, and the first prompt word Prompt1 for the task instruction;
[0013] When the original text includes long text and has low relevance to the target marketing text, style word vectors are constructed, and multiple similar relevance vectors are matched based on the style word vectors; and
[0014] Based on the mapping results between the multiple association vectors and the long text of the original text, a second prompt word Prompt2 is constructed, which includes at least the short text corresponding to the mapping results, style words, text generation examples, and task instructions.
[0015] In some embodiments, the mapping result between the plurality of association vectors and the long text of the original text includes:
[0016] Vectorize the style tags to obtain the style word vector for each style;
[0017] The original long text slice is divided into text blocks, and each text block is converted into a vector representation and stored in a vector database. The vector database stores the text block corresponding to each vector and a pointer to the vector.
[0018] The style word vectors are used to search the index in the vector database to obtain multiple text blocks with vector similarity that meet the requirements;
[0019] Based on the style word vectors provided in the index, perform an approximate nearest neighbor search on the vector database to return the most similar related vectors in the given vector space.
[0020] The returned multiple association vectors are mapped back to the corresponding text blocks as contextual background content in the prompt words.
[0021] In some embodiments, the step of constructing a second prompt word Prompt2, which includes at least the short text corresponding to the mapping result, style words, text generation examples, and task instructions, based on the mapping result between the plurality of association vectors and the long text of the original text, further includes:
[0022] Search enhancement based on knowledge graph system APIs and web search APIs as prompts.
[0023] In some embodiments, the step of constructing a second prompt word Prompt2, which includes at least the short text corresponding to the mapping result, style words, text generation examples, and task instructions, based on the mapping result between the plurality of association vectors and the long text of the original text, further includes:
[0024] The ReAct framework is used to retrieve different knowledge content and evaluate whether the knowledge content is suitable as background information input for target marketing texts.
[0025] In some embodiments, the step of outputting target marketing text based on the large language model includes:
[0026] Leveraging the general capabilities of the LLM large language model, perform multi-style transfer text generation tasks to generate targeted marketing text.
[0027] In some embodiments, the method further includes:
[0028] The classification results in the target marketing text are obtained by using a pre-trained multi-style marketing classification model. The multi-style marketing classification model combines a large language model and classification evaluation instructions. The training is fine-tuned by instructions to ensure the expected classification evaluation performance on the test set. Each set of data in the training data includes: sample text data and the style label corresponding to the sample text data.
[0029] Based on the classification results, determine whether the classification results of the target marketing text meet the standards;
[0030] If so, the target marketing text generated by the target style will be output.
[0031] If not, then optimize the suggested words.
[0032] Secondly, embodiments of this application also provide a marketing text generation apparatus, wherein the apparatus includes:
[0033] The receiving module is used to receive raw text and text generation instructions in different styles;
[0034] A construction module is used to construct prompt words based on the original text and the texts of different styles;
[0035] A generation module is used to engineer the large language model based on the prompt words;
[0036] The output module is used to output target marketing text based on the large language model.
[0037] Thirdly, embodiments of this application also provide an electronic device, including: a processor; and a memory arranged to store computer-executable instructions, which, when executed, cause the processor to perform the above-described method.
[0038] Fourthly, embodiments of this application also provide a computer-readable storage medium that stores one or more programs, which, when executed by an electronic device including multiple applications, cause the electronic device to perform the above-described method.
[0039] The at least one technical solution adopted in this application embodiment can achieve the following beneficial effects: receiving original text and text generation instructions of different styles; then constructing prompt words based on the original text and the text of different styles. Next, engineering the large language model based on the prompt words; and outputting target marketing text based on the large language model. Using the large language model, the data in the knowledge base can be fully utilized and analyzed to meet the needs of generating more personalized and anthropomorphic marketing text. Attached Figure Description
[0040] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0041] Figure 1 This is a flowchart illustrating the marketing text generation method in the embodiments of this application;
[0042] Figure 2 This is a schematic diagram illustrating the principle of the marketing text generation method in the embodiments of this application;
[0043] Figure 3 This is a schematic diagram of one implementation method of the marketing text generation method in the embodiments of this application (short text processing);
[0044] Figure 4 This is a second schematic diagram of the implementation method of the marketing text generation method in this application (long text processing);
[0045] Figure 5 This is a schematic diagram illustrating the optimization method of prompt words in the marketing text generation method in this application embodiment;
[0046] Figure 6 This is a schematic diagram of the marketing text generation device in the embodiments of this application;
[0047] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0048] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0049] The technical terms used in this application are as follows:
[0050] Explanatory notes: Transforming complex and highly technical texts about bank wealth management products and newly launched business products, such as personal pension funds, into easily understandable language.
[0051] Large Language Models: Ultra-large-scale deep learning models pre-trained on massive amounts of data. The underlying converters are a set of neural networks consisting of encoders and decoders with self-attention capabilities. The encoders and decoders extract meaning from a series of texts and understand the relationships between words and phrases within them.
[0052] Search enhancement: a technique that supplements text with information from private or proprietary data sources. If the system is required to keep up with real-time dynamics and needs to incorporate the latest information when obtaining answers, this technique can provide real-time knowledge supplementation.
[0053] Thought chain: Simply put, it's a series of intermediate reasoning steps, a set of typical steps followed by human thought processes when solving reasoning tasks. It involves breaking down a problem into a series of sub-problems, solving each sub-problem one by one, and then arriving at the final result.
[0054] The following challenges currently exist in our business scenarios:
[0055] (1) The content of the information leaflet is monotonous, lacks vividness and interest, and is difficult to attract customers' attention.
[0056] (2) The content of the explanation paper is too professional and theoretical, and it is difficult for people outside the industry to understand and accept it.
[0057] (3) The style of the paper is too monotonous and it is difficult to attract customers' interest and resonance.
[0058] Multi-style text generation refers to the computer-generated text content in various styles or style variations. Its background stems from the need for natural language generation to meet the text generation requirements of different scenarios, user preferences, and purposes. The goal of multi-style text generation is to ensure that the generated text matches a specific style in terms of language style, emotional tone, and word choice habits. However, multi-style text generation faces the following technical difficulties:
[0059] First, defining and modeling style is an open-ended problem. There is no clearly defined standard to describe a style, and how to abstract and represent the style of text, as well as how to quantify and control style, are challenging issues. Furthermore, most existing text generation technologies can only generate text with a single style, and cannot generate text that simultaneously contains multiple styles.
[0060] Secondly, existing text generation models are typically trained on large-scale corpora, which cannot cover all possible style variations. Therefore, the model needs to have a certain generalization ability, capable of generating text in styles beyond the training data. However, multi-style text generation requires multiple models concatenated, which are unrelated to each other, wasting training resources and leading to a decline in the quality of multi-style transfer. Furthermore, using reinforcement learning to generate multi-style text combines style loss with the generation model loss to achieve multi-style transfer. However, since text content and style are difficult to process separately, it cannot solve the problem of different styles influencing each other.
[0061] Then, multi-style text generation also needs to address the issue of consistency. It is necessary to maintain consistency in style to avoid situations where semantics, word choice, or other aspects do not conform to a specific style.
[0062] Finally, it is important to balance the consistency between the style and content of the text during the generation process. Overly pursuing stylistic expression may affect the logic and readability of the text.
[0063] During their research, the inventors discovered that current explanations of informational leaflets by various financial institutions and banks primarily rely on manual interpretation and clarification, leading to inaccurate descriptions and misunderstandings. Furthermore, the text generation methods used often employ traditional machine learning models or algorithms such as RNNs, LSTMs, and Transformers, requiring one-to-one model training for specific text styles. This results in significant transfer learning difficulties and inconsistent generation quality.
[0064] Given that there are many text conversion scenarios in the banking system, such as financial product introductions and business processing instructions, these tasks require highly skilled personnel and rely heavily on work experience. They cannot be processed in large batches and suffer from low efficiency.
[0065] To address the aforementioned shortcomings, a novel multi-style text generation method is proposed. This method combines a large-scale pre-trained language model with user profiles and uses Prompt input to enhance design specifications, outputting customized style text to customers for easier understanding. Furthermore, it leverages the cognitive chain and large-scale model classification capabilities to review the generated content, ensuring greater rigor and accuracy.
[0066] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0067] This application provides a method for generating marketing text, such as... Figure 1 The diagram illustrates a marketing text generation method in an embodiment of this application. The method includes at least the following steps S110 to S140:
[0068] Step S110: Receive the original text and text generation instructions in different styles.
[0069] The original text refers to the original text, which may include long or short text.
[0070] Text generation instructions include different styles of text generation instructions, such as the use of style tag words in the instructions.
[0071] The embodiments of this application are limited by the existing large language models' limited capacity for input text length, thus large language models mostly focus on processing short texts. On the other hand, they can conveniently meet the needs of generating multi-style marketing texts in various scenarios, and may also cover scenarios involving long texts.
[0072] Step S120: Construct prompt words based on the original text and the texts of different styles.
[0073] Based on the original text and texts of different styles, training sets such as "sample texts" and "label words" can be prepared to construct prompt words.
[0074] Preferably, it is also necessary to carry out standardized design of prompt word engineering, assembling parts such as character settings, task instructions, sample data, background content, and pre-questioning.
[0075] Step S130: Engineer the large language model based on the prompt words.
[0076] By further engineering the large language model based on the prompt words, the general capabilities of the pre-configured LLM large language model can usually be utilized to perform multi-style transfer text generation tasks and generate the target text.
[0077] Step S140: Based on the large language model, output the target marketing text.
[0078] The large language model can output targeted marketing text. It's important to note that this targeted marketing text is one that has undergone style evaluation and meets preset requirements. If it doesn't meet the requirements, the prompts will be adjusted.
[0079] By adopting the above method, online generation using a large language model eliminates the need for multiple language processing models to be chained together, and eliminates the need to train models from scratch for specific tasks, thus reducing development effort. Furthermore, the general generation capability can cover all possible style variations.
[0080] Unlike related technologies that can only generate text in a single style and cannot generate marketing text that simultaneously incorporates multiple styles, the method described above requires only a small training set to obtain a generalized large language model.
[0081] Unlike other related technologies that primarily employ traditional machine learning models or algorithms such as RNNs, LSTMs, and Transformers, which require one-to-one model training for specific text styles, leading to high transfer learning difficulty and inconsistent generation results, the method described above utilizes a large language model. This reduces the required amount of training data, allowing for the direct design of prompt words to excellently complete text generation tasks, and enabling the generation of text that incorporates multiple styles simultaneously.
[0082] By adopting the above method, we can also avoid being limited by the length of the original text and the influence between style words, making the target style text generation scheme more unified and the application more scalable.
[0083] Using the above methods, a solution for multi-style transfer text generation based on style representation of a retrieval-enhanced generative large language model is proposed, which realizes comprehensive and controllable text generation when the original text is long or short.
[0084] In one embodiment of this application, the original text includes long text and / or short text. Constructing a prompt word includes: when the original text includes short text and has a high degree of relevance to the target marketing text, constructing a first prompt word Prompt1 that includes at least the short text of the original text, style words, text generation examples, and task instructions; when the original text includes long text and has a low degree of relevance to the target marketing text, constructing style word vectors and matching multiple similar association vectors based on the style word vectors; and constructing a second prompt word Prompt2 that includes at least the short text corresponding to the mapping result, style words, text generation examples, and task instructions based on the mapping result between the multiple association vectors and the long text of the original text.
[0085] like Figure 2 As shown, the process mainly includes text input, style word input, design prompts through normalization and retrieval enhancement, generation of multi-style marketing text using a large language model, text validation and evaluation feedback iteration, and marketing text output. By distinguishing between long and short texts based on the original text length, this approach addresses the limitations of current large language models on input text length while conveniently meeting the diverse needs of generating multi-style marketing text across various scenarios.
[0086] If the original text includes short text and is highly relevant to the target marketing text, a short text is constructed that includes at least the original text, style words, text generation examples, and the first prompt word "Prompt1" for the task instruction. For example... Figure 2 As shown, "Prompt1" can be optimized through search enhancement, or it can be filtered based on evaluation metrics for large model classification results.
[0087] Furthermore, when the original text includes long text and has low relevance to the target marketing text, style word vectors are constructed, and multiple similar association vectors are matched based on the style word vectors. Through the mapping results between the constructed multiple association vectors and the long text of the original text, a second prompt word, Prompt2, is constructed, which includes at least the short text corresponding to the mapping result, style words, text generation examples, and task instructions. Figure 2 As shown, the "Second Prompt2" can be optimized through search enhancement, or it can be filtered based on evaluation metrics for the classification results of large models.
[0088] By designing a standardized process that includes role setting, task instructions, sample data, background content, pre-questioning, and search enhancement, we achieve multi-style marketing text generation for large models in few-shot environments. In particular, through text slicing vectorization and vector database retrieval techniques, we have enabled the transfer and generation of multi-style marketing text from long texts.
[0089] Please refer to Figure 3 This is a schematic diagram of one implementation method of the marketing text generation method in this application embodiment, which specifically includes the following steps:
[0090] Step S310: Receive the instruction sent by the requester to generate target multi-style text, the instruction containing N style tag words.
[0091] Style tags are constructed according to a multi-layered approach, such as dividing style tags into target audience-specific writing styles and general knowledge-based writing styles.
[0092] Among them, customer-oriented content can be categorized by customer profile tags, such as young people, middle-aged people, elderly people, or elites, white-collar workers, blue-collar workers, etc.
[0093] Among them, general knowledge-based writing styles are mainly classified by text genre and tone, and can be divided into lyrical, expository, everyday life, or styles such as Zhen Huan style, Lin Daiyu style, and Qiong Yao style.
[0094] Step S320: Receive the original text Text sent by the requester, and generate style texts TextN1, TextN2, and TextN3, where the original text is a short text.
[0095] Prepare a small amount of sample text data (e.g., 3-5 pieces) that correspond one-to-one with the multi-style tags. The accuracy of style semantic matching between tag words and sample texts can be improved by fine-tuning the large language model for multi-classification tasks. Among them, the sample texts of multi-style marketing texts play a few-shot fine-tuning effect in the large language model.
[0096] It should be noted that the algorithm for fine-tuning the instructions in this application embodiment is the LoRA algorithm. The core of LoRA is to add the product of low-rank matrices as trainable parameters to the original weight matrix as a bypass, so as to simulate the amount of parameter change.
[0097] Step S330: Design the prompt word, which includes the original text Text, style word N, text generation example, task instructions, etc.
[0098] Standardize the design of prompt words, assembling parts such as character settings, task instructions, sample data, background content, and pre-questions.
[0099] Among them, the role setting can be designed as "hoping that the model plays a certain role, such as copywriter, text polisher, etc."
[0100] The task instructions should be clear, placed at the beginning of the prompt, and separated from the background context using clear delimiters such as "###". The desired elements, formats, and styles should be specifically stated.
[0101] The sample data can be one or more, with more data output being more ideal. In addition, the background content mainly consists of context and original text.
[0102] Step S340: Using the preset LLM large language model, input the prompt word Prompt to generate target text of the corresponding style.
[0103] Leveraging the general capabilities of the LLM (Large Language Model), this project performs multi-style transfer text generation tasks to generate target text. The LLM is based on the transformer framework, which includes encoders and decoders. It primarily employs autoregressive or autoencoder models, using a self-attention mechanism to continuously predict the next possible token, thus achieving style transfer in text generation.
[0104] Step S350: Construct a classification evaluator corresponding to N label words using a high-quality sample dataset and a large model. Input the target text into the classification evaluator and obtain the style evaluation score.
[0105] A multi-style marketing classification model is constructed. Using a high-quality sample dataset and a large model, a classifier is built for N style tag words. The target text is input into the classifier to obtain its style evaluation score. The dataset uses sample text data with style tags. The model structure combines a large language model with classification evaluation instructions. Fine-tuning the training through instructions ensures good classification performance on the test set. The main function of this model is to review and score multi-style marketing texts generated by the large model, achieving basic controllability of the text style output. The target text is input into the multi-style classification model to obtain the classification result.
[0106] Step S360: Determine whether the style classification result of the target text is greater than a preset threshold. If so, send the target text to the requester; otherwise, optimize the prompt word design until the score meets the requirements.
[0107] A preset classification evaluation threshold is set, and the classification result of the target text is judged to see if it meets the standard. If it does, the text generated in the target style is output; otherwise, the prompt words are optimized, sample data is supplemented, and the large model is called again to generate new target text.
[0108] According to the above Figure 3 This method enables the rapid generation of multi-style marketing target text. By using a large language model, the required amount of training data is reduced, and text generation tasks can be performed excellently simply by designing prompt words. It can generate text that includes multiple styles simultaneously. Online generation using a large language model eliminates the need for multiple models concatenated together or for training models from scratch for specific tasks, reducing development effort, and its general generation capability covers all possible style variations.
[0109] Please refer to Figure 4 This is a second schematic diagram illustrating the implementation method of the marketing text generation method in this application embodiment, which specifically includes the following steps:
[0110] Step S410: Receive the instruction sent by the requester to generate target multi-style text, the instruction containing N style tag words.
[0111] Step S420: Receive the original text Text sent by the requester, wherein the original text is a long text and some of its content is unrelated to style words.
[0112] The system receives instructions from the requester regarding the generation of multi-style text, containing N style tag words. It also receives the original text (Text) from the requester, which is a long text and contains content unrelated to the style tags.
[0113] Step S430: Input the style tag words into the vectorization model to obtain style vector words.
[0114] In practice, a text embedding model is used to vectorize multi-style tag words, obtaining a vector representation for each style. This invention uses the bge-large vectorization model. To enrich the semantics of style tag words, (style tag, style definition description) can be combined and input into the text embedding model to obtain style tag vectors.
[0115] Step S440: The original text is segmented into blocks, each block is converted into a vector using a vectorization model, and stored in a vector database.
[0116] In practice, the original long text slice is divided into blocks, and each block is converted into a vector representation using a text embedding model and stored in a vector database. Each vector contains the corresponding text block and a pointer to that vector. It is understood that the text segmentation uses window overlap to avoid semantic continuity interruptions, and the tool used is langchain. Those skilled in the art can use other segmentation methods, and this application does not impose specific limitations on these methods in its embodiments.
[0117] Step S450: Use style word vectors to retrieve interpolations from the index in the vector database, and set the retrieval quantity K, where K represents the number of text blocks related to the style words to be retrieved.
[0118] Use style word vectors to perform indexed queries on the vector database, and set the number of searches to K, where K represents the number of text blocks related to the style words to be searched, i.e., the top K text blocks with high vector similarity.
[0119] In step S460, the vector database performs an approximate nearest neighbor (ANN) search on the style word vectors provided in the index and returns the K most similar vectors in the vector space.
[0120] The vector database performs an approximate nearest neighbor search (ANN) on the style word vectors provided in the index, returning the K most similar vectors in a given vector space. The ANN implementation is as follows: 1) Given a set S of n vectors of dimension f, where n represents the number of text blocks, f represents the dimension of the vector output by the embedding model, and set S represents the text block vector space stored in the vector database; 2) The distance between vectors a and b is represented by the dot product of normalized vectors, i.e., cosine similarity d = cos(a, b), with smaller distances indicating greater similarity between a and b; 3) Given a vector q of dimension f, find the K vectors in S that are closest to q, where vector q represents a style tag vector. Those skilled in the art can use other search algorithms, and this application does not impose specific limitations on these algorithms.
[0121] Step S470: The retrieved K vector inputs are mapped to the original text blocks representing them and concatenated into text TextK.
[0122] Design prompts. Map the returned vectors back to the corresponding text blocks as the contextual background content in the prompts. Combine character settings, task instructions containing style words, small text sample data, and pre-questions to construct the prompts.
[0123] Step S480: Design the prompt word, which includes the text TextK, style word N, text generation sample, task instructions, etc. In particular, the instructions include "Please complete step by step and optimize yourself".
[0124] Step S490: Using the preset LLM large language model, input the prompt word Prompt to generate target text of the corresponding style.
[0125] Step S4100: Construct a classification evaluator corresponding to N label words using a high-quality sample dataset and a large model. Input the target text into the classification evaluator and obtain the style evaluation score.
[0126] Step S4110: Determine whether the style classification result of the target text is greater than a preset threshold. If so, send the target text to the requester; otherwise, optimize the prompt word design until the score meets the requirements.
[0127] Step S4120: Using the ReAct framework, different knowledge content is retrieved through semantic keywords, etc., and the suitability of this content as background information input is evaluated for the generation target.
[0128] The ReAct framework is used to retrieve different knowledge content through semantic keywords and other methods, and to evaluate whether this content is suitable as background information input for generating the target. The ReAct framework is a general decision-making and reasoning framework that combines reasoning, action, and planning, effectively integrating the planning, action, and reasoning functions of a large language model. For the retrieved knowledge content, relevance evaluation metrics are used to assess its suitability as background information input, thus filtering the knowledge content. This operation is also implemented by combining the large model with prompt word engineering.
[0129] Step S4130: Register the knowledge graph system API, network search API, etc., using a custom function, and specify the knowledge content and scope that the API services can access.
[0130] By adding a new search enhancement module, the design of suggestion words can be optimized until the evaluation score meets the requirements.
[0131] This project utilizes custom functions to register knowledge graph system APIs and web search APIs, specifying the knowledge content and scope accessible through these API services. The knowledge graph system API is an interface based on knowledge graphs, allowing developers to access and manipulate data within the knowledge graph through custom functions. The web search API is an interface for accessing internet search engines; custom functions are used to perform web searches and retrieve search results, thereby obtaining relevant knowledge content.
[0132] Step S4140: Output and send marketing text.
[0133] By designing the ReAct framework and mind chain model, the text generation effect is continuously fed back and iterated, achieving style control and review of large-scale model text generation.
[0134] Through the above methods, we can improve the economy of generating large language models, design and combine prompt words in multi-style marketing text generation, enhance retrieval generation capabilities, and build classification evaluation based on large models.
[0135] pass Figure 4 The method integrates raw text data, style tag data, and knowledge bases from external business systems. Using a large language model, it fully utilizes and analyzes the data in the knowledge base to meet more personalized and human-like text generation needs. Enhanced semantic keyword retrieval and the design of prompt word combinations used in API tools are not limited by the length of the original text or the influence between style words, resulting in a more unified target style text generation scheme and stronger application scalability.
[0136] In one embodiment of this application, the mapping result between the multiple association vectors and the long text of the original text includes: vectorizing style tags to obtain style word vectors corresponding to each style; segmenting the original long text into text blocks, and converting each text block into a vector representation and storing it in a vector database, wherein the vector database stores the text block corresponding to each vector and a pointer to the vector; using the style word vectors to search the index in the vector database to obtain multiple text blocks whose vector similarity meets the requirements; performing an approximate nearest neighbor search on the style word vectors provided in the index according to the vector database to return the multiple most similar association vectors in the given vector space; and mapping the returned multiple association vectors back to the corresponding text blocks as contextual background content in the prompt words.
[0137] For cases where the original text is long, especially where most of the content is not relevant to the target generated text or is not strongly related to the target style, the embodiments of this application provide a more optimized solution:
[0138] a. Use a text model to vectorize multi-style tag words to obtain the vector representation corresponding to each style.
[0139] b. Divide the original long text slice into blocks, use a text model to convert each block into a vector representation and store it in a vector database, and save the text block corresponding to each vector and the pointer to the vector respectively.
[0140] c. Use style word vectors to perform index retrieval queries on the vector database, setting the retrieval quantity K, where K represents the number of text blocks related to the style words to be retrieved, i.e., the top K text blocks with high vector similarity.
[0141] d. The vector database performs an approximate nearest neighbor search (ANN) on the style word vectors provided in the index, returning the K most similar vectors in the given vector space.
[0142] e. Design prompts. Map the returned vectors back to the corresponding text blocks as the contextual background content in the prompts. Combine character settings, task instructions containing style words, small text sample data, and pre-questions to construct the prompts.
[0143] In one embodiment of this application, the step of constructing a second prompt word Prompt2, which includes at least the short text corresponding to the mapping result, style words, text generation examples, and task instructions, based on the mapping result of the multiple association vectors and the long text of the original text, further includes: retrieval enhancement based on knowledge graph system API and network search API as prompt words.
[0144] like Figure 5 As shown, a custom function is used to register knowledge graph system APIs, online search APIs, etc., specifying the knowledge content and scope that the API services can obtain.
[0145] As is understandable, a knowledge graph system API is an interface based on knowledge graphs that allows developers to access and manipulate data in the knowledge graph through custom functions.
[0146] As we can understand, an Internet search API is an interface used to access Internet search engines. It allows users to perform online searches and retrieve search results through custom functions, thereby obtaining relevant knowledge content.
[0147] In one embodiment of this application, the step of constructing a second prompt word Prompt2, which includes at least the short text corresponding to the mapping result, style words, text generation examples, and task instructions, based on the mapping result of the multiple association vectors and the long text of the original text, further includes: retrieving different knowledge content based on the ReAct framework, and evaluating whether the knowledge content is suitable as background information input for the target marketing text.
[0148] like Figure 5 As shown, the ReAct framework is used to retrieve different knowledge content through semantic keywords and other means, and to evaluate whether this content is suitable as background information input for generating the target.
[0149] It's important to note that the ReAct framework is a general decision-making and reasoning framework that combines reasoning, action, and planning, effectively integrating the planning, action, and reasoning capabilities of large language models. For retrieved knowledge content, a relevance evaluation metric is used to assess its suitability as background information input, filtering the knowledge content. This process is also implemented by combining the large model with prompt word engineering.
[0150] Understandably, the ReAct prompting large language model is used to generate verbal reasoning trajectories and actions for the task. This enables the system to perform dynamic reasoning to create, maintain, and adjust action plans, while also supporting interaction with external environments (e.g., document search repositories, knowledge graph systems) to incorporate additional information into the reasoning.
[0151] By using the ReAct framework, multiple loop queries can be performed, thereby enabling the decision to autonomously generate marketing text.
[0152] In one embodiment of this application, the step of outputting target marketing text based on the large language model includes: performing a multi-style transfer text generation task using the general capabilities of the LLM large language model to generate target marketing text.
[0153] In practical implementation, the general capabilities of the LLM (Large Language Model) are utilized to perform multi-style transfer text generation tasks and generate target text. The foundation of the LLM is the transformer framework, which includes encoders and decoders. It is mainly divided into autoregressive or autoencoder models, which continuously predict the next possible token through a self-attention mechanism to achieve text style transfer generation.
[0154] In one embodiment of this application, the method further includes: obtaining the classification result of the target marketing text through a pre-trained multi-style marketing classification model, wherein the multi-style marketing classification model adopts a combination of a large language model and classification evaluation instructions, and fine-tunes the training through instructions to ensure the expected classification evaluation performance on the test set, and each set of data in the training data includes: sample text data and style labels corresponding to the sample text data; based on the classification result, determining whether the classification result of the target marketing text meets the standard; if so, outputting the target marketing text generated by the target style.
[0155] In practice, when building a multi-style marketing classification model, a classification evaluator corresponding to N style tag words is constructed using a "high-quality" sample dataset and a large model. The target text is input into the classification evaluator to obtain the style evaluation score.
[0156] Furthermore, the dataset uses sample text data with style labels, and the model structure combines a large language model with classification evaluation instructions. Fine-tuning training through these instructions ensures good classification performance on the test set. The model's main function is to review and score multi-style marketing texts generated by the large model, ensuring basic control over the text style output. The target text is input into the multi-style classification model to obtain the classification results.
[0157] This application embodiment also provides a marketing text generation device 600, such as... Figure 6 The diagram shows a schematic representation of a marketing text generation device in an embodiment of this application. The marketing text generation device 600 includes at least: a receiving module 610, a construction module 620, a generation module 630, and an output module 640, wherein:
[0158] In one embodiment of this application, the receiving module 610 is specifically used to: receive original text and text generation instructions of different styles.
[0159] The original text refers to the original text, which may include long or short text.
[0160] Text generation instructions include different styles of text generation instructions, such as the use of style tag words in the instructions.
[0161] The embodiments of this application are limited by the existing large language models' limited capacity for input text length, thus large language models mostly focus on processing short texts. On the other hand, they can conveniently meet the needs of generating multi-style marketing texts in various scenarios, and may also cover scenarios involving long texts.
[0162] In one embodiment of this application, the construction module 620 is specifically used to: construct prompt words based on the original text and the texts of different styles.
[0163] Based on the original text and texts of different styles, training sets such as "sample texts" and "label words" can be prepared to construct prompt words.
[0164] Preferably, it is also necessary to carry out standardized design of prompt word engineering, assembling parts such as character settings, task instructions, sample data, background content, and pre-questioning.
[0165] In one embodiment of this application, the generation module 630 is specifically used to: engineer a large language model based on the prompt words.
[0166] By further engineering the large language model based on the prompt words, the general capabilities of the pre-configured LLM large language model can usually be utilized to perform multi-style transfer text generation tasks and generate the target text.
[0167] In one embodiment of this application, the output module 640 is specifically used to: output target marketing text based on the large language model.
[0168] The large language model can output targeted marketing text. It's important to note that this targeted marketing text is one that has undergone style evaluation and meets preset requirements. If it doesn't meet the requirements, the prompts will be adjusted.
[0169] It is understood that the marketing text generation device described above can implement each step of the marketing text generation method provided in the foregoing embodiments. The relevant explanations of the marketing text generation method are applicable to the marketing text generation device and will not be repeated here.
[0170] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Please refer to it. Figure 7 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and memory. The memory may include main memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the electronic device may also include other hardware required for other business operations.
[0171] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0172] Memory is used to store programs. Specifically, programs may include program code, which includes computer operation instructions. Memory may include main memory and non-volatile memory, and provides instructions and data to the processor.
[0173] The processor reads the corresponding computer program from non-volatile memory into main memory and then runs it, forming a marketing text generation device at the logical level. The processor executes the program stored in memory and specifically performs the following operations:
[0174] Receives raw text and text generation instructions in different styles;
[0175] Based on the original text and the texts of different styles, construct prompt words;
[0176] Based on the provided prompts, the large language model is engineered;
[0177] Based on the aforementioned large language model, the target marketing text is output.
[0178] The above is as stated in this application. Figure 1 The marketing text generation device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0179] The electronic device can also perform Figure 1 The method for executing a marketing text generation device, and the implementation of the marketing text generation device in... Figure 1 The functions of the embodiments shown are not described again in this application.
[0180] This application also proposes a computer-readable storage medium that stores one or more programs, the programs including instructions that, when executed by an electronic device including multiple applications, enable the electronic device to perform... Figure 1 The method executed by the marketing text generation device in the illustrated embodiment is specifically used to perform:
[0181] Receives raw text and text generation instructions in different styles;
[0182] Based on the original text and the texts of different styles, construct prompt words;
[0183] Based on the provided prompts, the large language model is engineered;
[0184] Based on the aforementioned large language model, the target marketing text is output.
[0185] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0186] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0187] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0188] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0189] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0190] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0191] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0192] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0193] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0194] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for generating marketing text, wherein, The method includes: Receives raw text and text generation instructions in different styles; Based on the original text and the texts of different styles, construct prompt words; The original text includes long text and / or short text, and prompt words are constructed, including: If most of the content in the original text is not relevant to the target generated text or is not strongly related to the target style, it is considered to have a low relevance to the target marketing text; otherwise, it is considered to have a high relevance to the target marketing text. If the original text includes short text and is highly relevant to the target marketing text, construct a short text that includes at least the original text, style words, text generation examples, and the first prompt word Prompt1 for the task instruction; When the original text includes long text and has low relevance to the target marketing text, style word vectors are constructed, and multiple similar relevance vectors are matched based on the style word vectors; and Based on the mapping results between the multiple association vectors and the long text of the original text, a second prompt word Prompt2 is constructed, which includes at least the short text corresponding to the mapping results, style words, text generation examples, and task instructions. The mapping results between the multiple association vectors and the long text of the original text include: Vectorize the style tags to obtain the style word vector for each style; The original long text slice is divided into text blocks, and each text block is converted into a vector representation and stored in a vector database. The vector database stores the text block corresponding to each vector and a pointer to the vector. The style word vectors are used to search the index in the vector database to obtain multiple text blocks with vector similarity that meet the requirements; Based on the style word vectors provided in the index, perform an approximate nearest neighbor search on the vector database to return the most similar related vectors in the given vector space. The returned multiple association vectors are mapped back to the corresponding text blocks as contextual background content in the prompt words; Based on the provided prompts, the large language model is engineered; Based on the aforementioned large language model, the target marketing text is output.
2. The method as described in claim 1, wherein, The step of constructing a second prompt word, Prompt2, which includes at least the short text corresponding to the mapping result, style words, text generation examples, and task instructions, based on the mapping result between the multiple association vectors and the long text of the original text, further includes: Search enhancement based on knowledge graph system APIs and web search APIs as prompts.
3. The method as described in claim 1, wherein, The step of constructing a second prompt word, Prompt2, which includes at least the short text corresponding to the mapping result, style words, text generation examples, and task instructions, based on the mapping result between the multiple association vectors and the long text of the original text, further includes: The ReAct framework is used to retrieve different knowledge content and evaluate whether the knowledge content is suitable as background information input for target marketing texts.
4. The method as described in claim 1, wherein, The output of target marketing text based on the large language model includes: Leveraging the general capabilities of the LLM large language model, perform multi-style transfer text generation tasks to generate targeted marketing text.
5. The method as described in claim 1, wherein, The method further includes: The classification results in the target marketing text are obtained by using a pre-trained multi-style marketing classification model. The multi-style marketing classification model combines a large language model and classification evaluation instructions. The training is fine-tuned by instructions to ensure the expected classification evaluation performance on the test set. Each set of data in the training data includes: sample text data and the style label corresponding to the sample text data. Based on the classification results, determine whether the classification results of the target marketing text meet the standards; If so, output the target marketing text generated by the target style; If not, then optimize the suggested words.
6. A marketing text generation device, wherein, The device includes: The receiving module is used to receive raw text and text generation instructions in different styles; A construction module is used to construct prompt words based on the original text and the texts of different styles; The original text includes long text and / or short text, and prompt words are constructed, including: If most of the content in the original text is not relevant to the target generated text or is not strongly related to the target style, it is considered to have a low relevance to the target marketing text; otherwise, it is considered to have a high relevance to the target marketing text. If the original text includes short text and is highly relevant to the target marketing text, construct a short text that includes at least the original text, style words, text generation examples, and the first prompt word Prompt1 for the task instruction; When the original text includes long text and has low relevance to the target marketing text, style word vectors are constructed, and multiple similar relevance vectors are matched based on the style word vectors; and Based on the mapping results between the multiple association vectors and the long text of the original text, a second prompt word Prompt2 is constructed, which includes at least the short text corresponding to the mapping results, style words, text generation examples, and task instructions. The mapping results between the multiple association vectors and the long text of the original text include: Vectorize the style tags to obtain the style word vector for each style; The original long text slice is divided into text blocks, and each text block is converted into a vector representation and stored in a vector database. The vector database stores the text block corresponding to each vector and a pointer to the vector. The style word vectors are used to search the index in the vector database to obtain multiple text blocks with vector similarity that meet the requirements; Based on the style word vectors provided in the index, perform an approximate nearest neighbor search on the vector database to return the most similar related vectors in the given vector space. The returned multiple association vectors are mapped back to the corresponding text blocks as contextual background content in the prompt words; A generation module is used to engineer the large language model based on the prompt words; The output module is used to output target marketing text based on the large language model.
7. An electronic device, comprising: processor; as well as A memory configured to store computer-executable instructions, which, when executed, cause the processor to perform the method of any one of claims 1 to 5.
8. A computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of applications, cause the electronic device to perform the method of any one of claims 1 to 5.
Citation Information
Patent Citations
Marketing information generation method, device and equipment
CN117057319A
Automatic optimization method and device for cue word, equipment and storage medium
CN117520507A