LLM-driven diversified text automatic generation method, device and system
By constructing a text attribute dictionary and training customized models in groups, the problems of low efficiency and high cost in generating diverse text data during large-scale pre-trained model training are solved, and efficient and diverse text data generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING INST OF TECH
- Filing Date
- 2025-12-01
- Publication Date
- 2026-05-12
AI Technical Summary
Existing technologies struggle to efficiently generate diverse text data with varied styles and rich content during the training and fine-tuning of large-scale pre-trained models, resulting in high costs and low efficiency.
By constructing a text attribute dictionary, using the OpenAI o4-mini language model to generate text attribute categories and candidate values, and combining K-means clustering and LoRA fine-tuning techniques, customized models are trained in groups to generate diverse text data in parallel.
It significantly improves the diversity and controllability of text data, reduces computational overhead and costs, supports flexible adjustment of generation scale, and provides personalized data generation solutions.
Smart Images

Figure CN122019762A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to an LLM-driven method, apparatus, and system for automatically generating diverse texts, belonging to the field of artificial intelligence natural language processing technology, and applied to the automatic generation of text data driven by large language models. Background Technology
[0002] Currently, obtaining high-quality, diverse text data in natural language processing and artificial intelligence model training is costly and inefficient. Traditional data generation methods mainly rely on pre-designed templates or manual creation, which is not only time-consuming and labor-intensive, but also lacks diversity and scalability due to fixed patterns, making it difficult to meet the ever-increasing demand for training data. Especially in the training and fine-tuning of large-scale pre-trained models, a large amount of corpus with diverse styles and rich content is required, and manually collecting or compiling such data often cannot balance efficiency and diversity control.
[0003] Therefore, how to achieve diversified batch automatic generation of text data driven by Large Language Model (LLM) has become an urgent problem to be solved. Summary of the Invention
[0004] The purpose of this invention is to address the technical problem of batch automatic generation of diverse text data driven by LLM (Liquidity Management Model), and to propose an LLM-driven method, apparatus, and system for automatic generation of diverse text data. This invention automatically generates text data that meets diversity requirements in batches based on user-provided necessary text descriptions, optional attribute preference dictionaries, optional example texts, the expected number of generated samples N, and a diversity coefficient K. This reduces the cost of acquiring large-scale diverse text data and improves generation efficiency.
[0005] The objective of this invention is achieved through the following technical solution:
[0006] On one hand, the present invention discloses an LLM-driven method for automatically generating diverse text, comprising the following steps:
[0007] Step 1: Define the text prompts consisting of text descriptions, attribute preference dictionaries, sample text, the number of target generated texts N, and a diversity coefficient K;
[0008] Step 2: Use the OpenAI o4-mini language model to obtain the key-value pairs for constructing the text attribute dictionary; further, the key is the text attribute category, and the value is the attribute candidate value;
[0009] Step 2.1: Input the text prompts into the OpenAIo4-mini language model to obtain the text attribute categories and candidate attribute values;
[0010] Step 2.2: Construct a text attribute dictionary using text attribute categories as keys and attribute candidate values as values;
[0011] Step 3: Input the constructed sample prompt words into the OpenAI o4-mini model to obtain a set of labeled text samples formed by randomly selected list key-value pairs from the text attribute dictionary;
[0012] Step 3.1: Construct sample prompt words using text descriptions, text attribute dictionaries, and example text;
[0013] Step 3.2: Input the sample prompt words into the OpenAI o4-mini model, and randomly select key-value pairs in list form from the text attribute dictionary;
[0014] Step 3.3: The OpenAI o4-mini model generates samples corresponding to the key-value pairs in the hit list;
[0015] Step 3.4: Construct a text sample set with labeled attributes from the corresponding samples;
[0016] Step 4: Use the K-means clustering method to cluster the semantic vectors extracted by the embedding model to obtain K groups of text samples;
[0017] Step 4.1: Extract semantic vectors from the text sample set with labeled attributes using an embedding model;
[0018] Step 4.2: Using the diversity coefficient K as input, the K-means clustering method is used to cluster the semantic vectors of the text sample set with labeled attributes to obtain K groups of text samples;
[0019] Step 5: Use K sets of text samples to train K fine-tuned LoRA modules of the inserted frozen pedestal model to obtain K customized models;
[0020] Step 5.1: Construct and freeze the pedestal model; train the pedestal model with fine-tuned LoRA modules using K sets of text samples to obtain the K trained fine-tuned LoRA modules;
[0021] Step 5.2: Insert the K trained fine-tuned LoRA modules into the base model respectively to obtain K customized models;
[0022] Step 6: Input the text attribute dictionary into K customized models in a quadratic parallel manner to obtain diverse text data;
[0023] Step 6.1: Input the text attribute dictionary into K customized models in parallel, and output key-value pairs in list form randomly selected from the text attribute dictionary in parallel;
[0024] Step 6.2: Input key-value pairs in the form of a random hit list into K customized models in parallel to obtain diverse text data;
[0025] On the other hand, in order to achieve the purpose of this invention, based on the above method, this invention further proposes an LLM-driven diversified automatic text generation system, including a prompt word construction module, an attribute dictionary generation module, a sample generation and annotation module, a semantic vector acquisition and clustering module, a fine-tuning and LoRA parameter training module, and a multi-model parallel generation module.
[0026] The prompt word construction module is used to parse the user's text data requirements and construct the required input prompt words; it will serve as the input to the attribute dictionary generation module and the sample generation and annotation module.
[0027] The attribute dictionary generation module is used to call the OpenAI o4-mini model to generate a text attribute dictionary based on prompt words; it will serve as input to the multi-model parallel generation module and the sample generation and annotation module.
[0028] The sample generation and annotation module is used to call the OpenAI o4-mini model using an attribute dictionary to generate a small number of representative text samples and to annotate each sample with specific attribute values; these will serve as input to the semantic vector acquisition and clustering module.
[0029] The semantic vector acquisition and clustering module is used to acquire semantic vectors from text samples and cluster the samples into groups; these groups will serve as input to the fine-tuning and LoRA parameter training module.
[0030] The fine-tuning and LoRA parameter training module is used to perform LoRA fine-tuning training on the base language model based on the data of each cluster group to obtain K customized models; these models will be used as input to the multi-model parallel generation module.
[0031] The multi-model parallel generation module is used to generate diverse text data in parallel from K customized models in two stages.
[0032] Furthermore, the present invention provides an LLM-driven diversified automatic text generation device, which consists of a user terminal and a server.
[0033] The user terminal is used to provide a graphical interface or API interface for users to input text data requirements and display the generated results;
[0034] The server is equipped with the aforementioned automatic text data generation device, and uses the aforementioned system to execute the aforementioned method to generate diverse text data.
[0035] Compared with existing technologies, it has the following beneficial effects:
[0036] This invention significantly improves the diversity and controllability of generated text data by introducing a guiding strategy for generating attribute dictionaries using language models and fine-tuning training by semantic grouping. Because it only calls powerful models on small batches of samples and transfers large-scale generation tasks to fine-tuned medium-sized models, it significantly reduces the computational overhead and cost of calling large models. Furthermore, the method supports flexible adjustment of the K value and generation scale according to resource budget, thus providing a personalized data generation scheme that can be adjusted according to budget, and has good practical value. Attached Figure Description
[0037] Figure 1 This is a schematic diagram of the structure of the present invention; Detailed Implementation
[0038] To better illustrate the purpose and advantages of this invention, the invention will be further described below with reference to the accompanying drawings and examples. It should be noted that the implementation of this invention is not limited to the following embodiments, and any modifications or alterations made to this invention will fall within the scope of protection of this invention.
[0039] Example
[0040] like Figure 1 As shown in this embodiment, an LLM-driven method for automatically generating diverse text includes the following steps:
[0041] Step 1: Define the text prompts consisting of text descriptions, attribute preference dictionaries, sample text, the number of target generated texts N, and a diversity coefficient K;
[0042] In this embodiment, the system receives text data request information provided by the user. The request includes at least a description of the target text data and may further include a dictionary of the user's attribute preferences and sample text. The text description explains the general content or purpose of the text to be generated; the attribute preference dictionary indicates one or more text attribute categories that the user is interested in and their preferred values (if this dictionary is provided, the invention can focus on these attributes in subsequent steps); the sample text can be several existing text fragments related to the desired output style or domain, used to provide reference examples. The system also needs to obtain the number of texts N to be generated and the diversity coefficient K specified by the user to determine the output scale and diversity requirements.
[0043] Step 2: Use the OpenAI o4-mini language model to obtain the key-value pairs for constructing the text attribute dictionary; further, the key is the text attribute category, and the value is the attribute candidate value;
[0044] Step 2.1: Input the text prompts into the OpenAIo4-mini language model to obtain the text attribute categories and candidate attribute values;
[0045] Step 2.2: Construct a text attribute dictionary using text attribute categories as keys and attribute candidate values as values;
[0046] In this embodiment, during the generation of the text attribute dictionary, prompts are constructed based on user needs to guide the discovery of text attributes. For example, elements such as text description, attribute preferences, and example text can be integrated into a prompt or instruction. These prompts are then input into the OpenAI o4-mini language model to leverage its rich linguistic knowledge to generate the text attribute dictionary. The OpenAI o4-mini language model outputs several attribute categories that may affect text expression, along with a list of candidate attribute values for each category. For instance, if the text description pertains to news reporting, the model might output attribute categories such as "article genre," "tone and style," and "reader audience." Candidate values for "article genre" include "current affairs news," "in-depth report," and "editorial," while candidate values for "tone and style" include "formal," "objective," and "friendly." This attribute dictionary clarifies the range of options that can vary across different dimensions of the generated text.
[0047] Step 3: Input the constructed sample prompt words into the OpenAI o4-mini model to obtain a set of labeled text samples formed by randomly selected list key-value pairs from the text attribute dictionary;
[0048] Step 3.1: Construct sample prompt words using text descriptions, text attribute dictionaries, and example text;
[0049] Step 3.2: Input the sample prompt words into the OpenAIo4-mini model, and randomly select key-value pairs in list form from the text attribute dictionary;
[0050] Step 3.3: The OpenAI o4-mini model generates samples corresponding to the key-value pairs in the hit list;
[0051] Step 3.4: Construct a text sample set with labeled attributes from the corresponding samples;
[0052] In this embodiment, when generating representative text samples and labeling their attributes, the generated text attribute dictionary is used to reconstruct prompt words to guide the strong language model in outputting example text data. Based on this, the OpenAI o4-mini model generates several text samples, along with the values of each sample in each category of the attribute dictionary. For example, for a given generated sample text, the model might label its "article genre" as "in-depth report," its "tone and style" as "objective," and its "reader audience" as "professionals," among other specific attributes. The output of this step is a small-scale labeled text dataset, where each text is accompanied by attribute labels. This dataset covers the topics expected by the user and also initially reflects the differences in text under different combinations of attribute values.
[0053] Step 4: Use the K-means clustering method to cluster the semantic vectors extracted by the embedding model to obtain K groups of text samples;
[0054] Step 4.1: Extract semantic vectors from the text sample set with labeled attributes using an embedding model;
[0055] Step 4.2: Using the diversity coefficient K as input, the K-means clustering method is used to cluster the semantic vectors of the text sample set with labeled attributes to obtain K groups of text samples;
[0056] In this embodiment, when obtaining and clustering the semantic vectors of the text sample set with labeled attributes, a predetermined semantic encoding model is used to calculate its semantic vector representation. The semantic encoding model can employ existing general text embedding models, such as Jina-Embeddings-v3, to map the text into a high-dimensional vector space. Then, a K-means clustering algorithm (where the number of clusters is set to K, i.e., the diversity coefficient) is applied to all the obtained text vectors. The clustering process groups text samples with similar semantic or stylistic features into a single group, ultimately resulting in K clusters. These K groups of text samples exhibit significant semantic differences, such as potentially corresponding to different writing styles, content emphases, or attribute combinations. Through clustering, the original text space can be divided according to semantic differences, thus providing a diverse foundation for subsequent generation stages.
[0057] Step 5: Use K sets of text samples to train K fine-tuned LoRA modules of the inserted frozen pedestal model to obtain K customized models;
[0058] Step 5.1: Construct and freeze the pedestal model; train the pedestal model with fine-tuned LoRA modules using K sets of text samples to obtain the K trained fine-tuned LoRA modules;
[0059] Step 5.2: Insert the K trained fine-tuned LoRA modules into the base model respectively to obtain K customized models;
[0060] In this embodiment, for each text sample group obtained in the previous step, a pre-trained language model with a moderate parameter size that can be used as a base is selected, and its parameters are efficiently fine-tuned based on small samples. Preferably, LoRA fine-tuning technology is used, that is, while freezing most of the parameters of the original model, only the small-scale low-rank parameter matrix of the insertion is trained, thereby efficiently learning the unique features of each group of data. Specifically, for the k-th group of text sample data, the base model is used as the initial model, and the model is trained using the samples of this group and their attribute labels to obtain the corresponding LoRA fine-tuning parameters W_k. Since the samples of each group differ in content and style, this grouping fine-tuning method allows the model parameters of each group to be adjusted for the specific distribution of the group. After this step, K groups of fine-tuning parameters W_1...W_K are obtained, as well as the corresponding customized model M_k = base model + W_k (representing the model instance after applying the fine-tuning increment parameters to the base model). It should be noted that the choice of base model can be determined according to specific application requirements and computing resources. For example, the Qwen-3 8B model mentioned above is a suitable base model choice, but it is not limited to this.
[0061] Step 6: Input the text attribute dictionary into K customized models in a quadratic parallel manner to obtain diverse text data;
[0062] Step 6.1: Input the text attribute dictionary into K customized models in parallel, and output key-value pairs in list form randomly selected from the text attribute dictionary in parallel;
[0063] Step 6.2: Input key-value pairs in the form of a random hit list into K customized models in parallel to obtain diverse text data;
[0064] In this embodiment, when multiple models generate text in parallel, K customized language models M_1...M_K are used. Based on the initially obtained text attribute dictionary, and with the goal of ensuring diversity, several specific attribute configurations are strategically sampled from the candidate value list for each attribute category to guide text generation. To obtain a total of N result texts, approximately N / K generation tasks can be assigned to each model M_k (if N is not divisible by K, one more task can be generated on some models to reach the total). For each model M_k, corresponding text data is generated based on the assigned attribute configuration combination. The texts generated by each model are aggregated to form the final output of N diverse text data. Since each model M_k has been specifically fine-tuned for the semantic features of different categories, the texts they generate are distinguishable in style and content, satisfying the pre-defined diversity requirements as a whole. Furthermore, the multi-model generation process can be executed in parallel, for example, in a system with multi-threaded or distributed computing capabilities, multiple model instances can be run simultaneously to generate text, thereby shortening the total generation time.
[0065] On the other hand, in order to achieve the purpose of the present invention, based on the above method, this embodiment further proposes an LLM-driven diversified text automatic generation system, including a prompt word construction module, an attribute dictionary generation module, a sample generation and annotation module, a semantic vector acquisition and clustering module, a fine-tuning and LoRA parameter training module, and a multi-model parallel generation module.
[0066] The prompt word construction module is used to parse the user's text data requirements and construct the required input prompt words; it will serve as the input to the attribute dictionary generation module and the sample generation and annotation module.
[0067] In this embodiment, the prompt word construction module receives and parses the user's input text data requirements, extracts elements such as text descriptions, attribute preferences, and example texts, and constructs prompt words to guide the language model according to a predetermined format. This module converts the user's requirements into prompt information that the strong language model can understand and outputs it to the attribute dictionary generation module and the sample generation and annotation module.
[0068] The attribute dictionary generation module is used to call the OpenAI o4-mini model to generate a text attribute dictionary based on prompt words; it will serve as input to the multi-model parallel generation module and the sample generation and annotation module.
[0069] In this embodiment, the attribute dictionary generation module receives prompts provided by the prompt word construction module, calls a strong language model (such as o4-mini) to generate a text attribute dictionary output. Its functions include sending prompt requests to the language model and obtaining the model's generation results, parsing and organizing the results to form an attribute dictionary data structure, and then passing the attribute dictionary to the sample generation and annotation module and the multi-model parallel generation module.
[0070] The sample generation and annotation module is used to call the OpenAI o4-mini model using an attribute dictionary to generate a small number of representative text samples and to annotate each sample with specific attribute values; these will serve as input to the semantic vector acquisition and clustering module.
[0071] In this embodiment, the sample generation and annotation module is used to further interact with the strong language model based on the attribute dictionary, generate a small number of representative text samples, and obtain the attribute values of these samples. Specifically, this module constructs a prompt request containing the content of the attribute dictionary, guides the model to generate several example texts, and uses the annotation provided by the model or preset rules to associate attribute value labels with each text sample. The generated annotated text sample data is transmitted to the semantic vector acquisition and clustering module.
[0072] The semantic vector acquisition and clustering module is used to acquire semantic vectors from text samples and cluster the samples into groups; these groups will serve as input to the fine-tuning and LoRA parameter training module.
[0073] In this embodiment, the semantic vector acquisition and clustering module is used to perform semantic analysis and grouping on the received text sample set. On one hand, this module invokes the semantic coding model to generate a semantic vector representation for each text sample; on the other hand, it performs clustering operations on all vectors (using K-means or other clustering algorithms) to obtain K semantically distinct text groups. After clustering is completed, the text data of each group and the corresponding attribute labels are sent to the fine-tuning and LoRA parameter training modules, respectively.
[0074] The fine-tuning and LoRA parameter training module is used to perform LoRA fine-tuning training on the base language model based on the data of each cluster group to obtain K customized models; these models will be used as input to the multi-model parallel generation module.
[0075] In this embodiment, the fine-tuning and LoRA parameter training module is used to perform small-sample group-based data fine-tuning training on the selected base language model. This module invokes the training process for each received text group, inputting the group's samples and their attribute labels into the base model, and applying efficient fine-tuning techniques such as LoRA to train and obtain the fine-tuning parameters W_k. During training, the newly added fine-tuning parameters are mainly adjusted rather than the original weights of the base model, thereby preserving the general language capabilities of the base model while adapting to tasks within the group. After training each group is completed, this module outputs the corresponding fine-tuning parameters and provides these parameters to the multi-model parallel generation module.
[0076] The multi-model parallel generation module is used to generate diverse text data in parallel from K customized models in two stages.
[0077] In this embodiment, a multi-model parallel generation module is used to perform the final text generation. This module instantiates K copies of a base model on the computing device and loads K customized models respectively. Simultaneously, the module determines the number of text entries to be generated and the attribute configuration for each text entry based on an attribute dictionary. During actual runtime, it allocates the number of text entries to be generated and the corresponding attribute configuration inputs to the K customized models, initiating the text generation tasks of all models in parallel. Once all models have completed their text generation, the module collects the text results output by each model to form the final output data. Thus, the device efficiently generates a large amount of diverse text data by coordinating the parallel work of each model. The above modules work together to achieve fully automated processing from user input requirements to the output of diverse text data.
[0078] Furthermore, this embodiment provides an LLM-driven diversified automatic text generation device, which consists of a user terminal and a server.
[0079] The user terminal is used to provide a graphical interface or API interface for users to input text data requirements and display the generated results;
[0080] The server is equipped with the aforementioned automatic text data generation device, and uses the aforementioned system to execute the aforementioned method to generate diverse text data.
[0081] In this embodiment, the server can instantiate K fine-tuned language models and run them in parallel, thereby generating multiple text results simultaneously and improving generation efficiency. User terminals and the server can interact via network connection, or simultaneously implement input, processing, and output functions on a local integrated device. Each module of the system can be implemented by software instructions on a general-purpose computing platform, or by hardware circuits with specific functions. In a typical implementation, these modules, as functional units of a computer program, are executed by one or more processors using corresponding software processes to complete their respective functions. Modules interact with each other through predefined data interfaces, such as passing prompt words, attribute dictionaries, sample data, etc., through memory sharing, message queues, or function calls. It is understood that the module division is logical, a functional division made to implement the method steps of this invention. In specific implementations, some modules can be merged or further subdivided as needed. For example, the functions of prompt word construction and attribute dictionary generation can be completed in an integrated module, or the semantic vector acquisition and clustering functions can be split into independent vector calculation units and clustering units, etc., all of which are within the scope of protection of this invention.
[0082] The above detailed description further illustrates the purpose, technical solution, and beneficial effects of the invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. An LLM-driven method for automatically generating diverse text, characterized in that: Includes the following steps, Step 1: Define the text prompts consisting of text descriptions, attribute preference dictionaries, sample text, the number of target generated texts N, and a diversity coefficient K; Step 2: Use the OpenAI o4-mini language model to obtain the key-value pairs for constructing the text attribute dictionary; further, the key is the text attribute category, and the value is the attribute candidate value; Step 2.1: Input the text prompts into the OpenAI o4-mini language model to obtain the text attribute categories and candidate attribute values; Step 2.2: Construct a text attribute dictionary using text attribute categories as keys and attribute candidate values as values; Step 3: Input the constructed sample prompt words into the OpenAI o4-mini model to obtain a set of labeled text samples formed by randomly selected list key-value pairs from the text attribute dictionary; Step 3.1: Construct sample prompt words using text descriptions, text attribute dictionaries, and example text; Step 3.2: Input the sample prompt words into the OpenAI o4-mini model, and randomly select key-value pairs in list form from the text attribute dictionary; Step 3.3: The OpenAI o4-mini model generates samples corresponding to the key-value pairs in the hit list; Step 3.4: Construct a text sample set with labeled attributes from the corresponding samples; Step 4: Use the K-means clustering method to cluster the semantic vectors extracted by the embedding model to obtain K groups of text samples; Step 4.1: Extract semantic vectors from the text sample set with labeled attributes using an embedding model; Step 4.2: Using the diversity coefficient K as input, the K-means clustering method is used to cluster the semantic vectors of the text sample set with labeled attributes to obtain K groups of text samples; Step 5: Use K sets of text samples to train K fine-tuned LoRA modules of the inserted frozen pedestal model to obtain K customized models; Step 5.1: Construct and freeze the pedestal model; train the pedestal model with fine-tuned LoRA modules using K sets of text samples to obtain the K trained fine-tuned LoRA modules; Step 5.2: Insert the K trained fine-tuned LoRA modules into the base model respectively to obtain K customized models; Step 6: Input the text attribute dictionary into K customized models in a quadratic parallel manner to obtain diverse text data; Step 6.1: Input the text attribute dictionary into K customized models in parallel, and output key-value pairs in list form randomly selected from the text attribute dictionary in parallel; Step 6.2: Input key-value pairs in the form of a random hit list into K customized models in parallel to obtain diverse text data.
2. An LLM-driven system for automatically generating diverse text as described in claim 1, characterized in that: It includes a prompt word construction module, an attribute dictionary generation module, a sample generation and annotation module, a semantic vector acquisition and clustering module, a fine-tuning and LoRA parameter training module, and a multi-model parallel generation module; The prompt word construction module is used to parse the user's text data requirements and construct the required input prompt words; it will serve as the input to the attribute dictionary generation module and the sample generation and annotation module. The attribute dictionary generation module is used to call the OpenAI o4-mini model to generate a text attribute dictionary based on prompt words; it will serve as input to the multi-model parallel generation module and the sample generation and annotation module. The sample generation and annotation module is used to call the OpenAI o4-mini model using an attribute dictionary to generate a small number of representative text samples and to annotate each sample with specific attribute values; these will serve as input to the semantic vector acquisition and clustering module. The semantic vector acquisition and clustering module is used to acquire semantic vectors from text samples and cluster the samples into groups; these groups will serve as input to the fine-tuning and LoRA parameter training module. The fine-tuning and LoRA parameter training module is used to perform LoRA fine-tuning training on the base language model based on the data of each cluster group to obtain K customized models; these models will be used as input to the multi-model parallel generation module. The multi-model parallel generation module is used to generate diverse text data in parallel from K customized models in a secondary manner.
3. An LLM-driven device for automatically generating diverse text, characterized in that: It consists of a user terminal and a server. The user terminal is used to provide a graphical interface or API interface for users to input text data requirements and display the generated results; The server is equipped with the aforementioned automatic text data generation device, and uses the system described above to execute the method described above to generate diverse text data.