Meteorological field-oriented adaptive instruction generation driven large model fine tuning method

Through the adaptive instruction generation-driven large-scale model fine-tuning method, the automatically generated meteorological domain instruction data is used to fine-tune the large-scale pre-trained language model, solving the problems of high resource consumption, high computing costs and difficult deployment in the existing technology, and achieving more efficient meteorological domain task performance.

CN119759510AActive Publication Date: 2025-04-04WUHAN UNIV

Patent Information

Application Number
CN202411593826.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-08
Publication Date
2025-04-04
Estimated Expiration
2044-11-08

AI Technical Summary

Technical Problem

When applying large-scale pre-trained language models to the meteorological field, it is difficult to create large-scale instruction data sets, which are resource-consuming, high computational costs, and difficult to deploy and interpret.

Method used

Adaptive instruction generation-driven large-model fine-tuning method is adopted to build a traffic meteorological seed data set, data augmentation is performed based on preset adaptive instruction fine-tuning strategies, and low-rank adaptive strategies are used to fine-tune the pretrained language model until the preset performance conditions are met.

Benefits of technology

It effectively solves the problems of difficulty in creating large-scale instruction data sets and high resource consumption, improves the performance of the model in meteorological tasks, simplifies model deployment, and improves the interpretability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759510A_ABST
    Figure CN119759510A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of software engineering and artificial intelligence, in particular to a meteorological field-oriented adaptive instruction generation driven large model fine tuning method, which comprises the following steps of: constructing a traffic meteorological seed data set; based on a preset adaptive instruction fine tuning strategy, performing data augmentation on the traffic meteorological seed data set to obtain an instruction data set; and based on a preset ChatGLM3-6B model and the instruction data set, performing fine tuning on the pre-training language model by using a preset low-rank adaptive strategy until the pre-training language model after fine tuning reaches a preset performance condition, obtaining a target language model, and performing meteorological prediction and / or providing meteorological information meeting a preset customization requirement through the target language model. Therefore, the problems of difficulty in creating a large-scale instruction data set, high resource consumption and the like in related technologies are solved, the large model can be finely adjusted by using the automatically generated meteorological field instruction data, and the performance of the model on the meteorological field task is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of software engineering and artificial intelligence technology, and in particular to a large model fine-tuning method driven by adaptive instruction generation in the meteorological field. Background Art

[0002] Large pre-trained language models are an advanced artificial intelligence model based on deep learning technology, designed specifically for processing and understanding complex natural language tasks. They are widely used in a variety of fields, including but not limited to machine translation, dialogue systems, sentiment analysis, and question-answering systems. Technologies such as the self-attention mechanism within the Transformer architecture make these models particularly good at capturing long-distance dependencies in text, thereby maintaining a high degree of semantic and grammatical accuracy when generating and understanding text. This capability ensures the efficiency and accuracy of the model in dealing with real-world natural language processing challenges.

[0003] When applying large pre-trained language models to specific tasks, it is usually necessary to fine-tune these models so that they can adapt to new data distributions and task requirements. Traditional fine-tuning methods involve adding an equal amount of trainable parameters to the original model parameters and then further training them on the data of the target task. This approach allows the model to fully utilize the knowledge gained in the pre-training phase, but it also has several significant drawbacks: (1) Large-scale instruction datasets are difficult to create: Designing instructions requires creative thinking and deep expertise to ensure that accurate and representative examples can be written. In addition, this process involves in-depth understanding of the task context, clarifying the task objectives, and accurately constructing input-output pairs that match the task characteristics, which is not only time-consuming but also labor-intensive.

[0004] (2) High resource consumption: Full parameter fine-tuning requires the introduction of an equal number of trainable parameters as the original model, resulting in extremely high demands on computing resources and storage space.

[0005] (3) High computational cost: The need to update all parameters in each training step leads to huge computational overhead, which is particularly evident when dealing with particularly large models.

[0006] (4) Difficulty in deployment: The fine-tuned model is difficult to load and update dynamically due to the large number of parameters, which makes the deployment and delivery of the model passive and static.

[0007] (5) Poor interpretability: Directly modifying the original parameters may affect the interpretability and controllability of the model behavior, reducing the transparency of the model prediction results. Summary of the invention

[0008] The present invention provides a large model fine-tuning method driven by adaptive instruction generation for the meteorological field to solve the problems that related technologies are difficult to create large-scale instruction data sets, consume a lot of resources and have high computing costs. The method can fine-tune the large model by using automatically generated meteorological field instruction data, thereby improving the performance of the model on meteorological tasks.

[0009] According to one aspect of the present invention, a large model fine-tuning method driven by adaptive instruction generation in the meteorological field is provided, comprising: Construct traffic meteorology seed dataset; Based on a preset adaptive instruction fine-tuning strategy, data augmentation is performed on the traffic meteorology seed data set to obtain an instruction data set; Based on the preset ChatGLM3-6B model and the instruction data set, the pre-trained language model is fine-tuned using the preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches the preset performance conditions, thereby obtaining a target language model, so as to perform weather forecasts and / or provide weather information that meets preset customized requirements through the target language model.

[0010] As a further technical solution, based on a preset adaptive instruction fine-tuning strategy, the traffic meteorology seed data set is augmented to obtain an instruction data set, including: Determine at least one instruction included in each instruction data to be generated; Inputting each instruction and the input instance corresponding to each instruction into a preset model respectively, obtaining an output instance corresponding to each instruction, and obtaining a plurality of given instructions according to each instruction and the output instance corresponding to each instruction; Determine each given instruction and the task type of each given instruction, and determine the instance generation strategy corresponding to each given instruction according to the task type of each given instruction, and perform data augmentation on the corresponding given instruction according to the instance generation strategy corresponding to each given instruction, and obtain the instruction data set according to the augmentation result.

[0011] As a further technical solution, determining the instance generation strategy corresponding to each given instruction according to the task type of each given instruction includes: If the task type is a generation task, the input priority method is used as the instance generation strategy; If the task type is a classification task, the output priority method is used as the instance generation strategy.

[0012] As a further technical solution, based on the preset ChatGLM3-6B model and the instruction data set, the pre-trained language model is fine-tuned using a preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches the preset performance conditions, thereby obtaining a target language model, including: Input the instruction data set into the preset ChatGLM3-6B model to obtain an output text vector; Calculating the loss between the output text vector and the target text vector, and based on the calculation result, fine-tuning the pre-trained language model using the preset low-rank adaptive strategy, and determining whether the fine-tuned pre-trained language model meets the preset performance condition; If the fine-tuned pre-trained language model meets the preset performance conditions, the fine-tuned pre-trained language model is used as the target language model; otherwise, the parameters of the preset low-rank adaptive strategy are adjusted, and the step of fine-tuning the pre-trained language model using the preset low-rank adaptive strategy is re-executed until the new fine-tuned pre-trained language model meets the preset performance conditions, thereby obtaining the target language model.

[0013] As a further technical solution, before inputting the instruction data set into the preset ChatGLM3-6B model, it also includes: The instruction data set is preprocessed to obtain an instruction data set that meets the preset ChatGLM3-6B model question and answer text format.

[0014] As a further technical solution, a traffic meteorology seed dataset is constructed, including: Obtain identifiers of multiple tasks, a name of each task, a task instruction of each task, a task type of each task, and a list of multiple task instances; The traffic meteorology seed dataset is constructed according to the identifiers of the multiple tasks, the name of each task, the task instruction of each task, the task type of each task and the multiple task instance lists.

[0015] According to one aspect of the present invention, there is provided a large model fine-tuning device driven by adaptive instruction generation in the meteorological field, comprising: Construction module, used to construct traffic meteorology seed dataset; An augmentation module, used for augmenting the traffic meteorology seed data set based on a preset adaptive instruction fine-tuning strategy to obtain an instruction data set; The fine-tuning module is used to fine-tune the pre-trained language model based on the preset ChatGLM3-6B model and the instruction data set using a preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches the preset performance conditions, thereby obtaining a target language model, so as to perform weather forecasts and / or provide weather information that meets preset customized requirements through the target language model.

[0016] As a further technical solution, the augmentation module is further used to execute the following instructions: Determine at least one instruction included in each instruction data to be generated; Inputting each instruction and the input instance corresponding to each instruction into a preset model respectively, obtaining an output instance corresponding to each instruction, and obtaining a plurality of given instructions according to each instruction and the output instance corresponding to each instruction; Determine each given instruction and the task type of each given instruction, and determine the instance generation strategy corresponding to each given instruction according to the task type of each given instruction, and perform data augmentation on the corresponding given instruction according to the instance generation strategy corresponding to each given instruction, and obtain the instruction data set according to the augmentation result.

[0017] According to one aspect of the present invention specification, there is provided an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the large model fine-tuning method driven by adaptive instruction generation for the meteorological field.

[0018] According to one aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the steps of the large model fine-tuning method driven by adaptive instruction generation for the meteorological field.

[0019] Compared with the prior art, the present invention has the following beneficial effects: The present invention first constructs a traffic meteorology seed data set, then based on a preset adaptive instruction fine-tuning strategy, performs data augmentation on the traffic meteorology seed data set to obtain an instruction data set, and then based on a preset ChatGLM3-6B model and instruction data set, uses a preset low-rank adaptive strategy to fine-tune the pre-trained language model until the fine-tuned pre-trained language model reaches a preset performance condition, and obtains a target language model, so as to perform weather forecasts and / or provide weather information that meets preset customized requirements through the target language model. Thus, the present invention solves the problems that the related technology is difficult to create large-scale instruction data sets and consumes a lot of resources, and can fine-tune the large model by using automatically generated meteorological field instruction data, thereby improving the performance of the model in meteorological field tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief introduction is given below to the drawings used in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0021] Figure 1 A flowchart of a large model fine-tuning method driven by adaptive instruction generation for the meteorological field provided according to an embodiment of the present invention; Figure 2 A flowchart of data augmentation based on adaptive instruction fine-tuning according to one embodiment of the present invention; Figure 3 A flowchart of fine-tuning a pre-trained language model based on low-rank adaptation (LoRA) according to an embodiment of the present invention; Figure 4 It is a block diagram of a large model fine-tuning device driven by adaptive instruction generation for the meteorological field according to an embodiment of the present invention; Figure 5 FIG. 4 is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0022] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.

[0023] The following describes a large model fine-tuning method driven by adaptive instruction generation for the meteorological field according to an embodiment of the present invention with reference to the accompanying drawings. In view of the problems mentioned in the above background technology such as the difficulty in creating a large-scale instruction data set and the large resource consumption, the present invention provides a large model fine-tuning method driven by adaptive instruction generation for the meteorological field. In this method, based on a preset adaptive instruction fine-tuning strategy, data augmentation is performed on a traffic meteorological seed data set to obtain an instruction data set, and a pre-trained language model is fine-tuned using a preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches a preset performance condition, thereby obtaining a target language model to perform meteorological forecasts and / or provide meteorological information that meets preset customized requirements. Thus, the problems of the difficulty in creating a large-scale instruction data set and the large resource consumption in the related technology are solved, and the large model can be fine-tuned by using automatically generated meteorological field instruction data, thereby improving the performance of the model on meteorological field tasks.

[0024] Specifically, Figure 1 A flow chart of a large model fine-tuning method driven by adaptive instruction generation for the meteorological field provided by an embodiment of the present invention.

[0025] like Figure 1 As shown, the large model fine-tuning method driven by adaptive instruction generation for the meteorological field includes the following steps: In step S101, a traffic weather seed dataset is constructed.

[0026] Specifically, the traffic meteorology seed dataset of the embodiment of the present invention needs to integrate multi-dimensional data such as meteorological conditions, geographic information and time changes, and simulate real-world application scenarios to ensure the practicality and effectiveness of the model.

[0027] Optionally, to demonstrate the diverse potential of model fine-tuning, the present invention designs the following types of application scenario tasks: (1) Fact judgment task: Evaluate the accuracy of the model’s judgment on geographic and climate information.

[0028] (2) Extreme weather selection task: testing the model’s ability to identify extreme weather phenomena.

[0029] (3) Paragraph search task: simulates actual meteorological information query and requires the model to accurately find relevant paragraphs.

[0030] (4) Intent recognition task: predicting potential intentions through user discourse analysis, reflecting the consulting application capabilities of the model.

[0031] (5) Travel advice generation task: Generate practical travel advice based on specific meteorological conditions.

[0032] Furthermore, in some embodiments, constructing a traffic meteorology seed dataset includes: obtaining identifiers of multiple tasks, the name of each task, the task instruction of each task, the task type of each task, and a list of multiple task instances; constructing a traffic meteorology seed dataset based on the identifiers of multiple tasks, the name of each task, the task instruction of each task, the task type of each task, and a list of multiple task instances.

[0033] Specifically, the original and earliest defined batch of seed data (175) is actually text with a fixed field format. The unique identifier id of the task is used to distinguish different tasks. The name of the task briefly describes the main content of the task. The task instruction describes the objectives and requirements of the task in detail in natural language. The task instance list instances, each instance contains an input (input) and an output (output) pair, which is used to describe the specific execution case of the task. Among them, input refers to the input content of the instance, which can be a question, description, query, etc., which varies according to different task types; output refers to the correct output expected for a specific input, which can be a classification result, text generation content, etc. The task type is_classification of the task indicates whether the task is a classification task. When the Boolean value is_classification is true, it means that the task is a classification task. When the Boolean value is_classification is false, it means that the task is a generation task or other types.

[0034] In step S102, based on a preset adaptive instruction fine-tuning strategy, data augmentation is performed on the traffic meteorology seed data set to obtain an instruction data set.

[0035] Furthermore, in some embodiments, based on a preset adaptive instruction fine-tuning strategy, data augmentation is performed on a traffic meteorology seed data set to obtain an instruction data set, including: determining at least one instruction contained in each instruction data to be generated; inputting each instruction and the input instance corresponding to each instruction into a preset model respectively to obtain an output instance corresponding to each instruction, and obtaining multiple given instructions based on each instruction and the output instance corresponding to each instruction; determining each given instruction and the task type of each given instruction, and determining the instance generation strategy corresponding to each given instruction based on the task type of each given instruction, and performing data augmentation on the corresponding given instruction based on the instance generation strategy corresponding to each given instruction, and obtaining an instruction data set based on the augmentation result.

[0036] It should be noted that the present invention adopts the semi-automatic data augmentation method SELF-INSTRUCT and introduces the SELF-INSTRUCT framework. The SELF-INSTRUCT framework represents a cutting-edge natural language processing technology that aims to improve the model's ability to follow instructions through the data generated by the model itself. The core idea of ​​the SELF-INSTRUCT framework is to use the existing knowledge base of the pre-trained language model (such as the GPT series, BERT series, etc.) and its own powerful generation ability to bootstrap (Bootstrap) to generate new instructions and their corresponding input-output samples. This method mainly includes two parts: the definition of instruction data and the automatic generation of instruction data.

[0037] First, the definition of instruction data is introduced. The instruction data to be generated by the present invention includes a set of instructions , each instruction defines a set of tasks in natural language. t have Input and output examples:

[0038] in, For the task, is the sequence number of the input and output instance, For the input of the i-th instance of task t, is the target output of the i-th instance of task t, For the task The number of input and output instances.

[0039] Given a task instruction and corresponding input, the model is expected to produce the following output:

[0040] in, Produces output for the model, For the task, is the sequence number of the input and output instance, is the instruction of task t, For the input of the i-th instance of task t, The model predicts the output for the i-th instance of task t.

[0041] for In many cases, there is no strict boundary between instructions and instance inputs. For example, "write an article about school safety" can be a valid instruction that the model responds to directly, while it can also be formulated as "write an article about the following topic" as an instruction and "school safety" as an instance input. In order to encourage the diversity of data formats, the present invention allows instructions without additional input (i.e., X is empty).

[0042] Next, we introduce the automatic generation of instruction data. This paper uses the semi-automatic data augmentation method SELF-INSTRUCT to automatically generate instruction data. The SELF-INSTRUCT framework uses the powerful generation capabilities of the pre-trained language model to build a self-guided task generation and self-training pipeline. This innovative method allows the pre-trained language model to expand the scope and depth of its task execution through self-exploration and generation, and then enhance its ability to follow and respond to human instructions through a refined instruction adjustment process.

[0043] Combine the following Figure 2This paper introduces the process of data augmentation (i.e., automatic generation of instruction data) based on adaptive instruction fine-tuning.

[0044] like Figure 2 As shown, first, a series of new task instructions are generated from the large language model.

[0045] Specifically, SELF-INSTRUCT generates new instructions from a small set of human-written seed instructions in a guided manner. The present invention uses a task pool containing 175 tasks, each of which includes 1 instruction and 1 instance. In each step, the model extracts 8 task instructions from the task pool as context example references. Among these 8 instructions, 6 are from manually written tasks and 2 are from tasks generated by the model in the previous steps to promote task diversity.

[0046] Second, distinguish whether the task is a classification task.

[0047] Specifically, this step classifies the tasks. The present invention requires two different methods to handle classified tasks and non-classified tasks. Next, it is determined whether the generated instructions represent classified tasks. Using the 12 classified instructions and 19 non-classified instructions in the seed task, the language model is guided to determine whether the newly generated instructions belong to classified tasks in a small number of prompts.

[0048] Again, for each generated instruction, the framework further generates corresponding input-output instances.

[0049] Specifically, after getting the given instruction and its task type, an instance is generated independently for each instruction. For generative tasks, the input-first approach can be used to require the language model to first propose input fields according to the instruction, and then generate the corresponding output. This generation order is similar to the way the model responds to instructions and inputs, but context examples from other tasks are used here. For classification tasks, the output-first approach is used, that is, possible class labels are generated first, and then input is generated based on the conditions of each class label.

[0050] Finally, the generated samples are filtered through a series of heuristic strategies to eliminate invalid instances or those that are highly similar to existing samples.

[0051] Specifically, in order to ensure the diversity and quality of generated data, the present invention sets some filtering conditions. For example, a new instruction is added to the task pool only when the similarity between the new instruction and the existing instruction (which can be measured by ROUGE-L) is less than 0.7. In addition, since some keywords are usually not processed by the language model, the present invention also excludes instructions containing certain specific keywords (such as eg, image, picture, graph). At the same time, when generating a new instance for each instruction, it also filters out exactly the same instances or instances with the same input but different outputs, and identifies and filters out invalid generation based on heuristic methods (such as instructions that are too long or too short, and instance outputs that repeat the input), thereby ensuring that the generated tasks and instances are of high quality and useful.

[0052] Furthermore, in some embodiments, the instance generation strategy is determined according to the multi-task type of each instruction, including: if the task type is a generation task, the input priority method is used as the instance generation strategy; if the task type is a classification task, the output priority method is used as the instance generation strategy.

[0053] Specifically, different generation strategies are adopted according to the task type of the instruction. For generation tasks, the input-first method is used, that is, the input field is determined first, and then the corresponding output is generated. For classification tasks, the output-first method is adopted, that is, the possible classification labels are determined first, and then the corresponding input is generated according to these labels.

[0054] In step S103, based on the preset ChatGLM3-6B model and instruction data set, the pre-trained language model is fine-tuned using the preset low-rank adaptive strategy until the fine-tuned pre-trained language model meets the preset performance conditions, and the target language model is obtained to perform weather forecasts and / or provide weather information that meets preset customized requirements through the target language model.

[0055] It should be noted that the present invention uses ChatGLM3-6B as the base model for the instruction fine-tuning stage. ChatGLM3-6B is a large-scale conversational language model developed by Zhipu AI. It is based on the Transformer architecture and has 6.2 billion parameters. ChatGLM3-6B uses similar technology to ChatGPT and is optimized for Chinese question-answering and dialogue. The core idea of ​​instruction fine-tuning is to build a large-scale data set containing various task instructions, and each sample format is "instruction + input" and "target output". Based on this instruction data set, the pre-trained model is fine-tuned in a supervised learning manner. The goal is to enable the model to learn to correctly map different task instructions to the desired output behavior. Among them, the fine-tuning process has three steps: data preprocessing, LoRA module deployment, and model training.

[0056] Specifically, the large language model used in the present invention is based on ChatGLM3-6B, and is trained on a pre-constructed meteorological question-and-answer dataset in the form of instruction fine-tuning according to the data characteristics and problem requirements in the field of meteorology and transportation. Through this process, the model can learn the relevant knowledge and question-and-answer style in the field of meteorology and transportation, better understand human instructions, and improve the question-and-answer effect. The model training uses the LoRA method to further reduce the training overhead. While adapting to the field of meteorology and transportation, this method also retains the conversation ability and knowledge reserve of the original language model as much as possible. Through fine-tuning training of domain-specific data, the generative language model can provide more suitable services for vertical fields.

[0057] Combine the following Figure 3 This paper introduces the process of fine-tuning the pre-trained language model based on low-rank adaptive LoRA.

[0058] like Figure 3 As shown, first, the original instruction data is preprocessed before training and converted into the unified question-answer text format of ChatGLM3.

[0059] Secondly, the preprocessed text is input into ChatGLM3 to obtain the output text vector.

[0060] Finally, the loss of the output vector text vector and the target text vector is calculated, and the pre-trained language model is fine-tuned using the LoRA technique.

[0061] Furthermore, in some embodiments, based on the preset ChatGLM3-6B model and instruction data set, the pre-trained language model is fine-tuned using a preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches the preset performance conditions to obtain a target language model, including: inputting the instruction data set into the preset ChatGLM3-6B model to obtain an output text vector; calculating the loss between the output text vector and the target text vector, and based on the calculation result, fine-tuning the pre-trained language model using the preset low-rank adaptive strategy, and determining whether the fine-tuned pre-trained language model reaches the preset performance conditions; if the fine-tuned pre-trained language model reaches the preset performance conditions, the fine-tuned pre-trained language model is used as the target language model, otherwise, adjusting the parameters of the preset low-rank adaptive strategy, and re-executing the step of fine-tuning the pre-trained language model using the preset low-rank adaptive strategy until the new fine-tuned pre-trained language model reaches the preset performance conditions to obtain the target language model.

[0062] Among them, in some embodiments, before inputting the instruction data set into the preset ChatGLM3-6B model, it also includes: preprocessing the instruction data set to obtain an instruction data set that meets the preset ChatGLM3-6B model question and answer text format.

[0063] It should be noted that the instruction question-answering dataset constructed by the data augmentation module based on adaptive instruction fine-tuning is stored in the jsonl file format, and the single-line data is stored in the json data format, which contains three parts: instruction, input, and target output. Before training, the original instruction data needs to be preprocessed and converted into the unified question-answering text format of ChatGLM3, and the processed data is converted into the input form acceptable to the language model: input tensor (input_ids), attention mask (attn_mask), label (labels).

[0064] Specifically, in the data preprocessing stage, data is first read line by line from the original data file, and each line is a Python dictionary object containing key fields such as instructions, inputs, and target outputs. Next, the context is constructed by concatenating the preset prompt text, the special tag "[gMASK]sop", the user prompt, and the instructions and inputs, while the target is composed of the assistant input prompt and the target output. The model's tokenizer is used to convert these texts into token sequences, and terminators (eos) are added at the end of the sequences. For sequences that exceed the preset maximum length, appropriate truncation or discarding is performed. Then, the start and end positions of the target in the complete token sequence are calculated, and the input tensor (input_ids), attention mask (attn_mask) and labels (labels) are constructed, where the labels of the non-target parts are marked with a special value of -100 to indicate that these parts are not included in the loss calculation. Finally, in order to ensure that the input length of the same batch of training samples is consistent, the three tensors are properly completed, so that the entire preprocessing process not only structures the data to meet the model requirements, but also optimizes the efficiency and effect of model training.

[0065] Furthermore, the preprocessed text is fed into the ChatGLM3 model, where the generated input tensors (input_ids), attention masks (attn_mask), and labels (labels) are first provided to the model. ChatGLM3 processes these inputs through its internal multi-layer Transformer structure, using attention mechanisms and neural network components for feature extraction and learning. After processing, the model outputs a text vector.

[0066] Furthermore, the loss between the output text vector generated by the ChatGLM3 model and the predefined target text vector is calculated, which is usually implemented using a loss function such as cross entropy loss or mean squared error, in order to quantify the error between the model output and the actual expected output. Next, the pre-trained language model is fine-tuned using LoRA technology.

[0067] Among them, in the fine-tuning process, the parameters of LoRA such as scaling factor, dropout rate and rank are set to meet specific needs. Specifically, the present invention uses the peft package of Huggingface to load the LoRA module in the model. In actual training, the scaling factor (alpha) of LoRA is set to 32, the dropout rate is 0.1, and the rank of LoRA is 8 by default. It is specified that the query / key / value mapping matrix of the model Transformer is fine-tuned by LoRA, and the bias is not fine-tuned by LoRA, only the weight matrix is ​​fine-tuned.

[0068] Furthermore, the network weights are updated through back-propagation and using optimizers such as AdamW. The whole process is iterated in multiple training cycles until the fine-tuned pre-trained language model reaches the preset performance conditions and the target language model is obtained.

[0069] Exemplarily, the present invention uses a multi-card parallelization method and uses the Accelerate package to perform data parallel training on four Nvidia V100 32GB graphics cards. AdamW is used as the optimizer for training, and in order to improve the stability of training and reduce the risk of gradient explosion, the present invention does not apply weight decay regularization to the bias and layer normalization weight parameters.

[0070] According to the large model fine-tuning method driven by adaptive instruction generation for the meteorological field according to the embodiment of the present invention, data augmentation is performed on the traffic meteorological seed data set based on the preset adaptive instruction fine-tuning strategy to obtain the instruction data set, and the pre-trained language model is fine-tuned using the preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches the preset performance conditions, and the target language model is obtained to perform meteorological forecasts and / or provide meteorological information that meets the preset customized requirements. Thus, the problems that the related technology is difficult to create large-scale instruction data sets and consumes a lot of resources are solved, and the large model can be fine-tuned by using the automatically generated meteorological field instruction data, thereby improving the performance of the model on meteorological tasks.

[0071] Next, the large model fine-tuning device driven by adaptive instruction generation for the meteorological field proposed in accordance with an embodiment of the present invention will be described with reference to the accompanying drawings.

[0072] Figure 4 It is a block diagram of a large model fine-tuning device driven by adaptive instruction generation for the meteorological field according to an embodiment of the present invention.

[0073] like Figure 4As shown, the large model fine-tuning device 10 driven by adaptive instruction generation for the meteorological field includes: a construction module 100, an augmentation module 200 and a fine-tuning module 300.

[0074] Among them, the construction module 100 is used to construct a traffic meteorology seed data set; the augmentation module 200 is used to perform data augmentation on the traffic meteorology seed data set based on a preset adaptive instruction fine-tuning strategy to obtain an instruction data set; the fine-tuning module 300 is used to fine-tune the pre-trained language model based on the preset ChatGLM3-6B model and instruction data set using a preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches the preset performance conditions, thereby obtaining a target language model, so as to perform weather forecasting and / or provide weather information that meets preset customized requirements through the target language model.

[0075] Furthermore, in some embodiments, the augmentation module 200 is used to: determine at least one instruction contained in each instruction data to be generated; input each instruction and the input instance corresponding to each instruction into a preset model respectively to obtain the output instance corresponding to each instruction, and obtain multiple given instructions based on each instruction and the output instance corresponding to each instruction; determine each given instruction and the task type of each given instruction, and determine the instance generation strategy corresponding to each given instruction based on the task type of each given instruction, and perform data augmentation on the corresponding given instruction based on the instance generation strategy corresponding to each given instruction, and obtain an instruction data set based on the augmentation result.

[0076] Furthermore, in some embodiments, the augmentation module 200 is used to: if the task type is a generation task, use the input priority method as the instance generation strategy; if the task type is a classification task, use the output priority method as the instance generation strategy.

[0077] Furthermore, in some embodiments, the fine-tuning module 300 is used to: input the instruction data set into the preset ChatGLM3-6B model to obtain an output text vector; calculate the loss between the output text vector and the target text vector, and based on the calculation result, use the preset low-rank adaptive strategy to fine-tune the pre-trained language model, and determine whether the fine-tuned pre-trained language model meets the preset performance conditions; if the fine-tuned pre-trained language model meets the preset performance conditions, the fine-tuned pre-trained language model is used as the target language model, otherwise, the parameters of the preset low-rank adaptive strategy are adjusted, and the step of fine-tuning the pre-trained language model using the preset low-rank adaptive strategy is re-executed until the new fine-tuned pre-trained language model meets the preset performance conditions to obtain the target language model.

[0078] Furthermore, in some embodiments, before inputting the instruction data set into the preset ChatGLM3-6B model, the fine-tuning module 300 is also used to: pre-process the instruction data set to obtain an instruction data set that satisfies the preset ChatGLM3-6B model question and answer text format.

[0079] Furthermore, in some embodiments, the construction module 100 is used to: obtain identifiers of multiple tasks, the name of each task, the task instructions of each task, the task type of each task and a list of multiple task instances; and construct a traffic meteorology seed dataset based on the identifiers of multiple tasks, the name of each task, the task instructions of each task, the task type of each task and a list of multiple task instances.

[0080] It should be noted that the above explanation of the embodiment of the large model fine-tuning method driven by adaptive instruction generation for the meteorological field is also applicable to the large model fine-tuning device driven by adaptive instruction generation for the meteorological field of this embodiment, and will not be repeated here.

[0081] According to the large model fine-tuning device driven by adaptive instruction generation for the meteorological field according to the embodiment of the present invention, based on the preset adaptive instruction fine-tuning strategy, the traffic meteorological seed data set is augmented to obtain the instruction data set, and the pre-trained language model is fine-tuned using the preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches the preset performance conditions, and the target language model is obtained to perform weather forecasts and / or provide weather information that meets the preset customized requirements. Thus, the problems that the related technology is difficult to create large-scale instruction data sets and consumes a lot of resources are solved, and the large model can be fine-tuned by using the automatically generated meteorological field instruction data, thereby improving the performance of the model in meteorological field tasks.

[0082] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. The electronic device may include: A memory 501 , a processor 502 , and a computer program stored in the memory 501 and executable on the processor 502 .

[0083] When the processor 502 executes the program, the large model fine-tuning method driven by adaptive instruction generation for the meteorological field provided in the above embodiment is implemented.

[0084] Furthermore, the electronic device further comprises: The communication interface 503 is used for communication between the memory 501 and the processor 502 .

[0085] The memory 501 is used to store computer programs that can be executed on the processor 502 .

[0086] The memory 501 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0087] If the memory 501, the processor 502 and the communication interface 503 are implemented independently, the communication interface 503, the memory 501 and the processor 502 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0088] Optionally, in a specific implementation, if the memory 501, the processor 502 and the communication interface 503 are integrated on a chip, the memory 501, the processor 502 and the communication interface 503 can communicate with each other through an internal interface.

[0089] The processor 502 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.

[0090] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned large model fine-tuning method driven by adaptive instruction generation for the meteorological field.

[0091] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0092] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0093] Although the embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. Those skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention. Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the technical solutions of the embodiments of the present invention.

Claims

1. A large model fine-tuning method driven by adaptive instruction generation for the meteorological field, characterized in that: include: Construct traffic meteorology seed dataset; Based on a preset adaptive instruction fine-tuning strategy, data augmentation is performed on the traffic meteorology seed data set to obtain an instruction data set; Based on the preset ChatGLM3-6B model and the instruction data set, the pre-trained language model is fine-tuned using the preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches the preset performance conditions, thereby obtaining a target language model, so as to perform weather forecasts and / or provide weather information that meets preset customized requirements through the target language model.

2. The large model fine-tuning method driven by adaptive instruction generation for the meteorological field according to claim 1 is characterized in that: Based on the preset adaptive instruction fine-tuning strategy, the traffic meteorology seed data set is augmented to obtain an instruction data set, including: Determine at least one instruction included in each instruction data to be generated; Inputting each instruction and the input instance corresponding to each instruction into a preset model respectively, obtaining an output instance corresponding to each instruction, and obtaining a plurality of given instructions according to each instruction and the output instance corresponding to each instruction; Determine each given instruction and the task type of each given instruction, and determine the instance generation strategy corresponding to each given instruction according to the task type of each given instruction, and perform data augmentation on the corresponding given instruction according to the instance generation strategy corresponding to each given instruction, and obtain the instruction data set according to the augmentation result.

3. The large model fine-tuning method driven by adaptive instruction generation for the meteorological field according to claim 2 is characterized in that: Determining, according to the task type of each given instruction, an instance generation strategy corresponding to each given instruction, includes: If the task type is a generation task, the input priority method is used as the instance generation strategy; If the task type is a classification task, the output priority method is used as the instance generation strategy.

4. The large model fine-tuning method driven by adaptive instruction generation for the meteorological field according to claim 1 is characterized in that: Based on the preset ChatGLM3-6B model and the instruction data set, the pre-trained language model is fine-tuned using a preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches a preset performance condition, thereby obtaining a target language model, including: Input the instruction data set into the preset ChatGLM3-6B model to obtain an output text vector; Calculating the loss between the output text vector and the target text vector, and based on the calculation result, fine-tuning the pre-trained language model using the preset low-rank adaptive strategy, and determining whether the fine-tuned pre-trained language model meets the preset performance condition; If the fine-tuned pre-trained language model meets the preset performance conditions, the fine-tuned pre-trained language model is used as the target language model; otherwise, the parameters of the preset low-rank adaptive strategy are adjusted, and the step of fine-tuning the pre-trained language model using the preset low-rank adaptive strategy is re-executed until the new fine-tuned pre-trained language model meets the preset performance conditions, thereby obtaining the target language model.

5. The large model fine-tuning method driven by adaptive instruction generation for the meteorological field according to claim 4 is characterized in that: Before inputting the instruction data set into the preset ChatGLM3-6B model, it also includes: The instruction data set is preprocessed to obtain an instruction data set that meets the preset ChatGLM3-6B model question and answer text format.

6. The large model fine-tuning method driven by adaptive instruction generation for the meteorological field according to claim 1 is characterized in that: Construct a traffic weather seed dataset, including: Obtain identifiers of multiple tasks, a name of each task, a task instruction of each task, a task type of each task, and a list of multiple task instances; The traffic meteorology seed dataset is constructed according to the identifiers of the multiple tasks, the name of each task, the task instruction of each task, the task type of each task and the multiple task instance lists.

7. A large model fine-tuning device driven by adaptive instruction generation for the meteorological field, characterized in that: include: Construction module, used to construct traffic meteorology seed dataset; An augmentation module, used for augmenting the traffic meteorology seed data set based on a preset adaptive instruction fine-tuning strategy to obtain an instruction data set; The fine-tuning module is used to fine-tune the pre-trained language model based on the preset ChatGLM3-6B model and the instruction data set using a preset low-rank adaptive strategy until the fine-tuned pre-trained language model reaches the preset performance conditions, thereby obtaining a target language model, so as to perform weather forecasts and / or provide weather information that meets preset customized requirements through the target language model.

8. The large model fine-tuning device driven by adaptive instruction generation for the meteorological field according to claim 7 is characterized in that: The augmentation module is also used to execute the following instructions: Determine at least one instruction included in each instruction data to be generated; Inputting each instruction and the input instance corresponding to each instruction into a preset model respectively, obtaining an output instance corresponding to each instruction, and obtaining a plurality of given instructions according to each instruction and the output instance corresponding to each instruction; Determine each given instruction and the task type of each given instruction, and determine the instance generation strategy corresponding to each given instruction according to the task type of each given instruction, and perform data augmentation on the corresponding given instruction according to the instance generation strategy corresponding to each given instruction, and obtain the instruction data set according to the augmentation result.

9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the large model fine-tuning method driven by adaptive instruction generation for the meteorological field as described in any one of claims 1 to 6.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the steps of a large model fine-tuning method driven by adaptive instruction generation for the meteorological field as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Generation method and device of instruction fine tuning data, equipment and medium

    CN116861928A

  • Banking industry large language model training method

    CN117217289A

  • Data construction method and device for fine tuning training of large language model

    CN118035751A

  • Marketing text generation method and device, electronic equipment and storage medium

    CN118350348A

  • Large language model fine tuning method and device, electronic equipment and readable storage medium

    CN118396033A

Cited By

  • Self-adaptive transformer substation noise on-line monitoring method and system based on large model fine tuning

    CN121306202A

  • Meteorological service multi-modal large model construction method and device

    CN121661458A