Multi-task execution method and device based on small language model, equipment and medium
By performing Lora fine-tuning and weight merge on small language models, the problems of insufficient semantic understanding capabilities of small language models and high deployment costs of large language models are solved, and efficient multi-task deployment and cost reduction in financial scenarios are achieved.
Patent Information
- Application Number
- CN202411707104.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-18
AI Technical Summary
In the prior art, the semantic understanding ability of small language models is limited and it is difficult to meet the needs of complex financial scenarios. The high cost and difficulty of deployment of large language models are not suitable for the deployment needs of large-scale or edge devices.
By performing Lora fine-tuning on a small language model, Lora weights of different task types are dynamically obtained, and weight calculations are performed separately under the initial weight and Lora weights, and the calculation results are combined to generate the final task execution results.
While maintaining task performance, the deployment cost is significantly reduced, and multi-task deployment in financial scenarios is realized, suitable for small-scale or edge devices deployment.
Smart Images

Figure CN119647459A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a multi-task execution method, device, equipment and medium based on a small language model. Background Art
[0002] In current financial scenarios, there are usually multiple specific downstream tasks, such as field standardization tasks, document parsing tasks, etc.
[0003] In the prior art, the above tasks can be processed by large language models or small language models, but there are mainly the following problems:
[0004] 1) Small language models have limited semantic understanding capabilities.
[0005] Traditional small models are insufficient in terms of semantic understanding and accuracy, and are unable to meet the needs of complex financial scenarios. Therefore, they cannot effectively handle tasks that require high precision, such as field standardization and document parsing.
[0006] 2) The high cost and difficulty of deploying large language models.
[0007] Although large models have excellent semantic understanding and processing capabilities, they have a huge number of parameters and extremely high computing and storage costs, which not only increases the difficulty of deployment but also leads to inefficient resource utilization. They are not suitable for deployment needs of large-scale or edge devices. Summary of the invention
[0008] The embodiments of the present application provide a multi-task execution method, apparatus, device and medium based on a small language model, aiming to solve the problem that task accuracy and cost cannot be taken into account in financial scenarios.
[0009] In a first aspect, an embodiment of the present application provides a multi-task execution method based on a small language model, which includes:
[0010] In response to an execution instruction for a target task in a financial scenario, determining a target task type of the target task;
[0011] Obtaining a target Lora weight from the main memory of the central processing unit according to the target task type, and loading the target Lora weight into the video memory of the graphics processing unit;
[0012] Obtaining initial weights of a small language model from the video memory;
[0013] Performing the target task using the small language model under the initial weights to obtain a first probability matrix for each predicted word;
[0014] Performing the target task using the small language model under the target Lora weight to obtain a second probability matrix for each predicted word;
[0015] Merge the first probability matrix of each word with the corresponding second probability matrix to obtain the target probability matrix of each word;
[0016] The execution result of the target task is generated according to the target probability matrix of each word.
[0017] In a second aspect, an embodiment of the present application provides a multi-task execution device based on a small language model, which includes:
[0018] a determination unit, configured to determine a target task type of the target task in response to an execution instruction for the target task in the financial scenario;
[0019] A loading unit, configured to obtain a target Lora weight from a main memory of a central processing unit according to the target task type, and load the target Lora weight into a video memory of a graphics processing unit;
[0020] An acquisition unit, used for acquiring the initial weight of the small language model from the video memory;
[0021] An execution unit, configured to execute the target task using the small language model under the initial weights to obtain a first probability matrix for each predicted word;
[0022] The execution unit is further configured to perform the target task using the small language model under the target Lora weight to obtain a second probability matrix for each predicted word;
[0023] A merging unit, used to merge the first probability matrix of each word with the corresponding second probability matrix to obtain a target probability matrix for each word;
[0024] A generating unit is used to generate the execution result of the target task according to the target probability matrix of each word.
[0025] In a third aspect, an embodiment of the present application further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the multi-task execution method based on a small language model described in the first aspect is implemented.
[0026] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the multi-task execution method based on a small language model described in the first aspect above.
[0027] The embodiments of the present application provide a multi-task execution method, apparatus, device and medium based on a small language model, which obtains different Lora weights from the main memory of the central processing unit according to different task types, and loads them into the video memory of the graphics processing unit, further performs weight calculation under the initial weight and Lora weight of the small language model respectively, and merges the calculation results to generate the final task execution result, which can realize multi-task deployment in financial scenarios based on Lora fine-tuning and small-scale models, which not only ensures task performance but also reduces deployment costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0029] Figure 1 A schematic diagram of an application scenario of a multi-task execution method based on a small language model provided in an embodiment of the present application;
[0030] Figure 2 A flowchart of a multi-task execution method based on a small language model provided in an embodiment of the present application;
[0031] Figure 3 A schematic block diagram of a multi-task execution device based on a small language model provided in an embodiment of the present application;
[0032] Figure 4 A schematic block diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0034] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0035] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, the singular forms "a", "an" and "the" are intended to include plural forms unless the context clearly indicates otherwise.
[0036] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0037] See also Figure 1 and Figure 2 , Figure 1 A schematic diagram of an application scenario of a multi-task execution method based on a small language model provided in an embodiment of the present application; Figure 2 A flowchart of a multi-task execution method based on a small language model provided in an embodiment of the present application is provided. The multi-task execution method based on a small language model is applied in a server, and the method is executed by application software installed in the server.
[0038] like Figure 2 As shown, the method includes steps S101 to S107.
[0039] S101. In response to an execution instruction for a target task in a financial scenario, determine a target task type of the target task.
[0040] In this embodiment, the technical solution is described with the server as the execution subject. The user terminal (such as a smart phone, tablet computer and other intelligent terminals) used by the user can exchange data with the server. Specifically, the server provides a task execution platform, and the user can log in to the task execution platform using the user terminal. The user interaction interface of the task execution platform is displayed on the terminal interface of the user terminal, and there is a task execution trigger button in the user interaction interface. When the button is detected to be triggered, the subsequent task can be performed in the server.
[0041] In this embodiment, the target tasks may include, but are not limited to: element parsing tasks, field standardization tasks, etc.
[0042] In this embodiment, the target task type may be determined according to the task identifier of the target task.
[0043] For example, when the task identifier of the target task is X, it is determined that the target task type is a feature parsing task.
[0044] In this embodiment, before executing a task, related resources need to be deployed first.
[0045] Specifically, the method further includes:
[0046] Get each task type;
[0047] For each task type, the small language model is fine-tuned using Lora (Low-Rank Adaptation) to obtain the Lora weight corresponding to each task type;
[0048] Configure the task ID corresponding to each task type;
[0049] The Lora weight corresponding to each task type is marked using the task identifier corresponding to each task type, and the marked Lora weight is stored in the main memory of the central processing unit (CPU).
[0050] Among them, the small language model can be a small model with a volume of 7B, which is obviously more lightweight and has a lower deployment cost than the commonly used large language model of 72B.
[0051] Among them, Lora fine-tuning is a form of "Parameter-Efficient Fine-Tuning" (PEFT), which allows large models to be fine-tuned using a small number of learnable parameters.
[0052] Through the above embodiments, the optimal weight corresponding to each task type can be dynamically obtained based on Lora fine-tuning, and then a smaller model (such as 7B) can be fine-tuned through Lora technology, and multiple Lora weights can be loaded on a smaller basic model, thereby significantly reducing costs while maintaining the task accuracy.
[0053] In this embodiment, the video memory is used to store the initial weight, the applied key-value cache (KV Cache) cache space and the preset temporary weight.
[0054] Among them, key-value caching is a technology used to accelerate the reasoning process of large language models (such as Transformer models).
[0055] In the above embodiment, during the deployment process, the Lora weights of all downstream tasks are loaded into the main memory of the central processing unit, and the initial weights of the small language model, the cache space of the applied key-value cache, and some temporary weights are loaded into the graphics processing unit (GPU) memory to accelerate processing.
[0056] S102, obtaining a target Lora weight from the main memory of the central processing unit according to the target task type, and loading the target Lora weight into the video memory of the graphics processing unit.
[0057] In this embodiment, obtaining the target Lora weight from the main memory of the central processing unit according to the target task type includes:
[0058] Obtaining a target task identifier corresponding to the target task type;
[0059] Traversing the main memory using the target task identifier;
[0060] The traversed Lora weight having the target task identifier is determined as the target Lora weight.
[0061] Through the above embodiment, the corresponding Lora weights can be automatically traversed in the main memory of the central processing unit and dynamically loaded into the video memory of the graphics processor for use in subsequent model reasoning, which can further optimize the deployment cost and resource utilization efficiency.
[0062] S103: Obtaining the initial weight of the small language model from the video memory.
[0063] In this embodiment, the initial weights of the small language model can be directly read from the video memory to improve processing efficiency.
[0064] S104: Execute the target task using the small language model under the initial weights to obtain a first probability matrix for each predicted word.
[0065] In this embodiment, weight calculation is performed based on the initial weights, so that the probability matrix of the next output word of the small language model under the effect of the initial weights can be predicted.
[0066] S105: Perform the target task using the small language model under the target Lora weight to obtain a second probability matrix for each predicted word.
[0067] In this embodiment, weight calculation is performed based on the target Lora weight, so that the probability matrix of the next output word of the small language model under the effect of the target Lora weight can be predicted.
[0068] S106: Combine the first probability matrix of each word with the corresponding second probability matrix to obtain a target probability matrix for each word.
[0069] In this embodiment, the merging of the first probability matrix of each word with the corresponding second probability matrix to obtain the target probability matrix of each word includes:
[0070] The first probability matrix of each word is added to the corresponding second probability matrix bit by bit to obtain the target probability matrix of each word.
[0071] The target probability matrix refers to the probability of the next output word of the small language model.
[0072] In the above embodiment, by combining a small-scale Base model (i.e., the small language model) with multiple task-specific weights fine-tuned by Lora, flexible and efficient multi-task deployment can be achieved while ensuring task performance, and the performance of the small model can be significantly improved under lower computing and storage requirements, making it more suitable for specific application scenarios in the financial field (such as standardization and parsing tasks, etc.).
[0073] S107: Generate the execution result of the target task according to the target probability matrix of each word.
[0074] In this embodiment, generating the execution result of the target task according to the target probability matrix of each word includes:
[0075] Obtaining a vocabulary of the small language model;
[0076] Use the target probability matrix of each word to match in the vocabulary to obtain each target word;
[0077] Each target word is combined in turn to obtain the execution result of the target task.
[0078] For example, when the words corresponding to the target probability matrices are "name", "title", "is", and "M", respectively, the sentence finally output by the small language model is "the name is M", which is used as the execution result.
[0079] Specifically, the corresponding words are matched in turn according to each target probability matrix in the vocabulary, and combined one by one to obtain the sentence finally output by the small language model.
[0080] In this embodiment, after obtaining the execution result of the target task, the method further includes:
[0081] The target Lora weight is released from the video memory.
[0082] In the above embodiment, when the task is completed, the Lora weights used in the task are released from the GPU cache, thereby reducing the memory usage, which can further optimize resource utilization and deployment costs. By flexibly managing the loading and release of Lora weights, efficient multi-tasking is achieved, while ensuring high-precision reasoning on a smaller Base model, meeting the diverse needs of financial scenarios, improving resource utilization, and significantly reducing deployment costs.
[0083] This embodiment utilizes the powerful reasoning ability of the large language model and the high efficiency of Lora fine-tuning to deploy the Lora weights of multiple tasks on a base model (Base model), thereby significantly reducing costs and improving work efficiency while maintaining the performance and accuracy of each task, and can solve the parallel reasoning problems of multiple tasks using limited hardware equipment conditions.
[0084] It can be seen from the above technical solutions that the present application obtains different Lora weights from the main memory of the central processing unit according to different task types, and loads them into the video memory of the graphics processor, and further performs weight calculations under the initial weights and Lora weights of the small language model respectively, and merges the calculation results to generate the final task execution results. It can realize multi-task deployment in financial scenarios based on Lora fine-tuning and small-scale models, which not only ensures task performance but also reduces deployment costs.
[0085] The present application also provides a multi-task execution device based on a small language model, which is used to execute any embodiment of the multi-task execution method based on a small language model. Figure 3 , Figure 3 is a schematic block diagram of a multi-task execution device 100 based on a small language model provided in an embodiment of the present application.
[0086] Among them, Figure 3 As shown, the multi-task execution device 100 based on the small language model includes a determination unit 101, a loading unit 102, an acquisition unit 103, an execution unit 104, a merging unit 105, and a generation unit 106.
[0087] The determining unit 101 is used to determine the target task type of the target task in response to an execution instruction for the target task in a financial scenario.
[0088] In this embodiment, the technical solution is described with the server as the execution subject. The user terminal (such as a smart phone, tablet computer and other intelligent terminals) used by the user can exchange data with the server. Specifically, the server provides a task execution platform, and the user can log in to the task execution platform using the user terminal. The user interaction interface of the task execution platform is displayed on the terminal interface of the user terminal, and there is a task execution trigger button in the user interaction interface. When the button is detected to be triggered, the subsequent task can be performed in the server.
[0089] In this embodiment, the target tasks may include, but are not limited to: element parsing tasks, field standardization tasks, etc.
[0090] In this embodiment, the target task type may be determined according to the task identifier of the target task.
[0091] For example, when the task identifier of the target task is X, it is determined that the target task type is a feature parsing task.
[0092] In this embodiment, before executing a task, related resources need to be deployed first.
[0093] Specifically, obtain each task type;
[0094] For each task type, the small language model is fine-tuned using Lora (Low-Rank Adaptation) to obtain the Lora weight corresponding to each task type;
[0095] Configure the task ID corresponding to each task type;
[0096] The Lora weight corresponding to each task type is marked using the task identifier corresponding to each task type, and the marked Lora weight is stored in the main memory of the central processing unit (CPU).
[0097] Among them, the small language model can be a small model with a volume of 7B, which is obviously more lightweight and has a lower deployment cost than the commonly used large language model of 72B.
[0098] Among them, Lora fine-tuning is a form of "Parameter-Efficient Fine-Tuning" (PEFT), which allows large models to be fine-tuned using a small number of learnable parameters.
[0099] Through the above embodiments, the optimal weight corresponding to each task type can be dynamically obtained based on Lora fine-tuning, and then a smaller model (such as 7B) can be fine-tuned through Lora technology, and multiple Lora weights can be loaded on a smaller basic model, thereby significantly reducing costs while maintaining the task accuracy.
[0100] In this embodiment, the video memory is used to store the initial weight, the applied key-value cache (KV Cache) cache space and the preset temporary weight.
[0101] Among them, key-value caching is a technology used to accelerate the reasoning process of large language models (such as Transformer models).
[0102] In the above embodiment, during the deployment process, the Lora weights of all downstream tasks are loaded into the main memory of the central processing unit, and the initial weights of the small language model, the cache space of the applied key-value cache, and some temporary weights are loaded into the graphics processing unit (GPU) memory to accelerate processing.
[0103] The loading unit 102 is used to obtain the target Lora weight from the main memory of the central processing unit according to the target task type, and load the target Lora weight into the video memory of the graphics processing unit.
[0104] In this embodiment, the loading unit 102 obtains the target Lora weight from the main memory of the central processing unit according to the target task type, including:
[0105] Obtaining a target task identifier corresponding to the target task type;
[0106] Traversing the main memory using the target task identifier;
[0107] The traversed Lora weight having the target task identifier is determined as the target Lora weight.
[0108] Through the above embodiment, the corresponding Lora weights can be automatically traversed in the main memory of the central processing unit and dynamically loaded into the video memory of the graphics processor for use in subsequent model reasoning, which can further optimize the deployment cost and resource utilization efficiency.
[0109] The acquisition unit 103 is used to acquire the initial weight of the small language model from the video memory.
[0110] In this embodiment, the initial weights of the small language model can be directly read from the video memory to improve processing efficiency.
[0111] The execution unit 104 is configured to execute the target task using the small language model under the initial weights to obtain a first probability matrix for each predicted word.
[0112] In this embodiment, weight calculation is performed based on the initial weights, so that the probability matrix of the next output word of the small language model under the effect of the initial weights can be predicted.
[0113] The execution unit 104 is further configured to execute the target task using the small language model under the target Lora weight to obtain a predicted second probability matrix for each word.
[0114] In this embodiment, weight calculation is performed based on the target Lora weight, so that the probability matrix of the next output word of the small language model under the effect of the target Lora weight can be predicted.
[0115] The merging unit 105 is used to merge the first probability matrix of each word with the corresponding second probability matrix to obtain a target probability matrix for each word.
[0116] In this embodiment, the merging unit 105 merges the first probability matrix of each word with the corresponding second probability matrix to obtain a target probability matrix of each word, including:
[0117] The first probability matrix of each word is added to the corresponding second probability matrix bit by bit to obtain the target probability matrix of each word.
[0118] The target probability matrix refers to the probability of the next output word of the small language model.
[0119] In the above embodiment, by combining a small-scale Base model (i.e., the small language model) with multiple task-specific weights fine-tuned by Lora, flexible and efficient multi-task deployment can be achieved while ensuring task performance, and the performance of the small model can be significantly improved under lower computing and storage requirements, making it more suitable for specific application scenarios in the financial field (such as standardization and parsing tasks, etc.).
[0120] The generating unit 106 is used to generate the execution result of the target task according to the target probability matrix of each word.
[0121] In this embodiment, the generating unit 106 generates the execution result of the target task according to the target probability matrix of each word, including:
[0122] Obtaining a vocabulary of the small language model;
[0123] Use the target probability matrix of each word to match in the vocabulary to obtain each target word;
[0124] Each target word is combined in turn to obtain the execution result of the target task.
[0125] For example, when the words corresponding to the target probability matrices are "name", "title", "is", and "M", respectively, the sentence finally output by the small language model is "the name is M", which is used as the execution result.
[0126] Specifically, the corresponding words are matched in turn according to each target probability matrix in the vocabulary, and combined one by one to obtain the sentence finally output by the small language model.
[0127] In this embodiment, after obtaining the execution result of the target task, the target Lora weight is released from the video memory.
[0128] In the above embodiment, when the task is completed, the Lora weights used in the task are released from the GPU cache, thereby reducing the memory usage, which can further optimize resource utilization and deployment costs. By flexibly managing the loading and release of Lora weights, efficient multi-tasking is achieved, while ensuring high-precision reasoning on a smaller Base model, meeting the diverse needs of financial scenarios, improving resource utilization, and significantly reducing deployment costs.
[0129] This embodiment utilizes the powerful reasoning ability of the large language model and the high efficiency of Lora fine-tuning to deploy the Lora weights of multiple tasks on a base model (Base model), thereby significantly reducing costs and improving work efficiency while maintaining the performance and accuracy of each task, and can solve the parallel reasoning problems of multiple tasks using limited hardware equipment conditions.
[0130] It can be seen from the above technical solutions that the present application obtains different Lora weights from the main memory of the central processing unit according to different task types, and loads them into the video memory of the graphics processor, and further performs weight calculations under the initial weights and Lora weights of the small language model respectively, and merges the calculation results to generate the final task execution results. It can realize multi-task deployment in financial scenarios based on Lora fine-tuning and small-scale models, which not only ensures task performance but also reduces deployment costs.
[0131] The multi-task execution device based on the small language model can be implemented in the form of a computer program. The computer program can be used in Figure 4 Runs on the computer device shown.
[0132] See also Figure 4 , Figure 4 4 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 400 is a server, or a server cluster. The server can be an independent server, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0133] See also Figure 4 The computer device 400 includes a processor 402 , a memory and a network interface 405 connected via a device bus 401 , wherein the memory may include a storage medium 403 and an internal memory 404 .
[0134] The storage medium 403 may store an operating system 4031 and a computer program 4032. When the computer program 4032 is executed, the processor 402 may execute a multi-task execution method based on a small language model.
[0135] The processor 402 is used to provide computing and control capabilities to support the operation of the entire computer device 400 .
[0136] The internal memory 404 provides an environment for the operation of the computer program 4032 in the storage medium 403. When the computer program 4032 is executed by the processor 402, the processor 402 can execute a multi-task execution method based on a small language model.
[0137] The network interface 405 is used for network communication, such as providing data information transmission, etc. Those skilled in the art will understand that Figure 4 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 400 to which the solution of the present application is applied. The specific computer device 400 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0138] The processor 402 is used to run a computer program 4032 stored in the memory to implement the multi-task execution method based on a small language model disclosed in the embodiment of the present application.
[0139] Those skilled in the art will understand that Figure 4 The embodiments of the computer device shown in the figure do not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, in some embodiments, the computer device may only include a memory and a processor. In such embodiments, the structure and function of the memory and the processor are the same as those of the embodiment of the present invention. Figure 4 The embodiments shown are consistent and will not be described again here.
[0140] It should be understood that in the embodiment of the present application, the processor 402 may be a central processing unit (CPU), and the processor 402 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0141] In another embodiment of the present application, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the multi-task execution method based on a small language model disclosed in the embodiment of the present application is implemented.
[0142] It should be noted that the data involved in this case were all obtained legally.
[0143] It will be clear to those skilled in the art that, for the convenience and simplicity of description, the specific working process of the above-described equipment, devices and units can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. It will be appreciated by those of ordinary skill in the art that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0144] In the several embodiments provided in the present application, it should be understood that the disclosed equipment, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, and units with the same function may be combined into one unit. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or units, or may be electrical, mechanical or other forms of connection.
[0145] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0146] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0147] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a background server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a disk or an optical disk.
[0148] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A multi-task execution method based on a small language model, characterized in that: include: In response to an execution instruction for a target task in a financial scenario, determining a target task type of the target task; Obtaining a target Lora weight from the main memory of the central processing unit according to the target task type, and loading the target Lora weight into the video memory of the graphics processing unit; Obtaining initial weights of a small language model from the video memory; Performing the target task using the small language model under the initial weights to obtain a first probability matrix for each predicted word; Performing the target task using the small language model under the target Lora weight to obtain a second probability matrix for each predicted word; Merge the first probability matrix of each word with the corresponding second probability matrix to obtain the target probability matrix of each word; The execution result of the target task is generated according to the target probability matrix of each word.
2. The multi-task execution method based on a small language model according to claim 1, characterized in that: The method further comprises: Get each task type; For each task type, the small language model is fine-tuned to obtain the Lora weight corresponding to each task type; Configure the task ID corresponding to each task type; The Lora weight corresponding to each task type is marked using the task identifier corresponding to each task type, and the marked Lora weight is stored in the main memory of the central processing unit.
3. The multi-task execution method based on a small language model according to claim 1, characterized in that: The video memory is used to store the initial weight, the cache space of the applied key-value cache, and the preset temporary weight.
4. The multi-task execution method based on a small language model according to claim 1, characterized in that: The step of obtaining a target Lora weight from a main memory of a central processing unit according to the target task type includes: Obtaining a target task identifier corresponding to the target task type; Traversing the main memory using the target task identifier; The traversed Lora weight having the target task identifier is determined as the target Lora weight.
5. The multi-task execution method based on a small language model according to claim 1, characterized in that: The step of combining the first probability matrix of each word with the corresponding second probability matrix to obtain a target probability matrix of each word includes: The first probability matrix of each word is added to the corresponding second probability matrix bit by bit to obtain the target probability matrix of each word.
6. The multi-task execution method based on a small language model according to claim 1, characterized in that: The generating the execution result of the target task according to the target probability matrix of each word includes: Obtaining a vocabulary of the small language model; Use the target probability matrix of each word to match in the vocabulary to obtain each target word; Each target word is combined in turn to obtain the execution result of the target task.
7. The multi-task execution method based on a small language model according to claim 1, characterized in that: After obtaining the execution result of the target task, the method further includes: The target Lora weight is released from the video memory.
8. A multi-task execution device based on a small language model, characterized in that: include: a determination unit, configured to determine a target task type of the target task in response to an execution instruction for the target task in the financial scenario; A loading unit, configured to obtain a target Lora weight from a main memory of a central processing unit according to the target task type, and load the target Lora weight into a video memory of a graphics processing unit; An acquisition unit, used for acquiring the initial weight of the small language model from the video memory; An execution unit, configured to execute the target task using the small language model under the initial weights to obtain a first probability matrix for each predicted word; The execution unit is further configured to perform the target task using the small language model under the target Lora weight to obtain a second probability matrix for each predicted word; A merging unit, used to merge the first probability matrix of each word with the corresponding second probability matrix to obtain a target probability matrix for each word; A generating unit is used to generate the execution result of the target task according to the target probability matrix of each word.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the multi-task execution method based on a small language model is implemented according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, enables the processor to perform the multi-task execution method based on a small language model according to any one of claims 1 to 7.