Knowledge distillation method, device, equipment, storage medium and computer program product
By entering the detection text into the teacher model to obtain thinking chains and global keywords and passing them to the student model, the problems of large-scale language model deployment difficulties and degraded student model learning performance are solved, and efficient knowledge under limited data is achieved Transmission and model performance improvements.
Patent Information
- Application Number
- CN202411051431.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-08-01
AI Technical Summary
The deployment of large-scale language models in practical applications is difficult, especially the high demand for computing resources, which leads to a degradation in student model learning performance.
By inputting the detection text into the teacher model, outputting thinking chains and global keywords, based on these outputs, the knowledge in the teacher model is passed on to the student model, simulate the human thinking process, and gradually train the student model to improve its performance in complex tasks.
Under the limited data conditions, the knowledge expression ability and generalization ability of students' models are significantly improved, their performance in complex tasks is enhanced, and the computing resource requirements for model deployment are reduced.
Smart Images

Figure CN119005175A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to knowledge distillation methods, devices, equipment, storage media and computer program products. Background Art
[0002] Large-scale language models (LLMs) excel in few-shot learning capabilities, but their sheer size makes deployment in real-world applications extremely challenging. In particular, as of 2024, OpenAI's GPT-4 is known to be the largest LLM, with over one trillion (1T) parameters. Models of this size require significantly more memory and compute resources, making deployment more difficult and placing extremely high demands on infrastructure. For most product teams, this computational requirement is prohibitive, especially for applications that require low-latency performance.
[0003] Currently, in order to circumvent the deployment challenges of large-scale models, practitioners usually choose to deploy smaller specialized models, but the insufficient data of small models makes the generated labeled data biased, resulting in a decrease in the learning performance of the student model.
[0004] Therefore, how to improve the learning performance of the student model is a problem that needs to be solved urgently. Summary of the invention
[0005] The main purpose of this application is to provide a knowledge distillation method, device, equipment, storage medium and computer program product, aiming to solve the technical problem of decreased learning performance of student models.
[0006] To achieve the above objectives, the present application proposes a knowledge distillation method, which includes:
[0007] Input the test text into the teacher model, and output a thought chain and global keywords, wherein the thought chain is used to represent the teacher model's understanding and reasoning process of the test text, and the global keywords are used to represent the core information and knowledge points of reasoning thinking in the test text;
[0008] Based on the thought chain and the global keywords, the knowledge in the teacher model is transferred to the student model.
[0009] In one embodiment, the step of inputting the detection text into the teacher model and outputting the thought chain and global keywords includes:
[0010] Inputting the test text into the teacher model, analyzing the semantic relationship and logical connection of the test text through the teacher model, and constructing a thinking chain according to the analysis result;
[0011] The detection text is recognized through the teacher model based on the thought chain, global keywords are extracted from the detection text according to the recognition result, and the thought chain and the global keywords are output.
[0012] In one embodiment, the step of analyzing the semantic relationship and logical connection of the detection text by the teacher model and constructing a thought chain according to the analysis result includes:
[0013] Performing data preprocessing on the detected text to obtain a preprocessed text;
[0014] Using a deep learning model to perform semantic analysis on the preprocessed text to obtain semantic units and semantic connections between the semantic units;
[0015] Based on the semantic connection, a logical connection among the semantic units is constructed, and a thought chain is constructed according to the logical connection and the semantic units.
[0016] In one embodiment, the step of transferring the knowledge in the teacher model to the student model based on the thought chain and the global keywords includes:
[0017] Input the thought chain and global keywords into the student model to be optimized for training, and output the student thought chain;
[0018] Modify the student's thinking chain according to the global keyword to obtain the target student's thinking chain;
[0019] Based on the target student's thinking chain, the knowledge in the teacher model is transferred to the student model.
[0020] In one embodiment, the step of correcting the student thinking chain according to the global keyword to obtain the target student thinking chain includes:
[0021] The student thinking chain is corrected using the global keywords, and the corrected student thinking chain and the thinking chain are input together into the student model to be optimized for iterative training until a target student thinking chain is obtained, and the deviation between the target student thinking chain and the thinking chain is less than a preset threshold.
[0022] In one embodiment, the step of using the global keywords to correct the student's thinking chain, and inputting the corrected student's thinking chain and the thinking chain into the student model to be optimized for iterative training includes:
[0023] Using the global keywords to modify the student's thinking chain, and inputting the modified student's thinking chain and the thinking chain into the student model to be optimized;
[0024] The loss function of the student model to be optimized is calculated according to the corrected student thinking chain and the thinking chain:
[0025]
[0026] Among them, L label represents the loss function, N represents the number of thought chains, represents the cross entropy loss between the predicted label and the target label, f represents the student model to be optimized, and x i It represents the revised student thinking chain. represents the predicted label;
[0027] The loss function is used to iteratively train the student model to be optimized.
[0028] In addition, to achieve the above purpose, the present application also proposes a knowledge distillation device, which includes:
[0029] A knowledge analysis module, which is used to input the test text into the teacher model and output a thought chain and global keywords, wherein the thought chain is used to represent the teacher model's understanding and reasoning process of the test text, and the global keywords are used to represent the core information and knowledge points of reasoning thinking in the test text;
[0030] The knowledge output module is used to transfer the knowledge in the teacher model to the student model based on the thinking chain and the global keywords.
[0031] In addition, to achieve the above-mentioned objectives, the present application also proposes a knowledge distillation device, which includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the computer program is configured to implement the steps of the knowledge distillation method described above.
[0032] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the knowledge distillation method described above are implemented.
[0033] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the knowledge distillation method described above.
[0034] One or more technical solutions proposed in this application have at least the following technical effects:
[0035] The test text is input into the teacher model, and the thought chain and global keywords are output. The thought chain is used to represent the teacher model's understanding and reasoning process of the test text, and the global keywords are used to represent the core information and knowledge points of reasoning thinking in the test text. Based on the thought chain and global keywords, the knowledge in the teacher model is transferred to the student model. By simulating the human thinking process, complex tasks are decomposed into a series of simple steps, so that the student model can gradually learn and master the processing methods of complex tasks, thereby improving its performance in complex tasks. By extracting global keywords, the model can capture and transfer knowledge more comprehensively, improving the learning effect of the student model. Through the introduction of global keywords and thought chains, the knowledge expression ability and generalization ability of the student model are effectively enhanced under limited data conditions, and the learning performance of the student model is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0038] Figure 1 A schematic diagram of the overall technical framework of an embodiment of the present application;
[0039] Figure 2 This is a schematic diagram of the process of the first embodiment of the knowledge distillation method of the present application;
[0040] Figure 3 This is a flow chart of the second embodiment of the knowledge distillation method of the present application;
[0041] Figure 4 A schematic diagram of a global keyword extraction process according to an embodiment of the present application;
[0042] Figure 5 A schematic diagram of constructing a thinking chain according to an embodiment of the present application;
[0043] Figure 6 This is a schematic diagram of the process of the third embodiment of the knowledge distillation method of the present application;
[0044] Figure 7 This is a schematic diagram of the knowledge transfer and distillation framework based on global keywords and thought chains in an embodiment of the present application;
[0045] Figure 8 This is a schematic diagram of the module structure of the knowledge distillation device in the embodiment of the present application;
[0046] Fig. 9 Schematic diagram of the device structure of the hardware operating environment involved in the knowledge distillation method in the embodiment of the present application.
[0047] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0048] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0049] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0050] Since large-scale language models (LLMs) require significantly more memory and computing resources, they not only increase the difficulty of deployment, but also place extremely high demands on infrastructure. For most product teams, this computing requirement is unbearable, especially for applications that require low-latency performance. In addition, LLMs still have limitations in fully understanding the context, especially when complex reasoning or domain-specific knowledge is involved, the logic and accuracy of the generated text are often affected. In order to circumvent the deployment challenges of large-scale models, practitioners usually choose to deploy smaller, specialized models. These smaller models are trained through two common paradigms: fine-tuning and distillation. Fine-tuning makes the model perform better in a specific domain by applying the pre-trained model to a specific task and further training it with manually annotated data. However, the effect of fine-tuning is highly dependent on the quality and quantity of the annotated data, and obtaining high-quality annotated data usually requires a lot of manpower and time. Distillation uses the labels generated by large-scale LLMs to train smaller models, and uses the large-scale model as a teacher model to generate pseudo-labeled data for training smaller student models. This method can use the knowledge of large-scale models to improve the performance of smaller models, but it also faces the computational resource requirements for generating high-quality pseudo-labeled data and the bias and noise of the labeled data. The knowledge distillation process is highly dependent on a large amount of high-quality training data. If the data quality is not high or the amount of data is insufficient, the distillation effect will be significantly affected, limiting the generalization ability of the student model. Therefore, how to make the student model with fewer parameters better express the knowledge output in the teacher model under limited data conditions is still a major challenge that needs to be solved.
[0051] This application provides a solution, which inputs the test text into the teacher model, outputs the thought chain and global keywords, the thought chain is used to represent the teacher model's understanding and reasoning process of the test text, and the global keywords are used to represent the core information and knowledge points of reasoning thinking in the test text. Based on the thought chain and global keywords, the knowledge in the teacher model is transferred to the student model. Figure 1 As shown, the relationship between the three parts of thought chain construction, global keyword extraction, and knowledge transfer and distillation in this application is demonstrated. The knowledge distillation method based on global keywords and thought chains frames the learning problem of explanation and global keywords as a multi-task problem. The training model not only predicts the task label, but also generates the corresponding explanation and global keywords. By increasing the supervision information, the generalization ability and prediction accuracy of the student model are improved. Through the construction of thought chains, the semantic relationship and logical connection of the input data are analyzed to form a complete thought chain, which not only improves the reasoning ability of the student model, but also ensures the accuracy and completeness of knowledge transfer. Using natural language processing technology, global keywords are extracted from the input data and the output of the teacher model, further enhancing the model's understanding and application ability of text content. This method significantly reduces the computing resources and data requirements for model deployment, improves the performance and adaptability of small-scale models in practical applications, and provides a new solution for the practical deployment of large-scale language models. Using large language models to generate detailed natural language explanations, providing reasons to support the model's prediction labels, so that the student model can better understand and apply this knowledge, and improve the transparency and credibility of the model.
[0052] Based on this, the present application embodiment provides a knowledge distillation method, referring to Figure 2 , Figure 2 This is a flow chart of the first embodiment of the knowledge distillation method of the present application.
[0053] In this embodiment, the knowledge distillation method includes steps S10 to S20:
[0054] Step S10, input the detected text into the teacher model, and output the thought chain and global keywords.
[0055] It should be noted that the test text can be understood as the text to be processed that is input into the teacher model. The teacher model can be a large and complex model that has been pre-trained. The thinking chain is used to represent the teacher model's understanding and reasoning process of the test text. The global keywords are used to represent the core information in the test text and the knowledge points of reasoning thinking.
[0056] Exemplarily, the teacher model extracts key information from the text according to the text content and reasoning process, constructs a logically coherent sequence of reasoning steps, and outputs key information, key information extraction logic, and a sequence of reasoning steps.
[0057] Step S20, based on the thought chain and global keywords, transfer the knowledge in the teacher model to the student model.
[0058] Exemplarily, the thought chain and global keywords can be input into the student model for iterative training, and the performance of the student model can be gradually enhanced through multiple iterations. This method can also be replaced by other progressive optimization methods.
[0059] In this embodiment, the test text is input into the teacher model, and the thought chain and global keywords are output. The thought chain is used to represent the teacher model's understanding and reasoning process of the test text, and the global keywords are used to represent the core information and knowledge points of reasoning thinking in the test text. Based on the thought chain and global keywords, the knowledge in the teacher model is transferred to the student model. By simulating the human thinking process, complex tasks are decomposed into a series of simple steps, so that the student model can gradually learn and master the processing methods of complex tasks, thereby improving its performance in complex tasks. By extracting global keywords, the model can capture and transfer knowledge more comprehensively, and improve the learning effect of the student model. Through the introduction of global keywords and thought chains, the knowledge expression ability and generalization ability of the student model are effectively enhanced under limited data conditions, and the learning performance of the student model is improved.
[0060] The first embodiment adopts a multi-task learning framework, thought chain construction and optimization, and global keyword extraction methods. These methods can be replaced by alternatives such as multi-perspective knowledge distillation, semantic relationship construction of graph neural networks, or keyword extraction based on contrastive learning. The above-mentioned extended method does not constitute a limitation on the knowledge distillation method of the present application, but in order for the student model to capture the knowledge points of the teacher model more accurately and completely during the learning process, the second embodiment of the present application is proposed.
[0061] Reference Figure 3 , Figure 3 This is a flow chart of the second embodiment of the knowledge distillation method of this application. Figure 2 The first embodiment shown proposes a second embodiment of the knowledge distillation method of the present application.
[0062] In the second embodiment, the step S10 includes:
[0063] Step S101, input the test text into the teacher model, analyze the semantic relationship and logical connection of the test text through the teacher model, and build a thinking chain based on the analysis results.
[0064] It should be noted that semantic relations can be understood as the meaning associations between words, sentences or paragraphs in a text, such as causal relations, parallel relations, transitional relations, etc. Logical connections can be understood as the associations between the various parts of a text based on logical reasoning, such as sequentiality, hierarchy, conditionality, etc. The analysis results can be the results obtained by the teacher model analyzing and detecting the semantic relations and logical connections of the text.
[0065] Exemplarily, the test text can be preprocessed as necessary, such as removing noise (such as HTML tags, special characters, etc.). The teacher model uses natural language processing technology (such as dependency syntax analysis, semantic role labeling, etc.) to identify the semantic relationship in the test text and analyze the interaction and connection between words in the text, such as identifying sentence components such as subject, predicate, object, and the modification, limitation, etc. between them. Furthermore, the teacher model analyzes the logical connection in the text, such as the order between paragraphs, the causal relationship between sentences, the transition relationship, etc., and through logical reasoning, constructs a correlation network between the various parts of the text, and constructs a thinking chain based on the above analysis results.
[0066] Step S102, based on the thought chain, the detection text is recognized through the teacher model, global keywords are extracted from the detection text according to the recognition result, and the thought chain and the global keywords are output.
[0067] It should be noted that global keyword extraction identifies key words and phrases by analyzing the input data and the teacher model's understanding and reasoning of the data.
[0068] For example, Figure 4 As shown in the figure, by guiding GPT-3.5 with examples, key words and phrases are identified by analyzing the input data and the understanding and reasoning process of the teacher model (such as GPT-3.5) on the data. These keywords represent the core information and knowledge points of reasoning thinking in the text. Global keyword extraction not only analyzes the input data, but also includes the reasoning information in the thinking chain. During the entire analysis process, the teacher model is able to identify key words and phrases in the global information, and these keywords accurately reflect the content and meaning of the text. The teacher model identifies the core information and key content in the detection text based on the constructed thinking chain. These core information are usually closely related to the theme, central idea or main argument of the text. From the identified core information, the teacher model extracts global keywords that can summarize the core content and theme of the text. These keywords should be representative and discriminative, and can help readers quickly understand the main content of the text. The teacher model outputs the constructed thinking chain and the extracted global keywords.
[0069] This embodiment inputs the test text into the teacher model, analyzes the semantic relationship and logical connection of the test text through the teacher model, constructs a thinking chain based on the analysis results, and recognizes the test text through the teacher model based on the thinking chain, extracts global keywords from the test text according to the recognition results, and outputs the thinking chain and global keywords. The thinking chain can reflect the teacher model's understanding and reasoning process of the input data, thereby improving the learning effect and performance of the student model. Global keyword extraction enables the model to quickly locate and understand the core information in the text, thereby reducing processing time. The model's ability to understand and apply the text content is enhanced, so that the student model can more accurately capture the key knowledge points in the teacher model during the learning process. In this way, not only the overall performance of the student model is improved, but also a stronger ability is shown when dealing with complex tasks.
[0070] In one embodiment, the step of analyzing the semantic relationship and logical connection of the detection text through a teacher model and constructing a thinking chain based on the analysis results includes: performing data preprocessing on the detection text to obtain a preprocessed text; performing semantic analysis on the preprocessed text using a deep learning model to obtain semantic units and semantic connections between semantic units; constructing logical connections between semantic units based on the semantic connections, and constructing a thinking chain based on the logical connections and semantic units.
[0071] For example, Figure 5 As shown in the figure, GPT-3.5 can be used as a teacher model to build a thinking chain, and the CQA dataset can be used. First, the CQA dataset is preprocessed, and the specific operations include removing meaningless characters, stop words, and other noise data. Then, semantic analysis, logical relationship construction, and thinking chain optimization are performed by calling the API interface of GPT-3.5. By guiding GPT-3.5 with examples, it can analyze the problem step by step and generate the reasoning process corresponding to the correct answer.
[0072] In this implementation, data preprocessing, semantic analysis, logical relationship construction and thinking chain optimization are performed. Data preprocessing ensures data quality and consistency through text cleaning, word segmentation and part-of-speech tagging. Semantic analysis uses deep learning models to extract semantic units and relationships and identify semantic connections between words. Logical relationship construction is based on these semantic units to display the reasoning path and logical structure between knowledge points. Finally, the thinking chain is output through a large model to ensure its accuracy and completeness.
[0073] Reference Figure 6 , Figure 6 This is a flow chart of the third embodiment of the knowledge distillation method of this application. Figure 3 The second embodiment shown proposes the third embodiment of the knowledge distillation method of the present application.
[0074] In the third embodiment, the step S20 includes:
[0075] Step S201, input the thinking chain and global keywords into the student model to be optimized for training, and output the student thinking chain.
[0076] It should be noted that the student thinking chain can be understood as the sequence of reasoning steps that the student model attempts to imitate and generate after receiving the thinking chain input and processing it through its internal algorithm. It is understandable that since the initial performance of the student model may be low, the thinking chain it generates may be different from the real or ideal thinking chain.
[0077] Step S202, correct the student's thinking chain according to the global keywords to obtain the target student's thinking chain.
[0078] It should be noted that the target student thinking chain is a student thinking chain that is closer to the real or ideal situation after being corrected by global keywords, and represents an optimized output of the student model on a specific task.
[0079] Exemplarily, we first need to use natural language processing technology to obtain global keywords from the input text. Next, we use the large language model to generate preliminary reasoning steps. We gradually generate reasoning steps through sample prompts. These steps preliminarily explain how to derive possible conclusions from the input text. Combined with global keywords, the preliminary generated reasoning steps are corrected and optimized. In this way, the generated thinking chain not only reflects the reasoning ability of the large language model, but also combines key knowledge to ensure the accuracy and reliability of the reasoning process. Finally, the optimized reasoning steps are organized into a coherent thinking chain. The thinking chain contains all the logical steps from the input text to the final conclusion, and each step is based on key knowledge and a reasonable reasoning path.
[0080] Step S203, based on the target student's thinking chain, transfer the knowledge in the teacher model to the student model.
[0081] For example, the knowledge transfer can be made more detailed and in-depth through multiple rounds of optimization process by using the stepwise distillation optimization method. Figure 7As shown in the figure, in each round of distillation training, the student model is trained using the answers provided by the teacher model while imitating the reasoning process of the teacher model. This training method not only focuses on the accuracy of the final answer, but also on the rationality and coherence of the reasoning process. The student model generates its own reasoning path by learning the reasoning chain of the teacher model, thereby understanding and mastering the knowledge in a specific field. This process is repeated many times, so that the reasoning ability and answer accuracy of the student model are gradually improved, approaching the level of the teacher model. After each round of training, the reasoning results of the student model are compared and corrected with the reasoning process of the teacher model. The student model is optimized by combining new training data and updated thinking chains.
[0082] In this embodiment, by inputting the thinking chain and global keywords into the student model to be optimized for training, the student thinking chain is output, the student thinking chain is corrected according to the global keywords, the target student thinking chain is obtained, and the knowledge in the teacher model is transferred to the student model based on the target student thinking chain. By combining the key knowledge in the global keywords, the initial generated reasoning steps are corrected and optimized. Each round of optimization not only improves the reasoning ability of the student model, but also avoids the reasoning deviation caused by relying solely on data-driven by correcting the reasoning steps. This method of step-by-step correction and optimization ensures the integrity and effectiveness of knowledge transfer, so that the student model performs well in problem solving in specific fields. The introduction of the thinking chain makes the reasoning process transparent, and the user can clearly see the basis and logic of each reasoning step, thereby enhancing the trust in the output results of the model. Through this technical solution, the model can provide more credible and valuable results in practical applications.
[0083] In one embodiment, based on the above-mentioned third embodiment, step S202 includes: using key information to correct the student's thinking chain, and inputting the corrected student's thinking chain and the thinking chain into the student model for iterative training until the target student's thinking chain is obtained, and the deviation between the target student's thinking chain and the thinking chain is less than a preset threshold.
[0084] It should be noted that the loss function of the student model can be calculated based on the corrected student thinking chain and thinking chain, and the student model can be iteratively trained using the loss function. In the absence of manually labeled labels, the task-specific distillation method uses a large language model (LLM) to generate pseudo-noise training labels Replace the true label (y i ). The smaller models f are trained by minimizing the label prediction loss. i ) and predicted labels To create a clearer connection between and keywords As additional supervision information, we frame learning explanations and question answering as a multi-task problem. Specifically, we train the model Not only predicting the task label, but also generating the corresponding explanation and keywords, the overall cross entropy loss can be further defined as formula (1):
[0085] L=λ1L label +λ2L exp lanation +(1-λ1-λ2)L keyword (1)
[0086] Among them, L is the cross entropy loss between the predicted label and the target label, λ1 and λ2 represent the weights of the loss function calculation, and L label represents the loss function, L explanation is the explanation generation loss, L keyword It is the global keyword generation loss.
[0087] L label The loss function can be expressed as formula (2):
[0088]
[0089] In formula (2), L label is the loss function, N represents the number of thought chains, represents the cross entropy loss between the predicted label and the target label, f represents the student model, and x i It represents the revised student thinking chain. Represents the predicted label.
[0090] In formula (1), L explanation is the explanation generation loss, defined as formula (3):
[0091]
[0092] In formula (3), L explanation To explain the generation loss, N represents the number of thought chains, represents the cross entropy loss between the predicted label and the target label, f represents the student model, and x i It represents the revised student thinking chain. Represents the extracted explanation.
[0093] In formula (1), L keyword is the global keyword generation loss, defined as formula (4):
[0094]
[0095] In formula (4), L keyword Generate loss for global keywords, N represents the number of thought chains, represents the cross entropy loss between the predicted label and the target label, f represents the student model, and x i It represents the revised student thinking chain. Indicates a keyword.
[0096] In this implementation, by optimizing the loss function, the student model maximizes the learning and expression of the knowledge in the teacher model under limited computing resources and data volume. After learning and training, the student model can make better predictions for new input questions. This step-by-step distillation method through global keywords and thought chains effectively utilizes the ability of large language models to generate explanations, significantly improves the performance and generalization ability of the student model, and provides a new solution for actual deployment.
[0097] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the knowledge distillation method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0098] This application also provides a knowledge distillation device, please refer to Figure 8 , the knowledge distillation device comprises:
[0099] The knowledge analysis module 10 is used to input the test text into the teacher model and output a thought chain and global keywords, wherein the thought chain is used to represent the teacher model's understanding and reasoning process of the test text, and the global keywords are used to represent the core information and knowledge points of reasoning thinking in the test text;
[0100] The knowledge output module 20 is used to transfer the knowledge in the teacher model to the student model based on the thought chain and the global keywords.
[0101] The knowledge distillation device provided in this application adopts the knowledge distillation method in the above embodiment, which can solve the technical problem of the decline in the learning performance of the student model. Compared with the prior art, the beneficial effects of the knowledge distillation device provided in this application are the same as the beneficial effects of the knowledge distillation method provided in the above embodiment, and the other technical features in the knowledge distillation device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0102] The present application provides a knowledge distillation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the knowledge distillation method in the above-mentioned embodiment one.
[0103] Reference below Fig. 9, which shows a schematic diagram of the structure of a knowledge distillation device suitable for implementing the embodiment of the present application. The knowledge distillation device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig. 9 The knowledge distillation device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0104] like Fig. 9 As shown, the knowledge distillation device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the knowledge distillation device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the knowledge distillation device to communicate with other devices wirelessly or by wire to exchange data. Fig. 9 A knowledge distillation apparatus having various systems is shown, but it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented or have alternatively.
[0105] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0106] The knowledge distillation device provided by this application adopts the knowledge distillation method in the above embodiment to solve the technical problem of the decline in the learning performance of the student model. Compared with the prior art, the beneficial effects of the knowledge distillation device provided by this application are the same as the beneficial effects of the knowledge distillation method provided by the above embodiment, and the other technical features in the knowledge distillation device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0107] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0108] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0109] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the knowledge distillation method in the above-mentioned embodiment.
[0110] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0111] The above-mentioned computer-readable storage medium may be included in the knowledge distillation device; or it may exist independently without being assembled into the knowledge distillation device.
[0112] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the knowledge distillation device, the knowledge distillation device: inputs the detection text into the teacher model, outputs the thinking chain and global keywords, the thinking chain is used to represent the teacher model's understanding and reasoning process of the detection text, and the global keywords are used to represent the core information and knowledge points of reasoning thinking in the detection text. Based on the thinking chain and global keywords, the knowledge in the teacher model is transferred to the student model.
[0113] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0114] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0115] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0116] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned knowledge distillation method, and can solve the technical problem of the decline in the learning performance of the student model. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the knowledge distillation method provided in the above-mentioned embodiment, and will not be repeated here.
[0117] The present application also provides a computer program product, including a computer program, which implements the steps of the knowledge distillation method as described above when executed by a processor.
[0118] The computer program product provided in this application can solve the technical problem of the decline in the learning performance of the student model. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the knowledge distillation method provided in the above embodiment, which will not be repeated here.
[0119] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A knowledge distillation method, characterized in that: The method includes: Input the test text into the teacher model, and output a thought chain and global keywords, wherein the thought chain is used to represent the teacher model's understanding and reasoning process of the test text, and the global keywords are used to represent the core information and knowledge points of reasoning thinking in the test text; Based on the thought chain and the global keywords, the knowledge in the teacher model is transferred to the student model.
2. The method according to claim 1, characterized in that The step of inputting the detected text into the teacher model and outputting the thought chain and global keywords includes: Inputting the test text into the teacher model, analyzing the semantic relationship and logical connection of the test text through the teacher model, and constructing a thinking chain according to the analysis result; The detection text is recognized through the teacher model based on the thought chain, global keywords are extracted from the detection text according to the recognition result, and the thought chain and the global keywords are output.
3. The method according to claim 2, characterized in that The step of analyzing the semantic relationship and logical connection of the detection text by the teacher model and constructing a thinking chain according to the analysis result includes: Performing data preprocessing on the detected text to obtain a preprocessed text; Using a deep learning model to perform semantic analysis on the preprocessed text to obtain semantic units and semantic connections between the semantic units; Based on the semantic connection, a logical connection among the semantic units is constructed, and a thought chain is constructed according to the logical connection and the semantic units.
4. The method according to any one of claims 1 to 3, characterized in that The step of transferring the knowledge in the teacher model to the student model based on the thought chain and the global keywords comprises: Input the thought chain and global keywords into the student model to be optimized for training, and output the student thought chain; Modify the student's thinking chain according to the global keyword to obtain the target student's thinking chain; Based on the target student's thinking chain, the knowledge in the teacher model is transferred to the student model.
5. The method according to claim 4, characterized in that The step of correcting the student's thinking chain according to the global keyword to obtain the target student's thinking chain includes: The student thinking chain is corrected using the global keywords, and the corrected student thinking chain and the thinking chain are input together into the student model to be optimized for iterative training until a target student thinking chain is obtained, and the deviation between the target student thinking chain and the thinking chain is less than a preset threshold.
6. The method according to claim 5, characterized in that The step of using the global keywords to correct the student's thinking chain, and inputting the corrected student's thinking chain and the thinking chain into the student model to be optimized for iterative training includes: Using the global keywords to modify the student's thinking chain, and inputting the modified student's thinking chain and the thinking chain into the student model to be optimized; The loss function of the student model to be optimized is calculated according to the corrected student thinking chain and the thinking chain: Among them, L label represents the loss function, N represents the number of thought chains, represents the cross entropy loss between the predicted label and the target label, f represents the student model to be optimized, and x i It represents the revised student thinking chain. represents the predicted label; The loss function is used to iteratively train the student model to be optimized.
7. A knowledge distillation device, characterized in that: The device comprises: A knowledge analysis module, which is used to input the test text into the teacher model and output a thought chain and global keywords, wherein the thought chain is used to represent the teacher model's understanding and reasoning process of the test text, and the global keywords are used to represent the core information and knowledge points of reasoning thinking in the test text; The knowledge output module is used to transfer the knowledge in the teacher model to the student model based on the thinking chain and the global keywords.
8. A knowledge distillation device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the knowledge distillation method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the knowledge distillation method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the steps of the knowledge distillation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Large language model distillation method based on thinking chain
CN116739110A
Customized training method and device based on large model thinking chain
CN117149984A
Multi-modal thinking chain reasoning method and device based on knowledge distillation
CN118014077A
System and Method for Aggregating Contextual Content
US20130080449A1
System and method for providing an interactive visual learning environment for creation, presentation, sharing, organizing and analysis of knowledge on subject matter
US20180366013A1
Cited By
Lightweight information extraction method and system based on knowledge distillation and thinking chain
CN120011533A
Teaching thinking chain generation method and device, equipment and medium
CN120144777A
