Task processing method, task processing device, electronic equipment and readable storage medium

By introducing LoRA technology and adapter Adapter into the large language model, only fine-tuning of the adapter weight parameters is solved, and the storage space occupation problem caused by the large language model is achieved, efficient resource utilization and fast response to task switching are achieved.

CN119248339APending Publication Date: 2025-01-03VIVO MOBILE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411222606.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-02
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

The large language model has huge parameters, which leads to excessive storage space and serious waste of resources. Especially when customization capabilities are required in multiple different language processing tasks, the parameters of the entire model need to be frequently fine-tuned, resulting in wasted time and resource costs. .

Method used

Using Low-Rank Adaptation of Large Language Models (LoRA) technology, the adapter Adapter is added to the decoding layer of the large language model, so that only the weight parameters of the Adapter are fine-tuned, rather than fine-tuning the weight parameters of the entire model, thereby reducing the storage space usage. And only the required adapter weight parameters are loaded when switching between different tasks.

Benefits of technology

It effectively reduces the usage of parameter data storage space of large language models, improves resource utilization and model inference efficiency, reduces the consumption of storage resources, and improves speed during task switching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248339A_ABST
    Figure CN119248339A_ABST
Patent Text Reader

Abstract

The invention discloses a task processing method, a task processing device, electronic equipment and a readable storage medium, and belongs to the technical field of computers. The task processing method comprises the steps of obtaining a first processing task; first weight parameters corresponding to the first processing task are determined, the first weight parameters are used for task processing of a first model, the first model comprises a base model and N adapters, the first weight parameters are weight parameters of the N adapters corresponding to the first processing task, and N is a positive integer; and processing the first processing task based on the base model, the N adapters and the first weight parameter to obtain a first processing result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and specifically relates to a task processing method, a task processing device, an electronic device and a readable storage medium. Background Art

[0002] The Big Language Model is a machine learning model that can automatically learn language rules and generate natural language text. It is an important research direction in the field of natural language processing and can be widely used in many fields such as text summarization, polishing, translation, expansion generation, and dialogue systems. The Big Language Model is a neural network model with a huge number of parameters. It can be trained with a large corpus to learn the rules and patterns of language.

[0003] For many different language processing tasks, such as text summarization, tone stylization, expansion and polishing, etc., large language models are often required to have customization capabilities. The number of parameters of such large language models with customization capabilities often reaches billions or tens of billions. These parameter data will take up a lot of storage space, resulting in a waste of resources. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a task processing method, a task processing device, an electronic device and a readable storage medium, which can reduce the storage space occupied by parameter data of a large language model and improve resource utilization.

[0005] In a first aspect, an embodiment of the present application provides a task processing method, the method comprising:

[0006] Get the first processing task;

[0007] Determine a first model weight parameter corresponding to a first processing task, wherein the first weight parameter is used for a first model to perform task processing, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer;

[0008] The first processing task is processed based on the base model, the N adapters, and the first weight parameter to obtain a first processing result.

[0009] In a second aspect, an embodiment of the present application provides a task processing device, the device comprising:

[0010] Acquisition module and processing module; wherein,

[0011] An acquisition module, used for acquiring a first processing task;

[0012] The acquisition module is further used to determine a first weight parameter corresponding to the first processing task, wherein the first weight parameter is used for the first model to perform task processing, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer;

[0013] The processing module is used to process the first processing task based on the base model, the N adapters, and the first weight parameter to obtain a first processing result.

[0014] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the language recognition method described in the first aspect are implemented.

[0015] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the language recognition method described in the first aspect are implemented.

[0016] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the language recognition method as described in the first aspect.

[0017] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the language recognition method as described in the first aspect.

[0018] In the embodiment of the present application, a first processing task is obtained; a first weight parameter corresponding to the first processing task is determined, wherein the first weight parameter is used for task processing by a first model, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer; the first processing task is processed based on the base model, the N adapters, and the first weight parameter to obtain a first processing result. Therefore, when executing different processing tasks, only the base model and the adapters corresponding to different processing tasks and their corresponding weight parameters are required, and there is no need for a large language model to include parameter data of various processing tasks at the same time, thereby greatly reducing the parameter data storage space occupied by the large language model, thereby effectively saving storage resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 This is one of the flowcharts of a task processing method provided in an embodiment of the present application;

[0020] Figure 2 This is a second flowchart of a task processing method provided in an embodiment of the present application;

[0021] Figure 3 This is a flowchart of a task processing method provided in an embodiment of the present application;

[0022] Figure 4 This is a fourth flowchart of a task processing method provided in an embodiment of the present application;

[0023] Figure 5 This is a fifth flowchart of a task processing method provided in an embodiment of the present application;

[0024] Figure 6 This is a sixth flowchart of a task processing method provided in an embodiment of the present application;

[0025] Figure 7 It is a schematic diagram of a LoRA model provided in an embodiment of the present application;

[0026] Figure 8 is a schematic diagram of Adapter parameter loading provided in an embodiment of the present application;

[0027] Fig. 9 is a schematic diagram of task switching provided by an embodiment of the present application;

[0028] Fig.10 is a structural diagram of a task processing device provided in an embodiment of the present application;

[0029] Fig.11 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0030] Fig.12 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0031] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0032] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0033] The terms "at least one (item)", "at least one of" and the like in the specification and claims of the present application refer to any one, any two or a combination of more than two of the objects included therein. For example, at least one (item) of a, b, and c can be represented by: "a", "b", "c", "a and b", "a and c", "b and c" and "a, b and c", where a, b, and c can be single or multiple. Similarly, "at least two (items)" refers to two or more, and its meaning is similar to that of "at least one (item)".

[0034] The following, in conjunction with the accompanying drawings, describes in detail the language recognition method, language recognition device, electronic device and readable storage medium provided in the embodiments of the present application through specific embodiments and their application scenarios.

[0035] The language recognition method, language recognition device, electronic device and readable storage medium provided in the embodiments of the present application can be applied to language recognition scenarios.

[0036] At present, large language models like ChatGPT are booming. A large language model is a machine learning model that can automatically learn language rules and generate natural language text. It is an important research direction in the field of natural language processing and can be widely used in many fields such as text summarization, polishing, translation, expansion generation, dialogue systems, etc. A large language model is a neural network model with a huge number of parameters. It can be trained with a large corpus to learn the rules and patterns of language. During the training process, the large language model can recognize different levels of language units such as words, phrases, sentences and paragraphs in the language, and can encode and decode them, thereby realizing the generation and understanding of natural language text.

[0037] Since the number of parameters of large language models often reaches billions or tens of billions, the cost requirements for training and reasoning large language models are very high. For multiple different language processing tasks, such as text summarization, tone stylization, expansion and polishing, large language models are often required to have customization capabilities. In order to make large language models customized, it is necessary to use specific training data for different language processing tasks to fine-tune all parameters of the large language model, so as to train the entire large language model. However, if specific data is used to train the entire large language model for each language processing task, it will cause a huge waste of time and resource costs. Therefore, the Low-Rank Adaptation of Large Language Models (LoRA) came into being. It adds an additional adapter Adapter in the decoding layer of the large language model, so that when training the large language model, only the weight parameters of the Adapter need to be fine-tuned, and the weight parameters of the entire large language model do not need to be fine-tuned, and the training of the large language model can be completed.

[0038] Although the LoRA model effectively reduces the training cost of fine-tuning large language models for different scenarios, when large language models are deployed on the end-side at a large scale, they are generally required to occupy megabytes of storage space due to their large size. For multiple different language processing tasks, such as text summarization, tone stylization, expansion and polishing, large language models are often required to have customization capabilities, and the number of parameters of such large language models with customization capabilities often reaches billions or tens of billions, and these parameter data will take up a lot of storage space, resulting in a waste of resources.

[0039] To this end, an embodiment of the present application provides a task processing method, a task processing device, an electronic device, and a readable storage medium, to obtain a first processing task; determine a first weight parameter corresponding to the first processing task, wherein the first weight parameter is used for task processing by a first model, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer; based on the base model, the N adapters, and the first weight parameter, the first processing task is processed to obtain a first processing result. Therefore, when executing different processing tasks, only the base model and the adapters corresponding to different processing tasks and their corresponding weight parameters are required, and there is no need for a large language model to include parameter data of various processing tasks at the same time, thereby greatly reducing the parameter data storage space occupied by the large language model, thereby effectively saving storage resources.

[0040] The execution subject of the task processing method provided in the embodiment of the present application may be a task processing device. Exemplarily, the task processing device may be an electronic device, or a functional component or functional entity in the electronic device. The following will take the execution subject as an electronic device as an example to exemplify the task processing method provided in the embodiment of the present application.

[0041] Figure 1 is a flowchart of a task processing method provided in an embodiment of the present application, such as Figure 1 As shown, the task processing method provided in the embodiment of the present application may include the following steps 101 to 103.

[0042] Step 101: The electronic device obtains a first processing task.

[0043] In some embodiments of the present application, the electronic device may obtain first task information of the first processing task while obtaining the first processing task.

[0044] In some embodiments of the present application, the first processing task is used to instruct processing of first task information.

[0045] In some embodiments of the present application, the above-mentioned first processing task may be a language processing task, an audio processing task, an image processing task or other processing tasks, and this embodiment does not make any specific restrictions here.

[0046] In some embodiments of the present application, when the above-mentioned first processing task can be a language processing task, the first task information can be language information, and the above-mentioned language processing task can be any one of text language summary, language polishing, language translation, language expansion generation, language dialogue and other language processing tasks.

[0047] For example, when the first processing task is text language summarization, the first processing task is used to instruct to perform text language summarization on the language information. For another example, when the first language processing task is language polishing, the first language processing task is used to instruct to perform language polishing on the language information.

[0048] Step 102: The electronic device determines a first model weight parameter corresponding to the first processing task.

[0049] In some embodiments of the present application, the above-mentioned first model weight parameters are used for the first model to perform task processing.

[0050] In some embodiments of the present application, when the first processing task is a language processing task, the first model may be a large language model. For example, the first model may be a LoRA model.

[0051] In some embodiments of the present application, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, where N is a positive integer.

[0052] In some embodiments of the present application, the first model includes a base model and N adapters, the weight parameters of the first task processing model include the first weight parameters of the N adapters and the second weight parameters of the base model, and the first model weight parameters are the first weight parameters corresponding to the first processing task.

[0053] In some embodiments of the present application, each adapter includes a weight matrix; the first model weight parameters are weight parameters of N weight matrices; combined Figure 1 ,like Figure 2 As shown, the above step 102 can be implemented through the following steps 102a to 102c:

[0054] Step 102a: The electronic device determines a first storage space corresponding to a first processing task.

[0055] In some embodiments of the present application, the first storage space is used to store a weight parameter file associated with the first processing task, and the weight parameter file includes M weight parameters.

[0056] Step 102b: The electronic device determines at least one third weight parameter from the M weight parameters based on the rank of the weight matrix of the first adapter as a weight parameter of the weight matrix of the first adapter.

[0057] In some embodiments of the present application, the weight matrix of the first adapter may be a low-rank decomposition matrix, which is used to perform low-rank decomposition on the first weight parameter of the first task processing model.

[0058] In some embodiments of the present application, the rank of the weight matrix may represent the number of weight vectors included in the weight matrix, wherein any two weight vectors in the weight matrix are linearly independent.

[0059] In some embodiments of the present application, the electronic device may determine at least one third weight parameter from the above-mentioned M weight parameters according to the rank of the above-mentioned weight matrix and the dimension of each weight vector in the weight matrix.

[0060] For example, when the first adapter is the first adapter of the above-mentioned N adapters, if the rank of the first adaptation weight matrix is ​​64, that is, if the weight matrix of the first adapter includes 64 weight vectors, the dimensions of the weight vectors in the first adaptation weight matrix are all 4096, then the electronic device determines the first 64*4096 weight parameters from the M weight parameters, and uses the 4096 weight parameters of the first group as the weight parameters of the first weight vector in the weight matrix of the first adapter, and uses the 4096 weight parameters of the second group as the weight parameters of the second weight vector in the weight matrix of the first adapter.... Use the 4096 weight parameters of the 64th group as the weight parameters of the 64th weight vector in the weight matrix of the first adapter.

[0061] Step 102c: The electronic device determines, based on the rank of the weight matrix of the second adapter, at least one fourth weight parameter from the model weight parameters subsequent to at least one third model weight parameter as the weight parameter of the weight matrix of the second adapter.

[0062] The first adapter is any one of the first N-1 adapters among the previous N adapters; the second adapter is the next adapter of the first adapter; and N and M are both integers greater than 1.

[0063] It should be noted that the process of determining the at least one fourth weight parameter may refer to the related description of the at least one third weight parameter in the above step 102b. To avoid repetition, this embodiment will not be described again here.

[0064] For example, when the second adapter is the second adapter among the above-mentioned N adapters, if the rank of the second adaptation weight matrix is ​​64, that is, if the weight matrix of the second adapter includes 64 weight vectors, the dimension of the weight vector in the second adaptation weight matrix is ​​4096, then the electronic device obtains 64*4096 weight parameters from the weight parameters after the first 64*4096 of the M weight parameters, and uses the 4096 weight parameters of the first group as the weight parameters of the first weight vector in the weight matrix of the second adapter, and uses the 4096 weight parameters of the second group as the weight parameters of the second weight vector in the weight matrix of the second adapter.... Use the 4096 weight parameters of the 64th group as the weight parameters of the 64th weight vector in the weight matrix of the second adapter.

[0065] In this way, the electronic device determines at least one third weight parameter from the M model weight parameters through the rank of the weight matrix of the first adapter as the weight parameter of the weight matrix of the first adapter, and can accurately and quickly obtain the weight parameter of the weight matrix of the first adapter from the M weight parameters.

[0066] Step 103: The electronic device processes the first processing task based on the base model, the N adapters, and the first weight parameter to obtain a first processing result.

[0067] In some embodiments of the present application, the base model includes N cascaded decoding layers, one decoding layer is connected to one adapter, and each adapter includes a first weight matrix and a second weight matrix; based on Figure 2 ,like Figure 3 As shown, the above step 103 can be implemented through the following steps 103a to 103e:

[0068] Step 103a: The electronic device performs a dimensionality reduction operation on the first task information of the first processing task based on the weight parameters of the first weight matrix of the first adapter to obtain a first dimensionality reduction result corresponding to the first adapter, and performs a dimensionality increase operation on the first dimensionality reduction result based on the weight parameters of the second weight matrix of the first adapter to obtain a first dimensionality increase result corresponding to the first adapter.

[0069] In some embodiments of the present application, the first weight matrix is ​​used to perform a dimensionality reduction operation on the first task information, and the second weight matrix is ​​used to perform a dimensionality increase operation on the first task information.

[0070] In some embodiments of the present application, the rank of the first weight matrix is ​​smaller than the dimension of the first task information, and the dimension of all weight vectors in the first weight matrix is ​​consistent with the dimension of the first task information. The electronic device can perform weighted operations on the first task information based on the rank of the first weight matrix and the weight parameters of all weight vectors in the first weight matrix to obtain weighted operation results corresponding to all weight vectors in the first weight matrix, so as to perform a dimensionality reduction operation on the first task information and obtain a first dimensionality reduction result corresponding to the first adapter, and the dimension of the first dimensionality reduction result is consistent with the rank of the first weight matrix.

[0071] For example, when the dimension of the first language information is 4096, if the rank of the above-mentioned first weight matrix is ​​64, the dimension of each weight vector in the first weight matrix is ​​4096, and each weight vector corresponds to 4096 weight parameters, then each weight parameter of the first weight vector in the first weight matrix can be the first weight of each dimension in the first task information, and the electronic device can use the first weight of each dimension to weight the first task information, and obtain a third weighted operation result of a dimension corresponding to the first weight vector. Similarly, each weight parameter of other weight vectors in the first weight matrix can be the second weight of each dimension in the first task information, and the electronic device can use the second weight of each dimension to weight the first task information, and obtain a fourth weighted operation result of a dimension corresponding to other weight vectors. Then, the electronic device uses the vector composed of the weighted results corresponding to the 64 weight vectors as the first dimensionality reduction result corresponding to the first adapter. Among them, the dimension of the vector composed of the weighted results corresponding to the 64 weight vectors is 64, which is consistent with the rank of the first weight matrix.

[0072] In some embodiments of the present application, the rank of the second weight matrix is ​​equal to the dimension of the first task information, and the dimension of all weight vectors in the first weight matrix is ​​consistent with the dimension of the first dimensionality reduction result. The electronic device can perform weighted operations on the first dimensionality reduction result based on the rank of the second weight matrix and the weight parameters of all weight vectors in the second weight matrix to obtain weighted operation results corresponding to all weight vectors of the second weight matrix, so as to perform dimensionality increase operation on the first dimensionality reduction result to obtain a first dimensionality increase result corresponding to the first adapter, and the dimension of the first dimensionality increase result is consistent with the rank of the second weight matrix.

[0073] For example, the rank of the above-mentioned second weight matrix is ​​4096, the dimension of each weight vector in the second weight matrix is ​​64, and each weight vector corresponds to 64 weight parameters, then each weight parameter of the first weight vector in the second weight matrix can be the second weight of each dimension in the first dimensionality reduction result, and the electronic device can use the second weight of each dimension to weight the first dimensionality reduction result to obtain a fifth weighted operation result of a dimension corresponding to the first weight vector in the second weight matrix. Similarly, each weight parameter in the other weight vectors in the second weight matrix can be the second weight of each dimension in the first dimensionality reduction result, and the electronic device can weight the first dimensionality reduction result with the second weight of each dimension to obtain a second weighted result of a dimension corresponding to other weight vectors. Then, the electronic device uses the vector composed of the weighted operation results corresponding to the 4096 weight vectors in the second weight matrix as the first dimensionality increase result corresponding to the first adapter. Among them, the dimension of the vector composed of the weighted operation results corresponding to the 4096 weight vectors is 4096, which is consistent with the rank of the second weight matrix.

[0074] Step 103b: The electronic device performs a decoding operation on the first task information based on the weight parameter of the first decoding layer to obtain a first decoding result.

[0075] In some embodiments of the present application, the first decoding layer is a decoding layer connected to the first adapter.

[0076] In some embodiments of the present application, the weight parameters of the decoding layer may be weight parameters of a weight matrix of the decoding layer.

[0077] In some embodiments of the present application, the rank of the weight matrix of the decoding layer is the same as the dimension of the first task information, and the dimension of all weight vectors in the weight matrix of the decoding layer is consistent with the dimension of the first task information. The electronic device can perform weighted operations on the first task information based on the rank of the weight matrix of the first decoding layer and the weight parameters of all weight vectors in the first weight matrix to obtain weighted operation results corresponding to all weight vectors in the first weight matrix, so as to perform a decoding operation on the first task information and obtain a first decoding result corresponding to the first decoding layer. The dimension of the first decoding result is consistent with the rank of the weight matrix of a decoding layer, that is, the dimension of the first decoding result is the same as the dimension of the first task information.

[0078] For example, when the dimension of the first language information is 4096, the rank of the weight matrix of the first decoding layer and the dimension of each weight vector in the weight matrix of the first decoding layer are 4096, and each weight vector in the weight matrix of the first decoding layer corresponds to 4096 weight parameters, then each weight parameter of the first weight vector in the first weight matrix can be the third weight of each dimension in the first task information, and the electronic device can use the third weight of each dimension to weight the first task information, and obtain the sixth weighted operation result of one dimension corresponding to the first weight vector in the weight matrix of the first decoding layer. Similarly, each weight parameter of other weight vectors in the first weight matrix can be the fourth weight of each dimension in the first task information, and the electronic device can use the second weight of each dimension to weight the first task information, and obtain the seventh weighted operation result of one dimension corresponding to other weight vectors. Then, the electronic device uses the vector composed of the weighted operation results corresponding to the 4096 weight vectors as the first decoding result corresponding to the first decoding layer. Among them, the dimension of the vector composed of the weighted operation results corresponding to the 4096 weight vectors is 4096, which is consistent with the rank of the weight matrix of the first decoding layer and the dimension of the first language information.

[0079] Step 103c: The electronic device performs a weighted operation on the first decoding result and the first dimensionality increase result to obtain a first weighted operation result.

[0080] In some embodiments of the present application, the electronic device may perform weighted operations on the first decoding result and the first dimensionality increase result in each dimension to obtain a first weighted operation result.

[0081] For example, when the first decoding result and the first dimensionality increase result are both 4096, the electronic device may perform a weighted operation on the first dimension of the first decoding result and the first dimension of the first dimensionality increase result, perform a weighted operation on the second dimension of the first decoding result and the second dimension of the first dimensionality increase result... perform a weighted operation on the 4096th dimension of the first decoding result and the 4096th dimension of the first dimensionality increase result to obtain a first weighted operation result, the first weighted operation result including the weighted operation result of the first dimension of the first decoding result and the first dimension of the first dimensionality increase result, the second dimension of the first decoding result and the first dimension of the second dimensionality increase result... the weighted operation result of the 4096th dimension of the first decoding result and the 4096th dimension of the first dimensionality increase result, that is, the first weighted operation result is also a 4096-dimensional vector.

[0082] Step 103d, the electronic device performs a dimensionality reduction operation on the weighted operation result corresponding to the previous adapter of the third adapter based on the weight parameters of the first weight matrix of the third adapter to obtain a second dimensionality reduction result corresponding to the third adapter, and performs a dimensionality increase operation on the second dimensionality reduction result based on the weight parameters of the second weight matrix of the third adapter to obtain a second dimensionality increase result corresponding to the third adapter.

[0083] It should be noted that, the process of performing dimensionality reduction operation on the weighted calculation result corresponding to the previous adapter in the above step 103d can refer to the relevant description of performing dimensionality reduction operation on the first language information in the above step 103a, and the process of performing dimensionality increase operation on the second dimensionality reduction result in the above step 103d can refer to the relevant description of performing dimensionality increase operation on the first dimensionality reduction result in the above step 103a. To avoid repetition, this embodiment will not be repeated here.

[0084] Step 103e: The electronic device performs a decoding operation on the weighted calculation result corresponding to the previous adapter of the third adapter based on the weight parameters of the second decoding layer to obtain a second decoding result.

[0085] In some embodiments of the present application, the second decoding layer is a decoding layer connected to the third adapter.

[0086] In some embodiments of the present application, the weighted calculation result corresponding to the previous adapter of the third adapter can be understood as the weighted calculation result of the dimensionality increase result corresponding to the previous adapter of the third adapter and the decoding result corresponding to the decoding layer connected to the previous adapter of the third adapter.

[0087] It should be noted that the process of decoding the weighted calculation result corresponding to the previous adapter in the above step 103e can refer to the relevant description of decoding the first language information in the above step 103b, and to avoid repetition, this embodiment will not be repeated here.

[0088] Step 103f: The electronic device determines the weighted calculation result corresponding to the last adapter among the N adapters as the first processing result.

[0089] In some embodiments of the present application, the weighted calculation result corresponding to the previous adapter of the last adapter can be understood as the weighted calculation result of the corresponding dimensionality increase result of the last adapter and the decoding result corresponding to the decoding layer connected to the last adapter.

[0090] The third adapter is any adapter after the first adapter among the N adapters.

[0091] In this way, the electronic device performs a dimensionality reduction operation on the first task information of the first processing task based on the weight parameters of the first weight matrix of the first adapter, and obtains the first dimensionality reduction result corresponding to the first adapter, and can map the high-dimensional features of the first task information to the low-dimensional feature space; based on the weight parameters of the second weight matrix of the first adapter, performs a dimensionality increase operation on the first dimensionality reduction result, and obtains the first dimensionality increase result corresponding to the first adapter, and can remap the low-dimensional features of the first dimensionality reduction result back to the original high-dimensional feature space, so that while maintaining the performance of the task processing model, only a few additional weight parameters need to be introduced into the language model, and the task processing model can perform different processing tasks without configuring all the weight parameters for each processing task, thereby effectively reducing the memory usage and processing volume of the data, improving the efficiency of the model reasoning operation and saving storage resources.

[0092] In the task processing method provided in the present application, a first processing task is obtained; a first weight parameter corresponding to the first processing task is determined, wherein the first weight parameter is used for task processing by a first model, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer; the first processing task is processed based on the base model, the N adapters, and the first weight parameter to obtain a first processing result. Therefore, when executing different processing tasks, only the base model and the adapters corresponding to different processing tasks and their corresponding weight parameters are required, and there is no need for a large language model to include parameter data of various processing tasks at the same time, thereby greatly reducing the parameter data storage space occupied by the large language model, thereby effectively saving storage resources.

[0093] In some embodiments of the present application, before the above step 101, Figure 2 ,like Figure 4 As shown, the task processing method provided by the present application also includes the following steps 104 to 106:

[0094] Step 104: The electronic device obtains a task processing training set.

[0095] In some embodiments of the present application, the task processing training set includes at least one processing task and at least one task information, the at least one task information includes at least one task processing sample and at least one label, and the at least one label includes a label for each task processing sample in the at least one task sample corresponding to a different processing task.

[0096] Step 105: The electronic device adjusts the weight parameters of the task processing model to be trained based on the task processing training set to obtain at least one fourth model weight parameter, where each fourth model weight parameter corresponds to a processing task.

[0097] In some embodiments of the present application, the structure of the task processing model to be trained is similar to the structure of the first model, and the weight parameters of the task processing model to be trained may be weight parameters of the adapter in the task processing model to be trained.

[0098] In some embodiments of the present application, when the electronic device adjusts the weight parameters of the task processing model to be trained based on the task processing training set, the above-mentioned at least one task processing sample and a language processing task can be input into the language model to be trained, and the task processing model to be trained can output the processing result corresponding to each task processing sample. The electronic device then calculates the loss function of the task processing model to be trained based on the processing corresponding to each task processing sample and the label of each task processing sample corresponding to the processing task, and then adjusts the weight parameters of the task processing model to be trained when the loss function is greater than the threshold, and then inputs the above-mentioned at least one task processing sample into the task processing model to be trained, and the task processing model to be trained outputs the processing result corresponding to each task processing sample. Then, the electronic device calculates the loss function of the task processing model to be trained based on the processing result corresponding to each task processing sample and the label corresponding to each task processing sample. This cycle is repeated until the loss function is less than or equal to the threshold, and the fourth weight parameter corresponding to the first processing task is obtained.

[0099] It should be noted that the process of obtaining the fourth model weight parameters corresponding to other processing tasks is similar to the above process. To avoid repetition, this embodiment will not be repeated here.

[0100] In some embodiments of the present application, the fourth model weight parameter is an adjusted adapter weight parameter.

[0101] Step 106: The electronic device stores at least one weight parameter file in a storage space corresponding to each processing task.

[0102] In some embodiments of the present application, each of the above-mentioned weight parameter files includes a fourth model weight parameter corresponding to a processing task.

[0103] In some embodiments of the present application, the electronic device may pre-allocate a corresponding storage space for each processing task. Then, after obtaining at least one fourth model weight parameter, the electronic device stores at least one weight parameter file in the storage space corresponding to each processing task.

[0104] In this way, when the weight parameters of the task processing model to be trained are the weight parameters of the adapter of the task processing model to be trained, the electronic device adjusts the weight parameters of the task processing model to be trained based on the processing task training set to obtain at least one fourth model weight parameter, and each fourth model weight parameter corresponds to a processing task, so that the electronic device can complete the training of the task processing model to be trained by training a small number of adapter weight parameters, without fine-tuning all the parameters of the task processing model, effectively reducing the amount of data calculation in the model training process, thereby improving the efficiency of model training.

[0105] In some embodiments of the present application, after the above step 103, in combination with Figure 2 ,like Figure 5 As shown, the task processing method provided by the present application also includes the following steps 107 to 108:

[0106] Step 107: The electronic device obtains historical usage information of the first model weight parameter.

[0107] In some embodiments of the present application, the above-mentioned historical usage information may include at least one of the number of times the above-mentioned first model weight parameter is used within a historical period, the most recent use time of the above-mentioned first model weight parameter, and the total number of times the first model weight parameter is used.

[0108] Step 108: When the historical usage information meets a condition, the electronic device deletes the first model parameter from the first storage space.

[0109] In some embodiments of the present application, the electronic device determines that a condition is met when at least one of the following is met: the number of times the above-mentioned first model weight parameter is used within the historical duration is less than a first preset number of times, the time difference between the most recent use time of the above-mentioned first model weight parameter and the current time is greater than the preset duration, and the total number of times the first model weight parameter is used is less than a second preset number of times.

[0110] In some embodiments of the present application, the number of times the first model weight parameter is used within the historical period is less than the first preset number of times, indicating that the historical usage frequency of the first model weight parameter is small, that is, the first model weight parameter is not used frequently. Therefore, the first model parameter can be deleted from the first storage space.

[0111] In some embodiments of the present application, if the time difference between the most recent use time of the first model weight parameter and the current time is greater than a preset duration, it means that the first model weight parameter has not been used recently. Therefore, the first model parameter can be deleted from the first storage space.

[0112] In some embodiments of the present application, the total number of times the first model weight parameter is used is less than the second preset number of times, indicating that the first model weight parameter is not used a total of a small number of times, and therefore, the first model parameter can be deleted from the first storage space.

[0113] In some embodiments of the present application, when the historical usage information does not satisfy a condition, the electronic device retains the first model parameter in the first storage space.

[0114] In some embodiments of the present application, the historical usage information does not satisfy the conditions including at least one of the following: the number of times the first model weight parameter is used within the historical duration is greater than or equal to a first preset number of times, the time difference between the most recent use time of the first model weight parameter and the current time is less than or equal to the preset duration, and the total number of times the first model weight parameter is used is greater than or equal to a second preset number of times.

[0115] In some embodiments of the present application, the number of times the first model weight parameter is used within a historical period is greater than or equal to a first preset number of times, indicating that the historical usage frequency of the first model weight parameter is large, that is, the first model weight parameter is frequently used. Therefore, the first model parameter can be retained in the first storage space.

[0116] In some embodiments of the present application, if the time difference between the most recent use time of the first model weight parameter and the current time is less than or equal to a preset time length, it means that the first model weight parameter has been used recently. Therefore, the first model parameter can be retained in the first storage space.

[0117] In some embodiments of the present application, the total number of times the first model weight parameter is used is greater than or equal to the second preset number of times, indicating that the first model weight parameter is used a large number of times in total. Therefore, the first model parameter can be retained in the first storage space.

[0118] In this way, the electronic device can effectively reduce memory usage without affecting the first model parameters by deleting the first model parameters from the first storage space when the historical usage information meets the conditions, thereby improving resource utilization; the electronic device can retain the first model parameters in the first storage space when the historical usage information does not meet the conditions, so that the next time when switching to the first processing task, the first model weight parameters can be quickly obtained from the first storage space, thereby effectively reducing switching delays and improving switching efficiency.

[0119] In some embodiments of the present application, after the above step 103, the task processing method provided by the present application further includes the following steps 109 to 110:

[0120] Step 109: When the electronic device detects that it has switched to the second processing task, the electronic device obtains a fifth model weight parameter corresponding to the second processing task based on the second processing task.

[0121] In some embodiments of the present application, the second processing task may be a language processing task different from the first processing task.

[0122] It should be noted that the process of obtaining the fifth model weight parameters corresponding to the second processing task can refer to the relevant description of the process of obtaining the first model weight parameters in the above step 102. To avoid repetition, this embodiment will not be repeated here.

[0123] Step 110: The electronic device processes the second processing task through the first model based on the fifth model weight parameter to obtain a second processing result.

[0124] In some embodiments of the present application, the second processing result corresponds to the second processing task, that is, the second processing result is a processing result corresponding to the second processing task.

[0125] It should be noted that the process of processing the second processing task based on the first model and the fifth model weight parameters in the above step 110 can refer to the relevant description of the base model, the N adapters, and the first weight parameters in the above step 103 for processing the first processing task. To avoid repetition, this embodiment will not be repeated here.

[0126] In this way, when the electronic device detects that the second processing task has been switched to, based on the second processing task, it obtains the fifth model weight parameter corresponding to the second language processing task, and processes the second processing task based on the fifth model weight parameter through the first model to obtain the second processing result. Therefore, when the electronic device detects that the second processing task has been switched to, the electronic device does not need to repeatedly load all the weight parameters, but only needs to load the fifth model weight parameter corresponding to the second processing task to achieve the switching of the processing tasks, thereby effectively improving the switching speed.

[0127] The task processing method provided in the present application is described below by taking the first processing task as a language processing task and the first model as a language processing model as an example. Figure 6 is a flowchart of a task processing method provided in an embodiment of the present application, combined with Figure 6 As shown, the task processing method provided in the embodiment of the present application specifically includes the following steps:

[0128] Step 601: The electronic device trains a language model to be trained using training sets corresponding to different language processing tasks, and obtains adapter weight parameters (ie, the above-mentioned model parameters) corresponding to different language processing tasks from the trained language model.

[0129] Exemplarily, the above-mentioned language model to be trained is a LoRA model. The LoRA model is an adapter added to the decoder of the large language model by adding a LoRA branch. The LoRA branch is an adapter added to the decoder of the large language model. The Adapter includes two low-rank decomposition matrices for low-rank decomposition of the weights of the base model of the large language model. When training the LoRA model, the electronic device does not need to fine-tune the entire model. For different language processing tasks, the base model structure and the weight parameters of the base model are the same. Only the Adapter weight parameters are fine-tuned. The Adapter weight parameters include the weight parameters of the two low-rank decomposition matrices of the Adapter. Therefore, when training the language model, it is only necessary to fine-tune the weight parameters of the two low-rank decomposition matrices of the training Adapter to complete the training of the language model, thereby improving the generalization ability and accuracy of the language model for different language processing tasks.

[0130] Exemplarily, after the electronic device obtains the Adapter weight parameters corresponding to different language processing tasks from the trained language recognition model, it can be offline, for example Figure 7In the model network structure of the large language model shown, a LoRA branch is added to the base model of the large language model, and the Adapter-related parameter information is saved in the LoRA branch, including Adapter_rank and Adapter_alhpa, etc. Among them, Adapter_rank represents the rank of the two low-rank decomposition matrices, Adapter_alhpa represents the coefficient of the Adapter weight parameter, and the LoRA model only contains the first weight parameter of the base model, and does not contain the Adapter weight parameter.

[0131] It should be noted that before the electronic device uses the training sets corresponding to different language processing tasks to train the language model to be trained, the first weight parameter of the base model in the large language model can be adjusted using the training set corresponding to the target language processing task. Then, when the electronic device uses the training sets corresponding to different language processing tasks to train the language model to be trained, the electronic device does not need to adjust the weight parameters of the base model in the large language model, but only needs to adjust the Adapter weight parameters of the large language model.

[0132] Step 602: The electronic device saves the adapter weight parameters corresponding to different language processing tasks into adapter weight files corresponding to different language processing tasks, and saves the base model of the language model.

[0133] For example, Figure 7 As shown, the electronic device saves the Adapter weight parameters fine-tuned for different language processing tasks in different Adapter weight files, such as Adapter1, Adapter2, Adapter3...AdapterN. Adapter1 saves the Adapter weight parameters corresponding to the first language processing task, Adapter2 saves the Adapter weight parameters corresponding to the second language processing task, Adapter3 saves the Adapter weight parameters corresponding to the third language processing task... AdapterN saves the Adapter weight parameters corresponding to the Nth language processing task. In this way, the electronic device can decouple the Adapter weight parameters fine-tuned for different language processing tasks from the base model and save them separately, that is, obtain a base model and N different Adapter weight files. Therefore, during the initialization process of model inference, the electronic device only loads the base model shared by each language processing task into the memory.

[0134] Step 603: The electronic device loads the base model of the language model, and when executing different language processing tasks, loads the adapter weight parameters corresponding to different language processing tasks.

[0135] Because each language processing task corresponds to a specific set of Adapter weight files, during model inference, the corresponding Adapter weight files can be dynamically loaded into the memory according to different language processing tasks, and passed into the large language model as input to execute the corresponding language processing tasks.

[0136] For example, when executing a first language processing task, the electronic device dynamically loads a first Adapter file corresponding to the first language processing task, reads a first Adapter weight parameter from the first Adapter weight file, and then passes the first Adapter weight parameter as input data into the large language model for reasoning to execute the first language processing task; when executing a second language processing task, the weight parameters of the base model of the large language model remain unchanged, the second Adapter file corresponding to the second language processing task is dynamically loaded, and the second Adapter weight parameter is read from the second Adapter weight file, and then the second Adapter weight parameter is passed as input data into the large language model for reasoning to execute the second language processing task; when executing a target language processing task, the electronic device only uses the weight parameters of the base model to perform model reasoning, so the electronic device does not need to pass in and load any Adapter files.

[0137] Since each Adapter file contains the Adapter weight parameters of the Adapter added in the decoder of the large language model, and the scale of the Adapter weight parameters is much smaller than the weight parameters of the base model of the large language model, generally only about 5% of the base model. Figure 8 As shown, a method of dynamically loading Adapter weight parameters on a base model with a size of 3G is adopted. For example, when executing language processing task 1, the corresponding Adapter1 is dynamically loaded on the base model, when executing language processing task 2, the corresponding Adapter2 is loaded on the base model, when executing language processing task 3, the corresponding Adapter3 is dynamically loaded on the base model, and when executing language processing task 4, the corresponding Adapter4 is dynamically loaded on the base model. This can effectively solve the problem of excessive memory usage caused by the superposition deployment of large models on the terminal side of multiple language processing tasks, thereby effectively reducing memory usage and saving storage resources.

[0138] Step 604: The electronic device uses the weight parameters of the base model and the weight parameters of the adapter to perform collaborative reasoning of the model.

[0139] Exemplarily, it can be seen from step 601 that an Adapter is added to the LoRA model. During model reasoning, when the electronic device calculates the position of the LoRA branch, it first needs to determine whether to read in the Adapter weight parameter, and the electronic device defaults to no.

[0140] For example, when only the weight parameters of the base model are used for model reasoning, the electronic device does not pass in the Adapter weight parameters, and the branch judgment is no. At this time, the model reasoning does not need to go through the LoRA branch, and only the base model is used for reasoning. At this time, the extended Adapter does not participate in the model reasoning, and only the weight parameters of the base model are used for model reasoning, thereby ensuring that the ability of the base model is not affected. At this time, the reasoning result of the model is as follows:

[0141] Result = Forward (base); (1)

[0142] Result indicates the output result of the large model on the end, Forward(·) indicates the calculation function of the base model, and base indicates the weight parameter of the base model.

[0143] Exemplarily, when the Adapter weight parameters need to be used to participate in model reasoning, when the electronic device loads the Adapter file, the Adapter weight parameters in the Adapter file are read. At this time, the branch is judged to be yes, the LoRA branch is opened and the corresponding Adapter weight parameters are obtained. The Adapter weight parameters and the weight parameters of the topic model are simultaneously involved in the calculation, and then the calculation results of the LoRA branch are added to the calculation results of the base model, thereby realizing the collaborative reasoning of the LoRA branch and the base model to perform the corresponding language processing tasks. And by inputting the Adapter weight parameters corresponding to different language processing tasks, the customized functions of different language processing tasks are realized. At this time, the reasoning results of the model are as follows:

[0144] Result=Forward(base)+Forward_LoRA(Adapter); (2)

[0145] Forward_LoRA(·) represents the calculation function of the LoRA branch, and Adapter represents the Adapter weight parameter.

[0146] Step 605: The electronic device switches the language processing task.

[0147] For example, in combination Fig. 9As shown, after the electronic device is initialized, it switches to the base model scenario first. In the process of switching to the base model scenario, the electronic device can load the network structure of the large model on the end side and the first weight parameter of the base model. Since the adapter weight parameters corresponding to each function are all obtained based on the base model through LoRA fine-tuning, and each adapter shares the base model capability. Therefore, when switching services, the base model does not need to be loaded repeatedly.

[0148] For example, take switching to language processing task A as an example. When switching for the first time, the Adapter_A file corresponding to language processing task A is passed in, the Adapter_A weight parameters are read and loaded from the Adapter_A file, the input pointer of the LoRA branch is pointed to the starting position of the Adapter_A weight parameters, and the corresponding weight parameters are directly read for calculation during calculation. Since the size of the Adapter file is generally less than 100M, for example Figure 8 As shown, the size of the Adapter file can be 60M, so the loading time can generally be completed in milliseconds.

[0149] In combination with business needs, the Adapter weight parameters corresponding to the language recognition tasks that have been loaded and need to be used frequently do not need to be released. When switching to the language processing task again, you only need to re-point the input pointer of the LoRA branch to the starting position of the Adapter weight parameters corresponding to the language processing task; for the Adapter weight parameters corresponding to the language processing tasks that are not used frequently, they can be released after use, thereby further optimizing the storage space occupancy. When switching to the language recognition business next time, you can reload the Adapter weight parameters.

[0150] In this way, for the Adapter weight parameters corresponding to the frequently used language processing tasks, when switching to the language processing task again, there is no need to reload the Adapter parameters corresponding to the language processing task. You only need to adjust the pointer to the starting position of the Adapter weight parameters corresponding to the language processing task, so there is almost no switching time.

[0151] In this way, it is possible to implement large-scale end-side deployment of large models for multiple business scenarios based on LoRA fine-tuning, ensuring the generalization and accuracy of the model while effectively reducing the memory usage caused by model superposition, and achieving millisecond-level switching of business functions to ensure user experience.

[0152] It should be noted that the specific implementation process of the task processing method in the above steps can refer to the relevant description of the above embodiment. To avoid repetition, this embodiment will not be repeated here.

[0153] It should be noted that the above-mentioned method embodiments, or various possible implementation methods in each method embodiment, can be executed separately, or any two or more can be executed in combination with each other. The specific implementation method can be determined according to actual usage requirements, and the embodiments of the present application do not impose any restrictions on this.

[0154] The task processing method provided in the embodiment of the present application can be executed by a task processing device. In the embodiment of the present application, the task processing device provided in the embodiment of the present application is described by taking the task processing method executed by the task processing device as an example.

[0155] Fig.10 It is a structural diagram of a task processing device provided in an embodiment of the present application, wherein the task processing device 1000 includes an acquisition module 1001 and a processing module 1002; wherein the acquisition module 1001 is used to acquire a first processing task; the acquisition module 1001 is also used to determine a first weight parameter corresponding to the first processing task, wherein the first weight parameter is used for task processing using a first model, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer; the first processing task is processed based on the base model, the N adapters, and the first weight parameter to obtain a first processing result.

[0156] In some embodiments of the present application, each adapter includes a weight matrix; the first model weight parameters are weight parameters of N weight matrices; the acquisition module 1001 is specifically used to: determine a first storage space corresponding to a first processing task, the first storage space is used to store a weight parameter file associated with the first processing task, and the weight parameter file includes M weight parameters; based on the rank of the weight matrix of the first adapter, determine at least one third weight parameter from the M weight parameters as the weight parameter of the weight matrix of the first adapter; based on the rank of the weight matrix of the second adapter, determine at least one fourth weight parameter from the weight parameters after at least one third weight parameter as the weight parameter of the weight matrix of the second adapter; wherein the first adapter is any one of the first N-1 adapters among the N adapters; the second adapter is the next adapter of the first adapter; N and M are both integers greater than 1.

[0157] In some embodiments of the present application, the base model includes N cascaded decoding layers, one decoding layer is connected to an adapter, and each adapter includes a first weight matrix and a second weight matrix; the processing module 1002 is specifically used to: based on the weight parameters of the first weight matrix of the first adapter, perform a dimensionality reduction operation on the first task information of the first processing task to obtain a first dimensionality reduction result corresponding to the first adapter, and based on the weight parameters of the second weight matrix of the first adapter, perform a dimensionality increase operation on the first dimensionality reduction result to obtain a first dimensionality increase result corresponding to the first adapter; based on the weight parameters of the first decoding layer, perform a decoding operation on the first task information to obtain a first decoding result, and the first decoding layer is a decoding layer connected to the first adapter; weight the first decoding result and the first dimensionality increase result to obtain a first weighted operation result; based on the weight parameters of the first decoding layer, perform a decoding operation on the first task information to obtain a first decoding result. The weight parameters of the first weight matrix of the three adapters are used to perform a dimensionality reduction operation on the weighted operation result corresponding to the previous adapter of the third adapter to obtain a second dimensionality reduction result corresponding to the third adapter, and based on the weight parameters of the second weight matrix of the third adapter, a dimensionality increase operation is performed on the second dimensionality reduction result to obtain a second dimensionality increase result corresponding to the third adapter; based on the weight parameters of the second decoding layer, a decoding operation is performed on the weighted operation result corresponding to the previous adapter of the third adapter to obtain a second decoding result, and the second decoding layer is a decoding layer connected to the third adapter; the second decoding result and the second dimensionality increase result are weighted to obtain a second weighted operation result; the weighted operation result corresponding to the last adapter among the N adapters is determined as the first processing result; wherein the third adapter is any adapter after the first adapter among the N adapters.

[0158] In some embodiments of the present application, the acquisition module 1001 is also used to obtain a task processing training set before obtaining the first processing task, and the task processing training set includes at least one processing task and at least one task information; the processing module 1002 is also used to adjust the weight parameters of the task processing model to be trained based on the task processing training set obtained by the acquisition module 1001 to obtain at least one fourth model weight parameter, each fourth model weight parameter corresponds to a processing task; and store at least one weight parameter file in the storage space corresponding to each processing task, each weight parameter file includes a fourth model weight parameter corresponding to a processing task.

[0159] In some embodiments of the present application, the acquisition module 1001 is also used to, after processing the first processing task based on the base model, N adapters, and the first weight parameter to obtain the first processing result, obtain historical usage information of the first model weight parameter; when the historical usage information meets the conditions, delete the first model parameter from the first storage space.

[0160] In some embodiments of the present application, the acquisition module 1001 is also used to, after processing the first processing task based on the base model, N adapters, and the first weight parameters to obtain the first processing result, when detecting a switch to the second processing task, obtain the fifth model weight parameters corresponding to the second processing task based on the second processing task; the processing module 1002 is also used to process the second processing task based on the fifth model weight parameters through the first model to obtain the second processing result, and the second processing result corresponds to the second processing task.

[0161] In the task processing device provided in the present application, the task processing device obtains a first processing task; determines a first weight parameter corresponding to the first processing task, wherein the first weight parameter is used for task processing by a first model, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer; based on the base model, the N adapters, and the first weight parameter, the first processing task is processed to obtain a first processing result. Therefore, when executing different processing tasks, only the base model and the adapters corresponding to different processing tasks and their corresponding weight parameters are required, and there is no need for a large language model to include parameter data of various processing tasks at the same time, thereby greatly reducing the parameter data storage space occupied by the large language model, thereby effectively saving storage resources.

[0162] The task processing device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or a device other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device, an augmented reality / virtual reality device, a robot, a wearable device, a super mobile personal computer, a netbook or a personal digital assistant, etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0163] The task processing device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0164] The task processing device provided in the embodiment of the present application can implement each process implemented by each embodiment of the above-mentioned language recognition method. To avoid repetition, it will not be described again here.

[0165] Alternatively, if Fig.11 As shown, an embodiment of the present application also provides an electronic device 1100, including a processor 1101 and a memory 1102, wherein the memory 1102 stores programs or instructions that can be executed on the processor 1101, and when the program or instructions are executed by the processor 1101, the various steps of the above-mentioned task processing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not repeated here.

[0166] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0167] Fig.12 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0168] The electronic device 1200 includes but is not limited to: a radio frequency unit 1201, a network module 1202, an audio output unit 1203, an input unit 1204, a sensor 1205, a display unit 1206, a user input unit 1207, an interface unit 1208, a memory 1209, and a processor 1210 and other components.

[0169] Those skilled in the art will appreciate that the electronic device 1200 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1210 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.12 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0170] Among them, the processor 1210 is used to obtain a first processing task; determine a first weight parameter corresponding to the first processing task, wherein the first weight parameter is used for task processing by a first model, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer; based on the base model, the N adapters, and the first weight parameter, the first processing task is processed to obtain a first processing result.

[0171] In some embodiments of the present application, each adapter includes a weight matrix; the first model weight parameters are weight parameters of N weight matrices; the processor 1210 is specifically used to: determine a first storage space corresponding to a first processing task, the first storage space is used to store a weight parameter file associated with the first processing task, and the weight parameter file includes M weight parameters; based on the rank of the weight matrix of the first adapter, determine at least one third weight parameter from the M weight parameters as the weight parameter of the weight matrix of the first adapter; based on the rank of the weight matrix of the second adapter, determine at least one fourth weight parameter from the weight parameters after at least one third weight parameter as the weight parameter of the weight matrix of the second adapter; wherein the first adapter is any one of the first N-1 adapters among the N adapters; the second adapter is the next adapter of the first adapter; N and M are both integers greater than 1.

[0172] In some embodiments of the present application, the base model includes N cascaded decoding layers, one decoding layer is connected to an adapter, and each adapter includes a first weight matrix and a second weight matrix; the processor 1210 is specifically used to: based on the weight parameters of the first weight matrix of the first adapter, perform a dimensionality reduction operation on the first task information of the first processing task to obtain a first dimensionality reduction result corresponding to the first adapter, and based on the weight parameters of the second weight matrix of the first adapter, perform a dimensionality increase operation on the first dimensionality reduction result to obtain a first dimensionality increase result corresponding to the first adapter; based on the weight parameters of the first decoding layer, perform a decoding operation on the first task information to obtain a first decoding result, and the first decoding layer is a decoding layer connected to the first adapter; perform a weighted operation on the first decoding result and the first dimensionality increase result to obtain a first weighted operation result; based on the third adapter Based on the weight parameters of the first weight matrix of the adapter, a dimensionality reduction operation is performed on the weighted operation result corresponding to the previous adapter of the third adapter to obtain a second dimensionality reduction result corresponding to the third adapter, and based on the weight parameters of the second weight matrix of the third adapter, a dimensionality increase operation is performed on the second dimensionality reduction result to obtain a second dimensionality increase result corresponding to the third adapter; based on the weight parameters of the second decoding layer, a decoding operation is performed on the weighted operation result corresponding to the previous adapter of the third adapter to obtain a second decoding result, where the second decoding layer is a decoding layer connected to the third adapter; the second decoding result and the second dimensionality increase result are weighted to obtain a second weighted operation result; the weighted operation result corresponding to the last adapter among the N adapters is determined as the first processing result; wherein the third adapter is any adapter after the first adapter among the N adapters.

[0173] In some embodiments of the present application, the processor 1210 is further used to obtain a task processing training set before obtaining the first processing task, the task processing training set including at least one processing task and at least one task information; based on the task processing training set, adjust the weight parameters of the task processing model to be trained to obtain at least one fourth model weight parameter, each fourth model weight parameter corresponds to a processing task; store at least one weight parameter file in the storage space corresponding to each processing task, each weight parameter file including a fourth model weight parameter corresponding to a processing task.

[0174] In some embodiments of the present application, the processor 1210 is also used to process the first processing task based on the base model, N adapters, and the first weight parameters, and after obtaining the first processing result, obtain historical usage information of the first model weight parameters; when the historical usage information meets the conditions, the first model parameters are deleted from the first storage space.

[0175] Processor 1210 is also used to process the first processing task based on the base model, N adapters, and the first weight parameters to obtain the first processing result, and then, when it is detected that a switch to the second processing task is made, obtain the fifth model weight parameters corresponding to the second processing task based on the second processing task; and process the first task information based on the fifth model weight parameters through the first task processing model to obtain the second processing result, and the second processing result corresponds to the second processing task.

[0176] In the electronic device provided in the present application, the electronic device obtains a first processing task; determines a first weight parameter corresponding to the first processing task, wherein the first weight parameter is used for task processing by a first model, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer; processes the first processing task based on the base model, the N adapters, and the first weight parameter to obtain a first processing result. Only the base model and the adapters corresponding to different processing tasks and their corresponding weight parameters are required, and there is no need for a large language model to include parameter data of various processing tasks at the same time, thereby greatly reducing the parameter data storage space occupied by the large language model, thereby effectively saving storage resources.

[0177] Therefore, when executing different processing tasks, task processing models corresponding to different processing tasks are not needed, only the model parameters of the first task processing model corresponding to different processing tasks are needed, thereby greatly reducing memory usage and effectively saving memory resources.

[0178] It should be understood that in the embodiment of the present application, the input unit 1204 may include a graphics processor (Graphics Processing Unit, GPU) 12041 and a microphone 12042, and the graphics processor 12041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1206 may include a display panel 12061, and the display panel 12061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1207 includes a touch panel 12071 and at least one of other input devices 12072. The touch panel 12071 is also called a touch screen. The touch panel 12071 may include two parts: a touch detection device and a touch controller. Other input devices 12072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0179] The memory 1209 can be used to store software programs and various data. The memory 1209 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1209 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0180] The processor 1210 may include one or more processing units; optionally, the processor 1210 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1210.

[0181] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned language recognition method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0182] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0183] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned language recognition method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0184] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0185] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned language recognition method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0186] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0187] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0188] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A task processing method, characterized in that: The method comprises: Get the first processing task; Determine a first weight parameter corresponding to the first processing task, wherein the first weight parameter is used for a first model to perform task processing, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer; The first processing task is processed based on the base model, the N adapters, and the first weight parameter to obtain a first processing result.

2. The method according to claim 1, characterized in that: Each of the adapters includes a weight matrix; the first model weight parameters are weight parameters of N weight matrices; The determining a first weight parameter corresponding to the first processing task includes: Determine a first storage space corresponding to the first processing task, where the first storage space is used to store a weight parameter file associated with the first processing task, where the weight parameter file includes M weight parameters; Based on the rank of the weight matrix of the first adapter, determining at least one third weight parameter from the M weight parameters as a weight parameter of the weight matrix of the first adapter; Based on the rank of the weight matrix of the second adapter, determining at least one fourth weight parameter from the weight parameters subsequent to the at least one third weight parameter as a weight parameter of the weight matrix of the second adapter; The first adapter is any one of the first N-1 adapters among the N adapters; the second adapter is the next adapter of the first adapter; and N and M are both integers greater than 1.

3. The method according to claim 2, characterized in that The base model includes N cascaded decoding layers, one of the decoding layers is connected to one of the adapters, and each adapter includes a first weight matrix and a second weight matrix; The processing of the first processing task based on the base model, the N adapters, and the first weight parameter to obtain a first processing result includes: Based on the weight parameters of the first weight matrix of the first adapter, a dimensionality reduction operation is performed on the first task information of the first processing task to obtain a first dimensionality reduction result corresponding to the first adapter, and based on the weight parameters of the second weight matrix of the first adapter, a dimensionality increase operation is performed on the first dimensionality reduction result to obtain a first dimensionality increase result corresponding to the first adapter; Based on a weight parameter of a first decoding layer, a decoding operation is performed on the first task information to obtain a first decoding result, wherein the first decoding layer is a decoding layer connected to the first adapter; Performing a weighted operation on the first decoding result and the first dimension-raising result to obtain a first weighted operation result; Based on the weight parameters of the first weight matrix of the third adapter, a dimensionality reduction operation is performed on the weighted operation result corresponding to the previous adapter of the third adapter to obtain a second dimensionality reduction result corresponding to the third adapter, and based on the weight parameters of the second weight matrix of the third adapter, a dimensionality increase operation is performed on the second dimensionality reduction result to obtain a second dimensionality increase result corresponding to the third adapter; Based on the weight parameter of the second decoding layer, a decoding operation is performed on the weighted operation result corresponding to the previous adapter of the third adapter to obtain a second decoding result, wherein the second decoding layer is a decoding layer connected to the third adapter; Perform a weighted operation on the second decoding result and the second dimension-raising result to obtain a second weighted operation result; Determine the weighted calculation result corresponding to the last adapter among the N adapters as the first processing result; The third adapter is any adapter after the first adapter among the N adapters.

4. The method according to claim 2 or 3, characterized in that: Before obtaining the first processing task, the method further includes: Acquire a task processing training set, wherein the task processing training set includes at least one processing task and at least one task information; Based on the task processing training set, adjusting the weight parameters of the task processing model to be trained to obtain at least one fourth model weight parameter, each fourth model weight parameter corresponding to a processing task; At least one weight parameter file is stored in the storage space corresponding to each processing task, each weight parameter file includes a fourth model weight parameter corresponding to a processing task.

5. The method according to claim 2, characterized in that: After the first processing task is processed based on the base model, the N adapters, and the first weight parameter to obtain a first processing result, the method further includes: Obtaining historical usage information of the weight parameters of the first model; When the historical usage information satisfies a condition, the first model parameter is deleted from the first storage space.

6. The method according to claim 1, characterized in that After the first processing task is processed based on the base model, the N adapters, and the first weight parameter to obtain a first processing result, the method further includes: When it is detected that the second processing task is switched, obtaining a fifth model weight parameter corresponding to the second processing task based on the second processing task; The second processing task is processed through the first model based on the fifth model weight parameter to obtain a second processing result, and the second processing result corresponds to the second processing task.

7. A task processing device, characterized in that: include: An acquisition module, used for acquiring a first processing task; The acquisition module is further used to determine a first weight parameter corresponding to the first processing task, wherein the first weight parameter is used for a first model to perform task processing, the first model includes a base model and N adapters, the first weight parameter is a weight parameter of the N adapters corresponding to the first processing task, and N is a positive integer; A processing module is used to process the first processing task based on the base model, the N adapters, and the first weight parameter to obtain a first processing result.

8. The device according to claim 7, characterized in that Each of the adapters includes a weight matrix; the first model weight parameters are weight parameters of N weight matrices; The acquisition module is specifically used for: Determine a first storage space corresponding to the first processing task, where the first storage space is used to store a weight parameter file associated with the first processing task, where the weight parameter file includes M weight parameters; Based on the rank of the weight matrix of the first adapter, determining at least one third weight parameter from the M weight parameters as a weight parameter of the weight matrix of the first adapter; Based on the rank of the weight matrix of the second adapter, determining at least one fourth weight parameter from the weight parameters subsequent to the at least one third weight parameter as a weight parameter of the weight matrix of the second adapter; The first adapter is any one of the first N-1 adapters among the N adapters; the second adapter is the next adapter of the first adapter; and N and M are both integers greater than 1.

9. The device according to claim 8, characterized in that The base model includes N cascaded decoding layers, one of the decoding layers is connected to one of the adapters, and each adapter includes a first weight matrix and a second weight matrix; The processing module is specifically used for: Based on the weight parameters of the first weight matrix of the first adapter, a dimensionality reduction operation is performed on the first task information of the first processing task to obtain a first dimensionality reduction result corresponding to the first adapter, and based on the weight parameters of the second weight matrix of the first adapter, a dimensionality increase operation is performed on the first dimensionality reduction result to obtain a first dimensionality increase result corresponding to the first adapter; Based on a weight parameter of a first decoding layer, a decoding operation is performed on the first task information to obtain a first decoding result, wherein the first decoding layer is a decoding layer connected to the first adapter; Performing a weighted operation on the first decoding result and the first dimension-raising result to obtain a first weighted operation result; Based on the weight parameters of the first weight matrix of the third adapter, a dimensionality reduction operation is performed on the weighted operation result corresponding to the previous adapter of the third adapter to obtain a second dimensionality reduction result corresponding to the third adapter, and based on the weight parameters of the second weight matrix of the third adapter, a dimensionality increase operation is performed on the second dimensionality reduction result to obtain a second dimensionality increase result corresponding to the third adapter; Based on the weight parameter of the second decoding layer, a decoding operation is performed on the weighted operation result corresponding to the previous adapter of the third adapter to obtain a second decoding result, wherein the second decoding layer is a decoding layer connected to the third adapter; Perform a weighted operation on the second decoding result and the second dimension-raising result to obtain a second weighted operation result; Determine the weighted calculation result corresponding to the last adapter among the N adapters as the first processing result; The third adapter is any adapter after the first adapter among the N adapters.

10. The device according to claim 7 or 8, characterized in that The acquisition module is further used to, before acquiring the first processing task, acquire a task processing training set, wherein the task processing training set includes at least one processing task and at least one task information; The processing module is further used to adjust the weight parameters of the task processing model to be trained based on the task processing training set obtained by the acquisition module to obtain at least one fourth model weight parameter, each fourth model weight parameter corresponding to a processing task; At least one weight parameter file is stored in the storage space corresponding to each processing task, each weight parameter file includes a fourth model weight parameter corresponding to a processing task.

11. The device according to claim 8, characterized in that The acquisition module is further used to: Processing the first processing task based on the base model, the N adapters, and the first weight parameter, and obtaining historical usage information of the first model weight parameter after obtaining a first processing result; When the historical usage information satisfies a condition, the first model parameter is deleted from the first storage space.

12. The device according to claim 7, characterized in that The acquisition module is further configured to, after processing the first processing task based on the base model, the N adapters, and the first weight parameter to obtain a first processing result, acquire a fifth model weight parameter corresponding to the second processing task based on the second processing task when a switch to the second processing task is detected; The processing module is further used to process the second processing task based on the fifth model weight parameter through the first model to obtain a second processing result, and the second processing result corresponds to the second processing task.

13. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the task processing method according to any one of claims 1 to 6 are implemented.

14. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by the processor, the steps of the task processing method according to any one of claims 1 to 6 are implemented.