A task semantic perception-based large model self-adaptive training method and system

By dynamically adjusting the rank of the LoRA model using a task semantic awareness method, the resource mismatch problem caused by fixed rank is solved, and efficient training and resource optimization of the model in specific tasks are achieved.

CN120688563BActive Publication Date: 2025-12-05NANJING FUTURE NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511181495.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-22
Publication Date
2025-12-05
Estimated Expiration
2045-08-22

AI Technical Summary

Technical Problem

In existing LoRA models, the low-rank matrix uses a pre-specified fixed rank, which cannot be adaptively adjusted according to actual needs, resulting in resource misallocation in specific tasks, causing memory waste or insufficient model expressive power.

Method used

By using a task-based semantic awareness method, high-dimensional semantic vectors are obtained and subjected to linear transformation and normalization. The rank of the LoRA model is dynamically adjusted, and combined with iterative training and validation, the allocation of model resources is ensured to match the task complexity.

Benefits of technology

It achieves dynamic optimization of model resources, shortens training time, improves convergence speed, reduces memory usage, and enhances the model's adaptability and accuracy in different tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120688563B_ABST
    Figure CN120688563B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of large models, and discloses a large model adaptive training method and system based on task semantic perception. The method comprises the following steps: obtaining a plurality of text data based on a target task, and selecting any text data to perform BERT encoding to obtain a high-dimensional semantic vector; performing first-layer linear transformation and activation processing on the high-dimensional semantic vector to obtain a low-dimensional semantic vector; performing second-layer linear transformation and normalization processing on the low-dimensional semantic vector to obtain a task complexity; determining a complexity interval in which the task complexity is located, obtaining a preset rank value interval corresponding to the complexity interval, and then obtaining a dynamic rank value of a low-rank matrix in a RoLA model based on the task complexity; introducing the RoLA model with the dynamic rank value into a pre-trained large language model, and iteratively training the large language model based on the text data until a corresponding evaluation index meets a preset index requirement. The application realizes optimized allocation of resources in the training process, and can significantly improve training efficiency and reduce memory occupation.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of large model, in particular to a large model adaptive training method and system based on task semantic perception. BACKGROUND

[0002] Natural language processing is a core technology of artificial intelligence, which has important applications in specific scenarios involving language processing and text processing. For example, in the education industry, large models for natural language processing provide effective technical support for the digital transformation of education, realizing an intelligent process from semantic understanding of education tasks to difficulty quantization and resource adaptation, and promoting the development of personalized education and smart education.

[0003] There are various pre-trained large language models in the current prior art, which are trained by massive data and have good universality. When these pre-trained large language models are applied to specific scenarios, they need to be fine-tuned for specific tasks in the corresponding scenarios. Introducing the LoRA model into the pre-trained large language model is a common means of fine-tuning. Specifically, the LoRA model uses two low-rank matrices to approximate the weight update of the corresponding parameters to reduce the number of parameters, which reduces the storage and technical costs, and also effectively improves the training speed.

[0004] However, in the existing LoRA model, the low-rank matrix uses a pre-specified fixed rank, which cannot be adaptively adjusted according to actual needs. Therefore, in actual application, there are the following defects: the fixed rank of the LoRA model causes resource mismatch, and cannot dynamically adjust the resource occupation. Specifically, a larger rank value is used in simple tasks, causing waste of more than video memory; a smaller rank value is used in complex task training, causing insufficient model performance and insufficient expression ability. SUMMARY

[0005] The present application aims to provide a large model adaptive training method and system based on task semantic perception, which solves the technical problem of resource waste or insufficient model expression ability caused by resource mismatch when a pre-trained large language model based on a fixed rank LoRA model is fine-tuned for specific tasks.

[0006] To achieve the above purpose, the present application proposes the following technical solutions:

[0007] In a first aspect, the present application provides a large model adaptive training method based on task semantic perception, comprising:

[0008] Based on the target task, a plurality of text data are obtained, and any text data is selected and BERT encoded to obtain a high-dimensional semantic vector;

[0009] wherein the high-dimensional semantic vector is: ; wherein, t k is selected text data, and k is the sequential number of the text data;

[0010] performing first-layer linear transformation and activation processing on the high-dimensional semantic vector to project it to a low-dimensional space, thereby obtaining a low-dimensional semantic vector; and performing second-layer linear transformation and normalization processing on the low-dimensional semantic vector to obtain a task complexity;

[0011] wherein the low-dimensional semantic vector is: ; wherein, ReLU() is a ReLU function, W1 is a weight matrix of the first-layer linear transformation, b 1 is a bias vector of the first-layer linear transformation; and the task complexity is: ; wherein, sigmoid() is a normalization function, W2 is a weight matrix of the second-layer linear transformation, b 2 is a bias vector of the second-layer linear transformation;

[0012] After determining the complexity interval in which the task complexity is located and determining the preset rank value interval corresponding to the complexity interval, a dynamic rank value of a low-rank matrix in the RoLA model is obtained based on the task complexity;

[0013] wherein the dynamic rank value is: ; wherein, r min is a lower limit value of the preset rank value interval, and r max is an upper limit value of the preset rank value interval;

[0014] The RoLA model with the dynamic rank value setting is introduced into a pre-trained large language model, and iterative training is performed on the large language model based on each text data until an evaluation index corresponding to the target task meets a preset index requirement, thereby obtaining a target large model.

[0015] Further, the iterative training based on each text data until the evaluation index corresponding to the target task meets the preset index requirement to obtain a target large model comprises:

[0016] constructing a training set, a validation set, and a test set based on each text data;

[0017] iteratively train a pre-trained large language model introducing the RoLA model based on the training set, and validate the model after each training based on the validation set; wherein, in the training process, if the loss value of the loss function decreases by less than a preset decrease threshold in a continuous preset number of training rounds, the parameter weight in the RoLA model is increased; in the validation process, if the output accuracy of a continuous preset number of validation rounds does not show an upward trend, the learning rate in the RoLA model is reduced;

[0018] When it is determined that the total number of iterative training rounds is reached, the model after iterative training and validation is tested based on the test set to determine that the memory occupancy of the model when running is less than a preset memory occupancy threshold, and the convergence step is less than a preset convergence threshold, so as to obtain the target large model.

[0019] Further, after introducing the RoLA model with dynamic rank value setting into the pre-trained large language model and iteratively training it based on each text data until the evaluation index corresponding to the target task meets the preset index requirement to obtain a target large model, the method further comprises:

[0020] processing each text information belonging to the target task based on the target large model;

[0021] When it is determined that the difference between the output result of the target large model and the expected result for any text information is greater than a preset difference threshold, introducing the any text information into the generative adversarial network to generate a plurality of generated text information; and storing the any text information and the corresponding generated text information into a periodic sample library;

[0022] When it is determined that a preset update period is reached, calling the periodic sample library to update the target large model.

[0023] Further, the method of obtaining a plurality of text data based on a target task comprises:

[0024] processing non-text type original data under each heterogeneous resource to obtain original text data;

[0025] When it is determined that the original data is image data, extracting the text in the image data based on OCR technology to obtain the original text data; when it is determined that the original data is voice data, converting the voice data based on speech recognition technology to obtain the original text data;

[0026] preprocessing each original text data to eliminate irrelevant data information, and then obtaining the corresponding text data.

[0027] Further, before the method of obtaining a plurality of text data based on a target task, the method comprises:

[0028] When judging the multiple target tasks at the same time, LoRA models corresponding to each target task are constructed;

[0029] Adapter parameters of each LoRA model are integrated into a pre-trained large language model; wherein, during the training process, each LoRA model is independently trained in parallel.

[0030] In a second aspect, the technical scheme provides a large model adaptive training system based on task semantic perception, comprising:

[0031] A data acquisition and coding module is configured to acquire a plurality of text data based on a target task, and to select any text data to perform BERT coding to obtain a high-dimensional semantic vector.

[0032] The high-dimensional semantic vector is: ; wherein, t k is the selected text data, and k is the sequential number of the text data;

[0033] A complexity acquisition module is configured to project the high-dimensional semantic vector to a low-dimensional space by performing a first layer linear transformation and activation processing on the high-dimensional semantic vector, thereby obtaining a low-dimensional semantic vector; and to obtain a task complexity by performing a second layer linear transformation and normalization processing on the low-dimensional semantic vector.

[0034] The low-dimensional semantic vector is: ; wherein, ReLU() is a ReLU function, W1 is a weight matrix of the first layer linear transformation, b 1 is a bias vector of the first layer linear transformation; and the task complexity is: ; wherein, sigmoid() is a normalization function, W2 is a weight matrix of the second layer linear transformation, b 2 is a bias vector of the second layer linear transformation.

[0035] A dynamic rank acquisition module is configured to determine a complexity interval in which the task complexity is located, to determine a preset rank value interval corresponding to the complexity interval, and to obtain a dynamic rank value of a low-rank matrix in a RoLA model based on the task complexity.

[0036] The dynamic rank value is: ; wherein, r min is a lower limit value of the preset rank value interval, and r max is an upper limit value of the preset rank value interval.

[0037] The training optimization module is configured to introduce the RoLA model with dynamic rank value setting into a pre-trained large language model, and iteratively train the pre-trained large language model based on each text data until evaluation indexes corresponding to the target task meet preset index requirements to obtain a target large model.

[0038] Further, the training optimization module comprises:

[0039] The set construction unit is configured to construct a training set, a verification set and a test set based on each text data.

[0040] The iterative training unit is configured to iteratively train the pre-trained large language model introduced with the RoLA model based on the training set, and verify the model after each training based on the verification set.

[0041] The model test unit is configured to, when a preset total iterative training round is reached, test the model after iterative training and verification based on the test set to determine that a memory occupancy of the model during running is less than a preset memory occupancy threshold and a convergence step number is less than a preset convergence threshold, so as to obtain the target large model.

[0042] Further, the training optimization module comprises:

[0043] The pre-construction module is configured to, when multiple target tasks are included at the same time, construct a LoRA model corresponding to each target task.

[0044] The pre-integration module is configured to integrate adapter parameters of each LoRA model into a pre-trained large language model, and in the training process, each LoRA model is independently trained in parallel.

[0045] In a third aspect, the technical solution provides an electronic device, which comprises at least one processor coupled with a memory, and the memory stores a computer program configured to be executed by the processor to implement the method.

[0046] In a fourth aspect, the technical solution provides a computer readable storage medium, which stores a computer program configured to be executed by a processor to implement the method.

[0047] Advantages:

[0048] According to the technical scheme, the technical scheme provides a large model adaptive training method based on task semantic perception to solve the technical defect of resource mismatch caused by fixed rank when a LoRA model is introduced into a pre-trained large language model for specific task targeted training.

[0049] The method comprises: first, obtaining a plurality of text data based on a target task, and selecting any text data to perform BERT encoding to obtain a high-dimensional semantic vector. At this time, the text data can be converted into a multi-dimensional vector representation containing surface semantics and deep semantics based on the BERT encoding, that is, a computer-recognizable language. Secondly, the high-dimensional semantic vector is subjected to first layer linear transformation and activation processing to project it to a low-dimensional space, thereby obtaining a low-dimensional semantic vector; and the low-dimensional semantic vector is subjected to second layer linear transformation and normalization processing to obtain task complexity. Specifically, the first layer linear transformation and activation processing are used to project the high-dimensional semantic vector output by the BERT encoding to a low-dimensional space, reduce the calculation complexity, and filter irrelevant negative information in the semantics. The second layer linear transformation in the second layer linear transformation and normalization processing is used to map the feature vector output by the first layer to a rank parameter space to generate a predicted rank; the normalization processing is used to standardize the predicted rank of the second layer linear transformation to obtain a final dynamic rank, avoid gradient explosion or disappearance caused by excessive value fluctuation, make the model training more stable and converge faster; at the same time, the normalization processing can also make the inputs of different types of target tasks maintain consistent numerical distribution in rank prediction, ensure that the model has unified rank prediction standards for various target tasks, and improve the generalization ability of cross-task adaptation. Then, the RoLA model with a dynamic rank value is introduced into the pre-trained large language model, and the RoLA model is iteratively trained based on each text data until the evaluation index corresponding to the target task meets the preset index requirement to obtain a target large model. At this time, in the adaptive training process of the target large model, the most suitable resources can be allocated to the model corresponding to the target task through the setting of the dynamic rank, solving the problem of resource waste caused by "static rank rigidity" in the original LoRA model. Not only can the representation ability be adjusted according to the demand, but also all-round optimization can be performed in terms of shortening the training time, improving the convergence speed, and reducing the memory occupation.

[0050] It should be understood that all combinations of the foregoing concepts and additional concepts described in greater detail below (provided such concepts are not mutually inconsistent) are contemplated as being part of the inventive subject matter.

[0051] The foregoing and other aspects, embodiments, and features of the present teachings can be better understood from the following detailed description taken in conjunction with the accompanying drawings. Other aspects, embodiments, and features of the present teachings will be apparent from consideration of the specification and practice of the present teachings as disclosed herein. Attached Figure Description

[0052] The accompanying drawings are not intended to be drawn to scale. In the drawings, each identical or nearly identical component shown in the various figures may be denoted by the same reference numeral. For clarity, not every component is labeled in each figure. Embodiments of various aspects of the invention will now be described by way of example and with reference to the accompanying drawings, wherein:

[0053] Figure 1 This is a flowchart of the large model adaptive training method based on task semantic awareness described in this embodiment;

[0054] Figure 2 This is a flowchart illustrating the process of acquiring text data in this embodiment;

[0055] Figure 3 This is a flowchart illustrating the preprocessing process for simultaneous training of multiple tasks in a given scenario, as described in this embodiment.

[0056] Figure 4 This is a flowchart illustrating the specific training process of the target large model in this embodiment;

[0057] Figure 5 A flowchart illustrating the periodic updates of the target large model in this embodiment;

[0058] Figure 6 This is a block diagram of the large model adaptive training system based on task semantic awareness described in this embodiment;

[0059] Figure 7 This is a structural block diagram of the electronic device described in this embodiment. Detailed Implementation

[0060] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention without creative effort are within the scope of protection of the present invention. Unless otherwise defined, the technical or scientific terms used herein should have the ordinary meaning understood by those skilled in the art to which this invention pertains.

[0061] The terms "first", "second", and similar terms used herein do not denote any order, quantity, or importance, but are used to distinguish one element from another. Also, the singular forms "a", "an", and "the" do not denote the quantity limitation, but denote the existence of at least one, unless the context clearly indicates otherwise. The terms "comprise", "comprising", and similar terms mean that the elements or objects before "comprise" or "comprising" encompass the features, integers, steps, operations, elements, and / or components listed after "comprise" or "comprising", and do not exclude one or more other features, integers, steps, operations, elements, components, and / or groups thereof. The terms "upper", "lower", "left", "right", and the like are used only to indicate relative positional relationships, and when the absolute positions of the described objects are changed, the relative positional relationships can also be changed accordingly.

[0062] Natural language processing is a core technology of artificial intelligence, which has important applications in specific scenarios involving language processing and text processing. When a large language model corresponding to a specific task is needed, a pre-trained large language model is first obtained as a model base, and then a LoRA model is used for targeted fine-tuning. However, the low-rank matrix in the existing LoRA model adopts a pre-specified fixed rank, which cannot be adaptively adjusted according to actual needs. Therefore, there is a problem of resource mismatch when training a model for a specific task, and the resource occupation cannot be dynamically adjusted. Based on this, the present embodiment aims to provide a large model adaptive training method based on task semantic perception to solve this technical defect.

[0063] The large model adaptive training method based on task semantic perception described in the present embodiment will be specifically introduced below in conjunction with the accompanying drawings.

[0064] In conjunction with Figure 1 As shown in the figure, the method comprises:

[0065] Step S202, based on the target task, a plurality of text data are obtained, and any text data is selected for BERT encoding to obtain a high-dimensional semantic vector.

[0066] In the present embodiment, the BERT encoding is used to convert the text data into a multi-dimensional vector representation containing surface semantics and deep semantics, so that the computer can effectively recognize it.

[0067] Specifically, the high-dimensional semantic vector after BERT encoding is:

[0068] ;

[0069] Wherein, t kFor the selected text data, k is the sequential number of the text data, for example, for the first text data, k = 1.

[0070] In specific implementation, when the target task described in the embodiment is an education task, for the education-oriented large model, the corresponding target task includes: answering reading comprehension questions, correcting compositions, generating academic literature summaries, analyzing academic literature, and analyzing vocabulary.

[0071] Since subsequent model training is to be based on each text data, in order to improve the accuracy of subsequent model training, it is necessary to collect various types of heterogeneous data and perform corresponding text processing. Based on this, combined with Figure 2 As shown in the figure, the method specifically includes the following steps:

[0072] Step S20202, processing non-text original data under each heterogeneous resource to obtain original text data.

[0073] In specific implementation, when the original data is image data, the text in the image data is extracted based on OCR technology to obtain the original text data. When the original data is voice data, the voice data is converted based on speech recognition technology to obtain the original text data.

[0074] Further, taking the education task as an example, the original text data extracted by the OCR technology can be the question text extracted by the OCR technology from the picture. The original text data obtained by voice recognition can be the spoken language practice content transcribed by voice.

[0075] Step S20204, preprocessing each original text data to eliminate irrelevant data information, and then obtaining corresponding text data.

[0076] At this time, the step S20204 can eliminate invalid information such as page header, page footer, etc. during picture conversion, to further improve the accuracy during subsequent training and avoid interference from invalid information.

[0077] And considering the demand for multiple target tasks in the same scenario (such as in the education scenario, vocabulary analysis is one type of education task, and literature analysis is another type of education task), combined with Figure 3 As shown in the figure, the method specifically includes the following steps:

[0078] Step S20102, when multiple target tasks are included, constructing a LoRA model corresponding to each target task.

[0079] Step S20104, integrating the adapter parameters of each LoRA model into a pre-trained large language model.

[0080] In this embodiment, the pre-trained large language model is specifically selected as the chatglm model. In the training process, the LoRA models are independently trained in parallel. At this time, the steps S20102-S20104 meet the demand for parallel training of multiple tasks in the same scene, and the trained large model can be applied to the processing demand of multiple tasks at the same time.

[0081] In step S204, the high-dimensional semantic vector is subjected to first layer linear transformation and activation processing to project it to a low-dimensional space, thereby obtaining a low-dimensional semantic vector; and the low-dimensional semantic vector is subjected to second layer linear transformation and normalization processing to obtain the task complexity.

[0082] In specific implementation, the first layer linear transformation and activation processing are used to project the high-dimensional semantic vector output by the BERT encoding to a low-dimensional space, reduce the calculation complexity, and filter irrelevant negative information in the semantics.

[0083] Specifically, the low-dimensional semantic vector is:

[0084] ;

[0085] wherein, ReLU() is a ReLU function, and W1 is a weight matrix of the first layer linear transformation; b 1 is a bias vector of the first layer linear transformation, used to adjust the offset of the first layer linear transformation.

[0086] The second layer linear transformation in the second layer linear transformation and normalization processing is used to map the feature vector output by the first layer to a rank parameter space to generate a predicted rank. The normalization processing is used to standardize the predicted rank of the second layer linear transformation to obtain a final dynamic rank, so as to avoid gradient explosion or disappearance caused by too large numerical fluctuation, make the model training more stable and converge faster; at the same time, the normalization processing can also make the input of different types of target tasks keep consistent numerical distribution in rank prediction, ensure that the model has unified rank prediction standard for various target tasks, and improve the generalization ability of cross-task adaptation.

[0087] Specifically, the task complexity finally obtained is:

[0088] ;

[0089] wherein, sigmoid() is a normalization function, W2 is a weight matrix of the second layer linear transformation, and the function is used to further map the low-dimensional semantic vector to a space suitable for calculating the task complexity, b 2 is a bias vector of the second layer linear transformation, used to adjust the offset of the second layer linear transformation.

[0090] In step S206, the task complexity is determined to be in a complexity interval, and a preset rank value interval corresponding to the complexity interval is determined, and then a dynamic rank value of a low-rank matrix in the RoLA model is obtained based on the task complexity.

[0091] The dynamic rank value is:

[0092]

[0093] The dynamic rank value is: min The lower limit value of the preset rank value interval is r max The upper limit value of the preset rank value interval is r

[0094] In a specific implementation, the higher the task complexity, the higher the preset rank value interval, and the larger the corresponding dynamic rank value.

[0095] In step S208, the RoLA model with the dynamic rank value is introduced into a pre-trained large language model, and the large language model is iteratively trained based on the text data until an evaluation index corresponding to the target task meets a preset index requirement to obtain a target large model.

[0096] As a specific implementation, referring to FIG. 8, step S208 includes the following processes. Figure 4

[0097] In step S20802, a training set, a verification set, and a test set are constructed based on the text data.

[0098] In step S20804, the pre-trained large language model with the introduced RoLA model is iteratively trained based on the training set, and the model after each training is verified based on the verification set.

[0099] In a specific implementation, in the training process, when the loss value of the loss function decreases by less than a preset decrease threshold in a continuous preset training round, the parameter weight in the RoLA model is increased. In the verification process, when the output accuracy in a continuous preset verification round does not show an upward trend, the learning rate in the RoLA model is decreased.

[0100] In step S20806, when a preset total iteration training round is reached, the model after the iteration training and verification is tested based on the test set, to determine that the memory occupancy of the model during running is less than a preset memory occupancy threshold, and the convergence step is less than a preset convergence threshold, to obtain the target large model.

[0101] Based on the above steps S202 to S208, the target task in the education industry is taken as an example. In a specific training, the following steps are performed.

[0102] ​​(1) Collect various task texts in educational scenarios as original data, including reading comprehension questions, student essay correction, academic literature summary generation, etc. And process these original data accordingly (such as conversion of non-text original data, removal of meaningless symbols, correction of misspelled words, annotation of error areas, etc.) to obtain text data. Then, divide these text data into three parts: training set for training the model, validation set for validating the quality of the model, and test set for testing the final effect.

[0103] (2) Obtain a pre-trained large language model (specifically, chatglm model), and add LoRA model to the corresponding neural network layer of the pre-trained large language model. Then, determine the total variation interval of the rank value of the LoRA model as [4, 64], and use smaller rank value for simple tasks and larger rank value for complex tasks. At the same time, determine the adjustment rule during training, such as increasing the parameter weight of the corresponding LoRA model by 2 if the loss of the target task does not decrease by more than 5% for 3 consecutive rounds. The initial value of the learning rate is set to 5e -5 . During training, use the validation set to check the accuracy of the model. If the validation results of 3 consecutive rounds show that the accuracy of the model does not increase, reduce the current learning rate to half of the previous round. Based on the above settings, the parameters can be kept stable during updating. At the same time, the corresponding relationship between task complexity, complexity interval and preset rank value interval is set in advance. Specifically, when the complexity interval corresponding to the task complexity is [0, 0.3], the corresponding preset rank value interval is [4, 16]; when the complexity interval corresponding to the task complexity is [0.3, 0.7], the corresponding preset rank value interval is [16, 32]; when the complexity interval corresponding to the task complexity is [0.7, 1], the corresponding preset rank value interval is [32, 64].

[0104] (3) Perform BERT encoding on each text data to generate a 768-dimensional high-dimensional semantic vector, so that the computer can understand the semantic information of the text data. Perform first-layer linear transformation and activation processing to change the 768-dimensional high-dimensional semantic vector to a 256-dimensional low-dimensional semantic vector, which is used to filter out invalid information and simplify the calculation. Continue to perform second-layer linear transformation to convert the 256-dimensional low-dimensional semantic vector to the parameter range of the rank, and perform normalization processing to avoid the model training abnormal due to large and small numerical values, and finally obtain a task complexity falling within the interval [0, 1]. At this time, the closer the task complexity is to 1, the more complex the task is. Then, according to the complexity interval where the task complexity is located, the corresponding preset rank value interval is called to solve the dynamic rank value corresponding to the LoRA model. At this time, complex tasks use large rank and simple tasks use small rank, which can effectively save resources.

[0105] (4) The LoRA model updates weights based on a low-rank matrix with the introduced dynamic rank value. Specifically, when processing complex tasks (such as analyzing academic literature), a low-rank matrix with a dynamic rank value of 64 can be used after system calculation, so that the model can better mine deep semantics; when processing simple tasks (such as vocabulary identification), a low-rank matrix with a dynamic rank value of 8 can be used after system calculation, which can reduce the computer memory occupancy. And every 100 steps of training, the loss of the corresponding target task is confirmed. If the loss of the complex task (such as analyzing academic literature) decreases slowly, the weight of the corresponding LoRA model is increased, so that it can give priority to the use of training resources; if the loss of the simple task (such as vocabulary identification) tends to be stable, the weight of the corresponding LoRA model is reduced to avoid wasting resources.

[0106] (5) The training quality of the model is confirmed by the validation set. For example, when the target task is a reading comprehension task, it is necessary to confirm whether the model can find the key points, and when the target task is an essay correction task, it is necessary to confirm whether the model can accurately mark the error area and whether the provided structure optimization suggestion is reasonable. At the same time, the following indicators also need to be confirmed simultaneously: the training time of a single target task, and the GPU memory occupancy of the computer during training. If the output result of a certain target task is not good after being confirmed by the validation set, the corresponding relationship between the preset rank value interval and the complexity interval can be modified, such as setting a higher upper limit value for the preset rank value interval of high complexity tasks.

[0107] (6) After the training of each target task is completed, the corresponding key indicators all need to meet the expected requirements. For example, the dynamic rank value can be automatically changed according to the task difficulty, the dynamic rank value of complex tasks is stable in the interval [32, 64], and the dynamic rank value of simple tasks is stable in the interval [4, 16]. The training time of a single target task needs to be shortened by at least 40% compared to the LoRA model with a fixed rank, the GPU memory occupancy needs to be reduced by at least 20%, the convergence step number needs to be reduced by at least 50%, and when multiple target tasks are trained in parallel, the loss decrease needs to be relatively stable.

[0108] As a preferred implementation, in order to further improve the output accuracy of the model, in combination with Figure 5 as shown, the following steps are further included:

[0109] Step S21002, processing each text information belonging to the target task based on the target large model.

[0110] Step S21004, when the difference between the output result of the target large model and the expected result for any text information is greater than the preset difference threshold, introducing the any text information into the generative adversarial network to generate a plurality of generated text information; and storing the any text information and the corresponding generated text information into the periodic sample library.

[0111] Step S21006, when reaching the preset update period, calling the period sample library to update the target large model.

[0112] At this time, based on steps S21002-S21006, the model can be periodically optimized based on specific text data with low accuracy, thereby achieving the purpose of targeted optimization of the model, while reducing resource occupation and improving the accuracy of the model in processing corresponding same type text data.

[0113] As can be seen from the above, the method of the embodiment dynamically sets the rank value of the low-rank matrix in the LoRA model based on the task complexity, ensures the accuracy of the model output, and dynamically optimizes the training resources during the model training process, which also significantly improves the training time, GPU memory occupation rate, and convergence speed during single-target task and multi-target task training.

[0114] The above program can run in a processor, or can also be stored in a memory (or a computer readable storage medium). The computer readable medium includes permanent and non-permanent, removable and non-removable media, and can be realized by any method or technology to store information. The information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. According to the definition in this paper, computer readable medium does not include temporary computer readable medium, such as modulated data signals and carriers.

[0115] These computer programs can also be loaded into a computer or other programmable data processing device, so that a series of operation steps are performed on the computer or other programmable device to generate a computer implemented process, so that the instructions executed on the computer or other programmable device provide a process for implementing the steps specified in the flow Figure 1 The steps of one flow or multiple flows and / or the functions of one block or multiple blocks specified in the flow Figure 1 The steps of one flow or multiple flows and / or the functions of one block or multiple blocks specified in the flow

[0116] The embodiment also provides a large model adaptive training system based on task semantic perception, which combines Figure 6As shown, specifically includes the following functional modules:

[0117] The data acquisition and coding module is configured to acquire a plurality of text data based on the target task, and select any text data to perform BERT coding to obtain a high-dimensional semantic vector.

[0118] The high-dimensional semantic vector is: ; wherein, t k The selected text data is denoted as k, and k is the sequential number of the text data.

[0119] The complexity acquisition module is configured to project the high-dimensional semantic vector to a low-dimensional space by performing a first layer of linear transformation and activation processing, thereby obtaining a low-dimensional semantic vector; and obtain a task complexity by performing a second layer of linear transformation and normalization processing on the low-dimensional semantic vector.

[0120] The low-dimensional semantic vector is: ; wherein, ReLU() is a ReLU function, W1 is a weight matrix of the first layer of linear transformation, b 1 is a bias vector of the first layer of linear transformation; and the task complexity is: ; wherein, sigmoid() is a normalization function, W2 is a weight matrix of the second layer of linear transformation, b 2 is a bias vector of the second layer of linear transformation.

[0121] The dynamic rank acquisition module is configured to determine the complexity interval in which the task complexity is located, determine a preset rank value interval corresponding to the complexity interval, and then obtain a dynamic rank value of a low-rank matrix in the RoLA model based on the task complexity.

[0122] The dynamic rank value is: ; wherein, r min is a lower limit value of the preset rank value interval, and r max is an upper limit value of the preset rank value interval.

[0123] The training optimization module is configured to introduce the RoLA model with the dynamic rank value set into a pre-trained large language model, and iteratively train the large language model based on each text data until an evaluation index corresponding to the target task meets a preset index requirement, thereby obtaining a target large model.

[0124] Since the system is built based on the method, the above description has been described and will not be repeated here.

[0125] For example, the training optimization module includes:

[0126] The set construction unit is configured to construct a training set, a validation set, and a test set based on each text data.

[0127] an iterative training unit configured to iteratively train a pre-trained large language model to which a RoLA model is introduced based on the training set, and validate the model after each training based on a validation set; wherein, in the training process, if the loss value of the loss function decreases by less than a preset decrease threshold in a continuous preset number of training rounds, the parameter weight in the RoLA model is increased; and in the validation process, if the output accuracy in a continuous preset number of validation rounds does not show an upward trend, the learning rate in the RoLA model is decreased.

[0128] a model testing unit configured to, when a preset total number of iterative training rounds is reached, test the model after iterative training and validation based on the test set, to determine that the memory occupancy of the model when running is less than a preset memory occupancy threshold, and the convergence step is less than a preset convergence threshold, so as to obtain the target large model.

[0129] For another example, the system further comprises:

[0130] a pre-construction module configured to, when the plurality of target tasks are included at the same time, construct a LoRA model corresponding to each target task.

[0131] a pre-integration module configured to integrate the adapter parameters of each LoRA model into a pre-trained large language model; wherein, in the training process, each LoRA model is independently trained in parallel.

[0132] In combination with Figure 7 As shown in the accompanying drawings, the embodiment also provides an electronic device comprising at least one processor coupled with a memory, wherein the memory stores a computer program configured to be executed by the processor to perform the method.

[0133] Meanwhile, the embodiment also provides a computer readable storage medium having a computer program stored thereon, wherein the computer program is configured to be executed by a processor to implement the method.

[0134] Since the system, the electronic device and the storage medium are all built based on the method or used to implement the method, the following technical advantages are also obtained in actual application: (1) The model can adjust the expression ability according to the requirement in different training stages or tasks through dynamic rank setting. (2) The training efficiency is significantly improved through dynamic rank allocation. The single-task training time is shortened by about 40% compared with the original LoRA, and the convergence step number is reduced by more than half in the multi-task scene, which indicates that the adaptability to complex tasks is stronger. Specifically, the strong adaptability to the multi-task scene is reflected in the following aspects: In the multi-task joint training, the difficulty of different tasks is different, so the expression ability of the model and the demand for computing resources are different; and adjusting the rank parameter according to the requirement for each task can make multiple tasks reach stable convergence effect faster in parallel training, which reflects the strong adaptability to the multi-task scene.

[0135] Although the present application has been disclosed in the above preferred embodiments, it is not intended to limit the present application. Those skilled in the art can make various modifications and improvements without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application shall be subject to the scope defined by the claims.

Claims

1. A large-scale adaptive training method for task-semantic-aware models, characterized in that, include: When it is determined that multiple target tasks are included simultaneously, a LoRA model corresponding to each target task is constructed. The adapter parameters of each LoRA model are integrated into a pre-trained large language model; during the training process, each LoRA model is trained independently in parallel. Based on the target task, acquire several text data, and select any text data to perform BERT encoding to obtain a high-dimensional semantic vector; The high-dimensional semantic vector is: ;in, t k The selected text data is represented by k, which is the sequential number of the text data. The high-dimensional semantic vector is subjected to a first-level linear transformation and activation process to project it into a low-dimensional space, thereby obtaining a low-dimensional semantic vector; and the low-dimensional semantic vector is subjected to a second-level linear transformation and normalization process to obtain the task complexity. The first layer of linear transformation and activation processing is also used to reduce computational complexity and filter irrelevant negative information in semantics; the second layer of linear transformation and normalization processing is also used to avoid gradient explosion or vanishing due to numerical fluctuations, thereby improving training stability and convergence speed. The low-dimensional semantic vector is: Where ReLU() is the ReLU function, and W1 is the weight matrix of the first-level linear transformation. b 1 represents the bias vector of the first-level linear transformation; the task complexity is: Where sigmoid() is the normalization function, and W2 is the weight matrix of the second-level linear transformation. b 2 represents the bias vector for the second-level linear transformation; After determining the complexity interval in which the task complexity falls and identifying the preset rank interval corresponding to the complexity interval, the dynamic rank of the low-rank matrix in the LoRA model is obtained based on the task complexity; wherein, the correspondence between the corresponding preset rank interval and the complexity interval can be adjusted based on the output results of the target task confirmed by the validation set; Wherein, the dynamic rank value is: ; where r min r is the lower limit of the preset rank interval. max This is the upper limit of the preset rank range; The LoRA model with dynamic rank setting is introduced into the pre-trained large language model, and iteratively trained on each text data until the evaluation index corresponding to the target task meets the preset index requirements to obtain a target large model. Based on the aforementioned target big model, the text information belonging to the target task is processed; If, for any text information, the difference between the output of the target large model and the expected result is greater than a preset difference threshold, the text information is introduced into the Generative Adversarial Network to generate several generated text information; and the text information and the corresponding generated text information are stored in the periodic sample library. When the preset update cycle is reached, the target large model is updated by calling the cycle sample library.

2. The large model adaptive training method based on task semantic awareness according to claim 1, characterized in that, The process of iteratively training the model based on each text data until the evaluation metrics corresponding to the target task meet the preset metric requirements is obtained, thus obtaining a target large model; includes: Training, validation, and test sets are constructed based on the text data. The pre-trained large language model incorporating the LoRA model is iteratively trained based on the training set, and the model is validated after each training session based on the validation set. Specifically, during the training process, if the decrease value of the loss function is less than a preset decrease threshold for consecutive preset training rounds, the parameter weights in the LoRA model are increased. During the validation process, if the output accuracy does not show an upward trend for consecutive preset validation rounds, the learning rate of the LoRA model is decreased. When the preset total number of iterations training rounds is reached, the model after iterative training and validation is tested based on the test set to determine if the memory usage during model operation is less than a preset memory usage threshold and the number of convergence steps is less than a preset convergence threshold, thus obtaining the target large model.

3. The large model adaptive training method based on task semantic awareness according to claim 1, characterized in that, The acquisition of several text data based on the target task includes: The original non-text data from various heterogeneous resources is processed to obtain the original text data. Specifically, when the original data is determined to be image data, the text within the image data is extracted using OCR technology to obtain the original text data; when the original data is determined to be speech data, the speech data is converted using speech recognition technology to obtain the original text data. The original text data is preprocessed to remove irrelevant data and information, thereby obtaining the corresponding text data.

4. A large-scale adaptive training system for task semantic awareness, characterized in that, To implement the method according to any one of claims 1-3, comprising: The data acquisition and encoding module is used to acquire several text data based on the target task, and select any text data to perform BERT encoding to obtain a high-dimensional semantic vector; The high-dimensional semantic vector is: ;in, t k The selected text data is represented by k, which is the sequential number of the text data. The complexity acquisition module is used to perform a first-level linear transformation and activation process on the high-dimensional semantic vector to project it into a low-dimensional space, thereby obtaining a low-dimensional semantic vector; and to perform a second-level linear transformation and normalization process on the low-dimensional semantic vector to obtain the task complexity. The low-dimensional semantic vector is: Where ReLU() is the ReLU function, and W1 is the weight matrix of the first-level linear transformation. b 1 represents the bias vector of the first-level linear transformation; the task complexity is: Where sigmoid() is the normalization function, and W2 is the weight matrix of the second-level linear transformation. b 2 represents the bias vector for the second-level linear transformation; The dynamic rank acquisition module is used to determine the complexity interval in which the task complexity is located, and after determining the preset rank value interval corresponding to the complexity interval, obtain the dynamic rank value of the low-rank matrix in the LoRA model based on the task complexity. Wherein, the dynamic rank value is: ; where r min r is the lower limit of the preset rank interval. max This is the upper limit of the preset rank range; The training optimization module is used to introduce the LoRA model with dynamic rank setting into the pre-trained large language model, and iteratively train it based on each text data until the evaluation index corresponding to the target task meets the preset index requirements to obtain a target large model.

5. The large model adaptive training system based on task semantic awareness according to claim 4, characterized in that, The training optimization module includes: The set construction unit is used to build training sets, validation sets, and test sets based on various text data. An iterative training unit is used to iteratively train a pre-trained large language model incorporating the LoRA model based on the training set, and to validate the model after each training based on the validation set. Specifically, during training, if the decrease in the loss value of the loss function is less than a preset decrease threshold for consecutive preset training rounds, the parameter weights within the LoRA model are increased. During validation, if the output accuracy does not show an upward trend for consecutive preset validation rounds, the learning rate within the LoRA model is decreased. The model testing unit is used to determine when the preset total number of iterations of training has been reached. Based on the test set, the model after iterative training and verification is tested to determine when the memory usage during model operation is less than a preset memory usage threshold and the number of convergence steps is less than a preset convergence threshold, so as to obtain the target large model.

6. The large model adaptive training system based on task semantic awareness according to claim 4, characterized in that, include: A pre-built module is used to determine when multiple target tasks are included simultaneously and to build a LoRA model that corresponds one-to-one with each target task. The pre-integration module is used to integrate the adapter parameters of each LoRA model into a pre-trained large language model; during the training process, each LoRA model is trained independently in parallel.

7. An electronic device, characterized in that, It includes at least one processor coupled to a memory storing a computer program configured to be executed by the processor to perform the method of any one of claims 1-3.

8. A computer-readable storage medium, characterized in that, It stores a computer program thereon, which is executed by a processor to implement the method of any one of claims 1-3.

Citation Information

Patent Citations

  • Method and device for generating difficult sample set, storage medium and electronic device

    CN119152308A

  • Task processing method, device and equipment based on dynamic LoRA network and medium

    CN120469778A