Large language model fine tuning training method and system for multi-task learning in legal field

By designing a multi-task efficient parameter fine-tuning framework in a large language model, using the LoRA module and task-driven neural network gate mechanism, the problem of diversified task requirements and high training costs in the legal field of large language models is solved, and the multi-to-many system is achieved efficient adaptation and cost reduction of downstream legal tasks.

CN119474861APending Publication Date: 2025-02-18TIANFU JIANGXI LAB
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411489714.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-24
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In the application of existing large language models in the legal field, they face diversified downstream tasks and high training and debugging costs, and it is difficult to effectively adapt to different legal business scenarios.

Method used

A multi-task efficient parameter fine-tuning framework is designed, using the LoRA module and task-driven neural network gating mechanism to dynamically adjust model parameters to adapt to different legal tasks needs and realize multi-task fine-tuning of large language models.

Benefits of technology

Through this method, while maintaining training inference efficiency, it is possible to adjust only the part of the total parameters of the large language model with less than 1% to achieve effective adaptation to multiple downstream legal tasks, reducing the cost and time of model customization Invest.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119474861A_ABST
    Figure CN119474861A_ABST
Patent Text Reader

Abstract

The invention provides a large language model fine-tuning training method and system for multi-task learning in the legal field, relates to the field of natural language processing, and solves the problems that an existing large language model faces various tasks to be processed and the training and debugging cost is too high in specific legal related application scenes. The method comprises the following steps: acquiring an infrastructure and configuring a plurality of LoRA modules for adapting to one or more different downstream legal tasks; task-related learning modules are integrated, so that each LoRA module is adjusted according to the requirements of downstream legal tasks; a neural network gating mechanism is adopted, a task embedding matrix corresponding to downstream legal tasks is input, contribution weights corresponding to the downstream legal tasks are dynamically determined, matched updating parameters are generated in a self-adaptive mode, and fine adjustment is conducted according to specific requirements of different downstream legal task scenes; according to the method, efficient parameter fine tuning in a multi-task legal business scene can be realized, and the scene adaptation cost and the secondary development workload are effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing and is applied to the fine-tuning training process of a large language model, and specifically to a large language model fine-tuning training method and system for multi-task learning in the legal field. Background Art

[0002] In recent years, large language models (LLMs) have demonstrated remarkable capabilities in natural language understanding and generation, attracting widespread attention from many industries. These models are based on deep learning architectures, acquire language knowledge by processing massive amounts of text data, and can perform a variety of complex natural language tasks. With the maturity of foundation LLMs, researchers have begun to explore how to adapt these models to the application needs of specific vertical fields through secondary training or fine-tuning, in order to achieve more accurate and targeted services. The legal field is one of the important and potential application scenarios.

[0003] The legal industry has its own unique complexity and professionalism, which makes it particularly important to develop artificial intelligence systems that can understand and effectively process legal information. Currently, large language models have been applied to online legal assistants to provide users with instant legal consulting services; at the same time, within law firms, they are also used to assist lawyers in case research, contract review and other work, greatly improving work efficiency and service quality. However, despite initial success, there are still a series of challenges in the actual deployment process.

[0004] First, due to the wide variety of downstream legal tasks, from simple question-answering to complex case analysis, the input and output forms required for different tasks vary greatly, which makes it extremely difficult to use a single general model for unified fine-tuning. In order to meet diverse needs, it is often necessary to design fine-tuning strategies for each specific application scenario, which not only consumes a lot of professional knowledge resources, but also increases manpower and computing costs. In addition, considering that legal documents usually contain sensitive information, it is also a major challenge to ensure data privacy and security while completing high-quality data labeling.

[0005] Secondly, although some existing multi-task learning frameworks can solve the cross-task generalization problem to a certain extent, comprehensive parameter fine-tuning is still a very time-consuming and expensive process for large language models with huge parameters. Traditional methods require adjustments to the entire network structure, and even with strong computing power support, such operations may exceed a reasonable time frame. Therefore, there is an urgent need to develop more efficient and flexible parameter optimization techniques to reduce training time and resource usage while maintaining model performance.

[0006] It can be seen that although solutions based on large language models have brought unprecedented opportunities to the legal field, many obstacles still need to be overcome to fully realize their potential. In this regard, technical personnel in this field have taken the multi-task learning part of large language models in specific fields as a new research point. Summary of the invention

[0007] Based on the current status of the background technology, the purpose of the present invention is to solve the problems of diverse tasks to be processed and high training and debugging costs faced by existing large language models in specific legal application scenarios, and therefore proposes a large language model fine-tuning training method and system for multi-task learning in the legal field. The present invention designs a learnable, multi-module integrated multi-task efficient parameter fine-tuning framework based on the large language model efficient fine-tuning method LoRA, realizes efficient parameter fine-tuning in multi-task legal business scenarios, and effectively reduces the model's scenario adaptation cost and secondary development workload.

[0008] The present invention adopts the following technical solutions to achieve the purpose:

[0009] A large language model fine-tuning training method for multi-task learning in the legal field comprises: obtaining an infrastructure based on a large language model, configuring a plurality of LoRA modules for the infrastructure, wherein each LoRA module is used to adapt to one or more different downstream legal tasks; integrating a task-related learning module in each LoRA module, and adjusting each LoRA module according to the requirements of the corresponding downstream legal tasks through the learning module; adopting a neural network gating mechanism, inputting a task embedding matrix corresponding to the downstream legal tasks to be executed, and dynamically determining the contribution weight of each LoRA module corresponding to the downstream legal tasks; according to the contribution weight, adaptively generating matching update parameters for each downstream legal task, so that the large language model is fine-tuned according to the specific requirements of different downstream legal task scenarios; iteratively optimizing the large language model through the update parameters until the preset model performance indicators are reached.

[0010] Furthermore, the method specifically includes the following process steps:

[0011] S1. After obtaining the base model and pre-training it, a pre-trained legal large model is obtained;

[0012] S2. After acquiring and processing multiple types of legal business data, generate multi-task fine-tuning data;

[0013] S3. Configure multiple LoRA modules for the pre-trained legal big model, perform multi-task fine-tuning training on the pre-trained legal big model based on the multi-task fine-tuning data, and obtain the multi-task legal big model after the training is completed;

[0014] S4. Apply and deploy the multi-task legal big model, which supports multiple downstream legal tasks corresponding to multiple types of legal business data.

[0015] Furthermore, in step S3, while configuring multiple LoRA modules, a task-driven neural network gating mechanism is adopted to fine-tune different specific training data in the multi-task data, so that the pre-trained legal large model can adaptively adapt to different downstream legal tasks.

[0016] The present invention also provides a large language model fine-tuning training system for multi-task learning in the legal field, the system comprising:

[0017] An infrastructure acquisition module based on a large language model, used to provide the infrastructure;

[0018] Multiple LoRA module configuration units, each LoRA module is adapted to one or more different downstream legal tasks, and is integrated with task-related learning modules, so that each LoRA module can be adjusted according to the corresponding downstream legal task requirements;

[0019] A neural network gating mechanism unit, which is used to receive a task embedding matrix corresponding to a downstream legal task to be performed, and dynamically determine the contribution weight of each LoRA module to the downstream legal task;

[0020] A parameter update generator, for adaptively generating matching update parameters for each downstream legal task based on the contribution weights determined by the neural network gating mechanism unit, so that the large language model can be fine-tuned according to the specific needs of different downstream legal task scenarios;

[0021] The model optimization iteration controller is used to iteratively optimize the large language model according to the update parameters generated by the parameter update generator until the preset model performance indicators are met.

[0022] In summary, due to the adoption of this technical solution, the beneficial effects of the present invention are as follows:

[0023] By adopting a multi-task efficient parameter fine-tuning framework, the present invention can achieve effective adaptation to downstream legal business scenarios by only adjusting less than 1% of the total parameters of the large language model while maintaining the training and reasoning efficiency comparable to that of LoRA. This approach effectively reduces the cost and time investment of model customization for specific application scenarios.

[0024] Compared with the traditional LoRA efficient fine-tuning method, the method proposed in this paper supports a centralized multi-task learning mechanism, which enables a single model to adapt to multiple different downstream task requirements at the same time, without the need to perform a separate LoRA fine-tuning process for each specific task. This design effectively enhances the model's support for diverse legal service scenarios and reduces the workload of repeated development.

[0025] By introducing a task-driven gated neural network learning mechanism, the present invention not only avoids the problem of decreased learning efficiency that may occur in the traditional fine-tuning process, but also ensures that no additional forward computing burden is required for practical application after training. This means that the effective utilization of computing resources is further improved while ensuring performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 It is a schematic diagram of the overall process of the method of the present invention;

[0027] Figure 2 A schematic diagram of multi-task learning in the method of the present invention;

[0028] Figure 3 Schematic diagram of a multi-task efficient parameter fine-tuning framework in the method of the present invention;

[0029] Figure 4 Schematic diagram of the LoRA module under multi-tasking in the method of the present invention. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0031] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0032] Example 1

[0033] A large language model fine-tuning training method for multi-task learning in the legal field, the main contents of the method include: obtaining an infrastructure based on a large language model, configuring multiple LoRA modules for the infrastructure, wherein each LoRA module is used to adapt to one or more different downstream legal tasks; integrating task-related learning modules in each LoRA module, and adjusting each LoRA module according to the requirements of the corresponding downstream legal tasks through the learning modules; adopting a neural network gating mechanism, inputting a task embedding matrix corresponding to the downstream legal tasks to be executed, and dynamically determining the contribution weight of each LoRA module corresponding to the downstream legal tasks; according to the contribution weights, adaptively generating matching update parameters for each downstream legal task, so that the large language model is fine-tuned according to the specific requirements of different downstream legal task scenarios; iteratively optimizing the large language model through the update parameters until the preset model performance indicators are reached.

[0034] like Figure 1 As shown, when implementing this method, its main process can be summarized as follows:

[0035] S1. After obtaining the base model and pre-training it, a pre-trained legal large model is obtained;

[0036] S2. After acquiring and processing multiple types of legal business data, generate multi-task fine-tuning data;

[0037] S3. Configure multiple LoRA modules for the pre-trained legal big model, perform multi-task fine-tuning training on the pre-trained legal big model based on the multi-task fine-tuning data, and obtain the multi-task legal big model after the training is completed;

[0038] S4. Apply and deploy the multi-task legal big model, which supports multiple downstream legal tasks corresponding to multiple types of legal business data.

[0039] The core of the above method lies in the design of multi-path, learnable, and adaptive LoRA fine-tuning modules for multi-task learning. The multi-path learnable LoRA module can effectively learn task-related knowledge, thereby maintaining the high efficiency of full-parameter fine-tuning of relatively large language models and adapting to multi-task learning scenarios. At the same time, the task-driven input / output gated neural network design can adaptively learn unique network parameters for training data of different tasks to adapt to different downstream learning tasks.

[0040] The most significant application feature of this method is that it extends the LoRA fine-tuning method to multi-task learning scenarios. For multiple types of downstream applications in the legal field, there is no need to repeatedly fine-tune multiple LoRA models. Multi-channel LoRA modules collaborate to learn to adapt to task diversity while greatly reducing the cost of training fine-tuning, improving efficiency and reducing training overhead. It can be extended to multi-task learning scenarios in similar fields.

[0041] Combination Figure 1 and Figure 2 This embodiment will introduce each step of the method flow in detail. Figure 2 The single multi-task fine-tuning training branch shown is the method concept of this embodiment, while the other branch of multiple LoRA fine-tuning is a comparative display of the traditional design.

[0042] In step S1 of this embodiment, the base model is pre-trained using common legal corpus to obtain a pre-trained legal large model. The base model here can use an existing public model, such as Qwen and LLaMA.

[0043] Step S2 of this embodiment performs data engineering, which processes data based on multiple types of legal business data. Data processing includes quality filtering, data deduplication, data cleaning, word segmentation, and annotation proofreading; the multiple types of legal business data processed by data correspond to multiple downstream legal tasks, including named entity recognition, attribute extraction, legal entity discovery, legal text classification, intent query, legal report generation, and legal question-and-answer dialogue.

[0044] In step S3 of this embodiment, Figure 3 As shown in the figure, while configuring multiple LoRA modules, a task-driven neural network gating mechanism is used to adapt the pre-trained legal model to different downstream legal tasks based on different specific training data in the multi-task fine-tuning data. The multiple LoRA modules configured here perform collaborative parameter learning and interaction through back propagation, thereby maintaining the parameter learning and update process within each LoRA module.

[0045] In this embodiment, combined with Figure 3 and Figure 4 As shown in the figure, when performing multi-task fine-tuning training, the standard gradient descent algorithm is used, and the forward calculation process is calculated as follows:

[0046]

[0047] In the formula, h j With x j They represent the input and output of the Transformer layer in the pre-trained legal model respectively; W0 represents the weight parameter of the Transformer layer, α represents the hyperparameter, and r represents the rank of the low-rank matrix in the LoRA module; LoRA i (x j ) represents the LoRA module of the jth path; Gate ji Represents the weight function of the corresponding gated neural network; N represents the total number of LoRA modules;

[0048] The gated neural network is embedded in the form of a task matrix. The dimension of the task matrix is ​​T*c, where c represents the dimension of the intermediate layer vector and T represents the task embedding dimension. j , by extracting the jth column of the task matrix as the representation vector of the task, and obtaining the corresponding weight function Gate after linear transformation calculation j .

[0049] In this embodiment, during the multi-task fine-tuning training process, different specific training data are alternately trained based on preset ratios, and different loss functions are used for the corresponding different downstream legal tasks. The training process stops until the loss function converges or reaches the maximum number of iterations. The pre-trained legal big model at this time is saved and used as the multi-task legal big model for subsequent application deployment.

[0050] In step S4 of this embodiment, corresponding component support is added to the multi-task legal big model according to the needs of actual business applications; the added component types include database and RAG. RAG stands for Retrieval Enhanced Generation, which is a technology that combines information retrieval systems and language models, and aims to enhance the generation capability of language models by retrieving relevant information from external knowledge sources.

[0051] Example 2

[0052] Based on Example 1, this embodiment provides a system corresponding to the method of Example 1, namely, a large language model fine-tuning training system for multi-task learning in the legal field, the system comprising:

[0053] An infrastructure acquisition module based on a large language model, used to provide the infrastructure;

[0054] Multiple LoRA module configuration units, each LoRA module is adapted to one or more different downstream legal tasks, and is integrated with task-related learning modules, so that each LoRA module can be adjusted according to the corresponding downstream legal task requirements;

[0055] A neural network gating mechanism unit, which is used to receive a task embedding matrix corresponding to a downstream legal task to be performed, and dynamically determine the contribution weight of each LoRA module to the downstream legal task;

[0056] A parameter update generator, for adaptively generating matching update parameters for each downstream legal task based on the contribution weights determined by the neural network gating mechanism unit, so that the large language model can be fine-tuned according to the specific needs of different downstream legal task scenarios;

[0057] The model optimization iteration controller is used to iteratively optimize the large language model according to the update parameters generated by the parameter update generator until the preset model performance indicators are met.

[0058] In summary, the present invention not only overcomes the key challenges existing in the prior art, such as high training and debugging costs, inefficient task adaptation processes, etc., but also opens up a new path to more intelligent and personalized legal services. The solution has wide applicability and important practical value, and shows great potential in promoting the development of legal technology.

Claims

1. A large language model fine-tuning training method for multi-task learning in the legal field, characterized by: Acquire an infrastructure based on a large language model, configure multiple LoRA modules for the infrastructure, wherein each LoRA module is used to adapt to one or more different downstream legal tasks; integrate task-related learning modules in each LoRA module, and adjust each LoRA module according to the requirements of the corresponding downstream legal tasks through the learning modules; adopt a neural network gating mechanism, input a task embedding matrix corresponding to the downstream legal tasks to be executed, and dynamically determine the contribution weight of each LoRA module corresponding to the downstream legal tasks; based on the contribution weights, adaptively generate matching update parameters for each downstream legal task, so that the large language model can be fine-tuned according to the specific requirements of different downstream legal task scenarios; iteratively optimize the large language model through the update parameters until the preset model performance indicators are reached.

2. The large language model fine-tuning training method for multi-task learning in the legal field according to claim 1 is characterized in that: The method specifically includes the following process steps: S1. After obtaining the base model and pre-training it, a pre-trained legal large model is obtained; S2. After acquiring and processing multiple types of legal business data, generate multi-task fine-tuning data; S3. Configure multiple LoRA modules for the pre-trained legal big model, perform multi-task fine-tuning training on the pre-trained legal big model based on the multi-task fine-tuning data, and obtain the multi-task legal big model after the training is completed; S4. Apply and deploy the multi-task legal big model, which supports multiple downstream legal tasks corresponding to multiple types of legal business data.

3. The large language model fine-tuning training method for multi-task learning in the legal field according to claim 2 is characterized by: In step S1, the base model is pre-trained using general legal corpus to obtain a pre-trained legal large model.

4. The large language model fine-tuning training method for multi-task learning in the legal field according to claim 2 is characterized by: In step S2, data processing includes quality filtering, data deduplication, data cleaning, word segmentation, and annotation and proofreading; the multiple categories of legal business data that have undergone data processing correspond to multiple downstream legal tasks, including named entity recognition, attribute extraction, legal entity discovery, legal text classification, intent query, legal report generation, and legal question-and-answer dialogue.

5. The large language model fine-tuning training method for multi-task learning in the legal field according to claim 2 is characterized by: In step S3, while configuring multiple LoRA modules, a task-driven neural network gating mechanism is adopted to fine-tune the different specific training data in the multi-task data, so that the pre-trained legal large model can adaptively adapt to different downstream legal tasks.

6. The large language model fine-tuning training method for multi-task learning in the legal field according to claim 5 is characterized by: The configured multiple LoRA modules perform collaborative parameter learning and interaction through back propagation, thereby maintaining the parameter learning and update process within each LoRA module.

7. The large language model fine-tuning training method for multi-task learning in the legal field according to claim 5 is characterized by: When performing multi-task fine-tuning training, the standard gradient descent algorithm is used, and the forward calculation process is calculated as follows: In the formula, h j With x j They represent the input and output of the Transformer layer of the LoRA module added to the pre-trained legal model; W0 represents the weight parameter of the Transformer layer, α represents the hyperparameter, and F represents the rank of the low-rank matrix in the LoRA module; LoRA i (x j ) represents the LoRA module of the jth path; Gate ji Represents the weight function of the corresponding gated neural network; N represents the total number of LoRA modules; The gated neural network is embedded in the form of a task matrix. The dimension of the task matrix is ​​T*c, where c represents the dimension of the intermediate layer vector and T represents the task embedding dimension. j , by extracting the jth column of the task matrix as the representation vector of the task, and obtaining the corresponding weight function Gate after linear transformation calculation j .

8. The large language model fine-tuning training method for multi-task learning in the legal field according to claim 7 is characterized by: During the multi-task fine-tuning training process, different specific training data are trained alternately based on preset ratios, and different loss functions are used for the corresponding different downstream legal tasks. The training process stops when the loss function converges or reaches the maximum number of iterations. The pre-trained legal big model at this time is saved and used as the multi-task legal big model for subsequent application deployment.

9. The large language model fine-tuning training method for multi-task learning in the legal field according to claim 2 is characterized by: In step S4, corresponding component support is added to the multi-task legal big model based on the needs of actual business applications; the added component types include database and RAG.

10. A large language model fine-tuning training system for multi-task learning in the legal field, characterized by: The system comprises: An infrastructure acquisition module based on a large language model, used to provide the infrastructure; Multiple LoRA module configuration units, each LoRA module is adapted to one or more different downstream legal tasks, and is integrated with task-related learning modules, so that each LoRA module can be adjusted according to the corresponding downstream legal task requirements; A neural network gating mechanism unit, which is used to receive a task embedding matrix corresponding to a downstream legal task to be performed, and dynamically determine the contribution weight of each LoRA module to the downstream legal task; A parameter update generator, for adaptively generating matching update parameters for each downstream legal task based on the contribution weights determined by the neural network gating mechanism unit, so that the large language model can be fine-tuned according to the specific needs of different downstream legal task scenarios; The model optimization iteration controller is used to iteratively optimize the large language model according to the update parameters generated by the parameter update generator until the preset model performance indicators are met.

Citation Information

Cited By

  • Zeolite multi-task synthesis auxiliary method and system based on large language model

    CN120808923A