Model distillation method and system based on teacher model and situational reasoning

Through a model distillation method combining context-aware mechanisms and inference chain strategies in the multi-teacher learning framework, resource consumption and performance problems in multi-model and multi-task collaborative optimization are solved, and efficient model deployment and update on resource-constrained devices are achieved.

CN119539011AInactive Publication Date: 2025-02-28FUDAN UNIVERSITY

Patent Information

Application Number
CN202510080881.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-02-28
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing knowledge distillation technology has shortcomings in the collaborative optimization of multi-model and multi-tasks. Especially on mobile devices, traditional methods are difficult to directly apply due to data heterogeneity and imbalance, resulting in poor model performance and high resource consumption.

Method used

The model distillation method based on teacher model and situational reasoning is adopted, and the student model is learned from multiple large teacher models through a multi-teacher learning framework. Combining the context perception mechanism and teacher-forced reasoning chain strategy, the reasoning process of the student model is optimized, and resource consumption is reduced through efficient parameter fine-tuning technology.

Benefits of technology

It significantly reduces resource consumption during model deployment and update, so that the trained model maintains similar performance to the model, improves the generalization and reasoning capabilities of the student model, and is suitable for devices with resource constraints.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119539011A_ABST
    Figure CN119539011A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of natural language processing, in particular to a model distillation method and system based on a teacher model and situational reasoning. By using a multi-teacher learning framework, the student model can draw knowledge from a plurality of large teacher models, and diversified learning paths are provided for the student model; due to the introduction of a context awareness and example generation mechanism, the understanding and reasoning ability of a student model to a complex situation is enhanced by considering context information of input data and an input example; the reasoning chain strategy can ensure that the student model can generate an accurate and deep reasoning process, and the decision process of the teacher model is simulated; a parameter fine adjustment technology is adopted, only key parameters in the student model are adjusted, efficient migration of teacher model knowledge is achieved, and the number of parameters needing to be adjusted in the distillation process of the student model is reduced; the resource consumption in the model deployment and updating process is remarkably reduced, so that the trained model keeps the performance similar to that of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a model distillation method and system based on a teacher model and contextual reasoning. Background Art

[0002] In the field of natural language processing (NLP), especially on resource-constrained mobile devices, deploying efficient language models faces significant challenges. In order to enable these devices to run complex language understanding tasks, researchers have proposed a variety of knowledge distillation techniques, aiming to improve the performance of models in resource-constrained environments through model compression and acceleration. However, most existing knowledge distillation techniques focus on the optimization of a single model, ignoring the need for collaborative optimization of multiple models and multiple tasks in practical applications. In addition, the heterogeneity and imbalance of data on mobile devices further increase the complexity of knowledge distillation, which limits the further improvement of model performance. Previous knowledge distillation methods are mainly performed between a single teacher-student model pair, and the student model is trained by imitating the behavior of the teacher model. These methods are effective in single model compression, but in multi-model environments, especially in mobile device scenarios, traditional methods are difficult to apply directly due to device diversity and inconsistency in data distribution. In addition, differences in communication and computing capabilities between mobile devices also make it complicated to implement effective knowledge distillation strategies on these devices. Previous model aggregation algorithms often lead to poor model performance and require more communication rounds to converge when processing non-independent and identically distributed data due to the lack of consideration of data diversity.

[0003] In order to solve the above problems, researchers have tried to introduce the concepts of multi-task learning and knowledge distillation to achieve collaborative optimization among multiple models. These methods allow different models to share knowledge by exchanging knowledge between mobile devices, thereby improving performance. However, when dealing with data heterogeneity and imbalance, these methods often adopt simple data sampling or model averaging strategies, which cannot fully consider the differences in data distribution and may cause the model to prefer certain data categories, thereby affecting the generalization ability of the model. In addition, existing multi-model collaborative optimization methods are also insufficient in resource scheduling. Since the computing power and network conditions of mobile devices are dynamically changing, fixed-frequency knowledge distillation and resource allocation strategies may not be able to adapt to these changes, resulting in resource waste or inefficient model training. Some methods may still perform knowledge distillation when the network conditions are poor, which not only increases communication overhead, but also may affect model performance due to incomplete data transmission.

[0004] Therefore, traditional knowledge distillation methods often consume a lot of resources and there are performance differences between trained models. Summary of the invention

[0005] Based on this, in order to solve the above technical problems, a model distillation method and system based on teacher model and contextual reasoning are provided, which can reduce resource consumption during model deployment and updating, so that the trained model maintains performance similar to the model.

[0006] A model distillation method based on a teacher model and contextual reasoning, the method comprising: Acquiring input data, preprocessing the input data, and extracting feature data from the input data; Using a context-aware mechanism to perform semantic analysis on the feature data to obtain context information; using a context example generator to generate a target example corresponding to the feature data, and using the target example to enrich the context information to obtain target context information; According to the target context information, each student model learns from each teacher model based on a multi-teacher learning framework, and generates a preliminary answer corresponding to the target example through each student model; Generate a reasoning process according to the preliminary answer using the reasoning chain strategy of the teacher model, and determine a final answer corresponding to the input data according to the reasoning process and the preliminary answer; According to the final answer, key parameters in the student model are fine-tuned to complete the optimization of the multi-teacher learning framework.

[0007] In one embodiment, the method further comprises: Obtaining multiple pre-trained teacher models, each teacher model corresponding to different knowledge and reasoning strategies; Each student model interacts with each teacher model through a knowledge distillation process, and each student model learns to imitate the instructions of each teacher model; Introducing a context-aware mechanism, and integrating context information into each of the student models for training based on the context-aware mechanism; The reasoning chain strategy of each teacher model is set, and based on the reasoning chain strategy, each student model is guided to learn the reasoning steps of each teacher model to complete the construction of a multi-teacher learning framework.

[0008] In one embodiment, the feature data is semantically analyzed using a context-aware mechanism to obtain context information including: Inputting the feature data into a pre-trained word embedding model, and obtaining a vector representation of each word through the word embedding model; Each of the vector representations is input into a dynamic context modeling network based on an attention mechanism to generate a context vector and obtain context information.

[0009] In one embodiment, the method further comprises: Obtain a sequence-to-sequence model, input the input data, the vector representation, and the context vector into the sequence-to-sequence model, and generate an inference chain that considers context information; Modifying and adjusting the inference chain, so that each of the student models learns the inference chain strategy of each of the teacher models based on the modified inference chain; The context-aware mechanism is integrated into the training process of each of the student models to complete the training of each of the student models.

[0010] In one embodiment, a context example generator is used to generate a target example corresponding to the feature data, and the target example is used to enrich the context information to obtain the target context information, including: Inputting the feature data into the context example generator, the context example generator randomly selects candidate examples from the data set; the candidate examples and the feature data belong to the same data distribution; Input the candidate examples into a context example generator function to generate a set of context examples as target examples; The context information is enriched using the target example to obtain target context information.

[0011] In one embodiment, the method further comprises: Each of the student models determines a feature representation through a feature extraction function, and inputs the feature representation into a knowledge base of each of the teacher models; Retrieving each knowledge point corresponding to the feature representation through the knowledge base; Each of the student models uses a logical reasoning mechanism to reason about each of the knowledge points and generate each intermediate conclusion; Connect the various intermediate conclusions to construct a student model reasoning chain.

[0012] In one embodiment, the method further comprises: Determine a true reasoning chain, compare the true reasoning chain with the student model reasoning chain, and obtain a comparison result; Constructing a loss function for the student model reasoning chain according to the comparison result and the reasoning chain strategy of each teacher model; Based on the loss function, parameters of the student model are updated.

[0013] In one embodiment, fine-tuning key parameters in the student model according to the final answer to complete the optimization of the multi-teacher learning framework includes: identifying key parameters in the student model based on the final answer; Obtaining a first parameter in the student model, a second parameter in the teacher model, and a first loss function of the student model; Constructing a parameter fine-tuning strategy according to the key parameter, the first parameter, the second parameter, and the first loss function; The parameter fine-tuning strategy is used to fine-tune key parameters in the student model.

[0014] In one embodiment, the method further comprises: Determine the learning rate in the student model, and adjust the learning rate using an exponential decay function to complete parameter update optimization of the student model; Using regularization technology to process the student model after parameter update optimization, to obtain a processed student model; The parameter fine-tuning strategy is iteratively used to fine-tune the key parameters in the processed student model to obtain a target student model.

[0015] A model distillation system based on a teacher model and contextual reasoning, the system comprising: A data processing module, used to obtain input data, pre-process the input data, and extract feature data from the input data; A context-aware and example generation mechanism module is used to perform semantic analysis on the feature data using a context-aware mechanism to obtain context information; use a context example generator to generate a target example corresponding to the feature data, and use the target example to enrich the context information to obtain target context information; A distillation module, configured to learn from each teacher model based on a multi-teacher learning framework according to the target context information, and generate a preliminary answer corresponding to the target example through each student model; An inference chain using module, used to generate an inference process according to the preliminary answer using the inference chain strategy of the teacher model, and determine a final answer corresponding to the input data according to the inference process and the preliminary answer; A parameter fine-tuning module is used to fine-tune key parameters in the student model according to the final answer to complete the optimization of the multi-teacher learning framework.

[0016] The above-mentioned model distillation method and system based on teacher model and contextual reasoning, by using a multi-teacher learning framework, enables the student model to absorb knowledge from multiple large teacher models, and each teacher model contributes its unique knowledge system and reasoning strategy, thereby providing a diversified learning path for the student model; due to the introduction of context perception and example generation mechanism, by considering the contextual information of input data and input examples, the student model's understanding and reasoning ability of complex situations are enhanced; in addition, the reasoning chain strategy can ensure that the student model can generate accurate and in-depth reasoning processes, imitating the decision-making process of the teacher model; using parameter fine-tuning technology, only the key parameters in the student model are adjusted to achieve efficient transfer of teacher model knowledge and reduce the number of parameters that need to be adjusted in the student model during the distillation process; significantly reducing the resource consumption during model deployment and updating, so that the trained model maintains similar performance to the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is an application environment diagram of a model distillation method based on a teacher model and contextual reasoning in one embodiment; Figure 2 A schematic diagram of a flow chart of a model distillation method based on a teacher model and contextual reasoning in one embodiment; Figure 3 is a structural block diagram of a model distillation system based on a teacher model and contextual reasoning in one embodiment; Figure 4 A schematic diagram of a multi-teacher learning framework structure in one embodiment; Figure 5 A schematic diagram of the context perception and example generation mechanism structure in one embodiment; Figure 6 A schematic diagram of the structure of a teacher-enforced reasoning chain strategy in one embodiment; Figure 7 A schematic diagram of an efficient parameter fine-tuning structure in an embodiment; Figure 8 is a schematic diagram of the structure of a model distillation system based on a teacher model and contextual reasoning in another embodiment; Fig. 9 A schematic diagram of a process for automated question and answering applied in an intelligent customer service system in one embodiment; Fig.10 is a schematic diagram of a flow chart of auxiliary diagnosis applied in a medical consultation system in one embodiment; Fig.11 A schematic diagram of a process for recommending a personalized learning path in an online education platform in one embodiment; Fig.12 A schematic diagram of a process of anomaly detection applied in intelligent manufacturing in one embodiment; Fig.13FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0018] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0019] The model distillation method based on teacher model and contextual reasoning provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Figure 1 As shown, the application environment includes a computer device 110. The computer device 110 can obtain input data, preprocess the input data, and extract feature data from the input data; the computer device 110 can use a context-aware mechanism to perform semantic analysis on the feature data to obtain context information; a context example generator is used to generate a target example corresponding to the feature data, and the target example is used to enrich the context information to obtain target context information; the computer device 110 can learn from each teacher model based on a multi-teacher learning framework according to the target context information, and generate a preliminary answer corresponding to the target example through each student model; the computer device 110 can use the teacher model's reasoning chain strategy to generate a reasoning process according to the preliminary answer, and determine the final answer corresponding to the input data according to the reasoning process and the preliminary answer; the computer device 110 can fine-tune the key parameters in the student model according to the final answer to complete the optimization of the multi-teacher learning framework. Among them, the computer device 110 can be, but is not limited to, various personal computers, laptops, smart phones, robots, unmanned aerial vehicles, tablet computers, portable wearable devices, etc.

[0020] In one embodiment, Figure 2 As shown, a model distillation method based on a teacher model and contextual reasoning is provided, including the following steps: Step 202: acquiring input data, preprocessing the input data, and extracting feature data from the input data.

[0021] The computer device can collect input data that needs to be distilled using the teacher model and the student model. For example, when the trained teacher model and the student model are applied in the intelligent customer service system, the input data can be the user's text query data; when the trained teacher model and the student model are applied in the medical consultation system, the input data can be the patient data; when the trained teacher model and the student model are applied in the education platform, the input data can be the learner's learning behavior data.

[0022] Next, the computer device can perform preprocessing operations on the collected input data. Specifically, the computer device can perform preprocessing according to the type of input data. For example, if the input data is text query data, the corresponding preprocessing may include word segmentation, removal of stop words, etc.; if the input data is patient data, the corresponding preprocessing may be extraction of key information, etc.; if the input data is learning behavior data, the corresponding preprocessing may be data cleaning, standardization, etc.

[0023] Step 204, using a context-aware mechanism to perform semantic analysis on the feature data to obtain context information; using a context example generator to generate a target example corresponding to the feature data, and using the target example to enrich the context information to obtain target context information.

[0024] In this embodiment, a context-aware mechanism can be introduced to obtain a more accurate and appropriate response by considering the context information of the input data. Specifically, a context example generator is also introduced to further enrich the context information by providing examples related to the current input, better understand the task context, and thus generate a more accurate and context-appropriate reasoning chain.

[0025] Step 206, according to the target context information, each student model learns from each teacher model based on a multi-teacher learning framework, and generates a preliminary answer corresponding to the target example through each student model.

[0026] Computer devices can adopt a multi-teacher learning framework, allowing the student model to learn from multiple teacher models, each of which represents a unique knowledge system and reasoning strategy, in this way, the student model can obtain broader knowledge coverage and deeper understanding.

[0027] Step 208, using the reasoning chain strategy of the teacher model to generate a reasoning process according to the preliminary answer, and determining the final answer corresponding to the input data according to the reasoning process and the preliminary answer.

[0028] The computer device can adopt the teacher-enforced reasoning chain strategy to ensure that the student model can generate accurate and in-depth reasoning processes when imitating the teacher model. The reasoning chain strategy improves the reasoning ability of the student model by guiding the student model to learn the reasoning steps of the teacher model.

[0029] Step 210, fine-tune the key parameters in the student model according to the final answer to complete the optimization of the multi-teacher learning framework.

[0030] In order to reduce the number of parameters that need to be adjusted in the student model during the distillation process, efficient parameter fine-tuning is adopted. By only adjusting the key parameters in the student model, efficient transfer of teacher model knowledge is achieved, while reducing the computational and storage requirements of the model.

[0031] In this embodiment, by using a multi-teacher learning framework, the student model can absorb knowledge from multiple large teacher models, and each teacher model contributes its unique knowledge system and reasoning strategy, thereby providing a diversified learning path for the student model; due to the introduction of context awareness and example generation mechanism, the student model's understanding and reasoning ability of complex situations are enhanced by considering the context information of the input data and the input examples; in addition, the reasoning chain strategy can ensure that the student model can generate accurate and in-depth reasoning processes, imitating the decision-making process of the teacher model; using parameter fine-tuning technology, only the key parameters in the student model are adjusted, to achieve efficient transfer of teacher model knowledge, and reduce the number of parameters that need to be adjusted in the student model during the distillation process; significantly reducing the resource consumption during model deployment and updating, so that the trained model maintains similar performance to the model.

[0032] In one embodiment, a model distillation method based on teacher models and situational reasoning is provided, which may also include a process of constructing a multi-teacher learning framework, and the specific process includes: obtaining multiple pre-trained teacher models, and the knowledge and reasoning strategies corresponding to each teacher model are different; each student model interacts with each teacher model through the knowledge distillation process, and each student model learns to imitate the instructions of each teacher model; introducing a context-aware mechanism, and integrating context information into each student model for training based on the context-aware mechanism; setting an reasoning chain strategy for each teacher model, and guiding each student model to learn the reasoning steps of each teacher model based on the reasoning chain strategy to complete the construction of the multi-teacher learning framework.

[0033] In the field of natural language processing, large models (LLMs) are valued for their powerful text generation and comprehension capabilities. However, these models consume a lot of resources, which limits their deployment on mobile devices and resource-constrained environments. To address this problem, knowledge distillation technology has emerged, which aims to train small student models by extracting knowledge from large teacher models. Existing knowledge distillation methods mostly use a single teacher model, which limits the ability of student models to acquire diverse knowledge. In addition, the lack of rich contextual information also affects the performance of student models on complex reasoning tasks. To this end, in this embodiment, the knowledge and reasoning capabilities of multiple large models are first integrated through a multi-teacher learning framework to enrich the learning resources of the student model. Each teacher model contributes knowledge with its unique perspective and expertise, thereby providing a diversified learning path for the student model.

[0034] Specifically, in the multi-teacher learning framework, each teacher model T mis represented by its parameterized neural network, where m belongs to the set {1, 2, ..., M}, M is the total number of teacher models, each of which is pre-trained and performs well on a specific task. The knowledge of the teacher model can be represented by its predictive distribution P(y|x, T m ), where y is the output label.

[0035] The student model S is a small neural network whose goal is to learn to imitate the knowledge of multiple teacher models. The knowledge distillation process can be formalized through the objective function, which can be expressed as: ;in, is a weight factor used to balance the contribution of different teacher models, and is a KL divergence loss function that measures the difference between the predicted distribution S(x) of the student model and the predicted distribution T of the teacher model. m The difference between (x).

[0036] In this embodiment, in order to improve the student model's ability to understand and reason about complex situations, a context-aware mechanism can be introduced to help the student model generate more accurate and appropriate responses by considering the context information of the input data. The context information can be integrated into the learning process of the student model, and the integration formula can be expressed as: ; where x i is the input sample, c i is the corresponding context information, y i is the true label, N is the total number of samples, is a KL divergence loss function.

[0037] In this embodiment, the teacher-enforced reasoning chain strategy is also adopted to ensure that the student model can generate accurate and in-depth reasoning processes when imitating the teacher model. The reasoning chain strategy improves the reasoning ability of the student model by guiding the student model to learn the reasoning steps of the teacher model. The generation formula of the reasoning chain can be expressed as: ; Among them, R m (x) is the inference chain generated by the teacher model m, is the corresponding real chain of reasoning, is the weight factor.

[0038] In order to reduce the number of parameters that need to be adjusted in the student model during the distillation process, this embodiment adopts efficient parameter fine-tuning. By only adjusting the key parameters in the student model, efficient transfer of teacher model knowledge is achieved, while reducing the model's computational and storage requirements. The fine-tuning process can be expressed as: ;in, and denote the parameters of the student model and the teacher model respectively, and is the subset of parameters that need to be adjusted.

[0039] Creating a multi-teacher learning framework can achieve the goal of student models efficiently learning from multiple teacher models. The multi-teacher learning framework can not only improve the generalization and reasoning capabilities of the student model, but also significantly reduce resource consumption during model deployment and updating, allowing the student model to run efficiently on resource-constrained devices while maintaining similar performance to large teacher models.

[0040] In one embodiment, a model distillation method based on a teacher model and contextual reasoning is provided, which may also include a process of using a context mechanism, and the specific process includes: inputting feature data into a pre-trained word embedding model, and obtaining a vector representation of each word through the word embedding model; inputting each vector representation into a dynamic context modeling network based on an attention mechanism, generating a context vector, and obtaining context information.

[0041] The use of contextual mechanisms aims to improve the student model’s understanding of the context of input data, thereby generating more accurate and appropriate responses in natural language processing tasks. The contextual mechanism helps the student model better capture the nuances and deep meaning of language by considering the contextual information of the input data.

[0042] In natural language processing, context information usually refers to words that are semantically related to the target word or phrase. This information is crucial for understanding word meaning, disambiguation, and generating appropriate responses. Context information can be represented by vectors, such as by using pre-trained word embedding models Word2Vec or GloVe to obtain a vector representation of each word. In this example, the input sequence is , where x i is the vector representation of the i-th word in the sequence, and the context vector c can be expressed as: ; Among them, f context It is a dynamic context modeling network based on the attention mechanism, which can learn the context dependencies of input data in different situations and dynamically generate corresponding context vectors for each word x in the input sequence x. i Dynamically assign context weights.

[0043] In one embodiment, a model distillation method based on a teacher model and contextual reasoning is provided, which may also include a process of generating context examples, and the specific process includes: inputting feature data into a context example generator, and the context example generator randomly selects candidate examples from a data set; the candidate examples and the feature data belong to the same data distribution; the candidate examples are input into a context example generator function to generate a set of context examples as target examples; and the target examples are used to enrich the context information to obtain the target context information.

[0044] That is, in this embodiment, in addition to utilizing the contextual information of the input data itself, a context example generator is introduced to further enrich the contextual information by providing examples related to the current input, helping the student model to better understand the task context and thus generate a more accurate and contextual reasoning chain.

[0045] The context example generation process includes three main steps: random sampling, example selection, and input construction. The context example generator randomly selects several examples from the same dataset. These examples belong to the same data distribution as the input question and can provide more context information for the question. Let the input question be Q and the candidate example set be E={e1, e2, ..., e N}, the context example generator function is G(Q,E), then the generated context example set P can be expressed as: P=G(Q,E)={p1,p2,...,p k}; where k is the number of generated context examples. Further, the selected examples P = {p1, p2, ..., p k} is encoded into a format suitable for inputting the teacher model, represented as a vector P = {p1, p2, ..., p k}, where each p j is an encoded representation of an example.

[0046] In this embodiment, the student model needs to learn both the standard output and the context-aware output of the language model during the training process. Therefore, the context-aware objective function can be expressed in the formula Based on this, it is further optimized as follows: ;in, is the standard loss function for language models, is the context-aware loss function, is a weight parameter used to balance the two losses.

[0047] In one embodiment, a model distillation method based on a teacher model and contextual reasoning is provided, which may also include a process of generating an inference chain, and the specific process includes: obtaining a sequence-to-sequence model, inputting input data, vector representation, and context vector into the sequence-to-sequence model, and generating an inference chain that considers context information; modifying and adjusting the inference chain, and each student model learns the inference chain strategy of each teacher model based on the modified inference chain; integrating the context-aware mechanism into the training process of each student model to complete the training of each student model.

[0048] When imitating the teacher model to generate reasoning chains, the student model should also consider contextual information. This can be achieved by modifying the reasoning chain strategy so that the generated reasoning chain contains not only logical steps but also contextual information related to the input data: ;in, is a generating function, which can be a sequence-to-sequence (seq2seq) model for generating reasoning chains that consider contextual information, x represents the input sequence, c represents the context vector, and P is the vector representation.

[0049] In this embodiment, the integration process of the context-aware mechanism may also be included. The integration of the context-aware mechanism involves integrating the representation and utilization of context information into the training process of the student model, requiring the student model to not only learn the standard output of the language model, but also learn how to use context information and example information to improve its prediction. The implementation of the integration process can be expressed as ; Among them, S base is the basic part of the student model, and S is the student model integrated with the context-aware mechanism. Through the design and integration of the above-mentioned context-aware and example generation mechanisms, the student model can understand and process natural language more accurately, thereby performing well in various natural language processing tasks. The context-aware mechanism is suitable for scenarios that require deep semantic understanding and complex reasoning.

[0050] In one embodiment, a model distillation method based on a teacher model and situational reasoning is provided, which may also include a process of constructing a reasoning chain. The specific process includes: each student model determines a feature representation through a feature extraction function, and inputs the feature representation into a knowledge base of each teacher model; retrieves each knowledge point corresponding to the feature representation through the knowledge base; each student model uses a logical reasoning mechanism to reason about each knowledge point and generate each intermediate conclusion; and each intermediate conclusion is connected to construct a student model reasoning chain.

[0051] The teacher-enforced reasoning chain strategy enhances the reasoning ability of the student model by simulating the reasoning process of the teacher model, requiring the student model to generate a logically coherent reasoning chain while generating answers, so as to better understand and imitate the decision-making process of the teacher model.

[0052] Specifically, the reasoning chain can be regarded as a series of logical steps, which start from the problem and gradually deduce the answer. Each reasoning step can be represented as an intermediate conclusion, and these conclusions are connected in series to form a complete reasoning process. In this embodiment, the reasoning chain R can be represented as: R = (r1, r2, ..., r k ); where r i is the i-th logical step in the reasoning chain.

[0053] To generate a chain of reasoning, the student model needs to explain its answer through a series of logical reasoning steps. Specific logical reasoning steps may include: Problem feature extraction: The student model first uses the feature extraction function f question To understand the semantic content and contextual information of the question, convert the question Q into a feature representation q.

[0054] Knowledge base retrieval: using the retrieval function f retrieve Retrieve problem-related knowledge from the teacher model’s knowledge base K to enhance the reasoning basis of the student model.

[0055] Logical reasoning step: The student model uses a logical reasoning mechanism f reason Reasoning on each retrieved knowledge point to generate an intermediate conclusion r i .

[0056] Reasoning chain construction: by connecting each logical reasoning step r i , build a complete reasoning chain R.

[0057] Answer inference: Finally, the student model combines the reasoning chain R and the question features q to infer the answer through the function g answer Generate the final answer A. The calculation formula for generating the final answer A can be expressed as: .

[0058] In one embodiment, a model distillation method based on a teacher model and contextual reasoning is provided, which may also include a process of evaluating the reasoning chain, and the specific process includes: determining the true reasoning chain, comparing the true reasoning chain with the student model reasoning chain, and obtaining a comparison result; constructing a loss function for the student model reasoning chain based on the comparison result and the reasoning chain strategy of each teacher model; and updating the parameters of the student model based on the loss function.

[0059] After implementing the teacher-enforced chain of reasoning strategy, the generated chain of reasoning needs to be evaluated. Specifically, the steps for evaluating the generated chain of reasoning may include: Evaluation of reasoning chains: By comparing the reasoning chain R generated by the student model with the true reasoning chain R true, an evaluation function d is used to quantify the accuracy and coherence of the reasoning chain.

[0060] Construction of loss function: Construct the loss function for the inference chain , which comprehensively considers the reasoning chain of M teacher models and uses weights To balance. .

[0061] Parameter update: according to the loss function The gradient information of the teacher is used to update the parameters of the student model to minimize the difference between the reasoning chain and the real reasoning chain. Through the teacher-enforced reasoning chain strategy, the student model of the present invention can imitate the reasoning process of the teacher model and generate a logically coherent and accurate reasoning chain, thereby performing well in complex reasoning tasks.

[0062] In one embodiment, a model distillation method based on a teacher model and contextual reasoning is provided, which may also include a parameter fine-tuning process, and the specific process includes: identifying key parameters in the student model based on the final answer; obtaining a first parameter in the student model, a second parameter in the teacher model, and a first loss function of the student model; constructing a parameter fine-tuning strategy based on the key parameters, the first parameter, the second parameter, and the first loss function; and using the parameter fine-tuning strategy to fine-tune the key parameters in the student model.

[0063] Efficient parameter fine-tuning aims to reduce the number of parameters that need to be adjusted in the student model during the distillation process, thereby reducing computational and storage requirements. By only adjusting the key parameters in the student model, efficient transfer of teacher model knowledge is achieved.

[0064] Specifically, in the process of efficient parameter fine-tuning, we first need to identify the key parameters in the student model, which have a significant impact on the model performance. Key parameters can be identified by a variety of methods, including sensitivity analysis, parameter importance scoring, or using the guidance of the teacher model. The set of key parameters can be expressed as Once the key parameters are identified, we need to design a fine-tuning strategy that only updates these parameters. The fine-tuning strategy can be based on stochastic gradient descent, and the objective function of the fine-tuning strategy can be expressed as: ;in, is the loss function, are the parameters of the student model, are the parameters of the teacher model, is the key parameter in the student model.

[0065] In one embodiment, a model distillation method based on a teacher model and contextual reasoning is provided, which may also include a parameter update optimization process, the specific process including: determining the learning rate in the student model, and adjusting the learning rate using an exponential decay function to complete the parameter update optimization of the student model; using regularization technology to process the student model after parameter update optimization to obtain a processed student model; iteratively using a parameter fine-tuning strategy to fine-tune key parameters in the processed student model to obtain a target student model.

[0066] In order to improve the efficiency of the fine-tuning process and accelerate the convergence to the optimal solution, in this embodiment, a specific learning rate decay method is also used to optimize parameter updates. Specifically, by dynamically adjusting the learning rate, the student model can learn quickly in the early stage of training, and more closely approach the optimal parameters in the later stage of training. Specifically, an exponential decay function is used to adjust the learning rate, and the update rule can be expressed as: ;in, is the learning rate at the tth training step, is the decay rate, which controls how fast the learning rate decreases, and e is the base of the natural logarithm. The learning rate decay method can ensure that the learning rate gradually decreases as the number of training steps t increases, thereby allowing a larger step size for rapid convergence in the early stages of training, and reducing the step size in the later stages of training to fine-tune and avoid oscillation.

[0067] During fine-tuning, regularization techniques can be used to improve the generalization ability of the model and prevent overfitting. L2 regularization and dropout are two very effective regularization techniques. L2 regularization works by adding a penalty term proportional to the square of the parameter to the loss function, which helps limit the value of the model parameters to prevent them from becoming too large; Dropout prevents the network from overfitting the training data by randomly discarding some network connections during training. The integration of L2 regularization and dropout can be expressed as: ;in, is the regularization coefficient, which is used to control the strength of the regularization term, w i are the model parameters, W is the parameter matrix, and represents the parameter matrix after dropout is applied. The L2 regularization term encourages the parameters to remain small, while the dropout term reduces the model's dependence on the training data by introducing randomness.

[0068] Efficient parameter fine-tuning is an iterative process that requires multiple iterations to gradually adjust key parameters. After each iteration, the performance of the student model can be evaluated and the fine-tuning strategy can be adjusted based on the performance feedback. The iterative process can be expressed as: ;in, is the key parameter of the tth iteration, is the learning rate, is the gradient of the loss function with respect to key parameters. Parameter fine-tuning considers the balance between computational efficiency and model performance, and is able to achieve similar performance to a large teacher model while keeping the size of the student model small.

[0069] A model distillation method based on teacher model and contextual reasoning provided in this application enables the student model to learn from multiple large teacher models through a multi-teacher learning framework, and each teacher model contributes its unique knowledge system and reasoning strategy. Compared with the traditional single teacher model distillation method, it can improve the average accuracy of the student model on similar tasks. On the OpenBookQA dataset of common sense reasoning tasks, compared with the single teacher model distillation method LoRA, the average accuracy is improved by more than 5%, showing a higher generalization ability.

[0070] Through the context-aware mechanism and the teacher-enforced reasoning chain strategy, the method of this application significantly improves the student model's understanding and reasoning ability of complex situations. Compared with traditional methods, this application can generate more accurate and appropriate responses, especially for tasks that require deep reasoning. This application adopts efficient parameter fine-tuning technology, only adjusting the key parameters in the student model, achieving efficient transfer of teacher model knowledge, significantly reducing the number of parameters that need to be adjusted in the student model during the distillation process, and can reduce the model's computational and storage requirements compared to traditional full-parameter fine-tuning methods.

[0071] Since the present application significantly reduces the resource consumption of the model, the small model can run efficiently on resource-constrained devices while maintaining similar performance to the large model. This feature greatly improves the flexibility of model deployment, making the present application method suitable for various resource-constrained environments, such as mobile devices, embedded systems, etc. The present application method allows the student model to learn multiple tasks at the same time through a multi-task learning framework, which improves the learning efficiency of the model. Compared with traditional single-task learning methods, the student model can master more skills and knowledge within the same training time. Since the present application method requires the student model to generate a reasoning chain similar to the teacher model, this improves the interpretability of the model. Compared with the traditional black box model, the present application method can provide a clearer and more transparent reasoning process, which helps to understand and trust the model's decisions.

[0072] It should be understood that, although the various steps in the above-mentioned flow chart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the above-mentioned flow chart may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0073] In one embodiment, Figure 3 As shown, a model distillation system based on a teacher model and contextual reasoning is provided, including: a data processing module 310, a context perception and example generation mechanism module 320, a distillation module 330, an inference chain use module 340 and a parameter fine-tuning module 350, wherein: The data processing module 310 is used to obtain input data, pre-process the input data, and extract feature data from the input data; The context-aware and example-generating mechanism module 320 is used to perform semantic analysis on the feature data using the context-aware mechanism to obtain context information; generate a target example corresponding to the feature data using the context example generator, and enrich the context information using the target example to obtain target context information; A distillation module 330 is used to learn from each teacher model based on a multi-teacher learning framework according to the target context information, and generate a preliminary answer corresponding to the target example through each student model; The inference chain using module 340 is used to generate an inference process according to the preliminary answer using the inference chain strategy of the teacher model, and determine a final answer corresponding to the input data according to the inference process and the preliminary answer; The parameter fine-tuning module 350 is used to fine-tune the key parameters in the student model according to the final answer to complete the optimization of the multi-teacher learning framework.

[0074] In one embodiment, a model distillation system based on teacher models and contextual reasoning is provided, which may also include a multi-teacher learning framework construction module, which is used to: obtain multiple pre-trained teacher models, each teacher model corresponding to different knowledge and reasoning strategies; each student model interacts with each teacher model through a knowledge distillation process, and each student model learns to imitate the instructions of each teacher model; introduces a context-aware mechanism, and integrates context information into each student model for training based on the context-aware mechanism; sets a reasoning chain strategy for each teacher model, and guides each student model to learn the reasoning steps of each teacher model based on the reasoning chain strategy to complete the construction of a multi-teacher learning framework.

[0075] Among them, the multi-teacher learning framework aims to improve the learning efficiency and generalization ability of the student model by integrating the wisdom of multiple teacher models. The structural diagram of the multi-teacher learning framework is shown in the figure. Figure 4 As shown in the figure, it mainly includes: teacher model set, student model, knowledge distillation process, context information integration, and reasoning chain generation. Among them: The teacher model ensemble consists of multiple pre-trained large models, each of which contributes unique knowledge and reasoning strategies; The student model is a small neural network whose goal is to learn from an ensemble of teacher models through knowledge distillation; The knowledge distillation process enables the student model to imitate the output of the teacher model set through a specific loss function; Contextual information integration is responsible for integrating the contextual information of the input data into the learning process of the student model; Reasoning chain generation is the part of the student model responsible for generating logical reasoning chains to improve the performance of complex reasoning tasks.

[0076] exist Figure 4 In the figure, arrows are used to represent data flow and information transfer in each part. The output of the teacher model set is passed to the student model through arrows, indicating that the knowledge of the teacher model set is passed to the student model; the student model interacts with the output of the teacher model set through the knowledge distillation process, indicating the knowledge distillation process; context information integration provides context information to the student model to enhance the student model's understanding of complex situations; reasoning chain generation receives information from the student model and generates a reasoning chain. The entire structural diagram clearly shows the technical process and the relationship between the components of a model distillation method and system based on teacher models and situational reasoning provided in this application.

[0077] In one embodiment, the context awareness and example generation mechanism module 320 is also used to input feature data into a pre-trained word embedding model, obtain the vector representation of each word through the word embedding model; input each vector representation into a dynamic context modeling network based on an attention mechanism, generate a context vector, and obtain context information.

[0078] In one embodiment, the inference chain usage module 340 is also used to obtain a sequence-to-sequence model, input the input data, vector representation, and context vector into the sequence-to-sequence model, and generate an inference chain that takes context information into account; modify and adjust the inference chain, and each student model learns the inference chain strategy of each teacher model based on the modified inference chain; integrate the context-aware mechanism into the training process of each student model to complete the training of each student model.

[0079] In one embodiment, the context perception and example generation mechanism module 320 is also used to input feature data into a context example generator, which randomly selects candidate examples from a data set; the candidate examples and the feature data belong to the same data distribution; the candidate examples are input into a context example generator function to generate a set of context examples as target examples; and the target examples are used to enrich the context information to obtain target context information.

[0080] Among them, the context-awareness and example generation mechanism focuses on enhancing the student model's understanding of the context of the input data and improving the performance of natural language processing tasks through example generation. Specifically, the schematic diagram of the context-awareness and example generation mechanism is shown in the figure below: Figure 5 As shown, it includes: input sequence processing, context example generator, context feature extraction, context vector generation, student model fusion, context-aware response generation, example representation and integration, among which: Input sequence processing is responsible for receiving and preliminarily processing input data sequences and extracting basic language features; The context example generator randomly selects examples related to the input question from the same dataset, providing more context information; Context feature extraction uses a pre-trained word embedding model or a specific neural network structure to extract context information from the output of input sequence processing and the examples generated by the context example generator; Context vector generation generates a vector that can represent the context of the entire input sequence based on the features extracted by context feature extraction; Student model fusion is the part of the student model that combines the context vector with the original input data for further learning and reasoning; Context-aware response generation is responsible for generating the final context-aware response based on the student model output that incorporates context information; Example representation and integration is responsible for encoding the generated examples into a format suitable for input to the teacher model and integrating them into the training process of the student model together with the context vector.

[0081] exist Figure 5 In the figure, arrows are used to represent data flow and information transfer. The output of input sequence processing points to context feature extraction through arrows, indicating feature extraction of input data; the output of context example generator is passed to context feature extraction through arrows, indicating generation of context examples; the output of context feature extraction is passed to context vector generation through arrows, indicating in-depth processing of context features; the generated context vector is passed to student model fusion through arrows, indicating integration of context information; the output of student model fusion points to context-aware response generation through arrows, indicating generation of context-aware response; context example generator is also directly passed to example representation and integration through arrows, indicating representation and integration of examples; context vector generation is also passed to example representation and integration through arrows, indicating joint integration of context vectors and examples.

[0082] In one embodiment, the reasoning chain using module 340 is also used for each student model to determine the feature representation through the feature extraction function, and input the feature representation into the knowledge base of each teacher model; retrieve each knowledge point corresponding to the feature representation through the knowledge base; each student model uses a logical reasoning mechanism to reason about each knowledge point and generate each intermediate conclusion; connect each intermediate conclusion to construct a student model reasoning chain.

[0083] In one embodiment, the inference chain usage module 340 is also used to determine the true inference chain, compare the true inference chain with the student model inference chain, and obtain a comparison result; based on the comparison result and the inference chain strategy of each teacher model, a loss function is constructed for the student model inference chain; based on the loss function, the parameters of the student model are updated.

[0084] Among them, the reasoning chain strategy aims to enhance the logical reasoning ability of the student model by imitating the reasoning process of the teacher model. Specifically, the structure diagram of the teacher-enforced reasoning chain strategy is as follows: Figure 6 As shown in the figure, it includes question input processing, teacher model knowledge base, logical reasoning mechanism, reasoning chain generation, answer generation, and consistency evaluation. Among them: Question input processing is responsible for receiving and processing the questions to be solved, providing the basis for the reasoning process; The teacher model knowledge base contains rich knowledge of the teacher model, which can be retrieved and used by the student model during the reasoning process; The logical reasoning mechanism extracts information from the problem input and the knowledge base through a series of logical steps to generate a reasoning chain; Reasoning chain generation is responsible for converting the output of the logical reasoning mechanism into a specific and understandable reasoning chain; Answer generation generates the final answer based on the results of the reasoning chain; Consistency evaluation assesses the consistency between the reasoning chain generated by the student model and that of the teacher model, providing feedback for model optimization.

[0085] exist Figure 6 In the figure, arrows are used to represent data flow and information transfer in each part. The output of the question input processing points to the logical reasoning mechanism through arrows, indicating the transfer of question understanding; the output of the teacher model knowledge base is passed to the logical reasoning mechanism through arrows, indicating the provision of knowledge base information; the output of the logical reasoning mechanism is passed to the reasoning chain generation through arrows, indicating the transformation from logical reasoning to reasoning chain generation; the output of the reasoning chain generation points to the answer generation through arrows, indicating the transformation from the reasoning chain to the answer generation; the output of the answer generation is passed to the consistency evaluation through arrows, indicating the consistency evaluation of the answer.

[0086] In one embodiment, the parameter fine-tuning module 350 is also used to identify key parameters in the student model based on the final answer; obtain the first parameter in the student model, the second parameter in the teacher model, and the first loss function of the student model; construct a parameter fine-tuning strategy based on the key parameters, the first parameter, the second parameter, and the first loss function; and use the parameter fine-tuning strategy to fine-tune the key parameters in the student model.

[0087] In one embodiment, the parameter fine-tuning module 350 is also used to determine the learning rate in the student model, and use an exponential decay function to adjust the learning rate to complete the parameter update optimization of the student model; use regularization technology to process the student model after parameter update optimization to obtain a processed student model; iteratively use the parameter fine-tuning strategy to fine-tune the key parameters in the processed student model to obtain the target student model.

[0088] Among them, efficient parameter fine-tuning achieves efficient transfer of teacher model knowledge by accurately adjusting the key parameters in the student model, while reducing the model's computational and storage requirements. Specifically, the schematic diagram of the efficient parameter fine-tuning structure is shown in the figure below: Figure 7 As shown in the figure, it includes key parameter identification module, parameter fine-tuning strategy module, regularization technology application, learning rate decay control, parameter update and optimization, performance evaluation and feedback, among which: The key parameter identification module is responsible for identifying the key parameter set that has the greatest impact on performance from the parameters of the student model; The parameter fine-tuning strategy module designs and implements a fine-tuning strategy for key parameters, which uses a specific optimization algorithm to update parameters; Regularization technology is applied in the fine-tuning process, introducing L2 regularization and dropout techniques to improve the generalization ability of the model and prevent overfitting; Learning rate decay control uses an exponential decay function to dynamically adjust the learning rate, ensuring rapid learning in the early stages of training and careful adjustment in the later stages; Parameter update and optimization Update and optimize key parameters based on the results of fine-tuning strategy and learning rate decay control; Performance Evaluation and Feedback Evaluate the performance of the fine-tuned model and feed the results back to the parameter fine-tuning strategy module to guide further optimization.

[0089] exist Figure 7 In the figure, arrows are used to represent data flow and information transfer in each part. The output of the key parameter identification module points to the parameter fine-tuning strategy module through an arrow, indicating the transfer of the key parameter set; the output of the parameter fine-tuning strategy module is passed to the regularization technology application and learning rate decay control through an arrow, indicating the transfer of the fine-tuning strategy and learning rate decay control; the output of the regularization technology application and learning rate decay control points to the parameter update and optimization through an arrow, indicating the execution of the parameter update and optimization; the output of the parameter update and optimization is passed to the performance evaluation and feedback through an arrow, indicating the execution of the performance evaluation.

[0090] In one embodiment, a model distillation system based on a teacher model and contextual reasoning is provided. Figure 8 As shown in the figure, it integrates a multi-teacher learning framework, a context-aware mechanism, a teacher-enforced reasoning chain strategy, efficient parameter fine-tuning, and collaborative learning objectives, among which: The multi-teacher learning framework is responsible for integrating the knowledge of multiple teacher models and providing diversified learning paths for student models; The context-aware mechanism is used to extract contextual information from the input data and integrate it into the learning process of the student model; The teacher-enforced reasoning chain strategy ensures that the student model can generate accurate and deep reasoning processes when imitating the teacher model; Efficient parameter fine-tuning achieves efficient transfer of teacher model knowledge by adjusting only the key parameters in the student model; The collaborative learning objective ensures that the student model not only learns to predict labels but also learns to generate inferences similar to those produced by the teacher model.

[0091] exist Figure 8In the figure, arrows are used to represent data flow and information transfer in each part. The output of the multi-teacher learning framework points to the context-aware mechanism through arrows, indicating the integration of multi-teacher knowledge; the output of the context-aware mechanism is passed to the teacher-enforced reasoning chain strategy through arrows, indicating the transfer of context information; the teacher-enforced reasoning chain strategy passes the reasoning process to the efficient parameter fine-tuning according to the reasoning chain strategy, indicating the generation of the reasoning chain; after the efficient parameter fine-tuning performs parameter fine-tuning, the optimization results are fed back to the multi-teacher learning framework, indicating knowledge transfer; the collaborative learning goal evaluates the system performance and feeds back the evaluation results to each module to achieve the goal of collaborative learning.

[0092] In one embodiment, a model distillation method and system based on a teacher model and contextual reasoning provided by this application is applied to an intelligent customer service system to improve the accuracy and efficiency of automatic question answering. Fig. 9 As shown, the specific implementation process includes: User query reception: The intelligent customer service system receives the user's text query; Query preprocessing: The system preprocesses the user's query, including word segmentation, removal of stop words, etc. Context-aware understanding: Using context-aware and example generation mechanisms to understand the semantics and intent of queries; Multi-teacher knowledge distillation: Through the multi-teacher learning framework, knowledge is extracted from different teacher models to enhance the answering ability of the student model; Answer generation and reasoning: The student model generates preliminary answers and generates reasoning using the teacher-enforced chain of reasoning strategy; Answer optimization and selection: The system optimizes and selects the most appropriate answer based on the generated answers and reasoning chains; Answer provision: The intelligent customer service system provides the final answer to the user; User feedback learning: Users provide feedback on answers, and the system learns and optimizes the model based on the feedback.

[0093] In one embodiment, a model distillation method and system based on a teacher model and contextual reasoning provided by the present application is applied to a medical consultation system to assist doctors in diagnosing diseases. Fig.10 As shown, the specific implementation process includes: Patient medical record input: The doctor enters the patient's medical record information, including symptoms, physical examination results, etc. Medical record preprocessing: The system preprocesses medical record information and extracts key information; Context-aware analysis: Analyze semantic relationships and potential connections in medical records using context-aware and example-generating mechanisms; Multi-teacher knowledge integration: Integrate knowledge from different medical fields through a multi-teacher learning framework; Preliminary diagnosis generation: The student model generates preliminary diagnosis results based on the integrated knowledge; Diagnostic reasoning and verification: The system generates reasoning chains and verifies the accuracy of the diagnosis through the teacher model; Auxiliary diagnosis suggestion provision: The system provides auxiliary diagnosis suggestions to doctors; Doctor decision and feedback: Doctors make decisions based on auxiliary diagnosis recommendations and provide feedback to the system.

[0094] In one embodiment, a model distillation method and system based on a teacher model and contextual reasoning provided by the present application is applied to an online education platform, aiming to provide learners with personalized learning path recommendations to improve learning efficiency and outcomes. Fig.11 As shown, the specific implementation process includes: Learning data collection: The platform collects learners’ learning behavior data, including course access records, homework submissions, and test scores; Data preprocessing and feature engineering: clean and standardize the collected data and extract key learning features; Context-aware learning status analysis: Use context-awareness and example generation mechanisms to analyze learners’ learning status and identify learning needs and preferences; Personalized learning path planning: Based on the multi-teacher learning framework, personalized learning paths are planned in combination with learner characteristics and contextual information; Knowledge distillation and model fine-tuning: Through efficient parameter fine-tuning technology, key knowledge is extracted from the teacher model and the student model is fine-tuned; Collaborative learning goal optimization: Adopting a collaborative learning goal framework to optimize learners’ knowledge acquisition and skill development simultaneously; Learning path implementation and evaluation: Implement personalized learning paths on the platform and evaluate based on learners’ progress and feedback; Model iteration and path adjustment: Based on the evaluation results, the student model and learning path are iteratively updated to adapt to the continuous development of learners.

[0095] In one embodiment, a model distillation method and system based on a teacher model and contextual reasoning provided by the present application is applied to the field of intelligent manufacturing to improve the operating efficiency and product quality of the production line through anomaly detection. Fig.12 As shown, the specific implementation process includes: Production data collection: collect various data on the production line, such as temperature, pressure, vibration, etc., through sensors and monitoring systems; Data preprocessing and feature extraction: preprocess the collected production data and extract key features for anomaly detection; Context-aware anomaly analysis: Use context-aware and example generation mechanisms to analyze context information in the production process and identify factors that may cause anomalies; Multi-teacher knowledge distillation: Through a multi-teacher learning framework, knowledge is extracted from historical anomaly cases to train student models for anomaly detection; Reasoning chain generation and anomaly identification: The student model generates reasoning chains, simulates the logical process of anomaly occurrence, and identifies the current abnormal state; Collaborative learning goal optimization: Adopting the collaborative learning goal framework, the accuracy and response speed of anomaly detection are optimized simultaneously; Abnormal response and system adjustment: Automatically or manually adjust the production line based on abnormal detection results to restore normal operation; Model iteration and performance improvement: Collect anomaly processing results, iteratively update the model, and improve the performance of anomaly detection.

[0096] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.13 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a database and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium, and the database stores a data set for the operation of the computer program. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a model distillation method based on a teacher model and situational reasoning is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0097] Those skilled in the art will understand that Fig.13 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0098] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of a model distillation method based on a teacher model and contextual reasoning are implemented.

[0099] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of a model distillation method based on a teacher model and contextual reasoning are implemented.

[0100] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0101] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0102] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A model distillation method based on teacher model and contextual reasoning, characterized in that: The method comprises: Acquiring input data, preprocessing the input data, and extracting feature data from the input data; Using a context-aware mechanism to perform semantic analysis on the feature data to obtain context information; using a context example generator to generate a target example corresponding to the feature data, and using the target example to enrich the context information to obtain target context information; According to the target context information, each student model learns from each teacher model based on a multi-teacher learning framework, and generates a preliminary answer corresponding to the target example through each student model; Generate a reasoning process according to the preliminary answer using the reasoning chain strategy of the teacher model, and determine a final answer corresponding to the input data according to the reasoning process and the preliminary answer; According to the final answer, key parameters in the student model are fine-tuned to complete the optimization of the multi-teacher learning framework.

2. The model distillation method based on teacher model and contextual reasoning according to claim 1, characterized in that: The method further comprises: Obtaining multiple pre-trained teacher models, each teacher model corresponding to different knowledge and reasoning strategies; Each student model interacts with each teacher model through a knowledge distillation process, and each student model learns to imitate the instructions of each teacher model; Introducing a context-aware mechanism, and integrating context information into each of the student models for training based on the context-aware mechanism; The reasoning chain strategy of each teacher model is set, and based on the reasoning chain strategy, each student model is guided to learn the reasoning steps of each teacher model to complete the construction of a multi-teacher learning framework.

3. The model distillation method based on teacher model and contextual reasoning according to claim 1, characterized in that: The feature data is semantically analyzed using a context-aware mechanism to obtain context information including: Inputting the feature data into a pre-trained word embedding model, and obtaining a vector representation of each word through the word embedding model; Each of the vector representations is input into a dynamic context modeling network based on an attention mechanism to generate a context vector and obtain context information.

4. The model distillation method based on teacher model and contextual reasoning according to claim 3 is characterized in that: The method further comprises: Obtain a sequence-to-sequence model, input the input data, the vector representation, and the context vector into the sequence-to-sequence model, and generate an inference chain that considers context information; Modifying and adjusting the inference chain, so that each of the student models learns the inference chain strategy of each of the teacher models based on the modified inference chain; The context-aware mechanism is integrated into the training process of each of the student models to complete the training of each of the student models.

5. The model distillation method based on teacher model and contextual reasoning according to claim 1, characterized in that: Using a context example generator to generate a target example corresponding to the feature data, and using the target example to enrich the context information to obtain target context information, including: Inputting the feature data into the context example generator, the context example generator randomly selects candidate examples from the data set; the candidate examples and the feature data belong to the same data distribution; Input the candidate examples into a context example generator function to generate a set of context examples as target examples; The context information is enriched using the target example to obtain target context information.

6. The model distillation method based on teacher model and contextual reasoning according to claim 1, characterized in that: The method further comprises: Each of the student models determines a feature representation through a feature extraction function, and inputs the feature representation into a knowledge base of each of the teacher models; Retrieving each knowledge point corresponding to the feature representation through the knowledge base; Each of the student models uses a logical reasoning mechanism to reason about each of the knowledge points and generate each intermediate conclusion; Connect the various intermediate conclusions to construct a student model reasoning chain.

7. The model distillation method based on teacher model and contextual reasoning according to claim 6, characterized in that: The method further comprises: Determine a true reasoning chain, compare the true reasoning chain with the student model reasoning chain, and obtain a comparison result; Constructing a loss function for the student model reasoning chain according to the comparison result and the reasoning chain strategy of each teacher model; Based on the loss function, parameters of the student model are updated.

8. The model distillation method based on teacher model and contextual reasoning according to claim 1, characterized in that: Fine-tune key parameters in the student model according to the final answer to complete the optimization of the multi-teacher learning framework, including: identifying key parameters in the student model based on the final answer; Obtaining a first parameter in the student model, a second parameter in the teacher model, and a first loss function of the student model; Constructing a parameter fine-tuning strategy according to the key parameter, the first parameter, the second parameter, and the first loss function; The parameter fine-tuning strategy is used to fine-tune key parameters in the student model.

9. The model distillation method based on teacher model and contextual reasoning according to claim 8, characterized in that: The method further comprises: Determine the learning rate in the student model, and adjust the learning rate using an exponential decay function to complete parameter update optimization of the student model; Using regularization technology to process the student model after parameter update optimization, to obtain a processed student model; The parameter fine-tuning strategy is iteratively used to fine-tune the key parameters in the processed student model to obtain a target student model.

10. A model distillation system based on teacher model and contextual reasoning, characterized in that: The system comprises: A data processing module, used to obtain input data, pre-process the input data, and extract feature data from the input data; A context-aware and example generation mechanism module is used to perform semantic analysis on the feature data using a context-aware mechanism to obtain context information; use a context example generator to generate a target example corresponding to the feature data, and use the target example to enrich the context information to obtain target context information; A distillation module, configured to learn from each teacher model based on a multi-teacher learning framework according to the target context information, and generate a preliminary answer corresponding to the target example through each student model; An inference chain using module, used to generate an inference process according to the preliminary answer using the inference chain strategy of the teacher model, and determine a final answer corresponding to the input data according to the inference process and the preliminary answer; A parameter fine-tuning module is used to fine-tune the key parameters in the student model according to the final answer to complete the optimization of the multi-teacher learning framework.

Citation Information

Patent Citations

  • BOM data multi-dimensional analysis system and analysis method based on large language model

    CN119004372A

  • Knowledge distillation method, device, equipment and storage medium

    CN119005166A

  • KR20240163867A

Cited By

  • Large model security protection method and device, equipment and storage medium

    CN120409549A

  • Training data synthesis method and device based on error extrapolation and inference chain analysis, medium and program product

    CN120611192A

  • Training data synthesis method and device based on error extrapolation and reasoning chain analysis, medium and program product

    CN120611192B

  • System adaptive modeling method and device based on meta-learning and storage medium

    CN121119060A

  • Table image reasoning method based on heterogeneous model multiplexing and knowledge distillation

    CN121706980A