Model iterative training method, device and electronic device based on model's own knowledge
By calculating knowledge requirements for language models and selecting training data of graph structures, the problem of unreasonable data allocation caused by human intervention in the existing technology is solved, and the automation and efficiency of model training is achieved.
Patent Information
- Application Number
- CN202411745413.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-02
AI Technical Summary
In the prior art, the classification and proportion of data during language model training rely on human intervention, resulting in unreasonable data allocation and difficult to adjust at all times, which affects the training speed and performance of the model.
By preprocessing the text data, building a graph structure, and sampling evenly within the graph structure, calculating the knowledge requirements of the current model, deleting nodes with lower knowledge requirements and their neighboring nodes, training nodes with moderate knowledge requirements, and iterative training until the expected effect is achieved.
It realizes automatic determination of the training data of the next stage model, tailoring the training plan, speeding up the model training process and improving the model capabilities.
Smart Images

Figure CN119227839B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer model technology, and in particular to a model iterative training method, device and electronic equipment based on model knowledge itself. Background Art
[0002] In the process of language model training, the demand for data is different at different stages. For example, a large amount of language data is needed in the early stage of model training to help the model learn basic language knowledge; in the later stage, the model will begin to learn more complex knowledge such as mathematics and logical reasoning. At present, the common practice is to classify the data by category, set a certain proportion for each type of data based on experience, then observe the loss curve of the model through experiments, and finally manually determine the data ratio for the next stage of model learning. This method has the following problems: data classification requires manual decision-making, which may not be reasonable; data ratio depends on human intervention and is difficult to adjust in a timely and effective manner, thus affecting the training speed and performance of the model. Summary of the invention
[0003] In order to solve the problems existing in the prior art, the present invention provides the following technical solutions.
[0004] The first aspect of the present invention provides a model iterative training method based on model self-knowledge, comprising:
[0005] S101, preprocessing the text data, and constructing a graph structure using the preprocessed text data;
[0006] S102, uniformly sampling in the graph structure, and using the sampled text data to calculate the knowledge requirement of the current model;
[0007] S103, deleting nodes and their neighboring nodes in the graph structure whose knowledge requirements are less than the first threshold; using nodes and their neighboring nodes in the graph structure whose knowledge requirements are greater than or equal to the first threshold and less than or equal to the second threshold to train the current model, and obtaining a model trained in this round; using nodes and their neighboring nodes in the graph structure whose knowledge requirements are greater than the second threshold to train the model trained in this round, and obtaining a model trained in the next round;
[0008] S104, using the next round of trained model as the current model to repeat steps S102 to S103 until the expected training effect is achieved.
[0009] Preferably, the preprocessing of text data includes:
[0010] The text data is first cleaned, converted, filtered, and deduplicated, and then the semantic vector is calculated;
[0011] Deduplication is performed at the semantic level based on semantic vectors.
[0012] Preferably, constructing a graph structure using preprocessed text data includes:
[0013] Calculate the similarity between each vector;
[0014] Each vector is regarded as a node, and edges are established between nodes whose similarity is higher than a preset threshold to obtain a graph structure.
[0015] Preferably, the calculating the knowledge requirement of the current model includes: calculating the perplexity of the sampled text data to the current model, and using the perplexity to represent the knowledge requirement.
[0016] A second aspect of the present invention provides a model iterative training device based on model self-knowledge, comprising:
[0017] A graph structure building module, used to preprocess text data and build a graph structure using the preprocessed text data;
[0018] The knowledge requirement calculation module is used to uniformly sample within the graph structure and use the sampled text data to calculate the knowledge requirement of the current model;
[0019] The training data selection and model training module is used to delete the nodes and their neighboring nodes in the graph structure whose knowledge requirements are less than the first threshold; use the nodes and their neighboring nodes in the graph structure whose knowledge requirements are greater than or equal to the first threshold and less than or equal to the second threshold to train the current model, and obtain the model trained in this round; use the nodes and their neighboring nodes in the graph structure whose knowledge requirements are greater than the second threshold to train the model trained in this round, and obtain the model trained in the next round;
[0020] The iterative training module is used to repeatedly execute the knowledge requirement calculation module, the training data selection module and the model training module using the next round of trained model as the current model until the expected training effect is achieved.
[0021] Preferably, in the graph structure building module, the preprocessing of text data includes:
[0022] The text data is first cleaned, converted, filtered, and deduplicated, and then the semantic vector is calculated;
[0023] Deduplication is performed at the semantic level based on semantic vectors.
[0024] Preferably, in the graph structure construction module, the step of constructing the graph structure using the preprocessed text data includes:
[0025] Calculate the similarity between each vector;
[0026] Each vector is regarded as a node, and edges are established between nodes whose similarity is higher than a preset threshold to obtain a graph structure.
[0027] Preferably, in the knowledge requirement calculation module, the calculation of the knowledge requirement of the current model includes: calculating the perplexity of the sampled text data to the current model, and using the perplexity to represent the knowledge requirement.
[0028] The present invention also provides a memory storing a plurality of instructions, wherein the instructions are used to implement the model iterative training method based on the model's own knowledge as described in the first aspect.
[0029] The present invention also provides an electronic device, comprising a processor and a memory connected to the processor, wherein the memory stores a plurality of instructions, and the instructions can be loaded and executed by the processor so that the processor can execute the model iterative training method based on the model's own knowledge as described in the first aspect.
[0030] The beneficial effects of the present invention are as follows: the model iterative training method, device and electronic device provided by the present invention based on the model's own knowledge deletes the nodes and their neighboring nodes in the graph structure whose knowledge requirements are less than the first threshold value according to the calculated knowledge requirements of the current model; the nodes and their neighboring nodes in the graph structure whose knowledge requirements are greater than or equal to the first threshold value and less than or equal to the second threshold value are used to train the current model to obtain the model trained in this round; the nodes and their neighboring nodes in the graph structure whose knowledge requirements are greater than the second threshold value are used to train the model trained in this round to obtain the model trained in the next round, and then the iterative training model is repeated. The training data of the model in the next stage can be automatically determined by calculating the knowledge requirements of the model, so as to achieve the purpose of tailoring the training plan for the model, accelerate the model training process and improve the model capability. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 It is a flow chart of the model iterative training method based on the model's own knowledge according to the present invention;
[0032] Figure 2 This is a functional structural diagram of the model iterative training device based on the model's own knowledge described in the present invention. DETAILED DESCRIPTION
[0033] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0034] The method provided by the present invention can be implemented in the following terminal environment, and the terminal may include one or more of the following components: a processor, a memory, and a display screen. The memory stores at least one instruction, and the instruction is loaded and executed by the processor to implement the method described in the following embodiment.
[0035] The processor may include one or more processing cores. The processor uses various interfaces and lines to connect various parts of the entire terminal, and executes various functions of the terminal and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory, and calling data stored in the memory.
[0036] The memory may include random access memory (RAM) or read-only memory (ROM). The memory may be used to store instructions, programs, codes, code sets or instructions.
[0037] The display screen is used to display the user interface of each application.
[0038] In addition, those skilled in the art can understand that the structure of the above terminal does not constitute a limitation on the terminal, and the terminal may include more or fewer components, or combine certain components, or arrange the components differently. For example, the terminal also includes components such as a radio frequency circuit, an input unit, a sensor, an audio circuit, and a power supply, which will not be described in detail here.
[0039] Embodiment 1
[0040] like Figure 1 As shown, an embodiment of the present invention provides a model iterative training method based on the model's own knowledge, including: S101, preprocessing text data, and constructing a graph structure using the preprocessed text data; S102, uniformly sampling in the graph structure, and using the sampled text data to calculate the knowledge requirement of the current model; S103, deleting the nodes and their neighboring nodes in the graph structure whose knowledge requirement is less than a first threshold; using the nodes and their neighboring nodes in the graph structure whose knowledge requirement is greater than or equal to the first threshold and less than or equal to the second threshold to train the current model, and obtain a model trained in this round; using the nodes and their neighboring nodes in the graph structure whose knowledge requirement is greater than the second threshold to train the model trained in this round, and obtain a model trained in the next round; S104, using the model trained in the next round as the current model to repeat steps S102~S103 until the expected training effect is achieved.
[0041] In step S101, preprocessing the text data includes: first cleaning, converting, filtering and deduplicating the text data, and then calculating the semantic vector; and deduplicating at the semantic level based on the semantic vector.
[0042] The aforementioned construction of a graph structure using preprocessed text data includes: calculating the similarity between each vector; taking each vector as a node, establishing edges between nodes whose similarity is higher than a preset threshold, and obtaining a graph structure.
[0043] Among them, the similarity between vectors can be calculated using methods such as cosine similarity. In actual application, clustering algorithms can be applied to optimize nodes and reduce redundancy.
[0044] In the embodiment of the present invention, the knowledge requirement can be understood as follows: the type, density, and difficulty of the knowledge contained in the data are different at different training stages of the model, and the model knowledge requirement refers to the degree to which the model needs the knowledge contained in the current data. A high knowledge requirement indicates that the model has not been exposed to such data and knowledge, and it is difficult for the model to learn such knowledge. A low knowledge requirement indicates that the model has already mastered such data and knowledge very well. Too high or too low knowledge requirement is not conducive to model training. If the knowledge requirement is too high, the model training is difficult and the model is not easy to converge; if the knowledge requirement is too low, the model causes unnecessary waste of computing power. A moderate knowledge requirement is conducive to efficient and high-quality learning of the model.
[0045] In the present invention, the aforementioned calculation of the knowledge requirement of the current model may include: calculating the perplexity of the sampled text data to the current model, and using the perplexity to represent the knowledge requirement.
[0046] There are two ways to calculate the perplexity: predict the next word based on the previous content from the beginning to the end, and calculate the cross entropy between the real word and the predicted word; randomly block part of the sentence, predict the content of the blocked part word by word based on the existing content, and calculate the cross entropy between the real word and the predicted word.
[0047] In the embodiment of the present invention, adjacent nodes can be defined as follows: nodes within a preset number of nodes; or the shortest distance between two points is less than a set value. The distance between two adjacent points can be defined by semantic similarity. Specifically, it can be determined by the model training personnel according to the actual situation based on the data situation, computing power resources and other specific conditions.
[0048] In practical applications, in order to improve the parallelism of the overall training, the next stage of training data and model training can be carried out in parallel. Specifically, the following method can be used to achieve this: use a version of the model training, calculate the knowledge requirement of the model, and determine the range of training data for the next stage. At this time, the model training is not stopped and continues. Based on the new model version, the new training data is used to continue training to ensure that the model training process will not stop.
[0049] Embodiment 2
[0050] like Figure 2As shown, another aspect of the present invention also includes a functional module architecture that is completely consistent with the aforementioned method flow, that is, the embodiment of the present invention also provides a model iterative training device based on the model's own knowledge, including: a graph structure construction module 201, used to preprocess text data and use the preprocessed text data to construct a graph structure; a knowledge requirement calculation module 202, used to uniformly sample within the graph structure, and use the sampled text data to calculate the knowledge requirement of the current model; a training data selection and model training module 203, used to delete nodes in the graph structure whose knowledge requirement is less than a first threshold and their neighboring nodes; use the nodes in the graph structure whose knowledge requirement is greater than or equal to the first threshold and less than or equal to the second threshold and their neighboring nodes to train the current model to obtain a model trained in this round; use the nodes in the graph structure whose knowledge requirement is greater than the second threshold and their neighboring nodes to train the model trained in this round to obtain a model trained in the next round; an iterative training module 204, used to use the model trained in the next round as the current model to repeatedly execute the knowledge requirement calculation module and the training data selection and model training module until the expected training effect is achieved.
[0051] Furthermore, in the graph structure construction module, the aforementioned preprocessing of text data includes: first cleaning, converting, filtering and deduplicating the text data, and then calculating the semantic vector; and deduplicating at the semantic level based on the semantic vector.
[0052] Furthermore, in the graph structure construction module, the aforementioned construction of the graph structure using the preprocessed text data includes: calculating the similarity between each vector; taking each vector as a node, establishing edges between nodes whose similarity is higher than a preset threshold, and obtaining a graph structure.
[0053] Furthermore, in the knowledge requirement calculation module, the aforementioned calculation of the knowledge requirement of the current model includes: calculating the perplexity of the sampled text data to the current model, and using the perplexity to represent the knowledge requirement.
[0054] The device can be implemented through the model iterative training method based on the model's own knowledge provided in the above-mentioned embodiment 1. The specific implementation method can be found in the description in embodiment 1 and will not be repeated here.
[0055] The present invention also provides a memory storing a plurality of instructions, wherein the instructions are used to implement the model iterative training method based on the model's own knowledge as described in Example 1.
[0056] The present invention also provides an electronic device, comprising a processor and a memory connected to the processor, wherein the memory stores a plurality of instructions, and the instructions can be loaded and executed by the processor so that the processor can execute the model iterative training method based on the model's own knowledge as described in Example 1.
[0057] Although preferred embodiments of the present invention have been described, additional changes and modifications may be made to these embodiments by those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention. Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A model iterative training method based on model knowledge, characterized in that: include: S101, preprocessing the text data, and constructing a graph structure using the preprocessed text data; The method of constructing a graph structure using the preprocessed text data includes: calculating the similarity between each vector; taking each vector as a node, establishing edges between nodes whose similarity is higher than a preset threshold, and obtaining a graph structure; S102, uniformly sampling in the graph structure, and using the sampled text data to calculate the knowledge requirement of the current model, wherein calculating the knowledge requirement of the current model includes: calculating the perplexity of the sampled text data to the current model, and using the perplexity to represent the knowledge requirement; S103, deleting nodes and their neighboring nodes in the graph structure whose knowledge requirements are less than the first threshold; using nodes and their neighboring nodes in the graph structure whose knowledge requirements are greater than or equal to the first threshold and less than or equal to the second threshold to train the current model, and obtaining a model trained in this round; using nodes and their neighboring nodes in the graph structure whose knowledge requirements are greater than the second threshold to train the model trained in this round, and obtaining a model trained in the next round; S104, repeating steps S102~S103 with the next round of trained model as the current model until the expected training effect is achieved; wherein the model iterative training method automatically determines the training data of the next stage model by calculating the knowledge requirement of the model, and determines the training data of the next stage model in parallel with the model training process, that is, using a version of the model training, calculating the knowledge requirement of the model, and determining the range of training data for the next stage.
2. The model iterative training method based on model self-knowledge as claimed in claim 1, characterized in that: The preprocessing of text data comprises: The text data is first cleaned, converted, filtered, and deduplicated, and then the semantic vector is calculated; Deduplication is performed at the semantic level based on semantic vectors.
3. A model iterative training device based on model self-knowledge, characterized in that: include: A graph structure building module, used to preprocess text data and build a graph structure using the preprocessed text data; The method of constructing a graph structure using the preprocessed text data includes: calculating the similarity between each vector; taking each vector as a node, establishing edges between nodes whose similarity is higher than a preset threshold, and obtaining a graph structure; A knowledge requirement calculation module is used to uniformly sample in the graph structure and use the sampled text data to calculate the knowledge requirement of the current model, wherein the calculation of the knowledge requirement of the current model includes: calculating the perplexity of the sampled text data to the current model and using the perplexity to represent the knowledge requirement; The training data selection and model training module is used to delete the nodes and their neighboring nodes in the graph structure whose knowledge requirements are less than the first threshold; use the nodes and their neighboring nodes in the graph structure whose knowledge requirements are greater than or equal to the first threshold and less than or equal to the second threshold to train the current model, and obtain the model trained in this round; use the nodes and their neighboring nodes in the graph structure whose knowledge requirements are greater than the second threshold to train the model trained in this round, and obtain the model trained in the next round; An iterative training module is used to repeatedly execute the knowledge requirement calculation module and the training data selection and model training module using the next round of trained model as the current model until the expected training effect is achieved; wherein the model iterative training device automatically determines the training data of the next stage model by calculating the knowledge requirement of the model, determines the training data of the next stage model in parallel with the model training process, uses a version in the model training, calculates the knowledge requirement of the model, and determines the range of training data for the next stage.
4. The model iterative training device based on model self-knowledge as claimed in claim 3, characterized in that: In the graph structure building module, the preprocessing of text data includes: The text data is first cleaned, converted, filtered, and deduplicated, and then the semantic vector is calculated; Deduplication is performed at the semantic level based on semantic vectors.
5. A memory, characterized in that: Multiple instructions are stored, and the instructions are used to implement the model iterative training method based on the model's own knowledge as described in any one of claims 1-2.
6. An electronic device, characterized in that: It includes a processor and a memory connected to the processor, the memory stores multiple instructions, and the instructions can be loaded and executed by the processor, so that the processor can execute the model iterative training method based on model self-knowledge as described in any one of claims 1-2.
Citation Information
Patent Citations
Question and answer model construction method and project question and answer method
CN117633196A