Method and system for generating and interactive narration of education scene based on multi-agent cooperation
Patent Information
- Application Number
- CN202610731151.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-26
- Publication Date
- 2026-08-18
AI Technical Summary
[0004]本发明的目的在于提供基于多智能体协同的教育场景生成与互动叙事方法及系统,以解决现有技术中存在原理呈现与互动过程相互割裂、系统反馈缺乏精细的电信号动态调制能力、协同控制架构扁平化难以实现层级化逻辑整合,并最终导致学习者出现认知协同断层而无法形成对复杂系统整体理解的根本性问题,具体技术方案如下:
[0014] The beneficial effects of this invention are as follows: This invention transforms the abstract gradient calculation, optimization, and game-playing processes in adversarial machine learning into concrete behaviors and signal interactions between multiple agents, such as attackers and defenders, that follow mathematical principles. It also constructs a dynamic modulation channel controlled by hierarchical narrative goals, enabling the autonomous generation of self-consistent and goal-oriented interactive attack and defense narrative sequences. Simultaneously, the system provides multi-view real-time visualization of the agent's internal state, game signals, and overall evolution, and offers a real-time parameter intervention interface, thereby creating a dynamic, visual, and interactive immersive teaching environment. This effectively solves the problem of highly abstract concepts, invisible processes, and difficulty in understanding in traditional teaching, allowing learners to intuitively understand the complete mechanism of attack generation, defense effectiveness, and dynamic game between the two.
Smart Images

Figure CN122595810A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of educational technology, and in particular to a method and system for generating educational scenarios and interactive narratives based on multi-agent collaboration. Background Technology
[0002] In today's era of rapid development in educational technology, the integration of multi-agent systems and interactive narrative technology has become a core direction for creating immersive and personalized learning environments. Compared to traditional predefined script-based educational scenarios, this approach better aligns with learners' cognitive patterns and facilitates deeper knowledge construction. However, existing technological systems suffer from numerous structural flaws in the underlying design of this integration, resulting in insufficient realism in educational scenarios and weak teaching relevance, severely limiting the application value of this technology in large-scale educational practice. In educational practice scenarios, the shortcomings of existing technological solutions manifest in several dimensions. Firstly, there is a severe disconnect between the presentation of principles and the interactive process. For example, when teaching physics circuits and chemical reactions, although the system can display animations of principles and allow simulated operations, there is a lack of real-time, interpretable dynamic coupling between the agent's behavior, the narrative progression, and the underlying scientific principles. Learners can only see the surface operational results and cannot intuitively perceive how microscopic mechanisms emerge into macroscopic phenomena through agent interaction, causing learning to remain at the level of surface memorization and failing to achieve conceptual understanding. Secondly, the dynamic modulation capability of interactive narratives is insufficient. In real educational interactions, every step of exploration, question, and even mistake made by learners should precisely disturb the collaborative network of intelligent agents, like neural electrical signals, triggering chain reactions and dynamic adjustments. However, the feedback of most current systems exhibits modular and discontinuous characteristics, with coarse information transmission between agents and abrupt narrative logic transitions. This fails to simulate continuous and refined control processes, making it difficult to maintain learners' flow state or adapt to changes in their cognitive load. Thirdly, multi-agent collaborative control lacks a reasonable hierarchical architecture. When simulating complex educational scenarios such as historical events and ecosystems, it is necessary to consider the macro-narrative direction, meso-level group patterns, and micro-level individual decisions. However, existing technologies either excessively centralize control, resulting in a loss of agent autonomy, or allow individual decisions to deviate from the teaching objectives, making it difficult to achieve natural coordination of multi-level logic. More subtly and critically, the aforementioned deficiencies collectively lead to the core pain point of cognitive synergy discontinuity. Even if the system separately achieves principle visualization, dynamic interaction of intelligent agents, and multi-layered control, these three elements are mostly pieced together reluctantly and fail to be integrated into a coherent organic whole. This results in a fragmented knowledge model built by learners. Even if they remember the principles, experience the interaction, and understand the control levels, they cannot form a holistic mental model of the operation of complex systems. It is difficult to cultivate higher-order cognitive literacy such as systematic thinking and cross-level analysis ability. This has become the core bottleneck restricting the upgrading of technology in this field to high-level educational products.
[0003] In view of this, there is an urgent need for educational scenario generation and interactive narrative methods and systems based on multi-agent collaboration, in order to at least address the above-mentioned shortcomings. Summary of the Invention
[0004] The purpose of this invention is to provide a method and system for generating educational scenarios and interactive narratives based on multi-agent collaboration, in order to solve the fundamental problems in existing technologies, such as the disconnect between the presentation of principles and the interactive process, the lack of fine-grained dynamic modulation capabilities of electrical signals in system feedback, and the difficulty in achieving hierarchical logical integration due to the flattened collaborative control architecture. Ultimately, these problems lead to cognitive collaboration gaps in learners, preventing them from forming a holistic understanding of complex systems. The specific technical solution is as follows: This invention provides a method for generating educational scenarios and interactive narratives based on multi-agent collaboration, including: S10: Construct an adversarial attack and defense simulation environment for model security education, specifically defining attacker intelligent agent swarm, defender model intelligent agent swarm, data sample intelligent agent and evaluation environment intelligent agent, and initializing their network topology and connection relationships. S20 encodes the mathematical principles of adversarial example generation and model defense into local behavior rules and state update functions for multi-agent systems; S30 constructs a bidirectional perturbation gradient signal flow and a dynamic modulation channel on top of the agent network, defining the signal type, propagation rules, and modulated signal parameters; S40 deploys a three-layer narrative control logic, translating high-level teaching intentions into temporal modulation instructions and scene constraints for signal parameters, driving narrative evolution; S50 initiates multi-agent collaborative simulation, autonomously calculating and generating a complete adversarial attack and defense interactive narrative sequence based on local behavior rules, bidirectional perturbation gradient signal flow and temporal modulation instructions. S60 provides real-time visualization and rendering of the internal states, interaction signals, and overall system evolution of multiple agents from multiple perspectives, and offers parameter intervention interfaces for learners to interact and explore.
[0005] Furthermore, S10 includes: S101 defines an attacker agent group, which includes an adversarial perturbation generator agent whose internal state is a perturbation tensor of the same dimension as the original sample, with an initial value of an all-zero tensor. S102 defines the defender model agent swarm, which is a miniature cluster of convolutional neural network agents, including convolutional layer agents and fully connected layer agents, used to classify data.
[0006] Furthermore, S20 includes: S201 encodes the principle rules of gradient attack for the attacker agent swarm. Each round, the attacker agent obtains the predicted loss value of the sum of the current input and the current perturbation from the defender network through the forward propagation path, and obtains the sign of the gradient of the loss with respect to the input through the back propagation path, and updates the internal perturbation state according to the projection gradient descent algorithm. S202 defines the principles and rules for training and adversarial training of the defender model intelligent swarm. The defender model intelligent swarm updates its parameters according to the standard training or adversarial training mode. In the standard training mode, the loss is calculated based on clean samples and the parameters are updated by backpropagation. In the adversarial training mode, the loss is calculated based on adversarial samples and the parameters are updated by backpropagation.
[0007] Furthermore, S30 includes: S301 defines the activation transfer signal for forward propagation and the gradient transfer signal for backward propagation, wherein the gradient transfer signal includes an attack gradient signal for generating perturbations and a defense gradient signal for updating model weights. S302, Establish a dynamic modulation channel, the signal parameters of which include the attacker agent's attack step size, perturbation limit, the defender agent's learning rate, and a signal selection switch for controlling the training data source. S303 sets the signal gain factor, which is used to balance the contributions of clean sample loss and adversarial sample loss in adversarial training. The total loss signal is the sum of the clean sample loss, the signal gain factor, and the adversarial sample loss.
[0008] Furthermore, S40 includes: S401, the top-level narrative goal controller defines the macro-level teaching theme; S402, the mid-level scene coordinator has built-in narrative script logic, which receives macro-level teaching topics and translates them into preset sequences and conditional response rules for signal parameters; S403, the underlying autonomous intelligent swarm operates strictly in accordance with local behavior rules, and its behavior is affected by its own state and the real-time parameter values received from the dynamic modulation channel.
[0009] Furthermore, the S50 includes: S501, start the co-simulation cycle. Each training cycle contains data sample agent forward passing data. The attacker agent performs iterations under signal parameter modulation to generate perturbations. The defender model agent forward calculates the loss of the sample after the perturbation. S502, during the back propagation phase, routes the gradient signal flow direction based on the value of the signal selection switch; S503, after each narrative phase, evaluates the intervention of the environmental agent, calculates and records the classification accuracy of the current defender model on the clean test set and the adversarial example test set.
[0010] Furthermore, the S60 includes: S601, the first view renders the feature space changes of the defender model agent group, and generates a dynamic scatter plot by the activation output of the last hidden layer agent through a dimensionality reduction algorithm, and marks the true class of the sample with color. S602, the second view is superimposed on the input sample in the form of a heat map, which visualizes the spatial distribution and intensity of the disturbances generated by the attacker's intelligent agent in real time. S603, the third view shows a hyperbola graph, one curve shows the change in clean test accuracy with the narrative stage, and the other curve shows the change in adversarial test accuracy.
[0011] Furthermore, the macro-level teaching theme is to demonstrate the difference between single-step attacks and iterative attacks. S402 also includes: using iterative attack intensity modulation narrative, and the mid-level scene coordinator generating instruction sequences: in the single-step attack demonstration phase, the attacker's single-step attack step size is set to be equal to the perturbation upper limit, and its iteration count is limited to one; in the iterative attack demonstration phase, the attacker's single-step attack step size is set to a value less than the perturbation upper limit, and the maximum number of iterations is set. The macro-level teaching theme is to demonstrate the role of the balance factor in adversarial training. S402 also includes: using a defensive signal balance modulation narrative, the mid-level scene coordinator generates an instruction sequence: the training phase is executed sequentially, each phase sets a different signal gain factor value, and after each phase, the clean accuracy and adversarial accuracy of the model after training under different signal gain factor values are evaluated. The macro-level teaching theme is to explore the attack strategies of attackers at different knowledge levels. S402 also includes: using attacker knowledge state to modulate the narrative. The mid-level scene coordinator arranges the narrative sequence by modulating the knowledge state parameters of the attacker agent. The knowledge state parameters are used to characterize the attacker's mastery of the defender's model information and control the attacker agent to adjust its gradient information source for calculating gradient symbols.
[0012] This invention also provides a system for generating and interacting with educational scenarios based on multi-agent collaboration, used to implement the method for generating and interacting with educational scenarios based on multi-agent collaboration. The system includes: The environment construction and multi-agent initialization module is used to build an adversarial attack and defense simulation environment for model security education. Specifically, it defines the attacker agent group, the defender model agent group, the data sample agent, and the evaluation environment agent, and initializes their network topology and connection relationships. A behavior rule and state update engine is used to encode the mathematical principles of adversarial example generation and model defense into local behavior rules and state update functions for multi-agent systems. The signal flow and dynamic modulation channel construction module is used to build bidirectional perturbation gradient signal flow and dynamic modulation channel on top of the agent network, and to define the signal type, propagation rules and modulated signal parameters. The narrative control logic deployment and translation module is used to deploy a three-layer narrative control logic, translating high-level teaching intentions into temporal modulation instructions and scene constraints for signal parameters to drive narrative evolution; The multi-agent collaborative simulation engine is used to initiate the multi-agent collaborative simulation loop. Based on local behavior rules, bidirectional perturbation gradient signal flow and timing modulation instructions, it automatically calculates and generates a complete adversarial attack and defense interactive narrative sequence. The visualization rendering and interaction interface module is used to perform real-time visualization rendering of the internal states, interaction signals and overall system evolution of multiple agents from multiple views, and provides a parameter intervention interface for learners to interact and explore.
[0013] An electronic device includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, implements the method.
[0014] The beneficial effects of this invention are as follows: This invention transforms the abstract gradient calculation, optimization, and game-playing processes in adversarial machine learning into concrete behaviors and signal interactions between multiple agents, such as attackers and defenders, that follow mathematical principles. It also constructs a dynamic modulation channel controlled by hierarchical narrative goals, enabling the autonomous generation of self-consistent and goal-oriented interactive attack and defense narrative sequences. Simultaneously, the system provides multi-view real-time visualization of the agent's internal state, game signals, and overall evolution, and offers a real-time parameter intervention interface, thereby creating a dynamic, visual, and interactive immersive teaching environment. This effectively solves the problem of highly abstract concepts, invisible processes, and difficulty in understanding in traditional teaching, allowing learners to intuitively understand the complete mechanism of attack generation, defense effectiveness, and dynamic game between the two.
[0015] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0016] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a schematic diagram of the educational scene generation and interactive narrative method based on multi-agent collaboration in an embodiment of the present invention; Figure 2 This is a schematic diagram of an educational scene generation and interactive narrative system based on multi-agent collaboration in an embodiment of the present invention. Detailed Implementation
[0017] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0018] This embodiment provides a method for generating educational scenarios and interactive narratives based on multi-agent collaboration, such as... Figure 1 As shown, it includes: S10: Construct an adversarial attack and defense simulation environment for model security education, specifically defining attacker intelligent agent swarm, defender model intelligent agent swarm, data sample intelligent agent and evaluation environment intelligent agent, and initializing their network topology and connection relationships. S20 encodes the mathematical principles of adversarial example generation and model defense into local behavior rules and state update functions for multi-agent systems; S30 constructs a bidirectional perturbation gradient signal flow and a dynamic modulation channel on top of the agent network, defining the signal type, propagation rules, and modulated signal parameters; S40 deploys a three-layer narrative control logic, translating high-level teaching intentions into temporal modulation instructions and scene constraints for signal parameters, driving narrative evolution; S50 initiates multi-agent collaborative simulation, autonomously calculating and generating a complete adversarial attack and defense interactive narrative sequence based on principle rules, dynamic signals and hierarchical control instructions. S60 provides real-time visualization and rendering of the internal states, interaction signals, and overall system evolution of multiple agents from multiple perspectives, and offers parameter intervention interfaces for learners to interact and explore.
[0019] The principle and effect of the above technical solution are as follows: It provides a method for generating educational scenarios and interactive narratives based on multi-agent collaboration. By transforming the abstract gradient calculation, optimization process and game strategy in adversarial machine learning into concrete behaviors and signal interactions of multiple agents, and controlled by hierarchical narrative goals, it creates an immersive teaching environment that is self-consistent in principle, dynamically visible and goal-oriented. This allows learners to intuitively understand how attacks are generated, how defenses take effect and the complete process of dynamic game between the two, solving the problems of highly abstract teaching and invisible processes.
[0020] In one embodiment, S10 includes: S101 defines an attacker agent group, which includes an adversarial perturbation generator agent whose internal state is a perturbation tensor delta_a of the same dimension as the original sample, with an initial value of an all-zero tensor. S102 defines the defender model agent swarm, which is a miniature convolutional neural network agent cluster, including two convolutional layer agents and two fully connected layer agents. The state of the convolutional layer agents includes the weight tensor W_conv, the bias b_conv, and the feature map output F. The state of the fully connected layer agents includes the weight matrix W_fc, the bias vector b_fc, and the activation output a_fc. This network is used to classify ten categories of handwritten digits from the MNIST dataset.
[0021] The principle and effect of the above technical solution are as follows: by instantiating two types of intelligent agents, attackers and defenders, a basic framework for game-theoretic confrontation is constructed, laying a physical foundation for subsequent coding of complex attack and defense principles.
[0022] In one embodiment, S20 includes: S201 encodes the principle rules based on gradient attacks. Specifically, each round, the attacker agent obtains the predicted loss value L_adv from the defender network for the sum of the current input x and the current perturbation delta_a from the forward propagation path, and obtains the gradient sign sign(grad_x_L) of the loss L_adv with respect to the input x from the back propagation path. Then, it updates its internal perturbation state according to the projective gradient descent algorithm, with the rule: delta_a_new = Clip_epsilon(delta_a_old + alpha_pgd). *sign(grad_x_L)), where delta_a_new represents the updated perturbation tensor, delta_a_old represents the original perturbation tensor, alpha_pgd represents the single-step attack step size, set to 0.001, epsilon represents the upper limit of the total perturbation, set to 0.03, Clip_epsilon represents the clipping function that projects the infinite norm of the perturbation tensor onto the interval from negative epsilon to positive epsilon, sign is the sign function, and grad_x_L represents the gradient of the loss L_adv with respect to the input x; S202, the principle rules for encoding model training and adversarial training, are as follows: The defender network intelligent agent swarm updates its parameters according to the standard training or adversarial training mode. In the standard training mode, it calculates the loss L_clean based on the clean sample x and backpropagates to update the parameters; in the adversarial training mode, it calculates the loss L_adv based on the sum of the adversarial sample x and the perturbation delta_a and backpropagates to update the parameters. The parameter update adopts the stochastic gradient descent algorithm. The basic learning rate eta_d is set to 0.01 and the momentum coefficient beta_d is set to 0.9.
[0023] The principle and effect of the above technical solution are as follows: the mathematical steps of core algorithms such as PGD attack, standard training, and adversarial training are visualized as autonomous behavior rules for attacker and defender agents, so that the abstract optimization process is transformed into an action sequence that the agent can execute, laying the algorithmic foundation for dynamic interaction.
[0024] In one embodiment, S30 includes: S301 defines the activation transfer signal from forward propagation and the gradient transfer signal from backward propagation, wherein the gradient transfer signal is further distinguished into an attack gradient signal used to generate perturbations and a defense gradient signal used to update model weights. S302, establish a dynamic modulation channel, whose key modulation parameters include the attacker agent's attack step size alpha_pgd, the perturbation upper limit epsilon, the defender agent's learning rate eta_d, and a signal selection switch K_switch for controlling the training data source. When K_switch is equal to zero, the defender receives gradient signals from clean samples, and when K_switch is equal to one, the defender receives gradient signals from adversarial samples. S303 sets the signal gain factor lambda_balance to balance the contributions of clean sample loss and adversarial sample loss during adversarial training. The total loss signal is L_total = L_clean + lambda_balance * L_adv, where the default value of lambda_balance is 1.0.
[0025] Specifically, bidirectional perturbation gradient signal flow refers to the signal flow that propagates in two directions. One is the forward activation propagation direction, which is the activation signal path that the data sample is transmitted from the input layer to the output layer; the other is the reverse gradient propagation direction, which is the gradient signal path that the loss is transmitted from the output layer to the input layer. The two paths form a complete bidirectional signal closed loop. Dynamic modulation channel: refers to a logical control channel built on the TCP / IP communication protocol. It can be implemented through shared memory, message queue or RESTful API interface. It is used to send control commands from the upper layer to the corresponding intelligent agent in real time, and at the same time send the status data of the intelligent agent back to the upper layer controller, so as to realize fine-grained and time-sequential control of the simulation process. Signal gain factor lambda_balance: This is a dimensionless coefficient used to linearly adjust the weight of adversarial example loss in the total loss calculation. Its value ranges from 0.1 to 10.0, and the adjustment granularity is 0.1. The larger the value, the higher the weight of adversarial example loss in model optimization, and the stronger the robustness of the model, but it may lead to a decrease in clean sample accuracy.
[0026] The value range and quantization impact of key parameters in this step: Attack step size alpha_pgd: value range is 0.0001~0.1, adjustment granularity is 0.0001; the larger the step size, the larger the single-step perturbation update amplitude, the faster the attack convergence speed, but it is easy to exceed the perturbation upper limit and cause the attack to fail. Perturbation upper limit epsilon: The value ranges from 0.001 to 1.0, and the adjustment granularity is 0.001. The larger the upper limit, the larger the perturbation amplitude that can be added, and the higher the success rate of the attack, but the higher the visual recognizability of the adversarial example and the worse its concealment. Learning rate eta_d: The value ranges from 0.0001 to 0.1, and the adjustment granularity is 0.0001. The larger the learning rate, the greater the magnitude of model parameter updates and the faster the convergence speed, but it is prone to oscillation and non-convergence. Signal selection switch K_switch: Values are 0, 1, and 2. 0 corresponds to clean sample only mode, where the defender updates parameters only based on clean samples; 1 corresponds to adversarial sample only mode, where the defender updates parameters only based on adversarial samples; 2 corresponds to hybrid mode, where the defender updates parameters based on both clean and adversarial samples, with the weights of the two adjusted by the signal gain factor.
[0027] The principle and effect of the above technical solution are as follows: by defining two types of gradient signals and establishing a multi-dimensional modulation channel including attack strength, learning mode, and balance factor, the key hyperparameters in the attack and defense game are transformed into a signal control knob that can be adjusted in real time, providing an interface for the narrative control layer to finely guide the dynamic process.
[0028] In one embodiment, S40 includes: S401, the top-level narrative target controller defines the macro-level teaching theme, which specifically includes demonstrating the vulnerability of undefended models under white-box attacks, comparing the robustness differences between standard training and adversarial training models, and exploring the impact of different attack intensities on the defense effect. S402, the mid-level scene coordinator has built-in narrative script logic. After receiving the top-level target, it translates it into a preset sequence and conditional response rules for the dynamic modulation parameters described in S30. For example, to achieve the comparison target, the coordinator generates an instruction sequence: First stage, set K_switch equal to 0, eta_d equal to 0.01, and train the defender model for fifty epochs until convergence; Second stage, set K_switch equal to 1, lambda_balance equal to 1.0, keep eta_d equal to 0.01, and continue training for fifty epochs; Third stage, freeze the defender parameters, and sequentially set the attacker parameters alpha_pgd to 0.001, 0.01, and epsilon to 0.03 to demonstrate the difference in attack effects. S403, the underlying autonomous intelligent agent swarm strictly follows the principles and rules of S20 encoding. Its behavior is only affected by its own state and the real-time parameters alpha_pgd, epsilon, eta_d, K_switch, and lambda_balance received from the modulation channel. The middle coordinator does not directly write the internal state of any agent.
[0029] In one embodiment, S50 includes: S501, start the co-simulation cycle. Each training cycle includes: the data sample agent forwards pixel data, the attacker agent performs up to ten iterations under signal modulation parameters to generate perturbation delta_a, and the defender agent forward calculates the loss of the perturbation sample. S502, during the backpropagation phase, the gradient signal flow is routed according to the value of the signal selection switch K_switch. If K_switch equals 0, the defense gradient signal is generated based on the clean sample loss L_clean and transmitted back to update the defender parameters; if K_switch equals 1, the defense gradient signal is generated based on the adversarial sample loss L_adv and transmitted back. S503, after each narrative phase, evaluates the intervention of the environmental agent, calculates and records the classification accuracy of the current defender model on a clean test set and a test set based on adversarial examples generated by the current attacker, as a key indicator of narrative evolution.
[0030] In one embodiment, S60 includes: S601, the first view renders the feature space changes of the defender network agent, and the activation output of the last hidden layer agent is reduced to a two-dimensional dynamic scatter plot through the t-distribution random neighborhood embedding algorithm, and the true class of the sample is marked with different colors. S602, the second view is superimposed on the input sample in the form of a heat map to visualize the spatial distribution and intensity of the perturbation delta_a generated by the attacker's agent in real time. S603, the third view shows a hyperbola graph. One curve shows the change in clean test accuracy with the narrative stage, and the other curve shows the change in adversarial test accuracy. The gap between the two curves intuitively represents the robustness gap of the model.
[0031] In one specific embodiment, in S40, if the goal of the top-level narrative is to demonstrate the efficiency and effectiveness difference between single-step attacks and iterative attacks, then the narrative is modulated using iterative attack intensity, and the specific steps are as follows: SA41: The mid-level scene coordinator initializes the defender as a pre-trained simple model, and sets the attacker perturbation upper limit epsilon to 0.03.
[0032] SA42: Entering the single-step attack demonstration phase, the coordinator sets the attacker's single-step attack step size alpha_pgd to epsilon, which is 0.03, and limits its iteration count to 1, and runs the attack and evaluation process.
[0033] SA43: Entering the iterative attack demonstration phase, the coordinator sets the attacker's single-step attack step size alpha_pgd to 0.001, the maximum number of iterations to ten, and runs the attack and evaluation process.
[0034] SA44: The coordinator compares and records the differences in visual recognizability of adversarial examples generated in the two stages and their attack success rates.
[0035] The technical solution vividly demonstrates the principle that iterative attacks can achieve a higher success rate by dynamically modulating the attacker's iteration steps and number of iterations, with smaller single-step perturbations, thus enabling learners to deeply understand the continuity of attack strategies.
[0036] In S40, if the top-level narrative objective is to demonstrate the role of the balance factor lambda_balance in adversarial training, then a defensive signal balance modulation narrative is adopted, and the specific steps are as follows: SB41: The mid-level scene coordinator initializes an unadversarially trained model and sets the adversarial training mode K_switch to one.
[0037] SB42: Execute three training phases in sequence, with each phase consisting of twenty cycles: in the first phase, the balance factor lambda_balance is set to 0.5; in the second phase, lambda_balance is set to 1.0; and in the third phase, lambda_balance is set to 2.0.
[0038] SB43: At the end of each phase, the coordinator calls the evaluation environment agent to evaluate the clean accuracy and adversarial accuracy of the model trained with the current lambda_balance value.
[0039] The proposed technical solution reveals the trade-off between robustness and standard accuracy in adversarial training by precisely controlling the loss balance factor, enabling learners to intuitively observe how different lambda_balance values affect the model's performance in two dimensions.
[0040] In S40, if the top-level narrative objective is to explore the attacker's attack strategies at different knowledge levels, then the attacker's knowledge state modulated narrative is adopted, and the specific steps are as follows: SC41: Define the knowledge state parameter theta_k of the attacker agent. theta_k equal to 0 indicates a black-box attack, in which the attacker uses the gradient sign of the substitute model; theta_k greater than 0 and less than 1 indicates a gray-box attack, in which the attacker obtains partial model information; theta_k equal to 1 indicates a white-box attack, in which the attacker obtains the complete gradient of the real model.
[0041] SC42: The mid-level scene coordinator arranges the narrative sequence: First, it sets theta_k to 1 to show the high success rate of white-box attacks; second, it sets theta_k to 0.3 to show the decreasing success rate of attacks; finally, it sets theta_k to 0, so that attackers can only perform gradient-free query attacks based on input-output relationships.
[0042] SC43: In each knowledge state, the attacker agent adjusts its gradient information source for calculating sign(grad_x_L) based on the value of theta_k and executes the attack.
[0043] The proposed technical solution simulates different attack scenarios, from white-box, gray-box to black-box, by modulating the attacker's knowledge state parameters. It systematically presents a panoramic view of the model's security threats and deepens learners' understanding of the feasibility of attacks.
[0044] In one specific embodiment, in S50, if the current narrative stage is adversarial training, then an adversarial training collaborative process is adopted, and the specific steps are as follows: SA51: At the start of each training cycle, the signal selection switch K_switch is set to one, and the data sample agent passes the original sample x to the attacker agent.
[0045] SA52: The attacker agent uses the current defender model as a white box and runs the rules described in S201 for up to ten iterations to generate adversarial samples x_adv, where x_adv is equal to the sum of x and delta_a.
[0046] SA53: The defender model agent receives x_adv and performs forward propagation, calculates the adversarial loss L_adv, and calculates the total loss according to the formula L_total, which is equal to the sum of the products of L_clean, lambda_balance, and L_adv, where L_clean is provided by the clean forward results of the same batch of samples.
[0047] SA54: The defender model agent performs backpropagation based on the defense gradient signal generated by L_total, and updates all its weights and bias parameters according to the S202 rule.
[0048] The process realizes the essence of adversarial training, which means that the model is optimized under the guidance of the gradient signal of adversarial examples, thereby improving its robustness. The whole process is completed autonomously and collaboratively by the agent according to the rules and modulation parameters.
[0049] In S50, if the current operating mode is black-box attack assessment, a query-based attack collaboration process is adopted, with the following specific steps: SB51: The attacker agent's knowledge state parameter theta_k is set to 0, preventing it from accessing the defender model's internal gradients.
[0050] SB52: The attacker agent builds a local swarm of alternative model agents and trains the alternative model by sending a large number of query requests to the defender model agent, i.e., inputting samples and obtaining the predicted probability distribution.
[0051] SB53: The attacker agent generates adversarial perturbation delta_a in a white-box manner based on the trained alternative model agent, and then adds delta_a to the original sample to form adversarial sample, which is then submitted to the defender model for attack testing.
[0052] The process simulates a real black-box attack scenario, in which the attacker agent launches an attack through active querying and local modeling strategies, demonstrating game-theoretic intelligence under information-limited conditions.
[0053] In one specific embodiment, in S60, if the learner needs to observe the adversarial vulnerability of samples of a specific category, a category-focused visualization mode is used, and the specific steps are as follows: SA61: Learners select a target category in the interactive interface, such as the number seven.
[0054] SA62: The system immediately highlights all sample points classified as seven or with a true label of seven in the feature space scatter plot in the first view.
[0055] SA63: In the second view, the system filters and displays adversarial perturbation heatmaps of seven types of target samples that have been successfully attacked, revealing pixel areas that are frequently modified when attacking these types of numbers.
[0056] SA64: Below the accuracy curve in the third view, a table is dynamically updated to display fine-grained statistics such as attack success rate and average perturbation size for seven types of samples.
[0057] The interactive visualization mode enables learners to go beyond macro-statistics and delve into the specific behaviors and vulnerability patterns of the model across different semantic categories, enhancing the depth of analysis and the relevance of teaching.
[0058] In S60, if learners wish to intervene in attack and defense in real time, a dynamic parameter exploration interaction mode is used, with the following specific steps: SB61: The system provides multiple real-time slider controls in the sidebar of the visualization interface, corresponding to the attack step size alpha_pgd, the perturbation limit epsilon, the balance factor lambda_balance, and the signal selection switch K_switch.
[0059] SB62: During the simulation, learners can dynamically drag the slider to modify any parameter. For example, during the attack demonstration, epsilon can be suddenly increased from 0.03 to 1.0.
[0060] SB63: Modification instructions are immediately sent through the dynamic modulation channel, and the relevant agent runs with the new parameters in the next computation cycle. The attacker agent generates a larger perturbation based on the new epsilon, and the defender's accuracy may drop instantly; or the learner resets K_switch from all to zero, and the defender immediately switches back to the standard training mode, thus changing its accuracy trajectory.
[0061] The interactive mode empowers learners with the ability to direct experiments, transforming passive observation into active exploration by modulating signal parameters in real time and immediately observing the system's emerging results, thus greatly deepening their understanding of parameter influence and attack-defense dynamics.
[0062] It should be noted that while this embodiment of the invention uses an adversarial attack and defense scenario in machine learning model security education as an example, the core technical framework provided by this invention—encoding abstract principles into agent-local rules, constructing bidirectional modulated signal streams, and deploying hierarchical narrative control—can be widely applied to other fields that require the visualization and interactive teaching and demonstration of complex system principles. For different application fields, those skilled in the art can define agent types, their local behavior rules (corresponding to S20), signal stream types (corresponding to S30), and narrative goals (corresponding to S40) according to the core principles of that field.
[0063] Accordingly, such as Figure 2 As shown, based on a multi-agent collaborative educational scene generation and interactive narrative method, this embodiment of the invention also provides a multi-agent collaborative educational scene generation and interactive narrative system to implement the multi-agent collaborative educational scene generation and interactive narrative method of this embodiment. The system includes: The environment construction and multi-agent initialization module is used to build an adversarial attack and defense simulation environment for model security education. Specifically, it defines the attacker agent group, the defender model agent group, the data sample agent, and the evaluation environment agent, and initializes their network topology and connection relationships. Among them, the attacker intelligent agent swarm and the defender model intelligent agent swarm constitute the core entities of the game confrontation; The defender model agent swarm is a cluster of miniature convolutional neural network agents used for classification tasks. The environment construction and multi-agent initialization module includes: The attacker agent initialization unit is used to instantiate an adversarial perturbation generator agent and initialize its internal state to a zero perturbation tensor delta_a with the same dimension as the original input sample x. The defender model agent initialization unit is used to instantiate a cluster of convolutional neural network agents, which includes two convolutional layer agents and two fully connected layer agents, and assign random initial values to their state parameters. The state of the convolutional layer agents includes a weight tensor W_conv and a bias b_conv, and the state of the fully connected layer agents includes a weight matrix W_fc and a bias vector b_fc. The network is used to classify ten handwritten digit categories in the MNIST dataset.
[0064] A behavior rule and state update engine is used to encode the mathematical principles of adversarial example generation and model defense into local behavior rules and state update functions for the multi-agent; The local behavior rules ensure that the actions of each agent strictly follow the corresponding algorithm principles. The state update function drives the evolution of the agent's state based on the received signals and internal logic. The behavior rules and state update engine include: The attack principle encoding unit is used to implement gradient-based adversarial example generation rules for the attacker agent. Specifically, the attacker agent obtains the predicted loss value L_adv of the defender network for the input x+delta_a from the forward path, obtains the gradient sign sign(grad_x_L) of the loss L_adv with respect to the input x from the backward path, and updates its perturbation state according to the projective gradient descent algorithm. The rule is: delta_a_new = Clip_epsilon(delta_a_old + alpha_pgd * sign(grad_x_L)), where alpha_pgd is the single-step attack step size, set to 0.001, epsilon is the upper limit of the total perturbation, set to 0.03, and Clip_epsilon is a function that clips the infinite norm of the perturbation tensor to the interval [-epsilon, epsilon]. The defense principle encoding unit is used to implement model training rules for the defender model agent swarm. Specifically, in the standard training mode, the loss L_clean is calculated based on the clean sample x and the parameters are updated; in the adversarial training mode, the loss L_adv is calculated based on the adversarial sample x + delta_a and the parameters are updated. The parameter update adopts the stochastic gradient descent algorithm, the basic learning rate eta_d is set to 0.01, and the momentum coefficient beta_d is set to 0.9.
[0065] The signal flow and dynamic modulation channel construction module is used to construct a bidirectional perturbation gradient signal flow and dynamic modulation channel on the agent network, and to define the signal type, propagation rules and modulated signal parameters. Among them, the forward activation and backward gradient propagation in the execution process of the signal flow simulation algorithm; The dynamic modulation channel exposes key hyperparameters as an externally adjustable interface. The signal flow and dynamic modulation channel construction module includes: The signal definition unit is used to define two types of core signals: activation transfer signals that propagate forward along the network connection, and gradient transfer signals that propagate backward along the network connection; the gradient transfer signals are further divided into attack gradient signals used to generate perturbations and defense gradient signals used to update model weights. The modulation parameter management unit is used to establish and maintain a dynamic modulation channel, which includes the following adjustable parameters: attacker attack step size alpha_pgd, perturbation upper limit epsilon, defender learning rate eta_d, signal selection switch K_switch, and signal gain factor lambda_balance. K_switch equals 0 when the defender receives gradient signals from clean samples, and equals 1 when it receives gradient signals from adversarial samples. lambda_balance is used to balance the loss during adversarial training; the total loss signal is L_total = L_clean + lambda_balance * L_adv, with a default value of 1.0.
[0066] The narrative control logic deployment and translation module is used to deploy a three-layer narrative control logic, translating high-level teaching intentions into temporal modulation instructions and scene constraints for signal parameters in the dynamic modulation channel, so as to drive narrative evolution; The three-layer narrative control logic ensures that the teaching objectives are achieved without undermining the autonomy of the underlying principles. The narrative control logic deployment and translation module includes: The narrative target controller, as the top-level logic, is used to define and select macro-level teaching topics, including: demonstrating the vulnerability of undefended models to white-box attacks, comparing the robustness differences between standard-trained and adversarial-trained models, and exploring the impact of different attack intensities on defense effectiveness. The scene coordinator, as a mid-level logic, receives topics from the narrative target controller and translates them into a set of preset sequences and conditional response rules for parameters in the modulation parameter management unit. For example, to achieve the comparison target, an instruction sequence is generated: In the first stage, K_switch=0, eta_d=0.01, and train for 50 epochs; in the second stage, K_switch=1, lambda_balance=1.0, keep eta_d=0.01, and train for another 50 epochs; in the third stage, the defender parameters are frozen, alpha_pgd is set to 0.001 and 0.01 respectively, epsilon=0.03, and an attack demonstration is performed. The autonomous agent execution layer, as the underlying logic, consists of all agents that follow the behavioral rules and state update engine coding. Their behavior is only affected by their own state and the real-time parameter values received from the dynamic modulation channel. The scene coordinator does not directly write into their internal state.
[0067] The multi-agent collaborative simulation engine is used to initiate the multi-agent collaborative simulation loop. Based on the coded principle rules, dynamic signal flow and hierarchical control instructions, it automatically calculates and generates a complete adversarial attack and defense interactive narrative sequence. The simulation iteratively advances the training cycle and evaluation phase; The narrative sequence is generated emergently from the interaction behaviors between agents; The multi-agent collaborative simulation engine includes: The collaborative training loop unit is used to perform collaborative computation in each training cycle. The specific steps are as follows: the data sample agent forwards pixel data x; the attacker agent iteratively generates perturbation delta_a based on the current parameters; the defender agent forward calculates the loss of x+delta_a; and the defender gradient signal is routed to update the defender parameters based on the value of K_switch. The evaluation and narrative advancement unit is used to call the evaluation environment agent after each preset narrative stage ends, calculate and record the classification accuracy of the current defender model on the clean test set and the adversarial test set generated by the current attacker, and use this as a quantitative indicator to drive the transition between narrative stages.
[0068] The visualization rendering and interaction interface module is used to perform real-time visualization rendering of the internal states, interaction signals and overall system evolution of multiple agents from multiple views, and provides a parameter intervention interface for learners to interact and explore. The multiple views reveal the system's operating mechanism from different dimensions; The interactive interface allows learners to influence the simulation process in real time. The visualization rendering and interaction interface module includes: The feature space visualization unit is used to render the internal representation of the defender network agent. Specifically, the activation output of the last hidden layer agent is reduced to two dimensions using the t-SNE algorithm to generate a dynamic scatter plot, and the true class of the sample is marked with different colors. The adversarial perturbation visualization unit is used to overlay the perturbation tensor delta_a generated by the attacker agent onto the corresponding original input sample image in the form of a heatmap, intuitively showing the modified pixel region and its intensity. The performance curve visualization unit is used to plot and update hyperbolic graphs in real time. One curve shows the change in the model's accuracy on the clean test set as training cycles or narrative stages change, while the other curve shows its accuracy on the adversarial test set. The gap between the two curves is used to characterize the robustness gap of the model. The real-time parameter intervention interface unit provides a set of real-time slider controls in the sidebar of the visualization interface, which are linked to key parameters in the dynamic modulation channel, including the attack step size alpha_pgd, the perturbation limit epsilon, the balance factor lambda_balance, and the signal selection switch K_switch. When the learner drags the slider to modify the parameters, the new values will be sent to the modulation parameter management unit in real time and take effect in the next simulation cycle.
[0069] The working principle of the above technical solution is as follows: An environment construction and multi-agent initialization module creates adversarial game agent entities; a behavior rule and state update engine encodes the mathematical principles of adversarial attacks and model defenses into the agents' intrinsic behavioral guidelines; a signal flow and dynamic modulation channel construction module establishes a controllable information flow network connecting agents; a narrative control logic deployment and translation module translates abstract teaching objectives into fine-tuning instructions for signal network parameters; a multi-agent collaborative simulation engine drives all agents to perform collaborative calculations based on rules, signals, and instructions, autonomously generating complete attack and defense narratives; and a visualization rendering and interactive interface module transforms the internally invisible computational process into a multi-dimensional visual view, allowing learners to actively explore by intervening in signal parameters, thereby constructing a self-consistent, dynamically visible, and goal-oriented immersive model security teaching system.
[0070] An electronic device includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, implements the method for generating educational scenarios and interactive narratives based on multi-agent collaboration.
[0071] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for generating educational scenarios and interactive narratives based on multi-agent collaboration, characterized in that, include: S10: Construct an adversarial attack and defense simulation environment for model security education, specifically defining attacker intelligent agent swarm, defender model intelligent agent swarm, data sample intelligent agent and evaluation environment intelligent agent, and initializing their network topology and connection relationships. S20 encodes the mathematical principles of adversarial example generation and model defense into local behavior rules and state update functions for multi-agent systems; S30 constructs a bidirectional perturbation gradient signal flow and a dynamic modulation channel on top of the agent network, defining the signal type, propagation rules and signal parameters; S40 deploys a three-layer narrative control logic, translating high-level teaching intentions into temporal modulation instructions and scene constraints for signal parameters, driving narrative evolution; S50 initiates multi-agent collaborative simulation, autonomously calculating and generating a complete adversarial attack and defense interactive narrative sequence based on local behavior rules, bidirectional perturbation gradient signal flow and temporal modulation instructions. S60 provides real-time visualization and rendering of the internal states, interaction signals, and overall system evolution of multiple agents from multiple perspectives, and offers parameter intervention interfaces for learners to interact and explore.
2. The method as described in claim 1, characterized in that, S10 includes: S101 defines an attacker agent group, which includes an adversarial perturbation generator agent whose internal state is a perturbation tensor of the same dimension as the original sample, with an initial value of an all-zero tensor. S102 defines the defender model agent swarm, which is a miniature cluster of convolutional neural network agents, including convolutional layer agents and fully connected layer agents, used to classify data.
3. The method as described in claim 1, characterized in that, S20 includes: S201 encodes the principle rules of gradient attack for the attacker agent swarm. Each round, the attacker agent obtains the predicted loss value of the sum of the current input and the current perturbation from the defender network through the forward propagation path, and obtains the sign of the gradient of the loss with respect to the input through the back propagation path, and updates the internal perturbation state according to the projection gradient descent algorithm. S202 defines the principles and rules for training and adversarial training of the defender model intelligent swarm. The defender model intelligent swarm updates its parameters according to the standard training or adversarial training mode. In the standard training mode, the loss is calculated based on clean samples and the parameters are updated by backpropagation. In the adversarial training mode, the loss is calculated based on adversarial samples and the parameters are updated by backpropagation.
4. The method as described in claim 1, characterized in that, S30 includes: S301 defines the activation transfer signal for forward propagation and the gradient transfer signal for backward propagation, wherein the gradient transfer signal includes an attack gradient signal for generating perturbations and a defense gradient signal for updating model weights. S302, Establish a dynamic modulation channel, the signal parameters of which include the attacker agent's attack step size, perturbation limit, the defender agent's learning rate, and a signal selection switch for controlling the training data source. S303 sets the signal gain factor, which is used to balance the contributions of clean sample loss and adversarial sample loss in adversarial training. The total loss signal is the sum of the clean sample loss, the signal gain factor, and the adversarial sample loss.
5. The method as described in claim 1, characterized in that, S40 includes: S401, the top-level narrative goal controller defines the macro-level teaching theme; S402, the mid-level scene coordinator has built-in narrative script logic, which receives macro-level teaching topics and translates them into preset sequences and conditional response rules for signal parameters; S403, the underlying autonomous intelligent swarm operates strictly in accordance with local behavior rules, and its behavior is affected by its own state and the real-time parameter values received from the dynamic modulation channel.
6. The method as described in claim 1, characterized in that, The S50 includes: S501, start the co-simulation cycle. Each training cycle contains data sample agent forward passing data. The attacker agent performs iterations under signal parameter modulation to generate perturbations. The defender model agent forward calculates the loss of the sample after the perturbation. S502, during the back propagation phase, routes the gradient signal flow direction based on the value of the signal selection switch; S503, after each narrative phase, evaluates the intervention of the environmental agent, calculates and records the classification accuracy of the current defender model on the clean test set and the adversarial example test set.
7. The method as described in claim 1, characterized in that, The S60 includes: S601, the first view renders the feature space changes of the defender model agent group, and generates a dynamic scatter plot by the activation output of the last hidden layer agent through a dimensionality reduction algorithm, and marks the true class of the sample with color. S602, the second view is superimposed on the input sample in the form of a heat map, which visualizes the spatial distribution and intensity of the disturbances generated by the attacker's intelligent agent in real time. S603, the third view shows a hyperbola graph, one curve shows the change in clean test accuracy with the narrative stage, and the other curve shows the change in adversarial test accuracy.
8. The method as described in claim 5, characterized in that, The macro-level teaching theme is to demonstrate the difference between single-step attacks and iterative attacks. S402 also includes: using iterative attack intensity modulation narrative, and generating instruction sequences by the mid-level scene coordinator: in the single-step attack demonstration phase, the attacker's single-step attack step size is set to be equal to the perturbation upper limit, and its iteration count is limited to one; in the iterative attack demonstration phase, the attacker's single-step attack step size is set to a value less than the perturbation upper limit, and the maximum number of iterations is set. The macro-level teaching theme is to demonstrate the role of the balance factor in adversarial training. S402 also includes: using a defensive signal balance modulation narrative, the mid-level scene coordinator generates an instruction sequence: the training phase is executed sequentially, each phase sets a different signal gain factor value, and after each phase, the clean accuracy and adversarial accuracy of the model after training under different signal gain factor values are evaluated. The macro-level teaching theme is to explore the attack strategies of attackers at different knowledge levels. S402 also includes: using attacker knowledge state to modulate the narrative. The mid-level scene coordinator arranges the narrative sequence by modulating the knowledge state parameters of the attacker agent. The knowledge state parameters are used to characterize the attacker's mastery of the defender's model information and control the attacker agent to adjust its gradient information source for calculating gradient symbols.
9. A system for generating and interacting with educational scenarios based on multi-agent collaboration, used to implement the method for generating and interacting with educational scenarios based on multi-agent collaboration as described in any one of claims 1-8, characterized in that the system... include: The environment construction and multi-agent initialization module is used to build an adversarial attack and defense simulation environment for model security education. Specifically, it defines the attacker agent group, the defender model agent group, the data sample agent, and the evaluation environment agent, and initializes their network topology and connection relationships. A behavior rule and state update engine is used to encode the mathematical principles of adversarial example generation and model defense into local behavior rules and state update functions for multi-agent systems. The signal flow and dynamic modulation channel construction module is used to build bidirectional perturbation gradient signal flow and dynamic modulation channel on top of the agent network, and to define the signal type, propagation rules and signal parameters. The narrative control logic deployment and translation module is used to deploy a three-layer narrative control logic, translating high-level teaching intentions into temporal modulation instructions and scene constraints for signal parameters to drive narrative evolution; The multi-agent collaborative simulation engine is used to initiate the multi-agent collaborative simulation loop. Based on local behavior rules, bidirectional perturbation gradient signal flow and timing modulation instructions, it automatically calculates and generates a complete adversarial attack and defense interactive narrative sequence. The visualization rendering and interaction interface module is used to perform real-time visualization rendering of the internal states, interaction signals and overall system evolution of multiple agents from multiple views, and provides a parameter intervention interface for learners to interact and explore.
10. An electronic device, comprising a processor and a memory, characterized in that, The memory stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1-8.