A model distillation and evolution method and device, electronic equipment and storage medium

CN122174882APending Publication Date: 2026-06-09SHENZHEN BEIDOU INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN BEIDOU INTELLIGENT TECH CO LTD
Filing Date
2026-04-25
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing technologies in industrial vision algorithm production suffer from several problems, including data annotation being susceptible to visual illusions, difficulty in adapting to the capacity gap between Teacher and Student models, fragile training scripts, significant limitations of manual parameter tuning, and serious idle computing resources.

Method used

The design incorporates labeling and refereeing agents to construct a trial-and-error loop mechanism. By dynamically adjusting the labeling parameters, and combining distributed training technology with hardware state awareness, adversarial refinement and efficient training are achieved. During training, anomalies are handled, a multi-dimensional evaluation system is set up for error pattern analysis, and asynchronous decision-making control by human experts is introduced.

Benefits of technology

It improves the accuracy and stability of data annotation, ensures the continuity of the training process and the continuous improvement of model performance, and significantly improves the efficiency and effectiveness of model distillation and evolution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122174882A_ABST
    Figure CN122174882A_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a model distillation and evolution method and device, electronic equipment and storage medium, relating to the technical field of artificial intelligence and computer vision, wherein the method comprises: constructing a data labeling trial-and-error cycle mechanism by designing a labeling agent and a referee agent, performing counter-purification on initial labeling data, encapsulating distributed training technology as a training module in combination with hardware state perception and a training strategy automatic adjustment mechanism, training a student model based on a distillation data set, and processing abnormalities in real time during the training process, setting up a multi-dimensional evaluation system to analyze error patterns of the student model and generate an analysis report, proposing optimization hypotheses based on the report, dynamically modifying model parameters within a preset parameter range, and optimizing the model architecture in combination with model experiments and code correction. The present application effectively solves the problems of data illusion, training vulnerability, parameter tuning limitations and idle computing power of traditional methods.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and computer vision technology, and in particular to a model distillation and evolution method, apparatus, electronic device and storage medium. Background Technology

[0002] With the explosive growth of Vision-Language Models (VLM) and Large Language Models (LLM) technologies, their application in industrial vision algorithm production is becoming increasingly widespread. Utilizing general-purpose large models (Teacher Models) with massive parameters to automatically annotate vast amounts of unlabeled surveillance videos or industrial images, and then distilling and fine-tuning them to create lightweight small models (Student Models) suitable for deployment at the edge, has become the mainstream paradigm in the current industry.

[0003] However, in actual industrial applications, the existing "data annotation-model training-architecture optimization" technology pipeline still faces many challenges. Traditional data annotation methods often adopt a unidirectional, open-loop static inference flow, directly receiving the output results of large models. This makes the labeled data susceptible to "visual illusions," and the "capacity gap" between the Teacher and Student models makes it difficult to adapt distilled data to lightweight models.

[0004] Meanwhile, static configuration scripts are extremely vulnerable to dynamically changing industrial data, easily leading to training crashes due to hyperparameter mismatch or hardware resource limitations. Furthermore, the "black box" mode of manual hyperparameter tuning restricts further optimization of model performance, while the synchronous, blocking human-computer interaction design results in severe idle computing resources.

[0005] Therefore, there is an urgent need for a model distillation and evolution method that can improve the production efficiency and model performance of industrial vision algorithms, and automate data purification, training self-healing, architecture evolution, and efficient human-machine collaboration. Summary of the Invention

[0006] The embodiments of this invention provide a model distillation and evolution method to address the problems of existing data purification techniques, such as capacity gaps, fragile training scripts, significant limitations of manual parameter tuning, and severe idle computing power. The technical solution is as follows: According to one aspect of the present invention, a model distillation and evolution method is provided, the method comprising: designing an annotation agent and a referee agent; the annotation agent is used to generate annotations with thought chains based on initial annotation data generated by a teacher model according to a positive knowledge base; the referee agent is used to verify the annotations based on a negative knowledge base; a trial-and-error loop mechanism is established between the annotation agent and the referee agent, when the annotation is unqualified, relevant information is fed back to the annotation agent, and the annotation parameters of the annotation agent are dynamically adjusted based on the number of retries through a preset dynamic adjustment mechanism and the annotation is re-annotated until a preset accuracy requirement is achieved; the calculation formula of the dynamic adjustment mechanism is: ,in, This represents the annotation parameters of the annotation agent during the t-th retry. This represents the initial annotation parameters. This represents the step size decay or amplification factor for each retry, used to determine the rate at which the labeled parameter changes with the number of retries, where t represents the number of retries. The upper limit of the annotation parameters is indicated; the initial annotation data generated by the teacher model is adversarially purified based on the trial-and-error loop mechanism to obtain a distillation dataset; the annotation agent and the referee agent coordinate their states through a global state object; the distributed training technology is encapsulated into a training module that can be called by large models, and the student model is trained based on the distillation dataset by combining hardware state awareness and automatic adjustment of training strategies, and anomalies are handled during the training process; the training module interacts with information through a global state object; after the student model is trained, a multi-dimensional evaluation system is set up to test the student model based on the test set to obtain test results; the multi-dimensional evaluation system includes accuracy, recall, and... F1 score; Unsupervised clustering algorithm is used to analyze error patterns in the test results to obtain model failure modes, and an analysis report is generated based on the model failure modes; The model failure modes include recognition errors in specific scenarios; Based on the analysis report, optimization hypotheses are proposed, the model parameters are dynamically modified within a preset parameter adjustment range, and the architecture of the student model is iteratively optimized by combining model experiments and code correction; During training, the interaction of human experts is set as asynchronous decision control points, and the control instructions of human experts are received through a global message bus. When an anomaly occurs, the current task is serialized and suspended and the computing power is released. After the anomaly is handled, the task is deserialized and woken up to respond to the control instructions.

[0007] In one embodiment, the distributed training technology is encapsulated into a training module that can be called by large models. The student model is trained based on the distillation dataset using a hardware state awareness and automatic training strategy adjustment mechanism. This is achieved through the following steps: encapsulating the distributed training technology into a training module that can be called by large models; using the training module to train the student model based on the distillation dataset; monitoring the hardware state in real time during training; adjusting the model training strategy according to the hardware state; and adjusting the penalty weights in the loss function based on the distribution characteristics of the training data. The hardware state includes GPU memory usage and computing node load.

[0008] In one embodiment, handling anomalies during training is achieved through the following steps: When an anomaly is detected during training, it is processed and the training strategy is adjusted according to a preset anomaly handling strategy; the anomalies include memory anomalies, compute node failures, and gradient explosion; the anomaly handling strategy includes dynamically adjusting the batch size and migrating training tasks; a daemon process takes over error output in real time, immediately intercepts error messages when the engine malfunctions, executes a preset computing power degradation strategy based on the error messages, modifies the configuration, initializes and restarts the training task; the computing power degradation strategy includes dynamically adjusting the batch size, adjusting the gradient accumulation steps, and dynamically adjusting the model dimension; a callback mechanism is used to monitor key indicators during training at the training step or training cycle level, and a hot-fix action is triggered when an abnormal trend is detected; the key indicators include the global gradient norm; the hot-fix action includes dynamically adjusting the learning rate and increasing weight decay.

[0009] In one embodiment, the optimization of the student model architecture based on the analysis report, including proposing optimization hypotheses, dynamically modifying model parameters within a preset parameter adjustment range, and iteratively optimizing the architecture through model experiments and code correction, is achieved through the following steps: Targeted optimization hypotheses are proposed based on the analysis report; the parameters of the student model are dynamically modified within a predefined optimizer library, loss function space, and network fine-tuning layer; and the optimization effect is verified through model experiments. The optimization hypotheses include adjusting the model structure and optimizing hyperparameters. Abstract Syntax Tree (AST) parsing technology is used to replace the underlying code nodes; micro-A / B testing is performed in an isolated computing sandbox to fix syntax errors and verify the benefits of the hypotheses. The underlying code nodes include optimizers and loss functions; the syntax errors include tensor dimension mismatch and operator incompatibility.

[0010] According to one aspect of the present invention, a model distillation and evolution apparatus includes: an agent adversarial purification module, configured to design a trial-and-error loop mechanism for constructing data annotation between a labeling agent and a referee agent, and to perform adversarial purification on initial labeled data generated by a teacher model based on the trial-and-error loop mechanism to obtain a distilled dataset; wherein the labeling agent and the referee agent coordinate state through a global state object; and a hardware-aware training module, configured to encapsulate distributed training technology into a training module that can be called by large models, and to train a student model based on the distilled dataset using a mechanism that combines hardware state awareness and automatic adjustment of training strategies, and to handle anomalies during training; the training module... Information interaction is achieved through a global state object; the model verification and optimization module is used to perform error pattern analysis on the student model by setting a multi-dimensional evaluation system to generate an analysis report, propose optimization hypotheses based on the analysis report, dynamically modify model parameters within a preset parameter adjustment range, and iteratively optimize the architecture of the student model by combining model experiments and code correction; the asynchronous expert arbitration module is used to set the interaction of human experts as asynchronous decision control points during training, and receive the control instructions of human experts through a global message bus, serialize and suspend the current task and release computing power when an anomaly occurs, and deserialize and wake up the task and respond to the control instructions after the anomaly is handled.

[0011] According to one aspect of the present invention, an electronic device includes at least one processor and at least one memory, wherein computer-readable instructions are stored on the memory; the computer-readable instructions are executed by one or more of the processors to cause the electronic device to implement the model distillation and evolution method as described above.

[0012] According to one aspect of the invention, a storage medium stores computer-readable instructions that are executed by one or more processors to implement the model distillation and evolution method as described above.

[0013] The beneficial effects of the technical solution provided by this invention are: In the above technical solution, this invention first constructs a trial-and-error loop mechanism for data annotation by designing annotation agents and referee agents. This mechanism adversarially purifies the initial labeled data generated by the teacher model, ensuring the high quality of the distillation dataset. Next, distributed training technology is encapsulated into a training module that can be called by large models. Combined with hardware state awareness and an automatic training strategy adjustment mechanism, the student model is efficiently trained based on the distillation dataset. Anomalies are handled in real time during training, ensuring the stability and robustness of the training. Then, by setting up a multi-dimensional evaluation system, error pattern analysis is performed on the student model, generating an analysis report that provides a clear direction for model optimization. Finally, optimization hypotheses are proposed based on the analysis report. Model parameters are dynamically modified within a preset parameter range. Combined with model experiments and code correction, the student model architecture is iteratively optimized, achieving continuous improvement in model performance. This method effectively solves the problems of low data purification quality, unstable training process, and unclear model optimization direction in existing technologies, significantly improving the efficiency and effectiveness of model distillation and evolution. Attached Figure Description

[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without creative effort.

[0015] Figure 1 This is a flowchart illustrating a model distillation and evolution method according to an exemplary embodiment; Figure 2 This is a schematic diagram of the system architecture corresponding to the model distillation and evolution method in an application scenario; Figure 3 This is a schematic diagram of the architecture of module one of the model distillation and evolution system in an application scenario; Figure 4 This is a schematic diagram of the architecture of module two of the model distillation and evolution system in an application scenario; Figure 5 This is a schematic diagram of the architecture of module three of the model distillation and evolution system in an application scenario; Figure 6 This is a block diagram of a model distillation and evolution apparatus according to an exemplary embodiment; Figure 7 This is a hardware structure diagram of an electronic device according to an exemplary embodiment; Figure 8 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation

[0016] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0017] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this disclosure means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.

[0018] This invention provides a model distillation and evolution method. By designing a data purification mechanism combining intelligent agent trial-and-error loops with human expert decision-making, an efficient and stable training and anomaly handling method, and error pattern analysis and iterative architecture optimization method, it achieves high-quality model distillation and continuous evolution, solving problems such as data quality, training stability, and unclear optimization direction. This model distillation and evolution method is applicable to model distillation and evolution devices, which can be electronic devices. The model distillation and evolution method in this invention can be applied to various scenarios, such as model distillation and evolution.

[0019] Please see Figure 1 This invention provides a model distillation and evolution method applicable to electronic devices.

[0020] In the following method embodiments, for ease of description, the execution subject of each step of the method is an electronic device, but this does not constitute a specific limitation.

[0021] like Figure 1 As shown, the method may include the following steps: Step 110: Design a trial-and-error loop mechanism for data annotation between the annotation agent and the referee agent. Based on the trial-and-error loop mechanism, perform adversarial purification on the initial annotation data generated by the teacher model to obtain the distilled dataset.

[0022] In one possible implementation, an annotation agent and a referee agent are designed, and a trial-and-error loop mechanism is established between the annotation agent and the referee agent. When the referee agent determines that the annotation result is unqualified, it feeds back relevant information to the annotation agent. The annotation parameters of the annotation agent are dynamically adjusted based on the number of retries through a preset dynamic adjustment mechanism, and the annotation is re-annotated until the preset accuracy requirement is met.

[0023] In one possible implementation, the calculation formula for the dynamic adjustment mechanism is: ,in, This represents the labeling parameters for the labeling agent during its t-th retry. This represents the initial annotation parameters. This represents the step size decay or amplification factor for each retry, used to determine the rate at which the annotation parameters change with the number of retries, where t represents the number of retries. This indicates the upper limit of the annotation parameter.

[0024] The dynamic adjustment mechanism is used to dynamically adjust the annotation parameters generated by the annotation agent during the trial-and-error loop, controlling the balance between exploration and utilization during the annotation process. The initial sampling parameters are those used by the annotation agent in its first attempt to generate annotations. An upper limit on the annotation parameters is used to prevent excessively high parameters from leading to overly random or unreasonable annotation results. Through this dynamic adjustment mechanism, the system can control the balance between exploration and utilization by the annotation agent in the trial-and-error loop. In the initial stage, higher annotation parameters help the model escape local optima and explore more possible annotation results; as the number of retries increases, gradually decreasing the annotation parameters helps the model converge to more stable and accurate annotation results. This dynamic adjustment mechanism improves the flexibility and adaptability of the annotation process, helping to cope with complex and varied annotation tasks and data distributions.

[0025] In one possible implementation, when scenarios arise during data purification that are difficult to automatically determine, human experts are introduced as external decision-making nodes. Human experts review and modify the annotation results that the annotation agent and the referee agent cannot agree on, thus obtaining the distilled dataset.

[0026] The annotation agent and the referee agent coordinate their states through a global state object. The annotation agent generates annotations with thought chains based on the initial annotation data generated by the teacher model from the positive knowledge base, while the referee agent verifies the annotations based on the negative knowledge base.

[0027] Specifically, an annotation agent and a referee agent are designed, and the two coordinate their states through a global state object: The annotation agent is responsible for receiving the initial annotation data generated by the teacher model and generating annotations with thought chains based on the positive knowledge base. This kind of annotation with thought chains can more clearly present the reasoning process of the annotation, which helps to improve the annotation quality and interpretability; The referee agent verifies the annotations generated by the annotation agent based on the negative knowledge base. In this way, the referee agent can strictly and accurately judge whether the annotation results meet the requirements according to the preset rules.

[0028] The positive knowledge base is a collection of knowledge containing numerous standard success cases, best practices, known correct annotation information, and model reasoning logic. During model distillation and evolution, the positive knowledge base primarily serves to provide reference and guidance for the annotation agent. Specifically, when the annotation agent receives initial annotation data generated by the teacher model, it retrieves relevant information from the positive knowledge base and, combined with the specific requirements of the current task, generates more accurate and reasonable annotation results. This annotation method based on the positive knowledge base can significantly improve the quality and consistency of annotations, reducing subjectivity and uncertainty in the annotation process.

[0029] A negative knowledge base, also known as a negative error log, is a collection of negative information recorded by the model in historical tasks, including errors, boundary condition failures, and category confusion. During model distillation and evolution, the negative knowledge base primarily provides a basis for verification and adjudication for the referee agent. When the referee agent receives the annotation results generated by the annotation agent, it searches the negative knowledge base for relevant information to determine whether the annotation results contain known error patterns or do not meet preset standards. If so, the referee agent feeds back specific error information and improvement suggestions to the annotation agent, prompting it to make corrections and improvements. The introduction of a negative knowledge base helps improve the model's ability to identify boundary conditions and anomalies, enhancing its robustness and generalization performance.

[0030] Furthermore, a trial-and-error loop mechanism is established between the annotation agent and the referee agent. When the referee agent determines that the annotation result is unqualified, it returns feedback information (including detailed information such as the error type and location) to the annotation agent. The annotation agent dynamically adjusts its annotation parameters based on the number of retries according to a preset dynamic adjustment mechanism, and re-annotates based on the feedback information. This process is repeated until the preset accuracy requirement is met.

[0031] Furthermore, during the data purification process, when scenarios arise that are difficult to automatically determine—namely, when the labeling agent and the referee agent cannot reach an agreement on the labeling results—human experts are introduced as external decision-making nodes. Using their expertise, human experts review and modify the labeling results from which the two parties cannot reach an agreement, ultimately resulting in a high-quality distilled dataset.

[0032] In the above process, this embodiment of the invention achieves automated purification of the initial labeled data generated by the teacher model by carefully designing a trial-and-error loop mechanism for the labeling agent and the referee agent, and combining it with external decision-making by human experts. This improves the accuracy of data labeling, significantly reduces the workload of manual labeling, and provides a solid and high-quality data foundation for subsequent model training.

[0033] Step 120: The distributed training technology is encapsulated into a training module that can be called by large models. The student model is trained based on the distillation dataset by combining hardware state awareness and automatic adjustment mechanism of training strategy, and anomalies are handled during the training process.

[0034] One possible implementation is to encapsulate distributed training technology into a training module that can be called by large models. The training module trains student models based on distillation datasets, monitors hardware status in real time during training, adjusts model training strategies based on hardware status, and adjusts penalty weights in the loss function based on the distribution characteristics of training data.

[0035] The hardware status includes GPU memory usage and computing node load, etc. The underlying distributed training framework includes PyTorch, Hugging Face transformers, etc., and the hardware status includes GPU memory usage, node topology, etc., which are not specified here.

[0036] In one possible implementation, when an anomaly is detected during training, it is handled according to a preset anomaly handling strategy and the training strategy is adjusted. Error output is taken over in real time by a daemon process. When an engine anomaly occurs, the error message is immediately intercepted, and a preset computing power degradation strategy is executed according to the error message. After modifying the configuration, the training task is initialized and restarted. Based on the callback mechanism, key indicators in the training process are monitored at the training step or training cycle granularity. When an abnormal trend is detected, a hot repair action is triggered.

[0037] Among them, anomalies include memory anomalies, computing node failures, and gradient explosion, etc. Anomaly handling strategies include dynamically adjusting batch size and transferring training tasks, etc. Computing power degradation strategies include dynamically adjusting batch size, adjusting gradient accumulation steps, and dynamically adjusting model dimensions, etc. Key indicators include global gradient norm, etc. Hot fix actions include dynamically adjusting the learning rate and increasing weight decay, etc., none of which are specified here.

[0038] Specifically, distributed training technology is encapsulated into a training module that can be called by large models, facilitating unified management and invocation. During training, hardware status (such as GPU memory usage and compute node load) is monitored in real time; training strategies are automatically adjusted based on hardware status, such as dynamically adjusting batch size and learning rate, to avoid hardware resource overload. When anomalies are detected during training (such as memory anomalies, compute node failures, or gradient explosion), pre-defined anomaly handling strategies are immediately activated. These strategies include dynamically adjusting batch size, migrating training tasks, implementing computational degradation strategies (such as dynamically adjusting gradient accumulation steps and model dimensions), and restarting the training task.

[0039] In the above process, this embodiment of the invention achieves efficient and stable training of the student model by encapsulating distributed training technology and combining hardware state awareness with an automatic training strategy adjustment mechanism. Simultaneously, the introduction of an anomaly handling mechanism ensures the continuity and stability of the training process, enabling rapid recovery even in the event of hardware failures or gradient explosion, thus improving training efficiency and success rate. Since training data distribution is often unbalanced, and different categories or regions of data have varying impacts on the model, adjusting the penalty weights in the loss function based on the characteristics of the training data distribution allows the model to focus more on key data components, avoiding underfitting or overfitting of certain data due to data imbalance.

[0040] Step 130: By setting up a multi-dimensional evaluation system, error pattern analysis is performed on the student model to generate an analysis report. Based on the analysis report, optimization hypotheses are proposed, model parameters are dynamically modified within the preset parameter adjustment range, and the architecture of the student model is iteratively optimized by combining model experiments and code correction.

[0041] In one possible implementation, after the student model is trained, a multi-dimensional evaluation system is set up to test the student model based on the test set to obtain test results. An unsupervised clustering algorithm is used to analyze the error patterns of the error samples in the test results to obtain the model failure modes, and an analysis report is generated based on the model failure modes.

[0042] In one possible implementation, targeted optimization hypotheses are proposed based on the analysis report. The parameters of the student model are dynamically modified within a predefined optimizer library, loss function space, and network fine-tuning layer. The optimization effect is verified by combining model experiments. Abstract Syntax Tree (AST) parsing technology is used to replace the underlying code nodes. Micro A / B tests are performed in an isolated computing power sandbox to fix syntax errors and verify the hypothetical benefits.

[0043] The multi-dimensional evaluation system includes accuracy, recall, and F1 score, etc.; model failure modes include recognition errors in specific scenarios, etc.; underlying code nodes include optimizers, loss functions, etc.; and syntax errors include tensor dimension mismatch, operator incompatibility, etc., none of which are specified here.

[0044] Specifically, after the student model is trained, a multi-dimensional evaluation system (such as accuracy, recall, F1 score, etc.) is set up based on the test set to comprehensively test the model. Unsupervised clustering algorithm is used to analyze error patterns in the test results to uncover model failure modes (such as recognition errors in specific scenarios); a detailed analysis report is generated based on the model failure modes to provide direction for subsequent model optimization.

[0045] In the above process, this embodiment of the invention achieves a comprehensive evaluation and precise identification of student model performance by setting up a multi-dimensional evaluation system and error mode analysis method. The generated analysis report not only provides a clear direction for model optimization but also helps developers deeply understand the model's performance bottlenecks, laying a solid foundation for subsequent iterative optimization.

[0046] Step 140: During the training process, the interaction of human experts is set as an asynchronous decision control point, and the control instructions of human experts are received through the global message bus. When an exception occurs, the current task is serialized and suspended and the computing power is released. After the exception is handled, the task is deserialized and woken up to respond to the control instructions.

[0047] Specifically, based on the analysis report, targeted optimization hypotheses are proposed (such as adjusting the model structure and optimizing hyperparameters). The parameters of the student model are dynamically modified within a predefined optimizer library, loss function space, and network fine-tuning layers. The optimization effect is verified through model experiments, using Abstract Syntax Tree (AST) parsing technology to replace underlying code nodes (such as optimizers and loss functions). Micro-A / B testing is performed in an isolated computing sandbox to fix syntax errors (such as tensor dimension mismatches and unsupported operators) and verify the hypothetical benefits.

[0048] In the above process, in this embodiment of the invention, all agents, modules, and agents and modules do not communicate directly point-to-point. Instead, they achieve efficient pipelined state coordination by jointly reading and writing global state objects containing context information. This embodiment of the invention achieves iterative optimization of the student model architecture by proposing optimization hypotheses, dynamically modifying model parameters, and combining model experiments with code correction methods. This step not only increases the upper limit of model performance but also ensures the correctness and effectiveness of the optimization direction through rigorous experimental verification. Simultaneously, the application of AST parsing technology makes code modification safer and more reliable, avoiding model training failures caused by code errors.

[0049] Through the above process, this invention achieves high-quality model distillation and continuous evolution by purifying and labeling data, training and handling anomalies, evaluating models and diagnosing bottlenecks, and iteratively optimizing the model architecture. This method not only improves the accuracy of data labeling and the stability of model training, but also significantly enhances the upper limit of model performance through error pattern analysis and iterative architecture optimization. Furthermore, the introduction of human experts makes the direction of model optimization clearer and more reliable, providing strong support for the application of large-scale visual models in industry.

[0050] like Figure 2 As shown, in one application scenario, a model distillation and evolution system was constructed using the model distillation and evolution method of this invention to perform model distillation and evolution. The overall architecture of this system revolves around a global state machine and includes multiple functional modules. These modules work together to achieve full automation from data annotation to model evolution.

[0051] Global State Machine: As the core hub of the system, it manages DCG topology and non-point-to-point related information in the form of strongly typed global state objects. It is responsible for coordinating the workflows between various modules, ensuring the consistency and efficient updating of system state, and providing fundamental support for the stable operation of the entire system.

[0052] Module 1: Data Labeling and Refinement Networks include: Labeling agent: Using the Ralph Loop trial-and-error loop, combined with positive case RAG, the collected industrial product image data is initially labeled to identify the location and type of product defects.

[0053] The adjudicating agent, also based on the Ralph Loop trial-and-error cycle, verifies and adjudicates the annotation results of the labeling agent according to the negative error log (RAG). If the annotation result is unsatisfactory, it will be fed back to the labeling agent for re-annotation until the preset confidence level is reached, thereby effectively improving the accuracy and quality of data annotation.

[0054] like Figure 3 As shown, Module 1 is the Data Purification Network (Adversarial Trial and Error). Its core objective is to purify high-purity data from raw data through adversarial and collaborative interactions between agents, utilizing techniques such as dual-track RAG. This module mainly consists of labeling nodes, referee nodes, a trial-and-error loop (Ralph Loop), and related data and control flows.

[0055] Annotation Node: Receives raw data distributed by the global state machine, combines it with a positive knowledge base (standard success cases), and annotates the raw data using dual-track RAG technology. It also features dynamic temperature scaling control, dynamically adjusting temperature parameters to maintain a balance between exploration and utilization during the annotation process. This enables efficient initial annotation of raw data, and the dynamic temperature scaling control ensures that the annotation process fully utilizes existing knowledge while maintaining a degree of exploratory nature, improving the accuracy and diversity of the annotations.

[0056] The referee node receives the labeled data generated by the labeling node and, combined with the negative error log (boundary red line rule), performs visual verification of the labeling results using dual-track RAG technology. It determines whether the labels meet the standards; if not, it provides a verification failure signal and Visual Traceback information. It strictly controls the quality of the labeled data, using the negative error log to clearly define boundary rules, ensuring that the labeling results meet high-quality standards and providing a reliable data foundation for subsequent model training.

[0057] The Ralph Loop connects annotation nodes and judge nodes, forming a closed-loop trial-and-error process. When a judge node determines that a annotation result is unqualified, it sends a verification failure message back to the annotation node. The annotation node then re-annotates based on the feedback, and this process continues until the retry limit is reached or the annotation requirements are met. Through continuous trial and error and feedback, the annotation nodes are prompted to continuously optimize their annotation results, improving the quality and accuracy of data annotation while avoiding the workload of repeated manual checks and corrections.

[0058] Data flow and control flow include: Data Flow: Raw data is distributed from the global state machine to the annotation nodes. The data generated by the annotations flows to the referee nodes. The verification results and related information from the referee nodes are fed back to the annotation nodes, forming the flow of data within the module. Simultaneously, high-purity data is ultimately output to the global state machine for use by subsequent modules.

[0059] Control flow: Includes control signals such as retry limit reached / task suspension. When the trial loop reaches the retry limit, a task suspension signal is triggered, serializing the current task into a suspension message queue, awaiting human arbitration or expert intervention. After human arbitration or expert intervention, the alignment intent is reverse-injected, adjusting relevant parameters or rules to allow the task to continue.

[0060] Among them, data flow ensures the orderly processing and transmission of data within the module, while control flow ensures a reasonable handling mechanism for the module when encountering abnormal situations, thereby improving the stability and reliability of the system.

[0061] Specifically, using this module for data annotation and purification may include the following steps: Step S101: Data distribution and initial annotation.

[0062] Specifically, the global state machine distributes the collected raw data to the annotation nodes of Module 1. After receiving the data, the annotation nodes immediately activate the dynamic temperature scaling control mechanism to calculate the current temperature based on the preset initial temperature, temperature change coefficient, and temperature upper limit.

[0063] Furthermore, by combining standard success cases from the positive knowledge base, the original data is annotated using dual-track RAG technology to generate preliminary annotation results. Dynamic temperature scaling control allows the annotation process to be flexibly adjusted according to actual conditions, improving accuracy while ensuring annotation efficiency and laying the foundation for subsequent data purification.

[0064] Step S102: Verify the annotation results.

[0065] Specifically, the annotation node sends the generated annotation results to the referee node. After receiving the annotation data, the referee node uses the dual-track RAG technology to visually verify the annotation results according to the boundary red line rules in the negative error notebook. It carefully checks whether the annotations meet the standards and whether there are any errors or violations of the rules.

[0066] Furthermore, if the annotation result is qualified, the referee node will return the high-purity data to the global state machine; if the annotation result is unqualified, the referee node will generate a verification failure signal, along with Visual Traceback information, which will point out the problems in the annotation in detail.

[0067] In the above process, the embodiments of the present invention clarify the boundary rules of data annotation through the strict verification of the referee node and the use of the negative error notebook, effectively ensuring the quality of the annotated data and preventing low-quality data from entering the subsequent process.

[0068] Step S103: Trial and error loop and feedback adjustment.

[0069] Specifically, when the annotation node receives a verification failure signal and Visual Traceback information from the referee node, it adjusts the annotation process based on the feedback. It restarts dynamic temperature scaling control, potentially adjusting temperature parameters or other relevant parameters, and then re-annotates the original data.

[0070] Furthermore, the labeled results are sent again to the referee node for verification, forming a closed-loop trial-and-error cycle. If the trial-and-error cycle reaches the preset retry limit and still cannot obtain a qualified labeling result, the system will trigger a task suspension signal, serialize the current task suspension message, and put it into the suspension message queue.

[0071] In the above process, this embodiment of the invention utilizes a trial-and-error loop mechanism, enabling annotation nodes to continuously optimize annotation results based on feedback, thereby improving the efficiency and success rate of data purification. Simultaneously, the task suspension mechanism prevents the system from endlessly looping through unsolvable problems, ensuring stable system operation.

[0072] Step S104: Manual intervention and task recovery.

[0073] Specifically, when a task enters the pending message queue, human arbitrators or experts can intervene. They can review relevant information in the pending messages, including raw data, annotation history, and verification failure messages, and then, after aligning their intentions, reverse-engineer and adjust parameters or rules. For example, they could adjust parameters for dynamic temperature scaling control, modify the retrieval strategy of the dual-track RAG, or update the positive knowledge base and negative error log.

[0074] Furthermore, after the adjustment is completed, the task resumes from the suspended state and re-enters the trial-and-error loop process to continue data annotation and verification until qualified annotation results are obtained and high-purity data is output to the global state machine.

[0075] In the above process, the embodiments of the present invention, through a human intervention mechanism, can make adjustments and optimizations with the help of human experts when the system encounters complex problems that cannot be solved automatically, thus ensuring the smooth progress of data purification and improving the system's adaptability and flexibility.

[0076] Module Two: Automated Fine-tuning and Self-Healing Systems include: Training and configuration agent: Based on data characteristics and training objectives, under the management of the global state machine, it is responsible for configuring model training parameters, selecting appropriate model structures, and preparing for model training.

[0077] Distributed self-healing training engine: This engine undertakes the actual training of the model, employing distributed computing to improve training efficiency. During training, it possesses self-healing capabilities. When anomalies are detected, such as CUDA memory overflow or NaN gradients, it automatically captures error information and triggers hot-fix actions, such as dynamically adjusting the learning rate and increasing weight decay, ensuring the smooth progress of the training process.

[0078] The monitoring and scheduling agent monitors hardware status (such as GPU memory usage and node topology) and core scalar features (such as the global gradient norm) throughout the training lifecycle in real time. Upon detecting anomalies, it promptly notifies the distributed self-healing training engine to make adjustments, while simultaneously coordinating computing resources to ensure efficient system operation.

[0079] like Figure 4As shown, Module 2 is an automated fine-tuning and self-healing system. Its core objective is to achieve automated adjustment and anomaly self-healing during model training, ensuring the stability and efficiency of training. This module mainly consists of three parts: a training pipeline configuration agent, a training monitoring and scheduling agent, and a distributed training engine.

[0080] Training pipeline configuration agent: Data feature matching and memory awareness: This involves in-depth analysis of the features of the input training data and real-time matching with the system's memory usage. In this way, data loading and usage strategies during training can be rationally planned based on the characteristics of the data and the remaining memory capacity.

[0081] Fine-tuning configuration strategy library: It has a rich set of built-in fine-tuning configuration strategies, such as batch halving. When the system detects anomalies during training or needs to optimize training performance, it can select appropriate strategies from the strategy library to fine-tune the training parameters.

[0082] Among these features, data feature matching and GPU memory awareness effectively avoid training interruptions caused by improper data loading or insufficient GPU memory, thus improving training stability. Meanwhile, the fine-tuning configuration strategy library provides diverse options for optimizing the training process, enabling rapid adjustment of training parameters according to different training scenarios and needs, thereby improving training efficiency and model performance.

[0083] Training monitoring and scheduling agent: Fatal error monitoring: Monitors the running status during the training process in real time. Once a fatal error is detected, such as hardware failure or program crash, an alarm is immediately issued and corresponding measures are taken.

[0084] Gradient monitoring and weight rollback command: Closely monitor gradient changes during training. When gradient anomalies are detected, such as gradient explosion or vanishing, issue a weight rollback command in a timely manner to restore the model's weights to their previous normal state, preventing the model from failing to train normally due to gradient problems.

[0085] Status reporting and policy change triggering: The system periodically reports training status information to the training pipeline configuration agent. When a training anomaly is detected or optimization is needed, the system triggers the training pipeline configuration agent to perform policy changes and training retry.

[0086] Among these features, the fatal error monitoring function ensures timely response to serious problems during training, minimizing losses. Gradient monitoring and weight rollback instructions effectively prevent the model from falling into undesirable states due to gradient issues, ensuring smooth training. The state reporting and policy change triggering mechanism enables collaborative work between the two agents, allowing dynamic adjustments to the training strategy based on actual training conditions, improving the automation and adaptability of training.

[0087] The distributed training engine, serving as the actual execution environment for model training, is responsible for receiving configuration information from the training pipeline configuration agent and performing distributed training according to the configuration requirements. Simultaneously, it feeds back the training process status information to the training monitoring and scheduling agent for monitoring and scheduling. The distributed training engine fully utilizes the resources of multiple computing devices, significantly improving the speed and efficiency of model training. Through collaborative work with two agents, it achieves automated management and anomaly self-healing of the training process, reducing the need for manual intervention and lowering training costs.

[0088] Specifically, using Module 2 for automated fine-tuning and self-healing may include the following steps: Step S201: Training configuration initialization.

[0089] Specifically, before model training begins, the training pipeline configuration agent first analyzes the characteristics of the input training data and, in conjunction with the current system's memory usage, formulates a preliminary training configuration plan through data feature matching and memory awareness.

[0090] Furthermore, a suitable default strategy, such as the initial batch size, is selected from the fine-tuning configuration strategy library, and the configuration information is sent to the distributed training engine.

[0091] In the above process, the embodiments of the present invention provide reasonable starting parameters and environment settings for model training by configuring the initialization configuration of the agent through the training pipeline, ensuring that training can start on a stable basis, thereby improving the reliability and efficiency of training.

[0092] Step S202: Monitoring the training process.

[0093] Specifically, after the distributed training engine begins model training according to the received configuration information, the training monitoring and scheduling agent immediately starts monitoring. It listens in real time for any fatal errors during training and closely monitors changes in gradients.

[0094] Furthermore, training status information, such as training progress and loss function values, is collected periodically from the distributed training engine and analyzed and evaluated.

[0095] In the above process, the embodiments of the present invention can promptly detect various problems that occur during the training process by real-time monitoring of the training monitoring and scheduling agent, providing a basis for subsequent adjustments and self-healing, and ensuring the stability and controllability of the training process.

[0096] Step S203: Exception handling and strategy adjustment.

[0097] Specifically, if the training monitoring and scheduling agent detects a fatal error, such as a hardware failure causing training to be interrupted, it will immediately trigger the error interception mechanism and notify the training pipeline configuration agent. The training pipeline configuration agent will then select an appropriate strategy from the fine-tuning configuration strategy library to respond based on the error type and the current training state, such as adjusting the data loading method or changing the training device, and trigger a training retry.

[0098] Furthermore, if an anomaly in gradients, such as gradient explosion, is detected, the training monitoring and scheduling agent will promptly issue a weight rollback instruction to restore the model weights to their previous normal state. Simultaneously, it will report the anomaly to the training pipeline configuration agent. The training pipeline configuration agent will adjust its training configuration strategy based on the reported information, such as adjusting the learning rate or optimizer parameters, and then reissue the configuration information to the distributed training engine to continue training.

[0099] In the above process, the embodiments of the present invention achieve rapid response and effective handling of abnormal situations during training through the collaborative work between two intelligent agents. It can automatically adjust the training strategy according to different types of abnormalities, thereby improving the automation level and self-healing ability of training.

[0100] Step S204: Gradient repair and continuous training.

[0101] Specifically, after executing the weight rollback instruction, the training monitoring and scheduling agent continues to monitor the gradients to ensure they return to the normal range. Simultaneously, the training pipeline configuration agent continuously optimizes the training process based on the adjusted configuration strategy.

[0102] Furthermore, the distributed training engine continues to train the model according to the new configuration information, and the training monitoring and scheduling agent continuously monitors it until the model training is completed.

[0103] In the above process, the embodiments of the present invention ensure that the model can resume normal training after experiencing anomalies through gradient repair and continuous training mechanisms, and improve the training quality and performance of the model by continuously optimizing the training strategy, and finally obtain a model that meets the requirements.

[0104] Module 3: The automatic evolution system for model evolution includes: Evaluation attribution points: Conduct a comprehensive evaluation of the trained model, analyze its performance, identify performance bottlenecks and defects, and provide direction for subsequent optimization.

[0105] Automated Development Node: Based on the analysis results of the evaluation attribution points, optimization hypotheses are generated within a predefined optimizer library, loss function space, and network fine-tuning layers. Through bounded search space techniques, optimal model parameter tuning schemes are explored within a limited scope, improving optimization efficiency.

[0106] Code Sandbox Test Node: Employing Docker sandbox technology, this provides an isolated testing environment for model optimization. The optimized model is tested within the sandbox, and AST (Abstract Syntax Tree) code injection technology automatically corrects potential syntax errors (such as tensor dimension mismatches, unsupported operators, etc.), verifies hypothetical benefits, and ensures the safety and effectiveness of model optimization.

[0107] Asynchronous Human-to-the-Line (HITL) Bus: Serving as a channel for human intervention, human experts can asynchronously intervene in the system at various critical stages when encountering complex problems or requiring special adjustments. Examples include adjusting training parameters and modifying model structure. The human expert's intentions are recorded and fed back into the system for subsequent model optimization and improvement, achieving effective collaboration between humans and the system.

[0108] like Figure 5 As shown, Module 3 is the bounded evolution and architecture optimization part of the automatic model evolution system. Its core objective is to achieve continuous model optimization and architecture improvement within a safe and controllable range. This module mainly consists of three parts: the AutoResearch agent, the multi-dimensional evaluation agent, and the code sandbox test node.

[0109] AutoResearch agent: Hypothesis generation: Based on the model's current performance and existing problems, it automatically generates a series of possible optimization hypotheses. These hypotheses cover multiple aspects such as model structure adjustment, parameter optimization, and training strategy improvement.

[0110] Bounded space search: This involves exploring and filtering optimization hypotheses within a predefined bounded search space. This search space is set based on factors such as model characteristics, application scenarios, and hardware resources to ensure the search process is both flexible enough and stays within a reasonable range.

[0111] AST code patch generation: When an optimization hypothesis is determined to have potential value, the AutoResearch agent can automatically generate corresponding Abstract Syntax Tree (AST) code patches. These code patches can be easily integrated into existing model code, enabling modifications and optimizations to the model.

[0112] By optimizing hypothesis generation and bounded space search, possible optimization solutions can be found across a wide range while avoiding aimless blind searches, thus improving optimization efficiency. The AST code patch generation function makes the implementation of optimization solutions more convenient and accurate, reducing errors that may arise from manual coding.

[0113] Multidimensional evaluation agent: Independent outflow set inference: The optimized model is tested independently using independent test datasets to evaluate the model's performance on new data, avoiding inaccurate evaluation results due to overfitting of the training data.

[0114] Fine-grained error clustering and attribution: This involves detailed classification and attribution analysis of errors occurring during the model's inference process. By analyzing the type of errors, their frequency of occurrence, and their relationship with the input data, specific problems and weaknesses in the model can be identified.

[0115] Analysis report generation: Based on the results of fine-grained error clustering attribution, a detailed analysis report is generated. The report clearly points out the bottleneck problems of the model, providing specific directions and basis for further optimization.

[0116] Independent outflow set inference ensures the objectivity and accuracy of performance evaluation for the optimized model. Fine-grained error clustering attribution delves into the model's problems, helping developers better understand its performance bottlenecks. The analysis report provides clear guidance for subsequent optimization efforts, improving the targeting and effectiveness of optimization.

[0117] Code Sandbox Test Node: Provides an isolated testing environment for executing code patches generated by AutoResearch agents and testing optimized models. Within this environment, various experiments and tests can be safely conducted without affecting the main system or other running tasks. It also receives configuration information from AutoResearch agents, executes corresponding test tasks, and feeds back the test results to the relevant agents.

[0118] The code sandbox testing node ensures the security and independence of the testing process, preventing damage to the main system from unstable or problematic code. The isolated environment allows for more confident experimentation and verification of various optimization schemes, improving system stability and reliability.

[0119] Specifically, using Module 3 for bounded evolution and architecture optimization may include the following steps: Step S301: Optimize hypothesis exploration and code generation.

[0120] Specifically, the AutoResearch agent first analyzes the current model and generates a series of optimization hypotheses based on the model's performance metrics and existing problems. For example, if the model performs poorly when processing certain types of data, the agent may generate hypotheses such as adjusting the number of model layers, changing the activation function, or optimizing training hyperparameters.

[0121] Furthermore, these hypotheses are evaluated and filtered within a predefined bounded search space to select the most promising optimization hypothesis. For the selected optimization hypothesis, the AutoResearch agent automatically generates the corresponding AST code patch and distributes the configuration information to the code sandbox test nodes.

[0122] In the above process, the embodiments of the present invention can quickly find possible optimization solutions within a reasonable range by generating optimization hypotheses and searching bounded space through the AutoResearch agent, and provide convenience for subsequent testing and implementation by generating AST code patches, thereby improving the efficiency of model optimization.

[0123] Step S302: Sandbox testing and result feedback.

[0124] Specifically, after receiving configuration information and code patches from the AutoResearch agent, the code sandbox test node executes test tasks in an isolated environment. The code patches are integrated into the model code, and the optimized model is tested using a specific test dataset.

[0125] Furthermore, after the test is completed, the test results are fed back to the AutoResearch agent and the multidimensional evaluation agent. If any anomalies or errors occur during the test, they will also be recorded in detail and relevant information will be provided.

[0126] In the above process, this embodiment of the invention ensures the security and stability of the testing process through isolated testing of code sandbox test nodes, avoiding the impact of problematic code on the main system. Simultaneously, timely feedback of results provides a basis for subsequent evaluation and decision-making, enabling the entire optimization process to proceed smoothly.

[0127] Step S303: Multidimensional assessment and bottleneck diagnosis.

[0128] Specifically, after receiving the test results from the code sandbox test node, the multidimensional evaluation agent first performs independent outflow set inference, uses an independent test dataset to evaluate the optimized model, and obtains the model's performance metrics on the new data.

[0129] Furthermore, fine-grained error clustering and attribution analysis is performed on errors occurring during the model's inference process to identify the causes and patterns of these errors. A detailed analysis report is generated based on the results, clearly identifying bottlenecks and optimization directions for the model. If the evaluation results show unsatisfactory optimization or serious problems, the multidimensional evaluation agent will trigger a conditional fallback mechanism, notifying the AutoResearch agent to self-correct the code or regenerate optimization hypotheses.

[0130] In the above process, the embodiments of the present invention, through comprehensive evaluation and in-depth analysis of the multi-dimensional evaluation agent, can accurately identify the problems and bottlenecks in the model, providing clear guidance for subsequent optimization. The conditional rollback mechanism ensures that adjustments can be made in a timely manner when the optimization effect is unsatisfactory, avoiding the continuation of invalid or erroneous optimization.

[0131] Step S304: Optimization, iteration and continuous improvement.

[0132] Specifically, the AutoResearch agent re-examines and adjusts the optimization hypotheses based on the analysis report and conditional rollback information provided by the multidimensional evaluation agent. If necessary, it generates new optimization hypotheses and AST code patches, which are then redeployed to the code sandbox test nodes for testing and evaluation.

[0133] Furthermore, repeat steps S302-S303 above, continuously optimizing and iterating until the model's performance reaches the expected target or meets application requirements.

[0134] In the above process, through continuous optimization and iteration, the embodiments of the present invention can continuously improve the performance and quality of the model, enabling the model to better adapt to different application scenarios and needs. The continuous improvement mechanism ensures that the model always remains in an optimal state, improving the model's practicality and competitiveness.

[0135] In one application scenario, the system is used to train and optimize a visual algorithm model for detecting surface defects in automotive parts.

[0136] Specifically, it may include the following steps: Step 1: Data collection and labeling.

[0137] Specifically, on the automotive parts production line, high-definition cameras collect a large amount of surface image data of automotive parts. These images include normal surfaces as well as surfaces with different types of defects such as scratches, dents, and bubbles. Using the annotation agent in Module 1, based on the positive case RAG, the collected image data is initially annotated to mark the specific location and type of defects.

[0138] Furthermore, the adjudicating agent rigorously verifies the annotation results of the annotation agent based on the negative error log (RAG). If inaccurate annotations are found, the annotation agent is forced to re-annotate using dynamic temperature scaling control until the preset confidence level is reached, thereby generating a high-quality labeled dataset.

[0139] In the above process, the embodiments of the present invention effectively improve the accuracy and efficiency of data labeling through the collaborative work of the labeling agent and the adjudication agent, as well as the RalphLoop trial-and-error loop mechanism, providing a reliable data foundation for subsequent model training.

[0140] Step 2: Model initialization and training.

[0141] Specifically, the labeled data is input into the global state machine, which manages and allocates the data, distributing the training tasks to Module 2. The training configuration agent is configured with appropriate model structures (such as convolutional neural networks) and training parameters (such as learning rate, batch size, etc.) based on the characteristics and requirements of surface defect detection of automotive parts.

[0142] Furthermore, the distributed self-healing training engine is activated, utilizing distributed computing resources to train the model. During training, the monitoring and scheduling agent monitors hardware status in real time, including GPU memory usage, node topology, and core scalar features such as the global gradient norm. Upon detecting an anomaly, such as CUDA memory overflow, a hot-fix action is immediately triggered, dynamically adjusting hyperparameters and restarting the computation graph. Simultaneously, residual memory processes are cleaned up, and the training task is reinitialized and restarted to ensure the stability of the training process.

[0143] In the above process, the embodiments of the present invention achieve stable training of the model through an automated fine-tuning and self-healing system, reduce training interruptions caused by hardware problems or training anomalies, and improve training efficiency.

[0144] Step 3: Model evaluation and optimization.

[0145] Specifically, after training is completed, the evaluation attribution points in Module 3 comprehensively evaluate the model, analyze the model's performance indicators such as accuracy and recall when detecting different types of defects, and identify the performance bottlenecks of the model, such as poor detection performance for certain minor defects.

[0146] Furthermore, based on the evaluation results, the automated development node generates optimization hypotheses within a predefined optimizer library, loss function space, and network fine-tuning layers. For example, it might try different optimizers or adjust the weights of the loss function. Model parameters are adjusted and optimized within a bounded search space. The optimized model code is then replaced with underlying code nodes using Abstract Syntax Tree (AST) parsing technology and tested in a code sandbox testing node. During testing, potential syntax errors are automatically corrected, and the benefits of the hypotheses are verified, ensuring that the optimized model's performance is improved and its reliability is guaranteed.

[0147] In the above process, the embodiments of the present invention realize the continuous optimization and improvement of the model through the automatic evolution system of model evolution, thereby improving the model's ability to detect surface defects of automotive parts.

[0148] Step 4: Human intervention and adjustment.

[0149] Specifically, during model training and optimization, the Asynchronous Human On-the-Road Bus (HITL) is always on standby. When the system encounters complex problems, such as the model's detection performance being unsatisfactory under certain special operating conditions, or when special adjustments to the model's detection criteria are needed, human experts intervene in the system through HITL. For example, experts can adjust the model's detection thresholds or modify the model's judgment logic for certain defect types.

[0150] Furthermore, the modification intentions of human experts are recorded in detail and fed back into the system for further optimization and improvement of the model, ensuring that the model can meet the actual industrial production needs.

[0151] In the above process, the embodiments of the present invention realize effective collaboration between humans and the system through asynchronous human-to-human bus, improve the flexibility and adaptability of the system, and enable the model to better cope with complex industrial scenarios.

[0152] Through the above process, this embodiment of the invention uses the training and optimization of a visual algorithm model for surface defect detection of automotive parts in the automotive manufacturing industry as a specific application scenario, demonstrating in detail the operation process of this system. High-quality labeled data is obtained through data annotation and network purification in Module 1; the automated fine-tuning and self-healing system in Module 2 ensures the stability and efficiency of model training; the automatic model evolution system in Module 3 enables continuous model optimization; and the asynchronous human-in-the-way bus ensures effective collaboration between humans and the system in complex situations. This system significantly improves the accuracy and efficiency of surface defect detection of automotive parts, reduces labor costs, provides strong technical support for quality control in the automotive manufacturing industry, and also provides a referable example for the production and optimization of visual algorithms in other industrial fields.

[0153] In one application scenario, the proposed automated distillation and evolution system for large visual models based on multi-agent collaboration is used in the field of intelligent security. This system employs a non-blocking multi-agent collaborative scheduling architecture based on a directed cyclic graph (DCG) and a global state machine. It unifies and abstracts the entire lifecycle of visual algorithm production (data purification, fine-tuning training, and architecture evolution) into a self-evolving directed cyclic graph execution network. Different agents achieve complex context transfer and collaboration through reading and writing a strongly typed global graph state object that runs throughout the entire process.

[0154] First, the intelligent security monitoring system automatically labels a large number of surveillance videos to identify abnormal behaviors (such as intrusions and fights). However, surveillance videos often contain complex scenes such as occlusion and backlighting, causing the large model to produce "visual illusions" and generate inaccurate labels. Therefore, the system adopts a dual-track retrieval augmentation (DAG) and adversarial trial-and-error loop: the labeling agent retrieves relevant information from a positive knowledge base (containing standard success cases and SOP text) to generate initial labels with thought chains. For example, for labeling "intrusion" behavior, the labeling agent will refer to features in historical success cases, such as human body contours and movement trajectories.

[0155] The referee agent retrieves relevant information from the negative knowledge base (containing boundary red line rules and a wrong answer notebook) and verifies the annotation results. If annotation errors or illusory data are found, the referee agent generates a traceback log containing error codes and visual guidance prompts.

[0156] Dynamic temperature scaling control: During the trial-and-error loop, if the referee agent determines the labeling result is unqualified, the system dynamically adjusts the generation parameters of the labeling agent according to the dynamic control formula Tt=min(T0+αt,Tmax), prompting it to re-label until the preset accuracy requirement is met. For example, T0 is set to 1.0, the step size factor α is set to -0.1, and the maximum number of retries is set to 10. By gradually reducing the parameters, the system guides the labeling agent to escape local optima, thereby improving labeling accuracy.

[0157] Furthermore, after obtaining high-quality labeled data, the model is fine-tuned and trained to generate a lightweight small model suitable for deployment on edge devices. However, the uneven distribution of surveillance video data and limited hardware resources can easily lead to anomalies such as CUDA memory overflow (OOM) or gradient NaN during training.

[0158] Therefore, this system employs a Hardware Ralph Loop: The training and configuration agent dynamically derives and fine-tunes hyperparameters, such as batch size and learning rate, based on data characteristics and hardware constraints. For example, for edge devices with limited GPU memory, a Parameter Efficient Fine-Tuning (PEFT) strategy, such as LoRA dimensionality reduction, is automatically adopted.

[0159] During training, if anomalies such as CUDA memory overflow or gradient NaN are detected, the system does not throw a crash signal. Instead, it intercepts the traceback, triggers hardware rollback edges, automatically executes computational degradation strategies (such as dynamic halving of batch size), and reinitializes the computation graph. Simultaneously, it supports fine-grained listening based on global gradient norm monitoring, triggering dynamic hyperparameter hot-fix and model rollback when abnormal trends are detected.

[0160] Furthermore, after basic fine-tuning, the model performance is further optimized to cope with constantly changing monitoring scenarios. Traditional methods rely on manual parameter tuning, which has limited exploration space and is inefficient.

[0161] Therefore, the system adopts a bounded automated architecture evolution based on clustering attribution and AST code injection: multi-dimensional evaluation and error clustering attribution: a multi-dimensional evaluation system is set up to perform attribution analysis on the model and generate reports. For example, unsupervised clustering algorithms are used to discover failure modes of the model, such as "low recognition rate of small targets in backlit scenes".

[0162] The Auto-Research agent generates optimization hypotheses within a predefined optimizer library and loss function space based on the report. For example, it proposes hypotheses such as "switching the optimizer from SGD to AdamW and adjusting the learning rate decay strategy".

[0163] AST Code Injection and Sandbox Experimentation: This involves securely replacing underlying code nodes using Abstract Syntax Tree (AST) technology, performing A / B tests in a micro-computing sandbox, and verifying hypothetical benefits. For example, optimizing optimizer configurations can be modified via AST, and model performance under the new configuration can be tested in the sandbox.

[0164] Human experts are introduced during model training and optimization to review data and handle anomalies. However, traditional synchronous blocking designs can lead to idle computing power and reduced system throughput. Therefore, this invention abstracts human experts as asynchronous arbitration nodes outside the computation graph, receiving control commands through a global message bus. When the system encounters extreme anomalies or requires architecture merging approval, the current task is serialized and suspended, instantly releasing the underlying GPU and CPU computing power for the next task.

[0165] Furthermore, after human experts process tasks asynchronously, the system wakes up the task through deserialization and reverse-engineers the expert's gold standard intent (such as bounding box correction, code approval, or rejection constraints). For example, if an expert corrects a false bounding box in a backlit scene, the system writes this correction intent into the global state object to guide subsequent model training.

[0166] Through the above process, this invention achieves an efficient, stable, and automated visual algorithm production process in an intelligent security monitoring system. The data purification stage significantly improves annotation accuracy, the fine-tuning training stage enhances model robustness, the architecture evolution stage breaks through performance ceilings, and the introduction of human expert mechanisms achieves optimal utilization of computing power. Ultimately, the lightweight visual model generated by the system performs excellently on edge devices, effectively improving the overall performance of the intelligent security system.

[0167] The following are embodiments of the apparatus of the present invention, which can be used to execute the model distillation and evolution method involved in the present invention. For details not disclosed in the embodiments of the apparatus of the present invention, please refer to the method embodiments of the model distillation and evolution method involved in the present invention.

[0168] Please see Figure 6 This invention provides a model distillation and evolution apparatus 800.

[0169] The model distillation and evolution device 800 includes, but is not limited to: an agent adversarial purification module 810, a hardware perception training module 830, a model verification and optimization module 850, and an asynchronous expert arbitration module 870.

[0170] Among them, the agent adversarial purification module 810 is used to design a trial-and-error loop mechanism for the labeling agent and the referee agent to construct data labeling. Based on the trial-and-error loop mechanism, the initial labeled data generated by the teacher model is adversarially purified to obtain the distilled dataset. The labeling agent and the referee agent coordinate their states through a global state object.

[0171] The hardware-aware training module 830 encapsulates distributed training technology into a training module that can be called by large models. It combines hardware state awareness and automatic adjustment mechanism of training strategy to train student models based on distillation dataset and handles anomalies during training. The training module interacts with information through global state object.

[0172] The model validation and optimization module 850 is used to perform error pattern analysis on student models by setting up a multi-dimensional evaluation system, generate analysis reports, propose optimization hypotheses based on the analysis reports, dynamically modify model parameters within a preset parameter adjustment range, and iteratively optimize the architecture of student models by combining model experiments and code correction.

[0173] The asynchronous expert arbitration module 870 is used to set the interaction of human experts as asynchronous decision control points during the training process, and to receive control instructions from human experts through the global message bus. When an exception occurs, the current task is serialized and suspended and the computing power is released. After the exception is handled, the task is deserialized and woken up and responds to the control instructions.

[0174] It should be noted that the model distillation and evolution provided in the above embodiments are only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed. That is, the internal structure of the model distillation and evolution device will be divided into different functional modules to complete all or part of the functions described above.

[0175] Furthermore, the embodiments of the model distillation and evolution apparatus and the model distillation and evolution method provided in the above embodiments belong to the same concept, and the specific way in which each module performs its operation has been described in detail in the method embodiments, and will not be repeated here.

[0176] Figure 7 A schematic diagram of the structure of an electronic device according to an exemplary embodiment is shown.

[0177] It should be noted that this electronic device is merely an example adapted to the present invention and should not be construed as providing any limitation on the scope of use of the present invention. Furthermore, this electronic device should not be interpreted as requiring or depending on having... Figure 7 One or more components of the exemplary electronic device 2000 shown.

[0178] The hardware structure of electronic devices 2000 can vary significantly due to differences in configuration or performance, such as... Figure 7 As shown, the electronic device 2000 includes: a power supply 210, an interface 230, at least one memory 250, and at least one central processing unit (CPU) 270.

[0179] Specifically, power supply 210 is used to provide operating voltage for various hardware devices on electronic device 2000.

[0180] Interface 230 includes at least one wired or wireless network interface 231 for interacting with external devices. Of course, in other examples adapted to this invention, interface 230 may further include at least one serial-to-parallel conversion interface 233, at least one input / output interface 235, and at least one USB interface 237, etc. Figure 7 As shown, this does not constitute a specific limitation.

[0181] The memory 250 serves as a carrier for resource storage and can be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored on it include the operating system 251, application programs 253, and data 255, etc., and the storage method can be temporary storage or permanent storage.

[0182] The operating system 251 is used to manage and control the various hardware devices and application programs 253 on the electronic device 2000, so as to enable the central processing unit 270 to perform calculations and processing on the massive data 255 in the memory 250. It can be Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0183] Application 253 is a computer-readable instruction based on operating system 251 that performs at least one specific task, and may include at least one module ( Figure 7 (Not shown), each module may contain computer-readable instructions for the electronic device 2000. For example, the model distillation and evolution device can be considered as application program 253 deployed on the electronic device 2000.

[0184] Data 255 may be signal information, etc., and is stored in memory 250.

[0185] The central processing unit 270 may include one or more processors and is configured to communicate with the memory 250 via at least one communication bus to read computer-readable instructions stored in the memory 250, thereby performing operations and processing on massive amounts of data 255 stored in the memory 250. For example, the model distillation and evolution method may be performed by the central processing unit 270 reading a series of computer-readable instructions stored in the memory 250.

[0186] Furthermore, the present invention can also be implemented through hardware circuits or a combination of hardware circuits and software. Therefore, the implementation of the present invention is not limited to any specific hardware circuit, software, or combination thereof.

[0187] Please see Figure 8 This invention provides an electronic device 4000, which may include: a desktop computer, a laptop computer, a server, etc., with sensor recognition capabilities.

[0188] exist Figure 8 In this context, the electronic device 4000 includes at least one processor 4001 and at least one memory 4003.

[0189] The data interaction between the processor 4001 and the memory 4003 can be achieved through at least one communication bus 4002. This communication bus 4002 may include a path for transmitting data between the processor 4001 and the memory 4003. The communication bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The communication bus 4002 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0190] Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present invention.

[0191] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this invention. Processor 4001 may also be a combination that implements computing functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0192] The memory 4003 may be a ROM (Read Only Memory) or other type of static storage device capable of storing static information and instructions, RAM (Random Access Memory) or other type of dynamic storage device capable of storing information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program instructions or code in the form of instructions or data structures and accessible by the electronic device 4000, but not limited thereto.

[0193] The memory 4003 stores computer-readable instructions, and the processor 4001 can read the computer-readable instructions stored in the memory 4003 through the communication bus 4002.

[0194] The computer-readable instructions are executed by one or more processors 4001 to implement the model distillation and evolution methods in the above embodiments.

[0195] Furthermore, this embodiment of the invention provides a storage medium storing computer-readable instructions, which are executed by one or more processors to implement the model distillation and evolution method as described above.

[0196] This invention provides a computer program product including computer-readable instructions stored in a storage medium. One or more processors of an electronic device read the computer-readable instructions from the storage medium, load and execute the computer-readable instructions, thereby enabling the electronic device to implement the model distillation and evolution method as described above.

[0197] Compared with related technologies, the beneficial effects of the present invention are: 1. This invention significantly improves the accuracy and efficiency of data annotation. By designing a trial-and-error loop mechanism for annotation and referee agents, and combining it with external decision-making by human experts, it achieves automated purification of the initial annotation data generated by the teacher model. This mechanism not only reduces the workload of manual annotation but also significantly improves the accuracy of annotation through multiple rounds of trial and error and feedback, providing a high-quality data foundation for subsequent model training.

[0198] 2. This invention possesses strong model training stability and robustness. By encapsulating distributed training technology and combining it with hardware state awareness and automatic training strategy adjustment mechanisms, it achieves efficient and stable training of student models. During training, the system can monitor the hardware status in real time and automatically adjust the training strategy accordingly, effectively avoiding hardware resource overload and training interruptions. Simultaneously, the introduction of an anomaly handling mechanism ensures the continuity and stability of the training process, enabling rapid recovery even in the event of hardware failures or gradient explosion, thus improving training efficiency and success rate.

[0199] 3. This invention enables precise evaluation of model performance and bottleneck identification. By establishing a multi-dimensional evaluation system and error mode analysis method, it achieves comprehensive evaluation and precise identification of student model performance. The multi-dimensional evaluation system assesses model performance from multiple perspectives, ensuring the comprehensiveness and accuracy of the evaluation results. The error mode analysis method can uncover specific failure modes of the model, providing a clear direction and basis for subsequent model optimization.

[0200] 4. This invention significantly improves the upper limit of model performance and optimization efficiency. By proposing optimization hypotheses, dynamically modifying model parameters, and combining model experiments with code correction methods, iterative optimization of the student model architecture is achieved. This step not only increases the upper limit of model performance but also ensures the correctness and effectiveness of the optimization direction through rigorous experimental verification. Simultaneously, the application of Abstract Syntax Tree (AST) parsing technology makes code modification safer and more reliable, avoiding model training failures due to code errors and significantly improving optimization efficiency.

[0201] 5. This invention possesses flexibility and scalability. By introducing human experts as external decision-making nodes and setting asynchronous decision control points during model training and optimization, this invention can flexibly respond to various complex scenarios and requirements. The introduction of human experts not only improves the accuracy and reliability of model optimization but also enables the system to be flexibly adjusted and optimized according to actual needs. Simultaneously, the setting of asynchronous decision control points ensures the stability and efficiency of the system under high-concurrency scenarios, providing strong support for system expansion and application.

[0202] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0203] The above description is only a partial embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A model distillation and evolution method, characterized in that, The method includes: Design an annotation agent and a referee agent; the annotation agent is used to generate annotations with thought chains based on the initial annotation data generated by the teacher model according to the positive knowledge base; the referee agent is used to verify the annotations based on the negative knowledge base; A trial-and-error loop mechanism is established between the labeling agent and the referee agent. When the labeling is unqualified, relevant information is fed back to the labeling agent. The labeling parameters of the labeling agent are dynamically adjusted based on the number of retries through a preset dynamic adjustment mechanism, and the labeling is re-labeled until the preset accuracy requirement is met. The calculation formula for the dynamic adjustment mechanism is: ,in, This represents the annotation parameters of the annotation agent during the t-th retry. This represents the initial annotation parameters. This represents the step size decay or amplification factor for each retry, used to determine the rate at which the labeled parameter changes with the number of retries, where t represents the number of retries. This indicates the upper limit value of the annotation parameter; Based on the aforementioned trial-and-error loop mechanism, the initial labeled data generated by the teacher model is adversarially purified to obtain a distilled dataset; the labeling agent and the referee agent coordinate their states through a global state object. Distributed training technology is encapsulated into a training module that can be called by large models. The student model is trained based on the distillation dataset by combining hardware state awareness and automatic adjustment mechanism of training strategy, and anomalies are handled during the training process. The training module interacts with information through a global state object. After the student model is trained, a multi-dimensional evaluation system is set up to test the student model based on the test set to obtain test results; the multi-dimensional evaluation system includes accuracy, recall and F1 score. An unsupervised clustering algorithm is used to perform error pattern analysis on the erroneous samples in the test results to obtain model failure modes, and an analysis report is generated based on the model failure modes; the model failure modes include recognition errors in specific scenarios. Based on the analysis report, optimization hypotheses are proposed, model parameters are dynamically modified within a preset parameter adjustment range, and the architecture of the student model is iteratively optimized by combining model experiments and code correction. During training, the interaction with human experts is set as an asynchronous decision control point, and the control instructions of the human experts are received through a global message bus. When an anomaly occurs, the current task is serialized and suspended and the computing power is released. After the anomaly is handled, the task is deserialized and woken up to respond to the control instructions.

2. The model distillation and evolution method as described in claim 1, characterized in that, The process of encapsulating distributed training technology into a training module that can be called by large models, and training the student model based on the distillation dataset using a hardware state-aware and automatic training strategy adjustment mechanism, includes: Distributed training technology is encapsulated into a training module that can be called by large models. The training module is used to train the student model based on the distillation dataset. During the training process, the hardware status is monitored in real time, and the model training strategy is adjusted according to the hardware status. The penalty weight in the loss function is adjusted based on the distribution characteristics of the training data. The hardware status includes GPU memory usage and computing node load.

3. The model distillation and evolution method as described in claim 1, characterized in that, The handling of anomalies during training includes: When an anomaly is detected during training, it is handled according to a preset anomaly handling strategy and the training strategy is adjusted accordingly. The anomalies include memory anomalies, computing node failures, and gradient explosion. The anomaly handling strategy includes dynamically adjusting the batch size and transferring training tasks. The daemon process takes over error output in real time. When the engine malfunctions, it immediately intercepts the error message and executes a preset computing power degradation strategy based on the error message. After modifying the configuration, it initializes and restarts the training task. The computing power degradation strategy includes dynamically adjusting the batch size, adjusting the gradient accumulation steps, and dynamically adjusting the model dimension. Based on a callback mechanism, key indicators during the training process are monitored at the training step or training cycle level. When an abnormal trend is detected, a hot-fix action is triggered. The key indicators include the global gradient norm. The hot-fix action includes dynamically adjusting the learning rate and increasing weight decay.

4. The model distillation and evolution method as described in claim 1, characterized in that, The process of proposing optimization hypotheses based on the analysis report, dynamically modifying model parameters within a preset parameter adjustment range, and iteratively optimizing the architecture of the student model by combining model experiments and code correction includes: Based on the analysis report, targeted optimization hypotheses are proposed. The parameters of the student model are dynamically modified within a predefined optimizer library, loss function space, and network fine-tuning layer. The optimization effect is verified by combining model experiments. The optimization hypotheses include adjusting the model structure and optimizing hyperparameters. Abstract Syntax Tree (AST) parsing technology is used to replace the underlying code nodes. Micro-A / B testing is performed in an isolated computing sandbox to fix syntax errors and verify hypothetical benefits. The underlying code nodes include optimizers and loss functions. The syntax errors include tensor dimension mismatch and operator incompatibility.

5. A model distillation and evolution apparatus, characterized in that, The device includes: The agent adversarial purification module is used to design a trial-and-error loop mechanism for the labeling agent and the referee agent to construct data labeling. Based on the trial-and-error loop mechanism, the initial labeled data generated by the teacher model is adversarially purified to obtain a distilled dataset. The labeling agent and the referee agent coordinate their states through a global state object. The hardware-aware training module encapsulates distributed training technology into a training module that can be called by large models. It trains student models based on the distillation dataset by combining hardware state awareness and automatic adjustment of training strategies, and handles anomalies during the training process. The training module interacts with information through a global state object. The model validation and optimization module is used to perform error pattern analysis on the student model by setting up a multi-dimensional evaluation system, generate an analysis report, propose optimization hypotheses based on the analysis report, dynamically modify the model parameters within a preset parameter adjustment range, and iteratively optimize the architecture of the student model by combining model experiments and code correction. The asynchronous expert arbitration module is used to set the interaction of human experts as asynchronous decision control points during the training process, and to receive the control instructions of the human experts through the global message bus. When an exception occurs, the current task is serialized and suspended and the computing power is released. After the exception is handled, the task is deserialized and woken up and responds to the control instructions.

6. An electronic device, characterized in that, include: At least one processor and at least one memory, wherein, The memory stores computer-readable instructions; The computer-readable instructions are executed by one or more of the processors, causing the electronic device to implement the model distillation and evolution method as described in any one of claims 1 to 4.

7. A storage medium having computer-readable instructions stored thereon, characterized in that, The computer-readable instructions are executed by one or more processors to implement the model distillation and evolution method as described in any one of claims 1 to 4.