Data generation method and device, equipment, storage medium and product

By matching role identity definition information with scenario-based templates, generating prompt words and inputting them into the model, the problem of insufficient data generation quality in vertical subdivision fields is solved, and high-quality and diverse data generation is achieved.

CN119337918AInactive Publication Date: 2025-01-21SANGFOR TECH INC

Patent Information

Application Number
CN202411894056.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-01-21
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art is difficult to meet the needs of data generation in vertical segments, such as the field of cybersecurity, especially in terms of the quality and diversity of data generation.

Method used

By obtaining the identity definition information of the character, the scene -based templates of the preset characters are matched to generate the prompts used to guide the output of the model, and input the preset models of these prompts to generate the expected data.

Benefits of technology

It improves the quality and diversity of data generation, can better meet the data generation needs of vertical subdivisions, and ensures that the generated data reaches excellent levels in terms of richness and coverage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119337918A_ABST
    Figure CN119337918A_ABST
Patent Text Reader

Abstract

The invention discloses a data generation method and device, equipment, a storage medium and a product. The method comprises the following steps: acquiring identity definition information representing an expected role; based on the identity definition information, matching with preset scene templates of various roles to obtain a matched target scene template; generating a cue word for guiding model output based on the target scenarized template; and inputting the cue word into a preset model to obtain data expected to be generated. Therefore, the identity definition information representing the expected role can be matched with the preset scene templates of various roles to obtain the target scene template matched with the user demand, and the prompt word is generated based on the target scene template, so that the data expected to be generated by the user is obtained based on the prompt word and the preset model, and the user experience is improved. The quality of generated data can be effectively improved, and the data generation requirement in the vertical subdivision field can be better met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a data generation method, device, equipment, storage medium and product. Background Art

[0002] Data is one of the three elements in the development of artificial intelligence technology. With the development of computing power, the complexity of model parameters continues to increase. As the model effect "works miracles with great effort", the importance of data is becoming increasingly prominent.

[0003] Data generation technology has become a research focus in the era of deep learning. Data generation refers to the use of artificial intelligence technology, usually through a large language model (LLM), to generate the data required by users.

[0004] Most related technologies focus on data generation in general fields and are unable to meet the data generation needs of vertical segments (for example, network security). Summary of the invention

[0005] In view of this, the embodiments of the present application provide a data generation method, apparatus, device, storage medium and product, which aim to improve the quality of data generation and meet the data generation needs of vertical segments.

[0006] The technical solution of the embodiment of the present application is implemented as follows: In a first aspect, an embodiment of the present application provides a data generation method, comprising: Obtaining identity definition information representing the desired role; Based on the identity definition information, the scenario templates of various preset roles are matched to obtain a matching target scenario template; Generate prompt words for guiding model output based on the target scenario template; The prompt words are input into a preset model to obtain the desired generated data.

[0007] In the above scheme, the method further includes: Divide multiple preset roles based on data application scenarios; Based on each preset role and setting field, a corresponding scenario template is configured; wherein the setting field is used to define a prompt word framework corresponding to the scenario template.

[0008] In the above solution, the step of generating prompt words for guiding model output based on the target scenario template includes: Based on the auxiliary information and / or preset information input by the user for generating prompt words, the setting fields in the target scenario template are filled to generate prompt words for guiding the model output.

[0009] In the above scheme, at least one of the setting fields includes a variable that supports configuration, and the method further includes: Replacing the variables based on the configuration file; Based on the replacement of the variables, the generated prompt words are generalized to obtain batch prompt words; The step of inputting the prompt word into a preset model to obtain the desired generated data includes: The batch prompt words are input into a preset model to obtain batch generated data.

[0010] In the above scheme, the number of the preset models is multiple, and the step of inputting the batch prompt words into the preset models to obtain batch generated data includes: Based on the distributed calling mechanism, the batched prompt words are divided and input into each preset model in batches to obtain batched generated data.

[0011] In the above solution, the configuration of the corresponding scenario template based on the preset roles and setting fields includes: When configuring a corresponding scenario-based template based on any preset role, set the supported configuration variables in at least one setting field; A variable list is generated based on the set variables, and the variable list is added to the corresponding scenario template; wherein the variable list is used for generalizing prompt words when the corresponding scenario template generates prompt words.

[0012] In the above solution, before obtaining the expected generated data, the method further includes: Based on the prompt word and the preset model, obtaining preview generated data; If it is determined that the previewed generated data does not meet the requirements, the configuration of the target scenario template is updated based on the previewed generated data.

[0013] In the above solution, the auxiliary information and / or preset information for generating prompt words input by the user is used to fill in the setting fields in the target scenario template to generate prompt words for guiding the model output, including: Based on the relationship between entities and attributes in the pre-built knowledge graph, determine the setting fields in the target scenario template corresponding to the auxiliary information and / or preset information input by the user, and fill the auxiliary information and / or preset information into the corresponding setting fields to obtain prompt words for guiding the model output.

[0014] In the above solution, the auxiliary information further includes: user-defined variables; the method further includes: Based on the user defined variables, the variable list is updated.

[0015] In the above solution, the identity definition information is matched with the preset scenario templates of various roles to obtain the matched target scenario template, including: Based on the identity definition information, it is determined whether the expected role falls into the preset roles. If so, the scenario template of the matching preset role is used as the target scenario template; if not, the general scenario template is used as the target scenario template.

[0016] In a second aspect, an embodiment of the present application provides a data generating device, including: An acquisition module, used to acquire identity definition information representing an expected role; A matching module, used to match the identity definition information with preset scenario templates of various roles to obtain a matching target scenario template; A first processing module, used to generate prompt words for guiding model output based on the target scenario template; The second processing module is used to input the prompt word into a preset model to obtain the expected generated data.

[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory for storing a computer program that can be run on the processor, wherein the processor, when used to run the computer program, executes the steps of the method described in the first aspect of the embodiment of the present application.

[0018] In a fourth aspect, an embodiment of the present application provides a computer storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the first aspect of the embodiment of the present application are implemented.

[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the method described in the first aspect of the embodiment of the present application.

[0020] The technical solution provided by the embodiment of the present application obtains identity definition information representing the expected role; matches the preset scenario templates of various roles based on the identity definition information to obtain a matching target scenario template; generates prompt words for guiding the model output based on the target scenario template; inputs the prompt words into the preset model to obtain the expected generated data. In this way, the target scenario template matching the user's needs can be obtained based on the identity definition information representing the expected role and the preset scenario templates of various roles, and prompt words can be generated based on the target scenario template, and then based on the prompt words and the preset model, the data expected to be generated by the user can be obtained, which can effectively improve the quality of the generated data and better meet the data generation needs of vertical segments. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A schematic diagram of a flow chart of a data generation method according to an embodiment of the present application; Figure 2 A schematic diagram of the interface for the task of generating data for the application example of this application; Figure 3 A schematic diagram of an interface for displaying prompt words in an application example of the present application; Figure 4 This is a schematic diagram of an interface for setting variables in the prompt words of the application embodiment of the present application; Figure 5 A schematic diagram of an interface for updating a variable list in an application example of the present application; Figure 6 A schematic diagram of an interface for uploading a configuration file for an application example of this application; Figure 7 This is a schematic diagram of the format of the configuration file of the application embodiment of this application; Figure 8 This is a schematic diagram of an interface in which variables in an embodiment of the present application are replaced; Fig. 9 A schematic diagram of an interface for previewing generated data for an application example of this application; Fig.10 This is a schematic diagram of the interface for switching models when previewing an application example of this application; Fig.11 A schematic diagram of a configuration interface for generating data for an application example of this application; Fig.12 One of the schematic diagrams of the display interface for generating data for the application embodiment of the present application; Fig.13 The second schematic diagram of the display interface for generating data for the application embodiment of the present application; Fig.14 The third schematic diagram of the display interface for generating data for the application example of the present application; Fig.15 This is a schematic diagram of the structure of a data generating device according to an embodiment of the present application; Fig.16 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0022] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments.

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

[0024] Data generation technology has become a research focus in the era of deep learning. The paper "Attributealignment: Controlling text generation from pre-trained language models" proposes a method called "Attribute Alignment" to control text generation to adapt to target attributes, such as sentiment polarity or specific topics, without changing the parameters of the pre-trained language model (LM-GPT2). The paper "Control, generate, augment: A scalable framework for multi-attribute text generation" introduces a framework called CGA (Control, Generate, Augment), which is a scalable framework for multi-attribute text generation. CGA combines adversarial learning, context-aware loss, and cyclic vocabulary loss strategies to control multiple semantic and syntactic attributes of generated natural English sentences.

[0025] The era of large language models has opened up new possibilities for data generation. The paper "Language models are realistic tabular data generators" proposes a new method called GReaT (Generation of Realistic Tabular data), which uses large models to generate synthetic samples (tabular data) with the characteristics of original data. The main contributions of GReaT include: 1. A new paradigm is proposed to model and generate real heterogeneous tabular data using a large model, connecting tabular and textual data modalities through a text encoding scheme.

[0026] 2. Support arbitrary conditioning. When trained on text encodings with random feature order, the model inherits the arbitrary conditioning capability of LLM and can model the data distribution of any given feature subset and sample the remaining features.

[0027] 3. We provide extensive experimental results, demonstrating that GReaT achieves state-of-the-art generation performance on a variety of datasets, and open-source the experimental results to provide a strong benchmark for the community.

[0028] 4. An easy-to-use Python implementation is provided, which can generate new synthetic samples with only three lines of code.

[0029] The paper "Generating datasets with pretrained language models" proposes a method called DINO (Datasets from Instructions), which uses large models to create text pairs by providing natural language instructions to provide high-quality sentence embeddings for small models.

[0030] Specifically, the DINO method is implemented through the following steps: 1. Use a pre-trained language model (such as GPT-2-XL) to generate text pairs with semantic similarity labels.

[0031] 2. The self-debiasing algorithm is used to ensure that the generated text pairs not only conform to the given similarity labels but also do not conform to other labels to reduce noise.

[0032] 3. Use the generated dataset to train smaller models, such as Sentence-RoBERTa, to improve its performance on multiple semantic text similarity datasets.

[0033] The contributions of the paper include: 1. We introduce the DINO method, which can automatically generate annotated datasets of any size.

[0034] 2. Released STS-Dino, the first fully automatically generated text similarity dataset that does not require any human annotation.

[0035] 3. We show that Sentence-RoBERTa trained on the dataset generated by DINO outperforms strong baseline models on multiple semantic text similarity datasets.

[0036] In addition, the paper also explores the importance of self-debiasing algorithms in improving the quality of generated data, and conducts a small-scale manual evaluation to evaluate the quality of the generated dataset. The experimental results show that although there is a certain degree of noise in the generated dataset, by taking appropriate measures to deal with this noise, the trained model can still achieve excellent performance on multiple semantic text similarity datasets.

[0037] However, the above-mentioned papers focus more on general data generation and do not provide specific methodology for data generation in vertical segments such as network security data, making it difficult to meet the training needs of large models in vertical fields.

[0038] Based on this, in various embodiments of the present application, by presetting scenario templates for various roles in vertical segments, and combining the identity definition information input by the user, the target scenario template is matched, and prompt words (Prompt) are generated based on the target scenario template. The prompt words are then input into the preset model, which can deepen the understanding of business roles, improve the generation quality of prompts, and thus obtain higher quality generated data to meet the data generation needs of vertical segments.

[0039] For example, the embodiment of the present application provides a data generation method, which can be independently applied to electronic devices with data processing capabilities, such as terminal devices, servers, etc., or can be implemented by the cooperation between terminal devices and servers; wherein the terminal device can specifically be a computer, a smart phone, a personal digital assistant (PDA), etc.; the server can specifically be an application server or a Web server. In actual deployment, the server can be an independent server or a cluster server. Figure 1 As shown, the method includes: Step 101, obtaining identity definition information representing the expected role.

[0040] Here, the electronic device may receive identity definition information input by the user, and the identity definition information is used to define an expected role, that is, the role played by the data generator, that is, the data generating agent (Agent) as the data generator generates data in the identity of the expected role.

[0041] Step 102 : matching the identity definition information with preset scenario templates of various roles to obtain a matching target scenario template.

[0042] Here, after obtaining the identity definition information input by the user, the electronic device can match it with the scenario templates of various roles built in advance to obtain a matching target scenario template. Among them, each scenario template can be understood as a template corresponding to the role for constraining the generation of prompt words, which can effectively improve the generation quality of prompt words.

[0043] Step 103: Generate prompt words for guiding model output based on the target scenario template.

[0044] Here, the prompt word is Prompt, which is used to clearly inform the model of the content of the data to be generated, thereby guiding the model to generate data that meets the requirements. The prompt word can be a simple instruction or question, or a complex description that includes rich context and relevant requirements.

[0045] Step 104: input the prompt word into a preset model to obtain the desired generated data.

[0046] Here, the preset model may be one or more large language models, for example, a GPT (Generative Pre-Trained Transformer) model. After the prompt word is input into the preset model, the preset model may generate the data expected by the user.

[0047] It can be understood that the embodiments of the present application can match the identity definition information representing the expected role with the preset scenario templates of various roles to obtain the target scenario template that matches the user's needs, and generate prompt words based on the target scenario template, and then based on the prompt words and the preset model, obtain the data that the user expects to generate, which can effectively improve the quality of the generated data, for example, improve the richness and coverage of the data generated, and better meet the data generation needs of vertical segments.

[0048] Exemplarily, the method further includes: Divide multiple preset roles based on data application scenarios; Based on each preset role and setting field, a corresponding scenario template is configured; wherein the setting field is used to define a prompt word framework corresponding to the scenario template.

[0049] Here, data can be divided based on the scenarios of data application to obtain multiple mainstream application scenarios in various business fields. For example, in the field of network security, it can include but is not limited to: email security, IoT device security, banking and financial security, cloud storage and backup, remote office, social media and other scenarios. Among them, one or more preset roles can be divided based on demand in each scenario. For example, multiple preset roles can be divided based on the application stage of the scenario, so as to better meet the data segmentation generation needs of vertical business fields, and can effectively guide users to enter the identity definition information of the role in segments, thereby laying a foundation for improving the quality of data generation.

[0050] It should be noted that the data generation quality of the model depends largely on the input prompt words. Based on this, a scientific and reasonable prompt word framework is particularly important. Among them, each preset role can preset a corresponding prompt word framework and configure the scenario template based on the corresponding setting field. Each prompt word framework has a corresponding setting field. For example, the prompt word framework and the corresponding setting field of the embodiment of the present application include but are not limited to one or more of the following: 1) ICIO framework, which includes the following setting fields: Instruction: Instructions, that is, the specific tasks you want the AI ​​to perform; Context: Background information. Giving AI more background information can guide the model to make responses that are more in line with the needs. Input Data: Input data, telling the model what data needs to be processed; Output Indicator: Output guide, telling the model the type or style of user output.

[0051] 2) CRISPE framework, which includes the following setting fields: Capacity and Role: Capacity and role, what role the model should play; Insight: Provides insights, background, and context behind user requests; Statement: what the user wants the model to do; Personality: the style, personality or way in which the user wants the model to respond; Experiment: Experiment, requesting the model to reply with multiple examples.

[0052] 3) BROKE framework, which includes the following setting fields: Background: Background, explain the background and provide sufficient information for the model; Role: the role you want the model to play; Objectives: what you want to achieve; Key Result: What specific effect should be tested and adjusted? Evolve: Experiment and improve, freely combine the following three improvement methods: a. Improve input: Start from the shortcomings of the answer to improve the background B, goal O and key results R; b. Improve answers: Correct the shortcomings of the model’s answers in subsequent conversations; c. Regenerate: Try to generate results multiple times without changing the prompt, and select the best one.

[0053] 4) APE frame, which includes the following setting fields: ACTION: Action, defines the work or activity to be done; PURPOSE: purpose, discuss intention or goal; EXPECTATION: Expectation, stating the expected outcome.

[0054] 5) COAST framework, which includes the following setting fields: CONTEXT: Context sets the stage for the conversation; OBJECTIVE: Purpose, describing the goal; ACTION: Action, explain the required action; SCENARIO: scenario, describing the scene; TASK: Task, describe the task.

[0055] 6) TAG frame, which includes the following setting fields: TASK: task, describe the task; ACTION: Action, explain the required action; GOAL: Goal, explain the final goal.

[0056] 7) RISE framework, which includes the following setting fields: ROLE: role, specifies the role of the model; INPUT: input, describing information or resources; STEPS: Steps, ask for detailed steps; EXPECTATION: Expectation, describing the desired outcome.

[0057] 8) TRACE frame, which includes the following setting fields: TASK: Task, defines a specific task; REQUEST: request, describing the requirements; ACTION: Action, indicating the required operation; CONTEXT: context, providing contextual information or situation; EXAMPLE: Example, giving an example to illustrate the effect the user wants to achieve.

[0058] 9) ERA framework, which includes the following setting fields: EXPECTATION: Expectation, describing the desired outcome; ROLE: role, specify the role; ACTION: Action, specifies what actions need to be taken.

[0059] 10) CARE framework, which includes the following setting fields: CONTEXT: context, providing contextual information or situation; ACTION: Action, indicating the required operation; RESULT: Result, describing the desired result; EXAMPLE: Example, giving an example to illustrate the effect the user wants to achieve.

[0060] 11) ROSES framework, which includes the following setting fields: ROLE: role, specify the role; OBJECTIVE: purpose, state the goal; SCENARIO: scenario, describing the situation; EXPECTED SOLUTION: Solution, defines the desired outcome; STEPS: Steps required to achieve the goal.

[0061] 12) PATFU frame, which includes the following setting fields: PROBLEM: Problem, clearly express the problem that needs to be solved; AERA: Field, the field of the problem or the role to be played; TASK: Task, the specific task that needs to be performed to solve this problem; FORMAT: Format, which defines the output format and restrictions in detail; UPDATE: Iterate, record the prompt word version and iterate the prompt word according to the output results.

[0062] It is understandable that multiple preset roles may also share the same prompt word framework, that is, the setting fields of multiple preset roles may be the same, and the embodiment of the present application does not limit this.

[0063] Exemplarily, the generating of prompt words for guiding model output based on the target scenario template includes: Based on the auxiliary information and / or preset information input by the user for generating prompt words, the setting fields in the target scenario template are filled to generate prompt words for guiding the model output.

[0064] Here, the electronic device can fill in the set fields in the target scenario template based on the preset information on the platform side to obtain the prompt words output by the reference model, or fill in the set fields in the target scenario template based on the auxiliary information input by the user and the preset information on the platform side to obtain the prompt words output by the reference model. Among them, the auxiliary information input by the user can be information corresponding to one or more fields in the prompt word framework, and the preset information on the platform side can be understood as the configuration information pre-defined for each field in the prompt word framework.

[0065] In one application example, the electronic device can establish a correspondence between the auxiliary information and / or preset information input by the user and the set fields in the target scenario template based on the knowledge graph of the vertical business field, that is, use the relationship between entities and attributes in the knowledge graph to determine the correspondence, and then realize automatic filling of each set field to obtain prompt words for guiding model output.

[0066] Exemplarily, the filling of the setting fields in the target scenario template based on the auxiliary information and / or preset information input by the user for generating the prompt words to generate the prompt words for guiding the model output includes: Based on the relationship between entities and attributes in the pre-built knowledge graph, determine the setting fields in the target scenario template corresponding to the auxiliary information and / or preset information input by the user, and fill the auxiliary information and / or preset information into the corresponding setting fields to obtain prompt words for guiding the model output.

[0067] Here, the data knowledge of the vertical business field can be expressed in the form of a knowledge graph, so that auxiliary information and / or preset information can be automatically filled into the prompt word framework of the target scenario template based on the knowledge graph, thereby realizing the automatic assembly of prompt words and improving the automation level of prompt word generation corresponding to each scenario template.

[0068] Exemplarily, at least one of the setting fields includes a variable supporting configuration, and the method further includes: Replacing the variables based on the configuration file; Based on the replacement of the variables, the generated prompt words are generalized to obtain batch prompt words; The step of inputting the prompt word into a preset model to obtain the desired generated data includes: The batch prompt words are input into a preset model to obtain batch generated data.

[0069] Here, the electronic device can receive a configuration file uploaded by a user, and the configuration file can be a pre-prepared formatted data file, wherein the variables supporting the configuration can be replaced by the content in the configuration file, for example, the configuration file can include multiple fields and corresponding value spaces, and the fields corresponding to the variables can be set, and the variables can be replaced based on the value spaces of the fields in the configuration file. For example, taking the generation of news data as an example, the variables can include regions and topics, wherein the regions in the formatted data file can include multiple regional information such as countries, provinces, and cities, and the topics can include: politics, economy, society, sports, science and technology, culture, entertainment, environment, military, health, and other examples. In this way, the variables in the prompt words can be replaced based on the formatted data file, and then batch prompt words are obtained. The electronic device then inputs the batch prompt words into a preset model to obtain batch generated data. The batch generated data can greatly enrich the diversity of data and the comprehensiveness of coverage, avoid the defects of insufficient richness and coverage of data generated by a single prompt word, and then effectively improve the quality of generated data to meet the data generation needs of vertical business fields.

[0070] Exemplarily, the number of the preset models is multiple, and the step of inputting the batch prompt words into the preset models to obtain batch generated data includes: Based on the distributed calling mechanism, the batched prompt words are divided and input into each preset model in batches to obtain batched generated data.

[0071] Here, in order to improve the efficiency of data generation by the data generation agent, in an embodiment of the present application, for multiple preset models, the electronic device can also divide the batched prompt words based on a distributed calling mechanism and input them into each preset model in batches to obtain batched generated data. In this way, the effect of load balancing control can be achieved based on the distributed calling mechanism, thereby meeting the data generation quality while greatly improving the data generation efficiency.

[0072] Exemplarily, configuring corresponding scenario-based templates based on preset roles and setting fields includes: When configuring a corresponding scenario-based template based on any preset role, set the supported configuration variables in at least one setting field; A variable list is generated based on the set variables, and the variable list is added to the corresponding scenario template; wherein the variable list is used for generalizing prompt words when the corresponding scenario template generates prompt words.

[0073] Here, in order to achieve the effect of generalized generation of prompt words, when configuring the preset scenario template, a variable that supports configuration can be set in at least one field of the prompt word framework, that is, a variable Key that can support replacement can be set, and the electronic device can generate a variable list based on the set variables, and add the variable list to the corresponding scenario template. In this way, when replacing the variables to generalize the prompt words, the variables in the variable list can be replaced in batches based on the variable list and the configuration file uploaded by the user, thereby obtaining batched prompt words.

[0074] Exemplarily, the auxiliary information further includes: user-defined variables; the method further includes: Based on the user defined variables, the variable list is updated.

[0075] Here, when the user performs the initialization configuration, the auxiliary information can also include user-defined variables, that is, new definitions can be made for the variables in the target scenario template. In this way, the electronic device can update the existing variable list based on the user-defined variables, thereby achieving the purpose of personalized addition of variables in the prompt words.

[0076] Exemplarily, before obtaining the data expected to be generated, the method further includes: Based on the prompt word and the preset model, obtaining preview generated data; If it is determined that the previewed generated data does not meet the requirements, the configuration of the target scenario template is updated based on the previewed generated data.

[0077] Here, the user can also preview the generated data corresponding to the prompt words under the target scenario template before obtaining the expected generated data, and judge whether the quality of the generated data meets the expectations. If it is determined that the previewed generated data meets the requirements, the target scenario template can be saved, and the generated data obtained based on the prompt words generated by the target scenario template can be used as the expected generated data; if it is determined that the previewed generated data does not meet the expected purpose, the configuration of the target scenario template can be further updated based on the auxiliary information, and batch prompt words can be generated after optimizing the configuration until the expected generated data is obtained based on the batch prompt words.

[0078] Exemplarily, the matching of the identity definition information with the preset scenario templates of various roles to obtain the matching target scenario template includes: Based on the identity definition information, it is determined whether the expected role falls into the preset roles. If so, the scenario template of the matching preset role is used as the target scenario template; if not, the general scenario template is used as the target scenario template.

[0079] Here, after receiving the identity definition information configured by the user, the electronic device can use the GPT-based classification model to perform role recognition on the identity definition information, and determine whether the expected role recognized falls into the preset role. If so, the scenario template of the matching preset role is used as the target scenario template, and if not, the general scenario template is used as the target scenario template. It should be noted that the quality of data generated using the scenario template of the matching preset role is often better than the quality of data generated based on the general scenario template.

[0080] The present application is further described in detail below in conjunction with an application example.

[0081] In this application embodiment, the task of data generation (such as Figure 2 ), configure preset roles and corresponding scenario templates, and then guide users to input requirements under the data generation task to realize data generation in vertical business fields.

[0082] For example, when configuring a scenario-based template, you can configure the prompt word framework according to multiple fields such as Role, Context, Constraint, and Example. For example, Figure 3 The following is a schematic diagram of the interface for displaying prompt words. In addition, variables can be set in the corresponding prompt words under the prompt word framework, such as Figure 4 The curly braces in the prompt words shown (i.e., {Chat_record}}, {{Question}}) are variables, which can be associated with the corresponding fields in the configuration file uploaded by the user. When executing the task, the configuration file is automatically read and the corresponding fields are replaced, thereby automatically modifying the Prompt and realizing batch generation of Prompts.

[0083] It should be noted that the variables in the prompt word can also be set by the user in the task definition interface, that is, the user sets the variable through the auxiliary information, and the electronic device determines whether the variable exists in the set prompt word list. If not, Figure 5 As shown, the user is prompted whether to add the referenced variables in the prompt word to the variable list, that is, to update the variable list. The electronic device can update the existing variable list based on the user-defined variables, thereby achieving the purpose of personalized addition of variables in the prompt word.

[0084] Figure 6 The schematic diagram of the interface for users to upload configuration files is shown, wherein the configuration file is a formatted data file, and its formatted data example is as follows Figure 7 The electronic device can match the variables in the prompt word with the fields in the configuration file and automatically replace the variables in the prompt word, such as Figure 8 shown.

[0085] Before obtaining the expected generated data, the user can also preview the generated data corresponding to the prompt word under the target scenario template, such as Fig. 9 As shown in the figure, click "Preview Generation Effect" in the interface to generate the preview result, such as Fig.10 As shown, in this step, the user can also select multiple models to compare the effects as needed, and then determine the best model configuration, that is, the user can update the configuration of the target scenario template based on the previewed generated data.

[0086] For example, the user can click Fig. 9 Click "Save and Run Generator" in the lower left corner of the interface, configure the execution information, and create a new field gpt_result to save the GPT output results. The interface is as follows Fig.11 The user then clicks "Generate Dataset Now" to start the data generation task. The interface is as follows Fig.12 As shown in the figure, the user clicks "Details" in the interface to expand the interface for viewing task details. Fig.13 As shown, click "Dataset Name" to get an example of generated data. Fig.14 shown.

[0087] It should be noted that the data generation method of this application embodiment can effectively improve the quality of data generation from the perspectives of diversity and data deviation of generated data. In terms of data diversity, it can be measured by two indicators: semantic similarity and vocabulary of generated data. Data deviation refers to the quantitative distribution of different types of a certain attribute (such as email subject, region) in a data set. An ideal data set should maintain basic data balance between various types. Language models such as ChatGPT are essentially probabilistic models. The attribute deviation in their training data is likely to be passed on to downstream applications, resulting in certain deviations in the data generated by such models, which is specifically manifested as a certain type of data accounting for too high a proportion of the overall data.

[0088] As for the aforementioned semantic similarity, through experimental verification, considering that there are naturally large semantic differences between emails from different companies, each sample email only calculates semantic similarity with other sample emails from the same company, and does not calculate between emails from different companies. The higher the similarity score, the higher the repetitiveness between the samples, and the worse the corresponding data diversity. The similarity score distribution of the email sample obtained by the data generation method of the embodiment of the present application is lower, with the center line around 0.8, while the center line of the similarity distribution of the ordinary data generation algorithm is around 0.9.

[0089] As for the aforementioned vocabulary size, the vocabulary size of a dataset can also reflect the size of data diversity. The larger the vocabulary size, the richer the sample description, and the corresponding differences between samples will also become greater, which will improve the diversity quality of the overall data.

[0090] In this application example, the experiment uses the python library Jieba for word segmentation, and uses the full mode to scan out all the words in the sentence that can be formed into words. The experimental results are shown in Table 1 below.

[0091] Table 1

[0092] Among them, the sample vocabulary obtained by the data generation algorithm of this application embodiment is generally higher than that of the general data generation algorithm, especially in the email data generation scenario, the sample vocabulary of this data generation algorithm is about twice that of the general data generation algorithm.

[0093] By statistically analyzing the data generation process, it can be found that the vocabulary of the data generation algorithm of this application embodiment increases faster, and the diversity continues to increase with the increase of data volume, while the vocabulary change of the ordinary data generation algorithm begins to flatten out at 500 samples. When the vocabulary reaches 5K, the ordinary algorithm generates 1.78 times more data than the intelligent data generation algorithm. In other words, when meeting the same diversity standard, the data generation algorithm can save 65.18% of the cost compared with the ordinary data generation algorithm.

[0094] As for the aforementioned data bias, studies have shown that in the news data generated by ChatGPT, news from Europe and America accounts for the majority, while data from Africa and Asia accounts for a small proportion. This data bias will lead to a decrease in the accuracy of the classification model, and may also cause discrimination in the question-answering model in vertical fields, resulting in backdoors.

[0095] The data generation algorithm of this application embodiment avoids the bias of models such as ChatGPT from being passed to the data generated downstream by presetting various attribute values ​​of the data to be generated. This experiment uses the generated email subject as the detection target. Through comparison, it can be concluded that the distribution of email data subjects obtained by the ordinary data generation algorithm is extremely unbalanced, among which the "official notice" type accounts for more than half (54.6%), while some topics, such as "salary" and "tax" topics included in "others", account for less than 0.5%. In contrast, the number distribution of email sample data obtained by the data generation algorithm of this application embodiment in each subject category is relatively balanced, most of which are 5.3%, and there is almost no data deviation.

[0096] In summary, the data generation method of the embodiment of the present application can effectively improve the quality of data generation in terms of data diversity and data deviation, and can better meet the needs of data generation in vertical segments.

[0097] In order to implement the method of the embodiment of the present application, the embodiment of the present application also provides a data generating device, which corresponds to the above-mentioned data generating method, and each step in the above-mentioned data generating method embodiment is also fully applicable to the embodiment of the present data generating device.

[0098] like Fig.15 As shown, the data generation device includes: an acquisition module 1501, a matching module 1502, a first processing module 1503 and a second processing module 1504. The acquisition module 1501 is used to acquire identity definition information representing the expected role; the matching module 1502 is used to match the identity definition information with the preset scenario templates of various roles to obtain the matched target scenario template; the first processing module 1503 is used to generate a prompt word for guiding the model output based on the target scenario template; the second processing module 1504 is used to input the prompt word into the preset model to obtain the expected generated data.

[0099] Exemplarily, the data generating device further includes: a configuration module 1505, configured to: Divide multiple preset roles based on data application scenarios; Based on each preset role and setting field, a corresponding scenario template is configured; wherein the setting field is used to define a prompt word framework corresponding to the scenario template.

[0100] Exemplarily, the first processing module 1503 is specifically configured to: Based on the auxiliary information and / or preset information input by the user for generating prompt words, the setting fields in the target scenario template are filled to generate prompt words for guiding the model output.

[0101] Exemplarily, at least one of the setting fields includes a variable supporting configuration, and the first processing module 1503 is further configured to: Replacing the variables based on the configuration file; Based on the replacement of the variables, the generated prompt words are generalized to obtain batch prompt words; The second processing module 1504 is specifically used for: The batch prompt words are input into a preset model to obtain batch generated data.

[0102] Exemplarily, there are multiple preset models, and the second processing module 1504 is specifically used to: Based on the distributed calling mechanism, the batched prompt words are divided and input into each preset model in batches to obtain batched generated data.

[0103] Exemplarily, the configuration module 1505 is specifically used for: When configuring a corresponding scenario-based template based on any preset role, set the supported configuration variables in at least one setting field; A variable list is generated based on the set variables, and the variable list is added to the corresponding scenario template; wherein the variable list is used for generalizing prompt words when the corresponding scenario template generates prompt words.

[0104] Exemplarily, the auxiliary information further includes: user-defined variables; the first processing module 1503 is further used to: Based on the user defined variables, the variable list is updated.

[0105] Exemplarily, before obtaining the expected generated data, the second processing module 1504 is further used to: Based on the prompt word and the preset model, obtaining preview generated data; If it is determined that the previewed generated data does not meet the requirements, the configuration of the target scenario template is updated based on the previewed generated data.

[0106] Exemplarily, the first processing module 1503 is specifically configured to: Based on the relationship between entities and attributes in the pre-built knowledge graph, determine the setting fields in the target scenario template corresponding to the auxiliary information and / or preset information input by the user, and fill the auxiliary information and / or preset information into the corresponding setting fields to obtain prompt words for guiding the model output.

[0107] Exemplarily, the matching module 1502 is specifically used for: Based on the identity definition information, it is determined whether the expected role falls into the preset roles. If so, the scenario template of the matching preset role is used as the target scenario template; if not, the general scenario template is used as the target scenario template.

[0108] In actual application, the acquisition module 1501, the matching module 1502, the first processing module 1503, the second processing module 1504 and the configuration module 1505 can be implemented by a processor in the electronic device. Of course, the processor needs to run the computer program in the memory to implement its functions.

[0109] It should be noted that: when the data generation device provided in the above embodiment performs data generation, only the division of the above program modules is used as an example. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the data generation device provided in the above embodiment and the data generation method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0110] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device. Fig.16 Only an exemplary structure of the electronic device is shown, not all structures, and it can be implemented as needed. Fig.16 Partial or complete structure shown.

[0111] like Fig.16 As shown, the electronic device 1600 provided in the embodiment of the present application includes: at least one processor 1601, a memory 1602, a user interface 1603 and at least one network interface 1604. The various components in the electronic device 1600 are coupled together through a bus system 1605. It can be understood that the bus system 1605 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 1605 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, in Fig.16 Various buses are labeled as bus system 1605.

[0112] The user interface 1603 may include a display, a keyboard, a mouse, a trackball, a click wheel, keys, buttons, a touch pad or a touch screen.

[0113] The memory 1602 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0114] The data generation method disclosed in the embodiment of the present application can be applied to the processor 1601, or implemented by the processor 1601. The processor 1601 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the data generation method can be completed by the hardware integrated logic circuit or software instructions in the processor 1601. The above-mentioned processor 1601 may be a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 1601 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, which is located in the memory 1602. The processor 1601 reads the information in the memory 1602 and completes the steps of the data generation method provided in the embodiment of the present application in combination with its hardware.

[0115] In an exemplary embodiment, the electronic device may be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA), general processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned method.

[0116] It can be understood that the memory 1602 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memories described in the embodiments of the present application are intended to include, but are not limited to, these and any other suitable types of memories.

[0117] In an exemplary embodiment, the present application also provides a computer storage medium, which can be a computer-readable storage medium, for example, a memory 1602 storing a computer program, and the computer program can be executed by a processor 1601 of an electronic device to complete the steps described in the method of the present application embodiment. The computer-readable storage medium can be a memory such as a ROM, a PROM, an EPROM, an EEPROM, a Flash Memory, a magnetic surface memory, an optical disk, or a CD-ROM.

[0118] In an exemplary embodiment, the embodiment of the present application further provides a computer program product, including a computer program, which can be executed by the processor 1601 of the electronic device 1600 to complete the steps described in the method of the embodiment of the present application.

[0119] It should be noted that: "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0120] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.

[0121] The above is only a specific implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

Claims

1. A data generation method, characterized in that: include: Obtaining identity definition information representing the desired role; Based on the identity definition information, the scenario templates of various preset roles are matched to obtain a matching target scenario template; Generate prompt words for guiding model output based on the target scenario template; The prompt words are input into a preset model to obtain the desired generated data.

2. The method according to claim 1, characterized in that The method further comprises: Divide multiple preset roles based on data application scenarios; Based on each preset role and setting field, a corresponding scenario template is configured; wherein the setting field is used to define a prompt word framework corresponding to the scenario template.

3. The method according to claim 1, characterized in that The generating of prompt words for guiding model output based on the target scenario template includes: Based on the auxiliary information and / or preset information input by the user for generating prompt words, the setting fields in the target scenario template are filled to generate prompt words for guiding the model output.

4. The method according to claim 3, characterized in that: At least one of the setting fields includes a variable that supports configuration, and the method further includes: Replacing the variables based on the configuration file; Based on the replacement of the variables, the generated prompt words are generalized to obtain batch prompt words; The step of inputting the prompt word into a preset model to obtain the desired generated data includes: The batch prompt words are input into a preset model to obtain batch generated data.

5. The method according to claim 2, characterized in that: The configuration of the corresponding scenario-based template based on the preset roles and setting fields includes: When configuring a corresponding scenario-based template based on any preset role, set the supported configuration variables in at least one setting field; A variable list is generated based on the set variables, and the variable list is added to the corresponding scenario template; wherein the variable list is used for generalizing prompt words when the corresponding scenario template generates prompt words.

6. The method according to claim 3, characterized in that The auxiliary information and / or preset information for generating prompt words input by the user is used to fill in the setting fields in the target scenario template to generate prompt words for guiding the model output, including: Based on the relationship between entities and attributes in the pre-built knowledge graph, determine the setting fields in the target scenario template corresponding to the auxiliary information and / or preset information input by the user, and fill the auxiliary information and / or preset information into the corresponding setting fields to obtain prompt words for guiding the model output.

7. A data generating device, characterized in that: include: An acquisition module, used to acquire identity definition information representing an expected role; A matching module, used to match the identity definition information with preset scenario templates of various roles to obtain a matching target scenario template; A first processing module, used to generate prompt words for guiding model output based on the target scenario template; The second processing module is used to input the prompt word into a preset model to obtain the expected generated data.

8. An electronic device, characterized in that: include: A processor and a memory for storing a computer program that can be executed on the processor, wherein: The processor is used to execute the steps of the method according to any one of claims 1 to 6 when running a computer program.

9. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Keyword-based search method, apparatus and device, and storage medium

    CN111339424A

  • Honeypot protection method and device, storage medium and electronic equipment

    CN116800525A

  • Content generation method and device, computer equipment and storage medium

    CN117171369A

  • Generation method and device of cue word information of large language model, equipment and medium

    CN117539975A

  • Generative large model-based cue word construction method and apparatus, and intelligent device

    CN117744796A

Cited By

  • Prompt word dynamic generation method based on domain ontology

    CN121301587A

  • A prompt word dynamic generation method based on a domain ontology

    CN121301587B