Role-playing-based education scene dialogue data automatic synthesis method and device
Patent Information
- Application Number
- CN202611409010.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-11
- Publication Date
- 2026-10-13
AI Technical Summary
[0009]本发明的目的在于提供基于角色扮演的教育场景对话数据自动合成方法及装置,以解决现有技术在有限样本条件下人口学分布精确控制、场景生成偏差的自动检测与传播隔离、以及多轮长上下文一致性维护方面的技术问题,在不采集真实儿童对话数据的条件下,实现人口学分布可控、场景与动机覆盖可追溯、场景设定可自动验证、年龄表达相匹配且多轮上下文连贯的教育场景对话数据合成
[0029]1)本发明解决了多阶段数据处理中偏差传播的技术问题,采用分阶段管线架构,将教育场景对话数据合成过程拆分为五个依次衔接的处理阶段,各阶段通过结构化中间数据对象传递信息。相比现有方法将所有约束集中于单次模型调用,本发明使每个阶段仅关注有限的生成目标,前一阶段输出经自动校验后才传入下一阶段,偏差可在产生阶段内被自动定位和修正,避免向后续处理环节传播。针对人口学分布准确性、场景覆盖完整性、角色年龄匹配程度和多轮交互连贯性,本发明分别设置了对应的自动化质量控制机制,产生了提高生成数据准确性、系统性和一致性的技术效果。实验表明,采用本发明的分阶段管线架构后,合成数据在人口学分布偏差、场景忠实度、年龄表达匹配度和多轮连贯性四项综合指标上的合格率达到88.0%,相比单次端到端生成方法的62.5%提升了25.5个百分点。各阶段间的错误隔离率为96.1%,即前置阶段产生的可识别偏差中,有96.1%在当前阶段内被自动校验机制捕获并修正,未向后续处理阶段传播。
Smart Images

Figure CN122903471A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing and data synthesis technology, and particularly relates to a method and apparatus for automatically synthesizing dialogue data in educational scenarios based on role-playing. Background Technology
[0002] With the widespread deployment of large language models in education, AI dialogue products targeting children and adolescents are rapidly emerging, covering various application scenarios such as intelligent tutoring, emotional companionship, and learning Q&A. The development, testing, and safety assessment of these products all rely on large-scale, high-quality dialogue data covering diverse demographic backgrounds. Dialogue data for educational scenarios must simultaneously meet multidimensional feature requirements. The data should cover children at different stages of cognitive development, as there are qualitative differences between 7-year-olds and 17-year-olds in language complexity, reasoning ability, and emotional expression. The data should also cover various interaction scenarios and motivations, including knowledge exploration, emotional assistance, behavioral imitation, and boundary exploration. The data should be demographically representative, ensuring sufficient coverage of children from different genders, races, and socioeconomic backgrounds. Furthermore, the dialogue content should be natural and authentic, reflecting children's language habits in real-world situations, rather than stereotypical simulations from an adult perspective.
[0003] Early data acquisition primarily relied on data collection from real children or manually compiled data. While real children's data reflects the most authentic language patterns, it faces strict ethical review and privacy protection requirements. Furthermore, the scale of collection is limited by recruitment capacity and implementation conditions, making it particularly difficult to cover low-socioeconomic families, minority groups, and children with special needs, leading to systematic biases in the demographic representativeness of the sample. Manually compiled data involves adult annotators or education experts using their professional knowledge to create dialogue data simulating children's speech. However, the realism of adult-simulated children's language is limited, it is difficult to accurately grasp the progressive differences in cognitive complexity across different age groups, and it is costly, limited in scale, and the data quality depends on the author's personal experience, lacking consistency guarantees.
[0004] In recent years, generating educational dialogue data based on large language models has become a new technological approach, but existing technologies have the following technical problems:
[0005] 1) Educational scenario dialogue data needs to simultaneously meet multiple data quality constraints, including controllable demographic distribution, comprehensive scenario types, reasonable scenario settings, age-appropriate character expressions, and coherent multi-turn dialogues. Existing methods typically handle all constraints in a single model call, lacking a process flow that executes generation, verification, and result transmission in stages according to data dependencies. If a deviation occurs in the data processing of the earlier stages, it will directly propagate to subsequent generation stages, and it is difficult to automatically locate and correct the source of the deviation. This problem is the core technical issue that the overall technical solution of this invention aims to address.
[0006] 2) Regarding demographic attribute control, existing methods typically involve random sampling of attributes such as age, gender, and socioeconomic background based on preset probabilities. This approach faces computational challenges in accurately controlling the discrete distribution under limited sample conditions: the actual number of each category can easily deviate from the target proportion, with a few categories particularly prone to insufficient sample size. Furthermore, when multiple attributes are directly and jointly randomly sampled, some attribute combinations may be generated repeatedly, while others remain uncovered for extended periods, resulting in incomplete coverage of the combination space. This issue corresponds to improvements in the demographic label generation module.
[0007] 3) Regarding scene construction, existing methods often directly expand scenes based on brief themes or natural language descriptions, lacking intermediate representations that explicitly define scene categories, character behaviors, interaction motivations, and contextual characteristics in the form of structured data objects. The generated content may deviate from the original task, mixing in other scene categories. Simultaneously, existing methods lack an automated multi-dimensional verification mechanism for the expanded results, typically only checking text fluency. They struggle to automatically detect deeper deviations such as whether the scene faithfully adheres to the original setting, whether questions remain open-ended, and whether character attributes are consistent. They also lack an iterative correction loop that automatically injects the reasons for modification into the next round of expansion input based on the verification results, failing to achieve automatic detection and isolation of generation deviations. This issue corresponds to improvements in the synthesis task and scene seed generation modules, as well as the scene expansion and verification modules.
[0008] 4) Regarding character expression and multi-turn interactions, children and adolescents of different age groups exhibit significant differences in vocabulary complexity, sentence length, emotional expression, causal reasoning ability, and communication habits. Existing general prompts only provide general requirements and cannot automatically retrieve matching constraints based on character age attribute values, making it difficult to stably match specific age groups. This results in younger characters expressing themselves in an adult manner, with emotions or reasoning levels inconsistent with the intended settings. During multi-turn generation, if the model only receives local context or fails to continuously inject scene settings as system-level context into each round of model calls, character identity changes, repeated questions, and inconsistencies can easily occur. This is a technical issue related to maintaining consistency in long context sequences. This problem corresponds to improvements in the initial character message generation module and the multi-turn dialogue generation module. Summary of the Invention
[0009] The purpose of this invention is to provide a method and apparatus for automatically synthesizing educational scene dialogue data based on role-playing, in order to solve the technical problems of accurate control of demographic distribution, automatic detection and propagation isolation of scene generation deviation, and maintenance of consistency in multiple rounds of long context under limited sample conditions in the existing technology. Without collecting real children's dialogue data, it can achieve the synthesis of educational scene dialogue data with controllable demographic distribution, traceable scene and motivation coverage, automatic verification of scene settings, matching age expression and coherent multi-round context.
[0010] This invention is achieved through the following technical solution:
[0011] This invention discloses a method for automatically synthesizing dialogue data in educational scenarios based on role-playing, comprising the following steps performed by a computer:
[0012] 1) Based on the target proportion and total number of samples for each demographic dimension, the integer quota is determined using the maximum remainder method. The pseudo-random number generator independently shuffles the label arrays for each dimension and combines them according to their corresponding positions to generate multidimensional demographic labels.
[0013] 2) Combine multidimensional demographic labels with scene classification data objects and interaction motivation data objects into a synthesis task, and generate structured scene seeds by scheduling a large language model through a concurrent window;
[0014] 3) The structured scene seed is expanded into a complete scene setting by the scene expansion model, and the model is independently verified for structured validation; if it fails, structured feedback is injected and iterative correction is performed;
[0015] 4) Obtain the character age group attribute values determined by multidimensional demographic labels from the structured scene seed, retrieve system prompt words from the hierarchical prompt word library based on the character age group attribute values, generate the first round of character messages based on the complete scene settings, and perform placeholder detection and condition regeneration.
[0016] 5) Write the complete scene settings into the system-level context and the first round of role messages into the dialogue history sequence. The multi-round dialogue engine alternately calls the role simulation model and the dialogue object model. After reaching the target number of rounds, the structured multi-round dialogue data is output.
[0017] As a further improvement, in step 1) of this invention, the maximum remainder method specifically includes: multiplying the target proportion of each category by the total number of samples to obtain the precise quota, rounding down to obtain the basic allocation quantity, calculating the difference between the precise quota and the basic allocation quantity as the remainder, and filling the remaining quotas into the corresponding categories one by one according to the remainder from largest to smallest. When the remainders are equal, they are allocated according to the category order, so that the deviation between the integer quota and the precise quota of each category does not exceed 1 sample; generating a label array for each dimension according to the integer quota, shuffling it independently by a pseudo-random number generator, and forming multidimensional demographic labels for each sample according to the elements in the same position.
[0018] As a further improvement, in step 2) of this invention, the structured scene seed is a data object containing the following predefined fields: a demographic attribute field, containing attribute values of each dimension in the multidimensional demographic label; a scene category field, whose value is selected from the sub-category enumeration set of the scene classification data object; a core behavior field, used to describe the intention or goal that the character intends to express in the scene, whose value is generated by the large language model based on the interaction motivation data object; a role characteristic field, containing two sub-fields: cognitive maturity and emotional maturity, the values of each sub-field being selected from the predefined level enumeration; an interaction context information field, whose value is selected from the predefined social dynamic pattern enumeration set; and a risk signal type field, whose value is selected from the predefined risk element significance enumeration set.
[0019] In step 2), the interaction motivation data object contains a variety of predefined motivation type identifiers. Each motivation type identifier corresponds to a behavior-driven category that the character initiates the dialogue, and participates in the construction of the synthetic task list as one of the dimensions of the combined enumeration.
[0020] As a further improvement, in step 3) of this invention, the scene expansion model takes the structured scene seed as input to generate a complete scene setting that includes character narrative and background description; after the scene expansion model completes its output, an independent verification model is called, taking the structured scene seed and the complete scene setting as input, and performing structured verification on six verification dimensions: seed fidelity, category purity, no leakage, openness maintenance, authenticity, and structural consistency. A binary judgment result is output for each verification dimension, and a structured feedback containing the failure dimension identifier, modification reason, and improvement suggestion is generated when there is a verification dimension that fails; the modification reason in the structured feedback is concatenated with the previous complete scene setting and used as the input for the next round of expansion of the scene expansion model, until all verification dimensions pass or the number of retries reaches the preset limit.
[0021] As a further improvement, in step 4) of this invention, the hierarchical prompt word library uses the character's age group attribute value as the search key to store three sets of system prompt word data: the first set corresponds to 7-9 years old, the second set corresponds to 10-12 years old, and the third set corresponds to 13-17 years old; when the model calls, each set of system prompt word data constrains the lexical complexity, sentence length, emotional expression mode, and reasoning depth of the output text, so that the language complexity of the first round of character messages matches the target age group.
[0022] As a further improvement, in step 5) of this invention, the role simulation model takes the system-level context and the dialogue history sequence as input, generates a role message representing the current speech of the target role, and appends the role message to the dialogue history sequence; the dialogue object model takes the system-level context and the dialogue history sequence as input, generates a dialogue object message for the role message, and appends the dialogue object message to the dialogue history sequence; the multi-turn dialogue engine maintains the data structure of the dialogue history sequence, schedules the role simulation model and the dialogue object model in a preset alternating order, continuously injects the system-level context during each call to achieve the anchoring of the scene setting, and terminates the call and serializes the structured multi-turn dialogue data when the number of turns in the dialogue history sequence reaches the target number of turns pre-configured according to the scene category.
[0023] This invention also discloses an automatic synthesis device for dialogue data in educational scenarios based on role-playing, comprising:
[0024] Demographic label generation module: It is used to determine the integer quota according to the target proportion and total number of samples of each demographic dimension, and the pseudo-random number generator independently shuffles the label array of each dimension and combines them according to the corresponding positions to generate multidimensional demographic labels.
[0025] Synthesis Task and Scene Seed Generation Module: This module combines multidimensional demographic labels with scene classification data objects and interaction motivation data objects into synthesis tasks, and generates structured scene seeds by scheduling a large language model through a concurrent window.
[0026] Scene Expansion and Verification Module: This module expands structured scene seeds into complete scene settings using the scene expansion model. The model then independently verifies the structured settings and injects structured feedback for iterative correction if the verification fails. First-Round Role Message Generation Module: This module retrieves role age group attribute values determined by multi-dimensional demographic labels from the structured scene seeds. It then uses these attribute values to retrieve system prompts from a hierarchical prompt word library, generates the first-round role messages based on the complete scene settings, and performs placeholder detection and condition regeneration.
[0027] Multi-turn dialogue generation module: It is used to write the complete scene settings into the system-level context and the first round of role messages into the dialogue history sequence. The multi-turn dialogue engine alternately calls the role simulation model and the dialogue object model, and outputs structured multi-turn dialogue data after reaching the target number of rounds.
[0028] The beneficial effects of this invention are:
[0029] 1) This invention solves the technical problem of bias propagation in multi-stage data processing. It adopts a phased pipeline architecture, breaking down the synthesis process of educational scenario dialogue data into five sequentially connected processing stages. Each stage transmits information through structured intermediate data objects. Compared to existing methods that concentrate all constraints on a single model call, this invention focuses on only limited generation objectives at each stage. The output of the previous stage is automatically verified before being passed to the next stage, allowing biases to be automatically located and corrected within the generation stage, preventing propagation to subsequent processing stages. For demographic distribution accuracy, scene coverage completeness, role age matching, and multi-turn interaction coherence, this invention sets corresponding automated quality control mechanisms, resulting in improved accuracy, systematicity, and consistency of the generated data. Experiments show that after adopting the phased pipeline architecture of this invention, the pass rate of the synthesized data reaches 88.0% across four comprehensive indicators: demographic distribution bias, scene fidelity, age expression matching, and multi-turn coherence, an improvement of 25.5 percentage points compared to the 62.5% of the single end-to-end generation method. The error isolation rate between stages is 96.1%, meaning that 96.1% of the identifiable deviations generated in the previous stage are captured and corrected by the automatic verification mechanism in the current stage and do not propagate to subsequent processing stages.
[0030] 2) This invention solves the computational problem of precise control of demographic distribution under limited sample conditions. It introduces a demographic label generation module and employs a proportional allocation strategy based on the maximum remainder method. The processor automatically performs quota calculation, rounding down, remainder sorting and supplementation, and array shuffling and positional combination operations driven by a pseudo-random number generator. This module multiplies the target proportion by the total number of samples to obtain the precise quota, rounds down, and supplements the remaining quotas according to the remainder from largest to smallest, ensuring that the deviation of each category from the ideal quota does not exceed one sample. The label arrays of each dimension are independently shuffled and combined positionally, allowing for free cross-fertilization of attributes across different dimensions. This method achieves the technical effect of precisely controlling demographic distribution under arbitrary sample sizes, solving the problems of existing probability sampling where the number of categories deviates from the target proportion, a few categories have insufficient samples, and attribute combination coverage is uneven under limited sample conditions. In an experiment generating 1000 samples, after adopting the maximum remainder method allocation strategy of this invention, the maximum deviation between the actual allocation quantity of each category in the four demographic dimensions and the target quota does not exceed one sample, and the marginal distribution of each dimension precisely matches the target proportion. Using probabilistic random sampling, repeated 100 times with the same sample size, the average distribution bias was 3.2%, with a maximum single-class bias averaging 15.6 samples and a worst-case bias of 28 samples. Furthermore, in 37 out of 100 experiments, a certain attribute combination was completely not covered. With a sample size of 1000, this invention, through independent and precise allocation of each dimension followed by random combination, achieved 100% attribute combination coverage, while the average combination coverage of the probabilistic random sampling method was only 63.0%.
[0031] 3) This invention solves the technical problem of automatically detecting and isolating the propagation of deviations during scene expansion by introducing a synthesis task and a scene seed generation module, as well as a scene expansion and verification module. The former combines and enumerates demographic tags, scene classification data objects, and interaction motivation data objects to systematically cover the scene space, generating structured scene seeds containing predefined fields such as cognitive maturity, emotional maturity, and core behavioral descriptions. The latter automatically performs structured verification from six dimensions—seed fidelity, category purity, no leakage, openness maintenance, authenticity, and structural consistency—by calling an independent verification model. It outputs a binary judgment result for each dimension, and if a verification fails, it injects structured feedback containing reasons for modification into the next round of expansion input, forming an automated closed-loop correction mechanism. These two modules achieve the technical effect of automatically detecting scene deviations and preventing their propagation to subsequent processing stages. In an expansion experiment with 500 structured scene seeds, after adopting the closed-loop verification and correction mechanism of this invention, the scene pass rate increased from 72.6% in the first round to 97.2% in the final round. The initial pass rates for the six verification dimensions were as follows: seed fidelity 88.4%, category purity 85.2%, no leakage 91.6%, openness maintenance 82.0%, authenticity 79.8%, and structural consistency 93.4%. After closed-loop correction, the pass rates for each dimension all increased to over 96%. Compared to the baseline method that only checks fluency, this invention reduced the scene deviation rate from 28.6% to 2.8%.
[0032] 4) This invention solves the technical problems of matching character age expressions and maintaining consistency in long context sequences by introducing a first-round message generation module and a multi-turn dialogue engine. The first-round message generation module uses the character's age group attribute value as the search key, automatically retrieving corresponding system prompt words from a hierarchical prompt word library. When calling the model, it injects constraints on lexical complexity, sentence length, emotional expression, and reasoning depth, and ensures the concrete completeness of the output through automatic placeholder detection and conditional regeneration control flow. The multi-turn dialogue engine maintains the dialogue history sequence data structure. During each round of generation, the complete dialogue history sequence and scene settings are simultaneously passed to the model. The scene settings are continuously injected as system-level context, and the target number of rounds is configured differently according to scene category. When the target number of rounds is reached, the call terminates and the output is serialized. These two modules achieve the technical effect of automatically matching character age expression features and maintaining the consistency of multi-turn dialogue context. Three educational psychology experts conducted a blind evaluation of 300 first-round messages. The message age group matching accuracy rate generated using the hierarchical prompt word library of this invention reached 91.3%, while the matching accuracy rate of the control group using general prompt words was only 58.7%. Regarding the coherence of multi-turn dialogues, an evaluation of 200 sets of multi-turn dialogues showed that the rate of role identity shift was 3.5%, the rate of inconsistency was 2.0%, and the rate of repeated questioning was 1.5%. Compared with the control method that only provided local context, the three indicators were reduced by 18.5, 14.0, and 11.5 percentage points, respectively. Attached Figure Description
[0033] Figure 1 This is a schematic diagram of the overall process of the data synthesis method of the present invention;
[0034] Figure 2 A schematic diagram of the closed-loop process for verifying the feedback-based scenario expansion;
[0035] Figure 3 This is a schematic diagram of the module architecture of the system of the present invention. Detailed Implementation
[0036] To make the objectives, technical solutions, and beneficial effects of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments are only for explaining the invention and not for limiting it. Without departing from the spirit and substance of this invention, those skilled in the art can make various modifications, equivalent substitutions, and improvements based on the content disclosed in this specification, and all such modifications and improvements should be considered to fall within the protection scope of this invention.
[0037] Furthermore, it should be understood that although the various embodiments are described differently in this specification for clarity, these embodiments are not mutually exclusive, and technical features of one embodiment can be combined with those of another embodiment without conflict.
[0038] It should be noted that, for ease of description and understanding, the specification uses terms such as "module," "unit," "step," and "device" to distinguish the division of functional logic or structural parts, but these are not limited to physically or logically absolutely independent units. These parts can be implemented in hardware, or through software functional modules, or a combination of hardware and software, all of which fall within the scope of protection of this invention.
[0039] Unless otherwise expressly defined, the technical or scientific terms used in this specification shall have the meanings commonly understood by one of ordinary skill in the art. The terms "comprising," "including," "having," and any variations thereof, as used herein, indicate non-exclusive inclusion; that is, the presence of a certain feature or step in the technical solution does not exclude the presence of other features or steps. Terms such as "a," "an," and "the" as used herein should not be construed as quantitative limitations and may indicate singular or plural. The terms "first," "second," and "third" as used herein are for the purpose of distinguishing different objects only and should not be construed as limitations on order or quantity.
[0040] For ease of understanding, the term "structured scene seed" in this paper refers to a field-based data object generated by the synthesis task and used to constrain subsequent scene expansion; "complete scene setting" refers to a scene data object that expands upon the structured scene seed and includes character narrative and background description; "scene expansion model" refers to a model call instance that receives the structured scene seed or the previous complete scene setting and its modification reasons, and outputs the complete scene setting; "verification model" refers to a model call instance that performs structured verification on the structured scene seed and the complete scene setting and outputs a pass or rejection judgment and modification reasons. The scene expansion model and verification model can be deployed based on the same or different base models, but expansion and verification should be performed separately with different input instructions and output responsibilities.
[0041] In this paper, "role simulation model" refers to a model invocation instance that generates the target role's current speech based on a verified complete scenario setting and dialogue history; "dialogue object model" refers to a model invocation instance that generates response messages based on a verified complete scenario setting and dialogue history; and "multi-turn dialogue engine" refers to an execution component that maintains the dialogue history sequence, alternately calls the role simulation model and dialogue object model according to a preset speaking order, and organizes and outputs structured multi-turn dialogue data after reaching the target number of turns. These terms are used to define input, output, and invocation relationships and do not require the corresponding models to be physically independent servers or programs.
[0042] Please see Figure 1This invention discloses an automatic synthesis method for educational scenario dialogue data based on role-playing. The figure illustrates the overall process of the proposed method. The method mainly includes five core steps automatically executed by a computer processor: demographic tag generation, synthesis task and scenario seed generation, scenario expansion and verification, first-round role message generation, and multi-round dialogue synthesis. The specific implementation of each step will be described in detail below.
[0043] In the demographic label generation stage, the processor automatically performs quota calculation and label allocation according to the preset demographic dimension ratio specifications, assigning multidimensional demographic labels to each sample to be synthesized, so that the final synthesized dataset accurately conforms to the target distribution in each demographic dimension.
[0044] In a preferred embodiment of the present invention, the system configuration includes four demographic dimensions: the age group dimension covers three groups: 7-9 years old, 10-12 years old, and 13-17 years old, corresponding to the three developmental stages of early childhood, pre-adolescence, and adolescence; the gender dimension includes two categories: girls and boys; the socioeconomic status dimension includes three levels: low, middle, and high; and the race dimension includes five categories: white, Latino, African American, Asian, and others. The above proportions can be flexibly configured according to the target application scenario. For each demographic dimension, the processor first multiplies the target proportion of each category in that dimension by the total number of samples to calculate the precise quota for each category. Since the quota is usually a non-integer, the processor performs a floor function on the precise quota to obtain the basic allocation quantity, and then fills in the remaining quotas in descending order of the remainder, finally obtaining the integer allocation quantity for each category. Taking the age group dimension as an example, if the target is to synthesize 30 samples, the precise quotas for the three age groups are 8.1, 8.1, and 13.8 respectively. Rounding down yields a base allocation of 8, 8, and 13, totaling 29. The remaining quota is allocated to the third group with the largest remainder, resulting in a final allocation of 8, 8, and 14. When remainders are equal, allocation is performed according to category order. This allocation method guarantees that the total is exactly equal to the target number, and the deviation of each category from the ideal quota does not exceed one sample. After completing the integer allocation for each dimension, the processor expands the allocation results into a label array and performs random combinations. For example, in the age group dimension, the allocation results 8, 8, and 14 are expanded into an array of length 30, where the three age groups are repeated according to their allocated quantities. The processor initializes the pseudo-random number generator with a user-specified seed value and independently performs random shuffling on the label array for each dimension. After each dimension is independently shuffled, it is combined into a multi-dimensional label according to the corresponding position. That is, the label vector of the i-th sample is formed by combining the i-th element of the age group array, the i-th element of the gender array, the i-th element of the socioeconomic status array, and the i-th element of the race array in sequence.
[0045] After generating demographic tags, the process moves to the synthesis task and scene seed generation stage. This stage combines and enumerates demographic tags with scene classification data objects and interaction motivation data objects to construct a synthesis task list. For each task, a large language model is invoked to generate a structured scene seed.
[0046] In a preferred embodiment of the present invention, the scene classification data object adopts a two-level hierarchical structure, containing 8 major categories and 25 subcategories. The first-level scene categories include: personal safety and legal risks, sexually explicit content and harmful behavior, psychological and emotional health, education and information misleading, prejudice, discrimination and hate speech, social, family and behavioral impacts, network information security, and growth and development risks. Each major category contains 2-5 subcategories, providing more granular scene differentiation. The interaction motivation data object contains 10 predefined motivation type identifiers. Each motivation type identifier corresponds to a behavioral driving category for a character initiating a dialogue. Specific categories include: curiosity / exploration (wanting to try, test, or understand new things), social belonging / identity (seeking acceptance, recognition, or alignment with peers), emotional distress / anxiety (acting out of fear, loneliness, or emotional stress), boredom / stimulation seeking (seeking stimulation, novelty, or excitement), rule testing / boundary pushing (probing permitted or possible boundaries), authority influence (following the instructions or expectations of elders or trusted figures), helping or protecting others (justifying behavior by helping others), misunderstanding consequences (underestimating harm or misjudging impact), identity exploration (exploring self-image, role, or values), and efficiency / shortcut seeking (wanting to achieve goals faster or easier). The processor combines demographic labels with subcategories in the scene classification data object and motivation type identifiers in the interaction motivation data object to construct a list of synthetic tasks. Concurrent window control schedules concurrent calls to the large language model to generate structured scene seeds. The scene seed is a field-based data object containing demographic attribute fields, scene category fields, core behavior fields, role characteristic fields, interaction context information fields, and risk signal type fields. Its demographic attribute fields contain attribute values from each dimension of the multi-dimensional demographic labels, with the demographic dimensions and value ranges consistent with the aforementioned demographic dimension configuration. The scene category field's value is selected from the sub-category enumeration set of the scene classification data object, used to identify the scene sub-category corresponding to the current synthesis task. The core behavior field describes the intention or goal the character intends to express in the scene. The large language model determines the motivation type identifier corresponding to the current synthesis task from the interaction motivation data object and generates the core behavior field based on this motivation type identifier. The motivation type identifier represents the behavior driving category of the character initiating dialogue, and the core behavior field represents the specific manifestation of this behavior driving category in the current scene. The role characteristic field contains two sub-fields: cognitive maturity and emotional maturity. Cognitive maturity is divided into three levels: low, medium, and high, used to characterize the character's thinking ability and understanding of the consequences of behavior. Emotional maturity is also divided into three levels: low, medium, and high, used to characterize the character's emotional regulation ability and the degree to which they are influenced by external factors. The values for the two subfields are selected from their respective predefined level enumerations. The value for the interaction context information field is selected from a predefined set of social dynamic patterns.The social dynamics pattern enumeration set includes four patterns: acting alone, peer pressure, authority influence, and online social interaction, used to characterize the social interaction states that influence role behavior. The value of the risk signal type field is selected from a predefined risk element visibility enumeration set. This risk element visibility enumeration set includes three levels: direct, subtle, and ambiguous, used to distinguish the degree to which risk intent is presented in the scenario.
[0047] The scene expansion and verification phase utilizes a scene expansion model to expand the structured scene seed into a complete scene setting that includes character narratives and background descriptions. A verification model, independent of the scene expansion model, performs multi-dimensional structured verification on the expansion results, forming an automated closed-loop quality assurance mechanism. Please refer to [link / reference]. Figure 2 The diagram illustrates the interaction process between the scenario expansion model and the validation model.
[0048] The scenario expansion model receives structured scenario seeds and generates complete scenario settings. Scenario settings include detailed descriptions of cognitive and emotional maturity, the character's cultural background and family situation, scenario narrative, and evaluation criteria. The narrative section describes the character's situation, thoughts, and interaction context using natural text, while the evaluation criteria provide a standard description for assessing the quality of subsequent dialogues. For specific scenarios requiring the establishment of a pre-defined trust relationship (such as emotional manipulation and inducement, virtual emotional dependence, etc.), the expansion results also include a memory field describing the AI assistant's understanding of the character in previous interactions. The validation model performs structured validation on the expansion results, including six dimensions: seed fidelity (verifying whether the expanded narrative accurately reflects the core behaviors defined in the seed, without semantic shifts or target substitution); category purity (verifying whether the expanded text revolves solely around the single scenario subcategory corresponding to the seed, without introducing topics from other categories); no leakage (verifying whether the expanded text avoids including expected responses or solutions to the dialogue); openness preservation (verifying whether the core issues in the scenario remain unresolved, leaving room for subsequent dialogue); authenticity (verifying whether the character's cognitive expressions and language style match the set age group and maturity level); and structural consistency (verifying whether there are logical contradictions between the fields). The validation model outputs a binary decision (pass / fail) for each validation dimension. If any dimension fails, the overall decision is rejection, and a structured feedback is output containing the failed dimension identifier, the reason for modification, and improvement suggestions. During retries, the previous complete scenario setting and the modification reason in the structured feedback are combined as the historical context for the next round of expansion input of the scenario expansion model, enabling targeted correction. The loop exit condition is that all validation dimensions pass or the number of retries reaches a preset limit.
[0049] Once the verified complete scenario setting is established, it enters the first round of character message generation. In this stage, based on the character's age group attribute value in the structured scenario seed, the corresponding system prompt words are automatically retrieved from the pre-stored hierarchical prompt word library. The large language model generates the first round of character messages that conform to the cognitive and linguistic characteristics of that age group, and the output is made concrete and complete through an automatic placeholder detection mechanism.
[0050] The tiered prompt word library uses the character's age group attribute as the search key and stores three sets of system prompt word data. Each set of system prompt word data constrains the language style and expression characteristics of characters in that age group when the model is invoked: The first set corresponds to 7-9 years old (early childhood stage), constraining character messages to be primarily short, specific, direct questions or simple statements, with vocabulary limited to commonly used simple words, direct and limited emotional expression, and no causal reasoning or background explanations. The second set corresponds to 10-12 years old (pre-adolescent stage), allowing character messages to include brief reasons or contextual explanations, maintaining an informal style and reflecting preliminary logical reasoning, but not presenting overly mature analysis. The third set corresponds to 13-17 years old (adolescent stage), allowing character messages to express emotions, uncertainty, and more complex reasoning processes, showcasing conflicting emotions and risk awareness, while still maintaining the style of instant messaging. After generating the first round of messages, the processor performs automatic placeholder detection. If a placeholder is detected, the previous output is concatenated with the concretization instruction, and the model is invoked again. The model replaces the placeholder description with a specific name or detail based on the scene context and character background until the detection is passed or the retry limit is reached.
[0051] The first round of character messages detected leads to the multi-turn dialogue generation stage. This stage initializes the state data of the multi-turn dialogue engine, and subsequent messages are generated alternately by the character simulation model and the dialogue object model based on the system-level context and dialogue history sequence. After completing the preset target number of rounds, structured multi-turn dialogue data containing the complete dialogue context is output.
[0052] During engine initialization, it receives the first-round character message that passes detection, the complete scene setting that passes verification, the character's age range, and the target number of rounds. It writes the complete scene setting into the system-level context and appends the first-round character message to the dialogue history sequence. The number of dialogue rounds is configured according to scene subcategories. Most direct expression-oriented scenes are configured with 3 rounds, which is sufficient to demonstrate the basic interaction structure of the character's initial request, the dialogue partner's response, and the character's subsequent reactions. For progressive information accumulation scenarios (such as subcategories like "emotional manipulation and inducement" and "virtual emotional dependence," where the character needs to gradually build trust or reveal sensitive information through multiple rounds of dialogue), it is configured with 8 rounds to provide sufficient interaction space to demonstrate the progressive relationship development process. The engine sequentially calls the character simulation model and the dialogue partner model using an alternating scheduling strategy. During each round generation, the complete dialogue history sequence is passed to the model as context to ensure semantic coherence between subsequent messages and preceding messages. The scene setting is continuously injected as system-level context into each model call, allowing the model to reference the character's background information and scene constraints during each round generation, preventing character shifts during dialogue progression. After each call, the generated message is appended to the dialogue history sequence. When the number of rounds in the dialogue history sequence reaches the target number of rounds pre-configured according to the scenario category, the call is terminated and the structured multi-round dialogue data is serialized and output. The final output structured dialogue data contains complete metadata, scenario settings and message sequences arranged in chronological order.
[0053] Please see Figure 3 The figure illustrates the modular architecture of the system of this invention. The system as a whole adopts a pipelined architecture, with the processor executing computer programs in memory to implement the following functional modules:
[0054] The demographic label generation module is used to obtain the precise quota for each demographic dimension by multiplying the target proportion of each category in that dimension by the total number of samples. The precise quota is then rounded down to obtain the basic allocation quantity. The remaining quotas are then allocated to the corresponding categories one by one according to the remainder from largest to smallest, resulting in the integer allocation quantity for each category. The integer allocation quantity is then expanded into a label array. A pseudo-random number generator is initialized with a preset seed value to independently perform random shuffling on the label arrays of each dimension and then combine them according to the corresponding positions to generate multidimensional demographic labels, so that the synthetic dataset accurately conforms to the target distribution in each demographic dimension.
[0055] The synthesis task and scene seed generation module is used to combine and enumerate demographic labels, scene classification data objects, and interaction motivation data objects to build a synthesis task list. Through concurrent window control scheduling, it concurrently calls the large language model for each synthesis task to generate a structured scene seed containing predefined fields.
[0056] The scene expansion and verification module is used to call the scene expansion model to generate a complete scene setting with the structured scene seed as input, and call the verification model, which is independent of the scene expansion model, to perform multi-dimensional structured verification on the complete scene setting and output a binary judgment result for each verification dimension. When there is a verification dimension that fails, the structured feedback containing the failure dimension identifier and the reason for modification is injected into the next round of input of the scene expansion model to perform iterative correction until all verification dimensions pass or the number of retries reaches the preset limit.
[0057] The first-round character message generation module is used to automatically retrieve the corresponding system prompt words from the pre-stored hierarchical prompt word library based on the character age group attribute value in the structured scene seed. Based on the verified complete scene setting, the module calls the model to generate the first-round character message. Automatic placeholder detection is performed on the first-round character message. When a placeholder is detected, the first-round character message is concatenated with the concrete instruction and the model is called again to generate the message until the detection is passed or the retry limit is reached.
[0058] The multi-turn dialogue generation module is used to initialize the state data of the multi-turn dialogue engine, write the verified complete scene settings into the system-level context, append the detected first-turn role messages to the dialogue history sequence, and call the role simulation model and dialogue object model in turn according to the alternating scheduling strategy. Each time it is called, the dialogue history sequence and system-level context are passed in as input, and the generated messages are appended to the dialogue history sequence after the call is completed. When the number of turns in the dialogue history sequence reaches the target number of turns pre-configured according to the scene category, the call is terminated and the structured multi-turn dialogue data is output.
[0059] To verify the beneficial effects of this invention, the following experiments were conducted. The scene expansion model, verification model, role simulation model, and dialogue object model in the experiments all used the DeepSeek series of large language models as base model call instances. This series of models are large-scale pre-trained language models with context understanding and natural language generation capabilities. The experimental goal was to synthesize 1000 complete multi-turn dialogue data sets.
[0060] The demographic dimensions are configured using four dimensions: age group (7-9 years, 10-12 years, 13-17 years), gender (girls and boys), socioeconomic status (low, middle, and high), and race (white, Latino, African American, Asian, and others). The scenario classification system includes 8 major categories and 25 subcategories, and the interaction motivation set includes 10 types. The maximum number of retries for the validation model is set to 3. The number of rounds in multi-turn dialogues is configured according to scenario type: 3 rounds for direct expression scenarios and 8 rounds for progressive information accumulation scenarios.
[0061] The experiment generated 1000 samples, and the maximum remainder method of this invention was used for demographic label allocation. The experimental results show that the actual number of samples generated for the three categories of age group were 270, 270, and 460, respectively; for gender, 500 and 500; for socioeconomic status, 300, 400, and 300; and for race, 300, 250, 200, 150, and 100. All categories accurately reached the target quota, with no distribution bias.
[0062] To verify the advantages of the method of this invention, a probabilistic random sampling method was used to repeat the experiment 100 times under the same configuration. The probabilistic random sampling method randomly selects samples according to the target proportion as the sampling probability for each category. Experimental results show that the average distribution bias of the probabilistic random sampling is 3.2%, the maximum single-category bias averages 15.6 samples, and the worst case reaches 28 samples. In 37 out of 100 experiments, some attribute combinations were completely not covered, and the average combination coverage rate was only 63.0%. This comparative experiment demonstrates that the maximum remainder method of this invention, by rounding down and supplementing with the remainder, ensures that the deviation of each category from the target quota within each dimension does not exceed one sample. After independent and precise allocation of each dimension, random combinations are achieved, resulting in 100% attribute combination coverage with a sample size of 1000. This effectively solves the problems of marginal distribution deviation and insufficient combination coverage caused by the randomness of probabilistic random sampling.
[0063] An expansion experiment was conducted on 500 structured scene seeds, employing the six-dimensional structured verification and closed-loop correction mechanism of this invention. Experimental results show that the overall pass rate for the first round of expansion was 72.6%, with the first-round pass rates for the six verification dimensions as follows: seed fidelity 88.4%, category purity 85.2%, no leakage 91.6%, openness maintenance 82.0%, authenticity 79.8%, and structural consistency 93.4%. After closed-loop correction, the overall pass rate increased to 91.8% in the second round and reached 97.2% in the third round, with the final pass rates for each dimension all exceeding 96%.
[0064] To verify the necessity of the verification mechanism, two sets of control experiments were set up: one set did not set up a verification step and was used directly after scenario expansion; the other set only performed fluency checks to detect grammatical errors and incoherent expressions. Through manual evaluation, the method without verification had a scenario deviation rate of 31.2% and a scenario usability rate of 68.8%, while the method with only fluency checks had a scenario deviation rate of 28.6% and a scenario usability rate of 71.4%. In contrast, the scenario deviation rate of the method of this invention was reduced to 2.8%, and the scenario usability rate reached 97.2%. This comparative experiment shows that checking fluency alone cannot identify deep-seated issues such as whether the scenario is faithful to the original setting. The six structured verification dimensions introduced in this invention specifically detect the specific types of deviations in scenario expansion, and the closed-loop correction mechanism injects the reasons for modification into the next round of expansion input, enabling the model to specifically correct problems and effectively improve scenario quality.
[0065] An age-matching assessment was conducted on 300 initial messages, 100 messages for each age group, and blind-reviewed by three educational psychology experts. Messages generated using the three-level hierarchical prompt word library of this invention (each with independent system prompt words for 7-9 years, 10-12 years, and 13-17 years) achieved matching accuracy rates of 88.0%, 91.0%, and 95.0% for the three age groups, respectively, with an overall matching accuracy of 91.3%. Matching accuracy means that the generated role messages conform to the cognitive development characteristics of the target age group in terms of vocabulary complexity, sentence length, emotional expression, and reasoning ability.
[0066] To verify the necessity of graded prompt words, a comparative experiment was conducted using a general prompt word method. This method only indicates the target age in the prompts without imposing graded language constraints. The experimental results showed that the matching rates for the three age groups using the general prompt word method were 42.0%, 61.0%, and 73.0%, respectively, with an overall matching rate of only 58.7%. Notably, the rate of childish adult-like expressions in the 7-9 age group was as high as 41.0%, indicating that 7-9 year old characters used complex sentence structures or abstract reasoning beyond their cognitive level. This comparative experiment demonstrates that simply labeling age values is insufficient to constrain the model to generate language complexity appropriate for that age group. This invention designs independent system prompt words for each of the three age groups, clearly defining the vocabulary range, sentence complexity, emotional expression methods, and reasoning ability boundaries corresponding to each age group, effectively improving the accuracy of age-related expressions.
[0067] Quality assessment was conducted on 200 multi-turn dialogues, including 3 rounds of direct expression scenarios and 8 rounds of progressive scenarios. Employing the strategy of continuously injecting the complete dialogue history sequence and scenario settings as system-level context, as per this invention, experimental results showed a role identity shift rate of 3.5%, an inconsistency rate of 2.0%, a repeated questioning rate of 1.5%, and an average multi-turn coherence score of 4.52 (out of 5). In the 8-round progressive scenarios, the role identity shift rate was 5.0%, and the coherence score was 4.31.
[0068] To verify the necessity of passing complete context, a control experiment was conducted, in which only the most recent two rounds of dialogue history were passed in, excluding scene settings. The results showed that this control method had a role identity drift rate of 22.0%, a contradiction rate of 16.0%, and a repeated question rate of 13.0%, with a drift rate as high as 38.0% in an 8-round progressive scene. This comparative experiment demonstrates that retaining only partial history causes the model to lose early dialogue information after the third round, failing to maintain consistency in role background. This invention combines the complete dialogue history sequence with system-level context anchoring of scene settings, allowing the model to reference the complete interaction history while remaining continuously constrained by the scene background during each round of generation, effectively ensuring the coherence of multi-round dialogues.
[0069] The experimental results above show that the present invention, through a phased pipeline architecture, combines the synergistic effect of five core modules automatically executed by the processor: demographic tag generation, synthesis task and scene seed generation, scene expansion and verification, first-round role message generation, and multi-round dialogue generation. It significantly outperforms existing methods in terms of demographic distribution accuracy, scene quality, age expression matching degree, and multi-round coherence, and achieves automated synthesis of high-quality educational scene dialogue data.
[0070] The above description of the embodiments is provided to enable those skilled in the art to understand and apply the present invention. Those skilled in the art can readily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without creative effort. Therefore, the present invention is not limited to the above embodiments, and any improvements and modifications made to the present invention by those skilled in the art based on the disclosure thereof should be within the scope of protection of the present invention.
Claims
1. A method for automatically synthesizing dialogue data in educational scenarios based on role-playing, characterized in that, Includes the following steps performed by a computer: 1) Based on the target proportion and total number of samples for each demographic dimension, the integer quota is determined using the maximum remainder method. The pseudo-random number generator independently shuffles the label arrays for each dimension and combines them according to their corresponding positions to generate multidimensional demographic labels. 2) The multidimensional demographic labels are combined with scene classification data objects and interaction motivation data objects and enumerated into a synthesis task. The large language model is then scheduled through a concurrent window to generate structured scene seeds. 3) The structured scene seed is expanded into a complete scene setting by the scene expansion model, and the structure is verified by independent verification model; If a test fails, structured feedback is injected and the test is iteratively corrected. 4) Obtain the character age group attribute value determined by the multidimensional demographic label from the structured scene seed, retrieve system prompt words from the hierarchical prompt word library with the character age group attribute value, generate the first round of character messages based on the complete scene setting, and perform placeholder detection and condition regeneration; 5) Write the complete scene settings into the system-level context and the first round of role messages into the dialogue history sequence. The multi-round dialogue engine alternately calls the role simulation model and the dialogue object model. After reaching the target number of rounds, the structured multi-round dialogue data is output.
2. The method according to claim 1, characterized in that, In step 1), the maximum remainder method specifically includes: multiplying the target proportion of each category by the total number of samples to obtain the precise quota, rounding down to obtain the basic allocation quantity, calculating the difference between the precise quota and the basic allocation quantity as the remainder, and filling the remaining quotas into the corresponding categories one by one according to the remainder from largest to smallest. When the remainders are equal, they are allocated according to the category order, so that the deviation between the integer quota and the precise quota of each category does not exceed 1 sample; generating a label array for each dimension according to the integer quota, which is independently shuffled by the pseudo-random number generator, and the elements in the same position are used to form the multidimensional demographic labels of each sample.
3. The method according to claim 1 or 2, characterized in that, In step 2), the structured scene seed is a data object containing the following predefined fields: a demographic attribute field, containing the attribute values of each dimension in the multidimensional demographic label; a scene category field, whose value is selected from the sub-category enumeration set of the scene classification data object; a core behavior field, used to describe the intention or goal that the character intends to express in the scene, whose value is generated by the large language model based on the interaction motivation data object; a role characteristic field, containing two sub-fields: cognitive maturity and emotional maturity, the values of each sub-field being selected from the predefined level enumeration; an interaction context information field, whose value is selected from the predefined social dynamic pattern enumeration set; and a risk signal type field, whose value is selected from the predefined risk element significance enumeration set.
4. The method according to claim 3, characterized in that, In step 2), the interaction motivation data object contains a variety of predefined motivation type identifiers. Each motivation type identifier corresponds to a behavior-driven category for a character to initiate a dialogue, and participates in the construction of the synthetic task list as one of the dimensions of the combined enumeration.
5. The method according to claim 4, characterized in that, In step 3), the scene expansion model takes the structured scene seed as input to generate a complete scene setting that includes character narrative and background description. After the scene expansion model completes its output, the independent verification model is called. Taking the structured scene seed and the complete scene setting as input, the model performs structured verification on six verification dimensions: seed fidelity, category purity, no leakage, openness maintenance, authenticity, and structural consistency. The model outputs the binary judgment result for each verification dimension and generates the structured feedback containing the failure dimension identifier, modification reason, and improvement suggestion when there is a verification dimension that fails. The modification reasons in the structured feedback are combined with the previous complete scene settings and used as the input for the next round of expansion of the scene expansion model until all verification dimensions pass or the number of retries reaches the preset limit.
6. The method according to claim 5, characterized in that, In step 4), the graded prompt word library uses the character's age group attribute value as the search key to store three sets of system prompt word data: the first set corresponds to 7-9 years old, the second set corresponds to 10-12 years old, and the third set corresponds to 13-17 years old. When the system prompts data for each group are called into the model, the lexical complexity, sentence length, emotional expression, and reasoning depth of the output text are constrained to ensure that the linguistic complexity of the first round of character messages matches the target age group.
7. The method according to claim 1, 2, 4, 5, or 6, characterized in that, In step 5), the role simulation model takes the system-level context and the dialogue history sequence as input, generates a role message representing the target role's current speech, and appends the role message to the dialogue history sequence; the dialogue object model takes the system-level context and the dialogue history sequence as input, generates a dialogue object message for the role message, and appends the dialogue object message to the dialogue history sequence; the multi-turn dialogue engine maintains the data structure of the dialogue history sequence, schedules the role simulation model and the dialogue object model in a preset alternating order, continuously injects the system-level context during each call to achieve scene setting anchoring, and terminates the call and serializes and outputs the structured multi-turn dialogue data when the number of turns in the dialogue history sequence reaches the target number of turns pre-configured according to the scene category.
8. A device for automatically synthesizing dialogue data in educational scenarios based on role-playing, characterized in that, include: Demographic label generation module: It is used to determine the integer quota according to the target proportion and total number of samples of each demographic dimension, and the pseudo-random number generator independently shuffles the label array of each dimension and combines them according to the corresponding positions to generate multidimensional demographic labels. Synthesis Task and Scene Seed Generation Module: This module is used to enumerate the multidimensional demographic labels, scene classification data objects, and interaction motivation data objects into synthesis tasks, and generate structured scene seeds by scheduling a large language model through a concurrent window. Scene Expansion and Verification Module: This module is used to expand the structured scene seed into a complete scene setting using the scene expansion model, perform structured verification through an independent verification model, and inject structured feedback for iterative correction if the verification fails. First-round character message generation module: used to obtain the character age group attribute value determined by the multi-dimensional demographic label from the structured scene seed, retrieve system prompt words from the hierarchical prompt word library with the character age group attribute value, generate the first-round character message based on the complete scene setting and perform placeholder detection and condition regeneration; Multi-turn dialogue generation module: It is used to write the complete scene settings into the system-level context and write the first round of role messages into the dialogue history sequence. The multi-turn dialogue engine alternately calls the role simulation model and the dialogue object model, and outputs structured multi-turn dialogue data after reaching the target number of rounds.