Low-resource unified information extraction method based on efficient fine tuning of large model parameters
Patent Information
- Application Number
- CN202410171987.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-07
- Publication Date
- 2024-08-23
AI Technical Summary
Traditional information extraction methods require a large amount of computing resources and time, and cannot effectively utilize the powerful generation capabilities of large models to complete unified information extraction tasks, and the existing technology lacks resource-saving methods.
Adopt a low-resource unified information extraction method based on efficient fine-tuning of large model parameters, and generate instruction fine-tuning data sets by designing instruction templates to efficiently fine-tune parameters of large models, and introduce model quantification pruning during the fine-tuning process to reduce resource consumption and training time. .
It achieves unified information extraction without training each sub-task separately in low resource scenarios, simplifies the model structure, reduces training difficulty, improves information utilization and generalization capabilities, and saves computing resources.
Smart Images

Figure CN118536491A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of information extraction, and in particular to a low-resource unified information extraction method based on efficient fine-tuning of large model parameters. Background Art
[0002] Information Extraction (IE) is a basic task in the field of natural language processing. It can be divided into three subtasks, including named entity recognition (NER), relation extraction (RE), and event extraction (EE). The purpose of named entity recognition is to identify and classify named entities from a given text; the purpose of relation extraction is to identify and extract the relationship between entities from a given text; the purpose of event extraction is to extract event information from a given text and complete the classification. The results of information extraction are usually used as the basis for other natural language processing tasks and knowledge graph construction.
[0003] Traditional information extraction methods only use small models and can only handle single information extraction tasks, such as entity recognition, relationship extraction, and event extraction. This often requires a large amount of pre-labeled data, and each specific downstream task requires separate training to adapt to different task requirements. Therefore, it consumes a lot of computing resources and time. Therefore, we need a new information extraction algorithm that can make good use of the powerful generation capabilities of large models to complete all information extraction tasks at one time, while saving computing resources and time.
[0004] In the current prior art, there is no method that utilizes a large model to perform unified information extraction and save resources. Summary of the invention
[0005] The purpose of the present invention is to provide a low-resource unified information extraction method based on efficient fine-tuning of large model parameters, which can use the efficient parameter fine-tuning method to fine-tune the large model, and introduce a model quantization pruning method to reduce resource consumption and speed up training.
[0006] To achieve the above object, the present invention provides the following solutions:
[0007] The present invention provides a low-resource unified information extraction method based on efficient fine-tuning of large model parameters, the method comprising the following steps:
[0008] S1, design different instruction templates for different downstream tasks, and finally apply the instruction templates to the original dataset to generate an instruction fine-tuning dataset;
[0009] S2, based on the instruction fine-tuning dataset, uses the parameter efficient fine-tuning method to fine-tune the selected large model. During the instruction fine-tuning process, the selected large model is quantized and pruned to obtain the fine-tuned large model.
[0010] S3: Input the text to be extracted into the fine-tuned large model, and use the fine-tuned large model to perform unified information extraction.
[0011] In step S1, different instruction templates are designed for different downstream tasks, and finally the instruction templates are applied to the original data set to generate an instruction fine-tuning data set, which specifically includes:
[0012] Design several instruction templates according to the task types of different downstream tasks and the structure, type and purpose of data;
[0013] For the original data set in json format, a piece of data is extracted and randomly matched to a designed instruction template to generate an instruction fine-tuning data, where the standard for matching data to the instruction template is to ensure the consistency of data type, content and template requirements, while maintaining the integrity and accuracy of the data, and considering contextual information and set domain requirements; the matching operation is repeated until all data in the original data set is converted into instruction fine-tuning data to form an instruction fine-tuning data set.
[0014] Furthermore, in step S1, the downstream task is a named entity recognition task, a relationship extraction task or an event extraction task.
[0015] Furthermore, the efficient parameter fine-tuning method includes lora, p-tuningv2, and the selected model is ChatGLM, LLaMa or baichuan.
[0016] Furthermore, in step S2, during the instruction fine-tuning process, the selected large model is quantized and pruned, specifically including:
[0017] Convert the floating point parameters of the selected large model into low-order integer format by quantization;
[0018] Next, the selected large model is pruned to remove parameters whose impact on model performance is below a set threshold;
[0019] After quantization and pruning, continue to fine-tune the instructions of the large model.
[0020] Furthermore, the integer format is int8 or int4.
[0021] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects: the low-resource unified information extraction method based on efficient fine-tuning of large model parameters provided by the present invention is different from the traditional information extraction algorithm. The traditional information extraction algorithm has the following disadvantages: first, a different network architecture is used to process each subtask, which makes the model structure very complex; second, each subtask needs to be trained separately. Since the training data of each subtask is quite different, the training difficulty is greater and more time and computing resources are required; third, there is some knowledge overlap between subtasks, but since different subtasks are processed separately, the information utilization is insufficient.
[0022] Therefore, the present invention proposes a unified information extraction algorithm based on efficient fine-tuning of large model parameters in a low-resource scenario. This method uses a small amount of instruction fine-tuning data to efficiently fine-tune the parameters of the large model. Compared with the traditional information extraction method, this method has the following advantages: First, unified information extraction can be achieved without separate training for specific subtasks, making the model structure simple, easy to maintain and optimize; second, the large model is fine-tuned by a small amount of instruction fine-tuning data and an efficient parameter fine-tuning method, which reduces the training difficulty, and introduces a model quantization pruning method, which reduces the training time and the required computing resources; third, the large model has rich prior knowledge and stronger representation capabilities, which can better utilize the knowledge overlap between information, improve the utilization rate of information, and enable the information extraction model to have better generalization capabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0024] Figure 1 A flowchart of a low-resource unified information extraction method based on efficient fine-tuning of large model parameters provided by the present invention;
[0025] Figure 2 This is an example diagram of an instruction fine-tuning template according to an embodiment of the present invention;
[0026] Figure 3 This is an example diagram of the original data format of an embodiment of the present invention;
[0027] Figure 4 This is an example diagram of instruction fine-tuning data according to an embodiment of the present invention;
[0028] Figure 5This is an example diagram of the reasoning results of the embodiment of the present invention. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. 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.
[0030] The low-resource unified information extraction method based on efficient fine-tuning of large model parameters provided by the present invention utilizes an efficient parameter fine-tuning method to fine-tune the large model, and introduces a model quantization pruning method to reduce resource consumption and speed up training. The method is divided into three stages. The first stage requires manual design of different instruction templates for different downstream tasks, and then the original data set is transformed into a corresponding instruction data set according to the template; the second stage uses the transformed instruction fine-tuning data set to perform supervised fine-tuning on the large model, with the aim of allowing the model to learn the output format of the information extraction task. And in this stage, the model needs to be quantized and pruned; the third stage uses the fine-tuned large model to perform reasoning on specific information extraction tasks.
[0031] like Figure 1 Specifically, the low-resource unified information extraction method based on efficient fine-tuning of large model parameters provided by the present invention can be executed by a low-resource unified information extraction system based on efficient fine-tuning of large model parameters, which integrates various functional modules for executing algorithms of various steps. The method includes the following steps:
[0032] S1, design different instruction templates for different downstream tasks, and finally apply the instruction templates to the original dataset to generate an instruction fine-tuning dataset; specifically including:
[0033] Design several instruction templates according to the task types of different downstream tasks and the structure, type and purpose of data; the downstream task is an information extraction task, for example, the downstream task is a named entity recognition task, a relationship extraction task or an event extraction task; the basis for designing instruction templates for different data is to first analyze and understand the essential characteristics of the data, including its structure, type and purpose, and then create a template that can effectively summarize and process the data based on these characteristics, which requires the template to not only be able to flexibly adapt to the diversity and complexity of the data, but also be able to accurately capture the key information of the data, and be easy for users to understand and use;
[0034] For the original data set in json format, extract a piece of data and randomly match it to a designed instruction template to generate an instruction fine-tuning data, where the standard or rule for matching data to the instruction template is to ensure the consistency of data type and content with template requirements, while maintaining the integrity and accuracy of the data and considering the context information and the requirements of the setting field; repeat the matching operation until all the data in the original data set is converted into instruction fine-tuning data to form an instruction fine-tuning data set;
[0035] The specific process of step S1 includes:
[0036] Step 1: Data and template preprocessing
[0037] Data preprocessing and standardization: Standardize the raw data in JSON format to ensure the consistency of the data format. For example, unify the timestamp format, number format, etc.
[0038] Template preprocessing and template design: Design a series of instruction templates for each downstream task (such as named entity recognition, relationship extraction, event extraction, etc.). Each template contains several placeholders for subsequent insertion of corresponding data.
[0039] Step 2: Feature extraction and template matching algorithm
[0040] Feature extraction:
[0041] (1) Data features: extract features from preprocessed data, including entity type, keywords, data structure, etc.; (2) Template features: extract template features based on the template metadata, such as applicable task type, data type requirements, etc.
[0042] Template matching algorithm: (1) Similarity calculation: Design an algorithm to calculate the similarity between data features and template features. Methods such as vector space model (VSM) and cosine similarity can be used.
[0043] (2) Conditional judgment: Based on the similarity score and the metadata of the template (such as the required data type, domain information, etc.), conditional judgment is performed on each data and the template with the highest similarity is selected for matching.
[0044] Step 3: Matching rules and filling in data
[0045] Matching rules: (1) Consistency check: Check whether the data meets the data type and structure requirements of the selected template. (2) Completeness and accuracy verification: Verify whether the data contains all the information required by the template and the accuracy of this information.
[0046] Data filling: For successfully matched data and templates, fill the data into the corresponding positions according to the placeholders in the template to generate instruction fine-tuning data.
[0047] Step 4: Iterative Optimization
[0048] Evaluation and feedback: Evaluate the quality of matching results through experiments and user feedback. Based on the evaluation results, continuously optimize data preprocessing, feature extraction methods, matching algorithms, and template design.
[0049] Implementation Example
[0050] Suppose there is an instruction template for event extraction: "An [event type] occurred at [location], involving [entity]." For a specific data: "At school, a student was praised. This student is Xiaohong."
[0051] Data preprocessing: Identify "school" as a location, "students are praised" as an event type, and "Xiaohong" as a person's name.
[0052] Template matching: Based on the extracted features, select a template that matches the "event extraction" task.
[0053] Data filling: Fill the identified entities into the template to generate instruction fine-tuning data: "An incident occurred in the school where a student was praised, involving Xiaohong."
[0054] S2, based on the instruction fine-tuning dataset, uses the parameter efficient fine-tuning method to fine-tune the selected large model. During the instruction fine-tuning process, the selected large model is quantized and pruned to obtain the fine-tuned large model; specifically, it includes:
[0055] After obtaining the instruction fine-tuning dataset, we will select a suitable large model and an efficient parameter fine-tuning method to perform instruction fine-tuning training on the large model. Instruction fine-tuning is a flexible model fine-tuning method that can customize the pre-trained language model according to the needs of specific tasks. By designing different instruction templates for different tasks and fine-tuning them, the model can perform different information extraction tasks according to the instructions input by the user. This fine-tuning method is applicable to all information extraction methods including entity extraction, relationship extraction, and event extraction. Suitable large models can be large language models, such as ChatGLM, LLAM, Baichuan, etc., and the parameter fine-tuning methods of universities include LoRA, P-TuningV2, etc. The selection of large models is mainly based on task requirements, model performance, resource constraints, and fine-tuning data. Different models may be selected for different information extraction tasks, such as named entity recognition, relationship extraction, or event extraction, because different models have different advantages in processing specific types of data. For example, some models may perform better in text understanding, while others may be better at capturing complex relationship patterns. In addition, the choice of model is also limited by the available computing resources and the nature of the fine-tuning data. Although large models have powerful performance, they require more computing resources. The coverage and quality of fine-tuning data also have an impact on the choice of model because they determine the prior knowledge and domain adaptability of the model. The fine-tuning scheme usually needs to be adjusted according to the selected model because different model architectures and characteristics may require different fine-tuning strategies to maximize their performance.
[0056] When fine-tuning instructions for large models, in order to improve training and inference speed, a model quantization and pruning method is introduced, which can quantize the model to int8 and int4 respectively. First, through quantization, the floating-point parameters of the model (such as weights) are converted into low-order integer formats (such as int8 or int4), which significantly reduces the memory usage and computing requirements of the model. Next, pruning is performed, that is, parameters that have little impact on model performance, such as small weights or entire neurons, are removed to further reduce the complexity and size of the model. However, these two steps may cause the performance of the model to deteriorate, so the model needs to be fine-tuned next to restore or optimize its performance on specific tasks. This process involves setting the model architecture, adjusting hyperparameters, performing backpropagation and gradient descent, etc. Finally, a comprehensive evaluation of the quantized and pruned model is performed to ensure that it meets the application requirements in terms of accuracy, speed, and resource consumption.
[0057] Specifically, the algorithm steps for instruction fine-tuning are as follows:
[0058] 1. Prepare an instruction fine-tuning dataset: Based on the description in step S1, prepare an instruction fine-tuning dataset for a specific task (such as named entity recognition). This dataset contains various samples with clear instructions to guide the model to perform specific information extraction tasks.
[0059] 2. Choose a large model and fine-tuning method: Based on the task requirements, model performance, resource constraints, and the characteristics of the fine-tuning data, choose an appropriate large model (such as LLaMA) and fine-tuning method (such as LoRA or P-Tuning V2). For example, if the task is named entity recognition, you may choose a model that performs well in text understanding.
[0060] 3. Preparation for efficient parameter fine-tuning:
[0061] LoRA: Adjusts the weights of the model by adding low-rank matrices at specific layers of the model without changing the structure of the pre-trained weights.
[0062] P-TuningV2: Utilizes trainable continuous vectors (i.e., prompt vectors) instead of traditional hard-coded prompts to achieve more flexible fine-tuning.
[0063] 4. Perform fine-tuning:
[0064] Loads the selected large model.
[0065] Apply the selected fine-tuning technique and train the model based on the instruction fine-tuning dataset. During the training process, the model learns how to perform a specific task based on the input instructions.
[0066] The model is quantized and pruned to improve the model's running efficiency and reduce the model size while trying to maintain the fine-tuned performance.
[0067] 5. Evaluation and optimization: Use an independent test set to evaluate the performance of the fine-tuned model. Based on the evaluation results, it may be necessary to adjust the fine-tuning strategy, such as changing the fine-tuning method, adjusting the training parameters, or further optimizing the dataset.
[0068] Specific example:
[0069] Assuming the task is named entity recognition, we choose the LLaMA model and the LoRA fine-tuning method for example:
[0070] Task: Named Entity Recognition.
[0071] Fine-tuning method: LoRA.
[0072] Model: LLaMA.
[0073] Fine-tuning process:
[0074] 1. Data preparation: Based on the named entity recognition task, prepare an instruction fine-tuning dataset containing various named entities (names, places, organizations, etc.).
[0075] 2. Model and fine-tuning technique selection: The LLaMA model is selected because of its strong ability in text understanding; LoRA is selected as the fine-tuning technique because it can effectively adjust the weights while keeping the model structure unchanged.
[0076] 3. Execution fine-tuning: Use LoRA to fine-tune LLaMA and train the model through the instruction fine-tuning dataset so that it can recognize named entities in text based on instructions.
[0077] 4. Quantization and pruning: After fine-tuning, the model is quantized and pruned to reduce the model size and improve the inference speed.
[0078] 5. Evaluation: Use an independent test set to evaluate the performance of the model on the named entity recognition task. Fine-tune parameters or methods as needed to optimize performance.
[0079] The steps for model training through instruction fine-tuning are as follows:
[0080] 1. Initialize model parameters;
[0081] 2. Pass the fine-tuning data to the model and calculate the model's predicted output through forward propagation;
[0082] 3. Calculate the error value between the predicted output and the actual result through the loss function;
[0083] 4. Calculate the gradient of model parameters through the back propagation algorithm;
[0084] 5. Update model parameters according to the gradient calculation results;
[0085] 6. Repeat the training iterations until the error is less than the preset value and the model fine-tuning is completed.
[0086] S3: Input the text to be extracted into the fine-tuned large model, and use the fine-tuned large model to perform unified information extraction.
[0087] Example: Taking the named entity recognition task as an example, the present invention can construct Figure 2 The instruction templates shown include: "Find the entities specified in the following sentence", "Perform entity extraction tasks", etc.
[0088] After constructing the instruction template for each task, you need to use the corresponding instruction template to transform the original data set. Figure 3As shown, the original data format is JSON format, the boundaries of the entity are marked using numeric subscript indexes, and the type field marks the type of the entity.
[0089] The format of the modified instruction fine-tuning data is as follows Figure 4 As shown in the figure, the input field is the instruction fine-tuning data generated after the original data set is applied with the instruction template, the target field is the preset answer, and the task_type field is used to identify different information extraction tasks.
[0090] Next, we use the constructed instruction fine-tuning dataset to efficiently fine-tune the parameters of the large model and perform quantitative pruning of the model. Finally, we can use the fine-tuned model to achieve unified information extraction. Taking entity extraction as an example, Figure 5 As shown in the figure, the answer field is a list, which shows the final extraction results. The large model after fine-tuning and quantitative pruning can complete the recognition of named entities while saving certain resources.
[0091] The low-resource unified information extraction system based on efficient fine-tuning of large model parameters provided by the present invention includes the following modules:
[0092] The instruction fine-tuning dataset construction module is used to design different instruction templates for different downstream tasks, and finally apply the instruction templates to the original dataset to generate the instruction fine-tuning dataset;
[0093] The large model training module is used to fine-tune the selected large model based on the instruction fine-tuning dataset using an efficient parameter fine-tuning method. During the instruction fine-tuning process, the selected large model is quantized and pruned to obtain the fine-tuned large model.
[0094] The information extraction module is used to input the text to be extracted into the fine-tuned large model and use the fine-tuned large model to perform unified information extraction.
[0095] The present invention also provides an electronic device, comprising one or more processors and a memory;
[0096] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the low-resource unified information extraction method based on efficient fine-tuning of large model parameters as described above.
[0097] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that when the computer program is executed by a processor, it implements the low-resource unified information extraction method based on efficient fine-tuning of large model parameters as described above.
[0098] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium, and the program can include the processes of the above-mentioned method embodiments when executed. The storage medium can be a memory, a disk, an optical disk, etc.
[0099] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A low-resource unified information extraction method based on efficient fine-tuning of large model parameters, It is characterized in that The following steps are involved: S1, design different instruction templates for different downstream tasks, and finally apply the instruction templates to the original dataset to generate an instruction fine-tuning dataset; S2, based on the instruction fine-tuning dataset, uses the parameter efficient fine-tuning method to fine-tune the selected large model. During the instruction fine-tuning process, the selected large model is quantized and pruned to obtain the fine-tuned large model. S3: Input the text to be extracted into the fine-tuned large model, and use the fine-tuned large model to perform unified information extraction.
2. According to claim 1, the low-resource unified information extraction method based on efficient fine-tuning of large model parameters, It is characterized in that In step S1, different instruction templates are designed for different downstream tasks, and finally the instruction templates are applied to the original data set to generate an instruction fine-tuning data set, which specifically includes: Design several instruction templates according to the task types of different downstream tasks and the structure, type and purpose of data; For the original data set in json format, a piece of data is extracted and randomly matched to a designed instruction template to generate an instruction fine-tuning data, where the standard for matching data to the instruction template is to ensure the consistency of data type, content and template requirements, while maintaining the integrity and accuracy of the data, and considering contextual information and set domain requirements; the matching operation is repeated until all data in the original data set is converted into instruction fine-tuning data to form an instruction fine-tuning data set.
3. According to claim 1, the low-resource unified information extraction method based on efficient fine-tuning of large model parameters, It is characterized in that In step S1, the downstream task is a named entity recognition task, a relationship extraction task or an event extraction task.
4. According to claim 1, the low-resource unified information extraction method based on efficient fine-tuning of large model parameters, It is characterized in that The efficient parameter fine-tuning method includes lora, p-tuningv2, and the selected model is ChatGLM, LLaMa or baichuan.
5. According to claim 1, the low-resource unified information extraction method based on efficient fine-tuning of large model parameters, It is characterized in that In step S2, during the instruction fine-tuning process, the selected large model is quantized and pruned, specifically including: Convert the floating point parameters of the selected large model into low-order integer format by quantization; Next, the selected large model is pruned to remove parameters whose impact on model performance is below a set threshold; After quantization and pruning, continue to fine-tune the instructions for the selected large model.
6. The low-resource unified information extraction method based on efficient fine-tuning of large model parameters according to claim 5, It is characterized in that The integer format is int8 or int4.
Citation Information
Cited By
Monitoring data processing method and device and computer storage medium
CN119169538A
